@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,4 +1,5 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useTranslations } from '../../i18n/useTranslations.js';
2
3
 
3
4
  /**
4
5
  * The line above the input that says what happens to a message written while
@@ -10,7 +11,8 @@ import { jsxs, jsx } from 'react/jsx-runtime';
10
11
  * `options.queueNoticeRenderer`.
11
12
  */
12
13
  function QueueNotice({ queuedCount, willProcess, alert, }) {
13
- return (jsxs("div", { className: "devic-queue-notice", "data-alert": alert ? 'true' : undefined, role: alert ? 'alert' : 'status', children: [jsx("span", { className: "devic-queue-notice-icon", "aria-hidden": "true", children: alert ? jsx(WarningIcon, {}) : jsx(ClockIcon, {}) }), jsx("span", { children: alert || noticeText(queuedCount, willProcess) })] }));
14
+ const t = useTranslations();
15
+ return (jsxs("div", { className: "devic-queue-notice", "data-alert": alert ? 'true' : undefined, role: alert ? 'alert' : 'status', children: [jsx("span", { className: "devic-queue-notice-icon", "aria-hidden": "true", children: alert ? jsx(WarningIcon, {}) : jsx(ClockIcon, {}) }), jsx("span", { children: alert || noticeText(t, queuedCount, willProcess) })] }));
14
16
  }
15
17
  /**
16
18
  * Three different promises, so three different sentences.
@@ -20,18 +22,28 @@ function QueueNotice({ queuedCount, willProcess, alert, }) {
20
22
  * sender to finish. Telling that person the assistant will pick it up "on its
21
23
  * next turn" describes a turn that is not happening.
22
24
  */
23
- function noticeText(queuedCount, willProcess) {
25
+ function noticeText(t, queuedCount, willProcess) {
24
26
  if (queuedCount <= 0) {
25
- return 'The assistant is still answering. Send anyway and your message joins its next turn.';
27
+ return t('The assistant is still answering. Send anyway and your message joins its next turn.');
26
28
  }
27
- const subject = queuedCount === 1 ? '1 message' : `${queuedCount} messages`;
29
+ // Singular and plural are separate entries rather than a placeholder over a
30
+ // suffix: the two differ by more than an "s" in most languages.
31
+ const one = queuedCount === 1;
28
32
  if (willProcess === 'after_delay') {
29
- return `${subject} waiting — the assistant is giving you a moment to finish before it answers.`;
33
+ return one
34
+ ? t('1 message waiting — the assistant is giving you a moment to finish before it answers.')
35
+ : t('{count} messages waiting — the assistant is giving you a moment to finish before it answers.', { count: queuedCount });
30
36
  }
31
37
  if (willProcess === 'on_resume') {
32
- return `${subject} waiting — the assistant picks ${queuedCount === 1 ? 'it' : 'them'} up when it comes back to this conversation.`;
38
+ return one
39
+ ? t('1 message waiting — the assistant picks it up when it comes back to this conversation.')
40
+ : t('{count} messages waiting — the assistant picks them up when it comes back to this conversation.', { count: queuedCount });
33
41
  }
34
- return `${subject} waiting — the assistant picks ${queuedCount === 1 ? 'it' : 'them'} up on its next turn.`;
42
+ return one
43
+ ? t('1 message waiting — the assistant picks it up on its next turn.')
44
+ : t('{count} messages waiting — the assistant picks them up on its next turn.', {
45
+ count: queuedCount,
46
+ });
35
47
  }
36
48
  function WarningIcon() {
37
49
  return (jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsx("path", { d: "M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" }), jsx("line", { x1: "12", y1: "9", x2: "12", y2: "13" }), jsx("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })] }));
@@ -1 +1 @@
1
- {"version":3,"file":"QueueNotice.js","sources":["../../../../src/components/ChatDrawer/QueueNotice.tsx"],"sourcesContent":["import React from 'react';\nimport type { QueueDisposition } from '../../api/types';\n\nexport interface QueueNoticeProps {\n /** How many messages are waiting on this conversation right now. */\n queuedCount: number;\n /** What the last accepted message was told. Shapes the wording. */\n willProcess?: QueueDisposition;\n /**\n * Something happened to a message that the count alone does not explain — it\n * was turned down, or a stop threw it away. Replaces the standing text while\n * it is set, since it is the more urgent of the two.\n */\n alert?: string;\n}\n\n/**\n * The line above the input that says what happens to a message written while\n * the assistant is working.\n *\n * Writing into a conversation that is busy is allowed but not obvious, so it is\n * spelled out twice: before sending, what the button will do; after, what became\n * of it. Suppress it with `options.hideQueueNotice`, or replace it with\n * `options.queueNoticeRenderer`.\n */\nexport function QueueNotice({\n queuedCount,\n willProcess,\n alert,\n}: QueueNoticeProps): JSX.Element {\n return (\n <div\n className=\"devic-queue-notice\"\n data-alert={alert ? 'true' : undefined}\n role={alert ? 'alert' : 'status'}\n >\n <span className=\"devic-queue-notice-icon\" aria-hidden=\"true\">\n {alert ? <WarningIcon /> : <ClockIcon />}\n </span>\n <span>{alert || noticeText(queuedCount, willProcess)}</span>\n </div>\n );\n}\n\n/**\n * Three different promises, so three different sentences.\n *\n * `after_delay` is the one that is easy to get wrong: an assistant with an input\n * delay queues what is written while the conversation is *idle*, waiting for the\n * sender to finish. Telling that person the assistant will pick it up \"on its\n * next turn\" describes a turn that is not happening.\n */\nfunction noticeText(\n queuedCount: number,\n willProcess?: QueueDisposition\n): string {\n if (queuedCount <= 0) {\n return 'The assistant is still answering. Send anyway and your message joins its next turn.';\n }\n\n const subject = queuedCount === 1 ? '1 message' : `${queuedCount} messages`;\n\n if (willProcess === 'after_delay') {\n return `${subject} waiting — the assistant is giving you a moment to finish before it answers.`;\n }\n if (willProcess === 'on_resume') {\n return `${subject} waiting — the assistant picks ${\n queuedCount === 1 ? 'it' : 'them'\n } up when it comes back to this conversation.`;\n }\n return `${subject} waiting — the assistant picks ${\n queuedCount === 1 ? 'it' : 'them'\n } up on its next turn.`;\n}\n\nfunction WarningIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\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=\"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z\" />\n <line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\" />\n <line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\" />\n </svg>\n );\n}\n\nfunction ClockIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"9\" />\n <polyline points=\"12 7 12 12 15 14\" />\n </svg>\n );\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;AAgBA;;;;;;;;AAQG;AACG,SAAU,WAAW,CAAC,EAC1B,WAAW,EACX,WAAW,E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X,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,CAEtBC,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,0FAA0F,EAAA,CAAG,EACrGA,cAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,EACvCA,GAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,OAAO,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,CAAA,EAAA,CACvC;AAEV;AAEA,SAAS,SAAS,GAAA;IAChB,QACED,IAAA,CAAA,KAAA,EAAA,EACE,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,CAEtBC,GAAA,CAAA,QAAA,EAAA,EAAQ,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,GAAG,EAAA,CAAG,EAChCA,GAAA,CAAA,UAAA,EAAA,EAAU,MAAM,EAAC,kBAAkB,EAAA,CAAG,CAAA,EAAA,CAClC;AAEV;;"}
1
+ {"version":3,"file":"QueueNotice.js","sources":["../../../../src/components/ChatDrawer/QueueNotice.tsx"],"sourcesContent":["import React from 'react';\nimport type { QueueDisposition } from '../../api/types';\nimport { useTranslations } from '../../i18n';\nimport type { Translator } from '../../i18n';\n\nexport interface QueueNoticeProps {\n /** How many messages are waiting on this conversation right now. */\n queuedCount: number;\n /** What the last accepted message was told. Shapes the wording. */\n willProcess?: QueueDisposition;\n /**\n * Something happened to a message that the count alone does not explain — it\n * was turned down, or a stop threw it away. Replaces the standing text while\n * it is set, since it is the more urgent of the two.\n */\n alert?: string;\n}\n\n/**\n * The line above the input that says what happens to a message written while\n * the assistant is working.\n *\n * Writing into a conversation that is busy is allowed but not obvious, so it is\n * spelled out twice: before sending, what the button will do; after, what became\n * of it. Suppress it with `options.hideQueueNotice`, or replace it with\n * `options.queueNoticeRenderer`.\n */\nexport function QueueNotice({\n queuedCount,\n willProcess,\n alert,\n}: QueueNoticeProps): JSX.Element {\n const t = useTranslations();\n return (\n <div\n className=\"devic-queue-notice\"\n data-alert={alert ? 'true' : undefined}\n role={alert ? 'alert' : 'status'}\n >\n <span className=\"devic-queue-notice-icon\" aria-hidden=\"true\">\n {alert ? <WarningIcon /> : <ClockIcon />}\n </span>\n <span>{alert || noticeText(t, queuedCount, willProcess)}</span>\n </div>\n );\n}\n\n/**\n * Three different promises, so three different sentences.\n *\n * `after_delay` is the one that is easy to get wrong: an assistant with an input\n * delay queues what is written while the conversation is *idle*, waiting for the\n * sender to finish. Telling that person the assistant will pick it up \"on its\n * next turn\" describes a turn that is not happening.\n */\nfunction noticeText(\n t: Translator,\n queuedCount: number,\n willProcess?: QueueDisposition\n): string {\n if (queuedCount <= 0) {\n return t(\n 'The assistant is still answering. Send anyway and your message joins its next turn.'\n );\n }\n\n // Singular and plural are separate entries rather than a placeholder over a\n // suffix: the two differ by more than an \"s\" in most languages.\n const one = queuedCount === 1;\n\n if (willProcess === 'after_delay') {\n return one\n ? t(\n '1 message waiting — the assistant is giving you a moment to finish before it answers.'\n )\n : t(\n '{count} messages waiting — the assistant is giving you a moment to finish before it answers.',\n { count: queuedCount }\n );\n }\n if (willProcess === 'on_resume') {\n return one\n ? t(\n '1 message waiting — the assistant picks it up when it comes back to this conversation.'\n )\n : t(\n '{count} messages waiting — the assistant picks them up when it comes back to this conversation.',\n { count: queuedCount }\n );\n }\n return one\n ? t('1 message waiting — the assistant picks it up on its next turn.')\n : t('{count} messages waiting the assistant picks them up on its next turn.', {\n count: queuedCount,\n });\n}\n\nfunction WarningIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\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=\"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z\" />\n <line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\" />\n <line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\" />\n </svg>\n );\n}\n\nfunction ClockIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"9\" />\n <polyline points=\"12 7 12 12 15 14\" />\n </svg>\n );\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAkBA;;;;;;;;AAQG;AACG,SAAU,WAAW,CAAC,EAC1B,WAAW,EACX,WAAW,EACX,KAAK,GACY,EAAA;AACjB,IAAA,MAAM,CAAC,GAAG,eAAe,EAAE;AAC3B,IAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAC,oBAAoB,EAAA,YAAA,EAClB,KAAK,GAAG,MAAM,GAAG,SAAS,EACtC,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,EAAA,QAAA,EAAA,CAEhCC,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,yBAAyB,EAAA,aAAA,EAAa,MAAM,EAAA,QAAA,EACzD,KAAK,GAAGA,GAAA,CAAC,WAAW,EAAA,EAAA,CAAG,GAAGA,GAAA,CAAC,SAAS,EAAA,EAAA,CAAG,E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,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,EACvCA,GAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,OAAO,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,CAAA,EAAA,CACvC;AAEV;AAEA,SAAS,SAAS,GAAA;IAChB,QACED,IAAA,CAAA,KAAA,EAAA,EACE,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,CAEtBC,GAAA,CAAA,QAAA,EAAA,EAAQ,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,GAAG,EAAA,CAAG,EAChCA,GAAA,CAAA,UAAA,EAAA,EAAU,MAAM,EAAC,kBAAkB,EAAA,CAAG,CAAA,EAAA,CAClC;AAEV;;;;"}
@@ -1,5 +1,6 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import { useState } from 'react';
3
+ import { useTranslations } from '../../i18n/useTranslations.js';
3
4
 
4
5
  const SOURCE_LABELS = {
5
6
  conversation_start: "Automatic recall",
@@ -47,6 +48,7 @@ function ChevronIcon({ up }) {
47
48
  * Renders nothing when the records carry no content.
48
49
  */
49
50
  function RecalledMemoriesWidget({ records, isLoading = false, renderer, }) {
51
+ const t = useTranslations();
50
52
  const [expanded, setExpanded] = useState(false);
51
53
  if (renderer) {
52
54
  return jsx(Fragment, { children: renderer({ records, isLoading }) });
@@ -56,19 +58,29 @@ function RecalledMemoriesWidget({ records, isLoading = false, renderer, }) {
56
58
  const turns = records
57
59
  .filter((r) => r.source === "conversation_start")
58
60
  .flatMap((r) => r.turns ?? []);
59
- const sources = [...new Set(records.map((r) => SOURCE_LABELS[r.source]))];
61
+ const sources = [
62
+ ...new Set(records.map((r) => t(SOURCE_LABELS[r.source]))),
63
+ ];
60
64
  if (!facts.length && !entities.length && !turns.length)
61
65
  return null;
62
66
  const summaryParts = [];
63
67
  if (facts.length) {
64
- summaryParts.push(`${facts.length} fact${facts.length > 1 ? "s" : ""}`);
68
+ summaryParts.push(facts.length === 1
69
+ ? t("1 fact")
70
+ : t("{count} facts", { count: facts.length }));
65
71
  }
66
72
  if (entities.length) {
67
- summaryParts.push(`${entities.length} entit${entities.length > 1 ? "ies" : "y"}`);
73
+ summaryParts.push(entities.length === 1
74
+ ? t("1 entity")
75
+ : t("{count} entities", { count: entities.length }));
68
76
  }
69
- return (jsxs("div", { className: "devic-recall", children: [jsxs("button", { type: "button", className: "devic-recall-header", onClick: () => setExpanded((v) => !v), "aria-expanded": expanded, children: [jsx(BrainIcon, {}), jsx("span", { className: "devic-recall-title", children: "Recalled memories" }), summaryParts.length > 0 && (jsx("span", { className: "devic-recall-summary", children: summaryParts.join(" · ") })), jsx("span", { className: "devic-recall-spacer" }), sources.map((s) => (jsx("span", { className: "devic-recall-source", children: s }, s))), jsx(ChevronIcon, { up: expanded })] }), expanded && (jsxs("div", { className: "devic-recall-body", children: [facts.length > 0 && (jsx("div", { className: "devic-recall-facts", children: facts.map((fact, i) => (jsxs("div", { className: "devic-recall-fact", children: [jsx("span", { children: fact.fact }), jsxs("span", { className: "devic-recall-fact-meta", children: [fact.source && fact.target
77
+ return (jsxs("div", { className: "devic-recall", children: [jsxs("button", { type: "button", className: "devic-recall-header", onClick: () => setExpanded((v) => !v), "aria-expanded": expanded, children: [jsx(BrainIcon, {}), jsx("span", { className: "devic-recall-title", children: t("Recalled memories") }), summaryParts.length > 0 && (jsx("span", { className: "devic-recall-summary", children: summaryParts.join(" · ") })), jsx("span", { className: "devic-recall-spacer" }), sources.map((s) => (jsx("span", { className: "devic-recall-source", children: s }, s))), jsx(ChevronIcon, { up: expanded })] }), expanded && (jsxs("div", { className: "devic-recall-body", children: [facts.length > 0 && (jsx("div", { className: "devic-recall-facts", children: facts.map((fact, i) => (jsxs("div", { className: "devic-recall-fact", children: [jsx("span", { children: fact.fact }), jsxs("span", { className: "devic-recall-fact-meta", children: [fact.source && fact.target
70
78
  ? `${fact.source} → ${fact.relation} → ${fact.target}`
71
- : fact.relation, fact.validAt ? ` · since ${fact.validAt.slice(0, 10)}` : ""] })] }, i))) })), entities.length > 0 && (jsx("div", { className: "devic-recall-entities", children: entities.map((entity) => (jsxs("span", { className: "devic-recall-entity", title: entity.summary || undefined, children: [entity.name, jsxs("span", { className: "devic-recall-entity-type", children: [" ", "\u00B7 ", entity.type] })] }, entity.id))) })), turns.length > 0 && (jsxs("div", { className: "devic-recall-turns", children: [jsx("span", { className: "devic-recall-turns-title", children: "Previous session context" }), turns.map((turn, i) => (jsxs("span", { className: "devic-recall-turn", children: [jsxs("span", { className: "devic-recall-turn-role", children: [turn.role, ":"] }), " ", turn.content] }, i)))] }))] }))] }));
79
+ : fact.relation, fact.validAt
80
+ ? ` · ${t("since {date}", {
81
+ date: fact.validAt.slice(0, 10),
82
+ })}`
83
+ : ""] })] }, i))) })), entities.length > 0 && (jsx("div", { className: "devic-recall-entities", children: entities.map((entity) => (jsxs("span", { className: "devic-recall-entity", title: entity.summary || undefined, children: [entity.name, jsxs("span", { className: "devic-recall-entity-type", children: [" ", "\u00B7 ", entity.type] })] }, entity.id))) })), turns.length > 0 && (jsxs("div", { className: "devic-recall-turns", children: [jsx("span", { className: "devic-recall-turns-title", children: t("Previous session context") }), turns.map((turn, i) => (jsxs("span", { className: "devic-recall-turn", children: [jsxs("span", { className: "devic-recall-turn-role", children: [turn.role, ":"] }), " ", turn.content] }, i)))] }))] }))] }));
72
84
  }
73
85
 
74
86
  export { RecalledMemoriesWidget };
@@ -1 +1 @@
1
- {"version":3,"file":"RecalledMemoriesWidget.js","sources":["../../../../src/components/ChatDrawer/RecalledMemoriesWidget.tsx"],"sourcesContent":["import { useState, type JSX, type ReactNode } from \"react\";\nimport type {\n RecalledMemoryEntity,\n RecalledMemoryFact,\n RecalledMemoryRecord,\n} from \"../../api/types\";\n\n/** Data handed to a custom recalled-memories renderer. */\nexport interface RecalledMemoriesRendererProps {\n /** The recall events anchored at this point of the conversation. */\n records: RecalledMemoryRecord[];\n /** True while the run that produced (or is producing) them is in flight. */\n isLoading: boolean;\n}\n\n/** Replaces the built-in \"Recalled memories\" strip. Return null to hide it. */\nexport type RecalledMemoriesRenderer = (\n props: RecalledMemoriesRendererProps\n) => ReactNode;\n\nconst SOURCE_LABELS: Record<RecalledMemoryRecord[\"source\"], string> = {\n conversation_start: \"Automatic recall\",\n search_memory: \"Memory search\",\n search_memory_nodes: \"Graph node search\",\n explore_memory_graph: \"Graph exploration\",\n};\n\nfunction dedupeFacts(records: RecalledMemoryRecord[]): RecalledMemoryFact[] {\n const seen = new Set<string>();\n const facts: RecalledMemoryFact[] = [];\n for (const record of records) {\n for (const fact of record.facts ?? []) {\n const key = (fact.fact ?? \"\").trim().toLowerCase();\n if (!key || seen.has(key)) continue;\n seen.add(key);\n facts.push(fact);\n }\n }\n return facts;\n}\n\nfunction dedupeEntities(\n records: RecalledMemoryRecord[]\n): RecalledMemoryEntity[] {\n const seen = new Set<string>();\n return records\n .flatMap((r) => r.entities ?? [])\n .filter((e) => {\n const key = (e.name ?? \"\").trim().toLowerCase();\n if (!key || seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n\nfunction BrainIcon(): JSX.Element {\n return (\n <svg\n className=\"devic-recall-icon\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M9.5 2a2.5 2.5 0 0 0-2.45 2A3.5 3.5 0 0 0 4.6 8.6 3.5 3.5 0 0 0 3 11.5c0 1.1.5 2.08 1.29 2.73A3.5 3.5 0 0 0 7 20a3 3 0 0 0 5-2.24V4.5A2.5 2.5 0 0 0 9.5 2Z\" />\n <path d=\"M14.5 2a2.5 2.5 0 0 1 2.45 2 3.5 3.5 0 0 1 2.45 4.6A3.5 3.5 0 0 1 21 11.5a3.49 3.49 0 0 1-1.29 2.73A3.5 3.5 0 0 1 17 20a3 3 0 0 1-5-2.24V4.5A2.5 2.5 0 0 1 14.5 2Z\" />\n </svg>\n );\n}\n\nfunction ChevronIcon({ up }: { up: boolean }): JSX.Element {\n return (\n <svg\n className=\"devic-recall-chevron\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n style={{ transform: up ? \"rotate(180deg)\" : undefined }}\n >\n <polyline points=\"6 9 12 15 18 9\" />\n </svg>\n );\n}\n\nexport interface RecalledMemoriesWidgetProps {\n records: RecalledMemoryRecord[];\n /** True while the run that produced the records is still processing. */\n isLoading?: boolean;\n /** Custom renderer replacing the built-in strip. */\n renderer?: RecalledMemoriesRenderer;\n}\n\n/**\n * Collapsible \"Recalled memories\" strip interleaved in the chat with the\n * message that brought long-term memories into the conversation. Collapsed it\n * summarizes (\"N facts · M entities\"); expanded it lists the facts (with\n * their graph endpoints), the entities and any previous-session context.\n * Renders nothing when the records carry no content.\n */\nexport function RecalledMemoriesWidget({\n records,\n isLoading = false,\n renderer,\n}: RecalledMemoriesWidgetProps): JSX.Element | null {\n const [expanded, setExpanded] = useState(false);\n\n if (renderer) {\n return <>{renderer({ records, isLoading })}</>;\n }\n\n const facts = dedupeFacts(records);\n const entities = dedupeEntities(records);\n const turns = records\n .filter((r) => r.source === \"conversation_start\")\n .flatMap((r) => r.turns ?? []);\n const sources = [...new Set(records.map((r) => SOURCE_LABELS[r.source]))];\n\n if (!facts.length && !entities.length && !turns.length) return null;\n\n const summaryParts: string[] = [];\n if (facts.length) {\n summaryParts.push(`${facts.length} fact${facts.length > 1 ? \"s\" : \"\"}`);\n }\n if (entities.length) {\n summaryParts.push(\n `${entities.length} entit${entities.length > 1 ? \"ies\" : \"y\"}`\n );\n }\n\n return (\n <div className=\"devic-recall\">\n <button\n type=\"button\"\n className=\"devic-recall-header\"\n onClick={() => setExpanded((v) => !v)}\n aria-expanded={expanded}\n >\n <BrainIcon />\n <span className=\"devic-recall-title\">Recalled memories</span>\n {summaryParts.length > 0 && (\n <span className=\"devic-recall-summary\">\n {summaryParts.join(\" · \")}\n </span>\n )}\n <span className=\"devic-recall-spacer\" />\n {sources.map((s) => (\n <span key={s} className=\"devic-recall-source\">\n {s}\n </span>\n ))}\n <ChevronIcon up={expanded} />\n </button>\n\n {expanded && (\n <div className=\"devic-recall-body\">\n {facts.length > 0 && (\n <div className=\"devic-recall-facts\">\n {facts.map((fact, i) => (\n <div key={i} className=\"devic-recall-fact\">\n <span>{fact.fact}</span>\n <span className=\"devic-recall-fact-meta\">\n {fact.source && fact.target\n ? `${fact.source} → ${fact.relation} → ${fact.target}`\n : fact.relation}\n {fact.validAt ? ` · since ${fact.validAt.slice(0, 10)}` : \"\"}\n </span>\n </div>\n ))}\n </div>\n )}\n\n {entities.length > 0 && (\n <div className=\"devic-recall-entities\">\n {entities.map((entity) => (\n <span\n key={entity.id}\n className=\"devic-recall-entity\"\n title={entity.summary || undefined}\n >\n {entity.name}\n <span className=\"devic-recall-entity-type\">\n {\" \"}\n · {entity.type}\n </span>\n </span>\n ))}\n </div>\n )}\n\n {turns.length > 0 && (\n <div className=\"devic-recall-turns\">\n <span className=\"devic-recall-turns-title\">\n Previous session context\n </span>\n {turns.map((turn, i) => (\n <span key={i} className=\"devic-recall-turn\">\n <span className=\"devic-recall-turn-role\">{turn.role}:</span>{\" \"}\n {turn.content}\n </span>\n ))}\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n\nexport default RecalledMemoriesWidget;\n"],"names":["_jsxs","_js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A,CACE,CACP,IACG,CACP,CAAA,EAAA,CACG;AAEV;;"}
1
+ {"version":3,"file":"RecalledMemoriesWidget.js","sources":["../../../../src/components/ChatDrawer/RecalledMemoriesWidget.tsx"],"sourcesContent":["import { useState, type JSX, type ReactNode } from \"react\";\nimport { useTranslations } from \"../../i18n\";\nimport type {\n RecalledMemoryEntity,\n RecalledMemoryFact,\n RecalledMemoryRecord,\n} from \"../../api/types\";\n\n/** Data handed to a custom recalled-memories renderer. */\nexport interface RecalledMemoriesRendererProps {\n /** The recall events anchored at this point of the conversation. */\n records: RecalledMemoryRecord[];\n /** True while the run that produced (or is producing) them is in flight. */\n isLoading: boolean;\n}\n\n/** Replaces the built-in \"Recalled memories\" strip. Return null to hide it. */\nexport type RecalledMemoriesRenderer = (\n props: RecalledMemoriesRendererProps\n) => ReactNode;\n\nconst SOURCE_LABELS: Record<RecalledMemoryRecord[\"source\"], string> = {\n conversation_start: \"Automatic recall\",\n search_memory: \"Memory search\",\n search_memory_nodes: \"Graph node search\",\n explore_memory_graph: \"Graph exploration\",\n};\n\nfunction dedupeFacts(records: RecalledMemoryRecord[]): RecalledMemoryFact[] {\n const seen = new Set<string>();\n const facts: RecalledMemoryFact[] = [];\n for (const record of records) {\n for (const fact of record.facts ?? []) {\n const key = (fact.fact ?? \"\").trim().toLowerCase();\n if (!key || seen.has(key)) continue;\n seen.add(key);\n facts.push(fact);\n }\n }\n return facts;\n}\n\nfunction dedupeEntities(\n records: RecalledMemoryRecord[]\n): RecalledMemoryEntity[] {\n const seen = new Set<string>();\n return records\n .flatMap((r) => r.entities ?? [])\n .filter((e) => {\n const key = (e.name ?? \"\").trim().toLowerCase();\n if (!key || seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n\nfunction BrainIcon(): JSX.Element {\n return (\n <svg\n className=\"devic-recall-icon\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M9.5 2a2.5 2.5 0 0 0-2.45 2A3.5 3.5 0 0 0 4.6 8.6 3.5 3.5 0 0 0 3 11.5c0 1.1.5 2.08 1.29 2.73A3.5 3.5 0 0 0 7 20a3 3 0 0 0 5-2.24V4.5A2.5 2.5 0 0 0 9.5 2Z\" />\n <path d=\"M14.5 2a2.5 2.5 0 0 1 2.45 2 3.5 3.5 0 0 1 2.45 4.6A3.5 3.5 0 0 1 21 11.5a3.49 3.49 0 0 1-1.29 2.73A3.5 3.5 0 0 1 17 20a3 3 0 0 1-5-2.24V4.5A2.5 2.5 0 0 1 14.5 2Z\" />\n </svg>\n );\n}\n\nfunction ChevronIcon({ up }: { up: boolean }): JSX.Element {\n return (\n <svg\n className=\"devic-recall-chevron\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n style={{ transform: up ? \"rotate(180deg)\" : undefined }}\n >\n <polyline points=\"6 9 12 15 18 9\" />\n </svg>\n );\n}\n\nexport interface RecalledMemoriesWidgetProps {\n records: RecalledMemoryRecord[];\n /** True while the run that produced the records is still processing. */\n isLoading?: boolean;\n /** Custom renderer replacing the built-in strip. */\n renderer?: RecalledMemoriesRenderer;\n}\n\n/**\n * Collapsible \"Recalled memories\" strip interleaved in the chat with the\n * message that brought long-term memories into the conversation. Collapsed it\n * summarizes (\"N facts · M entities\"); expanded it lists the facts (with\n * their graph endpoints), the entities and any previous-session context.\n * Renders nothing when the records carry no content.\n */\nexport function RecalledMemoriesWidget({\n records,\n isLoading = false,\n renderer,\n}: RecalledMemoriesWidgetProps): JSX.Element | null {\n const t = useTranslations();\n const [expanded, setExpanded] = useState(false);\n\n if (renderer) {\n return <>{renderer({ records, isLoading })}</>;\n }\n\n const facts = dedupeFacts(records);\n const entities = dedupeEntities(records);\n const turns = records\n .filter((r) => r.source === \"conversation_start\")\n .flatMap((r) => r.turns ?? []);\n const sources = [\n ...new Set(records.map((r) => t(SOURCE_LABELS[r.source]))),\n ];\n\n if (!facts.length && !entities.length && !turns.length) return null;\n\n const summaryParts: string[] = [];\n if (facts.length) {\n summaryParts.push(\n facts.length === 1\n ? t(\"1 fact\")\n : t(\"{count} facts\", { count: facts.length })\n );\n }\n if (entities.length) {\n summaryParts.push(\n entities.length === 1\n ? t(\"1 entity\")\n : t(\"{count} entities\", { count: entities.length })\n );\n }\n\n return (\n <div className=\"devic-recall\">\n <button\n type=\"button\"\n className=\"devic-recall-header\"\n onClick={() => setExpanded((v) => !v)}\n aria-expanded={expanded}\n >\n <BrainIcon />\n <span className=\"devic-recall-title\">{t(\"Recalled memories\")}</span>\n {summaryParts.length > 0 && (\n <span className=\"devic-recall-summary\">\n {summaryParts.join(\" · \")}\n </span>\n )}\n <span className=\"devic-recall-spacer\" />\n {sources.map((s) => (\n <span key={s} className=\"devic-recall-source\">\n {s}\n </span>\n ))}\n <ChevronIcon up={expanded} />\n </button>\n\n {expanded && (\n <div className=\"devic-recall-body\">\n {facts.length > 0 && (\n <div className=\"devic-recall-facts\">\n {facts.map((fact, i) => (\n <div key={i} className=\"devic-recall-fact\">\n <span>{fact.fact}</span>\n <span className=\"devic-recall-fact-meta\">\n {fact.source && fact.target\n ? `${fact.source} → ${fact.relation} → ${fact.target}`\n : fact.relation}\n {fact.validAt\n ? ` · ${t(\"since {date}\", {\n date: fact.validAt.slice(0, 10),\n })}`\n : \"\"}\n </span>\n </div>\n ))}\n </div>\n )}\n\n {entities.length > 0 && (\n <div className=\"devic-recall-entities\">\n {entities.map((entity) => (\n <span\n key={entity.id}\n className=\"devic-recall-entity\"\n title={entity.summary || undefined}\n >\n {entity.name}\n <span className=\"devic-recall-entity-type\">\n {\" \"}\n · {entity.type}\n </span>\n </span>\n ))}\n </div>\n )}\n\n {turns.length > 0 && (\n <div className=\"devic-recall-turns\">\n <span className=\"devic-recall-turns-title\">\n {t(\"Previous session context\")}\n </span>\n {turns.map((turn, i) => (\n <span key={i} className=\"devic-recall-turn\">\n <span className=\"devic-recall-turn-role\">{turn.role}:</span>{\" \"}\n {turn.content}\n </span>\n ))}\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n\nexport default RecalledMemoriesWidget;\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;AAqBA,MAAM,aAAa,GAAmD;AACpE,IAAA,kBAAkB,EAAE,kBAAkB;AACtC,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,mBAAmB,EAAE,mBAAmB;AACxC,IAAA,oBAAoB,EAAE,mBAAmB;CAC1C;AAED,SAAS,WAAW,CAAC,OAA+B,EAAA;AAClD,IAAA,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU;IAC9B,MAAM,KAAK,GAAyB,EAAE;AACtC,IAAA,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE;AACrC,YAAA,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE;YAClD,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE;AAC3B,YAAA,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AACb,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAClB;IACF;AACA,IAAA,OAAO,KAAK;AACd;AAEA,SAAS,cAAc,CACrB,OAA+B,EAAA;AAE/B,IAAA,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU;AAC9B,IAAA,OAAO;SACJ,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,IAAI,EAAE;AAC/B,SAAA,MAAM,CAAC,CAAC,CAAC,KAAI;AACZ,QAAA,MAAM,GAAG,GAAG,CAAC,C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AAA,EAAA,EAAK,SAAS,EAAC,oBAAoB,aACjCC,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,0BAA0B,EAAA,QAAA,EACvC,CAAC,CAAC,0BAA0B,CAAC,EAAA,CACzB,EACN,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,MACjBD,IAAA,CAAA,MAAA,EAAA,EAAc,SAAS,EAAC,mBAAmB,EAAA,QAAA,EAAA,CACzCA,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,wBAAwB,EAAA,QAAA,EAAA,CAAE,IAAI,CAAC,IAAI,EAAA,GAAA,CAAA,EAAA,CAAS,EAAC,GAAG,EAC/D,IAAI,CAAC,OAAO,CAAA,EAAA,EAFJ,CAAC,CAGL,CACR,CAAC,CAAA,EAAA,CACE,CACP,CAAA,EAAA,CACG,CACP,CAAA,EAAA,CACG;AAEV;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useTranslations } from '../../i18n/useTranslations.js';
2
3
 
3
4
  /**
4
5
  * Reusable chip node for an AIElementWrapper reference. Shared by the
@@ -7,10 +8,11 @@ import { jsxs, jsx } from 'react/jsx-runtime';
7
8
  * exact same chip markup and styling.
8
9
  */
9
10
  function ReferenceChip({ label, onRemove, variant = "input", icon, className, }) {
11
+ const t = useTranslations();
10
12
  const base = variant === "message"
11
13
  ? "devic-message-reference-chip"
12
14
  : "devic-reference-chip";
13
- return (jsxs("div", { className: className ? `${base} ${className}` : base, title: label, children: [icon ?? jsx(ReferenceArrowIcon, {}), jsxs("span", { className: `${base}-label`, children: ["\"", label, "\""] }), onRemove && (jsx("button", { type: "button", className: "devic-reference-chip-remove", onClick: onRemove, "aria-label": "Quitar referencia", children: "\u00D7" }))] }));
15
+ return (jsxs("div", { className: className ? `${base} ${className}` : base, title: label, children: [icon ?? jsx(ReferenceArrowIcon, {}), jsxs("span", { className: `${base}-label`, children: ["\"", label, "\""] }), onRemove && (jsx("button", { type: "button", className: "devic-reference-chip-remove", onClick: onRemove, "aria-label": t("Remove reference"), children: "\u00D7" }))] }));
14
16
  }
15
17
  /** Corner-down-right arrow used as the default reference glyph. */
16
18
  function ReferenceArrowIcon() {
@@ -1 +1 @@
1
- {"version":3,"file":"ReferenceChip.js","sources":["../../../../src/components/ChatDrawer/ReferenceChip.tsx"],"sourcesContent":["import React from \"react\";\n\n/**\n * Visual context a {@link ReferenceChip} is rendered in:\n * - `input`: inside the prompt box, as an editable, removable chip.\n * - `message`: above a sent user bubble, as a read-only chip.\n */\nexport type ReferenceChipVariant = \"input\" | \"message\";\n\nexport interface ReferenceChipProps {\n /** Short label shown inside the chip (quoted automatically). */\n label: string;\n /**\n * When provided, renders a remove (×) button that invokes this handler.\n * Only meaningful for the `input` variant.\n */\n onRemove?: () => void;\n /** Visual context. Defaults to `input`. */\n variant?: ReferenceChipVariant;\n /** Optional custom icon replacing the default reference arrow. */\n icon?: React.ReactNode;\n /** Extra className appended to the chip root. */\n className?: string;\n}\n\n/**\n * Reusable chip node for an AIElementWrapper reference. Shared by the\n * ChatInput (active references in the prompt box) and ChatMessages\n * (references parsed out of a sent user message), so both render the\n * exact same chip markup and styling.\n */\nexport function ReferenceChip({\n label,\n onRemove,\n variant = \"input\",\n icon,\n className,\n}: ReferenceChipProps): JSX.Element {\n const base =\n variant === \"message\"\n ? \"devic-message-reference-chip\"\n : \"devic-reference-chip\";\n\n return (\n <div className={className ? `${base} ${className}` : base} title={label}>\n {icon ?? <ReferenceArrowIcon />}\n <span className={`${base}-label`}>\"{label}\"</span>\n {onRemove && (\n <button\n type=\"button\"\n className=\"devic-reference-chip-remove\"\n onClick={onRemove}\n aria-label=\"Quitar referencia\"\n >\n &times;\n </button>\n )}\n </div>\n );\n}\n\n/** Corner-down-right arrow used as the default reference glyph. */\nfunction ReferenceArrowIcon(): JSX.Element {\n return (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <polyline points=\"15 10 20 15 15 20\" />\n <path d=\"M4 4v7a4 4 0 0 0 4 4h12\" />\n </svg>\n );\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;AAyBA;;;;;AAKG;AACG,SAAU,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,OAAO,EACjB,IAAI,EACJ,SAAS,GACU,EAAA;AACnB,IAAA,MAAM,IAAI,GACR,OAAO,KAAK;AACV,UAAE;UACA,sBAAsB;IAE5B,QACEA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,SAAS,GAAG,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,SAAS,CAAA,CAAE,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,EAAA,QAAA,EAAA,CACpE,IAAI,IAAIC,GAAA,CAAC,kBAAkB,EAAA,EAAA,CAAG,EAC/BD,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,CAAA,EAAG,IAAI,CAAA,MAAA,CAAQ,EAAA,QAAA,EAAA,CAAA,IAAA,EAAI,KAAK,EAAA,IAAA,CAAA,EAAA,CAAS,EACjD,QAAQ,KACPC,GAAA,CAAA,QAAA,EAAA,EACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,6BAA6B,EACvC,OAAO,EAAE,QAAQ,EAAA,YAAA,EACN,mBAAmB,EAAA,QAAA,EAAA,QAAA,EAAA,CAGvB,CACV,CAAA,EAAA,CACG;AAEV;AAEA;AACA,SAAS,kBAAkB,GAAA;IACzB,QACED,cACE,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,aAAA,EACV,MAAM,EAAA,QAAA,EAAA,CAElBC,GAAA,CAAA,UAAA,EAAA,EAAU,MAAM,EAAC,mBAAmB,EAAA,CAAG,EACvCA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,yBAAyB,EAAA,CAAG,CAAA,EAAA,CAChC;AAEV;;"}
1
+ {"version":3,"file":"ReferenceChip.js","sources":["../../../../src/components/ChatDrawer/ReferenceChip.tsx"],"sourcesContent":["import React from \"react\";\nimport { useTranslations } from \"../../i18n\";\n\n/**\n * Visual context a {@link ReferenceChip} is rendered in:\n * - `input`: inside the prompt box, as an editable, removable chip.\n * - `message`: above a sent user bubble, as a read-only chip.\n */\nexport type ReferenceChipVariant = \"input\" | \"message\";\n\nexport interface ReferenceChipProps {\n /** Short label shown inside the chip (quoted automatically). */\n label: string;\n /**\n * When provided, renders a remove (×) button that invokes this handler.\n * Only meaningful for the `input` variant.\n */\n onRemove?: () => void;\n /** Visual context. Defaults to `input`. */\n variant?: ReferenceChipVariant;\n /** Optional custom icon replacing the default reference arrow. */\n icon?: React.ReactNode;\n /** Extra className appended to the chip root. */\n className?: string;\n}\n\n/**\n * Reusable chip node for an AIElementWrapper reference. Shared by the\n * ChatInput (active references in the prompt box) and ChatMessages\n * (references parsed out of a sent user message), so both render the\n * exact same chip markup and styling.\n */\nexport function ReferenceChip({\n label,\n onRemove,\n variant = \"input\",\n icon,\n className,\n}: ReferenceChipProps): JSX.Element {\n const t = useTranslations();\n const base =\n variant === \"message\"\n ? \"devic-message-reference-chip\"\n : \"devic-reference-chip\";\n\n return (\n <div className={className ? `${base} ${className}` : base} title={label}>\n {icon ?? <ReferenceArrowIcon />}\n <span className={`${base}-label`}>\"{label}\"</span>\n {onRemove && (\n <button\n type=\"button\"\n className=\"devic-reference-chip-remove\"\n onClick={onRemove}\n aria-label={t(\"Remove reference\")}\n >\n &times;\n </button>\n )}\n </div>\n );\n}\n\n/** Corner-down-right arrow used as the default reference glyph. */\nfunction ReferenceArrowIcon(): JSX.Element {\n return (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <polyline points=\"15 10 20 15 15 20\" />\n <path d=\"M4 4v7a4 4 0 0 0 4 4h12\" />\n </svg>\n );\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;AA0BA;;;;;AAKG;AACG,SAAU,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,OAAO,EACjB,IAAI,EACJ,SAAS,GACU,EAAA;AACnB,IAAA,MAAM,CAAC,GAAG,eAAe,EAAE;AAC3B,IAAA,MAAM,IAAI,GACR,OAAO,KAAK;AACV,UAAE;UACA,sBAAsB;AAE5B,IAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,SAAS,GAAG,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,SAAS,CAAA,CAAE,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,EAAA,QAAA,EAAA,CACpE,IAAI,IAAIC,GAAA,CAAC,kBAAkB,EAAA,EAAA,CAAG,EAC/BD,eAAM,SAAS,EAAE,CAAA,EAAG,IAAI,CAAA,MAAA,CAAQ,EAAA,QAAA,EAAA,CAAA,IAAA,EAAI,KAAK,EAAA,IAAA,CAAA,EAAA,CAAS,EACjD,QAAQ,KACPC,GAAA,CAAA,QAAA,EAAA,EACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,6BAA6B,EACvC,OAAO,EAAE,QAAQ,EAAA,YAAA,EACL,CAAC,CAAC,kBAAkB,CAAC,EAAA,QAAA,EAAA,QAAA,EAAA,CAG1B,CACV,CAAA,EAAA,CACG;AAEV;AAEA;AACA,SAAS,kBAAkB,GAAA;IACzB,QACED,cACE,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,aAAA,EACV,MAAM,EAAA,QAAA,EAAA,CAElBC,GAAA,CAAA,UAAA,EAAA,EAAU,MAAM,EAAC,mBAAmB,EAAA,CAAG,EACvCA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,yBAAyB,EAAA,CAAG,CAAA,EAAA,CAChC;AAEV;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ToolTimeline.js","sources":["../../../../src/components/ChatDrawer/ToolTimeline.tsx"],"sourcesContent":["import React from 'react';\nimport type { ToolTimelineProps } from './ChatDrawer.types';\n\n/**\n * Tool execution timeline component\n */\nexport function ToolTimeline({ toolCalls }: ToolTimelineProps): JSX.Element | null {\n if (toolCalls.length === 0) {\n return null;\n }\n\n return (\n <div className=\"devic-tool-timeline\">\n {toolCalls.map((tool) => (\n <div key={tool.id} className=\"devic-tool-item\">\n <span className=\"devic-tool-status\" data-status={tool.status} />\n <span className=\"devic-tool-name\">{formatToolName(tool.name)}</span>\n {tool.status === 'error' && tool.error && (\n <span className=\"devic-tool-error\">{tool.error}</span>\n )}\n </div>\n ))}\n </div>\n );\n}\n\n/**\n * Format tool name for display\n */\nfunction formatToolName(name: string): string {\n // Convert snake_case or camelCase to Title Case with spaces\n return name\n .replace(/_/g, ' ')\n .replace(/([a-z])([A-Z])/g, '$1 $2')\n .replace(/\\b\\w/g, (char) => char.toUpperCase());\n}\n"],"names":["_jsx","_jsxs"],"mappings":";;AAGA;;AAEG;AACG,SAAU,YAAY,CAAC,EAAE,SAAS,EAAqB,EAAA;AAC3D,IAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;AAC1B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qBAAqB,EAAA,QAAA,EACjC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,MAClBC,IAAA,CAAA,KAAA,EAAA,EAAmB,SAAS,EAAC,iBAAiB,EAAA,QAAA,EAAA,CAC5CD,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,mBAAmB,EAAA,aAAA,EAAc,IAAI,CAAC,MAAM,GAAI,EAChEA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,iBAAiB,EAAA,QAAA,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA,CAAQ,EACnE,IAAI,CAAC,MAAM,KAAK,OAAO,IAAI,IAAI,CAAC,KAAK,KACpCA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kBAAkB,EAAA,QAAA,EAAE,IAAI,CAAC,KAAK,GAAQ,CACvD,CAAA,EAAA,EALO,IAAI,CAAC,EAAE,CAMX,CACP,CAAC,EAAA,CACE;AAEV;AAEA;;AAEG;AACH,SAAS,cAAc,CAAC,IAAY,EAAA;;AAElC,IAAA,OAAO;AACJ,SAAA,OAAO,CAAC,IAAI,EAAE,GAAG;AACjB,SAAA,OAAO,CAAC,iBAAiB,EAAE,OAAO;AAClC,SAAA,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;AACnD;;"}
1
+ {"version":3,"file":"ToolTimeline.js","sources":["../../../../src/components/ChatDrawer/ToolTimeline.tsx"],"sourcesContent":["import React from 'react';\nimport type { ToolTimelineProps } from './ChatDrawer.types';\n\n/**\n * Tool execution timeline component\n */\nexport function ToolTimeline({ toolCalls }: ToolTimelineProps): JSX.Element | null {\n if (toolCalls.length === 0) {\n return null;\n }\n\n return (\n <div className=\"devic-tool-timeline\">\n {toolCalls.map((tool) => (\n <div key={tool.id} className=\"devic-tool-item\">\n <span className=\"devic-tool-status\" data-status={tool.status} />\n <span className=\"devic-tool-name\">{formatToolName(tool.name)}</span>\n {tool.status === 'error' && tool.error && (\n <span className=\"devic-tool-error\">{tool.error}</span>\n )}\n </div>\n ))}\n </div>\n );\n}\n\n/**\n * Format tool name for display\n */\nfunction formatToolName(name: string): string {\n // Convert snake_case or camelCase to Title Case with spaces\n return name\n .replace(/_/g, ' ')\n .replace(/([a-z])([A-Z])/g, '$1 $2')\n .replace(/\\b\\w/g, (char) => char.toUpperCase());\n}\n"],"names":["_jsx","_jsxs"],"mappings":";;AAGA;;AAEG;AACG,SAAU,YAAY,CAAC,EAAE,SAAS,EAAqB,EAAA;AAC3D,IAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;AAC1B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qBAAqB,EAAA,QAAA,EACjC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,MAClBC,IAAA,CAAA,KAAA,EAAA,EAAmB,SAAS,EAAC,iBAAiB,EAAA,QAAA,EAAA,CAC5CD,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,mBAAmB,EAAA,aAAA,EAAc,IAAI,CAAC,MAAM,GAAI,EAChEA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,iBAAiB,EAAA,QAAA,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA,CAAQ,EACnE,IAAI,CAAC,MAAM,KAAK,OAAO,IAAI,IAAI,CAAC,KAAK,KACpCA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kBAAkB,EAAA,QAAA,EAAE,IAAI,CAAC,KAAK,GAAQ,CACvD,CAAA,EAAA,EALO,IAAI,CAAC,EAAE,CAMX,CACP,CAAC,EAAA,CACE;AAEV;AAEA;;AAEG;AACH,SAAS,cAAc,CAAC,IAAY,EAAA;;AAElC,IAAA,OAAO;AACJ,SAAA,OAAO,CAAC,IAAI,EAAE,GAAG;AACjB,SAAA,OAAO,CAAC,iBAAiB,EAAE,OAAO;AAClC,SAAA,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;AACnD;;;;"}
@@ -2,6 +2,7 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import { useMemo, useState, useCallback, useEffect } from 'react';
3
3
  import { useOptionalDevicContext } from '../../provider/DevicContext.js';
4
4
  import { DevicApiClient } from '../../api/client.js';
5
+ import { useTranslations } from '../../i18n/useTranslations.js';
5
6
 
6
7
  const DEFAULT_DISPLAY = {
7
8
  showValues: false,
@@ -24,24 +25,27 @@ function formatAmount(value, metric) {
24
25
  }
25
26
  return Math.round(value).toLocaleString();
26
27
  }
27
- function windowLabel(unit, every) {
28
- const u = every > 1 ? `${unit}s` : unit;
29
- return every > 1 ? `every ${every} ${u}` : `per ${unit}`;
28
+ // The unit names are translated on their own so a dictionary can decline
29
+ // them; the sentence around them is a separate entry with placeholders, which
30
+ // is what a language with a different word order needs.
31
+ function windowLabel(t, unit, every) {
32
+ const u = every > 1 ? t(`{count} ${unit}s`, { count: every }) : t(unit);
33
+ return every > 1 ? t('every {window}', { window: u }) : t('per {window}', { window: u });
30
34
  }
31
- function resetLabel(resetsAt) {
35
+ function resetLabel(t, resetsAt) {
32
36
  if (!resetsAt)
33
37
  return '';
34
38
  const ms = resetsAt - Date.now();
35
39
  if (ms <= 0)
36
- return 'resets now';
40
+ return t('resets now');
37
41
  const mins = Math.round(ms / 60000);
38
42
  if (mins < 60)
39
- return `resets in ${mins}m`;
43
+ return t('resets in {count}m', { count: mins });
40
44
  const hours = Math.round(mins / 60);
41
45
  if (hours < 48)
42
- return `resets in ${hours}h`;
46
+ return t('resets in {count}h', { count: hours });
43
47
  const days = Math.round(hours / 24);
44
- return `resets in ${days}d`;
48
+ return t('resets in {count}d', { count: days });
45
49
  }
46
50
  /**
47
51
  * A thin usage bar showing the current tenant/subtenant usage window(s).
@@ -49,6 +53,7 @@ function resetLabel(resetsAt) {
49
53
  * Renders nothing when there are no usage limits configured for the tenant.
50
54
  */
51
55
  function UsageBar({ apiKey, baseUrl, tenantId, subtenantId, mode = 'always', metric, display, customUsageBar, color = '#1890ff', refreshKey, debug = false, }) {
56
+ const t = useTranslations();
52
57
  const cfg = useMemo(() => ({ ...DEFAULT_DISPLAY, ...display }), [display]);
53
58
  const devicContext = useOptionalDevicContext();
54
59
  const getTenantSession = devicContext?.getTenantSession;
@@ -112,14 +117,14 @@ function UsageBar({ apiKey, baseUrl, tenantId, subtenantId, mode = 'always', met
112
117
  }
113
118
  // onDemand, collapsed: show a small toggle button.
114
119
  if (mode === 'onDemand' && !visible) {
115
- return (jsx("div", { className: "devic-usage-bar-wrap", "data-mode": "onDemand", children: jsxs("button", { type: "button", className: "devic-usage-toggle", onClick: () => setVisible(true), title: "Show usage", children: [jsx(GaugeIcon, {}), jsx("span", { children: "Usage" })] }) }));
120
+ return (jsx("div", { className: "devic-usage-bar-wrap", "data-mode": "onDemand", children: jsxs("button", { type: "button", className: "devic-usage-toggle", onClick: () => setVisible(true), title: t('Show usage'), children: [jsx(GaugeIcon, {}), jsx("span", { children: t('Usage') })] }) }));
116
121
  }
117
122
  // No configured limits (or not loaded yet with nothing to show): render nothing
118
123
  // in 'always' mode; in expanded onDemand, show a subtle note so the toggle isn't
119
124
  // confusing.
120
125
  if (rules.length === 0) {
121
126
  if (mode === 'onDemand' && loaded) {
122
- return (jsx("div", { className: "devic-usage-bar-wrap", "data-mode": "onDemand", children: jsxs("div", { className: "devic-usage-bar", "data-empty": "true", children: [jsx("span", { className: "devic-usage-bar-label", children: "No usage limits" }), jsx("button", { type: "button", className: "devic-usage-collapse", onClick: () => setVisible(false), title: "Hide usage", "aria-label": "Hide usage", children: "\u00D7" })] }) }));
127
+ return (jsx("div", { className: "devic-usage-bar-wrap", "data-mode": "onDemand", children: jsxs("div", { className: "devic-usage-bar", "data-empty": "true", children: [jsx("span", { className: "devic-usage-bar-label", children: t('No usage limits') }), jsx("button", { type: "button", className: "devic-usage-collapse", onClick: () => setVisible(false), title: t('Hide usage'), "aria-label": t('Hide usage'), children: "\u00D7" })] }) }));
123
128
  }
124
129
  return null;
125
130
  }
@@ -127,20 +132,20 @@ function UsageBar({ apiKey, baseUrl, tenantId, subtenantId, mode = 'always', met
127
132
  const multi = rules.length > 1;
128
133
  // A header carries the tier chip and/or the onDemand collapse control, so the
129
134
  // collapse "×" has a stable home regardless of how many rows render below.
130
- const header = showTierChip || mode === 'onDemand' ? (jsxs("div", { className: "devic-usage-bar-head", children: [showTierChip ? (jsx("span", { className: "devic-usage-tier", title: `Tier: ${tierId}`, children: tierId })) : (jsx("span", {})), mode === 'onDemand' && (jsx("button", { type: "button", className: "devic-usage-collapse", onClick: () => setVisible(false), title: "Hide usage", "aria-label": "Hide usage", children: "\u00D7" }))] })) : null;
135
+ const header = showTierChip || mode === 'onDemand' ? (jsxs("div", { className: "devic-usage-bar-head", children: [showTierChip ? (jsx("span", { className: "devic-usage-tier", title: t('Tier: {tier}', { tier: tierId }), children: tierId })) : (jsx("span", {})), mode === 'onDemand' && (jsx("button", { type: "button", className: "devic-usage-collapse", onClick: () => setVisible(false), title: t('Hide usage'), "aria-label": t('Hide usage'), children: "\u00D7" }))] })) : null;
131
136
  return (jsxs("div", { className: "devic-usage-bar-wrap", "data-mode": mode, children: [header, jsx("div", { className: "devic-usage-bar-group", children: rules.map((rule, i) => {
132
137
  const pct = Math.min(100, Math.round(rule.percent));
133
138
  const fill = fillColor(pct, color);
134
- const valuesText = `${formatAmount(rule.current, rule.metric)} / ${formatAmount(rule.limit, rule.metric)} ${rule.metric}`;
139
+ const valuesText = `${formatAmount(rule.current, rule.metric)} / ${formatAmount(rule.limit, rule.metric)} ${t(rule.metric)}`;
135
140
  // Distinguish rows by metric when several render; otherwise use the
136
141
  // scope-aware label so single-rule mode reads "Usage 24%".
137
142
  const prefix = multi
138
143
  ? rule.metric === 'cost'
139
- ? 'Cost'
140
- : 'Tokens'
144
+ ? t('Cost')
145
+ : t('Tokens')
141
146
  : rule.scope === 'subtenant'
142
- ? 'Your usage'
143
- : 'Usage';
147
+ ? t('Your usage')
148
+ : t('Usage');
144
149
  const main = [];
145
150
  if (cfg.showPercent)
146
151
  main.push(`${pct}%`);
@@ -149,8 +154,8 @@ function UsageBar({ apiKey, baseUrl, tenantId, subtenantId, mode = 'always', met
149
154
  if (main.length === 0)
150
155
  main.push(`${pct}%`);
151
156
  const label = `${prefix} ${main.join(' · ')}`.trim();
152
- const reset = resetLabel(rule.resetsAt);
153
- const win = windowLabel(rule.windowUnit, rule.windowEvery);
157
+ const reset = resetLabel(t, rule.resetsAt);
158
+ const win = windowLabel(t, rule.windowUnit, rule.windowEvery);
154
159
  const title = `${valuesText} · ${win}${reset ? ` · ${reset}` : ''}`;
155
160
  return (jsxs("div", { className: "devic-usage-bar", title: title, "data-state": pct >= 100 ? 'exceeded' : 'ok', children: [jsx("span", { className: "devic-usage-bar-label", children: label }), jsx("div", { className: "devic-usage-bar-track", children: jsx("div", { className: "devic-usage-bar-fill", style: { width: `${pct}%`, backgroundColor: fill } }) }), cfg.showWindow && (jsx("span", { className: "devic-usage-bar-window", children: win })), reset && jsx("span", { className: "devic-usage-bar-reset", children: reset })] }, `${rule.metric}-${rule.windowUnit}-${rule.windowEvery}-${rule.scope}-${i}`));
156
161
  }) })] }));
@@ -1 +1 @@
1
- {"version":3,"file":"UsageBar.js","sources":["../../../../src/components/ChatDrawer/UsageBar.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useOptionalDevicContext } from '../../provider';\nimport { DevicApiClient } from '../../api/client';\nimport type { TenantUsage, TenantUsageRule } from '../../api/types';\n\n/**\n * Controls what each usage row renders. All flags compose, so a developer can,\n * for example, show absolute values together with the percentage and the tier.\n */\nexport interface UsageBarDisplay {\n /**\n * Show the absolute amount of the active window: `current / limit metric`\n * (e.g. `1,200 / 5,000 tokens`).\n * @default false\n */\n showValues?: boolean;\n /**\n * Show the utilization percentage (e.g. `24%`).\n * @default true\n */\n showPercent?: boolean;\n /**\n * Show the temporal dimension of the window (e.g. `per 3h`, `every 3 hours`).\n * @default true\n */\n showWindow?: boolean;\n /**\n * Show the tier (plan) the limits come from, as a chip above the bar(s).\n * @default false\n */\n showTier?: boolean;\n /**\n * When more than one limit rule applies, render every rule (`true`) or only\n * the single most restrictive one (`false`, highest utilization). The\n * per-row presentation still follows the flags above.\n * @default true\n */\n showAllRules?: boolean;\n}\n\nconst DEFAULT_DISPLAY: Required<UsageBarDisplay> = {\n showValues: false,\n showPercent: true,\n showWindow: true,\n showTier: false,\n showAllRules: true,\n};\n\n/**\n * Usage data handed to a `customUsageBar` renderer so a developer can build\n * their own component with the live consumption / limits.\n */\nexport interface UsageBarData {\n /** Tenant the usage belongs to. */\n tenantId?: string;\n /** Subtenant the usage is scoped to, if any. */\n subtenantId?: string;\n /** Tier (plan) the limits come from, if any. */\n tierId?: string;\n /**\n * Applicable usage rules (filtered by `metric` when set), sorted by\n * utilization descending — the most restrictive first.\n */\n rules: TenantUsageRule[];\n /** `true` until the first fetch resolves. */\n loading: boolean;\n}\n\n/**\n * Props for the UsageBar component.\n */\nexport interface UsageBarProps {\n /** API key (resolved from provider by the ChatDrawer). */\n apiKey?: string;\n /** Base URL (resolved from provider by the ChatDrawer). */\n baseUrl?: string;\n /** Tenant whose usage is displayed. Required — without it the bar renders nothing. */\n tenantId?: string;\n /** Optional subtenant to scope the usage to a specific end user. */\n subtenantId?: string;\n /**\n * Display mode:\n * - 'always': the bar is always visible.\n * - 'onDemand': a small toggle button is shown; the bar appears on click.\n */\n mode?: 'always' | 'onDemand';\n /** Restrict the bar to a single metric. When omitted, all applicable rules are considered. */\n metric?: 'tokens' | 'cost';\n /**\n * What to render per rule (values / percentage / window / tier) and whether\n * to render all applicable rules or only the most restrictive one.\n */\n display?: UsageBarDisplay;\n /**\n * Render your own component instead of the built-in bar(s). Receives the live\n * usage data (rules + tier + loading) and renders in the same slot, replacing\n * the default UI entirely. When set, fetching/polling is still handled here;\n * `mode`/`display` only affect the default UI and are ignored.\n */\n customUsageBar?: (data: UsageBarData) => React.ReactNode;\n /** Primary color for the bar fill (below the warning threshold). */\n color?: string;\n /**\n * Changes to this value trigger a refetch (e.g. the message count, so the bar\n * refreshes after each assistant turn).\n */\n refreshKey?: number | string;\n /** Enable debug logging of fetch errors to the console. */\n debug?: boolean;\n}\n\nconst WARN_THRESHOLD = 90;\n\nfunction fillColor(percent: number, base: string): string {\n if (percent >= 100) return '#ff4d4f';\n if (percent >= WARN_THRESHOLD) return '#faad14';\n return base;\n}\n\nfunction formatAmount(value: number, metric: 'tokens' | 'cost'): string {\n if (metric === 'cost') {\n return `$${value.toFixed(value < 1 ? 4 : 2)}`;\n }\n return Math.round(value).toLocaleString();\n}\n\nfunction windowLabel(unit: string, every: number): string {\n const u = every > 1 ? `${unit}s` : unit;\n return every > 1 ? `every ${every} ${u}` : `per ${unit}`;\n}\n\nfunction resetLabel(resetsAt?: number): string {\n if (!resetsAt) return '';\n const ms = resetsAt - Date.now();\n if (ms <= 0) return 'resets now';\n const mins = Math.round(ms / 60000);\n if (mins < 60) return `resets in ${mins}m`;\n const hours = Math.round(mins / 60);\n if (hours < 48) return `resets in ${hours}h`;\n const days = Math.round(hours / 24);\n return `resets in ${days}d`;\n}\n\n/**\n * A thin usage bar showing the current tenant/subtenant usage window(s).\n * Rendered above the chat input. Antd-free — styled via `.devic-usage-*` classes.\n * Renders nothing when there are no usage limits configured for the tenant.\n */\nexport function UsageBar({\n apiKey,\n baseUrl,\n tenantId,\n subtenantId,\n mode = 'always',\n metric,\n display,\n customUsageBar,\n color = '#1890ff',\n refreshKey,\n debug = false,\n}: UsageBarProps): JSX.Element | null {\n const cfg = useMemo(() => ({ ...DEFAULT_DISPLAY, ...display }), [display]);\n\n const devicContext = useOptionalDevicContext();\n const getTenantSession = devicContext?.getTenantSession;\n const onSessionExpired = devicContext?.onSessionExpired;\n const client = useMemo(() => {\n if (!apiKey && !getTenantSession) return null;\n return new DevicApiClient({\n apiKey,\n baseUrl: baseUrl || 'https://api.devic.ai',\n getTenantSession,\n onSessionExpired,\n });\n }, [apiKey, getTenantSession, baseUrl]);\n\n const [usage, setUsage] = useState<TenantUsage | null>(null);\n const [loaded, setLoaded] = useState(false);\n // onDemand starts hidden; 'always' is effectively visible from the start.\n const [visible, setVisible] = useState(mode !== 'onDemand');\n\n const fetchUsage = useCallback(async () => {\n if (!client || !tenantId) return;\n try {\n const data = await client.getTenantUsage(tenantId, subtenantId);\n setUsage(data || null);\n } catch (err) {\n if (debug) console.warn('[UsageBar] getTenantUsage failed:', err);\n setUsage(null);\n } finally {\n setLoaded(true);\n }\n }, [client, tenantId, subtenantId, debug]);\n\n // A custom renderer always wants the data, regardless of the onDemand toggle.\n const active = !!customUsageBar || visible;\n\n useEffect(() => {\n if (!active) return;\n void fetchUsage();\n }, [active, fetchUsage, refreshKey]);\n\n // Applicable rules: filter by metric, sort most-restrictive first.\n const filteredSorted = useMemo(() => {\n const pool = (usage?.usage || []).filter(\n (r) => !metric || r.metric === metric,\n );\n return [...pool].sort((a, b) => b.percent - a.percent);\n }, [usage, metric]);\n\n // Default UI honours showAllRules; custom renderers always get the full set.\n const rules = useMemo(\n () => (cfg.showAllRules ? filteredSorted : filteredSorted.slice(0, 1)),\n [filteredSorted, cfg.showAllRules],\n );\n\n const tierId = usage?.tierId || filteredSorted[0]?.tierId;\n\n if (!tenantId || !client) return null;\n\n // Custom renderer fully replaces the default UI; hand it the live data.\n if (customUsageBar) {\n return (\n <>\n {customUsageBar({\n tenantId,\n subtenantId,\n tierId,\n rules: filteredSorted,\n loading: !loaded,\n })}\n </>\n );\n }\n\n // onDemand, collapsed: show a small toggle button.\n if (mode === 'onDemand' && !visible) {\n return (\n <div className=\"devic-usage-bar-wrap\" data-mode=\"onDemand\">\n <button\n type=\"button\"\n className=\"devic-usage-toggle\"\n onClick={() => setVisible(true)}\n title=\"Show usage\"\n >\n <GaugeIcon />\n <span>Usage</span>\n </button>\n </div>\n );\n }\n\n // No configured limits (or not loaded yet with nothing to show): render nothing\n // in 'always' mode; in expanded onDemand, show a subtle note so the toggle isn't\n // confusing.\n if (rules.length === 0) {\n if (mode === 'onDemand' && loaded) {\n return (\n <div className=\"devic-usage-bar-wrap\" data-mode=\"onDemand\">\n <div className=\"devic-usage-bar\" data-empty=\"true\">\n <span className=\"devic-usage-bar-label\">No usage limits</span>\n <button\n type=\"button\"\n className=\"devic-usage-collapse\"\n onClick={() => setVisible(false)}\n title=\"Hide usage\"\n aria-label=\"Hide usage\"\n >\n &times;\n </button>\n </div>\n </div>\n );\n }\n return null;\n }\n\n const showTierChip = cfg.showTier && !!tierId;\n const multi = rules.length > 1;\n // A header carries the tier chip and/or the onDemand collapse control, so the\n // collapse \"×\" has a stable home regardless of how many rows render below.\n const header =\n showTierChip || mode === 'onDemand' ? (\n <div className=\"devic-usage-bar-head\">\n {showTierChip ? (\n <span className=\"devic-usage-tier\" title={`Tier: ${tierId}`}>\n {tierId}\n </span>\n ) : (\n <span />\n )}\n {mode === 'onDemand' && (\n <button\n type=\"button\"\n className=\"devic-usage-collapse\"\n onClick={() => setVisible(false)}\n title=\"Hide usage\"\n aria-label=\"Hide usage\"\n >\n &times;\n </button>\n )}\n </div>\n ) : null;\n\n return (\n <div className=\"devic-usage-bar-wrap\" data-mode={mode}>\n {header}\n {/* All rows share a single container by default. */}\n <div className=\"devic-usage-bar-group\">\n {rules.map((rule, i) => {\n const pct = Math.min(100, Math.round(rule.percent));\n const fill = fillColor(pct, color);\n const valuesText = `${formatAmount(rule.current, rule.metric)} / ${formatAmount(\n rule.limit,\n rule.metric,\n )} ${rule.metric}`;\n // Distinguish rows by metric when several render; otherwise use the\n // scope-aware label so single-rule mode reads \"Usage 24%\".\n const prefix = multi\n ? rule.metric === 'cost'\n ? 'Cost'\n : 'Tokens'\n : rule.scope === 'subtenant'\n ? 'Your usage'\n : 'Usage';\n const main: string[] = [];\n if (cfg.showPercent) main.push(`${pct}%`);\n if (cfg.showValues) main.push(valuesText);\n if (main.length === 0) main.push(`${pct}%`);\n const label = `${prefix} ${main.join(' · ')}`.trim();\n const reset = resetLabel(rule.resetsAt);\n const win = windowLabel(rule.windowUnit, rule.windowEvery);\n const title = `${valuesText} · ${win}${reset ? ` · ${reset}` : ''}`;\n\n return (\n <div\n key={`${rule.metric}-${rule.windowUnit}-${rule.windowEvery}-${rule.scope}-${i}`}\n className=\"devic-usage-bar\"\n title={title}\n data-state={pct >= 100 ? 'exceeded' : 'ok'}\n >\n <span className=\"devic-usage-bar-label\">{label}</span>\n <div className=\"devic-usage-bar-track\">\n <div\n className=\"devic-usage-bar-fill\"\n style={{ width: `${pct}%`, backgroundColor: fill }}\n />\n </div>\n {cfg.showWindow && (\n <span className=\"devic-usage-bar-window\">{win}</span>\n )}\n {reset && <span className=\"devic-usage-bar-reset\">{reset}</span>}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\n/** Small gauge icon for the on-demand toggle. */\nfunction GaugeIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\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=\"M12 14a4 4 0 1 0-4-4\" />\n <path d=\"M3 18a9 9 0 0 1 18 0\" />\n <line x1=\"12\" y1=\"14\" x2=\"15\" y2=\"11\" />\n </svg>\n );\n}\n"],"names":["_jsx","_Fragment","_jsxs"],"mappings":";;;;;AAwCA,MAAM,eAAe,GAA8B;AACjD,IAAA,UAAU,EAAE,KAAK;AACjB,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,YAAY,EAAE,IAAI;CACnB;AAiED,MAAM,cAAc,GAAG,EAAE;AAEzB,SAAS,SAAS,CAAC,OAAe,EAAE,IAAY,EAAA;IAC9C,IAAI,OAAO,IAAI,GAAG;AAAE,QAAA,OAAO,SAAS;IACpC,IAAI,OAAO,IAAI,cA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G,EACjCA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,sBAAsB,EAAA,CAAG,EACjCA,cAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,CAAA,EAAA,CACpC;AAEV;;"}
1
+ {"version":3,"file":"UsageBar.js","sources":["../../../../src/components/ChatDrawer/UsageBar.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useOptionalDevicContext } from '../../provider';\nimport { DevicApiClient } from '../../api/client';\nimport type { TenantUsage, TenantUsageRule } from '../../api/types';\nimport { useTranslations } from '../../i18n';\nimport type { Translator } from '../../i18n';\n\n/**\n * Controls what each usage row renders. All flags compose, so a developer can,\n * for example, show absolute values together with the percentage and the tier.\n */\nexport interface UsageBarDisplay {\n /**\n * Show the absolute amount of the active window: `current / limit metric`\n * (e.g. `1,200 / 5,000 tokens`).\n * @default false\n */\n showValues?: boolean;\n /**\n * Show the utilization percentage (e.g. `24%`).\n * @default true\n */\n showPercent?: boolean;\n /**\n * Show the temporal dimension of the window (e.g. `per 3h`, `every 3 hours`).\n * @default true\n */\n showWindow?: boolean;\n /**\n * Show the tier (plan) the limits come from, as a chip above the bar(s).\n * @default false\n */\n showTier?: boolean;\n /**\n * When more than one limit rule applies, render every rule (`true`) or only\n * the single most restrictive one (`false`, highest utilization). The\n * per-row presentation still follows the flags above.\n * @default true\n */\n showAllRules?: boolean;\n}\n\nconst DEFAULT_DISPLAY: Required<UsageBarDisplay> = {\n showValues: false,\n showPercent: true,\n showWindow: true,\n showTier: false,\n showAllRules: true,\n};\n\n/**\n * Usage data handed to a `customUsageBar` renderer so a developer can build\n * their own component with the live consumption / limits.\n */\nexport interface UsageBarData {\n /** Tenant the usage belongs to. */\n tenantId?: string;\n /** Subtenant the usage is scoped to, if any. */\n subtenantId?: string;\n /** Tier (plan) the limits come from, if any. */\n tierId?: string;\n /**\n * Applicable usage rules (filtered by `metric` when set), sorted by\n * utilization descending — the most restrictive first.\n */\n rules: TenantUsageRule[];\n /** `true` until the first fetch resolves. */\n loading: boolean;\n}\n\n/**\n * Props for the UsageBar component.\n */\nexport interface UsageBarProps {\n /** API key (resolved from provider by the ChatDrawer). */\n apiKey?: string;\n /** Base URL (resolved from provider by the ChatDrawer). */\n baseUrl?: string;\n /** Tenant whose usage is displayed. Required — without it the bar renders nothing. */\n tenantId?: string;\n /** Optional subtenant to scope the usage to a specific end user. */\n subtenantId?: string;\n /**\n * Display mode:\n * - 'always': the bar is always visible.\n * - 'onDemand': a small toggle button is shown; the bar appears on click.\n */\n mode?: 'always' | 'onDemand';\n /** Restrict the bar to a single metric. When omitted, all applicable rules are considered. */\n metric?: 'tokens' | 'cost';\n /**\n * What to render per rule (values / percentage / window / tier) and whether\n * to render all applicable rules or only the most restrictive one.\n */\n display?: UsageBarDisplay;\n /**\n * Render your own component instead of the built-in bar(s). Receives the live\n * usage data (rules + tier + loading) and renders in the same slot, replacing\n * the default UI entirely. When set, fetching/polling is still handled here;\n * `mode`/`display` only affect the default UI and are ignored.\n */\n customUsageBar?: (data: UsageBarData) => React.ReactNode;\n /** Primary color for the bar fill (below the warning threshold). */\n color?: string;\n /**\n * Changes to this value trigger a refetch (e.g. the message count, so the bar\n * refreshes after each assistant turn).\n */\n refreshKey?: number | string;\n /** Enable debug logging of fetch errors to the console. */\n debug?: boolean;\n}\n\nconst WARN_THRESHOLD = 90;\n\nfunction fillColor(percent: number, base: string): string {\n if (percent >= 100) return '#ff4d4f';\n if (percent >= WARN_THRESHOLD) return '#faad14';\n return base;\n}\n\nfunction formatAmount(value: number, metric: 'tokens' | 'cost'): string {\n if (metric === 'cost') {\n return `$${value.toFixed(value < 1 ? 4 : 2)}`;\n }\n return Math.round(value).toLocaleString();\n}\n\n// The unit names are translated on their own so a dictionary can decline\n// them; the sentence around them is a separate entry with placeholders, which\n// is what a language with a different word order needs.\nfunction windowLabel(t: Translator, unit: string, every: number): string {\n const u = every > 1 ? t(`{count} ${unit}s`, { count: every }) : t(unit);\n return every > 1 ? t('every {window}', { window: u }) : t('per {window}', { window: u });\n}\n\nfunction resetLabel(t: Translator, resetsAt?: number): string {\n if (!resetsAt) return '';\n const ms = resetsAt - Date.now();\n if (ms <= 0) return t('resets now');\n const mins = Math.round(ms / 60000);\n if (mins < 60) return t('resets in {count}m', { count: mins });\n const hours = Math.round(mins / 60);\n if (hours < 48) return t('resets in {count}h', { count: hours });\n const days = Math.round(hours / 24);\n return t('resets in {count}d', { count: days });\n}\n\n/**\n * A thin usage bar showing the current tenant/subtenant usage window(s).\n * Rendered above the chat input. Antd-free — styled via `.devic-usage-*` classes.\n * Renders nothing when there are no usage limits configured for the tenant.\n */\nexport function UsageBar({\n apiKey,\n baseUrl,\n tenantId,\n subtenantId,\n mode = 'always',\n metric,\n display,\n customUsageBar,\n color = '#1890ff',\n refreshKey,\n debug = false,\n}: UsageBarProps): JSX.Element | null {\n const t = useTranslations();\n const cfg = useMemo(() => ({ ...DEFAULT_DISPLAY, ...display }), [display]);\n\n const devicContext = useOptionalDevicContext();\n const getTenantSession = devicContext?.getTenantSession;\n const onSessionExpired = devicContext?.onSessionExpired;\n const client = useMemo(() => {\n if (!apiKey && !getTenantSession) return null;\n return new DevicApiClient({\n apiKey,\n baseUrl: baseUrl || 'https://api.devic.ai',\n getTenantSession,\n onSessionExpired,\n });\n }, [apiKey, getTenantSession, baseUrl]);\n\n const [usage, setUsage] = useState<TenantUsage | null>(null);\n const [loaded, setLoaded] = useState(false);\n // onDemand starts hidden; 'always' is effectively visible from the start.\n const [visible, setVisible] = useState(mode !== 'onDemand');\n\n const fetchUsage = useCallback(async () => {\n if (!client || !tenantId) return;\n try {\n const data = await client.getTenantUsage(tenantId, subtenantId);\n setUsage(data || null);\n } catch (err) {\n if (debug) console.warn('[UsageBar] getTenantUsage failed:', err);\n setUsage(null);\n } finally {\n setLoaded(true);\n }\n }, [client, tenantId, subtenantId, debug]);\n\n // A custom renderer always wants the data, regardless of the onDemand toggle.\n const active = !!customUsageBar || visible;\n\n useEffect(() => {\n if (!active) return;\n void fetchUsage();\n }, [active, fetchUsage, refreshKey]);\n\n // Applicable rules: filter by metric, sort most-restrictive first.\n const filteredSorted = useMemo(() => {\n const pool = (usage?.usage || []).filter(\n (r) => !metric || r.metric === metric,\n );\n return [...pool].sort((a, b) => b.percent - a.percent);\n }, [usage, metric]);\n\n // Default UI honours showAllRules; custom renderers always get the full set.\n const rules = useMemo(\n () => (cfg.showAllRules ? filteredSorted : filteredSorted.slice(0, 1)),\n [filteredSorted, cfg.showAllRules],\n );\n\n const tierId = usage?.tierId || filteredSorted[0]?.tierId;\n\n if (!tenantId || !client) return null;\n\n // Custom renderer fully replaces the default UI; hand it the live data.\n if (customUsageBar) {\n return (\n <>\n {customUsageBar({\n tenantId,\n subtenantId,\n tierId,\n rules: filteredSorted,\n loading: !loaded,\n })}\n </>\n );\n }\n\n // onDemand, collapsed: show a small toggle button.\n if (mode === 'onDemand' && !visible) {\n return (\n <div className=\"devic-usage-bar-wrap\" data-mode=\"onDemand\">\n <button\n type=\"button\"\n className=\"devic-usage-toggle\"\n onClick={() => setVisible(true)}\n title={t('Show usage')}\n >\n <GaugeIcon />\n <span>{t('Usage')}</span>\n </button>\n </div>\n );\n }\n\n // No configured limits (or not loaded yet with nothing to show): render nothing\n // in 'always' mode; in expanded onDemand, show a subtle note so the toggle isn't\n // confusing.\n if (rules.length === 0) {\n if (mode === 'onDemand' && loaded) {\n return (\n <div className=\"devic-usage-bar-wrap\" data-mode=\"onDemand\">\n <div className=\"devic-usage-bar\" data-empty=\"true\">\n <span className=\"devic-usage-bar-label\">\n {t('No usage limits')}\n </span>\n <button\n type=\"button\"\n className=\"devic-usage-collapse\"\n onClick={() => setVisible(false)}\n title={t('Hide usage')}\n aria-label={t('Hide usage')}\n >\n &times;\n </button>\n </div>\n </div>\n );\n }\n return null;\n }\n\n const showTierChip = cfg.showTier && !!tierId;\n const multi = rules.length > 1;\n // A header carries the tier chip and/or the onDemand collapse control, so the\n // collapse \"×\" has a stable home regardless of how many rows render below.\n const header =\n showTierChip || mode === 'onDemand' ? (\n <div className=\"devic-usage-bar-head\">\n {showTierChip ? (\n <span className=\"devic-usage-tier\" title={t('Tier: {tier}', { tier: tierId })}>\n {tierId}\n </span>\n ) : (\n <span />\n )}\n {mode === 'onDemand' && (\n <button\n type=\"button\"\n className=\"devic-usage-collapse\"\n onClick={() => setVisible(false)}\n title={t('Hide usage')}\n aria-label={t('Hide usage')}\n >\n &times;\n </button>\n )}\n </div>\n ) : null;\n\n return (\n <div className=\"devic-usage-bar-wrap\" data-mode={mode}>\n {header}\n {/* All rows share a single container by default. */}\n <div className=\"devic-usage-bar-group\">\n {rules.map((rule, i) => {\n const pct = Math.min(100, Math.round(rule.percent));\n const fill = fillColor(pct, color);\n const valuesText = `${formatAmount(rule.current, rule.metric)} / ${formatAmount(\n rule.limit,\n rule.metric,\n )} ${t(rule.metric)}`;\n // Distinguish rows by metric when several render; otherwise use the\n // scope-aware label so single-rule mode reads \"Usage 24%\".\n const prefix = multi\n ? rule.metric === 'cost'\n ? t('Cost')\n : t('Tokens')\n : rule.scope === 'subtenant'\n ? t('Your usage')\n : t('Usage');\n const main: string[] = [];\n if (cfg.showPercent) main.push(`${pct}%`);\n if (cfg.showValues) main.push(valuesText);\n if (main.length === 0) main.push(`${pct}%`);\n const label = `${prefix} ${main.join(' · ')}`.trim();\n const reset = resetLabel(t, rule.resetsAt);\n const win = windowLabel(t, rule.windowUnit, rule.windowEvery);\n const title = `${valuesText} · ${win}${reset ? ` · ${reset}` : ''}`;\n\n return (\n <div\n key={`${rule.metric}-${rule.windowUnit}-${rule.windowEvery}-${rule.scope}-${i}`}\n className=\"devic-usage-bar\"\n title={title}\n data-state={pct >= 100 ? 'exceeded' : 'ok'}\n >\n <span className=\"devic-usage-bar-label\">{label}</span>\n <div className=\"devic-usage-bar-track\">\n <div\n className=\"devic-usage-bar-fill\"\n style={{ width: `${pct}%`, backgroundColor: fill }}\n />\n </div>\n {cfg.showWindow && (\n <span className=\"devic-usage-bar-window\">{win}</span>\n )}\n {reset && <span className=\"devic-usage-bar-reset\">{reset}</span>}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\n/** Small gauge icon for the on-demand toggle. */\nfunction GaugeIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\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=\"M12 14a4 4 0 1 0-4-4\" />\n <path d=\"M3 18a9 9 0 0 1 18 0\" />\n <line x1=\"12\" y1=\"14\" x2=\"15\" y2=\"11\" />\n </svg>\n );\n}\n"],"names":["_jsx","_Fragment","_jsxs"],"mappings":";;;;;;AA0CA,MAAM,eAAe,GAA8B;AACjD,IAAA,UAAU,EAAE,KAAK;AACjB,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,YAAY,EAAE,IAAI;CACnB;AAiED,MAAM,cAAc,GAAG,EAAE;AAEzB,SAAS,SAAS,CAAC,OAAe,EAAE,IAAY,EAAA;IAC9C,IAAI,OAAO,IAAI,GAAG;AAAE,QAAA,OAAO,SAAS;IACpC,IAAI,OAAO,IAAI,cAAc;AAAE,QAAA,OAAO,SAAS;AAC/C,IAAA,OAAO,IAAI;AACb;AAEA,SAAS,YAAY,CAAC,KAAa,EAAE,MAAyB,EAAA;AAC5D,IAAA,IAAI,MAAM,KAAK,MAAM,EAAE;AACrB,QAAA,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;IAC/C;IACA,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE;AAC3C;AAEA;AACA;AACA;AACA,SAAS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,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EAAA,QAAA,EAAA,CAEtBF,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,sBAAsB,EAAA,CAAG,EACjCA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,sBAAsB,EAAA,CAAG,EACjCA,cAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,CAAA,EAAA,CACpC;AAEV;;;;"}
@@ -15,6 +15,8 @@ export type { QueueNoticeProps } from './QueueNotice';
15
15
  export { RecalledMemoriesWidget } from './RecalledMemoriesWidget';
16
16
  export type { CompactionWidgetProps, CompactionRenderer, CompactionRendererProps, } from './CompactionWidget';
17
17
  export { CompactionWidget } from './CompactionWidget';
18
+ export { GuardrailNotice } from './GuardrailNotice';
19
+ export type { GuardrailNoticeProps, GuardrailRenderer, GuardrailPayload, } from './GuardrailNotice';
18
20
  export type { RecalledMemoriesWidgetProps, RecalledMemoriesRenderer, RecalledMemoriesRendererProps, } from './RecalledMemoriesWidget';
19
21
  export type { ChatDrawerProps, ChatDrawerOptions, ChatDrawerHandle, ChatMessagesProps, ChatInputProps, CustomPromptBoxProps, MessageBubbleRenderer, MessageBubbleRendererProps, ToolTimelineProps, AllowedFileTypes, ConversationSelectorProps, SuggestedMessage, } from './ChatDrawer.types';
20
22
  export type { HandoffSubagentWidgetProps } from './HandoffSubagentWidget';
@@ -1 +1 @@
1
- {"version":3,"file":"pastedText.js","sources":["../../../../src/components/ChatDrawer/pastedText.ts"],"sourcesContent":["/**\n * Shared contract for long blocks of pasted text.\n *\n * A long paste is shown in the prompt box as an attachment card instead of\n * flooding the textarea, but its content still reaches the model in full: on\n * send it is prepended to the message inside a <pasted-text> block. The thread\n * parses those blocks back out so the bubble shows a card too, rather than\n * thousands of lines of raw text.\n *\n * Both sides of that round-trip live here so they can never drift apart.\n */\n\nexport interface PastedText {\n id: string;\n text: string;\n}\n\n/**\n * A pasted block could itself contain the literal closing tag (pasting this\n * very file, say), which would truncate the block when parsed back. Escaping it\n * on the way out keeps the round-trip exact and still reads as the intended\n * text to the model.\n */\nconst CLOSING_TAG = '</pasted-text>';\nconst ESCAPED_CLOSING_TAG = '<\\\\/pasted-text>';\n\nconst PASTED_BLOCK_RE = /<pasted-text id=\"([^\"]*)\">\\n([\\s\\S]*?)\\n<\\/pasted-text>/g;\n\n/** Serialize a pasted block for the message sent to the assistant. */\nexport function toPastedBlock({ id, text }: PastedText): string {\n const escaped = text.split(CLOSING_TAG).join(ESCAPED_CLOSING_TAG);\n return `<pasted-text id=\"${id}\">\\n${escaped}\\n${CLOSING_TAG}`;\n}\n\n/**\n * Pull the pasted blocks out of a user message, returning them alongside the\n * message with those blocks removed. Returns null when there are none, so\n * callers can keep rendering untouched messages exactly as before.\n */\nexport function parsePastedBlocks(\n content: string\n): { blocks: PastedText[]; cleanContent: string } | null {\n const blocks: PastedText[] = [];\n const cleanContent = content\n .replace(PASTED_BLOCK_RE, (_match, id: string, text: string) => {\n blocks.push({\n id,\n text: text.split(ESCAPED_CLOSING_TAG).join(CLOSING_TAG),\n });\n return '';\n })\n .trim();\n\n if (blocks.length === 0) return null;\n return { blocks, cleanContent };\n}\n\n/** Short, single-line-ish excerpt shown on the collapsed card. */\nexport function pastedPreview(text: string, maxChars = 160): string {\n const collapsed = text.replace(/\\s+/g, ' ').trim();\n return collapsed.length > maxChars\n ? `${collapsed.slice(0, maxChars)}…`\n : collapsed;\n}\n\n/** Line count shown on the card, mirroring how editors report a selection. */\nexport function pastedLineCount(text: string): number {\n return text.split('\\n').length;\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;AAOH;;;;;AAKG;AACH,MAAM,WAAW,GAAG,gBAAgB;AACpC,MAAM,mBAAmB,GAAG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3,"file":"pastedText.js","sources":["../../../../src/components/ChatDrawer/pastedText.ts"],"sourcesContent":["/**\n * Shared contract for long blocks of pasted text.\n *\n * A long paste is shown in the prompt box as an attachment card instead of\n * flooding the textarea, but its content still reaches the model in full: on\n * send it is prepended to the message inside a <pasted-text> block. The thread\n * parses those blocks back out so the bubble shows a card too, rather than\n * thousands of lines of raw text.\n *\n * Both sides of that round-trip live here so they can never drift apart.\n */\n\nexport interface PastedText {\n id: string;\n text: string;\n}\n\n/**\n * A pasted block could itself contain the literal closing tag (pasting this\n * very file, say), which would truncate the block when parsed back. Escaping it\n * on the way out keeps the round-trip exact and still reads as the intended\n * text to the model.\n */\nconst CLOSING_TAG = '</pasted-text>';\nconst ESCAPED_CLOSING_TAG = '<\\\\/pasted-text>';\n\nconst PASTED_BLOCK_RE = /<pasted-text id=\"([^\"]*)\">\\n([\\s\\S]*?)\\n<\\/pasted-text>/g;\n\n/** Serialize a pasted block for the message sent to the assistant. */\nexport function toPastedBlock({ id, text }: PastedText): string {\n const escaped = text.split(CLOSING_TAG).join(ESCAPED_CLOSING_TAG);\n return `<pasted-text id=\"${id}\">\\n${escaped}\\n${CLOSING_TAG}`;\n}\n\n/**\n * Pull the pasted blocks out of a user message, returning them alongside the\n * message with those blocks removed. Returns null when there are none, so\n * callers can keep rendering untouched messages exactly as before.\n */\nexport function parsePastedBlocks(\n content: string\n): { blocks: PastedText[]; cleanContent: string } | null {\n const blocks: PastedText[] = [];\n const cleanContent = content\n .replace(PASTED_BLOCK_RE, (_match, id: string, text: string) => {\n blocks.push({\n id,\n text: text.split(ESCAPED_CLOSING_TAG).join(CLOSING_TAG),\n });\n return '';\n })\n .trim();\n\n if (blocks.length === 0) return null;\n return { blocks, cleanContent };\n}\n\n/** Short, single-line-ish excerpt shown on the collapsed card. */\nexport function pastedPreview(text: string, maxChars = 160): string {\n const collapsed = text.replace(/\\s+/g, ' ').trim();\n return collapsed.length > maxChars\n ? `${collapsed.slice(0, maxChars)}…`\n : collapsed;\n}\n\n/** Line count shown on the card, mirroring how editors report a selection. */\nexport function pastedLineCount(text: string): number {\n return text.split('\\n').length;\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;AAOH;;;;;AAKG;AACH,MAAM,WAAW,GAAG,gBAAgB;AACpC,MAAM,mBAAmB,GAAG,kBAAkB;AAE9C,MAAM,eAAe,GAAG,0DAA0D;AAElF;SACgB,aAAa,CAAC,EAAE,EAAE,EAAE,IAAI,EAAc,EAAA;AACpD,IAAA,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC;AACjE,IAAA,OAAO,oBAAoB,EAAE,CAAA,IAAA,EAAO,OAAO,CAAA,EAAA,EAAK,WAAW,EAAE;AAC/D;AAEA;;;;AAIG;AACG,SAAU,iBAAiB,CAC/B,OAAe,EAAA;IAEf,MAAM,MAAM,GAAiB,EAAE;IAC/B,MAAM,YAAY,GAAG;SAClB,OAAO,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,EAAU,EAAE,IAAY,KAAI;QAC7D,MAAM,CAAC,IAAI,CAAC;YACV,EAAE;YACF,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;AACxD,SAAA,CAAC;AACF,QAAA,OAAO,EAAE;AACX,IAAA,CAAC;AACA,SAAA,IAAI,EAAE;AAET,IAAA,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AACpC,IAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE;AACjC;AAEA;SACgB,aAAa,CAAC,IAAY,EAAE,QAAQ,GAAG,GAAG,EAAA;AACxD,IAAA,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE;AAClD,IAAA,OAAO,SAAS,CAAC,MAAM,GAAG;UACtB,CAAA,EAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA,CAAA;UAC/B,SAAS;AACf;AAEA;AACM,SAAU,eAAe,CAAC,IAAY,EAAA;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM;AAChC;;;;"}
@@ -4,6 +4,7 @@ import { createPortal } from 'react-dom';
4
4
  import { DevicApiClient } from '../../api/client.js';
5
5
  import { useOptionalDevicContext } from '../../provider/DevicContext.js';
6
6
  import { themeVars } from '../theme.js';
7
+ import { useTranslations } from '../../i18n/useTranslations.js';
7
8
 
8
9
  /** Canonical sections of the core tier, in display order. */
9
10
  const SECTIONS = ["persona", "instructions", "decisions", "profile"];
@@ -47,15 +48,25 @@ function PinIcon() {
47
48
  * the API key needs that endpoint allowed.
48
49
  */
49
50
  function CoreMemoryModal({ isOpen, onClose, assistantId, tenantId, subtenantId, apiKey, baseUrl, editable = true, title, labels, theme, }) {
50
- const l = useMemo(() => ({
51
- ...DEFAULT_CORE_MEMORY_LABELS,
52
- ...labels,
53
- title: labels?.title ?? title ?? DEFAULT_CORE_MEMORY_LABELS.title,
54
- sections: {
55
- ...DEFAULT_CORE_MEMORY_LABELS.sections,
56
- ...labels?.sections,
57
- },
58
- }), [labels, title]);
51
+ const t = useTranslations();
52
+ // Three layers, narrowest first: the `labels` this host passed, then the
53
+ // dictionary, then English. `labels` stays authoritative — a host that
54
+ // already spells this dialog out itself must not have it changed underneath
55
+ // by a page-wide dictionary.
56
+ const l = useMemo(() => {
57
+ const translated = Object.fromEntries(Object.entries(DEFAULT_CORE_MEMORY_LABELS)
58
+ .filter(([, value]) => typeof value === "string")
59
+ .map(([key, value]) => [key, t(value)]));
60
+ return {
61
+ ...translated,
62
+ ...labels,
63
+ title: labels?.title ?? title ?? t(DEFAULT_CORE_MEMORY_LABELS.title),
64
+ sections: {
65
+ ...Object.fromEntries(Object.entries(DEFAULT_CORE_MEMORY_LABELS.sections).map(([key, value]) => [key, t(value)])),
66
+ ...labels?.sections,
67
+ },
68
+ };
69
+ }, [labels, title, t]);
59
70
  const context = useOptionalDevicContext();
60
71
  const resolvedBaseUrl = baseUrl || context?.baseUrl || "https://api.devic.ai";
61
72
  const resolvedTenantId = tenantId || context?.tenantId;