@devicai/ui 0.55.0 → 0.56.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.
- package/README.md +37 -0
- package/dist/cjs/api/types.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js +3 -1
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatMessages.js +41 -4
- package/dist/cjs/components/ChatDrawer/ChatMessages.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/CompactionWidget.js +72 -0
- package/dist/cjs/components/ChatDrawer/CompactionWidget.js.map +1 -0
- package/dist/cjs/hooks/useDevicChat.js +32 -1
- package/dist/cjs/hooks/useDevicChat.js.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/esm/api/types.d.ts +83 -0
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.js +3 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.types.d.ts +33 -1
- package/dist/esm/components/ChatDrawer/ChatMessages.d.ts +1 -1
- package/dist/esm/components/ChatDrawer/ChatMessages.js +41 -4
- package/dist/esm/components/ChatDrawer/ChatMessages.js.map +1 -1
- package/dist/esm/components/ChatDrawer/CompactionWidget.d.ts +47 -0
- package/dist/esm/components/ChatDrawer/CompactionWidget.js +70 -0
- package/dist/esm/components/ChatDrawer/CompactionWidget.js.map +1 -0
- package/dist/esm/components/ChatDrawer/index.d.ts +2 -0
- package/dist/esm/hooks/useDevicChat.d.ts +13 -1
- package/dist/esm/hooks/useDevicChat.js +32 -1
- package/dist/esm/hooks/useDevicChat.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/styles.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -358,6 +358,43 @@ processing its first response (streamed in through the realtime poll).
|
|
|
358
358
|
The recall records are also available from the hook:
|
|
359
359
|
`useDevicChat().recalledMemories`.
|
|
360
360
|
|
|
361
|
+
#### Context compaction
|
|
362
|
+
|
|
363
|
+
An assistant with compaction enabled folds the older part of a long
|
|
364
|
+
conversation into a **checkpoint** — a written summary plus the identifiers,
|
|
365
|
+
paths and urls preserved verbatim — and reads that instead of the messages it
|
|
366
|
+
replaces. The messages themselves stay in the conversation and keep being
|
|
367
|
+
shown; only what the assistant receives changes.
|
|
368
|
+
|
|
369
|
+
The drawer draws a cut line at the exact point where that happens, expandable
|
|
370
|
+
to show what the assistant now reads. While a compaction is being written it
|
|
371
|
+
says so: it is a model call of its own, taken between two assistant messages,
|
|
372
|
+
so without it the conversation just appears to have gone quiet.
|
|
373
|
+
|
|
374
|
+
```tsx
|
|
375
|
+
<ChatDrawer
|
|
376
|
+
assistantId="my-assistant"
|
|
377
|
+
options={{
|
|
378
|
+
showCompaction: true, // default
|
|
379
|
+
// Replace the built-in marker with your own node. Called once per
|
|
380
|
+
// checkpoint, and once more while one is in flight (checkpoint: null):
|
|
381
|
+
compactionRenderer: ({ checkpoint, activity, isActive }) =>
|
|
382
|
+
activity?.state === "running" ? (
|
|
383
|
+
<MySpinner label="Summarizing the conversation…" />
|
|
384
|
+
) : (
|
|
385
|
+
<MyDivider
|
|
386
|
+
text={`${checkpoint!.compactedMessageCount} messages folded`}
|
|
387
|
+
muted={!isActive}
|
|
388
|
+
/>
|
|
389
|
+
),
|
|
390
|
+
}}
|
|
391
|
+
/>
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
Both are also available from the hook: `useDevicChat().compactions` (the
|
|
395
|
+
checkpoints, oldest first) and `useDevicChat().compaction` (the one being
|
|
396
|
+
written right now, or `null`).
|
|
397
|
+
|
|
361
398
|
### CoreMemoryModal
|
|
362
399
|
|
|
363
400
|
Modal showing — and letting the end user edit — the **core memory** of an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../src/api/types.ts"],"sourcesContent":["import type { AvatarStyle } from '../utils/avatar';\n\nimport type React from 'react';\n\n/**\n * File attachment for messages\n */\nexport interface ChatFile {\n name: string;\n downloadUrl?: string;\n fileType?: 'image' | 'document' | 'audio' | 'video' | 'other';\n}\n\n/**\n * Attachment as it appears on a message.\n *\n * Two shapes reach the UI for the same thing: the optimistic message built\n * locally on send uses `url`/`type`, while the history returned by the API\n * carries the stored `downloadUrl`/`fileType`. Both are accepted here; use\n * `normalizeMessageFile` before reading them.\n */\nexport interface MessageFile {\n name: string;\n url?: string;\n type?: string;\n downloadUrl?: string;\n fileType?: string;\n}\n\n/**\n * Message content structure\n */\nexport interface MessageContent {\n message?: string;\n data?: any;\n files?: MessageFile[];\n}\n\n/** Collapse either attachment shape into a single one the UI can render. */\nexport function normalizeMessageFile(file: MessageFile): {\n name: string;\n url: string;\n type: string;\n} {\n return {\n name: file.name,\n url: file.url || file.downloadUrl || '',\n type: file.type || file.fileType || 'other',\n };\n}\n\n/**\n * Tool call from the model\n */\nexport interface ToolCall {\n id: string;\n type: 'function';\n function: {\n name: string;\n arguments: string;\n };\n}\n\n/**\n * Chat message structure\n */\nexport interface ChatMessage {\n uid: string;\n role: 'user' | 'assistant' | 'developer' | 'system' | 'tool';\n content: MessageContent;\n timestamp: number;\n chatUid?: string;\n tool_calls?: ToolCall[];\n tool_call_id?: string;\n summary?: string;\n /**\n * Where `content.message` came from, when the model did not write it.\n * `'finish_tool'`: the assistant is configured to require a tool call to\n * finish (\"Require Tool Use to Finish\") and the backend lifted the reply from\n * the finish tool's `message` argument, so it can be read without parsing\n * tool calls. Absent on replies the model wrote itself — use it to label the\n * bubble as produced by the tool.\n */\n contentSource?: string;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Present on user messages dictated by voice; the chat can use\n * it to fetch the source audio (GET /api/v1/whisper/:transcriptId) and offer\n * playback.\n */\n transcriptId?: string;\n /**\n * Original server uid, present when the UI adopted an optimistic uid for\n * this message to keep React keys stable. Server-side references (e.g.\n * memory recall anchors) match against it.\n */\n serverUid?: string;\n /**\n * Client-side only: the conversation was busy when this message was sent, so\n * it was accepted into the queue and is waiting its turn. Drawn as a message\n * that has not landed rather than as part of the conversation. Falls away on\n * its own once the message comes back inside the history.\n */\n queued?: boolean;\n /**\n * Client-side only: when this message was accepted into the queue. Used to\n * tell \"the server has not reported it yet\" from \"the server no longer has\n * it\", which the timestamp is the only honest way to decide.\n */\n queuedAt?: number;\n}\n\n/**\n * Previous conversation message for initialization\n */\nexport interface PreviousMessage {\n message: string;\n role: 'user' | 'assistant';\n}\n\n/**\n * Model interface tool schema following OpenAI function calling format\n */\nexport interface ModelInterfaceToolSchema {\n type: 'function';\n function: {\n name: string;\n description: string;\n parameters: {\n type: 'object';\n properties: Record<string, any>;\n required?: string[];\n };\n };\n}\n\n/**\n * Props passed to a response widget component.\n * The widget is responsible for collecting the user's response and\n * calling `submit` with the payload to resolve the tool call.\n */\nexport interface ResponseWidgetProps {\n /** The tool call this widget is responding to */\n toolCall: ToolCall;\n /** Parsed arguments from the tool call */\n params: any;\n /** Submit the tool response payload (sent as the tool call result to the model) */\n submit: (response: any) => void;\n /** Cancel the tool call. Sends an error response so the model can continue. */\n cancel?: (reason?: string) => void;\n /** Whether the widget is currently submitting */\n isSubmitting?: boolean;\n}\n\n/**\n * Interactive response widget configuration for a client-side tool.\n *\n * When the model calls a tool configured with a `responseWidget`, the\n * widget is rendered in the chat UI instead of executing a callback.\n * The user interacts with the widget, which calls `submit(response)` to\n * define the tool response sent back to the model.\n *\n * - `render: 'inline'` renders the widget in the message thread at the\n * position of the tool call. The text input remains enabled.\n * - `render: 'input'` replaces the chat input area with the widget\n * while it is pending. The text input is disabled until submission.\n */\nexport interface ResponseWidgetConfig {\n /** Where to render the widget */\n render: 'inline' | 'input';\n /** The widget component */\n component: React.ComponentType<ResponseWidgetProps>;\n}\n\n/**\n * Model interface tool definition for client-side tools.\n *\n * A tool must provide either a `callback` (executed automatically when\n * the model invokes the tool) or a `responseWidget` (renders UI for\n * the user to produce the tool response). Providing both is an error.\n */\nexport interface ModelInterfaceTool {\n toolName: string;\n schema: ModelInterfaceToolSchema;\n /** Executed automatically when the model calls this tool */\n callback?: (params: any) => Promise<any> | any;\n /** Interactive widget that collects the user's tool response */\n responseWidget?: ResponseWidgetConfig;\n}\n\n/**\n * Tool call response to send back to the API\n */\nexport interface ToolCallResponse {\n tool_call_id: string;\n content: any;\n role: 'tool';\n /**\n * The client-side tools still on offer for the rest of the turn. The API\n * reads them off the first response of the batch: leaving them out drops\n * the tools from the continuation, so the model cannot call them again.\n */\n tools?: ModelInterfaceToolSchema[];\n}\n\n/**\n * DTO for sending messages to the assistant\n */\nexport interface ProcessMessageDto {\n message: string;\n chatUid?: string;\n userName?: string;\n files?: ChatFile[];\n /** Tags to associate with this chat (top-level, distinct from `metadata`). */\n tags?: string[];\n metadata?: {\n promptTemplateParams?: Record<string, any>;\n tenantToken?: string;\n [key: string]: any;\n };\n tenantId?: string;\n previousConversation?: PreviousMessage[];\n enabledTools?: string[];\n provider?: string;\n model?: string;\n // Model interface protocol fields\n tools?: ModelInterfaceToolSchema[];\n applicationState?: Record<string, any>;\n skipSummarization?: boolean;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Sent so the conversation keeps a link to the original audio.\n */\n transcriptId?: string;\n}\n\n/**\n * Response from the /whisper speech-to-text endpoint.\n */\nexport interface WhisperTranscriptionResponse {\n /** Public id of the transcript; send it back as ProcessMessageDto.transcriptId. */\n transcriptId: string;\n /** Transcribed text. */\n text: string;\n /** Language hint used, if any. */\n language?: string;\n /** Download URL of the source audio. */\n audioUrl?: string;\n /** Transcription model used. */\n model?: string;\n}\n\n/**\n * Response from the assistant\n */\nexport interface AssistantResponse {\n messages: ChatMessage[];\n chatUid: string;\n inputTokens?: number;\n outputTokens?: number;\n}\n\n/**\n * Async mode response\n */\nexport interface AsyncResponse {\n chatUid: string;\n message?: string;\n error?: string;\n /**\n * The conversation could not take the message right now, so it was queued\n * instead of starting a run of its own. Still an acceptance: the answer comes\n * later, and may cover several messages at once.\n */\n queued?: boolean;\n /** How many messages are queued on this conversation, this one included. */\n queuePosition?: number;\n /** When the queued message reaches the model. */\n willProcess?: QueueDisposition;\n}\n\n/**\n * When a queued message will reach the model.\n *\n * `after_delay` is the one that is not about being busy: an idle conversation\n * on an assistant with an input delay collects what is written during the\n * window, so a message can come back queued with nothing in flight at all.\n */\nexport type QueueDisposition = 'after_delay' | 'next_turn' | 'on_resume';\n\n/** Response of the stop endpoint. */\nexport interface StopChatResponse {\n chatUid: string;\n message: string;\n /**\n * Queued messages the stop threw away — answering them would be the opposite\n * of what was asked. Handed back so their text can be put where the user\n * wrote it. Absent on an API older than this, and when nothing was queued.\n */\n discardedMessages?: ChatMessage[];\n}\n\n/**\n * Real-time chat history status.\n * `limit_exceeded` means the message was blocked before reaching the LLM\n * because a configured tenant/subtenant usage limit was reached.\n */\nexport type RealtimeStatus =\n | 'processing'\n | 'completed'\n | 'error'\n | 'waiting_for_tool_response'\n | 'handed_off'\n | 'limit_exceeded'\n /** Collecting messages during the assistant's input delay, before any run. */\n | 'buffering';\n\n/**\n * Details of a tenant/subtenant usage limit that blocked a message.\n * Returned on the realtime endpoint when status is `limit_exceeded`, and on\n * the HTTP 429 body (`details`) when a synchronous request is blocked.\n */\nexport interface TenantLimitExceeded {\n /** Human-readable message describing the block. */\n message?: string;\n /** The rule that triggered the block (scope, metric, window, limit…). */\n blockingRule?: {\n scope?: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n windowEvery?: number;\n limit?: number;\n };\n /** Current consumption in the blocking window. */\n current?: number;\n /** The limit that was reached. */\n limit?: number;\n /** Epoch ms when the blocking window resets and usage is allowed again. */\n resetsAt?: number;\n}\n\n/** One fact a long-term-memory recall surfaced. */\nexport interface RecalledMemoryFact {\n fact: string;\n relation: string;\n /** Source entity name of the graph edge, when the fact connects two. */\n source: string | null;\n /** Target entity name of the graph edge, when the fact connects two. */\n target: string | null;\n /** ISO date the fact became valid, if known. */\n validAt: string | null;\n}\n\n/** One graph entity a long-term-memory recall surfaced. */\nexport interface RecalledMemoryEntity {\n id: string;\n name: string;\n type: string;\n summary: string | null;\n}\n\n/** One previous-session turn a conversation-start recall carried over. */\nexport interface RecalledMemoryTurn {\n role: string;\n content: string;\n}\n\n/**\n * One structured long-term-memory recall event of a conversation: the facts,\n * entities and previous-session turns a recall surfaced, plus the uid of the\n * message that brought it in (`messageUid`: the initial user message, or the\n * assistant message carrying the memory tool call — resolvable through\n * `toolCallId` while the run is still in flight).\n */\nexport interface RecalledMemoryRecord {\n uid: string;\n messageUid?: string;\n toolCallId?: string;\n source:\n | 'conversation_start'\n | 'search_memory'\n | 'search_memory_nodes'\n | 'explore_memory_graph';\n query?: string;\n facts?: RecalledMemoryFact[];\n entities?: RecalledMemoryEntity[];\n turns?: RecalledMemoryTurn[];\n timestampMs: number;\n}\n\n/**\n * Snapshot of the core-memory block a conversation saw (audit trail): the\n * render revision plus the injected entries as structured items.\n */\nexport interface CoreMemorySnapshot {\n uid: string;\n revision: string;\n items: Array<{\n id: number;\n section: string;\n content: string;\n pinned: boolean;\n source: string;\n }>;\n entries: number;\n omitted: number;\n chars: number;\n timestampMs: number;\n}\n\n/**\n * Real-time chat history response\n */\nexport interface RealtimeChatHistory {\n chatUID: string;\n clientUID: string;\n chatHistory: ChatMessage[];\n status: RealtimeStatus;\n lastUpdatedAt: number;\n pendingToolCalls?: ToolCall[];\n handedOffSubThreadId?: string;\n /** Present only when status is `limit_exceeded`. */\n limitExceeded?: TenantLimitExceeded;\n /**\n * Memory-recall events of the in-flight run — lets the UI show what the\n * assistant is recalling while the response is still processing.\n */\n recalledMemories?: RecalledMemoryRecord[];\n /**\n * Messages accepted into this conversation that the model has not seen yet.\n * Non-zero means more is coming: a `completed` status with messages still\n * queued is not the end of the exchange.\n */\n queuedMessages?: number;\n /**\n * The queued messages themselves. This is the conversation's queue, not the\n * caller's — it can include messages the same conversation received through\n * another channel. Absent on an API that does not return them, in which case\n * the widget falls back to its own optimistic copies.\n */\n pendingUserMessages?: ChatMessage[];\n}\n\n/**\n * A single usage rule with its current consumption (from GET\n * /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]).\n */\nexport interface TenantUsageRule {\n scope: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n /** Configured limit for the window. */\n limit: number;\n /** Current consumption in the active window. */\n current: number;\n /** Utilization percentage (0..100, capped). */\n percent: number;\n /** Epoch ms when the active window resets. */\n resetsAt?: number;\n /** Where the rule comes from ('tier' | 'adhoc'). */\n origin?: string;\n /** Tier the rule belongs to, if any. */\n tierId?: string;\n}\n\n/**\n * Response of GET /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]:\n * the effective usage rules with their current consumption + the active tier.\n */\nexport interface TenantUsage {\n tenantId: string;\n subtenantId?: string;\n tierId?: string;\n usage: TenantUsageRule[];\n}\n\n/**\n * A durable per-window usage history row (from GET\n * /api/v1/tenant-usage/:tenantId/history).\n */\nexport interface TenantUsageHistoryRow {\n clientUID: string;\n tenantId: string;\n subtenantId: string;\n scope: 'tenant' | 'subtenant';\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n windowKey: string;\n windowStart: number;\n windowEnd: number;\n /** Counted consumption (enforced). */\n consumption: number;\n /** Exempt consumption that did not count toward the limit, if any. */\n exemptConsumption?: number;\n limit: number;\n percent: number;\n tierId?: string;\n origin?: string;\n capturedAt: number;\n}\n\n/**\n * Options for querying tenant usage history.\n */\nexport interface TenantUsageHistoryQuery {\n subtenantId?: string;\n scope?: 'tenant' | 'subtenant';\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n /** Epoch ms lower bound (windowEnd >= from). */\n from?: number;\n /** Epoch ms upper bound (windowEnd <= to). */\n to?: number;\n limit?: number;\n skip?: number;\n}\n\n/**\n * Chat history structure\n */\nexport interface ChatHistory {\n chatUID: string;\n clientUID: string;\n userUID: string;\n chatContent: ChatMessage[];\n name?: string;\n assistantSpecializationIdentifier: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n llm?: string;\n inputTokens?: number;\n outputTokens?: number;\n metadata?: Record<string, any>;\n tenantId?: string;\n handedOff?: boolean;\n handedOffSubThreadId?: string;\n handedOffToolCallId?: string;\n /** Structured long-term-memory recall events of the conversation. */\n recalledMemories?: RecalledMemoryRecord[];\n /** Audit trail of the core-memory blocks the conversation saw. */\n coreMemories?: CoreMemorySnapshot[];\n}\n\n/** One core memory entry (the always-injected tier), as returned by the memory API. */\nexport interface CoreMemoryEntry {\n id: number;\n section: string;\n content: string;\n source: string;\n pinned: boolean;\n supersedes: number | null;\n archivedAt: string | null;\n createdAt?: string;\n updatedAt?: string;\n}\n\n/** Deployment caps of the core memory tier. */\nexport interface CoreMemoryLimits {\n maxChars: number;\n maxEntries: number;\n maxEntryChars: number;\n}\n\n/**\n * Response of GET /api/v1/memory/assistants/:identifier/core — the entries\n * of the bucket the assistant resolves for a tenant/subtenant combination.\n */\nexport interface CoreMemoryList {\n /** False when the assistant does not have the core memory tier enabled. */\n enabled: boolean;\n /** The resolved bucket tuple (tenant/subtenant/owner dimensions). */\n bucket: { tenantId?: string; subtenantId?: string; entityId?: string };\n entries: CoreMemoryEntry[];\n limits?: CoreMemoryLimits;\n}\n\n/**\n * Assistant specialization info\n */\nexport interface AssistantSpecialization {\n identifier: string;\n name: string;\n description: string;\n state: 'active' | 'inactive' | 'coming_soon';\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n availableToolsGroups?: Array<{\n name: string;\n description?: string;\n uid?: string;\n iconUrl?: string;\n tools?: Array<{\n name: string;\n description: string;\n }>;\n }>;\n model?: string;\n isCustom?: boolean;\n creationTimestampMs?: number;\n /**\n * Whether this assistant offers MCP servers of the tenant's own.\n *\n * Same contract as `tenantIntegrations` below, absence included.\n */\n tenantMcpServers?: {\n enabled: boolean;\n /** Servers listed ready to connect. Says nothing about how many are connected. */\n count?: number;\n };\n /**\n * Whether this assistant offers connected apps to its tenants.\n *\n * **Absent means \"cannot tell\", not \"no\"** — an API older than this field\n * says nothing, and treating silence as a no would hide the connected-apps\n * button from anyone whose deployment has not caught up yet.\n */\n tenantIntegrations?: {\n enabled: boolean;\n /**\n * How many apps the catalogue offers. An upper bound — the listing drops\n * any the provider cannot resolve — and enough to size a placeholder.\n */\n count?: number;\n };\n /**\n * Whether this assistant accepts messages sent while the conversation is\n * busy, queueing them instead of refusing them.\n *\n * **Absent means no**, unlike `tenantIntegrations` above. Promising a queue\n * that does not exist is paid for with a 409 and with the user's text left in\n * the air, so silence is read as the safe answer rather than as the open one.\n */\n messageQueueEnabled?: boolean;\n /** How many messages may wait at once before further sends are refused. */\n maxQueuedMessages?: number;\n}\n\n/**\n * Summary of a conversation for listing\n */\nexport interface ConversationSummary {\n chatUID: string;\n name?: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n}\n\nexport interface ListConversationsResponse {\n histories: ConversationSummary[];\n total: number;\n offset: number;\n limit: number;\n}\n\n/**\n * API error response\n */\nexport interface ApiError {\n statusCode: number;\n message: string;\n error?: string;\n /** Optional structured details (e.g. usage-limit blocking info on a 429). */\n details?: any;\n}\n\n/**\n * Feedback submission request\n */\nexport interface FeedbackSubmission {\n messageId: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n}\n\n/**\n * Feedback entry response\n */\nexport interface FeedbackEntry {\n _id: string;\n requestId: string;\n chatUID?: string;\n threadId?: string;\n agentId?: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n creationTimestamp: string;\n lastEditTimestamp?: string;\n}\n\n/**\n * Agent thread states\n */\nexport enum AgentThreadState {\n QUEUED = 'queued',\n PROCESSING = 'processing',\n COMPLETED = 'completed',\n FAILED = 'failed',\n TERMINATED = 'terminated',\n PAUSED = 'paused',\n PAUSED_FOR_APPROVAL = 'paused_for_approval',\n APPROVAL_REJECTED = 'approval_rejected',\n WAITING_FOR_RESPONSE = 'waiting_for_response',\n PAUSED_FOR_RESUME = 'paused_for_resume',\n HANDED_OFF = 'handed_off',\n GUARDRAIL_TRIGGER = 'guardrail_trigger',\n}\n\n/**\n * Task within an agent thread\n */\nexport interface AgentTaskDto {\n _id?: string;\n title?: string;\n description?: string;\n completed: boolean;\n}\n\n/**\n * Agent thread DTO\n */\nexport interface AgentThreadDto {\n _id?: string;\n agentId: string;\n state: AgentThreadState;\n threadContent: ChatMessage[];\n tasks?: AgentTaskDto[];\n finishReason?: string;\n pausedReason?: string;\n name?: string;\n creationTimestampMs?: number;\n lastEditTimestampMs?: number;\n pauseUntil?: number;\n isSubthread?: boolean;\n parentThreadId?: string;\n subThreadToolCallId?: string;\n parentAgentId?: string;\n}\n\n/**\n * Agent details\n */\nexport interface AgentDto {\n _id?: string;\n name: string;\n description?: string;\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n agentId?: string;\n}\n\n/**\n * Hand-off tool response content\n */\nexport interface HandOffToolResponse {\n response: string;\n subthreadId: string;\n}\n\n/**\n * Represents a single tool call within a tool group\n */\nexport interface ToolGroupCall {\n name: string;\n input: any;\n output: any;\n toolCallId: string;\n}\n\n/**\n * Configuration for grouping consecutive tool calls under a single renderer\n */\nexport interface ToolGroupConfig {\n tools: string[];\n renderer: (calls: ToolGroupCall[]) => React.ReactNode;\n}\n\n/**\n * One of the end user's connected accounts for an app.\n *\n * The provider's own identifiers do not travel here beyond `id`, which the\n * client needs in order to name the account it wants disconnected — and which\n * the server re-checks against the caller's tenant on the way back in.\n */\nexport interface IntegrationAccount {\n id: string;\n status: string;\n connectedAt?: string;\n updatedAt?: string;\n /** True when the account exists but can no longer run tools. */\n needsReconnect?: boolean;\n statusReason?: string;\n}\n\n/**\n * One value the end user is asked for before an account can be connected —\n * their API key, the subdomain of their instance.\n *\n * Comes from the provider's own catalogue, so the form is rendered from this\n * rather than from anything app-specific: most apps do not authenticate with\n * credentials Devic holds, and there are hundreds of them.\n */\nexport interface IntegrationAuthField {\n name: string;\n label: string;\n type: string;\n required: boolean;\n description?: string;\n /** Prefilled — usually a provider endpoint most accounts should keep. */\n default?: string;\n /** Mask it on screen. */\n secret: boolean;\n}\n\n/**\n * One way of connecting an app.\n *\n * `redirect` schemes send the user to the provider; the rest are connected\n * with the values they type, without ever leaving the page.\n *\n * There is deliberately no field for the *application's* credentials: the\n * OAuth application belongs to the developer who embedded this widget, is\n * registered once for every tenant, and is never the end user's to supply.\n */\nexport interface IntegrationAuthScheme {\n /** The provider's own name for it: `OAUTH2`, `API_KEY`, … */\n mode: string;\n /** Credentials for this scheme are held for you — nothing to fill in. */\n composioManaged: boolean;\n redirect: boolean;\n /** What this account supplies. Empty for a scheme that asks nothing. */\n accountFields: IntegrationAuthField[];\n /** The provider's own setup guide, when there is one. */\n guideUrl?: string;\n}\n\n/**\n * The answer when connecting needs values that were not sent.\n *\n * `stage` decides who can act on it: `account` is the end user, and the form\n * asks them. `app` is the developer's OAuth application, which the end user\n * cannot register — so that case is shown as \"not available yet\" instead of a\n * form asking a stranger for someone else's client secret.\n */\nexport interface IntegrationSetupRequired {\n code: \"INTEGRATION_SETUP_REQUIRED\";\n message: string;\n toolkit: string;\n authScheme: string;\n stage: \"app\" | \"account\";\n fields: IntegrationAuthField[];\n guideUrl?: string;\n}\n\n/**\n * An app the assistant offers to its tenants, with the accounts THIS tenant\n * has connected. Never another tenant's.\n */\nexport interface Integration {\n /** App slug, e.g. `gmail`. */\n app: string;\n name: string;\n description?: string;\n logo?: string;\n /** True when at least one account is active. */\n connected: boolean;\n accounts: IntegrationAccount[];\n /** Event types the developer allows this tenant to switch on. */\n availableTriggers?: string[];\n}\n\n// ── MCP servers the end user connects for themselves ──────────────────────\n\nexport type TenantMcpAuthMode = \"oauth\" | \"header\" | \"none\";\n\n/** One of the end user's own MCP connections. */\nexport interface TenantMcpConnection {\n id: string;\n /**\n * What to put in `disabledIntegrations` to have this server sit a message\n * out. Sent by the API so the prefix that separates it from an app slug lives\n * on the server, in one place.\n */\n toggleId?: string;\n name?: string;\n url: string;\n /** The developer's template this came from, when it came from one. */\n templateId?: string;\n authMode?: TenantMcpAuthMode;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n tools?: string[];\n lastProbeStatus?: string;\n lastProbeError?: string;\n lastProbeTimestampMs?: number;\n /** Connected for the whole tenant, so every end user of it shares this. */\n shared: boolean;\n /** True when this end user may use it but not change or remove it. */\n readOnly: boolean;\n}\n\n/**\n * One row of the MCP panel: either a server the developer offers ready to\n * connect, or one this end user added.\n *\n * A single list rather than two, because that is what the panel draws — keeping\n * \"offered\" and \"connected\" apart would leave them out of step for a moment\n * after every connect.\n */\nexport interface TenantMcpServer {\n source: \"template\" | \"custom\";\n templateId?: string;\n name: string;\n url: string;\n description?: string;\n logoUrl?: string;\n authMode?: TenantMcpAuthMode;\n /** Header the credential travels in, for `header` servers. */\n headerName?: string;\n /** Whether the end user may supply their own OAuth application. */\n allowClientCredentials?: boolean;\n /** Null until this tenant connects it. */\n connection: TenantMcpConnection | null;\n}\n\nexport interface TenantMcpListing {\n offered: boolean;\n /** Whether adding a server of one's own is permitted. */\n allowCustom: boolean;\n limits: { maxServers: number; maxToolsPerServer: number; used: number };\n servers: TenantMcpServer[];\n}\n\n/** Credentials the end user supplies when connecting a server. */\nexport interface TenantMcpAuthInput {\n mode?: TenantMcpAuthMode;\n headerName?: string;\n headerValue?: string;\n upstreamOAuth?: { clientId?: string; clientSecret?: string; scopes?: string[] };\n}\n\n/**\n * What connecting answers with.\n *\n * `status: \"active\"` means it is done. `authorizationUrl` must be opened in a\n * popup. `requiresClientCredentials` means the server has no dynamic client\n * registration and the end user has to register an OAuth application with it\n * themselves, authorising `callbackUrl` as the redirect URI.\n */\nexport interface TenantMcpConnectResult {\n id: string;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n authorizationUrl?: string;\n requiresClientCredentials?: boolean;\n callbackUrl?: string;\n error?: string;\n}\n"],"names":["AgentThreadState"],"mappings":";;AAsCA;AACM,SAAU,oBAAoB,CAAC,IAAiB,EAAA;IAKpD,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,IAAI,EAAE;QACvC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,OAAO;KAC5C;AACH;AAuoBA;;AAEG;AACSA;AAAZ,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,qBAAA,CAAA,GAAA,qBAA2C;AAC3C,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,gBAAA,CAAA,sBAAA,CAAA,GAAA,sBAA6C;AAC7C,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACzC,CAAC,EAbWA,wBAAgB,KAAhBA,wBAAgB,GAAA,EAAA,CAAA,CAAA;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../src/api/types.ts"],"sourcesContent":["import type { AvatarStyle } from '../utils/avatar';\n\nimport type React from 'react';\n\n/**\n * File attachment for messages\n */\nexport interface ChatFile {\n name: string;\n downloadUrl?: string;\n fileType?: 'image' | 'document' | 'audio' | 'video' | 'other';\n}\n\n/**\n * Attachment as it appears on a message.\n *\n * Two shapes reach the UI for the same thing: the optimistic message built\n * locally on send uses `url`/`type`, while the history returned by the API\n * carries the stored `downloadUrl`/`fileType`. Both are accepted here; use\n * `normalizeMessageFile` before reading them.\n */\nexport interface MessageFile {\n name: string;\n url?: string;\n type?: string;\n downloadUrl?: string;\n fileType?: string;\n}\n\n/**\n * Message content structure\n */\nexport interface MessageContent {\n message?: string;\n data?: any;\n files?: MessageFile[];\n}\n\n/** Collapse either attachment shape into a single one the UI can render. */\nexport function normalizeMessageFile(file: MessageFile): {\n name: string;\n url: string;\n type: string;\n} {\n return {\n name: file.name,\n url: file.url || file.downloadUrl || '',\n type: file.type || file.fileType || 'other',\n };\n}\n\n/**\n * Tool call from the model\n */\nexport interface ToolCall {\n id: string;\n type: 'function';\n function: {\n name: string;\n arguments: string;\n };\n}\n\n/**\n * Chat message structure\n */\nexport interface ChatMessage {\n uid: string;\n role: 'user' | 'assistant' | 'developer' | 'system' | 'tool';\n content: MessageContent;\n timestamp: number;\n chatUid?: string;\n tool_calls?: ToolCall[];\n tool_call_id?: string;\n summary?: string;\n /**\n * Where `content.message` came from, when the model did not write it.\n * `'finish_tool'`: the assistant is configured to require a tool call to\n * finish (\"Require Tool Use to Finish\") and the backend lifted the reply from\n * the finish tool's `message` argument, so it can be read without parsing\n * tool calls. Absent on replies the model wrote itself — use it to label the\n * bubble as produced by the tool.\n */\n contentSource?: string;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Present on user messages dictated by voice; the chat can use\n * it to fetch the source audio (GET /api/v1/whisper/:transcriptId) and offer\n * playback.\n */\n transcriptId?: string;\n /**\n * Original server uid, present when the UI adopted an optimistic uid for\n * this message to keep React keys stable. Server-side references (e.g.\n * memory recall anchors) match against it.\n */\n serverUid?: string;\n /**\n * Client-side only: the conversation was busy when this message was sent, so\n * it was accepted into the queue and is waiting its turn. Drawn as a message\n * that has not landed rather than as part of the conversation. Falls away on\n * its own once the message comes back inside the history.\n */\n queued?: boolean;\n /**\n * Client-side only: when this message was accepted into the queue. Used to\n * tell \"the server has not reported it yet\" from \"the server no longer has\n * it\", which the timestamp is the only honest way to decide.\n */\n queuedAt?: number;\n}\n\n/**\n * Previous conversation message for initialization\n */\nexport interface PreviousMessage {\n message: string;\n role: 'user' | 'assistant';\n}\n\n/**\n * Model interface tool schema following OpenAI function calling format\n */\nexport interface ModelInterfaceToolSchema {\n type: 'function';\n function: {\n name: string;\n description: string;\n parameters: {\n type: 'object';\n properties: Record<string, any>;\n required?: string[];\n };\n };\n}\n\n/**\n * Props passed to a response widget component.\n * The widget is responsible for collecting the user's response and\n * calling `submit` with the payload to resolve the tool call.\n */\nexport interface ResponseWidgetProps {\n /** The tool call this widget is responding to */\n toolCall: ToolCall;\n /** Parsed arguments from the tool call */\n params: any;\n /** Submit the tool response payload (sent as the tool call result to the model) */\n submit: (response: any) => void;\n /** Cancel the tool call. Sends an error response so the model can continue. */\n cancel?: (reason?: string) => void;\n /** Whether the widget is currently submitting */\n isSubmitting?: boolean;\n}\n\n/**\n * Interactive response widget configuration for a client-side tool.\n *\n * When the model calls a tool configured with a `responseWidget`, the\n * widget is rendered in the chat UI instead of executing a callback.\n * The user interacts with the widget, which calls `submit(response)` to\n * define the tool response sent back to the model.\n *\n * - `render: 'inline'` renders the widget in the message thread at the\n * position of the tool call. The text input remains enabled.\n * - `render: 'input'` replaces the chat input area with the widget\n * while it is pending. The text input is disabled until submission.\n */\nexport interface ResponseWidgetConfig {\n /** Where to render the widget */\n render: 'inline' | 'input';\n /** The widget component */\n component: React.ComponentType<ResponseWidgetProps>;\n}\n\n/**\n * Model interface tool definition for client-side tools.\n *\n * A tool must provide either a `callback` (executed automatically when\n * the model invokes the tool) or a `responseWidget` (renders UI for\n * the user to produce the tool response). Providing both is an error.\n */\nexport interface ModelInterfaceTool {\n toolName: string;\n schema: ModelInterfaceToolSchema;\n /** Executed automatically when the model calls this tool */\n callback?: (params: any) => Promise<any> | any;\n /** Interactive widget that collects the user's tool response */\n responseWidget?: ResponseWidgetConfig;\n}\n\n/**\n * Tool call response to send back to the API\n */\nexport interface ToolCallResponse {\n tool_call_id: string;\n content: any;\n role: 'tool';\n /**\n * The client-side tools still on offer for the rest of the turn. The API\n * reads them off the first response of the batch: leaving them out drops\n * the tools from the continuation, so the model cannot call them again.\n */\n tools?: ModelInterfaceToolSchema[];\n}\n\n/**\n * DTO for sending messages to the assistant\n */\nexport interface ProcessMessageDto {\n message: string;\n chatUid?: string;\n userName?: string;\n files?: ChatFile[];\n /** Tags to associate with this chat (top-level, distinct from `metadata`). */\n tags?: string[];\n metadata?: {\n promptTemplateParams?: Record<string, any>;\n tenantToken?: string;\n [key: string]: any;\n };\n tenantId?: string;\n previousConversation?: PreviousMessage[];\n enabledTools?: string[];\n provider?: string;\n model?: string;\n // Model interface protocol fields\n tools?: ModelInterfaceToolSchema[];\n applicationState?: Record<string, any>;\n skipSummarization?: boolean;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Sent so the conversation keeps a link to the original audio.\n */\n transcriptId?: string;\n}\n\n/**\n * Response from the /whisper speech-to-text endpoint.\n */\nexport interface WhisperTranscriptionResponse {\n /** Public id of the transcript; send it back as ProcessMessageDto.transcriptId. */\n transcriptId: string;\n /** Transcribed text. */\n text: string;\n /** Language hint used, if any. */\n language?: string;\n /** Download URL of the source audio. */\n audioUrl?: string;\n /** Transcription model used. */\n model?: string;\n}\n\n/**\n * Response from the assistant\n */\nexport interface AssistantResponse {\n messages: ChatMessage[];\n chatUid: string;\n inputTokens?: number;\n outputTokens?: number;\n}\n\n/**\n * Async mode response\n */\nexport interface AsyncResponse {\n chatUid: string;\n message?: string;\n error?: string;\n /**\n * The conversation could not take the message right now, so it was queued\n * instead of starting a run of its own. Still an acceptance: the answer comes\n * later, and may cover several messages at once.\n */\n queued?: boolean;\n /** How many messages are queued on this conversation, this one included. */\n queuePosition?: number;\n /** When the queued message reaches the model. */\n willProcess?: QueueDisposition;\n}\n\n/**\n * When a queued message will reach the model.\n *\n * `after_delay` is the one that is not about being busy: an idle conversation\n * on an assistant with an input delay collects what is written during the\n * window, so a message can come back queued with nothing in flight at all.\n */\nexport type QueueDisposition = 'after_delay' | 'next_turn' | 'on_resume';\n\n/** Response of the stop endpoint. */\nexport interface StopChatResponse {\n chatUid: string;\n message: string;\n /**\n * Queued messages the stop threw away — answering them would be the opposite\n * of what was asked. Handed back so their text can be put where the user\n * wrote it. Absent on an API older than this, and when nothing was queued.\n */\n discardedMessages?: ChatMessage[];\n}\n\n/**\n * Real-time chat history status.\n * `limit_exceeded` means the message was blocked before reaching the LLM\n * because a configured tenant/subtenant usage limit was reached.\n */\nexport type RealtimeStatus =\n | 'processing'\n | 'completed'\n | 'error'\n | 'waiting_for_tool_response'\n | 'handed_off'\n | 'limit_exceeded'\n /** Collecting messages during the assistant's input delay, before any run. */\n | 'buffering';\n\n/**\n * Details of a tenant/subtenant usage limit that blocked a message.\n * Returned on the realtime endpoint when status is `limit_exceeded`, and on\n * the HTTP 429 body (`details`) when a synchronous request is blocked.\n */\nexport interface TenantLimitExceeded {\n /** Human-readable message describing the block. */\n message?: string;\n /** The rule that triggered the block (scope, metric, window, limit…). */\n blockingRule?: {\n scope?: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n windowEvery?: number;\n limit?: number;\n };\n /** Current consumption in the blocking window. */\n current?: number;\n /** The limit that was reached. */\n limit?: number;\n /** Epoch ms when the blocking window resets and usage is allowed again. */\n resetsAt?: number;\n}\n\n/** One fact a long-term-memory recall surfaced. */\nexport interface RecalledMemoryFact {\n fact: string;\n relation: string;\n /** Source entity name of the graph edge, when the fact connects two. */\n source: string | null;\n /** Target entity name of the graph edge, when the fact connects two. */\n target: string | null;\n /** ISO date the fact became valid, if known. */\n validAt: string | null;\n}\n\n/** One graph entity a long-term-memory recall surfaced. */\nexport interface RecalledMemoryEntity {\n id: string;\n name: string;\n type: string;\n summary: string | null;\n}\n\n/** One previous-session turn a conversation-start recall carried over. */\nexport interface RecalledMemoryTurn {\n role: string;\n content: string;\n}\n\n/**\n * One structured long-term-memory recall event of a conversation: the facts,\n * entities and previous-session turns a recall surfaced, plus the uid of the\n * message that brought it in (`messageUid`: the initial user message, or the\n * assistant message carrying the memory tool call — resolvable through\n * `toolCallId` while the run is still in flight).\n */\nexport interface RecalledMemoryRecord {\n uid: string;\n messageUid?: string;\n toolCallId?: string;\n source:\n | 'conversation_start'\n | 'search_memory'\n | 'search_memory_nodes'\n | 'explore_memory_graph';\n query?: string;\n facts?: RecalledMemoryFact[];\n entities?: RecalledMemoryEntity[];\n turns?: RecalledMemoryTurn[];\n timestampMs: number;\n}\n\n/**\n * Snapshot of the core-memory block a conversation saw (audit trail): the\n * render revision plus the injected entries as structured items.\n */\nexport interface CoreMemorySnapshot {\n uid: string;\n revision: string;\n items: Array<{\n id: number;\n section: string;\n content: string;\n pinned: boolean;\n source: string;\n }>;\n entries: number;\n omitted: number;\n chars: number;\n timestampMs: number;\n}\n\n/**\n * Real-time chat history response\n */\nexport interface RealtimeChatHistory {\n chatUID: string;\n clientUID: string;\n chatHistory: ChatMessage[];\n status: RealtimeStatus;\n lastUpdatedAt: number;\n pendingToolCalls?: ToolCall[];\n handedOffSubThreadId?: string;\n /** Present only when status is `limit_exceeded`. */\n limitExceeded?: TenantLimitExceeded;\n /**\n * Memory-recall events of the in-flight run — lets the UI show what the\n * assistant is recalling while the response is still processing.\n */\n recalledMemories?: RecalledMemoryRecord[];\n /**\n * Messages accepted into this conversation that the model has not seen yet.\n * Non-zero means more is coming: a `completed` status with messages still\n * queued is not the end of the exchange.\n */\n queuedMessages?: number;\n /**\n * The queued messages themselves. This is the conversation's queue, not the\n * caller's — it can include messages the same conversation received through\n * another channel. Absent on an API that does not return them, in which case\n * the widget falls back to its own optimistic copies.\n */\n pendingUserMessages?: ChatMessage[];\n /**\n * Compaction checkpoints of the in-flight run. A conversation that compacts\n * mid-run stops sending the messages above the cut immediately, so these\n * arrive here before they are persisted on the conversation.\n */\n compactions?: CompactionCheckpoint[];\n /** The compaction running right now, if any. */\n compaction?: CompactionActivity;\n}\n\n/**\n * A single usage rule with its current consumption (from GET\n * /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]).\n */\nexport interface TenantUsageRule {\n scope: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n /** Configured limit for the window. */\n limit: number;\n /** Current consumption in the active window. */\n current: number;\n /** Utilization percentage (0..100, capped). */\n percent: number;\n /** Epoch ms when the active window resets. */\n resetsAt?: number;\n /** Where the rule comes from ('tier' | 'adhoc'). */\n origin?: string;\n /** Tier the rule belongs to, if any. */\n tierId?: string;\n}\n\n/**\n * Response of GET /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]:\n * the effective usage rules with their current consumption + the active tier.\n */\nexport interface TenantUsage {\n tenantId: string;\n subtenantId?: string;\n tierId?: string;\n usage: TenantUsageRule[];\n}\n\n/**\n * A durable per-window usage history row (from GET\n * /api/v1/tenant-usage/:tenantId/history).\n */\nexport interface TenantUsageHistoryRow {\n clientUID: string;\n tenantId: string;\n subtenantId: string;\n scope: 'tenant' | 'subtenant';\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n windowKey: string;\n windowStart: number;\n windowEnd: number;\n /** Counted consumption (enforced). */\n consumption: number;\n /** Exempt consumption that did not count toward the limit, if any. */\n exemptConsumption?: number;\n limit: number;\n percent: number;\n tierId?: string;\n origin?: string;\n capturedAt: number;\n}\n\n/**\n * Options for querying tenant usage history.\n */\nexport interface TenantUsageHistoryQuery {\n subtenantId?: string;\n scope?: 'tenant' | 'subtenant';\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n /** Epoch ms lower bound (windowEnd >= from). */\n from?: number;\n /** Epoch ms upper bound (windowEnd <= to). */\n to?: number;\n limit?: number;\n skip?: number;\n}\n\n/**\n * Chat history structure\n */\n/** A concrete value carried verbatim through a compaction. */\nexport interface CompactionFact {\n kind: string;\n value: string;\n label?: string;\n}\n\n/** The structured body a compaction produced. */\nexport interface CompactionSummary {\n goal?: string;\n constraints?: string[];\n inProgress?: string;\n pending?: string[];\n decisions?: string[];\n data?: Array<{ label: string; value: string }>;\n done?: string[];\n openQuestions?: string[];\n /** Fallback when the model answered without structure. */\n raw?: string;\n}\n\n/**\n * One compaction of a conversation: the messages before its boundary folded\n * into a written summary plus the identifiers, paths and urls lifted out of\n * them verbatim. From then on the model receives the checkpoint instead of\n * those messages — which are still in the conversation, and still shown.\n *\n * Only the newest checkpoint is in force: each compaction merges the previous\n * summary into itself.\n */\nexport interface CompactionCheckpoint {\n uid: string;\n /** 1 for the first compaction of the conversation, 2 for the next… */\n index: number;\n timestampMs: number;\n trigger: 'auto' | 'manual';\n /** First message that still travels verbatim. */\n firstKeptMessageUid?: string;\n /** Last folded message: where the widget belongs in the conversation. */\n anchorMessageUid?: string;\n compactedMessageCount: number;\n summary: CompactionSummary;\n facts: CompactionFact[];\n tokensBefore: number;\n tokensAfter: number;\n provider?: string;\n model?: string;\n cost?: number;\n}\n\n/**\n * A compaction happening right now, from the realtime endpoint.\n *\n * A compaction is a model call of its own, taken between two assistant\n * messages, so a client that only knows `processing` shows a conversation\n * that appears to have stalled for a few seconds. Present while it runs and\n * on the single update that reports it finished.\n */\nexport interface CompactionActivity {\n state: 'running' | 'completed';\n startedAt: number;\n /**\n * What this pass is folding: the messages new since the last checkpoint.\n * Not the conversation's totals — a checkpoint's own\n * `compactedMessageCount` and `tokensBefore` are cumulative across every\n * compaction, so the two are on different scales and must not be paired.\n */\n messageCount: number;\n tokensBefore: number;\n /** Which checkpoint the pass produced, once it is done. */\n index?: number;\n finishedAt?: number;\n}\n\nexport interface ChatHistory {\n chatUID: string;\n clientUID: string;\n userUID: string;\n chatContent: ChatMessage[];\n name?: string;\n assistantSpecializationIdentifier: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n llm?: string;\n inputTokens?: number;\n outputTokens?: number;\n metadata?: Record<string, any>;\n tenantId?: string;\n handedOff?: boolean;\n handedOffSubThreadId?: string;\n handedOffToolCallId?: string;\n /** Structured long-term-memory recall events of the conversation. */\n recalledMemories?: RecalledMemoryRecord[];\n /** Audit trail of the core-memory blocks the conversation saw. */\n coreMemories?: CoreMemorySnapshot[];\n /** Compaction checkpoints of the conversation, oldest first. */\n compactions?: CompactionCheckpoint[];\n}\n\n/** One core memory entry (the always-injected tier), as returned by the memory API. */\nexport interface CoreMemoryEntry {\n id: number;\n section: string;\n content: string;\n source: string;\n pinned: boolean;\n supersedes: number | null;\n archivedAt: string | null;\n createdAt?: string;\n updatedAt?: string;\n}\n\n/** Deployment caps of the core memory tier. */\nexport interface CoreMemoryLimits {\n maxChars: number;\n maxEntries: number;\n maxEntryChars: number;\n}\n\n/**\n * Response of GET /api/v1/memory/assistants/:identifier/core — the entries\n * of the bucket the assistant resolves for a tenant/subtenant combination.\n */\nexport interface CoreMemoryList {\n /** False when the assistant does not have the core memory tier enabled. */\n enabled: boolean;\n /** The resolved bucket tuple (tenant/subtenant/owner dimensions). */\n bucket: { tenantId?: string; subtenantId?: string; entityId?: string };\n entries: CoreMemoryEntry[];\n limits?: CoreMemoryLimits;\n}\n\n/**\n * Assistant specialization info\n */\nexport interface AssistantSpecialization {\n identifier: string;\n name: string;\n description: string;\n state: 'active' | 'inactive' | 'coming_soon';\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n availableToolsGroups?: Array<{\n name: string;\n description?: string;\n uid?: string;\n iconUrl?: string;\n tools?: Array<{\n name: string;\n description: string;\n }>;\n }>;\n model?: string;\n isCustom?: boolean;\n creationTimestampMs?: number;\n /**\n * Whether this assistant offers MCP servers of the tenant's own.\n *\n * Same contract as `tenantIntegrations` below, absence included.\n */\n tenantMcpServers?: {\n enabled: boolean;\n /** Servers listed ready to connect. Says nothing about how many are connected. */\n count?: number;\n };\n /**\n * Whether this assistant offers connected apps to its tenants.\n *\n * **Absent means \"cannot tell\", not \"no\"** — an API older than this field\n * says nothing, and treating silence as a no would hide the connected-apps\n * button from anyone whose deployment has not caught up yet.\n */\n tenantIntegrations?: {\n enabled: boolean;\n /**\n * How many apps the catalogue offers. An upper bound — the listing drops\n * any the provider cannot resolve — and enough to size a placeholder.\n */\n count?: number;\n };\n /**\n * Whether this assistant accepts messages sent while the conversation is\n * busy, queueing them instead of refusing them.\n *\n * **Absent means no**, unlike `tenantIntegrations` above. Promising a queue\n * that does not exist is paid for with a 409 and with the user's text left in\n * the air, so silence is read as the safe answer rather than as the open one.\n */\n messageQueueEnabled?: boolean;\n /** How many messages may wait at once before further sends are refused. */\n maxQueuedMessages?: number;\n}\n\n/**\n * Summary of a conversation for listing\n */\nexport interface ConversationSummary {\n chatUID: string;\n name?: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n}\n\nexport interface ListConversationsResponse {\n histories: ConversationSummary[];\n total: number;\n offset: number;\n limit: number;\n}\n\n/**\n * API error response\n */\nexport interface ApiError {\n statusCode: number;\n message: string;\n error?: string;\n /** Optional structured details (e.g. usage-limit blocking info on a 429). */\n details?: any;\n}\n\n/**\n * Feedback submission request\n */\nexport interface FeedbackSubmission {\n messageId: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n}\n\n/**\n * Feedback entry response\n */\nexport interface FeedbackEntry {\n _id: string;\n requestId: string;\n chatUID?: string;\n threadId?: string;\n agentId?: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n creationTimestamp: string;\n lastEditTimestamp?: string;\n}\n\n/**\n * Agent thread states\n */\nexport enum AgentThreadState {\n QUEUED = 'queued',\n PROCESSING = 'processing',\n COMPLETED = 'completed',\n FAILED = 'failed',\n TERMINATED = 'terminated',\n PAUSED = 'paused',\n PAUSED_FOR_APPROVAL = 'paused_for_approval',\n APPROVAL_REJECTED = 'approval_rejected',\n WAITING_FOR_RESPONSE = 'waiting_for_response',\n PAUSED_FOR_RESUME = 'paused_for_resume',\n HANDED_OFF = 'handed_off',\n GUARDRAIL_TRIGGER = 'guardrail_trigger',\n}\n\n/**\n * Task within an agent thread\n */\nexport interface AgentTaskDto {\n _id?: string;\n title?: string;\n description?: string;\n completed: boolean;\n}\n\n/**\n * Agent thread DTO\n */\nexport interface AgentThreadDto {\n _id?: string;\n agentId: string;\n state: AgentThreadState;\n threadContent: ChatMessage[];\n tasks?: AgentTaskDto[];\n finishReason?: string;\n pausedReason?: string;\n name?: string;\n creationTimestampMs?: number;\n lastEditTimestampMs?: number;\n pauseUntil?: number;\n isSubthread?: boolean;\n parentThreadId?: string;\n subThreadToolCallId?: string;\n parentAgentId?: string;\n}\n\n/**\n * Agent details\n */\nexport interface AgentDto {\n _id?: string;\n name: string;\n description?: string;\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n agentId?: string;\n}\n\n/**\n * Hand-off tool response content\n */\nexport interface HandOffToolResponse {\n response: string;\n subthreadId: string;\n}\n\n/**\n * Represents a single tool call within a tool group\n */\nexport interface ToolGroupCall {\n name: string;\n input: any;\n output: any;\n toolCallId: string;\n}\n\n/**\n * Configuration for grouping consecutive tool calls under a single renderer\n */\nexport interface ToolGroupConfig {\n tools: string[];\n renderer: (calls: ToolGroupCall[]) => React.ReactNode;\n}\n\n/**\n * One of the end user's connected accounts for an app.\n *\n * The provider's own identifiers do not travel here beyond `id`, which the\n * client needs in order to name the account it wants disconnected — and which\n * the server re-checks against the caller's tenant on the way back in.\n */\nexport interface IntegrationAccount {\n id: string;\n status: string;\n connectedAt?: string;\n updatedAt?: string;\n /** True when the account exists but can no longer run tools. */\n needsReconnect?: boolean;\n statusReason?: string;\n}\n\n/**\n * One value the end user is asked for before an account can be connected —\n * their API key, the subdomain of their instance.\n *\n * Comes from the provider's own catalogue, so the form is rendered from this\n * rather than from anything app-specific: most apps do not authenticate with\n * credentials Devic holds, and there are hundreds of them.\n */\nexport interface IntegrationAuthField {\n name: string;\n label: string;\n type: string;\n required: boolean;\n description?: string;\n /** Prefilled — usually a provider endpoint most accounts should keep. */\n default?: string;\n /** Mask it on screen. */\n secret: boolean;\n}\n\n/**\n * One way of connecting an app.\n *\n * `redirect` schemes send the user to the provider; the rest are connected\n * with the values they type, without ever leaving the page.\n *\n * There is deliberately no field for the *application's* credentials: the\n * OAuth application belongs to the developer who embedded this widget, is\n * registered once for every tenant, and is never the end user's to supply.\n */\nexport interface IntegrationAuthScheme {\n /** The provider's own name for it: `OAUTH2`, `API_KEY`, … */\n mode: string;\n /** Credentials for this scheme are held for you — nothing to fill in. */\n composioManaged: boolean;\n redirect: boolean;\n /** What this account supplies. Empty for a scheme that asks nothing. */\n accountFields: IntegrationAuthField[];\n /** The provider's own setup guide, when there is one. */\n guideUrl?: string;\n}\n\n/**\n * The answer when connecting needs values that were not sent.\n *\n * `stage` decides who can act on it: `account` is the end user, and the form\n * asks them. `app` is the developer's OAuth application, which the end user\n * cannot register — so that case is shown as \"not available yet\" instead of a\n * form asking a stranger for someone else's client secret.\n */\nexport interface IntegrationSetupRequired {\n code: \"INTEGRATION_SETUP_REQUIRED\";\n message: string;\n toolkit: string;\n authScheme: string;\n stage: \"app\" | \"account\";\n fields: IntegrationAuthField[];\n guideUrl?: string;\n}\n\n/**\n * An app the assistant offers to its tenants, with the accounts THIS tenant\n * has connected. Never another tenant's.\n */\nexport interface Integration {\n /** App slug, e.g. `gmail`. */\n app: string;\n name: string;\n description?: string;\n logo?: string;\n /** True when at least one account is active. */\n connected: boolean;\n accounts: IntegrationAccount[];\n /** Event types the developer allows this tenant to switch on. */\n availableTriggers?: string[];\n}\n\n// ── MCP servers the end user connects for themselves ──────────────────────\n\nexport type TenantMcpAuthMode = \"oauth\" | \"header\" | \"none\";\n\n/** One of the end user's own MCP connections. */\nexport interface TenantMcpConnection {\n id: string;\n /**\n * What to put in `disabledIntegrations` to have this server sit a message\n * out. Sent by the API so the prefix that separates it from an app slug lives\n * on the server, in one place.\n */\n toggleId?: string;\n name?: string;\n url: string;\n /** The developer's template this came from, when it came from one. */\n templateId?: string;\n authMode?: TenantMcpAuthMode;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n tools?: string[];\n lastProbeStatus?: string;\n lastProbeError?: string;\n lastProbeTimestampMs?: number;\n /** Connected for the whole tenant, so every end user of it shares this. */\n shared: boolean;\n /** True when this end user may use it but not change or remove it. */\n readOnly: boolean;\n}\n\n/**\n * One row of the MCP panel: either a server the developer offers ready to\n * connect, or one this end user added.\n *\n * A single list rather than two, because that is what the panel draws — keeping\n * \"offered\" and \"connected\" apart would leave them out of step for a moment\n * after every connect.\n */\nexport interface TenantMcpServer {\n source: \"template\" | \"custom\";\n templateId?: string;\n name: string;\n url: string;\n description?: string;\n logoUrl?: string;\n authMode?: TenantMcpAuthMode;\n /** Header the credential travels in, for `header` servers. */\n headerName?: string;\n /** Whether the end user may supply their own OAuth application. */\n allowClientCredentials?: boolean;\n /** Null until this tenant connects it. */\n connection: TenantMcpConnection | null;\n}\n\nexport interface TenantMcpListing {\n offered: boolean;\n /** Whether adding a server of one's own is permitted. */\n allowCustom: boolean;\n limits: { maxServers: number; maxToolsPerServer: number; used: number };\n servers: TenantMcpServer[];\n}\n\n/** Credentials the end user supplies when connecting a server. */\nexport interface TenantMcpAuthInput {\n mode?: TenantMcpAuthMode;\n headerName?: string;\n headerValue?: string;\n upstreamOAuth?: { clientId?: string; clientSecret?: string; scopes?: string[] };\n}\n\n/**\n * What connecting answers with.\n *\n * `status: \"active\"` means it is done. `authorizationUrl` must be opened in a\n * popup. `requiresClientCredentials` means the server has no dynamic client\n * registration and the end user has to register an OAuth application with it\n * themselves, authorising `callbackUrl` as the redirect URI.\n */\nexport interface TenantMcpConnectResult {\n id: string;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n authorizationUrl?: string;\n requiresClientCredentials?: boolean;\n callbackUrl?: string;\n error?: string;\n}\n"],"names":["AgentThreadState"],"mappings":";;AAsCA;AACM,SAAU,oBAAoB,CAAC,IAAiB,EAAA;IAKpD,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,IAAI,EAAE;QACvC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,OAAO;KAC5C;AACH;AA2tBA;;AAEG;AACSA;AAAZ,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,qBAAA,CAAA,GAAA,qBAA2C;AAC3C,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,gBAAA,CAAA,sBAAA,CAAA,GAAA,sBAA6C;AAC7C,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACzC,CAAC,EAbWA,wBAAgB,KAAhBA,wBAAgB,GAAA,EAAA,CAAA,CAAA;;"}
|
|
@@ -95,6 +95,8 @@ const DEFAULT_OPTIONS = {
|
|
|
95
95
|
messageQueue: undefined,
|
|
96
96
|
showRecalledMemories: true,
|
|
97
97
|
recalledMemoriesRenderer: undefined,
|
|
98
|
+
showCompaction: true,
|
|
99
|
+
compactionRenderer: undefined,
|
|
98
100
|
showCoreMemoryButton: false,
|
|
99
101
|
coreMemoryLabels: undefined,
|
|
100
102
|
showIntegrationsButton: true,
|
|
@@ -724,7 +726,7 @@ function ChatDrawerInner({ assistantId, chatUid: initialChatUid, options = {}, e
|
|
|
724
726
|
}), [mergedOptions.zIndex, mergedOptions.position]);
|
|
725
727
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!isInline && (jsxRuntime.jsx("div", { className: "devic-drawer-overlay", "data-open": isOpen, style: overlayStyle, onClick: handleClose })), jsxRuntime.jsxs("div", { ref: drawerRef, className: `devic-chat-drawer ${className || ''}`, "data-position": mergedOptions.position, "data-open": isOpen, "data-mode": mode, style: drawerStyle, children: [mergedOptions.resizable && (jsxRuntime.jsx("div", { className: "devic-resize-handle", "data-position": mergedOptions.position, onMouseDown: handleResizeStart })), jsxRuntime.jsxs("div", { className: "devic-drawer-header", children: [avatarUrl && (jsxRuntime.jsx("img", { className: "devic-drawer-avatar", src: avatarUrl, alt: "", "aria-hidden": "true" })), jsxRuntime.jsx("h2", { className: "devic-drawer-title", children: mergedOptions.title }), jsxRuntime.jsx(ConversationSelector.ConversationSelector, { assistantId: assistantId, currentChatUid: chat.chatUid, onSelect: handleConversationSelect, onNewChat: handleNewChat, apiKey: apiKey, baseUrl: baseUrl, tenantId: tenantId, subtenantId: subtenantId, conversationPreview: mergedOptions.conversationPreview }), jsxRuntime.jsxs("div", { className: "devic-drawer-header-actions", children: [mergedOptions.showIntegrationsButton !== false && (jsxRuntime.jsx(IntegrationsLauncher.IntegrationsLauncher, { state: integrationsState, mcp: mcpState, onClick: () => setIntegrationsOpen(true), label: mergedOptions.integrationsLabel, maxLogos: mergedOptions.maxIntegrationLogos, dark: theme.isDarkTheme(modalTheme), placeholders: pendingIntegrations, loading: integrationsDeciding })), mergedOptions.showCoreMemoryButton && (jsxRuntime.jsx("button", { className: "devic-new-chat-btn", onClick: () => setCoreMemoryOpen(true), type: "button", "aria-label": coreMemoryTitle, title: coreMemoryTitle, children: jsxRuntime.jsx(BrainIcon, {}) })), jsxRuntime.jsx("button", { className: "devic-new-chat-btn", onClick: handleNewChat, type: "button", "aria-label": "New chat", title: "New chat", children: jsxRuntime.jsx(PlusIcon, {}) }), !isInline && (jsxRuntime.jsx("button", { className: "devic-drawer-close", onClick: handleClose, type: "button", "aria-label": "Close chat", children: jsxRuntime.jsx(CloseIcon, {}) }))] })] }), chat.error && (jsxRuntime.jsx("div", { className: "devic-error", children: chat.error.message })), jsxRuntime.jsx(ChatMessages.ChatMessages, { messages: chat.messages, allMessages: chat.messages, isLoading: chat.isLoading, welcomeMessage: mergedOptions.welcomeMessage, suggestedMessages: mergedOptions.suggestedMessages, onSuggestedClick: handleSuggestedClick, showToolTimeline: mergedOptions.showToolTimeline, toolRenderers: mergedOptions.toolRenderers, toolIcons: mergedOptions.toolIcons, loadingIndicator: mergedOptions.loadingIndicator, showFeedback: mergedOptions.showFeedback, feedbackMap: feedbackMap, onFeedback: handleFeedback, handedOffSubThreadId: chat.handedOffSubThreadId || undefined, onHandoffCompleted: chat.onHandoffCompleted, handoffWidgetRenderer: mergedOptions.handoffWidgetRenderer, toolGroups: mergedOptions.toolGroups, userMessageRenderer: mergedOptions.userMessageRenderer, assistantMessageRenderer: mergedOptions.assistantMessageRenderer, apiKey: resolvedApiKey, baseUrl: resolvedBaseUrl, pollingInterval: pollingInterval, pendingInlineWidgets: inlineWidgets, onSubmitWidget: chat.submitWidgetResponse, onCancelWidget: chat.cancelWidgetCall, recalledMemories: mergedOptions.showRecalledMemories
|
|
726
728
|
? chat.recalledMemories
|
|
727
|
-
: undefined, recalledMemoriesRenderer: mergedOptions.recalledMemoriesRenderer }), mergedOptions.customPromptBox ? (jsxRuntime.jsxs("div", { className: "devic-input-area", children: [limitBannerNode, usageBarNode, integrationsHintNode, queueNoticeNode, mergedOptions.customPromptBox({
|
|
729
|
+
: undefined, recalledMemoriesRenderer: mergedOptions.recalledMemoriesRenderer, compactions: mergedOptions.showCompaction ? chat.compactions : undefined, compaction: mergedOptions.showCompaction ? chat.compaction : undefined, compactionRenderer: mergedOptions.compactionRenderer }), mergedOptions.customPromptBox ? (jsxRuntime.jsxs("div", { className: "devic-input-area", children: [limitBannerNode, usageBarNode, integrationsHintNode, queueNoticeNode, mergedOptions.customPromptBox({
|
|
728
730
|
sendMessage: handleSend,
|
|
729
731
|
transcribeAudio,
|
|
730
732
|
stop: chat.stopChat,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatDrawer.js","sources":["../../../../../src/components/ChatDrawer/ChatDrawer.tsx"],"sourcesContent":["import React, { useState, useEffect, useCallback, useMemo, useRef, forwardRef, useImperativeHandle } from 'react';\nimport { useDevicChat } from '../../hooks/useDevicChat';\nimport { useOptionalDevicContext } from '../../provider';\nimport { DevicApiClient } from '../../api/client';\nimport { useAssistantInfo } from '../../api/assistantInfo';\nimport { ChatMessages } from './ChatMessages';\nimport { ChatInput } from './ChatInput';\nimport { ConversationSelector } from './ConversationSelector';\nimport { ChatDrawerErrorBoundary } from './ErrorBoundary';\nimport { UsageBar } from './UsageBar';\nimport { LimitBanner } from './LimitBanner';\nimport { QueueNotice } from './QueueNotice';\nimport { CoreMemoryModal, DEFAULT_CORE_MEMORY_LABELS } from '../CoreMemoryModal';\nimport {\n IntegrationsHint,\n IntegrationsLauncher,\n IntegrationsModal,\n IntegrationsToggle,\n useIntegrations,\n useTenantMcp,\n integrationChoiceKey,\n readIntegrationChoice,\n writeIntegrationChoice,\n pruneIntegrationChoice,\n} from '../IntegrationsModal';\nimport { isDarkTheme } from '../theme';\nimport type { DevicTheme } from '../theme';\nimport type { ChatDrawerProps, ChatDrawerOptions, ChatDrawerHandle } from './ChatDrawer.types';\nimport type { QueueDisposition } from '../../api/types';\nimport './styles.css';\nimport { avatarUri } from '../../utils/avatar';\n\nconst DEFAULT_OPTIONS: Required<ChatDrawerOptions> = {\n position: 'right',\n width: '100%',\n defaultOpen: false,\n color: '#1890ff',\n welcomeMessage: '',\n suggestedMessages: [],\n enableFileUploads: false,\n allowedFileTypes: { images: true, documents: true },\n maxFileSize: 10 * 1024 * 1024,\n enableLongTextPaste: false,\n longTextPasteThreshold: 2000,\n enableSpeechToText: false,\n speechLanguage: undefined as any,\n speechAutoStop: true,\n speechAutoStopCountdownMs: 1000,\n speechAutoStopSilenceMs: 1000,\n speechAutoStopSilenceRatio: 0.1,\n speechAutoStopSilenceLevel: 0.02,\n speechAutoStopSpeechLevel: 0.12,\n speechHandoff: false,\n speechHandoffSendDelayMs: 1000,\n speechHandoffHoldMs: 3000,\n inputPlaceholder: 'Type a message...',\n title: 'Chat',\n showAvatar: false,\n avatarUrl: undefined as any,\n showToolTimeline: true,\n zIndex: 1000,\n borderRadius: 0,\n resizable: false,\n minWidth: 300,\n maxWidth: 800,\n style: {},\n fontFamily: undefined as any,\n backgroundColor: undefined as any,\n textColor: undefined as any,\n secondaryBackgroundColor: undefined as any,\n borderColor: undefined as any,\n userBubbleColor: undefined as any,\n userBubbleTextColor: undefined as any,\n assistantBubbleColor: undefined as any,\n assistantBubbleTextColor: undefined as any,\n sendButtonColor: undefined as any,\n loadingIndicator: undefined as any,\n sendButtonContent: undefined as any,\n toolRenderers: undefined as any,\n toolIcons: undefined as any,\n showFeedback: true,\n handoffWidgetRenderer: undefined as any,\n toolGroups: undefined as any,\n stopButtonContent: undefined as any,\n debug: false,\n persistConversation: false,\n customPromptBox: undefined as any,\n userMessageRenderer: undefined as any,\n assistantMessageRenderer: undefined as any,\n conversationPreview: 'date',\n showUsageBar: false,\n usageBarMetric: undefined as any,\n usageBarDisplay: undefined as any,\n customUsageBar: undefined as any,\n hideLimitBanner: false,\n limitBannerRenderer: undefined as any,\n hideQueueNotice: false,\n queueNoticeRenderer: undefined as any,\n // Unset on purpose: the assistant's own setting decides.\n messageQueue: undefined as any,\n showRecalledMemories: true,\n recalledMemoriesRenderer: undefined as any,\n showCoreMemoryButton: false,\n coreMemoryLabels: undefined as any,\n showIntegrationsButton: true,\n integrationsLabel: 'Connected apps',\n maxIntegrationLogos: 6,\n showIntegrationsHint: true,\n // Left unset so the strip can say \"Connect your apps\" or \"Explore connected\n // apps\" depending on what the end user has actually done.\n integrationsHintLabel: undefined as any,\n showIntegrationsToggle: true,\n integrationsToggleLabel: 'Apps in this chat',\n};\n\n/**\n * Chat drawer component for Devic assistants\n *\n * @example\n * ```tsx\n * <ChatDrawer\n * ref={drawerRef}\n * assistantId=\"my-assistant\"\n * options={{\n * position: 'right',\n * width: 400,\n * welcomeMessage: 'Hello! How can I help you?',\n * suggestedMessages: ['Help me with...', 'Tell me about...'],\n * }}\n * modelInterfaceTools={[\n * {\n * toolName: 'get_user_location',\n * schema: { ... },\n * callback: async () => ({ lat: 40.7, lng: -74.0 })\n * }\n * ]}\n * onMessageReceived={(msg) => console.log('Received:', msg)}\n * />\n * ```\n */\nexport const ChatDrawer = forwardRef<ChatDrawerHandle, ChatDrawerProps>(\n function ChatDrawer(props, ref) {\n return (\n <ChatDrawerErrorBoundary>\n <ChatDrawerInner {...props} forwardedRef={ref} />\n </ChatDrawerErrorBoundary>\n );\n }\n);\n\ninterface ChatDrawerInnerProps extends ChatDrawerProps {\n forwardedRef?: React.Ref<ChatDrawerHandle>;\n}\n\nfunction ChatDrawerInner({\n assistantId,\n chatUid: initialChatUid,\n options = {},\n enabledTools,\n modelInterfaceTools,\n tenantId,\n tenantMetadata,\n subtenantId,\n subtenantMetadata,\n tags,\n apiKey,\n baseUrl,\n pollingInterval,\n onMessageSent,\n onMessageReceived,\n onToolCall,\n onError,\n onChatCreated,\n onFileUpload,\n onOpen,\n onClose,\n isOpen: controlledIsOpen,\n className,\n mode = 'drawer',\n onConversationChange,\n forwardedRef,\n}: ChatDrawerInnerProps): JSX.Element {\n // Merge options with defaults\n const mergedOptions = useMemo(\n () => ({ ...DEFAULT_OPTIONS, ...options }),\n [options]\n );\n\n // localStorage key for persisting selected conversation\n const storageKey = mergedOptions.persistConversation\n ? `devic-ui-chatUid-${assistantId}`\n : null;\n\n // Resolve initial chatUid: prop takes priority, then localStorage\n const resolvedInitialChatUid = useMemo(() => {\n if (initialChatUid) return initialChatUid;\n if (storageKey) {\n try { return localStorage.getItem(storageKey) || undefined; } catch { return undefined; }\n }\n return undefined;\n }, [initialChatUid, storageKey]);\n\n // Drawer open state (can be controlled or uncontrolled; inline mode is always open)\n const [internalIsOpen, setInternalIsOpen] = useState(mergedOptions.defaultOpen);\n const isInline = mode === 'inline';\n const isOpen = isInline ? true : (controlledIsOpen ?? internalIsOpen);\n\n // Wrap onChatCreated to persist chatUid in localStorage\n const handleChatCreated = useCallback(\n (chatUid: string) => {\n if (storageKey) {\n try { localStorage.setItem(storageKey, chatUid); } catch {}\n }\n onChatCreated?.(chatUid);\n },\n [storageKey, onChatCreated]\n );\n\n /**\n * What the end user switched off: connected apps by slug, and their own MCP\n * servers by the `toggleId` the API hands out.\n *\n * Remembered in this browser (see `integrationChoice`) rather than only for\n * the life of the drawer — a reload used to forget it, which for someone who\n * keeps an app switched off on purpose reads as the switch not working. The\n * server still keeps nothing beyond the turn it was sent for; what is stored\n * is a preference of whoever is at this keyboard.\n *\n * The badge on the plug is what keeps that honest: a remembered choice is\n * visible at a glance rather than being an unexplained silence from an app.\n */\n const [disabledIntegrations, setDisabledIntegrations] = useState<string[]>([]);\n\n // Use chat hook\n const chat = useDevicChat({\n assistantId,\n chatUid: resolvedInitialChatUid,\n apiKey,\n baseUrl,\n tenantId,\n tenantMetadata,\n subtenantId,\n subtenantMetadata,\n tags,\n enabledTools,\n disabledIntegrations,\n modelInterfaceTools,\n pollingInterval,\n onMessageSent,\n onMessageReceived,\n onToolCall,\n onError,\n onChatCreated: handleChatCreated,\n onFileUpload,\n messageQueue: mergedOptions.messageQueue,\n debug: mergedOptions.debug,\n });\n\n // Fetch assistant avatar when showAvatar is enabled\n const context = useOptionalDevicContext();\n const resolvedApiKey = apiKey || context?.apiKey;\n // The session source, when the page authenticates with one. Every client\n // built below gets it, or a page without an API key would have nothing to\n // authenticate with.\n const resolvedTenantSession = context?.getTenantSession;\n const onSessionExpired = context?.onSessionExpired;\n const resolvedBaseUrl = baseUrl || context?.baseUrl || 'https://api.devic.ai';\n const [coreMemoryOpen, setCoreMemoryOpen] = useState(false);\n const [integrationsOpen, setIntegrationsOpen] = useState(false);\n\n const infoClient = useMemo(\n () =>\n resolvedApiKey || resolvedTenantSession\n ? new DevicApiClient({\n apiKey: resolvedApiKey,\n baseUrl: resolvedBaseUrl,\n getTenantSession: resolvedTenantSession,\n onSessionExpired,\n })\n : null,\n [resolvedApiKey, resolvedTenantSession, resolvedBaseUrl]\n );\n\n // Asked for only when something on screen depends on it, and then at most\n // once per assistant however many times this drawer is mounted — a host that\n // remounts it to start a fresh conversation used to pay for the answer again\n // every time.\n const assistantInfo = useAssistantInfo({\n assistantId,\n client: infoClient,\n baseUrl: resolvedBaseUrl,\n credential: resolvedApiKey || 'session',\n enabled:\n (!!mergedOptions.showAvatar && !mergedOptions.avatarUrl) ||\n (mergedOptions.showIntegrationsButton !== false && isOpen),\n });\n // The host's own image wins: an assistant carries one image for everybody, so\n // this is the only place a per-account face can come from. Failing that, an\n // assistant with no uploaded image still gets a face, generated from its\n // identifier — the same one the console shows for it. Drawn from `assistantId`\n // rather than from the fetched assistant so the header is not empty while the\n // lookup is in flight; the two agree, since that is what was asked for.\n const avatarUrl = mergedOptions.showAvatar\n ? (mergedOptions.avatarUrl ??\n assistantInfo.assistant?.imgUrl ??\n avatarUri(\n assistantInfo.assistant?.identifier || assistantId,\n assistantInfo.assistant?.avatarStyle\n ))\n : null;\n\n /**\n * Whether to ask which apps this assistant offers.\n *\n * The listing is worth a request only when there is something to list, and\n * most assistants offer nothing — for those, the call existed purely to be\n * refused, once per page load. The assistant now says so itself, so a plain\n * `false` settles it without asking.\n *\n * Anything else asks, exactly as before: a field that is absent means the API\n * is older than it, not that the answer is no, and a failed lookup means we\n * could not find out. Hiding the button on either would lose the feature for\n * a deployment that has it, which is far worse than one spare request.\n *\n * Where there are apps to show, this puts the two requests in sequence rather\n * than at once, so the listing lands later than it used to. The header holds\n * its place in the meantime — see `pendingIntegrations`.\n */\n const mayOfferIntegrations =\n assistantInfo.settled &&\n assistantInfo.assistant?.tenantIntegrations?.enabled !== false;\n\n // The apps this assistant offers its tenants. Loaded once, here, because the\n // header control cannot decide whether to exist without it — and lent to the\n // modal so opening it does not ask for the same listing again. Nothing is\n // fetched until the drawer is opened for the first time.\n const integrationsState = useIntegrations({\n assistantId,\n tenantId,\n subtenantId,\n apiKey: resolvedApiKey,\n baseUrl: resolvedBaseUrl,\n enabled:\n mergedOptions.showIntegrationsButton !== false &&\n isOpen &&\n mayOfferIntegrations,\n });\n\n /**\n * Whether this assistant offers MCP servers of the tenant's own.\n *\n * Read exactly like `mayOfferIntegrations`: absence means \"cannot tell\", so\n * the listing is asked for anyway. A deployment older than the field keeps\n * the behaviour it had — one refusal per drawer open — rather than losing the\n * feature.\n */\n const mayOfferMcp =\n assistantInfo.settled &&\n assistantInfo.assistant?.tenantMcpServers?.enabled !== false;\n\n /**\n * The tenant's own MCP servers, loaded here rather than inside the modal.\n *\n * The composer's switch needs them too, and it is not inside the modal — so\n * the listing has to live above both. The modal takes it as a prop and stops\n * asking for its own.\n */\n const mcpState = useTenantMcp({\n assistantId,\n tenantId,\n subtenantId,\n apiKey: resolvedApiKey,\n baseUrl: resolvedBaseUrl,\n enabled:\n mergedOptions.showIntegrationsButton !== false && isOpen && mayOfferMcp,\n });\n\n /**\n * Whether the answer to \"is there anything to show here\" is still on its way.\n *\n * Two requests decide it — what the assistant offers, and then what this\n * tenant has connected — and until both have answered the control cannot\n * know whether to exist. Without this the header simply had a gap and then a\n * button, which reads as the page changing its mind.\n */\n const integrationsDeciding =\n mergedOptions.showIntegrationsButton !== false &&\n isOpen &&\n (!assistantInfo.settled ||\n (mayOfferIntegrations && !integrationsState.settled) ||\n (mayOfferMcp && !mcpState.settled));\n\n /**\n * Placeholder chips to hold while the listing is in flight.\n *\n * Only when the assistant has said outright that it offers apps, and how\n * many: on a maybe there would be nothing to hold the place of half the time,\n * and a control that appears and then vanishes is worse than one that arrives\n * late. So this stays at zero for an API that does not say, which is also the\n * behaviour every version until now had.\n */\n const pendingIntegrations =\n assistantInfo.assistant?.tenantIntegrations?.enabled === true &&\n !integrationsState.settled\n ? (assistantInfo.assistant.tenantIntegrations.count ?? 0)\n : 0;\n\n // Tenant/subtenant resolution mirrors useDevicChat (prop overrides provider).\n const resolvedTenantId = tenantId || context?.tenantId;\n const resolvedSubtenantId = subtenantId || context?.subtenantId;\n\n // ── Remembering which apps and servers are switched off ────────────────\n\n const choiceKey = integrationChoiceKey(\n assistantId,\n resolvedTenantId,\n resolvedSubtenantId\n );\n\n // Loaded per key, so switching tenant loads that tenant's choice rather than\n // carrying the previous one over.\n const loadedChoiceRef = useRef<string | null>(null);\n useEffect(() => {\n if (loadedChoiceRef.current === choiceKey) return;\n loadedChoiceRef.current = choiceKey;\n setDisabledIntegrations(readIntegrationChoice(choiceKey));\n }, [choiceKey]);\n\n useEffect(() => {\n // Only once this key's stored value has been read, or the empty initial\n // state would erase it before it was ever loaded.\n if (loadedChoiceRef.current !== choiceKey) return;\n writeIntegrationChoice(choiceKey, disabledIntegrations);\n }, [choiceKey, disabledIntegrations]);\n\n /**\n * Forgets what is no longer on offer, once the listings can say so.\n *\n * Every clause of this is load-bearing. `mayOffer*` is false BEFORE the\n * assistant has answered as well as when the answer is no, so without the\n * `assistantInfo.settled` guard the prune runs on the first render against\n * two empty listings and erases the very thing that was just loaded — which\n * is exactly the reload-forgets-it bug this was meant to fix. A definite\n * \"this assistant offers none\" is an answer; an unsettled listing is not.\n *\n * With the drawer never opened, neither listing is ever fetched, so nothing\n * is pruned and the stored choice survives untouched.\n */\n const appsKnown =\n assistantInfo.settled && (!mayOfferIntegrations || integrationsState.settled);\n const mcpKnown = assistantInfo.settled && (!mayOfferMcp || mcpState.settled);\n useEffect(() => {\n if (!appsKnown || !mcpKnown) return;\n const live = [\n ...integrationsState.integrations\n .filter((i) => i.connected)\n .map((i) => i.app),\n ...mcpState.servers\n .filter((s) => s.connection?.status === 'active' && s.connection.toggleId)\n .map((s) => s.connection!.toggleId as string),\n ];\n setDisabledIntegrations((prev) => pruneIntegrationChoice(prev, live));\n }, [appsKnown, mcpKnown, integrationsState.integrations, mcpState.servers]);\n\n // Usage bar (above the input) — only when enabled and a tenant is known.\n // Refetches after each turn via the message count as refresh key.\n const usageBarNode =\n (mergedOptions.showUsageBar ||\n typeof mergedOptions.customUsageBar === 'function') &&\n resolvedTenantId ? (\n <UsageBar\n apiKey={resolvedApiKey}\n baseUrl={resolvedBaseUrl}\n tenantId={resolvedTenantId}\n subtenantId={resolvedSubtenantId}\n mode={mergedOptions.showUsageBar === 'onDemand' ? 'onDemand' : 'always'}\n metric={mergedOptions.usageBarMetric}\n display={mergedOptions.usageBarDisplay}\n customUsageBar={mergedOptions.customUsageBar}\n color={mergedOptions.color}\n refreshKey={chat.messages.length}\n debug={mergedOptions.debug}\n />\n ) : null;\n\n // Default usage-limit banner (above the input) — opt-out via hideLimitBanner,\n // override via limitBannerRenderer.\n const limitBannerNode =\n chat.limitExceeded && !mergedOptions.hideLimitBanner\n ? mergedOptions.limitBannerRenderer\n ? mergedOptions.limitBannerRenderer(chat.limitExceeded)\n : <LimitBanner limit={chat.limitExceeded} />\n : null;\n\n // Speech-to-text transcription, exposed to custom prompt boxes so a developer\n // can transcribe audio (binary or URL) and attach the resulting transcriptId.\n const transcribeAudio = useCallback(\n (\n audio: Blob | string,\n transcribeOptions?: {\n language?: string;\n messageUid?: string;\n chatUid?: string;\n tenantId?: string;\n },\n ) => {\n if (!resolvedApiKey && !resolvedTenantSession) {\n return Promise.reject(\n new Error('No credentials configured. Cannot transcribe audio.'),\n );\n }\n const client = new DevicApiClient({ apiKey: resolvedApiKey, baseUrl: resolvedBaseUrl, getTenantSession: resolvedTenantSession, onSessionExpired });\n return client.transcribeAudio(audio, {\n language: transcribeOptions?.language ?? mergedOptions.speechLanguage,\n messageUid: transcribeOptions?.messageUid,\n chatUid: transcribeOptions?.chatUid,\n tenantId: transcribeOptions?.tenantId ?? tenantId,\n });\n },\n [resolvedApiKey, resolvedTenantSession, resolvedBaseUrl, mergedOptions.speechLanguage, tenantId],\n );\n\n // Handle open/close\n const handleOpen = useCallback(() => {\n setInternalIsOpen(true);\n onOpen?.();\n }, [onOpen]);\n\n const handleClose = useCallback(() => {\n setInternalIsOpen(false);\n onClose?.();\n }, [onClose]);\n\n const handleToggle = useCallback(() => {\n setInternalIsOpen((prev) => !prev);\n }, []);\n\n // Expose handle for programmatic control\n useImperativeHandle(forwardedRef, () => ({\n open: handleOpen,\n close: handleClose,\n toggle: handleToggle,\n setChatUid: (chatUid: string) => {\n chat.loadChat(chatUid);\n },\n sendMessage: (message: string) => {\n chat.sendMessage(message);\n },\n }), [handleOpen, handleClose, handleToggle, chat]);\n\n // Register this drawer in the DevicProvider so AIElementWrapper can open it\n useEffect(() => {\n if (!context?.registerDrawer) return;\n const unregister = context.registerDrawer({\n open: handleOpen,\n close: handleClose,\n toggle: handleToggle,\n sendMessage: (message: string) => chat.sendMessage(message),\n });\n return unregister;\n }, [context, handleOpen, handleClose, handleToggle, chat]);\n\n // Partition pending widget calls by render mode\n const { inlineWidgets, inputWidget } = useMemo(() => {\n const inline: typeof chat.pendingWidgetCalls = [];\n let input: typeof chat.pendingWidgetCalls[number] | null = null;\n for (const wc of chat.pendingWidgetCalls) {\n if (wc.widget.render === 'input' && !input) {\n input = wc;\n } else {\n inline.push(wc);\n }\n }\n return { inlineWidgets: inline, inputWidget: input };\n }, [chat.pendingWidgetCalls]);\n\n // Active references from DevicProvider (created by AIElementWrapper)\n const references = context?.references ?? [];\n const removeReference = useCallback(\n (id: string) => {\n context?.removeReference(id);\n },\n [context]\n );\n const clearReferences = useCallback(() => {\n context?.clearReferences();\n }, [context]);\n\n // Handle send message — prefix references and clear them after sending\n /**\n * What the last accepted message was told about when it gets picked up. Only\n * the wording of the notice depends on it.\n */\n const [queueDisposition, setQueueDisposition] = useState<\n QueueDisposition | undefined\n >();\n /**\n * What became of a message that did not simply join the queue: it was turned\n * down, or a stop threw it away. Said out loud, because in both cases the\n * user's text has just moved back into the box on its own.\n */\n const [queueAlert, setQueueAlert] = useState<string | null>(null);\n\n const handleSend = useCallback(\n async (\n message: string,\n files?: File[],\n meta?: { transcriptId?: string; tags?: string[] }\n ) => {\n let finalMessage = message;\n if (references.length > 0) {\n const labels = references.map((r) => `\"${r.label}\"`).join(', ');\n finalMessage = `Elemento referenciado: ${labels}\\n\\n${message}`;\n }\n setQueueAlert(null);\n const result = await chat.sendMessage(finalMessage, {\n files,\n transcriptId: meta?.transcriptId,\n tags: meta?.tags,\n });\n\n if ('rejected' in result) {\n // The references belong to the message that was not sent, so they stay.\n if (result.reason !== 'error') {\n // An ordinary error already reaches the host through `onError`; these\n // two do not, and the only sign of them would otherwise be the text\n // reappearing in the box with no explanation.\n setQueueAlert(\n result.reason === 'queue_full'\n ? `${result.message} Your message is back in the box.`\n : 'The assistant is not taking messages while it works. Your message is back in the box.'\n );\n }\n return result;\n }\n\n setQueueDisposition('queued' in result && result.queued ? result.willProcess : undefined);\n if (references.length > 0) clearReferences();\n return result;\n },\n [chat, references, clearReferences]\n );\n\n /**\n * Whether a message may be written while the assistant is working.\n *\n * Being busy is not the only reason the box closes, and the other two are not\n * about waiting: an inline widget is the assistant waiting on *this* user, and\n * a usage limit is a refusal the queue cannot soften.\n */\n const canQueue =\n chat.queueEnabled && inlineWidgets.length === 0 && !chat.limitExceeded;\n\n const handleStopChat = useCallback(async () => {\n const result = await chat.stopChat();\n setQueueDisposition(undefined);\n setQueueAlert(\n result.discarded\n ? `${result.discarded === 1 ? 'A queued message was' : `${result.discarded} queued messages were`} not sent — the text is back in the box.`\n : null\n );\n return result;\n }, [chat]);\n\n /**\n * Shown while there is something to explain: the user is writing into a run\n * that has not finished, or messages are already waiting. With nothing typed\n * and nothing queued there is nothing to say.\n */\n const queueNoticeNode =\n !mergedOptions.hideQueueNotice &&\n // `queuedCount` on its own matters: an assistant with an input delay queues\n // what is written into an *idle* conversation whether or not it takes\n // messages while busy, so there can be something waiting with the queue\n // switched off.\n (queueAlert || chat.queuedCount > 0 || (canQueue && chat.isLoading))\n ? mergedOptions.queueNoticeRenderer\n ? mergedOptions.queueNoticeRenderer({\n queuedCount: chat.queuedCount,\n willProcess: queueDisposition,\n alert: queueAlert ?? undefined,\n })\n : (\n <QueueNotice\n queuedCount={chat.queuedCount}\n willProcess={queueDisposition}\n alert={queueAlert ?? undefined}\n />\n )\n : null;\n\n // Handle conversation selection\n const handleConversationSelect = useCallback(\n (chatUid: string) => {\n chat.loadChat(chatUid);\n onConversationChange?.(chatUid);\n if (storageKey) {\n try { localStorage.setItem(storageKey, chatUid); } catch {}\n }\n },\n [chat, onConversationChange, storageKey]\n );\n\n const handleNewChat = useCallback(() => {\n chat.clearChat();\n if (storageKey) {\n try { localStorage.removeItem(storageKey); } catch {}\n }\n }, [chat, storageKey]);\n\n // Handle suggested message click\n const handleSuggestedClick = useCallback(\n (message: string) => {\n chat.sendMessage(message);\n },\n [chat]\n );\n\n // Feedback state\n const [feedbackMap, setFeedbackMap] = useState<Map<string, 'positive' | 'negative'>>(new Map());\n const feedbackClientRef = useRef<DevicApiClient | null>(null);\n\n // Initialize feedback client\n useEffect(() => {\n if ((resolvedApiKey || resolvedTenantSession) && !feedbackClientRef.current) {\n feedbackClientRef.current = new DevicApiClient({\n apiKey: resolvedApiKey,\n baseUrl: resolvedBaseUrl,\n getTenantSession: resolvedTenantSession,\n onSessionExpired,\n });\n }\n }, [resolvedApiKey, resolvedTenantSession, resolvedBaseUrl]);\n\n // Load existing feedback when chat changes\n useEffect(() => {\n if (!chat.chatUid || !feedbackClientRef.current || !mergedOptions.showFeedback) return;\n\n feedbackClientRef.current.getChatFeedback(assistantId, chat.chatUid)\n .then((entries) => {\n const newMap = new Map<string, 'positive' | 'negative'>();\n for (const entry of entries) {\n if (entry.feedback !== undefined) {\n newMap.set(entry.requestId, entry.feedback ? 'positive' : 'negative');\n }\n }\n setFeedbackMap(newMap);\n })\n .catch(() => {\n // Silently ignore feedback loading errors\n });\n }, [chat.chatUid, assistantId, mergedOptions.showFeedback]);\n\n // Handle feedback submission\n const handleFeedback = useCallback(\n async (messageId: string, positive: boolean, comment?: string) => {\n if (!chat.chatUid || !feedbackClientRef.current) return;\n\n try {\n await feedbackClientRef.current.submitChatFeedback(assistantId, chat.chatUid, {\n messageId,\n feedback: positive,\n feedbackComment: comment,\n });\n\n setFeedbackMap((prev) => {\n const newMap = new Map(prev);\n newMap.set(messageId, positive ? 'positive' : 'negative');\n return newMap;\n });\n } catch (err) {\n console.error('Failed to submit feedback:', err);\n throw err;\n }\n },\n [chat.chatUid, assistantId]\n );\n\n // Apply CSS variables for theming on the drawer element itself\n // (must target the component root so they override the defaults defined on .devic-chat-drawer)\n const drawerRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const el = drawerRef.current;\n if (!el) return;\n const vars: [string, string | undefined][] = [\n ['--devic-primary', mergedOptions.color !== DEFAULT_OPTIONS.color ? mergedOptions.color : undefined],\n ['--devic-font-family', mergedOptions.fontFamily],\n ['--devic-bg', mergedOptions.backgroundColor],\n ['--devic-text', mergedOptions.textColor],\n ['--devic-bg-secondary', mergedOptions.secondaryBackgroundColor],\n ['--devic-border', mergedOptions.borderColor],\n ['--devic-user-bubble', mergedOptions.userBubbleColor],\n ['--devic-user-bubble-text', mergedOptions.userBubbleTextColor],\n ['--devic-assistant-bubble', mergedOptions.assistantBubbleColor],\n ['--devic-assistant-bubble-text', mergedOptions.assistantBubbleTextColor],\n ['--devic-send-btn', mergedOptions.sendButtonColor],\n ];\n for (const [name, value] of vars) {\n if (value) {\n el.style.setProperty(name, value);\n } else {\n el.style.removeProperty(name);\n }\n }\n }, [mergedOptions.color, mergedOptions.fontFamily, mergedOptions.backgroundColor, mergedOptions.textColor, mergedOptions.secondaryBackgroundColor, mergedOptions.borderColor, mergedOptions.userBubbleColor, mergedOptions.userBubbleTextColor, mergedOptions.assistantBubbleColor, mergedOptions.assistantBubbleTextColor, mergedOptions.sendButtonColor]);\n\n // The same values, handed to the dialogs this drawer opens. They render\n // through a portal into document.body, so the variables set above — which\n // live on the drawer element — never reach them.\n // The brain button says what the modal it opens is called.\n const coreMemoryTitle =\n mergedOptions.coreMemoryLabels?.title ?? DEFAULT_CORE_MEMORY_LABELS.title;\n\n const modalTheme: DevicTheme = useMemo(\n () => ({\n color:\n mergedOptions.color !== DEFAULT_OPTIONS.color\n ? mergedOptions.color\n : undefined,\n fontFamily: mergedOptions.fontFamily,\n backgroundColor: mergedOptions.backgroundColor,\n textColor: mergedOptions.textColor,\n secondaryBackgroundColor: mergedOptions.secondaryBackgroundColor,\n borderColor: mergedOptions.borderColor,\n }),\n [\n mergedOptions.color,\n mergedOptions.fontFamily,\n mergedOptions.backgroundColor,\n mergedOptions.textColor,\n mergedOptions.secondaryBackgroundColor,\n mergedOptions.borderColor,\n ]\n );\n\n // The strip above the composer. Dismissed per end user, because the whole\n // point of remembering a dismissal is that the same person is not told twice.\n const integrationsHintNode =\n mergedOptions.showIntegrationsButton !== false &&\n mergedOptions.showIntegrationsHint !== false ? (\n <IntegrationsHint\n state={integrationsState}\n onOpen={() => setIntegrationsOpen(true)}\n label={mergedOptions.integrationsHintLabel}\n maxLogos={mergedOptions.maxIntegrationLogos}\n storageKey={`${assistantId}:${resolvedTenantId ?? ''}:${resolvedSubtenantId ?? ''}`}\n dark={isDarkTheme(modalTheme)}\n />\n ) : null;\n\n // The per-message switch in the composer row. Shown only where there is\n // something to switch — the control returns null with nothing connected —\n // and hidden outright by `showIntegrationsToggle: false`.\n const integrationsToggleNode =\n mergedOptions.showIntegrationsButton !== false &&\n mergedOptions.showIntegrationsToggle !== false ? (\n <IntegrationsToggle\n state={integrationsState}\n mcp={mcpState}\n disabled={disabledIntegrations}\n onChange={setDisabledIntegrations}\n onManage={() => setIntegrationsOpen(true)}\n label={mergedOptions.integrationsToggleLabel}\n dark={isDarkTheme(modalTheme)}\n busy={chat.isLoading}\n loading={integrationsDeciding}\n />\n ) : null;\n\n // Resizable drawer\n const [resizedWidth, setResizedWidth] = useState<number | null>(null);\n\n const handleResizeStart = useCallback(\n (e: React.MouseEvent) => {\n e.preventDefault();\n const startX = e.clientX;\n const startWidth = drawerRef.current?.offsetWidth ?? 0;\n const isLeft = mergedOptions.position === 'left';\n\n const onMove = (ev: MouseEvent) => {\n const delta = ev.clientX - startX;\n const newWidth = startWidth + (isLeft ? delta : -delta);\n const clamped = Math.min(\n mergedOptions.maxWidth,\n Math.max(mergedOptions.minWidth, newWidth)\n );\n setResizedWidth(clamped);\n };\n\n const onUp = () => {\n document.removeEventListener('mousemove', onMove);\n document.removeEventListener('mouseup', onUp);\n };\n\n document.addEventListener('mousemove', onMove);\n document.addEventListener('mouseup', onUp);\n },\n [mergedOptions.position, mergedOptions.minWidth, mergedOptions.maxWidth]\n );\n\n // Build style object\n const baseWidth = resizedWidth\n ? `${resizedWidth}px`\n : typeof mergedOptions.width === 'number'\n ? `${mergedOptions.width}px`\n : mergedOptions.width;\n\n const drawerStyle = useMemo(\n () => ({\n width: baseWidth,\n zIndex: mergedOptions.zIndex,\n borderRadius: typeof mergedOptions.borderRadius === 'number'\n ? `${mergedOptions.borderRadius}px`\n : mergedOptions.borderRadius,\n ...mergedOptions.style,\n }),\n [baseWidth, mergedOptions.zIndex, mergedOptions.borderRadius, mergedOptions.style]\n );\n\n const overlayStyle = useMemo(\n () => ({\n zIndex: mergedOptions.zIndex - 1,\n }),\n [mergedOptions.zIndex]\n );\n\n const triggerStyle = useMemo(\n () => ({\n zIndex: mergedOptions.zIndex - 1,\n [mergedOptions.position]: 20,\n bottom: 20,\n }),\n [mergedOptions.zIndex, mergedOptions.position]\n );\n\n return (\n <>\n {/* Overlay (drawer mode only) */}\n {!isInline && (\n <div\n className=\"devic-drawer-overlay\"\n data-open={isOpen}\n style={overlayStyle}\n onClick={handleClose}\n />\n )}\n\n {/* Drawer */}\n <div\n ref={drawerRef}\n className={`devic-chat-drawer ${className || ''}`}\n data-position={mergedOptions.position}\n data-open={isOpen}\n data-mode={mode}\n style={drawerStyle}\n >\n {/* Resize handle */}\n {mergedOptions.resizable && (\n <div\n className=\"devic-resize-handle\"\n data-position={mergedOptions.position}\n onMouseDown={handleResizeStart}\n />\n )}\n\n {/* Header */}\n <div className=\"devic-drawer-header\">\n {avatarUrl && (\n <img\n className=\"devic-drawer-avatar\"\n src={avatarUrl}\n alt=\"\"\n aria-hidden=\"true\"\n />\n )}\n <h2 className=\"devic-drawer-title\">{mergedOptions.title}</h2>\n <ConversationSelector\n assistantId={assistantId}\n currentChatUid={chat.chatUid}\n onSelect={handleConversationSelect}\n onNewChat={handleNewChat}\n apiKey={apiKey}\n baseUrl={baseUrl}\n tenantId={tenantId}\n subtenantId={subtenantId}\n conversationPreview={mergedOptions.conversationPreview}\n />\n <div className=\"devic-drawer-header-actions\">\n {mergedOptions.showIntegrationsButton !== false && (\n <IntegrationsLauncher\n state={integrationsState}\n mcp={mcpState}\n onClick={() => setIntegrationsOpen(true)}\n label={mergedOptions.integrationsLabel}\n maxLogos={mergedOptions.maxIntegrationLogos}\n dark={isDarkTheme(modalTheme)}\n placeholders={pendingIntegrations}\n loading={integrationsDeciding}\n />\n )}\n {mergedOptions.showCoreMemoryButton && (\n <button\n className=\"devic-new-chat-btn\"\n onClick={() => setCoreMemoryOpen(true)}\n type=\"button\"\n aria-label={coreMemoryTitle}\n title={coreMemoryTitle}\n >\n <BrainIcon />\n </button>\n )}\n <button\n className=\"devic-new-chat-btn\"\n onClick={handleNewChat}\n type=\"button\"\n aria-label=\"New chat\"\n title=\"New chat\"\n >\n <PlusIcon />\n </button>\n {!isInline && (\n <button\n className=\"devic-drawer-close\"\n onClick={handleClose}\n type=\"button\"\n aria-label=\"Close chat\"\n >\n <CloseIcon />\n </button>\n )}\n </div>\n </div>\n\n {/* Error display */}\n {chat.error && (\n <div className=\"devic-error\">\n {chat.error.message}\n </div>\n )}\n\n {/* Messages */}\n <ChatMessages\n messages={chat.messages}\n allMessages={chat.messages}\n isLoading={chat.isLoading}\n welcomeMessage={mergedOptions.welcomeMessage}\n suggestedMessages={mergedOptions.suggestedMessages}\n onSuggestedClick={handleSuggestedClick}\n showToolTimeline={mergedOptions.showToolTimeline}\n toolRenderers={mergedOptions.toolRenderers}\n toolIcons={mergedOptions.toolIcons}\n loadingIndicator={mergedOptions.loadingIndicator}\n showFeedback={mergedOptions.showFeedback}\n feedbackMap={feedbackMap}\n onFeedback={handleFeedback}\n handedOffSubThreadId={chat.handedOffSubThreadId || undefined}\n onHandoffCompleted={chat.onHandoffCompleted}\n handoffWidgetRenderer={mergedOptions.handoffWidgetRenderer}\n toolGroups={mergedOptions.toolGroups}\n userMessageRenderer={mergedOptions.userMessageRenderer}\n assistantMessageRenderer={mergedOptions.assistantMessageRenderer}\n apiKey={resolvedApiKey}\n baseUrl={resolvedBaseUrl}\n pollingInterval={pollingInterval}\n pendingInlineWidgets={inlineWidgets}\n onSubmitWidget={chat.submitWidgetResponse}\n onCancelWidget={chat.cancelWidgetCall}\n recalledMemories={\n mergedOptions.showRecalledMemories\n ? chat.recalledMemories\n : undefined\n }\n recalledMemoriesRenderer={mergedOptions.recalledMemoriesRenderer}\n />\n\n {/* Input */}\n {mergedOptions.customPromptBox ? (\n <div className=\"devic-input-area\">\n {limitBannerNode}\n {usageBarNode}\n {integrationsHintNode}\n {queueNoticeNode}\n {mergedOptions.customPromptBox({\n sendMessage: handleSend,\n transcribeAudio,\n stop: chat.stopChat,\n isLoading: chat.isLoading,\n queueEnabled: canQueue,\n queuedCount: chat.queuedCount,\n newConversation: chat.clearChat,\n references,\n removeReference,\n clearReferences,\n limitExceeded: chat.limitExceeded,\n })}\n </div>\n ) : (\n <ChatInput\n onSend={handleSend}\n disabled={\n // `handedOff` is one of the states the queue covers — the\n // conversation is waiting on a subagent, which in an embedded\n // widget can take minutes — so with queueing on it no longer\n // closes the box. A pending widget and a usage limit still do:\n // one is the assistant waiting on this user, the other a refusal.\n (chat.isLoading && !canQueue) ||\n (chat.handedOff && !canQueue) ||\n inlineWidgets.length > 0 ||\n !!chat.limitExceeded\n }\n placeholder={mergedOptions.inputPlaceholder}\n enableFileUploads={mergedOptions.enableFileUploads}\n allowedFileTypes={mergedOptions.allowedFileTypes}\n maxFileSize={mergedOptions.maxFileSize}\n enableLongTextPaste={mergedOptions.enableLongTextPaste}\n longTextPasteThreshold={mergedOptions.longTextPasteThreshold}\n enableSpeechToText={mergedOptions.enableSpeechToText}\n speechLanguage={mergedOptions.speechLanguage}\n speechTenantId={tenantId}\n speechAutoStop={mergedOptions.speechAutoStop}\n speechAutoStopCountdownMs={mergedOptions.speechAutoStopCountdownMs}\n speechAutoStopSilenceMs={mergedOptions.speechAutoStopSilenceMs}\n speechAutoStopSilenceRatio={mergedOptions.speechAutoStopSilenceRatio}\n speechAutoStopSilenceLevel={mergedOptions.speechAutoStopSilenceLevel}\n speechAutoStopSpeechLevel={mergedOptions.speechAutoStopSpeechLevel}\n speechHandoff={mergedOptions.speechHandoff}\n speechHandoffSendDelayMs={mergedOptions.speechHandoffSendDelayMs}\n speechHandoffHoldMs={mergedOptions.speechHandoffHoldMs}\n apiKey={resolvedApiKey}\n baseUrl={resolvedBaseUrl}\n sendButtonContent={mergedOptions.sendButtonContent}\n disabledMessage={\n chat.handedOff\n ? 'Waiting for subagent to complete'\n : inlineWidgets.length > 0\n ? 'Waiting for tool response'\n : undefined\n }\n isProcessing={chat.isLoading && !chat.handedOff}\n onStop={handleStopChat}\n allowQueueing={canQueue}\n queueNotice={queueNoticeNode}\n stopButtonContent={mergedOptions.stopButtonContent}\n pendingInputWidget={inputWidget}\n onSubmitWidget={chat.submitWidgetResponse}\n onCancelWidget={chat.cancelWidgetCall}\n references={references}\n onRemoveReference={removeReference}\n usageBar={usageBarNode}\n limitBanner={limitBannerNode}\n integrationsHint={integrationsHintNode}\n integrationsToggle={integrationsToggleNode}\n />\n )}\n </div>\n\n {/* Trigger button (drawer mode only, when closed) */}\n {!isInline && !isOpen && (\n <button\n className=\"devic-trigger\"\n onClick={handleOpen}\n style={triggerStyle}\n type=\"button\"\n aria-label=\"Open chat\"\n >\n <ChatIcon />\n </button>\n )}\n\n {/* Core memory modal (opened from the header brain button) */}\n {mergedOptions.showCoreMemoryButton && (\n <CoreMemoryModal\n isOpen={coreMemoryOpen}\n onClose={() => setCoreMemoryOpen(false)}\n assistantId={assistantId}\n tenantId={tenantId}\n subtenantId={subtenantId}\n apiKey={resolvedApiKey}\n baseUrl={resolvedBaseUrl}\n labels={mergedOptions.coreMemoryLabels}\n theme={modalTheme}\n />\n )}\n\n {/* Connected apps modal (opened from the header app stack) */}\n {mergedOptions.showIntegrationsButton !== false && (\n <IntegrationsModal\n isOpen={integrationsOpen}\n onClose={() => setIntegrationsOpen(false)}\n assistantId={assistantId}\n tenantId={tenantId}\n subtenantId={subtenantId}\n apiKey={resolvedApiKey}\n baseUrl={resolvedBaseUrl}\n title={mergedOptions.integrationsLabel}\n theme={modalTheme}\n state={integrationsState}\n mcpState={mcpState}\n />\n )}\n </>\n );\n}\n\n/**\n * Brain icon for the core memory button\n */\nfunction BrainIcon(): JSX.Element {\n return (\n <svg\n width=\"17\"\n height=\"17\"\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=\"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 CloseIcon(): JSX.Element {\n return (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n\n/**\n * Plus icon for new chat button\n */\nfunction PlusIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\" />\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\" />\n </svg>\n );\n}\n\n/**\n * Chat icon for trigger button\n */\nfunction ChatIcon(): JSX.Element {\n return (\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n >\n <path d=\"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z\" />\n </svg>\n );\n}\n"],"names":["forwardRef","_jsx","ChatDrawerErrorBoundary","useMemo","useState","useCallback","useDevicChat","useOptionalDevicContext","DevicApiClient","assistantInfo","useAssistantInfo","avatarUri","useIntegrations","useTenantMcp","integrationChoiceKey","useRef","useEffect","readIntegrationChoice","writeIntegrationChoice","pruneIntegrationChoice","UsageBar","LimitBanner","client","useImperativeHandle","QueueNotice","DEFAULT_CORE_MEMORY_LABELS","IntegrationsHint","isDarkTheme","IntegrationsToggle","_jsxs","_Fragment","ConversationSelector","IntegrationsLauncher","ChatMessages","ChatInput","CoreMemoryModal","IntegrationsModal"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,eAAe,GAAgC;AACnD,IAAA,QAAQ,EAAE,OAAO;AACjB,IAAA,KAAK,EAAE,MAAM;AACb,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,cAAc,EAAE,EAAE;AAClB,IAAA,iBAAiB,EAAE,EAAE;AACrB,IAAA,iBAAiB,EAAE,KAAK;IACxB,gBAAgB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;AACnD,IAAA,WAAW,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;AAC7B,IAAA,mBAAmB,EAAE,KAAK;AAC1B,IAAA,sBAAsB,EAAE,IAAI;AAC5B,IAAA,kBAAkB,EAAE,KAAK;AACzB,IAAA,cAAc,EAAE,SAAgB;AAChC,IAAA,cAAc,EAAE,IAAI;AACpB,IAAA,yBAAyB,EAAE,IAAI;AAC/B,IAAA,uBAAuB,EAAE,IAAI;AAC7B,IAAA,0BAA0B,EAAE,GAAG;AAC/B,IAAA,0BAA0B,EAAE,IAAI;AAChC,IAAA,yBAAyB,EAAE,IAAI;AAC/B,IAAA,aAAa,EAAE,KAAK;AACpB,IAAA,wBAAwB,EAAE,IAAI;AAC9B,IAAA,mBAAmB,EAAE,IAAI;AACzB,IAAA,gBAAgB,EAAE,mBAAmB;AACrC,IAAA,KAAK,EAAE,MAAM;AACb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+
{"version":3,"file":"ChatDrawer.js","sources":["../../../../../src/components/ChatDrawer/ChatDrawer.tsx"],"sourcesContent":["import React, { useState, useEffect, useCallback, useMemo, useRef, forwardRef, useImperativeHandle } from 'react';\nimport { useDevicChat } from '../../hooks/useDevicChat';\nimport { useOptionalDevicContext } from '../../provider';\nimport { DevicApiClient } from '../../api/client';\nimport { useAssistantInfo } from '../../api/assistantInfo';\nimport { ChatMessages } from './ChatMessages';\nimport { ChatInput } from './ChatInput';\nimport { ConversationSelector } from './ConversationSelector';\nimport { ChatDrawerErrorBoundary } from './ErrorBoundary';\nimport { UsageBar } from './UsageBar';\nimport { LimitBanner } from './LimitBanner';\nimport { QueueNotice } from './QueueNotice';\nimport { CoreMemoryModal, DEFAULT_CORE_MEMORY_LABELS } from '../CoreMemoryModal';\nimport {\n IntegrationsHint,\n IntegrationsLauncher,\n IntegrationsModal,\n IntegrationsToggle,\n useIntegrations,\n useTenantMcp,\n integrationChoiceKey,\n readIntegrationChoice,\n writeIntegrationChoice,\n pruneIntegrationChoice,\n} from '../IntegrationsModal';\nimport { isDarkTheme } from '../theme';\nimport type { DevicTheme } from '../theme';\nimport type { ChatDrawerProps, ChatDrawerOptions, ChatDrawerHandle } from './ChatDrawer.types';\nimport type { QueueDisposition } from '../../api/types';\nimport './styles.css';\nimport { avatarUri } from '../../utils/avatar';\n\nconst DEFAULT_OPTIONS: Required<ChatDrawerOptions> = {\n position: 'right',\n width: '100%',\n defaultOpen: false,\n color: '#1890ff',\n welcomeMessage: '',\n suggestedMessages: [],\n enableFileUploads: false,\n allowedFileTypes: { images: true, documents: true },\n maxFileSize: 10 * 1024 * 1024,\n enableLongTextPaste: false,\n longTextPasteThreshold: 2000,\n enableSpeechToText: false,\n speechLanguage: undefined as any,\n speechAutoStop: true,\n speechAutoStopCountdownMs: 1000,\n speechAutoStopSilenceMs: 1000,\n speechAutoStopSilenceRatio: 0.1,\n speechAutoStopSilenceLevel: 0.02,\n speechAutoStopSpeechLevel: 0.12,\n speechHandoff: false,\n speechHandoffSendDelayMs: 1000,\n speechHandoffHoldMs: 3000,\n inputPlaceholder: 'Type a message...',\n title: 'Chat',\n showAvatar: false,\n avatarUrl: undefined as any,\n showToolTimeline: true,\n zIndex: 1000,\n borderRadius: 0,\n resizable: false,\n minWidth: 300,\n maxWidth: 800,\n style: {},\n fontFamily: undefined as any,\n backgroundColor: undefined as any,\n textColor: undefined as any,\n secondaryBackgroundColor: undefined as any,\n borderColor: undefined as any,\n userBubbleColor: undefined as any,\n userBubbleTextColor: undefined as any,\n assistantBubbleColor: undefined as any,\n assistantBubbleTextColor: undefined as any,\n sendButtonColor: undefined as any,\n loadingIndicator: undefined as any,\n sendButtonContent: undefined as any,\n toolRenderers: undefined as any,\n toolIcons: undefined as any,\n showFeedback: true,\n handoffWidgetRenderer: undefined as any,\n toolGroups: undefined as any,\n stopButtonContent: undefined as any,\n debug: false,\n persistConversation: false,\n customPromptBox: undefined as any,\n userMessageRenderer: undefined as any,\n assistantMessageRenderer: undefined as any,\n conversationPreview: 'date',\n showUsageBar: false,\n usageBarMetric: undefined as any,\n usageBarDisplay: undefined as any,\n customUsageBar: undefined as any,\n hideLimitBanner: false,\n limitBannerRenderer: undefined as any,\n hideQueueNotice: false,\n queueNoticeRenderer: undefined as any,\n // Unset on purpose: the assistant's own setting decides.\n messageQueue: undefined as any,\n showRecalledMemories: true,\n recalledMemoriesRenderer: undefined as any,\n showCompaction: true,\n compactionRenderer: undefined as any,\n showCoreMemoryButton: false,\n coreMemoryLabels: undefined as any,\n showIntegrationsButton: true,\n integrationsLabel: 'Connected apps',\n maxIntegrationLogos: 6,\n showIntegrationsHint: true,\n // Left unset so the strip can say \"Connect your apps\" or \"Explore connected\n // apps\" depending on what the end user has actually done.\n integrationsHintLabel: undefined as any,\n showIntegrationsToggle: true,\n integrationsToggleLabel: 'Apps in this chat',\n};\n\n/**\n * Chat drawer component for Devic assistants\n *\n * @example\n * ```tsx\n * <ChatDrawer\n * ref={drawerRef}\n * assistantId=\"my-assistant\"\n * options={{\n * position: 'right',\n * width: 400,\n * welcomeMessage: 'Hello! How can I help you?',\n * suggestedMessages: ['Help me with...', 'Tell me about...'],\n * }}\n * modelInterfaceTools={[\n * {\n * toolName: 'get_user_location',\n * schema: { ... },\n * callback: async () => ({ lat: 40.7, lng: -74.0 })\n * }\n * ]}\n * onMessageReceived={(msg) => console.log('Received:', msg)}\n * />\n * ```\n */\nexport const ChatDrawer = forwardRef<ChatDrawerHandle, ChatDrawerProps>(\n function ChatDrawer(props, ref) {\n return (\n <ChatDrawerErrorBoundary>\n <ChatDrawerInner {...props} forwardedRef={ref} />\n </ChatDrawerErrorBoundary>\n );\n }\n);\n\ninterface ChatDrawerInnerProps extends ChatDrawerProps {\n forwardedRef?: React.Ref<ChatDrawerHandle>;\n}\n\nfunction ChatDrawerInner({\n assistantId,\n chatUid: initialChatUid,\n options = {},\n enabledTools,\n modelInterfaceTools,\n tenantId,\n tenantMetadata,\n subtenantId,\n subtenantMetadata,\n tags,\n apiKey,\n baseUrl,\n pollingInterval,\n onMessageSent,\n onMessageReceived,\n onToolCall,\n onError,\n onChatCreated,\n onFileUpload,\n onOpen,\n onClose,\n isOpen: controlledIsOpen,\n className,\n mode = 'drawer',\n onConversationChange,\n forwardedRef,\n}: ChatDrawerInnerProps): JSX.Element {\n // Merge options with defaults\n const mergedOptions = useMemo(\n () => ({ ...DEFAULT_OPTIONS, ...options }),\n [options]\n );\n\n // localStorage key for persisting selected conversation\n const storageKey = mergedOptions.persistConversation\n ? `devic-ui-chatUid-${assistantId}`\n : null;\n\n // Resolve initial chatUid: prop takes priority, then localStorage\n const resolvedInitialChatUid = useMemo(() => {\n if (initialChatUid) return initialChatUid;\n if (storageKey) {\n try { return localStorage.getItem(storageKey) || undefined; } catch { return undefined; }\n }\n return undefined;\n }, [initialChatUid, storageKey]);\n\n // Drawer open state (can be controlled or uncontrolled; inline mode is always open)\n const [internalIsOpen, setInternalIsOpen] = useState(mergedOptions.defaultOpen);\n const isInline = mode === 'inline';\n const isOpen = isInline ? true : (controlledIsOpen ?? internalIsOpen);\n\n // Wrap onChatCreated to persist chatUid in localStorage\n const handleChatCreated = useCallback(\n (chatUid: string) => {\n if (storageKey) {\n try { localStorage.setItem(storageKey, chatUid); } catch {}\n }\n onChatCreated?.(chatUid);\n },\n [storageKey, onChatCreated]\n );\n\n /**\n * What the end user switched off: connected apps by slug, and their own MCP\n * servers by the `toggleId` the API hands out.\n *\n * Remembered in this browser (see `integrationChoice`) rather than only for\n * the life of the drawer — a reload used to forget it, which for someone who\n * keeps an app switched off on purpose reads as the switch not working. The\n * server still keeps nothing beyond the turn it was sent for; what is stored\n * is a preference of whoever is at this keyboard.\n *\n * The badge on the plug is what keeps that honest: a remembered choice is\n * visible at a glance rather than being an unexplained silence from an app.\n */\n const [disabledIntegrations, setDisabledIntegrations] = useState<string[]>([]);\n\n // Use chat hook\n const chat = useDevicChat({\n assistantId,\n chatUid: resolvedInitialChatUid,\n apiKey,\n baseUrl,\n tenantId,\n tenantMetadata,\n subtenantId,\n subtenantMetadata,\n tags,\n enabledTools,\n disabledIntegrations,\n modelInterfaceTools,\n pollingInterval,\n onMessageSent,\n onMessageReceived,\n onToolCall,\n onError,\n onChatCreated: handleChatCreated,\n onFileUpload,\n messageQueue: mergedOptions.messageQueue,\n debug: mergedOptions.debug,\n });\n\n // Fetch assistant avatar when showAvatar is enabled\n const context = useOptionalDevicContext();\n const resolvedApiKey = apiKey || context?.apiKey;\n // The session source, when the page authenticates with one. Every client\n // built below gets it, or a page without an API key would have nothing to\n // authenticate with.\n const resolvedTenantSession = context?.getTenantSession;\n const onSessionExpired = context?.onSessionExpired;\n const resolvedBaseUrl = baseUrl || context?.baseUrl || 'https://api.devic.ai';\n const [coreMemoryOpen, setCoreMemoryOpen] = useState(false);\n const [integrationsOpen, setIntegrationsOpen] = useState(false);\n\n const infoClient = useMemo(\n () =>\n resolvedApiKey || resolvedTenantSession\n ? new DevicApiClient({\n apiKey: resolvedApiKey,\n baseUrl: resolvedBaseUrl,\n getTenantSession: resolvedTenantSession,\n onSessionExpired,\n })\n : null,\n [resolvedApiKey, resolvedTenantSession, resolvedBaseUrl]\n );\n\n // Asked for only when something on screen depends on it, and then at most\n // once per assistant however many times this drawer is mounted — a host that\n // remounts it to start a fresh conversation used to pay for the answer again\n // every time.\n const assistantInfo = useAssistantInfo({\n assistantId,\n client: infoClient,\n baseUrl: resolvedBaseUrl,\n credential: resolvedApiKey || 'session',\n enabled:\n (!!mergedOptions.showAvatar && !mergedOptions.avatarUrl) ||\n (mergedOptions.showIntegrationsButton !== false && isOpen),\n });\n // The host's own image wins: an assistant carries one image for everybody, so\n // this is the only place a per-account face can come from. Failing that, an\n // assistant with no uploaded image still gets a face, generated from its\n // identifier — the same one the console shows for it. Drawn from `assistantId`\n // rather than from the fetched assistant so the header is not empty while the\n // lookup is in flight; the two agree, since that is what was asked for.\n const avatarUrl = mergedOptions.showAvatar\n ? (mergedOptions.avatarUrl ??\n assistantInfo.assistant?.imgUrl ??\n avatarUri(\n assistantInfo.assistant?.identifier || assistantId,\n assistantInfo.assistant?.avatarStyle\n ))\n : null;\n\n /**\n * Whether to ask which apps this assistant offers.\n *\n * The listing is worth a request only when there is something to list, and\n * most assistants offer nothing — for those, the call existed purely to be\n * refused, once per page load. The assistant now says so itself, so a plain\n * `false` settles it without asking.\n *\n * Anything else asks, exactly as before: a field that is absent means the API\n * is older than it, not that the answer is no, and a failed lookup means we\n * could not find out. Hiding the button on either would lose the feature for\n * a deployment that has it, which is far worse than one spare request.\n *\n * Where there are apps to show, this puts the two requests in sequence rather\n * than at once, so the listing lands later than it used to. The header holds\n * its place in the meantime — see `pendingIntegrations`.\n */\n const mayOfferIntegrations =\n assistantInfo.settled &&\n assistantInfo.assistant?.tenantIntegrations?.enabled !== false;\n\n // The apps this assistant offers its tenants. Loaded once, here, because the\n // header control cannot decide whether to exist without it — and lent to the\n // modal so opening it does not ask for the same listing again. Nothing is\n // fetched until the drawer is opened for the first time.\n const integrationsState = useIntegrations({\n assistantId,\n tenantId,\n subtenantId,\n apiKey: resolvedApiKey,\n baseUrl: resolvedBaseUrl,\n enabled:\n mergedOptions.showIntegrationsButton !== false &&\n isOpen &&\n mayOfferIntegrations,\n });\n\n /**\n * Whether this assistant offers MCP servers of the tenant's own.\n *\n * Read exactly like `mayOfferIntegrations`: absence means \"cannot tell\", so\n * the listing is asked for anyway. A deployment older than the field keeps\n * the behaviour it had — one refusal per drawer open — rather than losing the\n * feature.\n */\n const mayOfferMcp =\n assistantInfo.settled &&\n assistantInfo.assistant?.tenantMcpServers?.enabled !== false;\n\n /**\n * The tenant's own MCP servers, loaded here rather than inside the modal.\n *\n * The composer's switch needs them too, and it is not inside the modal — so\n * the listing has to live above both. The modal takes it as a prop and stops\n * asking for its own.\n */\n const mcpState = useTenantMcp({\n assistantId,\n tenantId,\n subtenantId,\n apiKey: resolvedApiKey,\n baseUrl: resolvedBaseUrl,\n enabled:\n mergedOptions.showIntegrationsButton !== false && isOpen && mayOfferMcp,\n });\n\n /**\n * Whether the answer to \"is there anything to show here\" is still on its way.\n *\n * Two requests decide it — what the assistant offers, and then what this\n * tenant has connected — and until both have answered the control cannot\n * know whether to exist. Without this the header simply had a gap and then a\n * button, which reads as the page changing its mind.\n */\n const integrationsDeciding =\n mergedOptions.showIntegrationsButton !== false &&\n isOpen &&\n (!assistantInfo.settled ||\n (mayOfferIntegrations && !integrationsState.settled) ||\n (mayOfferMcp && !mcpState.settled));\n\n /**\n * Placeholder chips to hold while the listing is in flight.\n *\n * Only when the assistant has said outright that it offers apps, and how\n * many: on a maybe there would be nothing to hold the place of half the time,\n * and a control that appears and then vanishes is worse than one that arrives\n * late. So this stays at zero for an API that does not say, which is also the\n * behaviour every version until now had.\n */\n const pendingIntegrations =\n assistantInfo.assistant?.tenantIntegrations?.enabled === true &&\n !integrationsState.settled\n ? (assistantInfo.assistant.tenantIntegrations.count ?? 0)\n : 0;\n\n // Tenant/subtenant resolution mirrors useDevicChat (prop overrides provider).\n const resolvedTenantId = tenantId || context?.tenantId;\n const resolvedSubtenantId = subtenantId || context?.subtenantId;\n\n // ── Remembering which apps and servers are switched off ────────────────\n\n const choiceKey = integrationChoiceKey(\n assistantId,\n resolvedTenantId,\n resolvedSubtenantId\n );\n\n // Loaded per key, so switching tenant loads that tenant's choice rather than\n // carrying the previous one over.\n const loadedChoiceRef = useRef<string | null>(null);\n useEffect(() => {\n if (loadedChoiceRef.current === choiceKey) return;\n loadedChoiceRef.current = choiceKey;\n setDisabledIntegrations(readIntegrationChoice(choiceKey));\n }, [choiceKey]);\n\n useEffect(() => {\n // Only once this key's stored value has been read, or the empty initial\n // state would erase it before it was ever loaded.\n if (loadedChoiceRef.current !== choiceKey) return;\n writeIntegrationChoice(choiceKey, disabledIntegrations);\n }, [choiceKey, disabledIntegrations]);\n\n /**\n * Forgets what is no longer on offer, once the listings can say so.\n *\n * Every clause of this is load-bearing. `mayOffer*` is false BEFORE the\n * assistant has answered as well as when the answer is no, so without the\n * `assistantInfo.settled` guard the prune runs on the first render against\n * two empty listings and erases the very thing that was just loaded — which\n * is exactly the reload-forgets-it bug this was meant to fix. A definite\n * \"this assistant offers none\" is an answer; an unsettled listing is not.\n *\n * With the drawer never opened, neither listing is ever fetched, so nothing\n * is pruned and the stored choice survives untouched.\n */\n const appsKnown =\n assistantInfo.settled && (!mayOfferIntegrations || integrationsState.settled);\n const mcpKnown = assistantInfo.settled && (!mayOfferMcp || mcpState.settled);\n useEffect(() => {\n if (!appsKnown || !mcpKnown) return;\n const live = [\n ...integrationsState.integrations\n .filter((i) => i.connected)\n .map((i) => i.app),\n ...mcpState.servers\n .filter((s) => s.connection?.status === 'active' && s.connection.toggleId)\n .map((s) => s.connection!.toggleId as string),\n ];\n setDisabledIntegrations((prev) => pruneIntegrationChoice(prev, live));\n }, [appsKnown, mcpKnown, integrationsState.integrations, mcpState.servers]);\n\n // Usage bar (above the input) — only when enabled and a tenant is known.\n // Refetches after each turn via the message count as refresh key.\n const usageBarNode =\n (mergedOptions.showUsageBar ||\n typeof mergedOptions.customUsageBar === 'function') &&\n resolvedTenantId ? (\n <UsageBar\n apiKey={resolvedApiKey}\n baseUrl={resolvedBaseUrl}\n tenantId={resolvedTenantId}\n subtenantId={resolvedSubtenantId}\n mode={mergedOptions.showUsageBar === 'onDemand' ? 'onDemand' : 'always'}\n metric={mergedOptions.usageBarMetric}\n display={mergedOptions.usageBarDisplay}\n customUsageBar={mergedOptions.customUsageBar}\n color={mergedOptions.color}\n refreshKey={chat.messages.length}\n debug={mergedOptions.debug}\n />\n ) : null;\n\n // Default usage-limit banner (above the input) — opt-out via hideLimitBanner,\n // override via limitBannerRenderer.\n const limitBannerNode =\n chat.limitExceeded && !mergedOptions.hideLimitBanner\n ? mergedOptions.limitBannerRenderer\n ? mergedOptions.limitBannerRenderer(chat.limitExceeded)\n : <LimitBanner limit={chat.limitExceeded} />\n : null;\n\n // Speech-to-text transcription, exposed to custom prompt boxes so a developer\n // can transcribe audio (binary or URL) and attach the resulting transcriptId.\n const transcribeAudio = useCallback(\n (\n audio: Blob | string,\n transcribeOptions?: {\n language?: string;\n messageUid?: string;\n chatUid?: string;\n tenantId?: string;\n },\n ) => {\n if (!resolvedApiKey && !resolvedTenantSession) {\n return Promise.reject(\n new Error('No credentials configured. Cannot transcribe audio.'),\n );\n }\n const client = new DevicApiClient({ apiKey: resolvedApiKey, baseUrl: resolvedBaseUrl, getTenantSession: resolvedTenantSession, onSessionExpired });\n return client.transcribeAudio(audio, {\n language: transcribeOptions?.language ?? mergedOptions.speechLanguage,\n messageUid: transcribeOptions?.messageUid,\n chatUid: transcribeOptions?.chatUid,\n tenantId: transcribeOptions?.tenantId ?? tenantId,\n });\n },\n [resolvedApiKey, resolvedTenantSession, resolvedBaseUrl, mergedOptions.speechLanguage, tenantId],\n );\n\n // Handle open/close\n const handleOpen = useCallback(() => {\n setInternalIsOpen(true);\n onOpen?.();\n }, [onOpen]);\n\n const handleClose = useCallback(() => {\n setInternalIsOpen(false);\n onClose?.();\n }, [onClose]);\n\n const handleToggle = useCallback(() => {\n setInternalIsOpen((prev) => !prev);\n }, []);\n\n // Expose handle for programmatic control\n useImperativeHandle(forwardedRef, () => ({\n open: handleOpen,\n close: handleClose,\n toggle: handleToggle,\n setChatUid: (chatUid: string) => {\n chat.loadChat(chatUid);\n },\n sendMessage: (message: string) => {\n chat.sendMessage(message);\n },\n }), [handleOpen, handleClose, handleToggle, chat]);\n\n // Register this drawer in the DevicProvider so AIElementWrapper can open it\n useEffect(() => {\n if (!context?.registerDrawer) return;\n const unregister = context.registerDrawer({\n open: handleOpen,\n close: handleClose,\n toggle: handleToggle,\n sendMessage: (message: string) => chat.sendMessage(message),\n });\n return unregister;\n }, [context, handleOpen, handleClose, handleToggle, chat]);\n\n // Partition pending widget calls by render mode\n const { inlineWidgets, inputWidget } = useMemo(() => {\n const inline: typeof chat.pendingWidgetCalls = [];\n let input: typeof chat.pendingWidgetCalls[number] | null = null;\n for (const wc of chat.pendingWidgetCalls) {\n if (wc.widget.render === 'input' && !input) {\n input = wc;\n } else {\n inline.push(wc);\n }\n }\n return { inlineWidgets: inline, inputWidget: input };\n }, [chat.pendingWidgetCalls]);\n\n // Active references from DevicProvider (created by AIElementWrapper)\n const references = context?.references ?? [];\n const removeReference = useCallback(\n (id: string) => {\n context?.removeReference(id);\n },\n [context]\n );\n const clearReferences = useCallback(() => {\n context?.clearReferences();\n }, [context]);\n\n // Handle send message — prefix references and clear them after sending\n /**\n * What the last accepted message was told about when it gets picked up. Only\n * the wording of the notice depends on it.\n */\n const [queueDisposition, setQueueDisposition] = useState<\n QueueDisposition | undefined\n >();\n /**\n * What became of a message that did not simply join the queue: it was turned\n * down, or a stop threw it away. Said out loud, because in both cases the\n * user's text has just moved back into the box on its own.\n */\n const [queueAlert, setQueueAlert] = useState<string | null>(null);\n\n const handleSend = useCallback(\n async (\n message: string,\n files?: File[],\n meta?: { transcriptId?: string; tags?: string[] }\n ) => {\n let finalMessage = message;\n if (references.length > 0) {\n const labels = references.map((r) => `\"${r.label}\"`).join(', ');\n finalMessage = `Elemento referenciado: ${labels}\\n\\n${message}`;\n }\n setQueueAlert(null);\n const result = await chat.sendMessage(finalMessage, {\n files,\n transcriptId: meta?.transcriptId,\n tags: meta?.tags,\n });\n\n if ('rejected' in result) {\n // The references belong to the message that was not sent, so they stay.\n if (result.reason !== 'error') {\n // An ordinary error already reaches the host through `onError`; these\n // two do not, and the only sign of them would otherwise be the text\n // reappearing in the box with no explanation.\n setQueueAlert(\n result.reason === 'queue_full'\n ? `${result.message} Your message is back in the box.`\n : 'The assistant is not taking messages while it works. Your message is back in the box.'\n );\n }\n return result;\n }\n\n setQueueDisposition('queued' in result && result.queued ? result.willProcess : undefined);\n if (references.length > 0) clearReferences();\n return result;\n },\n [chat, references, clearReferences]\n );\n\n /**\n * Whether a message may be written while the assistant is working.\n *\n * Being busy is not the only reason the box closes, and the other two are not\n * about waiting: an inline widget is the assistant waiting on *this* user, and\n * a usage limit is a refusal the queue cannot soften.\n */\n const canQueue =\n chat.queueEnabled && inlineWidgets.length === 0 && !chat.limitExceeded;\n\n const handleStopChat = useCallback(async () => {\n const result = await chat.stopChat();\n setQueueDisposition(undefined);\n setQueueAlert(\n result.discarded\n ? `${result.discarded === 1 ? 'A queued message was' : `${result.discarded} queued messages were`} not sent — the text is back in the box.`\n : null\n );\n return result;\n }, [chat]);\n\n /**\n * Shown while there is something to explain: the user is writing into a run\n * that has not finished, or messages are already waiting. With nothing typed\n * and nothing queued there is nothing to say.\n */\n const queueNoticeNode =\n !mergedOptions.hideQueueNotice &&\n // `queuedCount` on its own matters: an assistant with an input delay queues\n // what is written into an *idle* conversation whether or not it takes\n // messages while busy, so there can be something waiting with the queue\n // switched off.\n (queueAlert || chat.queuedCount > 0 || (canQueue && chat.isLoading))\n ? mergedOptions.queueNoticeRenderer\n ? mergedOptions.queueNoticeRenderer({\n queuedCount: chat.queuedCount,\n willProcess: queueDisposition,\n alert: queueAlert ?? undefined,\n })\n : (\n <QueueNotice\n queuedCount={chat.queuedCount}\n willProcess={queueDisposition}\n alert={queueAlert ?? undefined}\n />\n )\n : null;\n\n // Handle conversation selection\n const handleConversationSelect = useCallback(\n (chatUid: string) => {\n chat.loadChat(chatUid);\n onConversationChange?.(chatUid);\n if (storageKey) {\n try { localStorage.setItem(storageKey, chatUid); } catch {}\n }\n },\n [chat, onConversationChange, storageKey]\n );\n\n const handleNewChat = useCallback(() => {\n chat.clearChat();\n if (storageKey) {\n try { localStorage.removeItem(storageKey); } catch {}\n }\n }, [chat, storageKey]);\n\n // Handle suggested message click\n const handleSuggestedClick = useCallback(\n (message: string) => {\n chat.sendMessage(message);\n },\n [chat]\n );\n\n // Feedback state\n const [feedbackMap, setFeedbackMap] = useState<Map<string, 'positive' | 'negative'>>(new Map());\n const feedbackClientRef = useRef<DevicApiClient | null>(null);\n\n // Initialize feedback client\n useEffect(() => {\n if ((resolvedApiKey || resolvedTenantSession) && !feedbackClientRef.current) {\n feedbackClientRef.current = new DevicApiClient({\n apiKey: resolvedApiKey,\n baseUrl: resolvedBaseUrl,\n getTenantSession: resolvedTenantSession,\n onSessionExpired,\n });\n }\n }, [resolvedApiKey, resolvedTenantSession, resolvedBaseUrl]);\n\n // Load existing feedback when chat changes\n useEffect(() => {\n if (!chat.chatUid || !feedbackClientRef.current || !mergedOptions.showFeedback) return;\n\n feedbackClientRef.current.getChatFeedback(assistantId, chat.chatUid)\n .then((entries) => {\n const newMap = new Map<string, 'positive' | 'negative'>();\n for (const entry of entries) {\n if (entry.feedback !== undefined) {\n newMap.set(entry.requestId, entry.feedback ? 'positive' : 'negative');\n }\n }\n setFeedbackMap(newMap);\n })\n .catch(() => {\n // Silently ignore feedback loading errors\n });\n }, [chat.chatUid, assistantId, mergedOptions.showFeedback]);\n\n // Handle feedback submission\n const handleFeedback = useCallback(\n async (messageId: string, positive: boolean, comment?: string) => {\n if (!chat.chatUid || !feedbackClientRef.current) return;\n\n try {\n await feedbackClientRef.current.submitChatFeedback(assistantId, chat.chatUid, {\n messageId,\n feedback: positive,\n feedbackComment: comment,\n });\n\n setFeedbackMap((prev) => {\n const newMap = new Map(prev);\n newMap.set(messageId, positive ? 'positive' : 'negative');\n return newMap;\n });\n } catch (err) {\n console.error('Failed to submit feedback:', err);\n throw err;\n }\n },\n [chat.chatUid, assistantId]\n );\n\n // Apply CSS variables for theming on the drawer element itself\n // (must target the component root so they override the defaults defined on .devic-chat-drawer)\n const drawerRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const el = drawerRef.current;\n if (!el) return;\n const vars: [string, string | undefined][] = [\n ['--devic-primary', mergedOptions.color !== DEFAULT_OPTIONS.color ? mergedOptions.color : undefined],\n ['--devic-font-family', mergedOptions.fontFamily],\n ['--devic-bg', mergedOptions.backgroundColor],\n ['--devic-text', mergedOptions.textColor],\n ['--devic-bg-secondary', mergedOptions.secondaryBackgroundColor],\n ['--devic-border', mergedOptions.borderColor],\n ['--devic-user-bubble', mergedOptions.userBubbleColor],\n ['--devic-user-bubble-text', mergedOptions.userBubbleTextColor],\n ['--devic-assistant-bubble', mergedOptions.assistantBubbleColor],\n ['--devic-assistant-bubble-text', mergedOptions.assistantBubbleTextColor],\n ['--devic-send-btn', mergedOptions.sendButtonColor],\n ];\n for (const [name, value] of vars) {\n if (value) {\n el.style.setProperty(name, value);\n } else {\n el.style.removeProperty(name);\n }\n }\n }, [mergedOptions.color, mergedOptions.fontFamily, mergedOptions.backgroundColor, mergedOptions.textColor, mergedOptions.secondaryBackgroundColor, mergedOptions.borderColor, mergedOptions.userBubbleColor, mergedOptions.userBubbleTextColor, mergedOptions.assistantBubbleColor, mergedOptions.assistantBubbleTextColor, mergedOptions.sendButtonColor]);\n\n // The same values, handed to the dialogs this drawer opens. They render\n // through a portal into document.body, so the variables set above — which\n // live on the drawer element — never reach them.\n // The brain button says what the modal it opens is called.\n const coreMemoryTitle =\n mergedOptions.coreMemoryLabels?.title ?? DEFAULT_CORE_MEMORY_LABELS.title;\n\n const modalTheme: DevicTheme = useMemo(\n () => ({\n color:\n mergedOptions.color !== DEFAULT_OPTIONS.color\n ? mergedOptions.color\n : undefined,\n fontFamily: mergedOptions.fontFamily,\n backgroundColor: mergedOptions.backgroundColor,\n textColor: mergedOptions.textColor,\n secondaryBackgroundColor: mergedOptions.secondaryBackgroundColor,\n borderColor: mergedOptions.borderColor,\n }),\n [\n mergedOptions.color,\n mergedOptions.fontFamily,\n mergedOptions.backgroundColor,\n mergedOptions.textColor,\n mergedOptions.secondaryBackgroundColor,\n mergedOptions.borderColor,\n ]\n );\n\n // The strip above the composer. Dismissed per end user, because the whole\n // point of remembering a dismissal is that the same person is not told twice.\n const integrationsHintNode =\n mergedOptions.showIntegrationsButton !== false &&\n mergedOptions.showIntegrationsHint !== false ? (\n <IntegrationsHint\n state={integrationsState}\n onOpen={() => setIntegrationsOpen(true)}\n label={mergedOptions.integrationsHintLabel}\n maxLogos={mergedOptions.maxIntegrationLogos}\n storageKey={`${assistantId}:${resolvedTenantId ?? ''}:${resolvedSubtenantId ?? ''}`}\n dark={isDarkTheme(modalTheme)}\n />\n ) : null;\n\n // The per-message switch in the composer row. Shown only where there is\n // something to switch — the control returns null with nothing connected —\n // and hidden outright by `showIntegrationsToggle: false`.\n const integrationsToggleNode =\n mergedOptions.showIntegrationsButton !== false &&\n mergedOptions.showIntegrationsToggle !== false ? (\n <IntegrationsToggle\n state={integrationsState}\n mcp={mcpState}\n disabled={disabledIntegrations}\n onChange={setDisabledIntegrations}\n onManage={() => setIntegrationsOpen(true)}\n label={mergedOptions.integrationsToggleLabel}\n dark={isDarkTheme(modalTheme)}\n busy={chat.isLoading}\n loading={integrationsDeciding}\n />\n ) : null;\n\n // Resizable drawer\n const [resizedWidth, setResizedWidth] = useState<number | null>(null);\n\n const handleResizeStart = useCallback(\n (e: React.MouseEvent) => {\n e.preventDefault();\n const startX = e.clientX;\n const startWidth = drawerRef.current?.offsetWidth ?? 0;\n const isLeft = mergedOptions.position === 'left';\n\n const onMove = (ev: MouseEvent) => {\n const delta = ev.clientX - startX;\n const newWidth = startWidth + (isLeft ? delta : -delta);\n const clamped = Math.min(\n mergedOptions.maxWidth,\n Math.max(mergedOptions.minWidth, newWidth)\n );\n setResizedWidth(clamped);\n };\n\n const onUp = () => {\n document.removeEventListener('mousemove', onMove);\n document.removeEventListener('mouseup', onUp);\n };\n\n document.addEventListener('mousemove', onMove);\n document.addEventListener('mouseup', onUp);\n },\n [mergedOptions.position, mergedOptions.minWidth, mergedOptions.maxWidth]\n );\n\n // Build style object\n const baseWidth = resizedWidth\n ? `${resizedWidth}px`\n : typeof mergedOptions.width === 'number'\n ? `${mergedOptions.width}px`\n : mergedOptions.width;\n\n const drawerStyle = useMemo(\n () => ({\n width: baseWidth,\n zIndex: mergedOptions.zIndex,\n borderRadius: typeof mergedOptions.borderRadius === 'number'\n ? `${mergedOptions.borderRadius}px`\n : mergedOptions.borderRadius,\n ...mergedOptions.style,\n }),\n [baseWidth, mergedOptions.zIndex, mergedOptions.borderRadius, mergedOptions.style]\n );\n\n const overlayStyle = useMemo(\n () => ({\n zIndex: mergedOptions.zIndex - 1,\n }),\n [mergedOptions.zIndex]\n );\n\n const triggerStyle = useMemo(\n () => ({\n zIndex: mergedOptions.zIndex - 1,\n [mergedOptions.position]: 20,\n bottom: 20,\n }),\n [mergedOptions.zIndex, mergedOptions.position]\n );\n\n return (\n <>\n {/* Overlay (drawer mode only) */}\n {!isInline && (\n <div\n className=\"devic-drawer-overlay\"\n data-open={isOpen}\n style={overlayStyle}\n onClick={handleClose}\n />\n )}\n\n {/* Drawer */}\n <div\n ref={drawerRef}\n className={`devic-chat-drawer ${className || ''}`}\n data-position={mergedOptions.position}\n data-open={isOpen}\n data-mode={mode}\n style={drawerStyle}\n >\n {/* Resize handle */}\n {mergedOptions.resizable && (\n <div\n className=\"devic-resize-handle\"\n data-position={mergedOptions.position}\n onMouseDown={handleResizeStart}\n />\n )}\n\n {/* Header */}\n <div className=\"devic-drawer-header\">\n {avatarUrl && (\n <img\n className=\"devic-drawer-avatar\"\n src={avatarUrl}\n alt=\"\"\n aria-hidden=\"true\"\n />\n )}\n <h2 className=\"devic-drawer-title\">{mergedOptions.title}</h2>\n <ConversationSelector\n assistantId={assistantId}\n currentChatUid={chat.chatUid}\n onSelect={handleConversationSelect}\n onNewChat={handleNewChat}\n apiKey={apiKey}\n baseUrl={baseUrl}\n tenantId={tenantId}\n subtenantId={subtenantId}\n conversationPreview={mergedOptions.conversationPreview}\n />\n <div className=\"devic-drawer-header-actions\">\n {mergedOptions.showIntegrationsButton !== false && (\n <IntegrationsLauncher\n state={integrationsState}\n mcp={mcpState}\n onClick={() => setIntegrationsOpen(true)}\n label={mergedOptions.integrationsLabel}\n maxLogos={mergedOptions.maxIntegrationLogos}\n dark={isDarkTheme(modalTheme)}\n placeholders={pendingIntegrations}\n loading={integrationsDeciding}\n />\n )}\n {mergedOptions.showCoreMemoryButton && (\n <button\n className=\"devic-new-chat-btn\"\n onClick={() => setCoreMemoryOpen(true)}\n type=\"button\"\n aria-label={coreMemoryTitle}\n title={coreMemoryTitle}\n >\n <BrainIcon />\n </button>\n )}\n <button\n className=\"devic-new-chat-btn\"\n onClick={handleNewChat}\n type=\"button\"\n aria-label=\"New chat\"\n title=\"New chat\"\n >\n <PlusIcon />\n </button>\n {!isInline && (\n <button\n className=\"devic-drawer-close\"\n onClick={handleClose}\n type=\"button\"\n aria-label=\"Close chat\"\n >\n <CloseIcon />\n </button>\n )}\n </div>\n </div>\n\n {/* Error display */}\n {chat.error && (\n <div className=\"devic-error\">\n {chat.error.message}\n </div>\n )}\n\n {/* Messages */}\n <ChatMessages\n messages={chat.messages}\n allMessages={chat.messages}\n isLoading={chat.isLoading}\n welcomeMessage={mergedOptions.welcomeMessage}\n suggestedMessages={mergedOptions.suggestedMessages}\n onSuggestedClick={handleSuggestedClick}\n showToolTimeline={mergedOptions.showToolTimeline}\n toolRenderers={mergedOptions.toolRenderers}\n toolIcons={mergedOptions.toolIcons}\n loadingIndicator={mergedOptions.loadingIndicator}\n showFeedback={mergedOptions.showFeedback}\n feedbackMap={feedbackMap}\n onFeedback={handleFeedback}\n handedOffSubThreadId={chat.handedOffSubThreadId || undefined}\n onHandoffCompleted={chat.onHandoffCompleted}\n handoffWidgetRenderer={mergedOptions.handoffWidgetRenderer}\n toolGroups={mergedOptions.toolGroups}\n userMessageRenderer={mergedOptions.userMessageRenderer}\n assistantMessageRenderer={mergedOptions.assistantMessageRenderer}\n apiKey={resolvedApiKey}\n baseUrl={resolvedBaseUrl}\n pollingInterval={pollingInterval}\n pendingInlineWidgets={inlineWidgets}\n onSubmitWidget={chat.submitWidgetResponse}\n onCancelWidget={chat.cancelWidgetCall}\n recalledMemories={\n mergedOptions.showRecalledMemories\n ? chat.recalledMemories\n : undefined\n }\n recalledMemoriesRenderer={mergedOptions.recalledMemoriesRenderer}\n compactions={\n mergedOptions.showCompaction ? chat.compactions : undefined\n }\n compaction={\n mergedOptions.showCompaction ? chat.compaction : undefined\n }\n compactionRenderer={mergedOptions.compactionRenderer}\n />\n\n {/* Input */}\n {mergedOptions.customPromptBox ? (\n <div className=\"devic-input-area\">\n {limitBannerNode}\n {usageBarNode}\n {integrationsHintNode}\n {queueNoticeNode}\n {mergedOptions.customPromptBox({\n sendMessage: handleSend,\n transcribeAudio,\n stop: chat.stopChat,\n isLoading: chat.isLoading,\n queueEnabled: canQueue,\n queuedCount: chat.queuedCount,\n newConversation: chat.clearChat,\n references,\n removeReference,\n clearReferences,\n limitExceeded: chat.limitExceeded,\n })}\n </div>\n ) : (\n <ChatInput\n onSend={handleSend}\n disabled={\n // `handedOff` is one of the states the queue covers — the\n // conversation is waiting on a subagent, which in an embedded\n // widget can take minutes — so with queueing on it no longer\n // closes the box. A pending widget and a usage limit still do:\n // one is the assistant waiting on this user, the other a refusal.\n (chat.isLoading && !canQueue) ||\n (chat.handedOff && !canQueue) ||\n inlineWidgets.length > 0 ||\n !!chat.limitExceeded\n }\n placeholder={mergedOptions.inputPlaceholder}\n enableFileUploads={mergedOptions.enableFileUploads}\n allowedFileTypes={mergedOptions.allowedFileTypes}\n maxFileSize={mergedOptions.maxFileSize}\n enableLongTextPaste={mergedOptions.enableLongTextPaste}\n longTextPasteThreshold={mergedOptions.longTextPasteThreshold}\n enableSpeechToText={mergedOptions.enableSpeechToText}\n speechLanguage={mergedOptions.speechLanguage}\n speechTenantId={tenantId}\n speechAutoStop={mergedOptions.speechAutoStop}\n speechAutoStopCountdownMs={mergedOptions.speechAutoStopCountdownMs}\n speechAutoStopSilenceMs={mergedOptions.speechAutoStopSilenceMs}\n speechAutoStopSilenceRatio={mergedOptions.speechAutoStopSilenceRatio}\n speechAutoStopSilenceLevel={mergedOptions.speechAutoStopSilenceLevel}\n speechAutoStopSpeechLevel={mergedOptions.speechAutoStopSpeechLevel}\n speechHandoff={mergedOptions.speechHandoff}\n speechHandoffSendDelayMs={mergedOptions.speechHandoffSendDelayMs}\n speechHandoffHoldMs={mergedOptions.speechHandoffHoldMs}\n apiKey={resolvedApiKey}\n baseUrl={resolvedBaseUrl}\n sendButtonContent={mergedOptions.sendButtonContent}\n disabledMessage={\n chat.handedOff\n ? 'Waiting for subagent to complete'\n : inlineWidgets.length > 0\n ? 'Waiting for tool response'\n : undefined\n }\n isProcessing={chat.isLoading && !chat.handedOff}\n onStop={handleStopChat}\n allowQueueing={canQueue}\n queueNotice={queueNoticeNode}\n stopButtonContent={mergedOptions.stopButtonContent}\n pendingInputWidget={inputWidget}\n onSubmitWidget={chat.submitWidgetResponse}\n onCancelWidget={chat.cancelWidgetCall}\n references={references}\n onRemoveReference={removeReference}\n usageBar={usageBarNode}\n limitBanner={limitBannerNode}\n integrationsHint={integrationsHintNode}\n integrationsToggle={integrationsToggleNode}\n />\n )}\n </div>\n\n {/* Trigger button (drawer mode only, when closed) */}\n {!isInline && !isOpen && (\n <button\n className=\"devic-trigger\"\n onClick={handleOpen}\n style={triggerStyle}\n type=\"button\"\n aria-label=\"Open chat\"\n >\n <ChatIcon />\n </button>\n )}\n\n {/* Core memory modal (opened from the header brain button) */}\n {mergedOptions.showCoreMemoryButton && (\n <CoreMemoryModal\n isOpen={coreMemoryOpen}\n onClose={() => setCoreMemoryOpen(false)}\n assistantId={assistantId}\n tenantId={tenantId}\n subtenantId={subtenantId}\n apiKey={resolvedApiKey}\n baseUrl={resolvedBaseUrl}\n labels={mergedOptions.coreMemoryLabels}\n theme={modalTheme}\n />\n )}\n\n {/* Connected apps modal (opened from the header app stack) */}\n {mergedOptions.showIntegrationsButton !== false && (\n <IntegrationsModal\n isOpen={integrationsOpen}\n onClose={() => setIntegrationsOpen(false)}\n assistantId={assistantId}\n tenantId={tenantId}\n subtenantId={subtenantId}\n apiKey={resolvedApiKey}\n baseUrl={resolvedBaseUrl}\n title={mergedOptions.integrationsLabel}\n theme={modalTheme}\n state={integrationsState}\n mcpState={mcpState}\n />\n )}\n </>\n );\n}\n\n/**\n * Brain icon for the core memory button\n */\nfunction BrainIcon(): JSX.Element {\n return (\n <svg\n width=\"17\"\n height=\"17\"\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=\"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 CloseIcon(): JSX.Element {\n return (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n\n/**\n * Plus icon for new chat button\n */\nfunction PlusIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\" />\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\" />\n </svg>\n );\n}\n\n/**\n * Chat icon for trigger button\n */\nfunction ChatIcon(): JSX.Element {\n return (\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n >\n <path d=\"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z\" />\n </svg>\n );\n}\n"],"names":["forwardRef","_jsx","ChatDrawerErrorBoundary","useMemo","useState","useCallback","useDevicChat","useOptionalDevicContext","DevicApiClient","assistantInfo","useAssistantInfo","avatarUri","useIntegrations","useTenantMcp","integrationChoiceKey","useRef","useEffect","readIntegrationChoice","writeIntegrationChoice","pruneIntegrationChoice","UsageBar","LimitBanner","client","useImperativeHandle","QueueNotice","DEFAULT_CORE_MEMORY_LABELS","IntegrationsHint","isDarkTheme","IntegrationsToggle","_jsxs","_Fragment","ConversationSelector","IntegrationsLauncher","ChatMessages","ChatInput","CoreMemoryModal","IntegrationsModal"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,eAAe,GAAgC;AACnD,IAAA,QAAQ,EAAE,OAAO;AACjB,IAAA,KAAK,EAAE,MAAM;AACb,IAAA,WAAW,EAAE,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