@devicai/ui 0.57.0 → 0.59.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 (223) hide show
  1. package/README.md +186 -0
  2. package/dist/cjs/api/assistantInfo.js.map +1 -1
  3. package/dist/cjs/api/client.js +17 -1
  4. package/dist/cjs/api/client.js.map +1 -1
  5. package/dist/cjs/api/types.js.map +1 -1
  6. package/dist/cjs/components/AICommandBar/AICommandBar.js +12 -8
  7. package/dist/cjs/components/AICommandBar/AICommandBar.js.map +1 -1
  8. package/dist/cjs/components/AICommandBar/useAICommandBar.js +12 -6
  9. package/dist/cjs/components/AICommandBar/useAICommandBar.js.map +1 -1
  10. package/dist/cjs/components/AIElementWrapper/AIElementWrapper.js +19 -15
  11. package/dist/cjs/components/AIElementWrapper/AIElementWrapper.js.map +1 -1
  12. package/dist/cjs/components/AIElementWrapper/activeWrapperRegistry.js.map +1 -1
  13. package/dist/cjs/components/AIElementWrapper/useAIElementWrapper.js +12 -6
  14. package/dist/cjs/components/AIElementWrapper/useAIElementWrapper.js.map +1 -1
  15. package/dist/cjs/components/AIGenerationButton/AIGenerationButton.js +13 -7
  16. package/dist/cjs/components/AIGenerationButton/AIGenerationButton.js.map +1 -1
  17. package/dist/cjs/components/AIGenerationButton/useAIGenerationButton.js +11 -5
  18. package/dist/cjs/components/AIGenerationButton/useAIGenerationButton.js.map +1 -1
  19. package/dist/cjs/components/ChatDrawer/ChatDrawer.js +28 -13
  20. package/dist/cjs/components/ChatDrawer/ChatDrawer.js.map +1 -1
  21. package/dist/cjs/components/ChatDrawer/ChatInput.js +21 -15
  22. package/dist/cjs/components/ChatDrawer/ChatInput.js.map +1 -1
  23. package/dist/cjs/components/ChatDrawer/ChatMessages.js +54 -13
  24. package/dist/cjs/components/ChatDrawer/ChatMessages.js.map +1 -1
  25. package/dist/cjs/components/ChatDrawer/CompactionWidget.js +13 -4
  26. package/dist/cjs/components/ChatDrawer/CompactionWidget.js.map +1 -1
  27. package/dist/cjs/components/ChatDrawer/ConversationSelector.js +6 -4
  28. package/dist/cjs/components/ChatDrawer/ConversationSelector.js.map +1 -1
  29. package/dist/cjs/components/ChatDrawer/ErrorBoundary.js.map +1 -1
  30. package/dist/cjs/components/ChatDrawer/GuardrailNotice.js +40 -0
  31. package/dist/cjs/components/ChatDrawer/GuardrailNotice.js.map +1 -0
  32. package/dist/cjs/components/ChatDrawer/HandoffSubagentWidget.js +3 -1
  33. package/dist/cjs/components/ChatDrawer/HandoffSubagentWidget.js.map +1 -1
  34. package/dist/cjs/components/ChatDrawer/LimitBanner.js +19 -9
  35. package/dist/cjs/components/ChatDrawer/LimitBanner.js.map +1 -1
  36. package/dist/cjs/components/ChatDrawer/QueueNotice.js +19 -7
  37. package/dist/cjs/components/ChatDrawer/QueueNotice.js.map +1 -1
  38. package/dist/cjs/components/ChatDrawer/RecalledMemoriesWidget.js +17 -5
  39. package/dist/cjs/components/ChatDrawer/RecalledMemoriesWidget.js.map +1 -1
  40. package/dist/cjs/components/ChatDrawer/ReferenceChip.js +3 -1
  41. package/dist/cjs/components/ChatDrawer/ReferenceChip.js.map +1 -1
  42. package/dist/cjs/components/ChatDrawer/ToolTimeline.js.map +1 -1
  43. package/dist/cjs/components/ChatDrawer/UsageBar.js +23 -18
  44. package/dist/cjs/components/ChatDrawer/UsageBar.js.map +1 -1
  45. package/dist/cjs/components/ChatDrawer/pastedText.js.map +1 -1
  46. package/dist/cjs/components/CoreMemoryModal/CoreMemoryModal.js +20 -9
  47. package/dist/cjs/components/CoreMemoryModal/CoreMemoryModal.js.map +1 -1
  48. package/dist/cjs/components/Feedback/FeedbackModal.js +5 -1
  49. package/dist/cjs/components/Feedback/FeedbackModal.js.map +1 -1
  50. package/dist/cjs/components/Feedback/MessageActions.js +3 -1
  51. package/dist/cjs/components/Feedback/MessageActions.js.map +1 -1
  52. package/dist/cjs/components/IntegrationsModal/ConnectFieldsForm.js +12 -8
  53. package/dist/cjs/components/IntegrationsModal/ConnectFieldsForm.js.map +1 -1
  54. package/dist/cjs/components/IntegrationsModal/IntegrationLogo.js.map +1 -1
  55. package/dist/cjs/components/IntegrationsModal/IntegrationsHint.js +5 -3
  56. package/dist/cjs/components/IntegrationsModal/IntegrationsHint.js.map +1 -1
  57. package/dist/cjs/components/IntegrationsModal/IntegrationsLauncher.js +12 -3
  58. package/dist/cjs/components/IntegrationsModal/IntegrationsLauncher.js.map +1 -1
  59. package/dist/cjs/components/IntegrationsModal/IntegrationsModal.js.map +1 -1
  60. package/dist/cjs/components/IntegrationsModal/IntegrationsPanel.js +34 -24
  61. package/dist/cjs/components/IntegrationsModal/IntegrationsPanel.js.map +1 -1
  62. package/dist/cjs/components/IntegrationsModal/IntegrationsToggle.js +15 -6
  63. package/dist/cjs/components/IntegrationsModal/IntegrationsToggle.js.map +1 -1
  64. package/dist/cjs/components/IntegrationsModal/McpConnectForm.js +15 -7
  65. package/dist/cjs/components/IntegrationsModal/McpConnectForm.js.map +1 -1
  66. package/dist/cjs/components/IntegrationsModal/McpServersSection.js +32 -19
  67. package/dist/cjs/components/IntegrationsModal/McpServersSection.js.map +1 -1
  68. package/dist/cjs/components/IntegrationsModal/integrationChoice.js.map +1 -1
  69. package/dist/cjs/components/IntegrationsModal/useIntegrations.js +3 -1
  70. package/dist/cjs/components/IntegrationsModal/useIntegrations.js.map +1 -1
  71. package/dist/cjs/components/IntegrationsModal/useTenantMcp.js +3 -1
  72. package/dist/cjs/components/IntegrationsModal/useTenantMcp.js.map +1 -1
  73. package/dist/cjs/components/ThreadStateTag/ThreadStateTag.js +63 -40
  74. package/dist/cjs/components/ThreadStateTag/ThreadStateTag.js.map +1 -1
  75. package/dist/cjs/components/theme.js.map +1 -1
  76. package/dist/cjs/hooks/useDevicChat.js +21 -7
  77. package/dist/cjs/hooks/useDevicChat.js.map +1 -1
  78. package/dist/cjs/hooks/useModelInterface.js.map +1 -1
  79. package/dist/cjs/hooks/usePolling.js +117 -7
  80. package/dist/cjs/hooks/usePolling.js.map +1 -1
  81. package/dist/cjs/hooks/useSpeechRecording.js +8 -4
  82. package/dist/cjs/hooks/useSpeechRecording.js.map +1 -1
  83. package/dist/cjs/i18n/translate.js +48 -0
  84. package/dist/cjs/i18n/translate.js.map +1 -0
  85. package/dist/cjs/i18n/useTranslations.js +57 -0
  86. package/dist/cjs/i18n/useTranslations.js.map +1 -0
  87. package/dist/cjs/index.js +11 -0
  88. package/dist/cjs/index.js.map +1 -1
  89. package/dist/cjs/provider/DevicContext.js.map +1 -1
  90. package/dist/cjs/provider/DevicProvider.js +5 -1
  91. package/dist/cjs/provider/DevicProvider.js.map +1 -1
  92. package/dist/cjs/provider/sharedSession.js.map +1 -1
  93. package/dist/cjs/styles.css +1 -1
  94. package/dist/cjs/utils/avatar.js.map +1 -1
  95. package/dist/cjs/utils/consumeChatStream.js +44 -0
  96. package/dist/cjs/utils/consumeChatStream.js.map +1 -0
  97. package/dist/cjs/utils/index.js.map +1 -1
  98. package/dist/cjs/utils/logger.js.map +1 -1
  99. package/dist/cjs/utils/toolGroups.js.map +1 -1
  100. package/dist/esm/api/assistantInfo.js.map +1 -1
  101. package/dist/esm/api/client.d.ts +5 -1
  102. package/dist/esm/api/client.js +17 -1
  103. package/dist/esm/api/client.js.map +1 -1
  104. package/dist/esm/api/types.d.ts +12 -1
  105. package/dist/esm/api/types.js.map +1 -1
  106. package/dist/esm/components/AICommandBar/AICommandBar.js +13 -9
  107. package/dist/esm/components/AICommandBar/AICommandBar.js.map +1 -1
  108. package/dist/esm/components/AICommandBar/AICommandBar.types.d.ts +16 -0
  109. package/dist/esm/components/AICommandBar/useAICommandBar.d.ts +2 -0
  110. package/dist/esm/components/AICommandBar/useAICommandBar.js +13 -7
  111. package/dist/esm/components/AICommandBar/useAICommandBar.js.map +1 -1
  112. package/dist/esm/components/AIElementWrapper/AIElementWrapper.js +19 -15
  113. package/dist/esm/components/AIElementWrapper/AIElementWrapper.js.map +1 -1
  114. package/dist/esm/components/AIElementWrapper/AIElementWrapper.types.d.ts +16 -0
  115. package/dist/esm/components/AIElementWrapper/activeWrapperRegistry.js.map +1 -1
  116. package/dist/esm/components/AIElementWrapper/useAIElementWrapper.d.ts +2 -0
  117. package/dist/esm/components/AIElementWrapper/useAIElementWrapper.js +13 -7
  118. package/dist/esm/components/AIElementWrapper/useAIElementWrapper.js.map +1 -1
  119. package/dist/esm/components/AIGenerationButton/AIGenerationButton.js +14 -8
  120. package/dist/esm/components/AIGenerationButton/AIGenerationButton.js.map +1 -1
  121. package/dist/esm/components/AIGenerationButton/AIGenerationButton.types.d.ts +16 -0
  122. package/dist/esm/components/AIGenerationButton/useAIGenerationButton.d.ts +2 -0
  123. package/dist/esm/components/AIGenerationButton/useAIGenerationButton.js +12 -6
  124. package/dist/esm/components/AIGenerationButton/useAIGenerationButton.js.map +1 -1
  125. package/dist/esm/components/ChatDrawer/ChatDrawer.js +29 -14
  126. package/dist/esm/components/ChatDrawer/ChatDrawer.js.map +1 -1
  127. package/dist/esm/components/ChatDrawer/ChatDrawer.types.d.ts +41 -0
  128. package/dist/esm/components/ChatDrawer/ChatInput.js +21 -15
  129. package/dist/esm/components/ChatDrawer/ChatInput.js.map +1 -1
  130. package/dist/esm/components/ChatDrawer/ChatMessages.d.ts +1 -1
  131. package/dist/esm/components/ChatDrawer/ChatMessages.js +54 -13
  132. package/dist/esm/components/ChatDrawer/ChatMessages.js.map +1 -1
  133. package/dist/esm/components/ChatDrawer/CompactionWidget.js +13 -4
  134. package/dist/esm/components/ChatDrawer/CompactionWidget.js.map +1 -1
  135. package/dist/esm/components/ChatDrawer/ConversationSelector.js +6 -4
  136. package/dist/esm/components/ChatDrawer/ConversationSelector.js.map +1 -1
  137. package/dist/esm/components/ChatDrawer/ErrorBoundary.js.map +1 -1
  138. package/dist/esm/components/ChatDrawer/GuardrailNotice.d.ts +36 -0
  139. package/dist/esm/components/ChatDrawer/GuardrailNotice.js +38 -0
  140. package/dist/esm/components/ChatDrawer/GuardrailNotice.js.map +1 -0
  141. package/dist/esm/components/ChatDrawer/HandoffSubagentWidget.js +3 -1
  142. package/dist/esm/components/ChatDrawer/HandoffSubagentWidget.js.map +1 -1
  143. package/dist/esm/components/ChatDrawer/LimitBanner.js +19 -9
  144. package/dist/esm/components/ChatDrawer/LimitBanner.js.map +1 -1
  145. package/dist/esm/components/ChatDrawer/QueueNotice.js +19 -7
  146. package/dist/esm/components/ChatDrawer/QueueNotice.js.map +1 -1
  147. package/dist/esm/components/ChatDrawer/RecalledMemoriesWidget.js +17 -5
  148. package/dist/esm/components/ChatDrawer/RecalledMemoriesWidget.js.map +1 -1
  149. package/dist/esm/components/ChatDrawer/ReferenceChip.js +3 -1
  150. package/dist/esm/components/ChatDrawer/ReferenceChip.js.map +1 -1
  151. package/dist/esm/components/ChatDrawer/ToolTimeline.js.map +1 -1
  152. package/dist/esm/components/ChatDrawer/UsageBar.js +23 -18
  153. package/dist/esm/components/ChatDrawer/UsageBar.js.map +1 -1
  154. package/dist/esm/components/ChatDrawer/index.d.ts +2 -0
  155. package/dist/esm/components/ChatDrawer/pastedText.js.map +1 -1
  156. package/dist/esm/components/CoreMemoryModal/CoreMemoryModal.js +20 -9
  157. package/dist/esm/components/CoreMemoryModal/CoreMemoryModal.js.map +1 -1
  158. package/dist/esm/components/Feedback/FeedbackModal.js +5 -1
  159. package/dist/esm/components/Feedback/FeedbackModal.js.map +1 -1
  160. package/dist/esm/components/Feedback/MessageActions.js +3 -1
  161. package/dist/esm/components/Feedback/MessageActions.js.map +1 -1
  162. package/dist/esm/components/IntegrationsModal/ConnectFieldsForm.js +12 -8
  163. package/dist/esm/components/IntegrationsModal/ConnectFieldsForm.js.map +1 -1
  164. package/dist/esm/components/IntegrationsModal/IntegrationLogo.js.map +1 -1
  165. package/dist/esm/components/IntegrationsModal/IntegrationsHint.js +5 -3
  166. package/dist/esm/components/IntegrationsModal/IntegrationsHint.js.map +1 -1
  167. package/dist/esm/components/IntegrationsModal/IntegrationsLauncher.js +12 -3
  168. package/dist/esm/components/IntegrationsModal/IntegrationsLauncher.js.map +1 -1
  169. package/dist/esm/components/IntegrationsModal/IntegrationsModal.js.map +1 -1
  170. package/dist/esm/components/IntegrationsModal/IntegrationsPanel.d.ts +1 -1
  171. package/dist/esm/components/IntegrationsModal/IntegrationsPanel.js +34 -24
  172. package/dist/esm/components/IntegrationsModal/IntegrationsPanel.js.map +1 -1
  173. package/dist/esm/components/IntegrationsModal/IntegrationsToggle.d.ts +1 -1
  174. package/dist/esm/components/IntegrationsModal/IntegrationsToggle.js +15 -6
  175. package/dist/esm/components/IntegrationsModal/IntegrationsToggle.js.map +1 -1
  176. package/dist/esm/components/IntegrationsModal/McpConnectForm.js +15 -7
  177. package/dist/esm/components/IntegrationsModal/McpConnectForm.js.map +1 -1
  178. package/dist/esm/components/IntegrationsModal/McpServersSection.js +32 -19
  179. package/dist/esm/components/IntegrationsModal/McpServersSection.js.map +1 -1
  180. package/dist/esm/components/IntegrationsModal/integrationChoice.js.map +1 -1
  181. package/dist/esm/components/IntegrationsModal/useIntegrations.js +3 -1
  182. package/dist/esm/components/IntegrationsModal/useIntegrations.js.map +1 -1
  183. package/dist/esm/components/IntegrationsModal/useTenantMcp.js +3 -1
  184. package/dist/esm/components/IntegrationsModal/useTenantMcp.js.map +1 -1
  185. package/dist/esm/components/ThreadStateTag/ThreadStateTag.js +63 -40
  186. package/dist/esm/components/ThreadStateTag/ThreadStateTag.js.map +1 -1
  187. package/dist/esm/components/theme.js.map +1 -1
  188. package/dist/esm/hooks/index.d.ts +1 -1
  189. package/dist/esm/hooks/useDevicChat.d.ts +6 -0
  190. package/dist/esm/hooks/useDevicChat.js +23 -9
  191. package/dist/esm/hooks/useDevicChat.js.map +1 -1
  192. package/dist/esm/hooks/useModelInterface.js.map +1 -1
  193. package/dist/esm/hooks/usePolling.d.ts +35 -0
  194. package/dist/esm/hooks/usePolling.js +114 -8
  195. package/dist/esm/hooks/usePolling.js.map +1 -1
  196. package/dist/esm/hooks/useSpeechRecording.js +8 -4
  197. package/dist/esm/hooks/useSpeechRecording.js.map +1 -1
  198. package/dist/esm/i18n/index.d.ts +4 -0
  199. package/dist/esm/i18n/translate.d.ts +23 -0
  200. package/dist/esm/i18n/translate.js +43 -0
  201. package/dist/esm/i18n/translate.js.map +1 -0
  202. package/dist/esm/i18n/types.d.ts +27 -0
  203. package/dist/esm/i18n/useTranslations.d.ts +32 -0
  204. package/dist/esm/i18n/useTranslations.js +53 -0
  205. package/dist/esm/i18n/useTranslations.js.map +1 -0
  206. package/dist/esm/index.d.ts +4 -2
  207. package/dist/esm/index.js +3 -0
  208. package/dist/esm/index.js.map +1 -1
  209. package/dist/esm/provider/DevicContext.js.map +1 -1
  210. package/dist/esm/provider/DevicProvider.d.ts +1 -1
  211. package/dist/esm/provider/DevicProvider.js +5 -1
  212. package/dist/esm/provider/DevicProvider.js.map +1 -1
  213. package/dist/esm/provider/sharedSession.js.map +1 -1
  214. package/dist/esm/provider/types.d.ts +51 -0
  215. package/dist/esm/styles.css +1 -1
  216. package/dist/esm/utils/avatar.js.map +1 -1
  217. package/dist/esm/utils/consumeChatStream.d.ts +6 -0
  218. package/dist/esm/utils/consumeChatStream.js +42 -0
  219. package/dist/esm/utils/consumeChatStream.js.map +1 -0
  220. package/dist/esm/utils/index.js.map +1 -1
  221. package/dist/esm/utils/logger.js.map +1 -1
  222. package/dist/esm/utils/toolGroups.js.map +1 -1
  223. package/package.json +3 -1
@@ -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":[],"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;IACS;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,EAbW,gBAAgB,KAAhB,gBAAgB,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 /** Ephemeral provider output; never persisted or treated as a tool call. */\n streamingMessage?: ChatMessage;\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":[],"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;AA6tBA;;AAEG;IACS;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,EAbW,gBAAgB,KAAhB,gBAAgB,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -1,6 +1,7 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { forwardRef, useMemo, useImperativeHandle, useState, useRef, useEffect, useCallback } from 'react';
3
3
  import { useAICommandBar, formatShortcut } from './useAICommandBar.js';
4
+ import { useTranslations, DevicTranslationsProvider } from '../../i18n/useTranslations.js';
4
5
  import { MessageActions } from '../Feedback/MessageActions.js';
5
6
  import { useOptionalDevicContext } from '../../provider/DevicContext.js';
6
7
  import { DevicApiClient } from '../../api/client.js';
@@ -72,6 +73,7 @@ const DEFAULT_OPTIONS = {
72
73
  commands: undefined,
73
74
  showHistoryCommand: true,
74
75
  toolGroups: undefined,
76
+ translations: undefined,
75
77
  };
76
78
  /**
77
79
  * AI Command Bar component - a floating input for quick AI interactions
@@ -91,13 +93,15 @@ const DEFAULT_OPTIONS = {
91
93
  * ```
92
94
  */
93
95
  const AICommandBar = forwardRef(function AICommandBar(props, ref) {
94
- const { assistantId, apiKey, baseUrl, pollingInterval, tenantId, tenantMetadata, tags, options = {}, isVisible: controlledVisible, onVisibilityChange, onExecute = 'callback', chatDrawerRef, onResponse, modelInterfaceTools, onSubmit, onToolCall, onError, onOpen, onClose, className, } = props;
96
+ const { assistantId, apiKey, baseUrl, pollingInterval, streaming, tenantId, tenantMetadata, tags, options = {}, isVisible: controlledVisible, onVisibilityChange, onExecute = 'callback', chatDrawerRef, onResponse, modelInterfaceTools, onSubmit, onToolCall, onError, onOpen, onClose, className, } = props;
95
97
  const mergedOptions = useMemo(() => ({ ...DEFAULT_OPTIONS, ...options }), [options]);
98
+ const t = useTranslations(mergedOptions.translations);
96
99
  const hook = useAICommandBar({
97
100
  assistantId,
98
101
  apiKey,
99
102
  baseUrl,
100
103
  pollingInterval,
104
+ streaming,
101
105
  tenantId,
102
106
  tenantMetadata,
103
107
  tags,
@@ -314,14 +318,14 @@ const AICommandBar = forwardRef(function AICommandBar(props, ref) {
314
318
  return (jsxs("div", { className: "devic-command-bar-result-tool-item", children: [customIcon ? (jsx("span", { className: "devic-command-bar-result-tool-icon", children: customIcon })) : (jsx(CheckIcon, { className: "devic-command-bar-result-tool-icon" })), jsx("span", { className: "devic-command-bar-result-tool-name", children: tc.summary || tc.name })] }, tc.id));
315
319
  });
316
320
  };
317
- return (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 && (jsxs("div", { className: "devic-command-bar-dropdown", children: [jsxs("div", { className: "devic-command-bar-dropdown-header", children: [jsx("span", { children: "Commands" }), jsxs("span", { className: "devic-command-bar-dropdown-hint", children: [jsx("kbd", { children: "\u2191" }), jsx("kbd", { children: "\u2193" }), " to navigate, ", jsx("kbd", { children: "Enter" }), " to select"] })] }), jsx("div", { className: "devic-command-bar-dropdown-list", children: hook.filteredCommands.map((cmd, index) => (jsxs("div", { className: "devic-command-bar-dropdown-item", "data-selected": index === hook.selectedCommandIndex, onClick: () => hook.selectCommand(cmd), onMouseEnter: () => { }, children: [cmd.icon && (jsx("span", { className: "devic-command-bar-dropdown-icon", children: cmd.icon })), jsxs("span", { className: "devic-command-bar-dropdown-keyword", children: ["/", cmd.keyword] }), jsx("span", { className: "devic-command-bar-dropdown-desc", children: cmd.description })] }, cmd.keyword))) })] })), hook.showingHistory && (jsxs("div", { className: "devic-command-bar-dropdown", children: [jsxs("div", { className: "devic-command-bar-dropdown-header", children: [jsx("span", { children: "Command History" }), hook.history.length > 0 && (jsx("button", { className: "devic-command-bar-dropdown-clear", onClick: () => {
318
- hook.clearHistory();
321
+ return (jsx(DevicTranslationsProvider, { translations: mergedOptions.translations, children: 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 && (jsxs("div", { className: "devic-command-bar-dropdown", children: [jsxs("div", { className: "devic-command-bar-dropdown-header", children: [jsx("span", { children: t('Commands') }), jsxs("span", { className: "devic-command-bar-dropdown-hint", children: [jsx("kbd", { children: "\u2191" }), jsx("kbd", { children: "\u2193" }), " ", t('to navigate,'), " ", jsx("kbd", { children: "Enter" }), ' ', t('to select')] })] }), jsx("div", { className: "devic-command-bar-dropdown-list", children: hook.filteredCommands.map((cmd, index) => (jsxs("div", { className: "devic-command-bar-dropdown-item", "data-selected": index === hook.selectedCommandIndex, onClick: () => hook.selectCommand(cmd), onMouseEnter: () => { }, children: [cmd.icon && (jsx("span", { className: "devic-command-bar-dropdown-icon", children: cmd.icon })), jsxs("span", { className: "devic-command-bar-dropdown-keyword", children: ["/", cmd.keyword] }), jsx("span", { className: "devic-command-bar-dropdown-desc", children: cmd.description })] }, cmd.keyword))) })] })), hook.showingHistory && (jsxs("div", { className: "devic-command-bar-dropdown", children: [jsxs("div", { className: "devic-command-bar-dropdown-header", children: [jsx("span", { children: t('Command History') }), hook.history.length > 0 && (jsx("button", { className: "devic-command-bar-dropdown-clear", onClick: () => {
322
+ hook.clearHistory();
323
+ hook.setShowingHistory(false);
324
+ }, type: "button", children: t('Clear') }))] }), jsx("div", { className: "devic-command-bar-dropdown-list", style: resultMessageStyle, children: hook.history.length === 0 ? (jsx("div", { className: "devic-command-bar-dropdown-empty", children: t('No history yet') })) : (hook.history.map((item, index) => (jsxs("div", { className: "devic-command-bar-dropdown-item devic-command-bar-history-item", onClick: () => {
319
325
  hook.setShowingHistory(false);
320
- }, type: "button", children: "Clear" }))] }), jsx("div", { className: "devic-command-bar-dropdown-list", style: resultMessageStyle, children: hook.history.length === 0 ? (jsx("div", { className: "devic-command-bar-dropdown-empty", children: "No history yet" })) : (hook.history.map((item, index) => (jsxs("div", { className: "devic-command-bar-dropdown-item devic-command-bar-history-item", onClick: () => {
321
- hook.setShowingHistory(false);
322
- hook.setInputValue(item);
323
- hook.focus();
324
- }, children: [jsx(HistoryIcon, { className: "devic-command-bar-dropdown-icon" }), jsx("span", { className: "devic-command-bar-history-text", children: item })] }, `${item}-${index}`)))) })] })), mergedOptions.showResultCard && hook.result && !hook.showingHistory && !hook.showingCommands && (jsxs("div", { className: "devic-command-bar-result", children: [hook.result.toolCalls.length > 0 && (jsxs("div", { className: "devic-command-bar-result-tools", children: [jsxs("div", { className: "devic-command-bar-result-tools-header", "data-expanded": toolsExpanded, onClick: () => setToolsExpanded(!toolsExpanded), children: [jsx(ChevronIcon, { className: "devic-command-bar-result-tools-chevron" }), jsx("span", { children: "Tool calls" }), jsx("span", { className: "devic-command-bar-result-tools-count", children: hook.result.toolCalls.length })] }), jsx("div", { className: "devic-command-bar-result-tools-list", "data-expanded": toolsExpanded, children: renderToolCallItems(hook.result.toolCalls, mergedOptions) })] })), jsx("div", { className: "devic-command-bar-result-message", style: resultMessageStyle, children: hook.result.message.content?.message || (jsx("span", { className: "devic-command-bar-result-empty", children: "No response" })) }), jsx("div", { className: "devic-cmd-result-actions", children: jsx(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 && (jsx("div", { className: "devic-command-bar-error", children: hook.error.message })), jsxs("div", { className: "devic-command-bar", style: barStyle, children: [jsx("div", { className: "devic-command-bar-icon", children: hook.isProcessing ? (jsx("div", { className: "devic-command-bar-spinner" })) : (mergedOptions.icon || jsx(SparklesIcon, {})) }), hook.isProcessing ? (jsxs("div", { className: "devic-command-bar-summary", children: [hook.currentToolSummary || mergedOptions.processingMessage, "..."] })) : (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 && (jsx("div", { className: "devic-command-bar-shortcut", children: formatShortcut(mergedOptions.shortcut) }))] })] }));
326
+ hook.setInputValue(item);
327
+ hook.focus();
328
+ }, children: [jsx(HistoryIcon, { className: "devic-command-bar-dropdown-icon" }), jsx("span", { className: "devic-command-bar-history-text", children: item })] }, `${item}-${index}`)))) })] })), mergedOptions.showResultCard && hook.result && !hook.showingHistory && !hook.showingCommands && (jsxs("div", { className: "devic-command-bar-result", children: [hook.result.toolCalls.length > 0 && (jsxs("div", { className: "devic-command-bar-result-tools", children: [jsxs("div", { className: "devic-command-bar-result-tools-header", "data-expanded": toolsExpanded, onClick: () => setToolsExpanded(!toolsExpanded), children: [jsx(ChevronIcon, { className: "devic-command-bar-result-tools-chevron" }), jsx("span", { children: t('Tool calls') }), jsx("span", { className: "devic-command-bar-result-tools-count", children: hook.result.toolCalls.length })] }), jsx("div", { className: "devic-command-bar-result-tools-list", "data-expanded": toolsExpanded, children: renderToolCallItems(hook.result.toolCalls, mergedOptions) })] })), jsx("div", { className: "devic-command-bar-result-message", style: resultMessageStyle, children: hook.result.message.content?.message || (jsx("span", { className: "devic-command-bar-result-empty", children: t('No response') })) }), jsx("div", { className: "devic-cmd-result-actions", children: jsx(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 && (jsx("div", { className: "devic-command-bar-error", children: hook.error.message })), jsxs("div", { className: "devic-command-bar", style: barStyle, children: [jsx("div", { className: "devic-command-bar-icon", children: hook.isProcessing ? (jsx("div", { className: "devic-command-bar-spinner" })) : (mergedOptions.icon || jsx(SparklesIcon, {})) }), hook.isProcessing ? (jsxs("div", { className: "devic-command-bar-summary", children: [hook.currentToolSummary || t(mergedOptions.processingMessage), "..."] })) : (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 && (jsx("div", { className: "devic-command-bar-shortcut", children: formatShortcut(mergedOptions.shortcut) }))] })] }) }));
325
329
  });
326
330
  /**
327
331
  * Sparkles icon (default)
@@ -1 +1 @@
1
- {"version":3,"file":"AICommandBar.js","sources":["../../../../src/components/AICommandBar/AICommandBar.tsx"],"sourcesContent":["import React, { forwardRef, useImperativeHandle, useState, useMemo, useEffect, useRef, useCallback } from 'react';\nimport { useAICommandBar, formatShortcut } from './useAICommandBar';\nimport { MessageActions } from '../Feedback';\nimport { useOptionalDevicContext } from '../../provider';\nimport { DevicApiClient } from '../../api/client';\nimport type { AICommandBarProps, AICommandBarHandle, AICommandBarOptions, ToolCallSummary } from './AICommandBar.types';\nimport type { ToolGroupCall } from '../../api/types';\nimport { segmentToolCalls } from '../../utils/toolGroups';\nimport type { FeedbackState, FeedbackTheme } from '../Feedback';\nimport './AICommandBar.css';\nimport '../Feedback/Feedback.css';\n\n/**\n * Detect if a color is dark based on perceived brightness\n */\nfunction isColorDark(color: string): boolean {\n // Handle hex colors\n const hex = color.replace('#', '');\n if (hex.length === 3 || hex.length === 6) {\n const r = parseInt(hex.length === 3 ? hex[0] + hex[0] : hex.slice(0, 2), 16);\n const g = parseInt(hex.length === 3 ? hex[1] + hex[1] : hex.slice(2, 4), 16);\n const b = parseInt(hex.length === 3 ? hex[2] + hex[2] : hex.slice(4, 6), 16);\n // Perceived brightness formula\n const brightness = (r * 299 + g * 587 + b * 114) / 1000;\n return brightness < 128;\n }\n // Handle rgb/rgba\n const rgbMatch = color.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/);\n if (rgbMatch) {\n const r = parseInt(rgbMatch[1], 10);\n const g = parseInt(rgbMatch[2], 10);\n const b = parseInt(rgbMatch[3], 10);\n const brightness = (r * 299 + g * 587 + b * 114) / 1000;\n return brightness < 128;\n }\n return false;\n}\n\n/**\n * Lighten or darken a hex color\n */\nfunction adjustColor(color: string, amount: number): string {\n const hex = color.replace('#', '');\n const r = Math.min(255, Math.max(0, parseInt(hex.slice(0, 2), 16) + amount));\n const g = Math.min(255, Math.max(0, parseInt(hex.slice(2, 4), 16) + amount));\n const b = Math.min(255, Math.max(0, parseInt(hex.slice(4, 6), 16) + amount));\n return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;\n}\n\nconst DEFAULT_OPTIONS: Required<AICommandBarOptions> = {\n position: 'inline',\n fixedPlacement: {},\n shortcut: '',\n showShortcutHint: true,\n placeholder: 'Ask AI...',\n icon: undefined as any,\n width: 400,\n maxWidth: '100%',\n zIndex: 9999,\n showResultCard: true,\n resultCardMaxHeight: 300,\n color: '#3b82f6',\n backgroundColor: '#ffffff',\n textColor: '#1f2937',\n borderColor: '#e5e7eb',\n borderRadius: 12,\n fontFamily: \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\",\n fontSize: 14,\n padding: '12px 16px',\n boxShadow: '0 4px 20px rgba(0, 0, 0, 0.1)',\n animationDuration: 200,\n toolRenderers: undefined as any,\n toolIcons: undefined as any,\n processingMessage: 'Processing...',\n enableHistory: true,\n maxHistoryItems: 50,\n historyStorageKey: 'devic-command-bar-history',\n commands: undefined as any,\n showHistoryCommand: true,\n toolGroups: undefined as any,\n};\n\n/**\n * AI Command Bar component - a floating input for quick AI interactions\n *\n * @example\n * ```tsx\n * <AICommandBar\n * assistantId=\"support-assistant\"\n * options={{\n * position: 'fixed',\n * fixedPlacement: { bottom: 20, right: 20 },\n * shortcut: 'cmd+j',\n * placeholder: 'Ask AI...',\n * }}\n * onResponse={({ message }) => console.log('Response:', message.content)}\n * />\n * ```\n */\nexport const AICommandBar = forwardRef<AICommandBarHandle, AICommandBarProps>(\n function AICommandBar(props, ref) {\n const {\n assistantId,\n apiKey,\n baseUrl,\n pollingInterval,\n tenantId,\n tenantMetadata,\n tags,\n options = {},\n isVisible: controlledVisible,\n onVisibilityChange,\n onExecute = 'callback',\n chatDrawerRef,\n onResponse,\n modelInterfaceTools,\n onSubmit,\n onToolCall,\n onError,\n onOpen,\n onClose,\n className,\n } = props;\n\n const mergedOptions = useMemo(\n () => ({ ...DEFAULT_OPTIONS, ...options }),\n [options]\n );\n\n const hook = useAICommandBar({\n assistantId,\n apiKey,\n baseUrl,\n pollingInterval,\n tenantId,\n tenantMetadata,\n tags,\n options: mergedOptions,\n isVisible: controlledVisible,\n onVisibilityChange,\n onExecute,\n chatDrawerRef,\n onResponse,\n modelInterfaceTools,\n onSubmit,\n onToolCall,\n onError,\n onOpen,\n onClose,\n });\n\n // Expose handle\n useImperativeHandle(ref, () => ({\n open: hook.open,\n close: hook.close,\n toggle: hook.toggle,\n focus: hook.focus,\n submit: hook.submit,\n reset: hook.reset,\n }));\n\n // Tool list expansion state\n const [toolsExpanded, setToolsExpanded] = useState(false);\n\n // Feedback state\n const [feedbackState, setFeedbackState] = useState<FeedbackState>('none');\n const feedbackClientRef = useRef<DevicApiClient | null>(null);\n\n // Get context for API client\n const context = useOptionalDevicContext();\n const resolvedApiKey = apiKey || context?.apiKey;\n const resolvedBaseUrl = baseUrl || context?.baseUrl || 'https://api.devic.ai';\n\n // Initialize feedback client\n useEffect(() => {\n if ((resolvedApiKey || context?.getTenantSession) && !feedbackClientRef.current) {\n feedbackClientRef.current = new DevicApiClient({\n apiKey: resolvedApiKey,\n baseUrl: resolvedBaseUrl,\n getTenantSession: context?.getTenantSession,\n onSessionExpired: context?.onSessionExpired,\n });\n }\n }, [resolvedApiKey, context?.getTenantSession, resolvedBaseUrl]);\n\n // Reset feedback state when result changes\n useEffect(() => {\n if (hook.result) {\n setFeedbackState('none');\n }\n }, [hook.result?.chatUid, hook.result?.message.uid]);\n\n // Handle feedback submission\n const handleFeedback = useCallback(\n async (messageId: string, positive: boolean, comment?: string) => {\n if (!hook.result?.chatUid || !feedbackClientRef.current) return;\n\n try {\n await feedbackClientRef.current.submitChatFeedback(assistantId, hook.result.chatUid, {\n messageId,\n feedback: positive,\n feedbackComment: comment,\n });\n\n setFeedbackState(positive ? 'positive' : 'negative');\n } catch (err) {\n console.error('Failed to submit feedback:', err);\n throw err;\n }\n },\n [hook.result?.chatUid, assistantId]\n );\n\n // Container ref for theming\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Apply CSS variables for theming\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n\n const vars: [string, string | undefined][] = [\n ['--devic-cmd-bg-override', mergedOptions.backgroundColor],\n ['--devic-cmd-text-override', mergedOptions.textColor],\n ['--devic-cmd-border-override', mergedOptions.borderColor],\n ['--devic-cmd-primary-override', mergedOptions.color],\n ['--devic-cmd-font-family-override', mergedOptions.fontFamily],\n ['--devic-cmd-font-size-override', typeof mergedOptions.fontSize === 'number' ? `${mergedOptions.fontSize}px` : mergedOptions.fontSize],\n ['--devic-cmd-radius-override', typeof mergedOptions.borderRadius === 'number' ? `${mergedOptions.borderRadius}px` : mergedOptions.borderRadius],\n ['--devic-cmd-shadow-override', mergedOptions.boxShadow],\n ['--devic-cmd-animation-duration-override', `${mergedOptions.animationDuration}ms`],\n ];\n\n for (const [name, value] of vars) {\n if (value) {\n el.style.setProperty(name, value);\n } else {\n el.style.removeProperty(name);\n }\n }\n }, [mergedOptions]);\n\n // Click-outside detection to close the bar\n useEffect(() => {\n if (!hook.isVisible) return;\n\n const handleClickOutside = (e: MouseEvent) => {\n const container = containerRef.current;\n if (container && !container.contains(e.target as Node)) {\n // Reset if there's a result, otherwise just close\n if (hook.result) {\n hook.reset();\n }\n hook.close();\n }\n };\n\n // Use mousedown instead of click to prevent race conditions\n document.addEventListener('mousedown', handleClickOutside);\n return () => document.removeEventListener('mousedown', handleClickOutside);\n }, [hook.isVisible, hook.result, hook.reset, hook.close]);\n\n // Feedback theme derived from command bar options\n const feedbackTheme = useMemo((): FeedbackTheme | undefined => {\n const bg = mergedOptions.backgroundColor;\n const text = mergedOptions.textColor;\n const border = mergedOptions.borderColor;\n const primary = mergedOptions.color;\n\n // Only create theme if we have some custom colors\n if (!bg && !text) return undefined;\n\n const isDark = bg ? isColorDark(bg) : false;\n\n return {\n backgroundColor: bg,\n textColor: text,\n textMutedColor: text && bg ? (isDark ? adjustColor(text, -60) : adjustColor(text, 60)) : undefined,\n secondaryBackgroundColor: bg ? (isDark ? adjustColor(bg, 20) : adjustColor(bg, -15)) : undefined,\n borderColor: border,\n primaryColor: primary,\n primaryHoverColor: primary ? (isDark ? adjustColor(primary, 20) : adjustColor(primary, -20)) : undefined,\n };\n }, [mergedOptions.backgroundColor, mergedOptions.textColor, mergedOptions.borderColor, mergedOptions.color]);\n\n // Container styles\n const containerStyle = useMemo(() => {\n const style: React.CSSProperties = {\n width: typeof mergedOptions.width === 'number' ? `${mergedOptions.width}px` : mergedOptions.width,\n maxWidth: typeof mergedOptions.maxWidth === 'number' ? `${mergedOptions.maxWidth}px` : mergedOptions.maxWidth,\n zIndex: mergedOptions.zIndex,\n };\n\n if (mergedOptions.position === 'fixed') {\n const { top, right, bottom, left } = mergedOptions.fixedPlacement || {};\n if (top !== undefined) style.top = typeof top === 'number' ? `${top}px` : top;\n if (right !== undefined) style.right = typeof right === 'number' ? `${right}px` : right;\n if (bottom !== undefined) style.bottom = typeof bottom === 'number' ? `${bottom}px` : bottom;\n if (left !== undefined) style.left = typeof left === 'number' ? `${left}px` : left;\n }\n\n return style;\n }, [mergedOptions]);\n\n // Bar padding style\n const barStyle = useMemo(() => {\n if (!mergedOptions.padding || mergedOptions.padding === DEFAULT_OPTIONS.padding) {\n return undefined;\n }\n return {\n padding: typeof mergedOptions.padding === 'number' ? `${mergedOptions.padding}px` : mergedOptions.padding,\n };\n }, [mergedOptions.padding]);\n\n // Result card max height style\n const resultMessageStyle = useMemo(() => {\n if (!mergedOptions.resultCardMaxHeight || mergedOptions.resultCardMaxHeight === DEFAULT_OPTIONS.resultCardMaxHeight) {\n return undefined;\n }\n return {\n maxHeight: typeof mergedOptions.resultCardMaxHeight === 'number'\n ? `${mergedOptions.resultCardMaxHeight}px`\n : mergedOptions.resultCardMaxHeight,\n };\n }, [mergedOptions.resultCardMaxHeight]);\n\n // Render tool call items with optional toolGroups segmentation\n const renderToolCallItems = (toolCalls: ToolCallSummary[], opts: Required<AICommandBarOptions>) => {\n if (opts.toolGroups && opts.toolGroups.length > 0) {\n const calls: ToolGroupCall[] = toolCalls.map((tc) => ({\n name: tc.name,\n input: tc.input,\n output: tc.output,\n toolCallId: tc.id,\n }));\n const segments = segmentToolCalls(calls, opts.toolGroups);\n const elements: React.ReactNode[] = [];\n let callIdx = 0;\n\n for (const segment of segments) {\n if (segment.type === 'group') {\n const groupKey = segment.calls.map((c) => c.toolCallId).join('-');\n elements.push(\n <div key={`cmd-group-${groupKey}`} className=\"devic-command-bar-result-tool-item devic-command-bar-result-tool-custom\">\n {segment.config.renderer(segment.calls)}\n </div>,\n );\n callIdx += segment.calls.length;\n } else {\n const tc = toolCalls[callIdx];\n const customRenderer = opts.toolRenderers?.[tc.name];\n if (customRenderer) {\n elements.push(\n <div key={tc.id} className=\"devic-command-bar-result-tool-item devic-command-bar-result-tool-custom\">\n {customRenderer(tc.input, tc.output)}\n </div>,\n );\n } else {\n const customIcon = opts.toolIcons?.[tc.name];\n elements.push(\n <div key={tc.id} className=\"devic-command-bar-result-tool-item\">\n {customIcon ? (\n <span className=\"devic-command-bar-result-tool-icon\">{customIcon}</span>\n ) : (\n <CheckIcon className=\"devic-command-bar-result-tool-icon\" />\n )}\n <span className=\"devic-command-bar-result-tool-name\">{tc.summary || tc.name}</span>\n </div>,\n );\n }\n callIdx += 1;\n }\n }\n\n return elements;\n }\n\n // Default: no toolGroups, render individually\n return toolCalls.map((tc) => {\n const customRenderer = opts.toolRenderers?.[tc.name];\n if (customRenderer) {\n return (\n <div key={tc.id} className=\"devic-command-bar-result-tool-item devic-command-bar-result-tool-custom\">\n {customRenderer(tc.input, tc.output)}\n </div>\n );\n }\n const customIcon = opts.toolIcons?.[tc.name];\n return (\n <div key={tc.id} className=\"devic-command-bar-result-tool-item\">\n {customIcon ? (\n <span className=\"devic-command-bar-result-tool-icon\">{customIcon}</span>\n ) : (\n <CheckIcon className=\"devic-command-bar-result-tool-icon\" />\n )}\n <span className=\"devic-command-bar-result-tool-name\">{tc.summary || tc.name}</span>\n </div>\n );\n });\n };\n\n return (\n <div\n ref={containerRef}\n className={`devic-command-bar-container ${className || ''}`}\n data-position={mergedOptions.position}\n data-visible={hook.isVisible}\n style={containerStyle}\n >\n {/* Commands dropdown */}\n {hook.showingCommands && hook.filteredCommands.length > 0 && (\n <div className=\"devic-command-bar-dropdown\">\n <div className=\"devic-command-bar-dropdown-header\">\n <span>Commands</span>\n <span className=\"devic-command-bar-dropdown-hint\">\n <kbd>↑</kbd><kbd>↓</kbd> to navigate, <kbd>Enter</kbd> to select\n </span>\n </div>\n <div className=\"devic-command-bar-dropdown-list\">\n {hook.filteredCommands.map((cmd, index) => (\n <div\n key={cmd.keyword}\n className=\"devic-command-bar-dropdown-item\"\n data-selected={index === hook.selectedCommandIndex}\n onClick={() => hook.selectCommand(cmd)}\n onMouseEnter={() => {/* Could update selectedCommandIndex on hover */}}\n >\n {cmd.icon && (\n <span className=\"devic-command-bar-dropdown-icon\">{cmd.icon}</span>\n )}\n <span className=\"devic-command-bar-dropdown-keyword\">/{cmd.keyword}</span>\n <span className=\"devic-command-bar-dropdown-desc\">{cmd.description}</span>\n </div>\n ))}\n </div>\n </div>\n )}\n\n {/* History list */}\n {hook.showingHistory && (\n <div className=\"devic-command-bar-dropdown\">\n <div className=\"devic-command-bar-dropdown-header\">\n <span>Command History</span>\n {hook.history.length > 0 && (\n <button\n className=\"devic-command-bar-dropdown-clear\"\n onClick={() => {\n hook.clearHistory();\n hook.setShowingHistory(false);\n }}\n type=\"button\"\n >\n Clear\n </button>\n )}\n </div>\n <div className=\"devic-command-bar-dropdown-list\" style={resultMessageStyle}>\n {hook.history.length === 0 ? (\n <div className=\"devic-command-bar-dropdown-empty\">No history yet</div>\n ) : (\n hook.history.map((item, index) => (\n <div\n key={`${item}-${index}`}\n className=\"devic-command-bar-dropdown-item devic-command-bar-history-item\"\n onClick={() => {\n hook.setShowingHistory(false);\n hook.setInputValue(item);\n hook.focus();\n }}\n >\n <HistoryIcon className=\"devic-command-bar-dropdown-icon\" />\n <span className=\"devic-command-bar-history-text\">{item}</span>\n </div>\n ))\n )}\n </div>\n </div>\n )}\n\n {/* Result card (above bar when completed) */}\n {mergedOptions.showResultCard && hook.result && !hook.showingHistory && !hook.showingCommands && (\n <div className=\"devic-command-bar-result\">\n {/* Tool calls section */}\n {hook.result.toolCalls.length > 0 && (\n <div className=\"devic-command-bar-result-tools\">\n <div\n className=\"devic-command-bar-result-tools-header\"\n data-expanded={toolsExpanded}\n onClick={() => setToolsExpanded(!toolsExpanded)}\n >\n <ChevronIcon className=\"devic-command-bar-result-tools-chevron\" />\n <span>Tool calls</span>\n <span className=\"devic-command-bar-result-tools-count\">\n {hook.result.toolCalls.length}\n </span>\n </div>\n <div\n className=\"devic-command-bar-result-tools-list\"\n data-expanded={toolsExpanded}\n >\n {renderToolCallItems(hook.result.toolCalls, mergedOptions)}\n </div>\n </div>\n )}\n\n {/* Message section */}\n <div className=\"devic-command-bar-result-message\" style={resultMessageStyle}>\n {hook.result.message.content?.message || (\n <span className=\"devic-command-bar-result-empty\">No response</span>\n )}\n </div>\n\n {/* Feedback actions */}\n <div className=\"devic-cmd-result-actions\">\n <MessageActions\n messageId={hook.result.message.uid}\n messageContent={hook.result.message.content?.message}\n currentFeedback={feedbackState}\n onFeedback={handleFeedback}\n showCopy={true}\n showFeedback={true}\n theme={feedbackTheme}\n />\n </div>\n </div>\n )}\n\n {/* Error display */}\n {hook.error && !hook.isProcessing && (\n <div className=\"devic-command-bar-error\">\n {hook.error.message}\n </div>\n )}\n\n {/* Main bar */}\n <div className=\"devic-command-bar\" style={barStyle}>\n {/* Left: Icon or Loader */}\n <div className=\"devic-command-bar-icon\">\n {hook.isProcessing ? (\n <div className=\"devic-command-bar-spinner\" />\n ) : (\n mergedOptions.icon || <SparklesIcon />\n )}\n </div>\n\n {/* Center: Input or Processing Summary */}\n {hook.isProcessing ? (\n <div className=\"devic-command-bar-summary\">\n {hook.currentToolSummary || mergedOptions.processingMessage}...\n </div>\n ) : (\n <input\n ref={hook.inputRef}\n type=\"text\"\n className=\"devic-command-bar-input\"\n placeholder={mergedOptions.placeholder}\n value={hook.inputValue}\n onChange={(e) => hook.setInputValue(e.target.value)}\n onKeyDown={hook.handleKeyDown}\n />\n )}\n\n {/* Right: Shortcut hint */}\n {mergedOptions.showShortcutHint && mergedOptions.shortcut && !hook.isProcessing && (\n <div className=\"devic-command-bar-shortcut\">\n {formatShortcut(mergedOptions.shortcut)}\n </div>\n )}\n </div>\n </div>\n );\n }\n);\n\n/**\n * Sparkles icon (default)\n */\nfunction SparklesIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {/* Main star - 4-point diamond */}\n <path\n d=\"M10 2L11.5 8.5L18 10L11.5 11.5L10 18L8.5 11.5L2 10L8.5 8.5L10 2Z\"\n fill=\"currentColor\"\n opacity=\"0.9\"\n />\n {/* Small accent star - top right */}\n <path\n d=\"M16 3L16.5 5L18.5 5.5L16.5 6L16 8L15.5 6L13.5 5.5L15.5 5L16 3Z\"\n fill=\"currentColor\"\n opacity=\"0.6\"\n />\n {/* Tiny accent dot - bottom left */}\n <circle cx=\"4\" cy=\"15\" r=\"1\" fill=\"currentColor\" opacity=\"0.4\" />\n </svg>\n );\n}\n\n/**\n * Chevron right icon\n */\nfunction ChevronIcon({ className }: { className?: string }): JSX.Element {\n return (\n <svg\n className={className}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"9 18 15 12 9 6\" />\n </svg>\n );\n}\n\n/**\n * Check icon\n */\nfunction CheckIcon({ className }: { className?: string }): JSX.Element {\n return (\n <svg\n className={className}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"20 6 9 17 4 12\" />\n </svg>\n );\n}\n\n/**\n * History icon\n */\nfunction HistoryIcon({ className }: { className?: string }): JSX.Element {\n return (\n <svg\n className={className}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M3 3v5h5\" />\n <path d=\"M3.05 13A9 9 0 1 0 6 5.3L3 8\" />\n <path d=\"M12 7v5l4 2\" />\n </svg>\n );\n}\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;AAYA;;AAEG;AACH,SAAS,WAAW,CAAC,KAAa,EAAA;;IAEhC,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;AAClC,IAAA,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;AAC5E,QAAA,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;AAC5E,Q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;"}
1
+ {"version":3,"file":"AICommandBar.js","sources":["../../../../src/components/AICommandBar/AICommandBar.tsx"],"sourcesContent":["import React, { forwardRef, useImperativeHandle, useState, useMemo, useEffect, useRef, useCallback } from 'react';\nimport { useAICommandBar, formatShortcut } from './useAICommandBar';\nimport { MessageActions } from '../Feedback';\nimport { useOptionalDevicContext } from '../../provider';\nimport { DevicApiClient } from '../../api/client';\nimport type { AICommandBarProps, AICommandBarHandle, AICommandBarOptions, ToolCallSummary } from './AICommandBar.types';\nimport type { ToolGroupCall } from '../../api/types';\nimport { segmentToolCalls } from '../../utils/toolGroups';\nimport { DevicTranslationsProvider, useTranslations } from '../../i18n';\nimport type { FeedbackState, FeedbackTheme } from '../Feedback';\nimport './AICommandBar.css';\nimport '../Feedback/Feedback.css';\n\n/**\n * Detect if a color is dark based on perceived brightness\n */\nfunction isColorDark(color: string): boolean {\n // Handle hex colors\n const hex = color.replace('#', '');\n if (hex.length === 3 || hex.length === 6) {\n const r = parseInt(hex.length === 3 ? hex[0] + hex[0] : hex.slice(0, 2), 16);\n const g = parseInt(hex.length === 3 ? hex[1] + hex[1] : hex.slice(2, 4), 16);\n const b = parseInt(hex.length === 3 ? hex[2] + hex[2] : hex.slice(4, 6), 16);\n // Perceived brightness formula\n const brightness = (r * 299 + g * 587 + b * 114) / 1000;\n return brightness < 128;\n }\n // Handle rgb/rgba\n const rgbMatch = color.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/);\n if (rgbMatch) {\n const r = parseInt(rgbMatch[1], 10);\n const g = parseInt(rgbMatch[2], 10);\n const b = parseInt(rgbMatch[3], 10);\n const brightness = (r * 299 + g * 587 + b * 114) / 1000;\n return brightness < 128;\n }\n return false;\n}\n\n/**\n * Lighten or darken a hex color\n */\nfunction adjustColor(color: string, amount: number): string {\n const hex = color.replace('#', '');\n const r = Math.min(255, Math.max(0, parseInt(hex.slice(0, 2), 16) + amount));\n const g = Math.min(255, Math.max(0, parseInt(hex.slice(2, 4), 16) + amount));\n const b = Math.min(255, Math.max(0, parseInt(hex.slice(4, 6), 16) + amount));\n return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;\n}\n\nconst DEFAULT_OPTIONS: Required<AICommandBarOptions> = {\n position: 'inline',\n fixedPlacement: {},\n shortcut: '',\n showShortcutHint: true,\n placeholder: 'Ask AI...',\n icon: undefined as any,\n width: 400,\n maxWidth: '100%',\n zIndex: 9999,\n showResultCard: true,\n resultCardMaxHeight: 300,\n color: '#3b82f6',\n backgroundColor: '#ffffff',\n textColor: '#1f2937',\n borderColor: '#e5e7eb',\n borderRadius: 12,\n fontFamily: \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\",\n fontSize: 14,\n padding: '12px 16px',\n boxShadow: '0 4px 20px rgba(0, 0, 0, 0.1)',\n animationDuration: 200,\n toolRenderers: undefined as any,\n toolIcons: undefined as any,\n processingMessage: 'Processing...',\n enableHistory: true,\n maxHistoryItems: 50,\n historyStorageKey: 'devic-command-bar-history',\n commands: undefined as any,\n showHistoryCommand: true,\n toolGroups: undefined as any,\n translations: undefined as any,\n};\n\n/**\n * AI Command Bar component - a floating input for quick AI interactions\n *\n * @example\n * ```tsx\n * <AICommandBar\n * assistantId=\"support-assistant\"\n * options={{\n * position: 'fixed',\n * fixedPlacement: { bottom: 20, right: 20 },\n * shortcut: 'cmd+j',\n * placeholder: 'Ask AI...',\n * }}\n * onResponse={({ message }) => console.log('Response:', message.content)}\n * />\n * ```\n */\nexport const AICommandBar = forwardRef<AICommandBarHandle, AICommandBarProps>(\n function AICommandBar(props, ref) {\n const {\n assistantId,\n apiKey,\n baseUrl,\n pollingInterval,\n streaming,\n tenantId,\n tenantMetadata,\n tags,\n options = {},\n isVisible: controlledVisible,\n onVisibilityChange,\n onExecute = 'callback',\n chatDrawerRef,\n onResponse,\n modelInterfaceTools,\n onSubmit,\n onToolCall,\n onError,\n onOpen,\n onClose,\n className,\n } = props;\n\n const mergedOptions = useMemo(\n () => ({ ...DEFAULT_OPTIONS, ...options }),\n [options]\n );\n\n const t = useTranslations(mergedOptions.translations);\n\n const hook = useAICommandBar({\n assistantId,\n apiKey,\n baseUrl,\n pollingInterval,\n streaming,\n tenantId,\n tenantMetadata,\n tags,\n options: mergedOptions,\n isVisible: controlledVisible,\n onVisibilityChange,\n onExecute,\n chatDrawerRef,\n onResponse,\n modelInterfaceTools,\n onSubmit,\n onToolCall,\n onError,\n onOpen,\n onClose,\n });\n\n // Expose handle\n useImperativeHandle(ref, () => ({\n open: hook.open,\n close: hook.close,\n toggle: hook.toggle,\n focus: hook.focus,\n submit: hook.submit,\n reset: hook.reset,\n }));\n\n // Tool list expansion state\n const [toolsExpanded, setToolsExpanded] = useState(false);\n\n // Feedback state\n const [feedbackState, setFeedbackState] = useState<FeedbackState>('none');\n const feedbackClientRef = useRef<DevicApiClient | null>(null);\n\n // Get context for API client\n const context = useOptionalDevicContext();\n const resolvedApiKey = apiKey || context?.apiKey;\n const resolvedBaseUrl = baseUrl || context?.baseUrl || 'https://api.devic.ai';\n\n // Initialize feedback client\n useEffect(() => {\n if ((resolvedApiKey || context?.getTenantSession) && !feedbackClientRef.current) {\n feedbackClientRef.current = new DevicApiClient({\n apiKey: resolvedApiKey,\n baseUrl: resolvedBaseUrl,\n getTenantSession: context?.getTenantSession,\n onSessionExpired: context?.onSessionExpired,\n });\n }\n }, [resolvedApiKey, context?.getTenantSession, resolvedBaseUrl]);\n\n // Reset feedback state when result changes\n useEffect(() => {\n if (hook.result) {\n setFeedbackState('none');\n }\n }, [hook.result?.chatUid, hook.result?.message.uid]);\n\n // Handle feedback submission\n const handleFeedback = useCallback(\n async (messageId: string, positive: boolean, comment?: string) => {\n if (!hook.result?.chatUid || !feedbackClientRef.current) return;\n\n try {\n await feedbackClientRef.current.submitChatFeedback(assistantId, hook.result.chatUid, {\n messageId,\n feedback: positive,\n feedbackComment: comment,\n });\n\n setFeedbackState(positive ? 'positive' : 'negative');\n } catch (err) {\n console.error('Failed to submit feedback:', err);\n throw err;\n }\n },\n [hook.result?.chatUid, assistantId]\n );\n\n // Container ref for theming\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Apply CSS variables for theming\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n\n const vars: [string, string | undefined][] = [\n ['--devic-cmd-bg-override', mergedOptions.backgroundColor],\n ['--devic-cmd-text-override', mergedOptions.textColor],\n ['--devic-cmd-border-override', mergedOptions.borderColor],\n ['--devic-cmd-primary-override', mergedOptions.color],\n ['--devic-cmd-font-family-override', mergedOptions.fontFamily],\n ['--devic-cmd-font-size-override', typeof mergedOptions.fontSize === 'number' ? `${mergedOptions.fontSize}px` : mergedOptions.fontSize],\n ['--devic-cmd-radius-override', typeof mergedOptions.borderRadius === 'number' ? `${mergedOptions.borderRadius}px` : mergedOptions.borderRadius],\n ['--devic-cmd-shadow-override', mergedOptions.boxShadow],\n ['--devic-cmd-animation-duration-override', `${mergedOptions.animationDuration}ms`],\n ];\n\n for (const [name, value] of vars) {\n if (value) {\n el.style.setProperty(name, value);\n } else {\n el.style.removeProperty(name);\n }\n }\n }, [mergedOptions]);\n\n // Click-outside detection to close the bar\n useEffect(() => {\n if (!hook.isVisible) return;\n\n const handleClickOutside = (e: MouseEvent) => {\n const container = containerRef.current;\n if (container && !container.contains(e.target as Node)) {\n // Reset if there's a result, otherwise just close\n if (hook.result) {\n hook.reset();\n }\n hook.close();\n }\n };\n\n // Use mousedown instead of click to prevent race conditions\n document.addEventListener('mousedown', handleClickOutside);\n return () => document.removeEventListener('mousedown', handleClickOutside);\n }, [hook.isVisible, hook.result, hook.reset, hook.close]);\n\n // Feedback theme derived from command bar options\n const feedbackTheme = useMemo((): FeedbackTheme | undefined => {\n const bg = mergedOptions.backgroundColor;\n const text = mergedOptions.textColor;\n const border = mergedOptions.borderColor;\n const primary = mergedOptions.color;\n\n // Only create theme if we have some custom colors\n if (!bg && !text) return undefined;\n\n const isDark = bg ? isColorDark(bg) : false;\n\n return {\n backgroundColor: bg,\n textColor: text,\n textMutedColor: text && bg ? (isDark ? adjustColor(text, -60) : adjustColor(text, 60)) : undefined,\n secondaryBackgroundColor: bg ? (isDark ? adjustColor(bg, 20) : adjustColor(bg, -15)) : undefined,\n borderColor: border,\n primaryColor: primary,\n primaryHoverColor: primary ? (isDark ? adjustColor(primary, 20) : adjustColor(primary, -20)) : undefined,\n };\n }, [mergedOptions.backgroundColor, mergedOptions.textColor, mergedOptions.borderColor, mergedOptions.color]);\n\n // Container styles\n const containerStyle = useMemo(() => {\n const style: React.CSSProperties = {\n width: typeof mergedOptions.width === 'number' ? `${mergedOptions.width}px` : mergedOptions.width,\n maxWidth: typeof mergedOptions.maxWidth === 'number' ? `${mergedOptions.maxWidth}px` : mergedOptions.maxWidth,\n zIndex: mergedOptions.zIndex,\n };\n\n if (mergedOptions.position === 'fixed') {\n const { top, right, bottom, left } = mergedOptions.fixedPlacement || {};\n if (top !== undefined) style.top = typeof top === 'number' ? `${top}px` : top;\n if (right !== undefined) style.right = typeof right === 'number' ? `${right}px` : right;\n if (bottom !== undefined) style.bottom = typeof bottom === 'number' ? `${bottom}px` : bottom;\n if (left !== undefined) style.left = typeof left === 'number' ? `${left}px` : left;\n }\n\n return style;\n }, [mergedOptions]);\n\n // Bar padding style\n const barStyle = useMemo(() => {\n if (!mergedOptions.padding || mergedOptions.padding === DEFAULT_OPTIONS.padding) {\n return undefined;\n }\n return {\n padding: typeof mergedOptions.padding === 'number' ? `${mergedOptions.padding}px` : mergedOptions.padding,\n };\n }, [mergedOptions.padding]);\n\n // Result card max height style\n const resultMessageStyle = useMemo(() => {\n if (!mergedOptions.resultCardMaxHeight || mergedOptions.resultCardMaxHeight === DEFAULT_OPTIONS.resultCardMaxHeight) {\n return undefined;\n }\n return {\n maxHeight: typeof mergedOptions.resultCardMaxHeight === 'number'\n ? `${mergedOptions.resultCardMaxHeight}px`\n : mergedOptions.resultCardMaxHeight,\n };\n }, [mergedOptions.resultCardMaxHeight]);\n\n // Render tool call items with optional toolGroups segmentation\n const renderToolCallItems = (toolCalls: ToolCallSummary[], opts: Required<AICommandBarOptions>) => {\n if (opts.toolGroups && opts.toolGroups.length > 0) {\n const calls: ToolGroupCall[] = toolCalls.map((tc) => ({\n name: tc.name,\n input: tc.input,\n output: tc.output,\n toolCallId: tc.id,\n }));\n const segments = segmentToolCalls(calls, opts.toolGroups);\n const elements: React.ReactNode[] = [];\n let callIdx = 0;\n\n for (const segment of segments) {\n if (segment.type === 'group') {\n const groupKey = segment.calls.map((c) => c.toolCallId).join('-');\n elements.push(\n <div key={`cmd-group-${groupKey}`} className=\"devic-command-bar-result-tool-item devic-command-bar-result-tool-custom\">\n {segment.config.renderer(segment.calls)}\n </div>,\n );\n callIdx += segment.calls.length;\n } else {\n const tc = toolCalls[callIdx];\n const customRenderer = opts.toolRenderers?.[tc.name];\n if (customRenderer) {\n elements.push(\n <div key={tc.id} className=\"devic-command-bar-result-tool-item devic-command-bar-result-tool-custom\">\n {customRenderer(tc.input, tc.output)}\n </div>,\n );\n } else {\n const customIcon = opts.toolIcons?.[tc.name];\n elements.push(\n <div key={tc.id} className=\"devic-command-bar-result-tool-item\">\n {customIcon ? (\n <span className=\"devic-command-bar-result-tool-icon\">{customIcon}</span>\n ) : (\n <CheckIcon className=\"devic-command-bar-result-tool-icon\" />\n )}\n <span className=\"devic-command-bar-result-tool-name\">{tc.summary || tc.name}</span>\n </div>,\n );\n }\n callIdx += 1;\n }\n }\n\n return elements;\n }\n\n // Default: no toolGroups, render individually\n return toolCalls.map((tc) => {\n const customRenderer = opts.toolRenderers?.[tc.name];\n if (customRenderer) {\n return (\n <div key={tc.id} className=\"devic-command-bar-result-tool-item devic-command-bar-result-tool-custom\">\n {customRenderer(tc.input, tc.output)}\n </div>\n );\n }\n const customIcon = opts.toolIcons?.[tc.name];\n return (\n <div key={tc.id} className=\"devic-command-bar-result-tool-item\">\n {customIcon ? (\n <span className=\"devic-command-bar-result-tool-icon\">{customIcon}</span>\n ) : (\n <CheckIcon className=\"devic-command-bar-result-tool-icon\" />\n )}\n <span className=\"devic-command-bar-result-tool-name\">{tc.summary || tc.name}</span>\n </div>\n );\n });\n };\n\n return (\n <DevicTranslationsProvider translations={mergedOptions.translations}>\n <div\n ref={containerRef}\n className={`devic-command-bar-container ${className || ''}`}\n data-position={mergedOptions.position}\n data-visible={hook.isVisible}\n style={containerStyle}\n >\n {/* Commands dropdown */}\n {hook.showingCommands && hook.filteredCommands.length > 0 && (\n <div className=\"devic-command-bar-dropdown\">\n <div className=\"devic-command-bar-dropdown-header\">\n <span>{t('Commands')}</span>\n <span className=\"devic-command-bar-dropdown-hint\">\n <kbd>↑</kbd><kbd>↓</kbd> {t('to navigate,')} <kbd>Enter</kbd>{' '}\n {t('to select')}\n </span>\n </div>\n <div className=\"devic-command-bar-dropdown-list\">\n {hook.filteredCommands.map((cmd, index) => (\n <div\n key={cmd.keyword}\n className=\"devic-command-bar-dropdown-item\"\n data-selected={index === hook.selectedCommandIndex}\n onClick={() => hook.selectCommand(cmd)}\n onMouseEnter={() => {/* Could update selectedCommandIndex on hover */}}\n >\n {cmd.icon && (\n <span className=\"devic-command-bar-dropdown-icon\">{cmd.icon}</span>\n )}\n <span className=\"devic-command-bar-dropdown-keyword\">/{cmd.keyword}</span>\n <span className=\"devic-command-bar-dropdown-desc\">{cmd.description}</span>\n </div>\n ))}\n </div>\n </div>\n )}\n\n {/* History list */}\n {hook.showingHistory && (\n <div className=\"devic-command-bar-dropdown\">\n <div className=\"devic-command-bar-dropdown-header\">\n <span>{t('Command History')}</span>\n {hook.history.length > 0 && (\n <button\n className=\"devic-command-bar-dropdown-clear\"\n onClick={() => {\n hook.clearHistory();\n hook.setShowingHistory(false);\n }}\n type=\"button\"\n >\n {t('Clear')}\n </button>\n )}\n </div>\n <div className=\"devic-command-bar-dropdown-list\" style={resultMessageStyle}>\n {hook.history.length === 0 ? (\n <div className=\"devic-command-bar-dropdown-empty\">\n {t('No history yet')}\n </div>\n ) : (\n hook.history.map((item, index) => (\n <div\n key={`${item}-${index}`}\n className=\"devic-command-bar-dropdown-item devic-command-bar-history-item\"\n onClick={() => {\n hook.setShowingHistory(false);\n hook.setInputValue(item);\n hook.focus();\n }}\n >\n <HistoryIcon className=\"devic-command-bar-dropdown-icon\" />\n <span className=\"devic-command-bar-history-text\">{item}</span>\n </div>\n ))\n )}\n </div>\n </div>\n )}\n\n {/* Result card (above bar when completed) */}\n {mergedOptions.showResultCard && hook.result && !hook.showingHistory && !hook.showingCommands && (\n <div className=\"devic-command-bar-result\">\n {/* Tool calls section */}\n {hook.result.toolCalls.length > 0 && (\n <div className=\"devic-command-bar-result-tools\">\n <div\n className=\"devic-command-bar-result-tools-header\"\n data-expanded={toolsExpanded}\n onClick={() => setToolsExpanded(!toolsExpanded)}\n >\n <ChevronIcon className=\"devic-command-bar-result-tools-chevron\" />\n <span>{t('Tool calls')}</span>\n <span className=\"devic-command-bar-result-tools-count\">\n {hook.result.toolCalls.length}\n </span>\n </div>\n <div\n className=\"devic-command-bar-result-tools-list\"\n data-expanded={toolsExpanded}\n >\n {renderToolCallItems(hook.result.toolCalls, mergedOptions)}\n </div>\n </div>\n )}\n\n {/* Message section */}\n <div className=\"devic-command-bar-result-message\" style={resultMessageStyle}>\n {hook.result.message.content?.message || (\n <span className=\"devic-command-bar-result-empty\">\n {t('No response')}\n </span>\n )}\n </div>\n\n {/* Feedback actions */}\n <div className=\"devic-cmd-result-actions\">\n <MessageActions\n messageId={hook.result.message.uid}\n messageContent={hook.result.message.content?.message}\n currentFeedback={feedbackState}\n onFeedback={handleFeedback}\n showCopy={true}\n showFeedback={true}\n theme={feedbackTheme}\n />\n </div>\n </div>\n )}\n\n {/* Error display */}\n {hook.error && !hook.isProcessing && (\n <div className=\"devic-command-bar-error\">\n {hook.error.message}\n </div>\n )}\n\n {/* Main bar */}\n <div className=\"devic-command-bar\" style={barStyle}>\n {/* Left: Icon or Loader */}\n <div className=\"devic-command-bar-icon\">\n {hook.isProcessing ? (\n <div className=\"devic-command-bar-spinner\" />\n ) : (\n mergedOptions.icon || <SparklesIcon />\n )}\n </div>\n\n {/* Center: Input or Processing Summary */}\n {hook.isProcessing ? (\n <div className=\"devic-command-bar-summary\">\n {hook.currentToolSummary || t(mergedOptions.processingMessage)}...\n </div>\n ) : (\n <input\n ref={hook.inputRef}\n type=\"text\"\n className=\"devic-command-bar-input\"\n placeholder={t(mergedOptions.placeholder)}\n value={hook.inputValue}\n onChange={(e) => hook.setInputValue(e.target.value)}\n onKeyDown={hook.handleKeyDown}\n />\n )}\n\n {/* Right: Shortcut hint */}\n {mergedOptions.showShortcutHint && mergedOptions.shortcut && !hook.isProcessing && (\n <div className=\"devic-command-bar-shortcut\">\n {formatShortcut(mergedOptions.shortcut)}\n </div>\n )}\n </div>\n </div>\n </DevicTranslationsProvider>\n );\n }\n);\n\n/**\n * Sparkles icon (default)\n */\nfunction SparklesIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {/* Main star - 4-point diamond */}\n <path\n d=\"M10 2L11.5 8.5L18 10L11.5 11.5L10 18L8.5 11.5L2 10L8.5 8.5L10 2Z\"\n fill=\"currentColor\"\n opacity=\"0.9\"\n />\n {/* Small accent star - top right */}\n <path\n d=\"M16 3L16.5 5L18.5 5.5L16.5 6L16 8L15.5 6L13.5 5.5L15.5 5L16 3Z\"\n fill=\"currentColor\"\n opacity=\"0.6\"\n />\n {/* Tiny accent dot - bottom left */}\n <circle cx=\"4\" cy=\"15\" r=\"1\" fill=\"currentColor\" opacity=\"0.4\" />\n </svg>\n );\n}\n\n/**\n * Chevron right icon\n */\nfunction ChevronIcon({ className }: { className?: string }): JSX.Element {\n return (\n <svg\n className={className}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"9 18 15 12 9 6\" />\n </svg>\n );\n}\n\n/**\n * Check icon\n */\nfunction CheckIcon({ className }: { className?: string }): JSX.Element {\n return (\n <svg\n className={className}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"20 6 9 17 4 12\" />\n </svg>\n );\n}\n\n/**\n * History icon\n */\nfunction HistoryIcon({ className }: { className?: string }): JSX.Element {\n return (\n <svg\n className={className}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M3 3v5h5\" />\n <path d=\"M3.05 13A9 9 0 1 0 6 5.3L3 8\" />\n <path d=\"M12 7v5l4 2\" />\n </svg>\n );\n}\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;AAaA;;AAEG;AACH,SAAS,WAAW,CAAC,KAAa,EAAA;;IAEhC,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;AAClC,IAAA,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;AAC5E,QAAA,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC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Ac,EAAC,OAAO,YAEtBA,GAAA,CAAA,UAAA,EAAA,EAAU,MAAM,EAAC,gBAAgB,EAAA,CAAG,EAAA,CAChC;AAEV;AAEA;;AAEG;AACH,SAAS,WAAW,CAAC,EAAE,SAAS,EAA0B,EAAA;IACxD,QACEC,IAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,SAAS,EACpB,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EAAA,QAAA,EAAA,CAEtBD,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,UAAU,EAAA,CAAG,EACrBA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,8BAA8B,EAAA,CAAG,EACzCA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,aAAa,EAAA,CAAG,CAAA,EAAA,CACpB;AAEV;;;;"}
@@ -1,4 +1,5 @@
1
1
  import type { ChatMessage, ModelInterfaceTool, ToolGroupConfig } from '../../api/types';
2
+ import type { DevicTranslations } from '../../i18n';
2
3
  /**
3
4
  * Command definition for the command bar
4
5
  */
@@ -168,6 +169,15 @@ export interface AICommandBarOptions {
168
169
  * Tool group configurations for rendering consecutive tool calls together.
169
170
  */
170
171
  toolGroups?: ToolGroupConfig[];
172
+ /**
173
+ * Translations for the texts this component renders itself, keyed by the
174
+ * exact English text: `{ 'Cancel': 'Cancelar' }`.
175
+ *
176
+ * Merged on top of the `DevicProvider`'s `translations` and passed down to
177
+ * everything mounted below. Anything absent stays as the provider left it,
178
+ * or in English.
179
+ */
180
+ translations?: DevicTranslations;
171
181
  }
172
182
  /**
173
183
  * Result returned after command bar execution
@@ -266,6 +276,12 @@ export interface AICommandBarProps {
266
276
  * @default 1000
267
277
  */
268
278
  pollingInterval?: number;
279
+ /**
280
+ * Follow the conversation over a server-sent event stream instead of
281
+ * polling it. Overrides the DevicProvider's `streaming`.
282
+ * @default false
283
+ */
284
+ streaming?: boolean;
269
285
  /**
270
286
  * Tenant ID
271
287
  */
@@ -10,6 +10,8 @@ export interface UseAICommandBarOptions {
10
10
  tags?: string[];
11
11
  /** Poll cadence (ms) for the command in progress (overrides the provider's). */
12
12
  pollingInterval?: number;
13
+ /** Follow it over a server-sent event stream instead of polling (overrides the provider's). */
14
+ streaming?: boolean;
13
15
  options?: AICommandBarOptions;
14
16
  isVisible?: boolean;
15
17
  onVisibilityChange?: (visible: boolean) => void;
@@ -2,8 +2,9 @@ import { useState, useRef, useMemo, useEffect, useCallback } from 'react';
2
2
  import 'react/jsx-runtime';
3
3
  import { useOptionalDevicContext } from '../../provider/DevicContext.js';
4
4
  import { DevicApiClient } from '../../api/client.js';
5
- import { resolvePollingInterval, usePolling } from '../../hooks/usePolling.js';
5
+ import { resolvePollingInterval, resolveStreaming, usePolling } from '../../hooks/usePolling.js';
6
6
  import { useModelInterface } from '../../hooks/useModelInterface.js';
7
+ import { useTranslations } from '../../i18n/useTranslations.js';
7
8
 
8
9
  /**
9
10
  * Parse a shortcut string like "cmd+j" into its components
@@ -53,8 +54,9 @@ function formatToolName(toolName) {
53
54
  * Hook for managing AICommandBar state and behavior
54
55
  */
55
56
  function useAICommandBar(options) {
56
- const { assistantId, apiKey: propsApiKey, baseUrl: propsBaseUrl, tenantId, tenantMetadata, tags, pollingInterval: propsPollingInterval, options: barOptions = {}, isVisible: controlledVisible, onVisibilityChange, onExecute = 'callback', chatDrawerRef, onResponse, modelInterfaceTools = [], onSubmit, onToolCall, onError, onOpen, onClose, } = options;
57
+ const { assistantId, apiKey: propsApiKey, baseUrl: propsBaseUrl, tenantId, tenantMetadata, tags, pollingInterval: propsPollingInterval, streaming: propsStreaming, options: barOptions = {}, isVisible: controlledVisible, onVisibilityChange, onExecute = 'callback', chatDrawerRef, onResponse, modelInterfaceTools = [], onSubmit, onToolCall, onError, onOpen, onClose, } = options;
57
58
  const { shortcut } = barOptions;
59
+ const t = useTranslations(barOptions.translations);
58
60
  // Get context
59
61
  const context = useOptionalDevicContext();
60
62
  const apiKey = propsApiKey || context?.apiKey;
@@ -65,6 +67,7 @@ function useAICommandBar(options) {
65
67
  const resolvedTenantMetadata = { ...context?.tenantMetadata, ...tenantMetadata };
66
68
  const resolvedTags = Array.from(new Set([...(context?.tags ?? []), ...(tags ?? [])]));
67
69
  const pollingInterval = resolvePollingInterval(propsPollingInterval, context?.pollingInterval);
70
+ const streaming = resolveStreaming(propsStreaming, context?.streaming);
68
71
  // Visibility state
69
72
  const [internalVisible, setInternalVisible] = useState(false);
70
73
  const isVisible = controlledVisible ?? internalVisible;
@@ -106,9 +109,9 @@ function useAICommandBar(options) {
106
109
  // Built-in history command
107
110
  const historyCommand = useMemo(() => ({
108
111
  keyword: 'history',
109
- description: 'Show command history',
112
+ description: t('Show command history'),
110
113
  message: '', // Special handling
111
- }), []);
114
+ }), [t]);
112
115
  // All available commands (user commands + built-in)
113
116
  const allCommands = useMemo(() => {
114
117
  const userCommands = commands;
@@ -354,11 +357,14 @@ function useAICommandBar(options) {
354
357
  // Polling
355
358
  usePolling(shouldPoll ? chatUid : null, async () => {
356
359
  if (!clientRef.current || !chatUid) {
357
- throw new Error('Cannot poll without client or chatUid');
360
+ throw new Error(t('Cannot poll without client or chatUid'));
358
361
  }
359
362
  return clientRef.current.getRealtimeHistory(assistantId, chatUid);
360
363
  }, {
361
364
  interval: pollingInterval,
365
+ streamFn: streaming
366
+ ? (onSnapshot, signal, onActivity) => clientRef.current.streamRealtimeHistory(assistantId, chatUid, onSnapshot, signal, onActivity)
367
+ : undefined,
362
368
  enabled: shouldPoll,
363
369
  stopStatuses: ['completed', 'error', 'waiting_for_tool_response'],
364
370
  onUpdate: async (data) => {
@@ -381,7 +387,7 @@ function useAICommandBar(options) {
381
387
  setShouldPoll(false);
382
388
  if (data?.status === 'error') {
383
389
  setIsProcessing(false);
384
- const err = new Error('Processing failed');
390
+ const err = new Error(t('Processing failed'));
385
391
  setError(err);
386
392
  onErrorRef.current?.(err);
387
393
  return;
@@ -429,7 +435,7 @@ function useAICommandBar(options) {
429
435
  if (!msg.trim())
430
436
  return;
431
437
  if (!clientRef.current) {
432
- const err = new Error('API client not configured. Please provide an API key.');
438
+ const err = new Error(t('API client not configured. Please provide an API key.'));
433
439
  setError(err);
434
440
  onErrorRef.current?.(err);
435
441
  return;