@devicai/ui 0.60.0 → 0.61.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 +4 -0
- package/dist/cjs/api/client.js +38 -5
- package/dist/cjs/api/client.js.map +1 -1
- package/dist/cjs/api/types.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js +9 -2
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatMessages.js +2 -1
- package/dist/cjs/components/ChatDrawer/ChatMessages.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/LiveVoicePanel.js +106 -0
- package/dist/cjs/components/ChatDrawer/LiveVoicePanel.js.map +1 -0
- package/dist/cjs/components/ChatDrawer/LiveVoicePrompter.js +148 -0
- package/dist/cjs/components/ChatDrawer/LiveVoicePrompter.js.map +1 -0
- package/dist/cjs/hooks/useDevicChat.js +68 -17
- package/dist/cjs/hooks/useDevicChat.js.map +1 -1
- package/dist/cjs/hooks/useDevicLiveVoice.js +73 -0
- package/dist/cjs/hooks/useDevicLiveVoice.js.map +1 -0
- package/dist/cjs/hooks/usePolling.js +1 -1
- package/dist/cjs/hooks/usePolling.js.map +1 -1
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/cjs/voice/LiveVoiceController.js +287 -0
- package/dist/cjs/voice/LiveVoiceController.js.map +1 -0
- package/dist/esm/api/client.d.ts +12 -3
- package/dist/esm/api/client.js +38 -5
- package/dist/esm/api/client.js.map +1 -1
- package/dist/esm/api/liveVoice.types.d.ts +49 -0
- package/dist/esm/api/types.d.ts +3 -0
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.js +11 -4
- package/dist/esm/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.types.d.ts +6 -0
- package/dist/esm/components/ChatDrawer/ChatMessages.js +2 -1
- package/dist/esm/components/ChatDrawer/ChatMessages.js.map +1 -1
- package/dist/esm/components/ChatDrawer/LiveVoicePanel.d.ts +21 -0
- package/dist/esm/components/ChatDrawer/LiveVoicePanel.js +102 -0
- package/dist/esm/components/ChatDrawer/LiveVoicePanel.js.map +1 -0
- package/dist/esm/components/ChatDrawer/LiveVoicePrompter.d.ts +12 -0
- package/dist/esm/components/ChatDrawer/LiveVoicePrompter.js +145 -0
- package/dist/esm/components/ChatDrawer/LiveVoicePrompter.js.map +1 -0
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/useDevicChat.d.ts +6 -0
- package/dist/esm/hooks/useDevicChat.js +68 -17
- package/dist/esm/hooks/useDevicChat.js.map +1 -1
- package/dist/esm/hooks/useDevicLiveVoice.d.ts +20 -0
- package/dist/esm/hooks/useDevicLiveVoice.js +71 -0
- package/dist/esm/hooks/useDevicLiveVoice.js.map +1 -0
- package/dist/esm/hooks/usePolling.d.ts +1 -1
- package/dist/esm/hooks/usePolling.js +1 -1
- package/dist/esm/hooks/usePolling.js.map +1 -1
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/styles.css +1 -1
- package/dist/esm/voice/LiveVoiceController.d.ts +38 -0
- package/dist/esm/voice/LiveVoiceController.js +284 -0
- package/dist/esm/voice/LiveVoiceController.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1473,3 +1473,7 @@ import type {
|
|
|
1473
1473
|
## License
|
|
1474
1474
|
|
|
1475
1475
|
MIT
|
|
1476
|
+
|
|
1477
|
+
# Live voice (0.61.0)
|
|
1478
|
+
|
|
1479
|
+
Enable with `options={{ liveVoice: { enabled: true } }}` on `ChatDrawer`, after enabling voice on the assistant. Reuses the existing SSE for messages and tools; WebRTC carries audio. See [Live voice integration](docs/live-voice.md) for backend requirements, tenant sessions, lifecycle, recordings and headless hooks. No OpenAI key is needed in the browser.
|
package/dist/cjs/api/client.js
CHANGED
|
@@ -117,7 +117,7 @@ class DevicApiClient {
|
|
|
117
117
|
/**
|
|
118
118
|
* Make an authenticated request to the API
|
|
119
119
|
*/
|
|
120
|
-
async request(endpoint, options = {}, isRetry = false) {
|
|
120
|
+
async request(endpoint, options = {}, isRetry = false, binary = false) {
|
|
121
121
|
const url = `${this.config.baseUrl}${endpoint}`;
|
|
122
122
|
const credential = await this.authorization();
|
|
123
123
|
const headers = {
|
|
@@ -135,7 +135,7 @@ class DevicApiClient {
|
|
|
135
135
|
// turns that into a pause instead of a broken conversation.
|
|
136
136
|
if (response.status === 401 && this.config.getTenantSession && !isRetry) {
|
|
137
137
|
if (await this.recoverSession(credential)) {
|
|
138
|
-
return this.request(endpoint, options, true);
|
|
138
|
+
return this.request(endpoint, options, true, binary);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
if (!response.ok) {
|
|
@@ -158,6 +158,10 @@ class DevicApiClient {
|
|
|
158
158
|
}
|
|
159
159
|
throw new DevicApiError(errorData);
|
|
160
160
|
}
|
|
161
|
+
if (binary)
|
|
162
|
+
return await response.blob();
|
|
163
|
+
if (response.status === 204)
|
|
164
|
+
return undefined;
|
|
161
165
|
// Handle responses that may have a wrapper structure
|
|
162
166
|
const data = await response.json();
|
|
163
167
|
// If the response has a data property, extract it (common wrapper pattern)
|
|
@@ -166,9 +170,38 @@ class DevicApiClient {
|
|
|
166
170
|
}
|
|
167
171
|
return data;
|
|
168
172
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
async liveRequest(path, options = {}) {
|
|
174
|
+
const controller = new AbortController();
|
|
175
|
+
const timeout = setTimeout(() => controller.abort(), 25000);
|
|
176
|
+
try {
|
|
177
|
+
return await this.request(path, { ...options, signal: controller.signal });
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
clearTimeout(timeout);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
createLiveSession(assistantId, body) {
|
|
184
|
+
// No network-error retry: an ambiguous response could hide a paid session.
|
|
185
|
+
return this.liveRequest(`/api/v1/assistants/${encodeURIComponent(assistantId)}/live/sessions`, {
|
|
186
|
+
method: 'POST', body: JSON.stringify(body),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
getLiveSessionStatus(assistantId, sessionId) {
|
|
190
|
+
return this.liveRequest(`/api/v1/assistants/${encodeURIComponent(assistantId)}/live/sessions/${encodeURIComponent(sessionId)}`);
|
|
191
|
+
}
|
|
192
|
+
closeLiveSession(assistantId, sessionId) {
|
|
193
|
+
return this.liveRequest(`/api/v1/assistants/${encodeURIComponent(assistantId)}/live/sessions/${encodeURIComponent(sessionId)}`, { method: 'DELETE', keepalive: true });
|
|
194
|
+
}
|
|
195
|
+
getLiveRecordings(assistantId, chatUid, offset = 0, limit = 100) {
|
|
196
|
+
return this.request(`/api/v1/assistants/${encodeURIComponent(assistantId)}/chats/${encodeURIComponent(chatUid)}/recordings?offset=${offset}&limit=${limit}`);
|
|
197
|
+
}
|
|
198
|
+
getLiveRecordingAudio(assistantId, chatUid, sessionId) {
|
|
199
|
+
return this.request(`/api/v1/assistants/${encodeURIComponent(assistantId)}/chats/${encodeURIComponent(chatUid)}/recordings/${encodeURIComponent(sessionId)}/audio`, {}, false, true);
|
|
200
|
+
}
|
|
201
|
+
getLiveVoiceUsage(assistantId, chatUid) {
|
|
202
|
+
return this.request(`/api/v1/assistants/${encodeURIComponent(assistantId)}/chats/${encodeURIComponent(chatUid)}/live-usage`);
|
|
203
|
+
}
|
|
204
|
+
/** Get all assistant specializations. */
|
|
172
205
|
async getAssistants(external = false) {
|
|
173
206
|
const query = external ? "?external=true" : "";
|
|
174
207
|
return this.request(`/api/v1/assistants${query}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../../src/api/client.ts"],"sourcesContent":["import { consumeChatStream } from '../utils/consumeChatStream';\nimport type {\n ProcessMessageDto,\n ChatMessage,\n AsyncResponse,\n RealtimeChatHistory,\n ChatHistory,\n AssistantSpecialization,\n ApiError,\n ToolCallResponse,\n ConversationSummary,\n ListConversationsResponse,\n FeedbackSubmission,\n FeedbackEntry,\n AgentThreadDto,\n AgentDto,\n WhisperTranscriptionResponse,\n TenantUsage,\n TenantUsageHistoryRow,\n TenantUsageHistoryQuery,\n CoreMemoryList,\n CoreMemoryEntry,\n Integration,\n TenantMcpAuthInput,\n TenantMcpConnectResult,\n TenantMcpListing,\n IntegrationAuthScheme,\n IntegrationSetupRequired,\n ModelInterfaceToolSchema,\n StopChatResponse,\n} from \"./types\";\n\n/**\n * A tenant session, as the integrator's backend hands it over.\n *\n * A bare string is accepted too — the expiry is then read out of the token\n * itself, so the simplest possible source still gets proactive renewal.\n */\nexport interface TenantSessionToken {\n token: string;\n /** Epoch milliseconds. */\n expiresAt?: number;\n /** Seconds from now. Used when `expiresAt` is absent. */\n expiresIn?: number;\n}\n\nexport interface DevicApiClientConfig {\n /**\n * The public API key. Optional when `getTenantSession` is supplied — a page\n * using tenant sessions has no reason to carry one.\n */\n apiKey?: string;\n baseUrl: string;\n /**\n * Where the tenant session comes from.\n *\n * Supplying this changes what the tenant IS: with an API key alone the tenant\n * is whatever the page says it is, and the page can say anything. With a\n * session it is what your server signed.\n *\n * A function rather than a value because it is called again on its own —\n * before the token expires and after the API rejects one. It does not have to\n * reach your backend: reading a cookie your login already set is a perfectly\n * good answer, and then the whole thing is `async () => readCookie(…)`.\n *\n * It is called with `force: true` when the API has just rejected the token in\n * hand, meaning a cached answer is known to be dead. Your own function can\n * ignore the argument — `DevicProvider` uses it to share one session across\n * every component without ever serving a refused token back.\n */\n getTenantSession?: (force?: boolean) => Promise<string | TenantSessionToken>;\n /**\n * Called when the session is dead and cannot be replaced — the API rejected\n * it and `getTenantSession` handed back the same expired token.\n *\n * Matters most when the session comes from a cookie with no way to renew it:\n * without this the widget simply stops answering, at the exact moment the\n * user's own login has also expired. Refresh the page, send them to log in,\n * or say something — but say it.\n */\n onSessionExpired?: () => void;\n}\n\n/** Renew this long before expiry, so a request never leaves with a dead token. */\nconst RENEWAL_MARGIN_MS = 60_000;\n\n/**\n * The expiry inside a JWT, in epoch milliseconds.\n *\n * Read rather than required, so the session source can return just the string.\n * Any failure means \"no idea\", and the token is then renewed only when the API\n * rejects it — correct, just less graceful.\n */\nfunction expiryOf(token: string): number | undefined {\n try {\n const payload = token.split(\".\")[1];\n if (!payload) return undefined;\n const json = atob(payload.replace(/-/g, \"+\").replace(/_/g, \"/\"));\n const exp = JSON.parse(json)?.exp;\n return typeof exp === \"number\" ? exp * 1000 : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Devic API client using native fetch\n */\nexport class DevicApiClient {\n private config: DevicApiClientConfig;\n private session?: { token: string; expiresAt?: number };\n /** In flight renewal, shared so a burst of calls fetches one token. */\n private renewing?: Promise<string>;\n /** So a page full of widgets reports one expiry, not one per widget. */\n private expiryReported = false;\n\n constructor(config: DevicApiClientConfig) {\n this.config = config;\n }\n\n /**\n * Update client configuration\n */\n setConfig(config: Partial<DevicApiClientConfig>): void {\n const previous = this.config;\n this.config = { ...this.config, ...config };\n // A new session source speaks for a different end user; keeping the old\n // token would show them the previous one's conversations.\n if (\n config.getTenantSession &&\n config.getTenantSession !== previous.getTenantSession\n ) {\n this.session = undefined;\n this.expiryReported = false;\n }\n }\n\n /** The credential for the next request, renewed if it is about to expire. */\n private async authorization(force = false): Promise<string> {\n if (!this.config.getTenantSession) return this.config.apiKey ?? \"\";\n\n const current = this.session;\n const stillGood =\n current &&\n (current.expiresAt === undefined ||\n current.expiresAt - Date.now() > RENEWAL_MARGIN_MS);\n if (stillGood && !force) return current.token;\n\n return this.renew(force);\n }\n\n private renew(force = false): Promise<string> {\n if (!this.renewing) {\n this.renewing = Promise.resolve(this.config.getTenantSession!(force))\n .then((result) => {\n const token = typeof result === \"string\" ? result : result.token;\n const declared =\n typeof result === \"string\"\n ? undefined\n : (result.expiresAt ??\n (result.expiresIn\n ? Date.now() + result.expiresIn * 1000\n : undefined));\n this.session = { token, expiresAt: declared ?? expiryOf(token) };\n return token;\n })\n .finally(() => {\n this.renewing = undefined;\n });\n }\n return this.renewing;\n }\n\n /**\n * Whether a rejected request is worth retrying, having got a live session.\n *\n * Takes the token the request actually went out with, not the current one:\n * with several requests in flight another may already have replaced it, and\n * comparing against the current one would read that success as a failure.\n *\n * False means the session is dead and cannot be replaced — a cookie set at\n * login, now expired, with nowhere to renew it from. That is worth telling\n * the host application about, once.\n */\n private async recoverSession(rejected: string): Promise<boolean> {\n if (this.session && this.session.token !== rejected) {\n this.expiryReported = false;\n return true;\n }\n\n let fresh: string | undefined;\n try {\n // Forced: whatever is cached upstream is the token that was just\n // refused, so asking for it again would only confirm the refusal.\n fresh = await this.renew(true);\n } catch {\n fresh = undefined;\n }\n if (fresh && fresh !== rejected) {\n this.expiryReported = false;\n return true;\n }\n\n if (!this.expiryReported) {\n this.expiryReported = true;\n this.config.onSessionExpired?.();\n }\n return false;\n }\n\n /**\n * Make an authenticated request to the API\n */\n private async request<T>(\n endpoint: string,\n options: RequestInit = {},\n isRetry = false,\n ): Promise<T> {\n const url = `${this.config.baseUrl}${endpoint}`;\n const credential = await this.authorization();\n\n const headers: HeadersInit = {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${credential}`,\n \"devic-api-source\": \"ui\",\n ...options.headers,\n };\n\n const response = await fetch(url, {\n ...options,\n headers,\n });\n\n // A session can die between being checked and being used — a clock adrift,\n // a tab asleep for an hour, the key revoked. One retry with a fresh token\n // turns that into a pause instead of a broken conversation.\n if (response.status === 401 && this.config.getTenantSession && !isRetry) {\n if (await this.recoverSession(credential)) {\n return this.request<T>(endpoint, options, true);\n }\n }\n\n if (!response.ok) {\n let errorData: ApiError;\n try {\n errorData = await response.json();\n } catch {\n errorData = {\n statusCode: response.status,\n message: response.statusText,\n };\n }\n // Not every refusal carries its own status in the body. A 409 raised with\n // an object (`{ error: 'CHAT_BUSY', ... }`) is returned verbatim, so\n // reading the code off the body alone leaves it undefined and every\n // `statusCode === 409` branch silently misses it.\n if (typeof errorData?.statusCode !== \"number\") {\n errorData = { ...errorData, statusCode: response.status };\n }\n throw new DevicApiError(errorData);\n }\n\n // Handle responses that may have a wrapper structure\n const data = await response.json();\n\n // If the response has a data property, extract it (common wrapper pattern)\n if (data && typeof data === \"object\" && \"data\" in data) {\n return data.data as T;\n }\n\n return data as T;\n }\n\n /**\n * Get all assistant specializations\n */\n async getAssistants(external = false): Promise<AssistantSpecialization[]> {\n const query = external ? \"?external=true\" : \"\";\n return this.request<AssistantSpecialization[]>(\n `/api/v1/assistants${query}`,\n );\n }\n\n /**\n * Get a specific assistant specialization\n */\n async getAssistant(identifier: string): Promise<AssistantSpecialization> {\n return this.request<AssistantSpecialization>(\n `/api/v1/assistants/${identifier}`,\n );\n }\n\n /**\n * Send a message to an assistant (sync mode)\n */\n async sendMessage(\n assistantId: string,\n dto: ProcessMessageDto,\n signal?: AbortSignal,\n ): Promise<ChatMessage[]> {\n return this.request<ChatMessage[]>(\n `/api/v1/assistants/${assistantId}/messages${dto.skipSummarization ? \"?skipSummarization=true\" : \"\"}`,\n {\n method: \"POST\",\n body: JSON.stringify(dto),\n signal,\n },\n );\n }\n\n /**\n * Send a message to an assistant (async mode)\n */\n async sendMessageAsync(\n assistantId: string,\n dto: ProcessMessageDto,\n ): Promise<AsyncResponse> {\n return this.request<AsyncResponse>(\n `/api/v1/assistants/${assistantId}/messages?async=true${dto.skipSummarization ? \"&skipSummarization=true\" : \"\"}`,\n {\n method: \"POST\",\n body: JSON.stringify(dto),\n },\n );\n }\n\n /**\n * Get the list of unique tags used across this account's chat histories.\n * Backed by GET /api/v1/assistants/tags. Useful for autocompletion / filters.\n */\n async getChatTags(): Promise<string[]> {\n return this.request<string[]>(`/api/v1/assistants/tags`);\n }\n\n /**\n * Follow a conversation in progress over its server-sent event stream.\n * Resolves when the server closes the stream; rejects when it is not a\n * stream at all (an older API) or the connection fails. `onActivity` fires\n * on every chunk received, keep-alives included.\n */\n async streamRealtimeHistory(\n assistantId: string,\n chatUid: string,\n onSnapshot: (snapshot: RealtimeChatHistory) => void | Promise<void>,\n signal: AbortSignal,\n onActivity?: () => void,\n ): Promise<void> {\n // `partial=1`: while only the reply being written changes, the API sends\n // `partial` frames with just that instead of the whole conversation.\n const url = `${this.config.baseUrl}/api/v1/assistants/${encodeURIComponent(assistantId)}/chats/${encodeURIComponent(chatUid)}/stream?partial=1`;\n let credential = await this.authorization();\n const open = () => fetch(url, { signal, headers: { Authorization: `Bearer ${credential}`, Accept: 'text/event-stream', 'devic-api-source': 'ui' } });\n let response = await open();\n if (response.status === 401 && this.config.getTenantSession && await this.recoverSession(credential)) {\n credential = await this.authorization(); response = await open();\n }\n await consumeChatStream(response, onSnapshot, onActivity);\n }\n\n async getRealtimeHistory(\n assistantId: string,\n chatUid: string,\n ): Promise<RealtimeChatHistory> {\n return this.request<RealtimeChatHistory>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/realtime`,\n );\n }\n\n /**\n * Get chat history for a specific conversation\n */\n async getChatHistory(\n assistantId: string,\n chatUid: string,\n options?: { tenantId?: string },\n ): Promise<ChatHistory> {\n const params = new URLSearchParams();\n if (options?.tenantId) {\n params.set(\"tenantId\", options.tenantId);\n }\n const query = params.toString();\n return this.request<ChatHistory>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}${query ? `?${query}` : \"\"}`,\n );\n }\n\n /**\n * List conversations for an assistant\n */\n async listConversations(\n assistantId: string,\n options?: {\n tenantId?: string;\n subtenantId?: string;\n offset?: number;\n limit?: number;\n },\n ): Promise<ListConversationsResponse> {\n const params = new URLSearchParams();\n if (options?.tenantId) {\n params.set(\"tenantId\", options.tenantId);\n }\n if (options?.subtenantId) {\n params.set(\"subtenantId\", options.subtenantId);\n }\n if (options?.offset != null) {\n params.set(\"offset\", String(options.offset));\n }\n if (options?.limit != null) {\n params.set(\"limit\", String(options.limit));\n }\n params.set(\"omitContent\", \"true\");\n const query = params.toString();\n return this.request<ListConversationsResponse>(\n `/api/v1/assistants/${assistantId}/chats${query ? `?${query}` : \"\"}`,\n );\n }\n\n /**\n * Send tool call responses back to the assistant.\n *\n * `toolSchemas` re-states the client-side tools for the continuation. The\n * API takes them from the first response of the batch, and without them the\n * turn resumes with no client tools at all — the model stops being able to\n * call them after the first round.\n */\n async sendToolResponses(\n assistantId: string,\n chatUid: string,\n responses: ToolCallResponse[],\n toolSchemas?: ModelInterfaceToolSchema[],\n ): Promise<AsyncResponse> {\n const body =\n toolSchemas?.length && responses.length > 0\n ? responses.map((response, index) =>\n index === 0 ? { ...response, tools: toolSchemas } : response,\n )\n : responses;\n\n return this.request<AsyncResponse>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/tool-response`,\n {\n method: \"POST\",\n body: JSON.stringify({ responses: body }),\n },\n );\n }\n\n /**\n * Submit feedback for a chat message\n */\n async submitChatFeedback(\n assistantId: string,\n chatUid: string,\n data: FeedbackSubmission,\n ): Promise<FeedbackEntry> {\n return this.request<FeedbackEntry>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/feedback`,\n {\n method: \"POST\",\n body: JSON.stringify(data),\n },\n );\n }\n\n /**\n * Get all feedback for a chat\n */\n async getChatFeedback(\n assistantId: string,\n chatUid: string,\n ): Promise<FeedbackEntry[]> {\n return this.request<FeedbackEntry[]>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/feedback`,\n );\n }\n\n /**\n * Get an agent thread by ID\n */\n async getThreadById(\n threadId: string,\n withTasks = false,\n ): Promise<AgentThreadDto> {\n const query = withTasks ? \"?withTasks=true\" : \"\";\n return this.request<AgentThreadDto>(\n `/api/v1/agents/threads/${threadId}${query}`,\n );\n }\n\n /**\n * Get agent details\n */\n async getAgentDetails(agentId: string): Promise<AgentDto> {\n return this.request<AgentDto>(`/api/v1/agents/${agentId}`);\n }\n\n /**\n * Get an AI-generated explanation of a thread's execution\n */\n async explainAgentThread(threadId: string): Promise<string> {\n return this.request<string>(\n `/api/v1/agents/threads/${threadId}/explain`,\n );\n }\n\n /**\n * Pause or resume a thread\n */\n async pauseResumeThread(\n threadId: string,\n action: \"paused\" | \"queued\",\n ): Promise<void> {\n return this.request<void>(\n `/api/v1/agents/threads/${threadId}/pause-resume`,\n {\n method: \"POST\",\n body: JSON.stringify({ action }),\n },\n );\n }\n\n /**\n * Handle thread approval (approve/reject)\n */\n async handleThreadApproval(\n threadId: string,\n approved: boolean,\n retry: boolean,\n message: string,\n ): Promise<void> {\n return this.request<void>(\n `/api/v1/agents/threads/${threadId}/approval`,\n {\n method: \"POST\",\n body: JSON.stringify({\n action: approved ? \"approved\" : \"rejected\",\n message,\n retry,\n }),\n },\n );\n }\n\n /**\n * Manually complete a thread\n */\n async completeThread(\n threadId: string,\n completionState: string,\n ): Promise<void> {\n return this.request<void>(\n `/api/v1/agents/threads/${threadId}/complete`,\n {\n method: \"POST\",\n body: JSON.stringify({ state: completionState }),\n },\n );\n }\n\n /**\n * Continue an existing thread with a new user message. The backend decides how\n * to apply it based on the thread state: a finished/failed/waiting thread is\n * re-queued and re-run with the message appended, while a running/queued thread\n * receives it on its next turn (right after the pending tool response). Returns\n * the updated thread.\n */\n async sendThreadMessage(\n threadId: string,\n message: string | Record<string, unknown>,\n ): Promise<AgentThreadDto> {\n return this.request<AgentThreadDto>(\n `/api/v1/agents/threads/${threadId}/messages`,\n {\n method: \"POST\",\n body: JSON.stringify({ message }),\n },\n );\n }\n\n /**\n * Stop an in-progress async chat.\n * The current LLM call or tool execution will finish, then the chat\n * will be marked as completed with the history accumulated so far.\n */\n async stopChat(\n assistantId: string,\n chatUid: string,\n ): Promise<StopChatResponse> {\n return this.request<StopChatResponse>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/stop`,\n { method: \"POST\" },\n );\n }\n\n /**\n * Upload a file and get a download URL\n */\n async uploadFile(\n file: File,\n isRetry = false,\n ): Promise<{ name: string; downloadUrl: string; fileType: string }> {\n const url = `${this.config.baseUrl}/api/v1/files/upload`;\n\n const formData = new FormData();\n formData.append(\"file\", file);\n\n const credential = await this.authorization();\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${credential}`,\n \"devic-api-source\": \"ui\",\n },\n body: formData,\n });\n\n // The FormData is rebuilt from `file` on the way back in, so unlike a\n // consumed stream this retry is safe.\n if (response.status === 401 && this.config.getTenantSession && !isRetry) {\n if (await this.recoverSession(credential)) return this.uploadFile(file, true);\n }\n\n if (!response.ok) {\n let errorData: { statusCode: number; message: string };\n try {\n errorData = await response.json();\n } catch {\n errorData = {\n statusCode: response.status,\n message: response.statusText,\n };\n }\n // See `request`: a body-shaped refusal need not carry its own status.\n if (typeof errorData?.statusCode !== \"number\") {\n errorData = { ...errorData, statusCode: response.status };\n }\n throw new DevicApiError(errorData);\n }\n\n const data = await response.json();\n if (data && typeof data === \"object\" && \"data\" in data) {\n return data.data;\n }\n return data;\n }\n\n /**\n * Transcribe audio to text using the /whisper endpoint.\n * Accepts either an audio binary (Blob/File, sent as multipart/form-data) or\n * a download URL string (sent as `audioUrl`). The backend stores the binary\n * and runs speech-to-text with Devic's own OpenAI key. Returns the text and a\n * `transcriptId` to attach to the resulting message.\n */\n async transcribeAudio(\n audio: Blob | string,\n options?: {\n language?: string;\n messageUid?: string;\n chatUid?: string;\n tenantId?: string;\n fileName?: string;\n },\n isRetry = false,\n ): Promise<WhisperTranscriptionResponse> {\n const url = `${this.config.baseUrl}/api/v1/whisper`;\n\n const formData = new FormData();\n if (typeof audio === \"string\") {\n formData.append(\"audioUrl\", audio);\n } else {\n formData.append(\"audio\", audio, options?.fileName || \"recording.webm\");\n }\n if (options?.language) formData.append(\"language\", options.language);\n if (options?.messageUid) formData.append(\"messageUid\", options.messageUid);\n if (options?.chatUid) formData.append(\"chatUid\", options.chatUid);\n if (options?.tenantId) formData.append(\"tenantId\", options.tenantId);\n\n const credential = await this.authorization();\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${credential}`,\n \"devic-api-source\": \"ui\",\n },\n body: formData,\n });\n\n if (response.status === 401 && this.config.getTenantSession && !isRetry) {\n if (await this.recoverSession(credential)) {\n return this.transcribeAudio(audio, options, true);\n }\n }\n\n if (!response.ok) {\n let errorData: { statusCode: number; message: string };\n try {\n errorData = await response.json();\n } catch {\n errorData = {\n statusCode: response.status,\n message: response.statusText,\n };\n }\n // See `request`: a body-shaped refusal need not carry its own status.\n if (typeof errorData?.statusCode !== \"number\") {\n errorData = { ...errorData, statusCode: response.status };\n }\n throw new DevicApiError(errorData);\n }\n\n const data = await response.json();\n if (data && typeof data === \"object\" && \"data\" in data) {\n return data.data;\n }\n return data;\n }\n\n /**\n * Fetch a single speech-to-text transcript by its id (the `transcriptId`\n * stored on a message). Returns the transcribed text and the download URL of\n * the source audio so the chat can offer playback of a dictated message.\n */\n async getTranscript(\n transcriptId: string,\n ): Promise<WhisperTranscriptionResponse> {\n return this.request<WhisperTranscriptionResponse>(\n `/api/v1/whisper/${encodeURIComponent(transcriptId)}`,\n );\n }\n\n /**\n * Get chat history content (full conversation after handoff)\n */\n async getChatHistoryContent(\n assistantId: string,\n chatUid: string,\n ): Promise<ChatMessage[]> {\n return this.request<ChatMessage[]>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/content`,\n );\n }\n\n /**\n * Get the current usage limits + consumption for a tenant (or a specific\n * subtenant). Read-only — backed by `GET /api/v1/tenant-usage/:tenantId`\n * (or `/:tenantId/subtenants/:subtenantId`), which is part of the devic-ui\n * key preset. Returns the effective rules with their live consumption and the\n * active tier. Use it to render a usage bar.\n */\n async getTenantUsage(\n tenantId: string,\n subtenantId?: string,\n ): Promise<TenantUsage> {\n const path = subtenantId\n ? `/api/v1/tenant-usage/${encodeURIComponent(tenantId)}/subtenants/${encodeURIComponent(subtenantId)}`\n : `/api/v1/tenant-usage/${encodeURIComponent(tenantId)}`;\n return this.request<TenantUsage>(path);\n }\n\n /**\n * Get the durable per-window usage history for a tenant (or subtenant).\n * Read-only — backed by `GET /api/v1/tenant-usage/:tenantId/history`.\n */\n async getTenantUsageHistory(\n tenantId: string,\n options?: TenantUsageHistoryQuery,\n ): Promise<TenantUsageHistoryRow[]> {\n const params = new URLSearchParams();\n if (options?.subtenantId) params.set(\"subtenantId\", options.subtenantId);\n if (options?.scope) params.set(\"scope\", options.scope);\n if (options?.metric) params.set(\"metric\", options.metric);\n if (options?.windowUnit) params.set(\"windowUnit\", options.windowUnit);\n if (options?.from != null) params.set(\"from\", String(options.from));\n if (options?.to != null) params.set(\"to\", String(options.to));\n if (options?.limit != null) params.set(\"limit\", String(options.limit));\n if (options?.skip != null) params.set(\"skip\", String(options.skip));\n const query = params.toString();\n return this.request<TenantUsageHistoryRow[]>(\n `/api/v1/tenant-usage/${encodeURIComponent(tenantId)}/history${query ? `?${query}` : \"\"}`,\n );\n }\n\n private coreMemoryPath(\n assistantId: string,\n tenantId?: string,\n subtenantId?: string,\n entryId?: number,\n ): string {\n const params = new URLSearchParams();\n if (tenantId) params.set(\"tenantId\", tenantId);\n if (subtenantId) params.set(\"subtenantId\", subtenantId);\n const query = params.toString();\n return `/api/v1/memory/assistants/${encodeURIComponent(assistantId)}/core${\n entryId != null ? `/${entryId}` : \"\"\n }${query ? `?${query}` : \"\"}`;\n }\n\n /**\n * Core memory entries of the bucket the assistant resolves for a\n * tenant/subtenant combination — what the assistant permanently remembers\n * there. `enabled: false` when the assistant has no core memory tier.\n */\n async getCoreMemory(\n assistantId: string,\n options?: { tenantId?: string; subtenantId?: string },\n ): Promise<CoreMemoryList> {\n return this.request<CoreMemoryList>(\n this.coreMemoryPath(assistantId, options?.tenantId, options?.subtenantId),\n );\n }\n\n /** Add a standing core memory entry to the assistant's resolved bucket. */\n async addCoreMemoryEntry(\n assistantId: string,\n entry: { content: string; section?: string; pinned?: boolean },\n options?: { tenantId?: string; subtenantId?: string },\n ): Promise<{ entry?: CoreMemoryEntry; deduped: boolean }> {\n return this.request(\n this.coreMemoryPath(assistantId, options?.tenantId, options?.subtenantId),\n { method: \"POST\", body: JSON.stringify(entry) },\n );\n }\n\n /** Edit the text, section or pinned flag of a core memory entry. */\n async updateCoreMemoryEntry(\n assistantId: string,\n entryId: number,\n patch: { content?: string; section?: string; pinned?: boolean },\n options?: { tenantId?: string; subtenantId?: string },\n ): Promise<CoreMemoryEntry> {\n return this.request<CoreMemoryEntry>(\n this.coreMemoryPath(\n assistantId,\n options?.tenantId,\n options?.subtenantId,\n entryId,\n ),\n { method: \"PATCH\", body: JSON.stringify(patch) },\n );\n }\n\n /** Remove (archive) a core memory entry. */\n async deleteCoreMemoryEntry(\n assistantId: string,\n entryId: number,\n options?: { tenantId?: string; subtenantId?: string },\n ): Promise<{ removed: boolean; id?: number }> {\n return this.request(\n this.coreMemoryPath(\n assistantId,\n options?.tenantId,\n options?.subtenantId,\n entryId,\n ),\n { method: \"DELETE\" },\n );\n }\n\n // ── Connected apps of the end user ────────────────────────────────\n //\n // Backed by `/api/v1/tenant-integrations`: the tenant is resolved on the\n // server and never taken from the path. The tenant/subtenant sent here\n // identify the end user in front of the widget, so one tenant's accounts are\n // never reachable from another's.\n\n private integrationsQuery(options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n returnTo?: string;\n }): string {\n const params = new URLSearchParams({ assistantId: options.assistantId });\n if (options.tenantId) params.set(\"tenantId\", options.tenantId);\n if (options.subtenantId) params.set(\"subtenantId\", options.subtenantId);\n if (options.returnTo) params.set(\"returnTo\", options.returnTo);\n return params.toString();\n }\n\n /** Apps this assistant offers, with the end user's own connection status. */\n async getIntegrations(options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n }): Promise<Integration[]> {\n return this.request<Integration[]>(\n `/api/v1/tenant-integrations?${this.integrationsQuery(options)}`,\n );\n }\n\n /**\n * How this app can be connected, and what it asks the end user for.\n *\n * Scoped like everything else here: the schemes of an app this assistant\n * does not offer cannot be read by asking for them.\n */\n async getIntegrationAuth(\n app: string,\n options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n },\n ): Promise<{ schemes: IntegrationAuthScheme[] }> {\n return this.request(\n `/api/v1/tenant-integrations/${encodeURIComponent(app)}/auth?${this.integrationsQuery(options)}`,\n );\n }\n\n /**\n * Connects an account, in one of two ways.\n *\n * `connected: true` means it is done: the app authenticates with a key the\n * user supplied, so there is nobody to authorise with. Otherwise\n * `authorizationUrl` must be opened in a popup.\n *\n * `returnTo` is where the callback posts the result back to, and the server\n * refuses any value that does not match the origin this request came from —\n * so it cannot be turned into an open redirector.\n *\n * Rejects with a `DevicApiError` carrying `setupRequired` when the app needs\n * values that were not sent.\n */\n async connectIntegration(\n app: string,\n options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n returnTo?: string;\n /** Which scheme to use, from {@link getIntegrationAuth}. */\n authScheme?: string;\n /** This account's own values: its API key, its subdomain. */\n accountFields?: Record<string, string>;\n },\n ): Promise<{ connected: boolean; authorizationUrl?: string }> {\n const { authScheme, accountFields, ...query } = options;\n return this.request(\n `/api/v1/tenant-integrations/${encodeURIComponent(app)}/connect?${this.integrationsQuery(query)}`,\n {\n method: \"POST\",\n body: JSON.stringify({ authScheme, accountFields }),\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n /** Disconnects one of the end user's own accounts. */\n async disconnectIntegration(\n accountId: string,\n options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n },\n ): Promise<{ disconnected: boolean }> {\n return this.request(\n `/api/v1/tenant-integrations/accounts/${encodeURIComponent(accountId)}?${this.integrationsQuery(options)}`,\n { method: \"DELETE\" },\n );\n }\n\n /**\n * Drops the server's short-lived cache of the end user's connections.\n *\n * Called right after the OAuth popup closes: without it the freshly connected\n * app would keep reading as disconnected until the cache expires, which looks\n * like the connection silently failed.\n */\n async refreshIntegrations(options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n }): Promise<{ refreshed: boolean }> {\n return this.request(\n `/api/v1/tenant-integrations/refresh?${this.integrationsQuery(options)}`,\n { method: \"POST\" },\n );\n }\n\n // ---------------------------------------------------------------------------\n // MCP servers the end user connects for themselves\n // ---------------------------------------------------------------------------\n // Backed by `/api/v1/tenant-mcp`, scoped exactly like the integrations above:\n // the tenant is resolved on the server, never taken from the path. Sending a\n // `subtenantId` makes the connection that end user's own; omitting it puts it\n // on the tenant, where every one of its end users shares it.\n\n /** The MCP servers this assistant offers, and the ones this tenant connected. */\n async getMcpServers(options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n }): Promise<TenantMcpListing> {\n return this.request<TenantMcpListing>(\n `/api/v1/tenant-mcp?${this.integrationsQuery(options)}`,\n );\n }\n\n /**\n * Connects a server: one the developer offers (`templateId`) or one the end\n * user brings (`url`).\n *\n * `returnTo` is where the callback posts the result back to, and the server\n * refuses any value that does not match the origin this request came from —\n * so it cannot be turned into an open redirector.\n */\n async connectMcpServer(options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n returnTo?: string;\n templateId?: string;\n url?: string;\n name?: string;\n auth?: TenantMcpAuthInput;\n }): Promise<TenantMcpConnectResult> {\n const { templateId, url, name, auth, returnTo, ...query } = options;\n return this.request(`/api/v1/tenant-mcp?${this.integrationsQuery(query)}`, {\n method: \"POST\",\n // The scope travels in the body as well as the query string: it is what\n // decides whether this connection is the end user's own or the tenant's,\n // and the server reads it from there on writes.\n body: JSON.stringify({\n templateId,\n url,\n name,\n auth,\n returnTo,\n tenantId: options.tenantId,\n subtenantId: options.subtenantId,\n }),\n headers: { \"Content-Type\": \"application/json\" },\n });\n }\n\n /** Authorises again, for a server whose credentials expired or were revoked. */\n async reconnectMcpServer(\n id: string,\n options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n returnTo?: string;\n auth?: TenantMcpAuthInput;\n },\n ): Promise<TenantMcpConnectResult> {\n const { auth, returnTo, ...query } = options;\n return this.request(\n `/api/v1/tenant-mcp/${encodeURIComponent(id)}/reconnect?${this.integrationsQuery(query)}`,\n {\n method: \"POST\",\n body: JSON.stringify({\n auth,\n returnTo,\n tenantId: options.tenantId,\n subtenantId: options.subtenantId,\n }),\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n /** Disconnects one of the end user's own MCP servers. */\n async disconnectMcpServer(\n id: string,\n options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n },\n ): Promise<{ disconnected: boolean }> {\n return this.request(\n `/api/v1/tenant-mcp/${encodeURIComponent(id)}?${this.integrationsQuery(options)}`,\n { method: \"DELETE\" },\n );\n }\n}\n\n/**\n * Custom error class for API errors\n */\nexport class DevicApiError extends Error {\n public statusCode: number;\n public errorType?: string;\n /** Structured error details (e.g. usage-limit blocking info on a 429). */\n public details?: any;\n /** What connecting an app is still waiting for, when that is why it failed.\n * Carried whole because the fields *are* the form to render. */\n public setupRequired?: IntegrationSetupRequired;\n\n constructor(error: ApiError) {\n super(error.message);\n this.name = \"DevicApiError\";\n this.statusCode = error.statusCode;\n this.errorType = error.error;\n this.details = error.details;\n if ((error as any)?.code === \"INTEGRATION_SETUP_REQUIRED\") {\n this.setupRequired = error as unknown as IntegrationSetupRequired;\n }\n }\n}\n"],"names":["consumeChatStream"],"mappings":";;;;AAmFA;AACA,MAAM,iBAAiB,GAAG,KAAM;AAEhC;;;;;;AAMG;AACH,SAAS,QAAQ,CAAC,KAAa,EAAA;AAC7B,IAAA,IAAI;QACF,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnC,QAAA,IAAI,CAAC,OAAO;AAAE,YAAA,OAAO,SAAS;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAChE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG;AACjC,QAAA,OAAO,OAAO,GAAG,KAAK,QAAQ,GAAG,GAAG,GAAG,IAAI,GAAG,S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,IAAI,CAAC,SAAS,CAAC;gBACnB,IAAI;gBACJ,QAAQ;gBACR,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC;AACF,YAAA,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;AAChD,SAAA,CACF;IACH;;AAGA,IAAA,MAAM,mBAAmB,CACvB,EAAU,EACV,OAIC,EAAA;QAED,OAAO,IAAI,CAAC,OAAO,CACjB,CAAA,mBAAA,EAAsB,kBAAkB,CAAC,EAAE,CAAC,CAAA,CAAA,EAAI,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAA,CAAE,EACjF,EAAE,MAAM,EAAE,QAAQ,EAAE,CACrB;IACH;AACD;AAED;;AAEG;AACG,MAAO,aAAc,SAAQ,KAAK,CAAA;AAStC,IAAA,WAAA,CAAY,KAAe,EAAA;AACzB,QAAA,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;AACpB,QAAA,IAAI,CAAC,IAAI,GAAG,eAAe;AAC3B,QAAA,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU;AAClC,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,KAAK;AAC5B,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO;AAC5B,QAAA,IAAK,KAAa,EAAE,IAAI,KAAK,4BAA4B,EAAE;AACzD,YAAA,IAAI,CAAC,aAAa,GAAG,KAA4C;QACnE;IACF;AACD;;;;;"}
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../../src/api/client.ts"],"sourcesContent":["import { consumeChatStream } from '../utils/consumeChatStream';\nimport type { CreateLiveSessionRequest, LiveVoiceSession, LiveVoiceSessionStatus, LiveVoiceRecording, LiveVoiceUsage } from './liveVoice.types';\nimport type {\n ProcessMessageDto,\n ChatMessage,\n AsyncResponse,\n RealtimeChatHistory,\n ChatHistory,\n AssistantSpecialization,\n ApiError,\n ToolCallResponse,\n ConversationSummary,\n ListConversationsResponse,\n FeedbackSubmission,\n FeedbackEntry,\n AgentThreadDto,\n AgentDto,\n WhisperTranscriptionResponse,\n TenantUsage,\n TenantUsageHistoryRow,\n TenantUsageHistoryQuery,\n CoreMemoryList,\n CoreMemoryEntry,\n Integration,\n TenantMcpAuthInput,\n TenantMcpConnectResult,\n TenantMcpListing,\n IntegrationAuthScheme,\n IntegrationSetupRequired,\n ModelInterfaceToolSchema,\n StopChatResponse,\n} from \"./types\";\n\n/**\n * A tenant session, as the integrator's backend hands it over.\n *\n * A bare string is accepted too — the expiry is then read out of the token\n * itself, so the simplest possible source still gets proactive renewal.\n */\nexport interface TenantSessionToken {\n token: string;\n /** Epoch milliseconds. */\n expiresAt?: number;\n /** Seconds from now. Used when `expiresAt` is absent. */\n expiresIn?: number;\n}\n\nexport interface DevicApiClientConfig {\n /**\n * The public API key. Optional when `getTenantSession` is supplied — a page\n * using tenant sessions has no reason to carry one.\n */\n apiKey?: string;\n baseUrl: string;\n /**\n * Where the tenant session comes from.\n *\n * Supplying this changes what the tenant IS: with an API key alone the tenant\n * is whatever the page says it is, and the page can say anything. With a\n * session it is what your server signed.\n *\n * A function rather than a value because it is called again on its own —\n * before the token expires and after the API rejects one. It does not have to\n * reach your backend: reading a cookie your login already set is a perfectly\n * good answer, and then the whole thing is `async () => readCookie(…)`.\n *\n * It is called with `force: true` when the API has just rejected the token in\n * hand, meaning a cached answer is known to be dead. Your own function can\n * ignore the argument — `DevicProvider` uses it to share one session across\n * every component without ever serving a refused token back.\n */\n getTenantSession?: (force?: boolean) => Promise<string | TenantSessionToken>;\n /**\n * Called when the session is dead and cannot be replaced — the API rejected\n * it and `getTenantSession` handed back the same expired token.\n *\n * Matters most when the session comes from a cookie with no way to renew it:\n * without this the widget simply stops answering, at the exact moment the\n * user's own login has also expired. Refresh the page, send them to log in,\n * or say something — but say it.\n */\n onSessionExpired?: () => void;\n}\n\n/** Renew this long before expiry, so a request never leaves with a dead token. */\nconst RENEWAL_MARGIN_MS = 60_000;\n\n/**\n * The expiry inside a JWT, in epoch milliseconds.\n *\n * Read rather than required, so the session source can return just the string.\n * Any failure means \"no idea\", and the token is then renewed only when the API\n * rejects it — correct, just less graceful.\n */\nfunction expiryOf(token: string): number | undefined {\n try {\n const payload = token.split(\".\")[1];\n if (!payload) return undefined;\n const json = atob(payload.replace(/-/g, \"+\").replace(/_/g, \"/\"));\n const exp = JSON.parse(json)?.exp;\n return typeof exp === \"number\" ? exp * 1000 : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Devic API client using native fetch\n */\nexport class DevicApiClient {\n private config: DevicApiClientConfig;\n private session?: { token: string; expiresAt?: number };\n /** In flight renewal, shared so a burst of calls fetches one token. */\n private renewing?: Promise<string>;\n /** So a page full of widgets reports one expiry, not one per widget. */\n private expiryReported = false;\n\n constructor(config: DevicApiClientConfig) {\n this.config = config;\n }\n\n /**\n * Update client configuration\n */\n setConfig(config: Partial<DevicApiClientConfig>): void {\n const previous = this.config;\n this.config = { ...this.config, ...config };\n // A new session source speaks for a different end user; keeping the old\n // token would show them the previous one's conversations.\n if (\n config.getTenantSession &&\n config.getTenantSession !== previous.getTenantSession\n ) {\n this.session = undefined;\n this.expiryReported = false;\n }\n }\n\n /** The credential for the next request, renewed if it is about to expire. */\n private async authorization(force = false): Promise<string> {\n if (!this.config.getTenantSession) return this.config.apiKey ?? \"\";\n\n const current = this.session;\n const stillGood =\n current &&\n (current.expiresAt === undefined ||\n current.expiresAt - Date.now() > RENEWAL_MARGIN_MS);\n if (stillGood && !force) return current.token;\n\n return this.renew(force);\n }\n\n private renew(force = false): Promise<string> {\n if (!this.renewing) {\n this.renewing = Promise.resolve(this.config.getTenantSession!(force))\n .then((result) => {\n const token = typeof result === \"string\" ? result : result.token;\n const declared =\n typeof result === \"string\"\n ? undefined\n : (result.expiresAt ??\n (result.expiresIn\n ? Date.now() + result.expiresIn * 1000\n : undefined));\n this.session = { token, expiresAt: declared ?? expiryOf(token) };\n return token;\n })\n .finally(() => {\n this.renewing = undefined;\n });\n }\n return this.renewing;\n }\n\n /**\n * Whether a rejected request is worth retrying, having got a live session.\n *\n * Takes the token the request actually went out with, not the current one:\n * with several requests in flight another may already have replaced it, and\n * comparing against the current one would read that success as a failure.\n *\n * False means the session is dead and cannot be replaced — a cookie set at\n * login, now expired, with nowhere to renew it from. That is worth telling\n * the host application about, once.\n */\n private async recoverSession(rejected: string): Promise<boolean> {\n if (this.session && this.session.token !== rejected) {\n this.expiryReported = false;\n return true;\n }\n\n let fresh: string | undefined;\n try {\n // Forced: whatever is cached upstream is the token that was just\n // refused, so asking for it again would only confirm the refusal.\n fresh = await this.renew(true);\n } catch {\n fresh = undefined;\n }\n if (fresh && fresh !== rejected) {\n this.expiryReported = false;\n return true;\n }\n\n if (!this.expiryReported) {\n this.expiryReported = true;\n this.config.onSessionExpired?.();\n }\n return false;\n }\n\n /**\n * Make an authenticated request to the API\n */\n private async request<T>(\n endpoint: string,\n options: RequestInit = {},\n isRetry = false,\n binary = false,\n ): Promise<T> {\n const url = `${this.config.baseUrl}${endpoint}`;\n const credential = await this.authorization();\n\n const headers: HeadersInit = {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${credential}`,\n \"devic-api-source\": \"ui\",\n ...options.headers,\n };\n\n const response = await fetch(url, {\n ...options,\n headers,\n });\n\n // A session can die between being checked and being used — a clock adrift,\n // a tab asleep for an hour, the key revoked. One retry with a fresh token\n // turns that into a pause instead of a broken conversation.\n if (response.status === 401 && this.config.getTenantSession && !isRetry) {\n if (await this.recoverSession(credential)) {\n return this.request<T>(endpoint, options, true, binary);\n }\n }\n\n if (!response.ok) {\n let errorData: ApiError;\n try {\n errorData = await response.json();\n } catch {\n errorData = {\n statusCode: response.status,\n message: response.statusText,\n };\n }\n // Not every refusal carries its own status in the body. A 409 raised with\n // an object (`{ error: 'CHAT_BUSY', ... }`) is returned verbatim, so\n // reading the code off the body alone leaves it undefined and every\n // `statusCode === 409` branch silently misses it.\n if (typeof errorData?.statusCode !== \"number\") {\n errorData = { ...errorData, statusCode: response.status };\n }\n throw new DevicApiError(errorData);\n }\n\n if (binary) return await response.blob() as T;\n if (response.status === 204) return undefined as T;\n // Handle responses that may have a wrapper structure\n const data = await response.json();\n\n // If the response has a data property, extract it (common wrapper pattern)\n if (data && typeof data === \"object\" && \"data\" in data) {\n return data.data as T;\n }\n\n return data as T;\n }\n\n private async liveRequest<T>(path: string, options: RequestInit = {}): Promise<T> {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 25000);\n try { return await this.request<T>(path, { ...options, signal: controller.signal }); }\n finally { clearTimeout(timeout); }\n }\n\n createLiveSession(assistantId: string, body: CreateLiveSessionRequest): Promise<LiveVoiceSession> {\n // No network-error retry: an ambiguous response could hide a paid session.\n return this.liveRequest(`/api/v1/assistants/${encodeURIComponent(assistantId)}/live/sessions`, {\n method: 'POST', body: JSON.stringify(body),\n });\n }\n\n getLiveSessionStatus(assistantId: string, sessionId: string): Promise<LiveVoiceSessionStatus> {\n return this.liveRequest(`/api/v1/assistants/${encodeURIComponent(assistantId)}/live/sessions/${encodeURIComponent(sessionId)}`);\n }\n\n closeLiveSession(assistantId: string, sessionId: string): Promise<{ closing: boolean; chatUid: string }> {\n return this.liveRequest(`/api/v1/assistants/${encodeURIComponent(assistantId)}/live/sessions/${encodeURIComponent(sessionId)}`, { method: 'DELETE', keepalive: true });\n }\n\n getLiveRecordings(assistantId: string, chatUid: string, offset = 0, limit = 100): Promise<LiveVoiceRecording[]> {\n return this.request(`/api/v1/assistants/${encodeURIComponent(assistantId)}/chats/${encodeURIComponent(chatUid)}/recordings?offset=${offset}&limit=${limit}`);\n }\n\n getLiveRecordingAudio(assistantId: string, chatUid: string, sessionId: string): Promise<Blob> {\n return this.request(`/api/v1/assistants/${encodeURIComponent(assistantId)}/chats/${encodeURIComponent(chatUid)}/recordings/${encodeURIComponent(sessionId)}/audio`, {}, false, true);\n }\n\n getLiveVoiceUsage(assistantId: string, chatUid: string): Promise<LiveVoiceUsage> {\n return this.request(`/api/v1/assistants/${encodeURIComponent(assistantId)}/chats/${encodeURIComponent(chatUid)}/live-usage`);\n }\n\n /** Get all assistant specializations. */\n async getAssistants(external = false): Promise<AssistantSpecialization[]> {\n const query = external ? \"?external=true\" : \"\";\n return this.request<AssistantSpecialization[]>(\n `/api/v1/assistants${query}`,\n );\n }\n\n /**\n * Get a specific assistant specialization\n */\n async getAssistant(identifier: string): Promise<AssistantSpecialization> {\n return this.request<AssistantSpecialization>(\n `/api/v1/assistants/${identifier}`,\n );\n }\n\n /**\n * Send a message to an assistant (sync mode)\n */\n async sendMessage(\n assistantId: string,\n dto: ProcessMessageDto,\n signal?: AbortSignal,\n ): Promise<ChatMessage[]> {\n return this.request<ChatMessage[]>(\n `/api/v1/assistants/${assistantId}/messages${dto.skipSummarization ? \"?skipSummarization=true\" : \"\"}`,\n {\n method: \"POST\",\n body: JSON.stringify(dto),\n signal,\n },\n );\n }\n\n /**\n * Send a message to an assistant (async mode)\n */\n async sendMessageAsync(\n assistantId: string,\n dto: ProcessMessageDto,\n ): Promise<AsyncResponse> {\n return this.request<AsyncResponse>(\n `/api/v1/assistants/${assistantId}/messages?async=true${dto.skipSummarization ? \"&skipSummarization=true\" : \"\"}`,\n {\n method: \"POST\",\n body: JSON.stringify(dto),\n },\n );\n }\n\n /**\n * Get the list of unique tags used across this account's chat histories.\n * Backed by GET /api/v1/assistants/tags. Useful for autocompletion / filters.\n */\n async getChatTags(): Promise<string[]> {\n return this.request<string[]>(`/api/v1/assistants/tags`);\n }\n\n /**\n * Follow a conversation in progress over its server-sent event stream.\n * Resolves when the server closes the stream; rejects when it is not a\n * stream at all (an older API) or the connection fails. `onActivity` fires\n * on every chunk received, keep-alives included.\n */\n async streamRealtimeHistory(\n assistantId: string,\n chatUid: string,\n onSnapshot: (snapshot: RealtimeChatHistory) => void | Promise<void>,\n signal: AbortSignal,\n onActivity?: () => void,\n ): Promise<void> {\n // `partial=1`: while only the reply being written changes, the API sends\n // `partial` frames with just that instead of the whole conversation.\n const url = `${this.config.baseUrl}/api/v1/assistants/${encodeURIComponent(assistantId)}/chats/${encodeURIComponent(chatUid)}/stream?partial=1`;\n let credential = await this.authorization();\n const open = () => fetch(url, { signal, headers: { Authorization: `Bearer ${credential}`, Accept: 'text/event-stream', 'devic-api-source': 'ui' } });\n let response = await open();\n if (response.status === 401 && this.config.getTenantSession && await this.recoverSession(credential)) {\n credential = await this.authorization(); response = await open();\n }\n await consumeChatStream(response, onSnapshot, onActivity);\n }\n\n async getRealtimeHistory(\n assistantId: string,\n chatUid: string,\n ): Promise<RealtimeChatHistory> {\n return this.request<RealtimeChatHistory>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/realtime`,\n );\n }\n\n /**\n * Get chat history for a specific conversation\n */\n async getChatHistory(\n assistantId: string,\n chatUid: string,\n options?: { tenantId?: string },\n ): Promise<ChatHistory> {\n const params = new URLSearchParams();\n if (options?.tenantId) {\n params.set(\"tenantId\", options.tenantId);\n }\n const query = params.toString();\n return this.request<ChatHistory>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}${query ? `?${query}` : \"\"}`,\n );\n }\n\n /**\n * List conversations for an assistant\n */\n async listConversations(\n assistantId: string,\n options?: {\n tenantId?: string;\n subtenantId?: string;\n offset?: number;\n limit?: number;\n },\n ): Promise<ListConversationsResponse> {\n const params = new URLSearchParams();\n if (options?.tenantId) {\n params.set(\"tenantId\", options.tenantId);\n }\n if (options?.subtenantId) {\n params.set(\"subtenantId\", options.subtenantId);\n }\n if (options?.offset != null) {\n params.set(\"offset\", String(options.offset));\n }\n if (options?.limit != null) {\n params.set(\"limit\", String(options.limit));\n }\n params.set(\"omitContent\", \"true\");\n const query = params.toString();\n return this.request<ListConversationsResponse>(\n `/api/v1/assistants/${assistantId}/chats${query ? `?${query}` : \"\"}`,\n );\n }\n\n /**\n * Send tool call responses back to the assistant.\n *\n * `toolSchemas` re-states the client-side tools for the continuation. The\n * API takes them from the first response of the batch, and without them the\n * turn resumes with no client tools at all — the model stops being able to\n * call them after the first round.\n */\n async sendToolResponses(\n assistantId: string,\n chatUid: string,\n responses: ToolCallResponse[],\n toolSchemas?: ModelInterfaceToolSchema[],\n ): Promise<AsyncResponse> {\n const body =\n toolSchemas?.length && responses.length > 0\n ? responses.map((response, index) =>\n index === 0 ? { ...response, tools: toolSchemas } : response,\n )\n : responses;\n\n return this.request<AsyncResponse>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/tool-response`,\n {\n method: \"POST\",\n body: JSON.stringify({ responses: body }),\n },\n );\n }\n\n /**\n * Submit feedback for a chat message\n */\n async submitChatFeedback(\n assistantId: string,\n chatUid: string,\n data: FeedbackSubmission,\n ): Promise<FeedbackEntry> {\n return this.request<FeedbackEntry>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/feedback`,\n {\n method: \"POST\",\n body: JSON.stringify(data),\n },\n );\n }\n\n /**\n * Get all feedback for a chat\n */\n async getChatFeedback(\n assistantId: string,\n chatUid: string,\n ): Promise<FeedbackEntry[]> {\n return this.request<FeedbackEntry[]>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/feedback`,\n );\n }\n\n /**\n * Get an agent thread by ID\n */\n async getThreadById(\n threadId: string,\n withTasks = false,\n ): Promise<AgentThreadDto> {\n const query = withTasks ? \"?withTasks=true\" : \"\";\n return this.request<AgentThreadDto>(\n `/api/v1/agents/threads/${threadId}${query}`,\n );\n }\n\n /**\n * Get agent details\n */\n async getAgentDetails(agentId: string): Promise<AgentDto> {\n return this.request<AgentDto>(`/api/v1/agents/${agentId}`);\n }\n\n /**\n * Get an AI-generated explanation of a thread's execution\n */\n async explainAgentThread(threadId: string): Promise<string> {\n return this.request<string>(\n `/api/v1/agents/threads/${threadId}/explain`,\n );\n }\n\n /**\n * Pause or resume a thread\n */\n async pauseResumeThread(\n threadId: string,\n action: \"paused\" | \"queued\",\n ): Promise<void> {\n return this.request<void>(\n `/api/v1/agents/threads/${threadId}/pause-resume`,\n {\n method: \"POST\",\n body: JSON.stringify({ action }),\n },\n );\n }\n\n /**\n * Handle thread approval (approve/reject)\n */\n async handleThreadApproval(\n threadId: string,\n approved: boolean,\n retry: boolean,\n message: string,\n ): Promise<void> {\n return this.request<void>(\n `/api/v1/agents/threads/${threadId}/approval`,\n {\n method: \"POST\",\n body: JSON.stringify({\n action: approved ? \"approved\" : \"rejected\",\n message,\n retry,\n }),\n },\n );\n }\n\n /**\n * Manually complete a thread\n */\n async completeThread(\n threadId: string,\n completionState: string,\n ): Promise<void> {\n return this.request<void>(\n `/api/v1/agents/threads/${threadId}/complete`,\n {\n method: \"POST\",\n body: JSON.stringify({ state: completionState }),\n },\n );\n }\n\n /**\n * Continue an existing thread with a new user message. The backend decides how\n * to apply it based on the thread state: a finished/failed/waiting thread is\n * re-queued and re-run with the message appended, while a running/queued thread\n * receives it on its next turn (right after the pending tool response). Returns\n * the updated thread.\n */\n async sendThreadMessage(\n threadId: string,\n message: string | Record<string, unknown>,\n ): Promise<AgentThreadDto> {\n return this.request<AgentThreadDto>(\n `/api/v1/agents/threads/${threadId}/messages`,\n {\n method: \"POST\",\n body: JSON.stringify({ message }),\n },\n );\n }\n\n /**\n * Stop an in-progress async chat.\n * The current LLM call or tool execution will finish, then the chat\n * will be marked as completed with the history accumulated so far.\n */\n async stopChat(\n assistantId: string,\n chatUid: string,\n ): Promise<StopChatResponse> {\n return this.request<StopChatResponse>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/stop`,\n { method: \"POST\" },\n );\n }\n\n /**\n * Upload a file and get a download URL\n */\n async uploadFile(\n file: File,\n isRetry = false,\n ): Promise<{ name: string; downloadUrl: string; fileType: string }> {\n const url = `${this.config.baseUrl}/api/v1/files/upload`;\n\n const formData = new FormData();\n formData.append(\"file\", file);\n\n const credential = await this.authorization();\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${credential}`,\n \"devic-api-source\": \"ui\",\n },\n body: formData,\n });\n\n // The FormData is rebuilt from `file` on the way back in, so unlike a\n // consumed stream this retry is safe.\n if (response.status === 401 && this.config.getTenantSession && !isRetry) {\n if (await this.recoverSession(credential)) return this.uploadFile(file, true);\n }\n\n if (!response.ok) {\n let errorData: { statusCode: number; message: string };\n try {\n errorData = await response.json();\n } catch {\n errorData = {\n statusCode: response.status,\n message: response.statusText,\n };\n }\n // See `request`: a body-shaped refusal need not carry its own status.\n if (typeof errorData?.statusCode !== \"number\") {\n errorData = { ...errorData, statusCode: response.status };\n }\n throw new DevicApiError(errorData);\n }\n\n const data = await response.json();\n if (data && typeof data === \"object\" && \"data\" in data) {\n return data.data;\n }\n return data;\n }\n\n /**\n * Transcribe audio to text using the /whisper endpoint.\n * Accepts either an audio binary (Blob/File, sent as multipart/form-data) or\n * a download URL string (sent as `audioUrl`). The backend stores the binary\n * and runs speech-to-text with Devic's own OpenAI key. Returns the text and a\n * `transcriptId` to attach to the resulting message.\n */\n async transcribeAudio(\n audio: Blob | string,\n options?: {\n language?: string;\n messageUid?: string;\n chatUid?: string;\n tenantId?: string;\n fileName?: string;\n },\n isRetry = false,\n ): Promise<WhisperTranscriptionResponse> {\n const url = `${this.config.baseUrl}/api/v1/whisper`;\n\n const formData = new FormData();\n if (typeof audio === \"string\") {\n formData.append(\"audioUrl\", audio);\n } else {\n formData.append(\"audio\", audio, options?.fileName || \"recording.webm\");\n }\n if (options?.language) formData.append(\"language\", options.language);\n if (options?.messageUid) formData.append(\"messageUid\", options.messageUid);\n if (options?.chatUid) formData.append(\"chatUid\", options.chatUid);\n if (options?.tenantId) formData.append(\"tenantId\", options.tenantId);\n\n const credential = await this.authorization();\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${credential}`,\n \"devic-api-source\": \"ui\",\n },\n body: formData,\n });\n\n if (response.status === 401 && this.config.getTenantSession && !isRetry) {\n if (await this.recoverSession(credential)) {\n return this.transcribeAudio(audio, options, true);\n }\n }\n\n if (!response.ok) {\n let errorData: { statusCode: number; message: string };\n try {\n errorData = await response.json();\n } catch {\n errorData = {\n statusCode: response.status,\n message: response.statusText,\n };\n }\n // See `request`: a body-shaped refusal need not carry its own status.\n if (typeof errorData?.statusCode !== \"number\") {\n errorData = { ...errorData, statusCode: response.status };\n }\n throw new DevicApiError(errorData);\n }\n\n const data = await response.json();\n if (data && typeof data === \"object\" && \"data\" in data) {\n return data.data;\n }\n return data;\n }\n\n /**\n * Fetch a single speech-to-text transcript by its id (the `transcriptId`\n * stored on a message). Returns the transcribed text and the download URL of\n * the source audio so the chat can offer playback of a dictated message.\n */\n async getTranscript(\n transcriptId: string,\n ): Promise<WhisperTranscriptionResponse> {\n return this.request<WhisperTranscriptionResponse>(\n `/api/v1/whisper/${encodeURIComponent(transcriptId)}`,\n );\n }\n\n /**\n * Get chat history content (full conversation after handoff)\n */\n async getChatHistoryContent(\n assistantId: string,\n chatUid: string,\n ): Promise<ChatMessage[]> {\n return this.request<ChatMessage[]>(\n `/api/v1/assistants/${assistantId}/chats/${chatUid}/content`,\n );\n }\n\n /**\n * Get the current usage limits + consumption for a tenant (or a specific\n * subtenant). Read-only — backed by `GET /api/v1/tenant-usage/:tenantId`\n * (or `/:tenantId/subtenants/:subtenantId`), which is part of the devic-ui\n * key preset. Returns the effective rules with their live consumption and the\n * active tier. Use it to render a usage bar.\n */\n async getTenantUsage(\n tenantId: string,\n subtenantId?: string,\n ): Promise<TenantUsage> {\n const path = subtenantId\n ? `/api/v1/tenant-usage/${encodeURIComponent(tenantId)}/subtenants/${encodeURIComponent(subtenantId)}`\n : `/api/v1/tenant-usage/${encodeURIComponent(tenantId)}`;\n return this.request<TenantUsage>(path);\n }\n\n /**\n * Get the durable per-window usage history for a tenant (or subtenant).\n * Read-only — backed by `GET /api/v1/tenant-usage/:tenantId/history`.\n */\n async getTenantUsageHistory(\n tenantId: string,\n options?: TenantUsageHistoryQuery,\n ): Promise<TenantUsageHistoryRow[]> {\n const params = new URLSearchParams();\n if (options?.subtenantId) params.set(\"subtenantId\", options.subtenantId);\n if (options?.scope) params.set(\"scope\", options.scope);\n if (options?.metric) params.set(\"metric\", options.metric);\n if (options?.windowUnit) params.set(\"windowUnit\", options.windowUnit);\n if (options?.from != null) params.set(\"from\", String(options.from));\n if (options?.to != null) params.set(\"to\", String(options.to));\n if (options?.limit != null) params.set(\"limit\", String(options.limit));\n if (options?.skip != null) params.set(\"skip\", String(options.skip));\n const query = params.toString();\n return this.request<TenantUsageHistoryRow[]>(\n `/api/v1/tenant-usage/${encodeURIComponent(tenantId)}/history${query ? `?${query}` : \"\"}`,\n );\n }\n\n private coreMemoryPath(\n assistantId: string,\n tenantId?: string,\n subtenantId?: string,\n entryId?: number,\n ): string {\n const params = new URLSearchParams();\n if (tenantId) params.set(\"tenantId\", tenantId);\n if (subtenantId) params.set(\"subtenantId\", subtenantId);\n const query = params.toString();\n return `/api/v1/memory/assistants/${encodeURIComponent(assistantId)}/core${\n entryId != null ? `/${entryId}` : \"\"\n }${query ? `?${query}` : \"\"}`;\n }\n\n /**\n * Core memory entries of the bucket the assistant resolves for a\n * tenant/subtenant combination — what the assistant permanently remembers\n * there. `enabled: false` when the assistant has no core memory tier.\n */\n async getCoreMemory(\n assistantId: string,\n options?: { tenantId?: string; subtenantId?: string },\n ): Promise<CoreMemoryList> {\n return this.request<CoreMemoryList>(\n this.coreMemoryPath(assistantId, options?.tenantId, options?.subtenantId),\n );\n }\n\n /** Add a standing core memory entry to the assistant's resolved bucket. */\n async addCoreMemoryEntry(\n assistantId: string,\n entry: { content: string; section?: string; pinned?: boolean },\n options?: { tenantId?: string; subtenantId?: string },\n ): Promise<{ entry?: CoreMemoryEntry; deduped: boolean }> {\n return this.request(\n this.coreMemoryPath(assistantId, options?.tenantId, options?.subtenantId),\n { method: \"POST\", body: JSON.stringify(entry) },\n );\n }\n\n /** Edit the text, section or pinned flag of a core memory entry. */\n async updateCoreMemoryEntry(\n assistantId: string,\n entryId: number,\n patch: { content?: string; section?: string; pinned?: boolean },\n options?: { tenantId?: string; subtenantId?: string },\n ): Promise<CoreMemoryEntry> {\n return this.request<CoreMemoryEntry>(\n this.coreMemoryPath(\n assistantId,\n options?.tenantId,\n options?.subtenantId,\n entryId,\n ),\n { method: \"PATCH\", body: JSON.stringify(patch) },\n );\n }\n\n /** Remove (archive) a core memory entry. */\n async deleteCoreMemoryEntry(\n assistantId: string,\n entryId: number,\n options?: { tenantId?: string; subtenantId?: string },\n ): Promise<{ removed: boolean; id?: number }> {\n return this.request(\n this.coreMemoryPath(\n assistantId,\n options?.tenantId,\n options?.subtenantId,\n entryId,\n ),\n { method: \"DELETE\" },\n );\n }\n\n // ── Connected apps of the end user ────────────────────────────────\n //\n // Backed by `/api/v1/tenant-integrations`: the tenant is resolved on the\n // server and never taken from the path. The tenant/subtenant sent here\n // identify the end user in front of the widget, so one tenant's accounts are\n // never reachable from another's.\n\n private integrationsQuery(options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n returnTo?: string;\n }): string {\n const params = new URLSearchParams({ assistantId: options.assistantId });\n if (options.tenantId) params.set(\"tenantId\", options.tenantId);\n if (options.subtenantId) params.set(\"subtenantId\", options.subtenantId);\n if (options.returnTo) params.set(\"returnTo\", options.returnTo);\n return params.toString();\n }\n\n /** Apps this assistant offers, with the end user's own connection status. */\n async getIntegrations(options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n }): Promise<Integration[]> {\n return this.request<Integration[]>(\n `/api/v1/tenant-integrations?${this.integrationsQuery(options)}`,\n );\n }\n\n /**\n * How this app can be connected, and what it asks the end user for.\n *\n * Scoped like everything else here: the schemes of an app this assistant\n * does not offer cannot be read by asking for them.\n */\n async getIntegrationAuth(\n app: string,\n options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n },\n ): Promise<{ schemes: IntegrationAuthScheme[] }> {\n return this.request(\n `/api/v1/tenant-integrations/${encodeURIComponent(app)}/auth?${this.integrationsQuery(options)}`,\n );\n }\n\n /**\n * Connects an account, in one of two ways.\n *\n * `connected: true` means it is done: the app authenticates with a key the\n * user supplied, so there is nobody to authorise with. Otherwise\n * `authorizationUrl` must be opened in a popup.\n *\n * `returnTo` is where the callback posts the result back to, and the server\n * refuses any value that does not match the origin this request came from —\n * so it cannot be turned into an open redirector.\n *\n * Rejects with a `DevicApiError` carrying `setupRequired` when the app needs\n * values that were not sent.\n */\n async connectIntegration(\n app: string,\n options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n returnTo?: string;\n /** Which scheme to use, from {@link getIntegrationAuth}. */\n authScheme?: string;\n /** This account's own values: its API key, its subdomain. */\n accountFields?: Record<string, string>;\n },\n ): Promise<{ connected: boolean; authorizationUrl?: string }> {\n const { authScheme, accountFields, ...query } = options;\n return this.request(\n `/api/v1/tenant-integrations/${encodeURIComponent(app)}/connect?${this.integrationsQuery(query)}`,\n {\n method: \"POST\",\n body: JSON.stringify({ authScheme, accountFields }),\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n /** Disconnects one of the end user's own accounts. */\n async disconnectIntegration(\n accountId: string,\n options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n },\n ): Promise<{ disconnected: boolean }> {\n return this.request(\n `/api/v1/tenant-integrations/accounts/${encodeURIComponent(accountId)}?${this.integrationsQuery(options)}`,\n { method: \"DELETE\" },\n );\n }\n\n /**\n * Drops the server's short-lived cache of the end user's connections.\n *\n * Called right after the OAuth popup closes: without it the freshly connected\n * app would keep reading as disconnected until the cache expires, which looks\n * like the connection silently failed.\n */\n async refreshIntegrations(options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n }): Promise<{ refreshed: boolean }> {\n return this.request(\n `/api/v1/tenant-integrations/refresh?${this.integrationsQuery(options)}`,\n { method: \"POST\" },\n );\n }\n\n // ---------------------------------------------------------------------------\n // MCP servers the end user connects for themselves\n // ---------------------------------------------------------------------------\n // Backed by `/api/v1/tenant-mcp`, scoped exactly like the integrations above:\n // the tenant is resolved on the server, never taken from the path. Sending a\n // `subtenantId` makes the connection that end user's own; omitting it puts it\n // on the tenant, where every one of its end users shares it.\n\n /** The MCP servers this assistant offers, and the ones this tenant connected. */\n async getMcpServers(options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n }): Promise<TenantMcpListing> {\n return this.request<TenantMcpListing>(\n `/api/v1/tenant-mcp?${this.integrationsQuery(options)}`,\n );\n }\n\n /**\n * Connects a server: one the developer offers (`templateId`) or one the end\n * user brings (`url`).\n *\n * `returnTo` is where the callback posts the result back to, and the server\n * refuses any value that does not match the origin this request came from —\n * so it cannot be turned into an open redirector.\n */\n async connectMcpServer(options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n returnTo?: string;\n templateId?: string;\n url?: string;\n name?: string;\n auth?: TenantMcpAuthInput;\n }): Promise<TenantMcpConnectResult> {\n const { templateId, url, name, auth, returnTo, ...query } = options;\n return this.request(`/api/v1/tenant-mcp?${this.integrationsQuery(query)}`, {\n method: \"POST\",\n // The scope travels in the body as well as the query string: it is what\n // decides whether this connection is the end user's own or the tenant's,\n // and the server reads it from there on writes.\n body: JSON.stringify({\n templateId,\n url,\n name,\n auth,\n returnTo,\n tenantId: options.tenantId,\n subtenantId: options.subtenantId,\n }),\n headers: { \"Content-Type\": \"application/json\" },\n });\n }\n\n /** Authorises again, for a server whose credentials expired or were revoked. */\n async reconnectMcpServer(\n id: string,\n options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n returnTo?: string;\n auth?: TenantMcpAuthInput;\n },\n ): Promise<TenantMcpConnectResult> {\n const { auth, returnTo, ...query } = options;\n return this.request(\n `/api/v1/tenant-mcp/${encodeURIComponent(id)}/reconnect?${this.integrationsQuery(query)}`,\n {\n method: \"POST\",\n body: JSON.stringify({\n auth,\n returnTo,\n tenantId: options.tenantId,\n subtenantId: options.subtenantId,\n }),\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n /** Disconnects one of the end user's own MCP servers. */\n async disconnectMcpServer(\n id: string,\n options: {\n assistantId: string;\n tenantId?: string;\n subtenantId?: string;\n },\n ): Promise<{ disconnected: boolean }> {\n return this.request(\n `/api/v1/tenant-mcp/${encodeURIComponent(id)}?${this.integrationsQuery(options)}`,\n { method: \"DELETE\" },\n );\n }\n}\n\n/**\n * Custom error class for API errors\n */\nexport class DevicApiError extends Error {\n public statusCode: number;\n public errorType?: string;\n /** Structured error details (e.g. usage-limit blocking info on a 429). */\n public details?: any;\n /** What connecting an app is still waiting for, when that is why it failed.\n * Carried whole because the fields *are* the form to render. */\n public setupRequired?: IntegrationSetupRequired;\n\n constructor(error: ApiError) {\n super(error.message);\n this.name = \"DevicApiError\";\n this.statusCode = error.statusCode;\n this.errorType = error.error;\n this.details = error.details;\n if ((error as any)?.code === \"INTEGRATION_SETUP_REQUIRED\") {\n this.setupRequired = error as unknown as IntegrationSetupRequired;\n }\n }\n}\n"],"names":["consumeChatStream"],"mappings":";;;;AAoFA;AACA,MAAM,iBAAiB,GAAG,KAAM;AAEhC;;;;;;AAMG;AACH,SAAS,QAAQ,CAAC,KAAa,EAAA;AAC7B,IAAA,IAAI;QACF,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnC,QAAA,IAAI,CAAC,OAAO;AAAE,YAAA,OAAO,SAAS;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAChE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG;AACjC,QAAA,OAAO,OAAO,GAAG,KAAK,QAAQ,GAAG,GAAG,GAAG,IAAI,GAAG,SAAS;IACzD;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,SAAS;IAClB;AACF;AAEA;;AAEG;MACU,cAAc,CAAA;AAQzB,IAAA,WAAA,CAAY,MAA4B,EAAA;;QAFhC,IAAA,CAAA,cAAc,GAAG,KAAK;AAG5B,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AStC,IAAA,WAAA,CAAY,KAAe,EAAA;AACzB,QAAA,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;AACpB,QAAA,IAAI,CAAC,IAAI,GAAG,eAAe;AAC3B,QAAA,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU;AAClC,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,KAAK;AAC5B,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO;AAC5B,QAAA,IAAK,KAAa,EAAE,IAAI,KAAK,4BAA4B,EAAE;AACzD,YAAA,IAAI,CAAC,aAAa,GAAG,KAA4C;QACnE;IACF;AACD;;;;;"}
|
|
@@ -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 /**\n * The message text.\n *\n * Declared as a string because that is what it is for every role a reader\n * cares about, but do not trust it blindly on a `guard_rail` message:\n * conversations stopped by a guardrail before the backend fix carry the raw\n * provider result object here instead. Guard a `typeof x === 'string'` check\n * around anything that treats it as text.\n */\n message?: string;\n data?: any;\n files?: MessageFile[];\n}\n\n/** Collapse either attachment shape into a single one the UI can render. */\nexport function normalizeMessageFile(file: MessageFile): {\n name: string;\n url: string;\n type: string;\n} {\n return {\n name: file.name,\n url: file.url || file.downloadUrl || '',\n type: file.type || file.fileType || 'other',\n };\n}\n\n/**\n * Tool call from the model\n */\nexport interface ToolCall {\n id: string;\n type: 'function';\n function: {\n name: string;\n arguments: string;\n };\n}\n\n/**\n * Chat message structure\n */\nexport interface ChatMessage {\n uid: string;\n role: 'user' | 'assistant' | 'developer' | 'system' | 'tool' | 'guard_rail';\n content: MessageContent;\n timestamp: number;\n chatUid?: string;\n tool_calls?: ToolCall[];\n tool_call_id?: string;\n summary?: string;\n /**\n * Where `content.message` came from, when the model did not write it.\n * `'finish_tool'`: the assistant is configured to require a tool call to\n * finish (\"Require Tool Use to Finish\") and the backend lifted the reply from\n * the finish tool's `message` argument, so it can be read without parsing\n * tool calls. Absent on replies the model wrote itself — use it to label the\n * bubble as produced by the tool.\n */\n contentSource?: string;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Present on user messages dictated by voice; the chat can use\n * it to fetch the source audio (GET /api/v1/whisper/:transcriptId) and offer\n * playback.\n */\n transcriptId?: string;\n /**\n * Original server uid, present when the UI adopted an optimistic uid for\n * this message to keep React keys stable. Server-side references (e.g.\n * memory recall anchors) match against it.\n */\n serverUid?: string;\n /**\n * Client-side only: the conversation was busy when this message was sent, so\n * it was accepted into the queue and is waiting its turn. Drawn as a message\n * that has not landed rather than as part of the conversation. Falls away on\n * its own once the message comes back inside the history.\n */\n queued?: boolean;\n /**\n * Client-side only: when this message was accepted into the queue. Used to\n * tell \"the server has not reported it yet\" from \"the server no longer has\n * it\", which the timestamp is the only honest way to decide.\n */\n queuedAt?: number;\n}\n\n/**\n * Previous conversation message for initialization\n */\nexport interface PreviousMessage {\n message: string;\n role: 'user' | 'assistant';\n}\n\n/**\n * Model interface tool schema following OpenAI function calling format\n */\nexport interface ModelInterfaceToolSchema {\n type: 'function';\n function: {\n name: string;\n description: string;\n parameters: {\n type: 'object';\n properties: Record<string, any>;\n required?: string[];\n };\n };\n}\n\n/**\n * Props passed to a response widget component.\n * The widget is responsible for collecting the user's response and\n * calling `submit` with the payload to resolve the tool call.\n */\nexport interface ResponseWidgetProps {\n /** The tool call this widget is responding to */\n toolCall: ToolCall;\n /** Parsed arguments from the tool call */\n params: any;\n /** Submit the tool response payload (sent as the tool call result to the model) */\n submit: (response: any) => void;\n /** Cancel the tool call. Sends an error response so the model can continue. */\n cancel?: (reason?: string) => void;\n /** Whether the widget is currently submitting */\n isSubmitting?: boolean;\n}\n\n/**\n * Interactive response widget configuration for a client-side tool.\n *\n * When the model calls a tool configured with a `responseWidget`, the\n * widget is rendered in the chat UI instead of executing a callback.\n * The user interacts with the widget, which calls `submit(response)` to\n * define the tool response sent back to the model.\n *\n * - `render: 'inline'` renders the widget in the message thread at the\n * position of the tool call. The text input remains enabled.\n * - `render: 'input'` replaces the chat input area with the widget\n * while it is pending. The text input is disabled until submission.\n */\nexport interface ResponseWidgetConfig {\n /** Where to render the widget */\n render: 'inline' | 'input';\n /** The widget component */\n component: React.ComponentType<ResponseWidgetProps>;\n}\n\n/**\n * Model interface tool definition for client-side tools.\n *\n * A tool must provide either a `callback` (executed automatically when\n * the model invokes the tool) or a `responseWidget` (renders UI for\n * the user to produce the tool response). Providing both is an error.\n */\nexport interface ModelInterfaceTool {\n toolName: string;\n schema: ModelInterfaceToolSchema;\n /** Executed automatically when the model calls this tool */\n callback?: (params: any) => Promise<any> | any;\n /** Interactive widget that collects the user's tool response */\n responseWidget?: ResponseWidgetConfig;\n}\n\n/**\n * Tool call response to send back to the API\n */\nexport interface ToolCallResponse {\n tool_call_id: string;\n content: any;\n role: 'tool';\n /**\n * The client-side tools still on offer for the rest of the turn. The API\n * reads them off the first response of the batch: leaving them out drops\n * the tools from the continuation, so the model cannot call them again.\n */\n tools?: ModelInterfaceToolSchema[];\n}\n\n/**\n * DTO for sending messages to the assistant\n */\nexport interface ProcessMessageDto {\n message: string;\n chatUid?: string;\n userName?: string;\n files?: ChatFile[];\n /** Tags to associate with this chat (top-level, distinct from `metadata`). */\n tags?: string[];\n metadata?: {\n promptTemplateParams?: Record<string, any>;\n tenantToken?: string;\n [key: string]: any;\n };\n tenantId?: string;\n previousConversation?: PreviousMessage[];\n enabledTools?: string[];\n provider?: string;\n model?: string;\n // Model interface protocol fields\n tools?: ModelInterfaceToolSchema[];\n applicationState?: Record<string, any>;\n skipSummarization?: boolean;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Sent so the conversation keeps a link to the original audio.\n */\n transcriptId?: string;\n}\n\n/**\n * Response from the /whisper speech-to-text endpoint.\n */\nexport interface WhisperTranscriptionResponse {\n /** Public id of the transcript; send it back as ProcessMessageDto.transcriptId. */\n transcriptId: string;\n /** Transcribed text. */\n text: string;\n /** Language hint used, if any. */\n language?: string;\n /** Download URL of the source audio. */\n audioUrl?: string;\n /** Transcription model used. */\n model?: string;\n}\n\n/**\n * Response from the assistant\n */\nexport interface AssistantResponse {\n messages: ChatMessage[];\n chatUid: string;\n inputTokens?: number;\n outputTokens?: number;\n}\n\n/**\n * Async mode response\n */\nexport interface AsyncResponse {\n chatUid: string;\n message?: string;\n error?: string;\n /**\n * The conversation could not take the message right now, so it was queued\n * instead of starting a run of its own. Still an acceptance: the answer comes\n * later, and may cover several messages at once.\n */\n queued?: boolean;\n /** How many messages are queued on this conversation, this one included. */\n queuePosition?: number;\n /** When the queued message reaches the model. */\n willProcess?: QueueDisposition;\n}\n\n/**\n * When a queued message will reach the model.\n *\n * `after_delay` is the one that is not about being busy: an idle conversation\n * on an assistant with an input delay collects what is written during the\n * window, so a message can come back queued with nothing in flight at all.\n */\nexport type QueueDisposition = 'after_delay' | 'next_turn' | 'on_resume';\n\n/** Response of the stop endpoint. */\nexport interface StopChatResponse {\n chatUid: string;\n message: string;\n /**\n * Queued messages the stop threw away — answering them would be the opposite\n * of what was asked. Handed back so their text can be put where the user\n * wrote it. Absent on an API older than this, and when nothing was queued.\n */\n discardedMessages?: ChatMessage[];\n}\n\n/**\n * Real-time chat history status.\n * `limit_exceeded` means the message was blocked before reaching the LLM\n * because a configured tenant/subtenant usage limit was reached.\n */\nexport type RealtimeStatus =\n | 'processing'\n | 'completed'\n | 'error'\n | 'waiting_for_tool_response'\n | 'handed_off'\n | 'limit_exceeded'\n /** Collecting messages during the assistant's input delay, before any run. */\n | 'buffering';\n\n/**\n * Details of a tenant/subtenant usage limit that blocked a message.\n * Returned on the realtime endpoint when status is `limit_exceeded`, and on\n * the HTTP 429 body (`details`) when a synchronous request is blocked.\n */\nexport interface TenantLimitExceeded {\n /** Human-readable message describing the block. */\n message?: string;\n /** The rule that triggered the block (scope, metric, window, limit…). */\n blockingRule?: {\n scope?: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n windowEvery?: number;\n limit?: number;\n };\n /** Current consumption in the blocking window. */\n current?: number;\n /** The limit that was reached. */\n limit?: number;\n /** Epoch ms when the blocking window resets and usage is allowed again. */\n resetsAt?: number;\n}\n\n/** One fact a long-term-memory recall surfaced. */\nexport interface RecalledMemoryFact {\n fact: string;\n relation: string;\n /** Source entity name of the graph edge, when the fact connects two. */\n source: string | null;\n /** Target entity name of the graph edge, when the fact connects two. */\n target: string | null;\n /** ISO date the fact became valid, if known. */\n validAt: string | null;\n}\n\n/** One graph entity a long-term-memory recall surfaced. */\nexport interface RecalledMemoryEntity {\n id: string;\n name: string;\n type: string;\n summary: string | null;\n}\n\n/** One previous-session turn a conversation-start recall carried over. */\nexport interface RecalledMemoryTurn {\n role: string;\n content: string;\n}\n\n/**\n * One structured long-term-memory recall event of a conversation: the facts,\n * entities and previous-session turns a recall surfaced, plus the uid of the\n * message that brought it in (`messageUid`: the initial user message, or the\n * assistant message carrying the memory tool call — resolvable through\n * `toolCallId` while the run is still in flight).\n */\nexport interface RecalledMemoryRecord {\n uid: string;\n messageUid?: string;\n toolCallId?: string;\n source:\n | 'conversation_start'\n | 'search_memory'\n | 'search_memory_nodes'\n | 'explore_memory_graph';\n query?: string;\n facts?: RecalledMemoryFact[];\n entities?: RecalledMemoryEntity[];\n turns?: RecalledMemoryTurn[];\n timestampMs: number;\n}\n\n/**\n * Snapshot of the core-memory block a conversation saw (audit trail): the\n * render revision plus the injected entries as structured items.\n */\nexport interface CoreMemorySnapshot {\n uid: string;\n revision: string;\n items: Array<{\n id: number;\n section: string;\n content: string;\n pinned: boolean;\n source: string;\n }>;\n entries: number;\n omitted: number;\n chars: number;\n timestampMs: number;\n}\n\n/**\n * Real-time chat history response\n */\nexport interface RealtimeChatHistory {\n /** Ephemeral provider output; never persisted or treated as a tool call. */\n streamingMessage?: ChatMessage;\n chatUID: string;\n clientUID: string;\n chatHistory: ChatMessage[];\n status: RealtimeStatus;\n lastUpdatedAt: number;\n pendingToolCalls?: ToolCall[];\n handedOffSubThreadId?: string;\n /** Present only when status is `limit_exceeded`. */\n limitExceeded?: TenantLimitExceeded;\n /**\n * Memory-recall events of the in-flight run — lets the UI show what the\n * assistant is recalling while the response is still processing.\n */\n recalledMemories?: RecalledMemoryRecord[];\n /**\n * Messages accepted into this conversation that the model has not seen yet.\n * Non-zero means more is coming: a `completed` status with messages still\n * queued is not the end of the exchange.\n */\n queuedMessages?: number;\n /**\n * The queued messages themselves. This is the conversation's queue, not the\n * caller's — it can include messages the same conversation received through\n * another channel. Absent on an API that does not return them, in which case\n * the widget falls back to its own optimistic copies.\n */\n pendingUserMessages?: ChatMessage[];\n /**\n * Compaction checkpoints of the in-flight run. A conversation that compacts\n * mid-run stops sending the messages above the cut immediately, so these\n * arrive here before they are persisted on the conversation.\n */\n compactions?: CompactionCheckpoint[];\n /** The compaction running right now, if any. */\n compaction?: CompactionActivity;\n}\n\n/**\n * A single usage rule with its current consumption (from GET\n * /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]).\n */\nexport interface TenantUsageRule {\n scope: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n /** Configured limit for the window. */\n limit: number;\n /** Current consumption in the active window. */\n current: number;\n /** Utilization percentage (0..100, capped). */\n percent: number;\n /** Epoch ms when the active window resets. */\n resetsAt?: number;\n /** Where the rule comes from ('tier' | 'adhoc'). */\n origin?: string;\n /** Tier the rule belongs to, if any. */\n tierId?: string;\n}\n\n/**\n * Response of GET /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]:\n * the effective usage rules with their current consumption + the active tier.\n */\nexport interface TenantUsage {\n tenantId: string;\n subtenantId?: string;\n tierId?: string;\n usage: TenantUsageRule[];\n}\n\n/**\n * A durable per-window usage history row (from GET\n * /api/v1/tenant-usage/:tenantId/history).\n */\nexport interface TenantUsageHistoryRow {\n clientUID: string;\n tenantId: string;\n subtenantId: string;\n scope: 'tenant' | 'subtenant';\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n windowKey: string;\n windowStart: number;\n windowEnd: number;\n /** Counted consumption (enforced). */\n consumption: number;\n /** Exempt consumption that did not count toward the limit, if any. */\n exemptConsumption?: number;\n limit: number;\n percent: number;\n tierId?: string;\n origin?: string;\n capturedAt: number;\n}\n\n/**\n * Options for querying tenant usage history.\n */\nexport interface TenantUsageHistoryQuery {\n subtenantId?: string;\n scope?: 'tenant' | 'subtenant';\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n /** Epoch ms lower bound (windowEnd >= from). */\n from?: number;\n /** Epoch ms upper bound (windowEnd <= to). */\n to?: number;\n limit?: number;\n skip?: number;\n}\n\n/**\n * Chat history structure\n */\n/** A concrete value carried verbatim through a compaction. */\nexport interface CompactionFact {\n kind: string;\n value: string;\n label?: string;\n}\n\n/** The structured body a compaction produced. */\nexport interface CompactionSummary {\n goal?: string;\n constraints?: string[];\n inProgress?: string;\n pending?: string[];\n decisions?: string[];\n data?: Array<{ label: string; value: string }>;\n done?: string[];\n openQuestions?: string[];\n /** Fallback when the model answered without structure. */\n raw?: string;\n}\n\n/**\n * One compaction of a conversation: the messages before its boundary folded\n * into a written summary plus the identifiers, paths and urls lifted out of\n * them verbatim. From then on the model receives the checkpoint instead of\n * those messages — which are still in the conversation, and still shown.\n *\n * Only the newest checkpoint is in force: each compaction merges the previous\n * summary into itself.\n */\nexport interface CompactionCheckpoint {\n uid: string;\n /** 1 for the first compaction of the conversation, 2 for the next… */\n index: number;\n timestampMs: number;\n trigger: 'auto' | 'manual';\n /** First message that still travels verbatim. */\n firstKeptMessageUid?: string;\n /** Last folded message: where the widget belongs in the conversation. */\n anchorMessageUid?: string;\n compactedMessageCount: number;\n summary: CompactionSummary;\n facts: CompactionFact[];\n tokensBefore: number;\n tokensAfter: number;\n provider?: string;\n model?: string;\n cost?: number;\n}\n\n/**\n * A compaction happening right now, from the realtime endpoint.\n *\n * A compaction is a model call of its own, taken between two assistant\n * messages, so a client that only knows `processing` shows a conversation\n * that appears to have stalled for a few seconds. Present while it runs and\n * on the single update that reports it finished.\n */\nexport interface CompactionActivity {\n state: 'running' | 'completed';\n startedAt: number;\n /**\n * What this pass is folding: the messages new since the last checkpoint.\n * Not the conversation's totals — a checkpoint's own\n * `compactedMessageCount` and `tokensBefore` are cumulative across every\n * compaction, so the two are on different scales and must not be paired.\n */\n messageCount: number;\n tokensBefore: number;\n /** Which checkpoint the pass produced, once it is done. */\n index?: number;\n finishedAt?: number;\n}\n\nexport interface ChatHistory {\n chatUID: string;\n clientUID: string;\n userUID: string;\n chatContent: ChatMessage[];\n name?: string;\n assistantSpecializationIdentifier: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n llm?: string;\n inputTokens?: number;\n outputTokens?: number;\n metadata?: Record<string, any>;\n tenantId?: string;\n handedOff?: boolean;\n handedOffSubThreadId?: string;\n handedOffToolCallId?: string;\n /** Structured long-term-memory recall events of the conversation. */\n recalledMemories?: RecalledMemoryRecord[];\n /** Audit trail of the core-memory blocks the conversation saw. */\n coreMemories?: CoreMemorySnapshot[];\n /** Compaction checkpoints of the conversation, oldest first. */\n compactions?: CompactionCheckpoint[];\n}\n\n/** One core memory entry (the always-injected tier), as returned by the memory API. */\nexport interface CoreMemoryEntry {\n id: number;\n section: string;\n content: string;\n source: string;\n pinned: boolean;\n supersedes: number | null;\n archivedAt: string | null;\n createdAt?: string;\n updatedAt?: string;\n}\n\n/** Deployment caps of the core memory tier. */\nexport interface CoreMemoryLimits {\n maxChars: number;\n maxEntries: number;\n maxEntryChars: number;\n}\n\n/**\n * Response of GET /api/v1/memory/assistants/:identifier/core — the entries\n * of the bucket the assistant resolves for a tenant/subtenant combination.\n */\nexport interface CoreMemoryList {\n /** False when the assistant does not have the core memory tier enabled. */\n enabled: boolean;\n /** The resolved bucket tuple (tenant/subtenant/owner dimensions). */\n bucket: { tenantId?: string; subtenantId?: string; entityId?: string };\n entries: CoreMemoryEntry[];\n limits?: CoreMemoryLimits;\n}\n\n/**\n * Assistant specialization info\n */\nexport interface AssistantSpecialization {\n identifier: string;\n name: string;\n description: string;\n state: 'active' | 'inactive' | 'coming_soon';\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n availableToolsGroups?: Array<{\n name: string;\n description?: string;\n uid?: string;\n iconUrl?: string;\n tools?: Array<{\n name: string;\n description: string;\n }>;\n }>;\n model?: string;\n isCustom?: boolean;\n creationTimestampMs?: number;\n /**\n * Whether this assistant offers MCP servers of the tenant's own.\n *\n * Same contract as `tenantIntegrations` below, absence included.\n */\n tenantMcpServers?: {\n enabled: boolean;\n /** Servers listed ready to connect. Says nothing about how many are connected. */\n count?: number;\n };\n /**\n * Whether this assistant offers connected apps to its tenants.\n *\n * **Absent means \"cannot tell\", not \"no\"** — an API older than this field\n * says nothing, and treating silence as a no would hide the connected-apps\n * button from anyone whose deployment has not caught up yet.\n */\n tenantIntegrations?: {\n enabled: boolean;\n /**\n * How many apps the catalogue offers. An upper bound — the listing drops\n * any the provider cannot resolve — and enough to size a placeholder.\n */\n count?: number;\n };\n /**\n * Whether this assistant accepts messages sent while the conversation is\n * busy, queueing them instead of refusing them.\n *\n * **Absent means no**, unlike `tenantIntegrations` above. Promising a queue\n * that does not exist is paid for with a 409 and with the user's text left in\n * the air, so silence is read as the safe answer rather than as the open one.\n */\n messageQueueEnabled?: boolean;\n /** How many messages may wait at once before further sends are refused. */\n maxQueuedMessages?: number;\n}\n\n/**\n * Summary of a conversation for listing\n */\nexport interface ConversationSummary {\n chatUID: string;\n name?: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n}\n\nexport interface ListConversationsResponse {\n histories: ConversationSummary[];\n total: number;\n offset: number;\n limit: number;\n}\n\n/**\n * API error response\n */\nexport interface ApiError {\n statusCode: number;\n message: string;\n error?: string;\n /** Optional structured details (e.g. usage-limit blocking info on a 429). */\n details?: any;\n}\n\n/**\n * Feedback submission request\n */\nexport interface FeedbackSubmission {\n messageId: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n}\n\n/**\n * Feedback entry response\n */\nexport interface FeedbackEntry {\n _id: string;\n requestId: string;\n chatUID?: string;\n threadId?: string;\n agentId?: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n creationTimestamp: string;\n lastEditTimestamp?: string;\n}\n\n/**\n * Agent thread states\n */\nexport enum AgentThreadState {\n QUEUED = 'queued',\n PROCESSING = 'processing',\n COMPLETED = 'completed',\n FAILED = 'failed',\n TERMINATED = 'terminated',\n PAUSED = 'paused',\n PAUSED_FOR_APPROVAL = 'paused_for_approval',\n APPROVAL_REJECTED = 'approval_rejected',\n WAITING_FOR_RESPONSE = 'waiting_for_response',\n PAUSED_FOR_RESUME = 'paused_for_resume',\n HANDED_OFF = 'handed_off',\n GUARDRAIL_TRIGGER = 'guardrail_trigger',\n}\n\n/**\n * Task within an agent thread\n */\nexport interface AgentTaskDto {\n _id?: string;\n title?: string;\n description?: string;\n completed: boolean;\n}\n\n/**\n * Agent thread DTO\n */\nexport interface AgentThreadDto {\n _id?: string;\n agentId: string;\n state: AgentThreadState;\n threadContent: ChatMessage[];\n tasks?: AgentTaskDto[];\n finishReason?: string;\n pausedReason?: string;\n name?: string;\n creationTimestampMs?: number;\n lastEditTimestampMs?: number;\n pauseUntil?: number;\n isSubthread?: boolean;\n parentThreadId?: string;\n subThreadToolCallId?: string;\n parentAgentId?: string;\n}\n\n/**\n * Agent details\n */\nexport interface AgentDto {\n _id?: string;\n name: string;\n description?: string;\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n agentId?: string;\n}\n\n/**\n * Hand-off tool response content\n */\nexport interface HandOffToolResponse {\n response: string;\n subthreadId: string;\n}\n\n/**\n * Represents a single tool call within a tool group\n */\nexport interface ToolGroupCall {\n name: string;\n input: any;\n output: any;\n toolCallId: string;\n}\n\n/**\n * Configuration for grouping consecutive tool calls under a single renderer\n */\nexport interface ToolGroupConfig {\n tools: string[];\n renderer: (calls: ToolGroupCall[]) => React.ReactNode;\n}\n\n/**\n * One of the end user's connected accounts for an app.\n *\n * The provider's own identifiers do not travel here beyond `id`, which the\n * client needs in order to name the account it wants disconnected — and which\n * the server re-checks against the caller's tenant on the way back in.\n */\nexport interface IntegrationAccount {\n id: string;\n status: string;\n connectedAt?: string;\n updatedAt?: string;\n /** True when the account exists but can no longer run tools. */\n needsReconnect?: boolean;\n statusReason?: string;\n}\n\n/**\n * One value the end user is asked for before an account can be connected —\n * their API key, the subdomain of their instance.\n *\n * Comes from the provider's own catalogue, so the form is rendered from this\n * rather than from anything app-specific: most apps do not authenticate with\n * credentials Devic holds, and there are hundreds of them.\n */\nexport interface IntegrationAuthField {\n name: string;\n label: string;\n type: string;\n required: boolean;\n description?: string;\n /** Prefilled — usually a provider endpoint most accounts should keep. */\n default?: string;\n /** Mask it on screen. */\n secret: boolean;\n}\n\n/**\n * One way of connecting an app.\n *\n * `redirect` schemes send the user to the provider; the rest are connected\n * with the values they type, without ever leaving the page.\n *\n * There is deliberately no field for the *application's* credentials: the\n * OAuth application belongs to the developer who embedded this widget, is\n * registered once for every tenant, and is never the end user's to supply.\n */\nexport interface IntegrationAuthScheme {\n /** The provider's own name for it: `OAUTH2`, `API_KEY`, … */\n mode: string;\n /** Credentials for this scheme are held for you — nothing to fill in. */\n composioManaged: boolean;\n redirect: boolean;\n /** What this account supplies. Empty for a scheme that asks nothing. */\n accountFields: IntegrationAuthField[];\n /** The provider's own setup guide, when there is one. */\n guideUrl?: string;\n}\n\n/**\n * The answer when connecting needs values that were not sent.\n *\n * `stage` decides who can act on it: `account` is the end user, and the form\n * asks them. `app` is the developer's OAuth application, which the end user\n * cannot register — so that case is shown as \"not available yet\" instead of a\n * form asking a stranger for someone else's client secret.\n */\nexport interface IntegrationSetupRequired {\n code: \"INTEGRATION_SETUP_REQUIRED\";\n message: string;\n toolkit: string;\n authScheme: string;\n stage: \"app\" | \"account\";\n fields: IntegrationAuthField[];\n guideUrl?: string;\n}\n\n/**\n * An app the assistant offers to its tenants, with the accounts THIS tenant\n * has connected. Never another tenant's.\n */\nexport interface Integration {\n /** App slug, e.g. `gmail`. */\n app: string;\n name: string;\n description?: string;\n logo?: string;\n /** True when at least one account is active. */\n connected: boolean;\n accounts: IntegrationAccount[];\n /** Event types the developer allows this tenant to switch on. */\n availableTriggers?: string[];\n}\n\n// ── MCP servers the end user connects for themselves ──────────────────────\n\nexport type TenantMcpAuthMode = \"oauth\" | \"header\" | \"none\";\n\n/** One of the end user's own MCP connections. */\nexport interface TenantMcpConnection {\n id: string;\n /**\n * What to put in `disabledIntegrations` to have this server sit a message\n * out. Sent by the API so the prefix that separates it from an app slug lives\n * on the server, in one place.\n */\n toggleId?: string;\n name?: string;\n url: string;\n /** The developer's template this came from, when it came from one. */\n templateId?: string;\n authMode?: TenantMcpAuthMode;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n tools?: string[];\n lastProbeStatus?: string;\n lastProbeError?: string;\n lastProbeTimestampMs?: number;\n /** Connected for the whole tenant, so every end user of it shares this. */\n shared: boolean;\n /** True when this end user may use it but not change or remove it. */\n readOnly: boolean;\n}\n\n/**\n * One row of the MCP panel: either a server the developer offers ready to\n * connect, or one this end user added.\n *\n * A single list rather than two, because that is what the panel draws — keeping\n * \"offered\" and \"connected\" apart would leave them out of step for a moment\n * after every connect.\n */\nexport interface TenantMcpServer {\n source: \"template\" | \"custom\";\n templateId?: string;\n name: string;\n url: string;\n description?: string;\n logoUrl?: string;\n authMode?: TenantMcpAuthMode;\n /** Header the credential travels in, for `header` servers. */\n headerName?: string;\n /** Whether the end user may supply their own OAuth application. */\n allowClientCredentials?: boolean;\n /** Null until this tenant connects it. */\n connection: TenantMcpConnection | null;\n}\n\nexport interface TenantMcpListing {\n offered: boolean;\n /** Whether adding a server of one's own is permitted. */\n allowCustom: boolean;\n limits: { maxServers: number; maxToolsPerServer: number; used: number };\n servers: TenantMcpServer[];\n}\n\n/** Credentials the end user supplies when connecting a server. */\nexport interface TenantMcpAuthInput {\n mode?: TenantMcpAuthMode;\n headerName?: string;\n headerValue?: string;\n upstreamOAuth?: { clientId?: string; clientSecret?: string; scopes?: string[] };\n}\n\n/**\n * What connecting answers with.\n *\n * `status: \"active\"` means it is done. `authorizationUrl` must be opened in a\n * popup. `requiresClientCredentials` means the server has no dynamic client\n * registration and the end user has to register an OAuth application with it\n * themselves, authorising `callbackUrl` as the redirect URI.\n */\nexport interface TenantMcpConnectResult {\n id: string;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n authorizationUrl?: string;\n requiresClientCredentials?: boolean;\n callbackUrl?: string;\n error?: string;\n}\n"],"names":["AgentThreadState"],"mappings":";;AA+CA;AACM,SAAU,oBAAoB,CAAC,IAAiB,EAAA;IAKpD,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,IAAI,EAAE;QACvC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,OAAO;KAC5C;AACH;AA6tBA;;AAEG;AACSA;AAAZ,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,qBAAA,CAAA,GAAA,qBAA2C;AAC3C,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,gBAAA,CAAA,sBAAA,CAAA,GAAA,sBAA6C;AAC7C,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACzC,CAAC,EAbWA,wBAAgB,KAAhBA,wBAAgB,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../src/api/types.ts"],"sourcesContent":["import type { AvatarStyle } from '../utils/avatar';\n\nimport type React from 'react';\n\n/**\n * File attachment for messages\n */\nexport interface ChatFile {\n name: string;\n downloadUrl?: string;\n fileType?: 'image' | 'document' | 'audio' | 'video' | 'other';\n}\n\n/**\n * Attachment as it appears on a message.\n *\n * Two shapes reach the UI for the same thing: the optimistic message built\n * locally on send uses `url`/`type`, while the history returned by the API\n * carries the stored `downloadUrl`/`fileType`. Both are accepted here; use\n * `normalizeMessageFile` before reading them.\n */\nexport interface MessageFile {\n name: string;\n url?: string;\n type?: string;\n downloadUrl?: string;\n fileType?: string;\n}\n\n/**\n * Message content structure\n */\nexport interface MessageContent {\n /**\n * The message text.\n *\n * Declared as a string because that is what it is for every role a reader\n * cares about, but do not trust it blindly on a `guard_rail` message:\n * conversations stopped by a guardrail before the backend fix carry the raw\n * provider result object here instead. Guard a `typeof x === 'string'` check\n * around anything that treats it as text.\n */\n message?: string;\n data?: any;\n files?: MessageFile[];\n}\n\n/** Collapse either attachment shape into a single one the UI can render. */\nexport function normalizeMessageFile(file: MessageFile): {\n name: string;\n url: string;\n type: string;\n} {\n return {\n name: file.name,\n url: file.url || file.downloadUrl || '',\n type: file.type || file.fileType || 'other',\n };\n}\n\n/**\n * Tool call from the model\n */\nexport interface ToolCall {\n id: string;\n type: 'function';\n function: {\n name: string;\n arguments: string;\n };\n}\n\n/**\n * Chat message structure\n */\nexport interface ChatMessage {\n uid: string;\n role: 'user' | 'assistant' | 'developer' | 'system' | 'tool' | 'guard_rail';\n content: MessageContent;\n timestamp: number;\n chatUid?: string;\n tool_calls?: ToolCall[];\n tool_call_id?: string;\n summary?: string;\n /**\n * Where `content.message` came from, when the model did not write it.\n * `'finish_tool'`: the assistant is configured to require a tool call to\n * finish (\"Require Tool Use to Finish\") and the backend lifted the reply from\n * the finish tool's `message` argument, so it can be read without parsing\n * tool calls. Absent on replies the model wrote itself — use it to label the\n * bubble as produced by the tool.\n */\n contentSource?: string;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Present on user messages dictated by voice; the chat can use\n * it to fetch the source audio (GET /api/v1/whisper/:transcriptId) and offer\n * playback.\n */\n transcriptId?: string;\n /**\n * Original server uid, present when the UI adopted an optimistic uid for\n * this message to keep React keys stable. Server-side references (e.g.\n * memory recall anchors) match against it.\n */\n serverUid?: string;\n /**\n * Client-side only: the conversation was busy when this message was sent, so\n * it was accepted into the queue and is waiting its turn. Drawn as a message\n * that has not landed rather than as part of the conversation. Falls away on\n * its own once the message comes back inside the history.\n */\n queued?: boolean;\n /**\n * Client-side only: when this message was accepted into the queue. Used to\n * tell \"the server has not reported it yet\" from \"the server no longer has\n * it\", which the timestamp is the only honest way to decide.\n */\n queuedAt?: number;\n}\n\n/**\n * Previous conversation message for initialization\n */\nexport interface PreviousMessage {\n message: string;\n role: 'user' | 'assistant';\n}\n\n/**\n * Model interface tool schema following OpenAI function calling format\n */\nexport interface ModelInterfaceToolSchema {\n type: 'function';\n function: {\n name: string;\n description: string;\n parameters: {\n type: 'object';\n properties: Record<string, any>;\n required?: string[];\n };\n };\n}\n\n/**\n * Props passed to a response widget component.\n * The widget is responsible for collecting the user's response and\n * calling `submit` with the payload to resolve the tool call.\n */\nexport interface ResponseWidgetProps {\n /** The tool call this widget is responding to */\n toolCall: ToolCall;\n /** Parsed arguments from the tool call */\n params: any;\n /** Submit the tool response payload (sent as the tool call result to the model) */\n submit: (response: any) => void;\n /** Cancel the tool call. Sends an error response so the model can continue. */\n cancel?: (reason?: string) => void;\n /** Whether the widget is currently submitting */\n isSubmitting?: boolean;\n}\n\n/**\n * Interactive response widget configuration for a client-side tool.\n *\n * When the model calls a tool configured with a `responseWidget`, the\n * widget is rendered in the chat UI instead of executing a callback.\n * The user interacts with the widget, which calls `submit(response)` to\n * define the tool response sent back to the model.\n *\n * - `render: 'inline'` renders the widget in the message thread at the\n * position of the tool call. The text input remains enabled.\n * - `render: 'input'` replaces the chat input area with the widget\n * while it is pending. The text input is disabled until submission.\n */\nexport interface ResponseWidgetConfig {\n /** Where to render the widget */\n render: 'inline' | 'input';\n /** The widget component */\n component: React.ComponentType<ResponseWidgetProps>;\n}\n\n/**\n * Model interface tool definition for client-side tools.\n *\n * A tool must provide either a `callback` (executed automatically when\n * the model invokes the tool) or a `responseWidget` (renders UI for\n * the user to produce the tool response). Providing both is an error.\n */\nexport interface ModelInterfaceTool {\n toolName: string;\n schema: ModelInterfaceToolSchema;\n /** Executed automatically when the model calls this tool */\n callback?: (params: any) => Promise<any> | any;\n /** Interactive widget that collects the user's tool response */\n responseWidget?: ResponseWidgetConfig;\n}\n\n/**\n * Tool call response to send back to the API\n */\nexport interface ToolCallResponse {\n tool_call_id: string;\n content: any;\n role: 'tool';\n /**\n * The client-side tools still on offer for the rest of the turn. The API\n * reads them off the first response of the batch: leaving them out drops\n * the tools from the continuation, so the model cannot call them again.\n */\n tools?: ModelInterfaceToolSchema[];\n}\n\n/**\n * DTO for sending messages to the assistant\n */\nexport interface ProcessMessageDto {\n disabledIntegrations?: string[];\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 subtenantId?: string;\n previousConversation?: PreviousMessage[];\n enabledTools?: string[];\n provider?: string;\n model?: string;\n // Model interface protocol fields\n tools?: ModelInterfaceToolSchema[];\n applicationState?: Record<string, any>;\n skipSummarization?: boolean;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Sent so the conversation keeps a link to the original audio.\n */\n transcriptId?: string;\n}\n\n/**\n * Response from the /whisper speech-to-text endpoint.\n */\nexport interface WhisperTranscriptionResponse {\n /** Public id of the transcript; send it back as ProcessMessageDto.transcriptId. */\n transcriptId: string;\n /** Transcribed text. */\n text: string;\n /** Language hint used, if any. */\n language?: string;\n /** Download URL of the source audio. */\n audioUrl?: string;\n /** Transcription model used. */\n model?: string;\n}\n\n/**\n * Response from the assistant\n */\nexport interface AssistantResponse {\n messages: ChatMessage[];\n chatUid: string;\n inputTokens?: number;\n outputTokens?: number;\n}\n\n/**\n * Async mode response\n */\nexport interface AsyncResponse {\n chatUid: string;\n message?: string;\n error?: string;\n /**\n * The conversation could not take the message right now, so it was queued\n * instead of starting a run of its own. Still an acceptance: the answer comes\n * later, and may cover several messages at once.\n */\n queued?: boolean;\n /** How many messages are queued on this conversation, this one included. */\n queuePosition?: number;\n /** When the queued message reaches the model. */\n willProcess?: QueueDisposition;\n}\n\n/**\n * When a queued message will reach the model.\n *\n * `after_delay` is the one that is not about being busy: an idle conversation\n * on an assistant with an input delay collects what is written during the\n * window, so a message can come back queued with nothing in flight at all.\n */\nexport type QueueDisposition = 'after_delay' | 'next_turn' | 'on_resume';\n\n/** Response of the stop endpoint. */\nexport interface StopChatResponse {\n chatUid: string;\n message: string;\n /**\n * Queued messages the stop threw away — answering them would be the opposite\n * of what was asked. Handed back so their text can be put where the user\n * wrote it. Absent on an API older than this, and when nothing was queued.\n */\n discardedMessages?: ChatMessage[];\n}\n\n/**\n * Real-time chat history status.\n * `limit_exceeded` means the message was blocked before reaching the LLM\n * because a configured tenant/subtenant usage limit was reached.\n */\nexport type RealtimeStatus =\n | 'processing'\n | 'completed'\n | 'error'\n | 'waiting_for_tool_response'\n | 'handed_off'\n | 'limit_exceeded'\n /** Collecting messages during the assistant's input delay, before any run. */\n | 'buffering';\n\n/**\n * Details of a tenant/subtenant usage limit that blocked a message.\n * Returned on the realtime endpoint when status is `limit_exceeded`, and on\n * the HTTP 429 body (`details`) when a synchronous request is blocked.\n */\nexport interface TenantLimitExceeded {\n /** Human-readable message describing the block. */\n message?: string;\n /** The rule that triggered the block (scope, metric, window, limit…). */\n blockingRule?: {\n scope?: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n windowEvery?: number;\n limit?: number;\n };\n /** Current consumption in the blocking window. */\n current?: number;\n /** The limit that was reached. */\n limit?: number;\n /** Epoch ms when the blocking window resets and usage is allowed again. */\n resetsAt?: number;\n}\n\n/** One fact a long-term-memory recall surfaced. */\nexport interface RecalledMemoryFact {\n fact: string;\n relation: string;\n /** Source entity name of the graph edge, when the fact connects two. */\n source: string | null;\n /** Target entity name of the graph edge, when the fact connects two. */\n target: string | null;\n /** ISO date the fact became valid, if known. */\n validAt: string | null;\n}\n\n/** One graph entity a long-term-memory recall surfaced. */\nexport interface RecalledMemoryEntity {\n id: string;\n name: string;\n type: string;\n summary: string | null;\n}\n\n/** One previous-session turn a conversation-start recall carried over. */\nexport interface RecalledMemoryTurn {\n role: string;\n content: string;\n}\n\n/**\n * One structured long-term-memory recall event of a conversation: the facts,\n * entities and previous-session turns a recall surfaced, plus the uid of the\n * message that brought it in (`messageUid`: the initial user message, or the\n * assistant message carrying the memory tool call — resolvable through\n * `toolCallId` while the run is still in flight).\n */\nexport interface RecalledMemoryRecord {\n uid: string;\n messageUid?: string;\n toolCallId?: string;\n source:\n | 'conversation_start'\n | 'search_memory'\n | 'search_memory_nodes'\n | 'explore_memory_graph';\n query?: string;\n facts?: RecalledMemoryFact[];\n entities?: RecalledMemoryEntity[];\n turns?: RecalledMemoryTurn[];\n timestampMs: number;\n}\n\n/**\n * Snapshot of the core-memory block a conversation saw (audit trail): the\n * render revision plus the injected entries as structured items.\n */\nexport interface CoreMemorySnapshot {\n uid: string;\n revision: string;\n items: Array<{\n id: number;\n section: string;\n content: string;\n pinned: boolean;\n source: string;\n }>;\n entries: number;\n omitted: number;\n chars: number;\n timestampMs: number;\n}\n\n/**\n * Real-time chat history response\n */\nexport interface RealtimeChatHistory {\n /** Ephemeral provider output; never persisted or treated as a tool call. */\n streamingMessage?: ChatMessage;\n chatUID: string;\n clientUID: string;\n chatHistory: ChatMessage[];\n status: RealtimeStatus;\n lastUpdatedAt: number;\n pendingToolCalls?: ToolCall[];\n handedOffSubThreadId?: string;\n /** Present only when status is `limit_exceeded`. */\n limitExceeded?: TenantLimitExceeded;\n /**\n * Memory-recall events of the in-flight run — lets the UI show what the\n * assistant is recalling while the response is still processing.\n */\n recalledMemories?: RecalledMemoryRecord[];\n /**\n * Messages accepted into this conversation that the model has not seen yet.\n * Non-zero means more is coming: a `completed` status with messages still\n * queued is not the end of the exchange.\n */\n queuedMessages?: number;\n /**\n * The queued messages themselves. This is the conversation's queue, not the\n * caller's — it can include messages the same conversation received through\n * another channel. Absent on an API that does not return them, in which case\n * the widget falls back to its own optimistic copies.\n */\n pendingUserMessages?: ChatMessage[];\n /**\n * Compaction checkpoints of the in-flight run. A conversation that compacts\n * mid-run stops sending the messages above the cut immediately, so these\n * arrive here before they are persisted on the conversation.\n */\n compactions?: CompactionCheckpoint[];\n /** The compaction running right now, if any. */\n compaction?: CompactionActivity;\n}\n\n/**\n * A single usage rule with its current consumption (from GET\n * /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]).\n */\nexport interface TenantUsageRule {\n scope: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n /** Configured limit for the window. */\n limit: number;\n /** Current consumption in the active window. */\n current: number;\n /** Utilization percentage (0..100, capped). */\n percent: number;\n /** Epoch ms when the active window resets. */\n resetsAt?: number;\n /** Where the rule comes from ('tier' | 'adhoc'). */\n origin?: string;\n /** Tier the rule belongs to, if any. */\n tierId?: string;\n}\n\n/**\n * Response of GET /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]:\n * the effective usage rules with their current consumption + the active tier.\n */\nexport interface TenantUsage {\n tenantId: string;\n subtenantId?: string;\n tierId?: string;\n usage: TenantUsageRule[];\n}\n\n/**\n * A durable per-window usage history row (from GET\n * /api/v1/tenant-usage/:tenantId/history).\n */\nexport interface TenantUsageHistoryRow {\n clientUID: string;\n tenantId: string;\n subtenantId: string;\n scope: 'tenant' | 'subtenant';\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n windowKey: string;\n windowStart: number;\n windowEnd: number;\n /** Counted consumption (enforced). */\n consumption: number;\n /** Exempt consumption that did not count toward the limit, if any. */\n exemptConsumption?: number;\n limit: number;\n percent: number;\n tierId?: string;\n origin?: string;\n capturedAt: number;\n}\n\n/**\n * Options for querying tenant usage history.\n */\nexport interface TenantUsageHistoryQuery {\n subtenantId?: string;\n scope?: 'tenant' | 'subtenant';\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n /** Epoch ms lower bound (windowEnd >= from). */\n from?: number;\n /** Epoch ms upper bound (windowEnd <= to). */\n to?: number;\n limit?: number;\n skip?: number;\n}\n\n/**\n * Chat history structure\n */\n/** A concrete value carried verbatim through a compaction. */\nexport interface CompactionFact {\n kind: string;\n value: string;\n label?: string;\n}\n\n/** The structured body a compaction produced. */\nexport interface CompactionSummary {\n goal?: string;\n constraints?: string[];\n inProgress?: string;\n pending?: string[];\n decisions?: string[];\n data?: Array<{ label: string; value: string }>;\n done?: string[];\n openQuestions?: string[];\n /** Fallback when the model answered without structure. */\n raw?: string;\n}\n\n/**\n * One compaction of a conversation: the messages before its boundary folded\n * into a written summary plus the identifiers, paths and urls lifted out of\n * them verbatim. From then on the model receives the checkpoint instead of\n * those messages — which are still in the conversation, and still shown.\n *\n * Only the newest checkpoint is in force: each compaction merges the previous\n * summary into itself.\n */\nexport interface CompactionCheckpoint {\n uid: string;\n /** 1 for the first compaction of the conversation, 2 for the next… */\n index: number;\n timestampMs: number;\n trigger: 'auto' | 'manual';\n /** First message that still travels verbatim. */\n firstKeptMessageUid?: string;\n /** Last folded message: where the widget belongs in the conversation. */\n anchorMessageUid?: string;\n compactedMessageCount: number;\n summary: CompactionSummary;\n facts: CompactionFact[];\n tokensBefore: number;\n tokensAfter: number;\n provider?: string;\n model?: string;\n cost?: number;\n}\n\n/**\n * A compaction happening right now, from the realtime endpoint.\n *\n * A compaction is a model call of its own, taken between two assistant\n * messages, so a client that only knows `processing` shows a conversation\n * that appears to have stalled for a few seconds. Present while it runs and\n * on the single update that reports it finished.\n */\nexport interface CompactionActivity {\n state: 'running' | 'completed';\n startedAt: number;\n /**\n * What this pass is folding: the messages new since the last checkpoint.\n * Not the conversation's totals — a checkpoint's own\n * `compactedMessageCount` and `tokensBefore` are cumulative across every\n * compaction, so the two are on different scales and must not be paired.\n */\n messageCount: number;\n tokensBefore: number;\n /** Which checkpoint the pass produced, once it is done. */\n index?: number;\n finishedAt?: number;\n}\n\nexport interface ChatHistory {\n chatUID: string;\n clientUID: string;\n userUID: string;\n chatContent: ChatMessage[];\n name?: string;\n assistantSpecializationIdentifier: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n llm?: string;\n inputTokens?: number;\n outputTokens?: number;\n metadata?: Record<string, any>;\n tenantId?: string;\n handedOff?: boolean;\n handedOffSubThreadId?: string;\n handedOffToolCallId?: string;\n /** Structured long-term-memory recall events of the conversation. */\n recalledMemories?: RecalledMemoryRecord[];\n /** Audit trail of the core-memory blocks the conversation saw. */\n coreMemories?: CoreMemorySnapshot[];\n /** Compaction checkpoints of the conversation, oldest first. */\n compactions?: CompactionCheckpoint[];\n}\n\n/** One core memory entry (the always-injected tier), as returned by the memory API. */\nexport interface CoreMemoryEntry {\n id: number;\n section: string;\n content: string;\n source: string;\n pinned: boolean;\n supersedes: number | null;\n archivedAt: string | null;\n createdAt?: string;\n updatedAt?: string;\n}\n\n/** Deployment caps of the core memory tier. */\nexport interface CoreMemoryLimits {\n maxChars: number;\n maxEntries: number;\n maxEntryChars: number;\n}\n\n/**\n * Response of GET /api/v1/memory/assistants/:identifier/core — the entries\n * of the bucket the assistant resolves for a tenant/subtenant combination.\n */\nexport interface CoreMemoryList {\n /** False when the assistant does not have the core memory tier enabled. */\n enabled: boolean;\n /** The resolved bucket tuple (tenant/subtenant/owner dimensions). */\n bucket: { tenantId?: string; subtenantId?: string; entityId?: string };\n entries: CoreMemoryEntry[];\n limits?: CoreMemoryLimits;\n}\n\n/**\n * Assistant specialization info\n */\nexport interface AssistantSpecialization {\n liveVoice?: import('./liveVoice.types').LiveVoiceConfiguration;\n identifier: string;\n name: string;\n description: string;\n state: 'active' | 'inactive' | 'coming_soon';\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n availableToolsGroups?: Array<{\n name: string;\n description?: string;\n uid?: string;\n iconUrl?: string;\n tools?: Array<{\n name: string;\n description: string;\n }>;\n }>;\n model?: string;\n isCustom?: boolean;\n creationTimestampMs?: number;\n /**\n * Whether this assistant offers MCP servers of the tenant's own.\n *\n * Same contract as `tenantIntegrations` below, absence included.\n */\n tenantMcpServers?: {\n enabled: boolean;\n /** Servers listed ready to connect. Says nothing about how many are connected. */\n count?: number;\n };\n /**\n * Whether this assistant offers connected apps to its tenants.\n *\n * **Absent means \"cannot tell\", not \"no\"** — an API older than this field\n * says nothing, and treating silence as a no would hide the connected-apps\n * button from anyone whose deployment has not caught up yet.\n */\n tenantIntegrations?: {\n enabled: boolean;\n /**\n * How many apps the catalogue offers. An upper bound — the listing drops\n * any the provider cannot resolve — and enough to size a placeholder.\n */\n count?: number;\n };\n /**\n * Whether this assistant accepts messages sent while the conversation is\n * busy, queueing them instead of refusing them.\n *\n * **Absent means no**, unlike `tenantIntegrations` above. Promising a queue\n * that does not exist is paid for with a 409 and with the user's text left in\n * the air, so silence is read as the safe answer rather than as the open one.\n */\n messageQueueEnabled?: boolean;\n /** How many messages may wait at once before further sends are refused. */\n maxQueuedMessages?: number;\n}\n\n/**\n * Summary of a conversation for listing\n */\nexport interface ConversationSummary {\n chatUID: string;\n name?: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n}\n\nexport interface ListConversationsResponse {\n histories: ConversationSummary[];\n total: number;\n offset: number;\n limit: number;\n}\n\n/**\n * API error response\n */\nexport interface ApiError {\n statusCode: number;\n message: string;\n error?: string;\n /** Optional structured details (e.g. usage-limit blocking info on a 429). */\n details?: any;\n}\n\n/**\n * Feedback submission request\n */\nexport interface FeedbackSubmission {\n messageId: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n}\n\n/**\n * Feedback entry response\n */\nexport interface FeedbackEntry {\n _id: string;\n requestId: string;\n chatUID?: string;\n threadId?: string;\n agentId?: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n creationTimestamp: string;\n lastEditTimestamp?: string;\n}\n\n/**\n * Agent thread states\n */\nexport enum AgentThreadState {\n QUEUED = 'queued',\n PROCESSING = 'processing',\n COMPLETED = 'completed',\n FAILED = 'failed',\n TERMINATED = 'terminated',\n PAUSED = 'paused',\n PAUSED_FOR_APPROVAL = 'paused_for_approval',\n APPROVAL_REJECTED = 'approval_rejected',\n WAITING_FOR_RESPONSE = 'waiting_for_response',\n PAUSED_FOR_RESUME = 'paused_for_resume',\n HANDED_OFF = 'handed_off',\n GUARDRAIL_TRIGGER = 'guardrail_trigger',\n}\n\n/**\n * Task within an agent thread\n */\nexport interface AgentTaskDto {\n _id?: string;\n title?: string;\n description?: string;\n completed: boolean;\n}\n\n/**\n * Agent thread DTO\n */\nexport interface AgentThreadDto {\n _id?: string;\n agentId: string;\n state: AgentThreadState;\n threadContent: ChatMessage[];\n tasks?: AgentTaskDto[];\n finishReason?: string;\n pausedReason?: string;\n name?: string;\n creationTimestampMs?: number;\n lastEditTimestampMs?: number;\n pauseUntil?: number;\n isSubthread?: boolean;\n parentThreadId?: string;\n subThreadToolCallId?: string;\n parentAgentId?: string;\n}\n\n/**\n * Agent details\n */\nexport interface AgentDto {\n _id?: string;\n name: string;\n description?: string;\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n agentId?: string;\n}\n\n/**\n * Hand-off tool response content\n */\nexport interface HandOffToolResponse {\n response: string;\n subthreadId: string;\n}\n\n/**\n * Represents a single tool call within a tool group\n */\nexport interface ToolGroupCall {\n name: string;\n input: any;\n output: any;\n toolCallId: string;\n}\n\n/**\n * Configuration for grouping consecutive tool calls under a single renderer\n */\nexport interface ToolGroupConfig {\n tools: string[];\n renderer: (calls: ToolGroupCall[]) => React.ReactNode;\n}\n\n/**\n * One of the end user's connected accounts for an app.\n *\n * The provider's own identifiers do not travel here beyond `id`, which the\n * client needs in order to name the account it wants disconnected — and which\n * the server re-checks against the caller's tenant on the way back in.\n */\nexport interface IntegrationAccount {\n id: string;\n status: string;\n connectedAt?: string;\n updatedAt?: string;\n /** True when the account exists but can no longer run tools. */\n needsReconnect?: boolean;\n statusReason?: string;\n}\n\n/**\n * One value the end user is asked for before an account can be connected —\n * their API key, the subdomain of their instance.\n *\n * Comes from the provider's own catalogue, so the form is rendered from this\n * rather than from anything app-specific: most apps do not authenticate with\n * credentials Devic holds, and there are hundreds of them.\n */\nexport interface IntegrationAuthField {\n name: string;\n label: string;\n type: string;\n required: boolean;\n description?: string;\n /** Prefilled — usually a provider endpoint most accounts should keep. */\n default?: string;\n /** Mask it on screen. */\n secret: boolean;\n}\n\n/**\n * One way of connecting an app.\n *\n * `redirect` schemes send the user to the provider; the rest are connected\n * with the values they type, without ever leaving the page.\n *\n * There is deliberately no field for the *application's* credentials: the\n * OAuth application belongs to the developer who embedded this widget, is\n * registered once for every tenant, and is never the end user's to supply.\n */\nexport interface IntegrationAuthScheme {\n /** The provider's own name for it: `OAUTH2`, `API_KEY`, … */\n mode: string;\n /** Credentials for this scheme are held for you — nothing to fill in. */\n composioManaged: boolean;\n redirect: boolean;\n /** What this account supplies. Empty for a scheme that asks nothing. */\n accountFields: IntegrationAuthField[];\n /** The provider's own setup guide, when there is one. */\n guideUrl?: string;\n}\n\n/**\n * The answer when connecting needs values that were not sent.\n *\n * `stage` decides who can act on it: `account` is the end user, and the form\n * asks them. `app` is the developer's OAuth application, which the end user\n * cannot register — so that case is shown as \"not available yet\" instead of a\n * form asking a stranger for someone else's client secret.\n */\nexport interface IntegrationSetupRequired {\n code: \"INTEGRATION_SETUP_REQUIRED\";\n message: string;\n toolkit: string;\n authScheme: string;\n stage: \"app\" | \"account\";\n fields: IntegrationAuthField[];\n guideUrl?: string;\n}\n\n/**\n * An app the assistant offers to its tenants, with the accounts THIS tenant\n * has connected. Never another tenant's.\n */\nexport interface Integration {\n /** App slug, e.g. `gmail`. */\n app: string;\n name: string;\n description?: string;\n logo?: string;\n /** True when at least one account is active. */\n connected: boolean;\n accounts: IntegrationAccount[];\n /** Event types the developer allows this tenant to switch on. */\n availableTriggers?: string[];\n}\n\n// ── MCP servers the end user connects for themselves ──────────────────────\n\nexport type TenantMcpAuthMode = \"oauth\" | \"header\" | \"none\";\n\n/** One of the end user's own MCP connections. */\nexport interface TenantMcpConnection {\n id: string;\n /**\n * What to put in `disabledIntegrations` to have this server sit a message\n * out. Sent by the API so the prefix that separates it from an app slug lives\n * on the server, in one place.\n */\n toggleId?: string;\n name?: string;\n url: string;\n /** The developer's template this came from, when it came from one. */\n templateId?: string;\n authMode?: TenantMcpAuthMode;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n tools?: string[];\n lastProbeStatus?: string;\n lastProbeError?: string;\n lastProbeTimestampMs?: number;\n /** Connected for the whole tenant, so every end user of it shares this. */\n shared: boolean;\n /** True when this end user may use it but not change or remove it. */\n readOnly: boolean;\n}\n\n/**\n * One row of the MCP panel: either a server the developer offers ready to\n * connect, or one this end user added.\n *\n * A single list rather than two, because that is what the panel draws — keeping\n * \"offered\" and \"connected\" apart would leave them out of step for a moment\n * after every connect.\n */\nexport interface TenantMcpServer {\n source: \"template\" | \"custom\";\n templateId?: string;\n name: string;\n url: string;\n description?: string;\n logoUrl?: string;\n authMode?: TenantMcpAuthMode;\n /** Header the credential travels in, for `header` servers. */\n headerName?: string;\n /** Whether the end user may supply their own OAuth application. */\n allowClientCredentials?: boolean;\n /** Null until this tenant connects it. */\n connection: TenantMcpConnection | null;\n}\n\nexport interface TenantMcpListing {\n offered: boolean;\n /** Whether adding a server of one's own is permitted. */\n allowCustom: boolean;\n limits: { maxServers: number; maxToolsPerServer: number; used: number };\n servers: TenantMcpServer[];\n}\n\n/** Credentials the end user supplies when connecting a server. */\nexport interface TenantMcpAuthInput {\n mode?: TenantMcpAuthMode;\n headerName?: string;\n headerValue?: string;\n upstreamOAuth?: { clientId?: string; clientSecret?: string; scopes?: string[] };\n}\n\n/**\n * What connecting answers with.\n *\n * `status: \"active\"` means it is done. `authorizationUrl` must be opened in a\n * popup. `requiresClientCredentials` means the server has no dynamic client\n * registration and the end user has to register an OAuth application with it\n * themselves, authorising `callbackUrl` as the redirect URI.\n */\nexport interface TenantMcpConnectResult {\n id: string;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n authorizationUrl?: string;\n requiresClientCredentials?: boolean;\n callbackUrl?: string;\n error?: string;\n}\n"],"names":["AgentThreadState"],"mappings":";;AA+CA;AACM,SAAU,oBAAoB,CAAC,IAAiB,EAAA;IAKpD,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,IAAI,EAAE;QACvC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,OAAO;KAC5C;AACH;AAguBA;;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;;;;"}
|
|
@@ -26,7 +26,9 @@ var IntegrationsToggle = require('../IntegrationsModal/IntegrationsToggle.js');
|
|
|
26
26
|
var integrationChoice = require('../IntegrationsModal/integrationChoice.js');
|
|
27
27
|
var avatar = require('../../utils/avatar.js');
|
|
28
28
|
|
|
29
|
+
const LiveVoicePanel = React.lazy(() => Promise.resolve().then(function () { return require('./LiveVoicePanel.js'); }));
|
|
29
30
|
const DEFAULT_OPTIONS = {
|
|
31
|
+
liveVoice: { enabled: false },
|
|
30
32
|
position: 'right',
|
|
31
33
|
width: '100%',
|
|
32
34
|
defaultOpen: false,
|
|
@@ -219,9 +221,12 @@ function ChatDrawerInner({ assistantId, chatUid: initialChatUid, options = {}, e
|
|
|
219
221
|
onChatCreated: handleChatCreated,
|
|
220
222
|
onFileUpload,
|
|
221
223
|
messageQueue: mergedOptions.messageQueue,
|
|
224
|
+
liveVoice: mergedOptions.liveVoice,
|
|
222
225
|
debug: mergedOptions.debug,
|
|
223
226
|
});
|
|
224
227
|
// Fetch assistant avatar when showAvatar is enabled
|
|
228
|
+
React.useEffect(() => { if (!isOpen)
|
|
229
|
+
void chat.voice.stop(); }, [isOpen, chat.voice.stop]);
|
|
225
230
|
const context = DevicContext.useOptionalDevicContext();
|
|
226
231
|
const resolvedApiKey = apiKey || context?.apiKey;
|
|
227
232
|
// The session source, when the page authenticates with one. Every client
|
|
@@ -249,7 +254,8 @@ function ChatDrawerInner({ assistantId, chatUid: initialChatUid, options = {}, e
|
|
|
249
254
|
client: infoClient,
|
|
250
255
|
baseUrl: resolvedBaseUrl,
|
|
251
256
|
credential: resolvedApiKey || 'session',
|
|
252
|
-
enabled: (!!mergedOptions.
|
|
257
|
+
enabled: (!!mergedOptions.liveVoice?.enabled && isOpen) ||
|
|
258
|
+
(!!mergedOptions.showAvatar && !mergedOptions.avatarUrl) ||
|
|
253
259
|
(mergedOptions.showIntegrationsButton !== false && isOpen),
|
|
254
260
|
});
|
|
255
261
|
// The host's own image wins: an assistant carries one image for everybody, so
|
|
@@ -742,7 +748,8 @@ function ChatDrawerInner({ assistantId, chatUid: initialChatUid, options = {}, e
|
|
|
742
748
|
? t(mergedOptions.title)
|
|
743
749
|
: 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: t(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": t('New chat'), title: t('New chat'), children: jsxRuntime.jsx(PlusIcon, {}) }), !isInline && (jsxRuntime.jsx("button", { className: "devic-drawer-close", onClick: handleClose, type: "button", "aria-label": t('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
|
|
744
750
|
? chat.recalledMemories
|
|
745
|
-
: undefined, recalledMemoriesRenderer: mergedOptions.recalledMemoriesRenderer, compactions: mergedOptions.showCompaction ? chat.compactions : undefined, compaction: mergedOptions.showCompaction ? chat.compaction : undefined, compactionRenderer: mergedOptions.compactionRenderer, guardrailRenderer: mergedOptions.guardrailRenderer, expandableCompaction: mergedOptions.expandableCompaction }), mergedOptions.customPromptBox ? (jsxRuntime.jsxs("div", { className: "devic-input-area", children: [limitBannerNode, usageBarNode, integrationsHintNode, queueNoticeNode, mergedOptions.customPromptBox({
|
|
751
|
+
: undefined, recalledMemoriesRenderer: mergedOptions.recalledMemoriesRenderer, compactions: mergedOptions.showCompaction ? chat.compactions : undefined, compaction: mergedOptions.showCompaction ? chat.compaction : undefined, compactionRenderer: mergedOptions.compactionRenderer, guardrailRenderer: mergedOptions.guardrailRenderer, expandableCompaction: mergedOptions.expandableCompaction }), mergedOptions.liveVoice?.enabled && jsxRuntime.jsx(React.Suspense, { fallback: null, children: jsxRuntime.jsx(LiveVoicePanel, { voice: chat.voice, client: infoClient, assistantId: assistantId, chatUid: chat.chatUid, canStart: isOpen && assistantInfo$1.assistant?.liveVoice?.enabled === true && !chat.isLoading && !chat.handedOff && !chat.limitExceeded && !inputWidget && inlineWidgets.length === 0, recordSessions: assistantInfo$1.assistant?.liveVoice?.recordSessions, children: chat.voice.active && !inputWidget ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [limitBannerNode, usageBarNode, queueNoticeNode] }) : null }) }), chat.voice.active && !inputWidget ? null : Boolean(mergedOptions.customPromptBox) && !(chat.voice.active && inputWidget) ? (jsxRuntime.jsxs("div", { className: "devic-input-area", children: [limitBannerNode, usageBarNode, integrationsHintNode, queueNoticeNode, mergedOptions.customPromptBox({
|
|
752
|
+
voice: chat.voice,
|
|
746
753
|
sendMessage: handleSend,
|
|
747
754
|
transcribeAudio,
|
|
748
755
|
stop: chat.stopChat,
|