🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(openapi): add the async IM channel and push-token REST resources (#20440)
Arvin Xu3bfb309aad35
diff --git a/packages/openapi/openapi.yml b/packages/openapi/openapi.ymlindex b62a3f817a6..5d2d05aba6e 100644--- a/packages/openapi/openapi.yml+++ b/packages/openapi/openapi.yml@@ -12686,6 +12686,432 @@ paths:agentId:type: stringminLength: 1+ /api/v1/im/messages:+ post:+ operationId: sendImMessage+ summary: Send a message to an agent; the reply arrives asynchronously via sync+ tags:+ - im+ responses:+ "200":+ content:+ application/json:+ schema:+ additionalProperties: false+ properties:+ data:+ additionalProperties: false+ properties:+ accepted:+ type: boolean+ operationId:+ type:+ - string+ - "null"+ topicId:+ type: string+ userMessage:+ additionalProperties: false+ properties:+ content:+ type: string+ createdAt:+ format: date-time+ type: string+ error:+ type: boolean+ id:+ type: string+ role:+ enum:+ - assistant+ - user+ type: string+ required:+ - content+ - createdAt+ - error+ - id+ - role+ type: object+ required:+ - accepted+ - operationId+ - topicId+ - userMessage+ type: object+ message:+ type: string+ success:+ const: true+ type: boolean+ timestamp:+ format: date-time+ type: string+ required:+ - success+ - timestamp+ type: object+ description: Successful response+ "400":+ description: Validation Error+ content:+ application/json:+ schema:+ type: object+ properties:+ success:+ type: boolean+ enum:+ - false+ error:+ type: array+ items: {}+ data: {}+ required:+ - success+ - error+ - data+ "401":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Authentication required+ "403":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Insufficient permission+ "404":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Resource not found+ "409":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Resource conflict+ "429":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Rate limit exceeded+ "500":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Internal server error+ requestBody:+ required: true+ content:+ application/json:+ schema:+ type: object+ properties:+ agentId:+ type: string+ minLength: 1+ clientMessageId:+ type: string+ pattern: ^msg_[\w-]{8,64}$+ content:+ type: string+ minLength: 1+ maxLength: 100000+ topicId:+ anyOf:+ - type: string+ minLength: 1+ - type: "null"+ required:+ - agentId+ - content+ /api/v1/im/topics/{topicId}/sync:+ get:+ operationId: syncImTopic+ summary: Long-poll a conversation for whole new messages, typing and read receipts+ tags:+ - im+ responses:+ "200":+ content:+ application/json:+ schema:+ additionalProperties: false+ properties:+ data:+ additionalProperties: false+ properties:+ cursor:+ type: string+ messages:+ items:+ additionalProperties: false+ properties:+ content:+ type: string+ createdAt:+ format: date-time+ type: string+ error:+ type: boolean+ id:+ type: string+ role:+ enum:+ - assistant+ - user+ type: string+ required:+ - content+ - createdAt+ - error+ - id+ - role+ type: object+ type: array+ readUpTo:+ anyOf:+ - additionalProperties: false+ properties:+ messageId:+ type: string+ readAt:+ format: date-time+ type: string+ required:+ - messageId+ - readAt+ type: object+ - type: "null"+ state:+ type: string+ typing:+ type: boolean+ unread:+ minimum: 0+ type: integer+ required:+ - cursor+ - messages+ - readUpTo+ - state+ - typing+ - unread+ type: object+ message:+ type: string+ success:+ const: true+ type: boolean+ timestamp:+ format: date-time+ type: string+ required:+ - success+ - timestamp+ type: object+ description: Successful response+ "400":+ description: Validation Error+ content:+ application/json:+ schema:+ type: object+ properties:+ success:+ type: boolean+ enum:+ - false+ error:+ type: array+ items: {}+ data: {}+ required:+ - success+ - error+ - data+ "401":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Authentication required+ "403":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Insufficient permission+ "404":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Resource not found+ "409":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Resource conflict+ "429":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Rate limit exceeded+ "500":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Internal server error+ parameters:+ - in: path+ name: topicId+ schema:+ type: string+ minLength: 1+ required: true+ - in: query+ name: cursor+ schema:+ type: string+ pattern: ^\d+(_[\w-]{1,128})?$+ - in: query+ name: limit+ schema:+ type: integer+ minimum: 1+ maximum: 200+ - in: query+ name: state+ schema:+ type: string+ maxLength: 200+ - in: query+ name: waitMs+ schema:+ type: integer+ minimum: 0+ maximum: 25000+ /api/v1/im/topics/{topicId}/read:+ post:+ operationId: markImTopicRead+ summary: Mark the agent's messages read up to a message+ tags:+ - im+ responses:+ "200":+ content:+ application/json:+ schema:+ additionalProperties: false+ properties:+ data:+ additionalProperties: false+ properties:+ unread:+ minimum: 0+ type: integer+ required:+ - unread+ type: object+ message:+ type: string+ success:+ const: true+ type: boolean+ timestamp:+ format: date-time+ type: string+ required:+ - success+ - timestamp+ type: object+ description: Successful response+ "400":+ description: Validation Error+ content:+ application/json:+ schema:+ type: object+ properties:+ success:+ type: boolean+ enum:+ - false+ error:+ type: array+ items: {}+ data: {}+ required:+ - success+ - error+ - data+ "401":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Authentication required+ "403":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Insufficient permission+ "404":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Resource not found+ "409":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Resource conflict+ "429":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Rate limit exceeded+ "500":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Internal server error+ parameters:+ - in: path+ name: topicId+ schema:+ type: string+ minLength: 1+ required: true+ requestBody:+ required: true+ content:+ application/json:+ schema:+ type: object+ properties:+ messageId:+ type: string+ minLength: 1+ required:+ - messageId/api/v1/knowledge-bases:get:operationId: getApiV1KnowledgeBases@@ -18304,6 +18730,227 @@ paths:description: Internal server errortags:- providers+ /api/v1/push-tokens/{deviceId}:+ put:+ operationId: registerPushToken+ summary: Register or rotate this device's push token+ tags:+ - push-tokens+ responses:+ "200":+ content:+ application/json:+ schema:+ additionalProperties: false+ properties:+ data:+ additionalProperties: false+ properties:+ deviceId:+ type: string+ platform:+ type: string+ required:+ - deviceId+ - platform+ type: object+ message:+ type: string+ success:+ const: true+ type: boolean+ timestamp:+ format: date-time+ type: string+ required:+ - success+ - timestamp+ type: object+ description: Successful response+ "400":+ description: Validation Error+ content:+ application/json:+ schema:+ type: object+ properties:+ success:+ type: boolean+ enum:+ - false+ error:+ type: array+ items: {}+ data: {}+ required:+ - success+ - error+ - data+ "401":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Authentication required+ "403":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Insufficient permission+ "404":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Resource not found+ "409":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Resource conflict+ "429":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Rate limit exceeded+ "500":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Internal server error+ parameters:+ - in: path+ name: deviceId+ schema:+ type: string+ minLength: 1+ maxLength: 200+ required: true+ requestBody:+ required: true+ content:+ application/json:+ schema:+ type: object+ properties:+ appVersion:+ type: string+ maxLength: 64+ expoToken:+ type: string+ minLength: 1+ maxLength: 512+ locale:+ type: string+ maxLength: 32+ platform:+ type: string+ enum:+ - ios+ - android+ required:+ - expoToken+ - platform+ delete:+ operationId: unregisterPushToken+ summary: Stop pushing to this device (sign-out)+ tags:+ - push-tokens+ responses:+ "200":+ content:+ application/json:+ schema:+ additionalProperties: false+ properties:+ data:+ type: "null"+ message:+ type: string+ success:+ const: true+ type: boolean+ timestamp:+ format: date-time+ type: string+ required:+ - success+ - timestamp+ type: object+ description: Successful response+ "400":+ description: Validation Error+ content:+ application/json:+ schema:+ type: object+ properties:+ success:+ type: boolean+ enum:+ - false+ error:+ type: array+ items: {}+ data: {}+ required:+ - success+ - error+ - data+ "401":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Authentication required+ "403":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Insufficient permission+ "404":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Resource not found+ "409":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Resource conflict+ "429":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Rate limit exceeded+ "500":+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/ApiError"+ description: Internal server error+ parameters:+ - in: path+ name: deviceId+ schema:+ type: string+ minLength: 1+ maxLength: 200+ required: true+ - in: query+ name: expoToken+ schema:+ type: string+ minLength: 1+ maxLength: 512/api/v1/responses:post:operationId: postApiV1Responsesdiff --git a/packages/openapi/src/controllers/im.controller.ts b/packages/openapi/src/controllers/im.controller.tsnew file mode 100644index 00000000000..145988bb5e4--- /dev/null+++ b/packages/openapi/src/controllers/im.controller.ts@@ -0,0 +1,80 @@+import type { Context } from 'hono';++import { BaseController } from '../common/base.controller';+import { ImRestService } from '../services/im.service';+import type {+ ImReadRequest,+ ImSendRequest,+ ImSyncQuery,+ ImTopicParam,+ PushTokenParam,+ PushTokenRegisterRequest,+ PushTokenUnregisterQuery,+} from '../types/im.type';++/** IM channel controller — send, sync (long-poll), read receipts, push tokens. */+export class ImController extends BaseController {+ private async service(c: Context): Promise<ImRestService> {+ return new ImRestService(await this.getDatabase(), this.getUserId(c), this.getWorkspaceId(c));+ }++ /** POST /api/v1/im/messages */+ async send(c: Context): Promise<Response> {+ try {+ const body = await this.getBody<ImSendRequest>(c);+ const service = await this.service(c);+ return this.success(c, await service.send(body), 'Message received');+ } catch (error) {+ return this.handleError(c, error);+ }+ }++ /** GET /api/v1/im/topics/:topicId/sync */+ async sync(c: Context): Promise<Response> {+ try {+ const { topicId } = this.getParams<ImTopicParam>(c);+ const query = this.getQuery<ImSyncQuery>(c);+ const service = await this.service(c);+ return this.success(c, await service.sync(topicId, query));+ } catch (error) {+ return this.handleError(c, error);+ }+ }++ /** POST /api/v1/im/topics/:topicId/read */+ async markRead(c: Context): Promise<Response> {+ try {+ const { topicId } = this.getParams<ImTopicParam>(c);+ const body = await this.getBody<ImReadRequest>(c);+ const service = await this.service(c);+ return this.success(c, await service.markRead(topicId, body), 'Marked as read');+ } catch (error) {+ return this.handleError(c, error);+ }+ }++ /** PUT /api/v1/push-tokens/:deviceId */+ async registerPushToken(c: Context): Promise<Response> {+ try {+ const { deviceId } = this.getParams<PushTokenParam>(c);+ const body = await this.getBody<PushTokenRegisterRequest>(c);+ const service = await this.service(c);+ return this.success(c, await service.registerPushToken(deviceId, body), 'Device registered');+ } catch (error) {+ return this.handleError(c, error);+ }+ }++ /** DELETE /api/v1/push-tokens/:deviceId */+ async unregisterPushToken(c: Context): Promise<Response> {+ try {+ const { deviceId } = this.getParams<PushTokenParam>(c);+ const { expoToken } = this.getQuery<PushTokenUnregisterQuery>(c);+ const service = await this.service(c);+ await service.unregisterPushToken(deviceId, expoToken);+ return this.success(c, undefined, 'Device unregistered');+ } catch (error) {+ return this.handleError(c, error);+ }+ }+}diff --git a/packages/openapi/src/routes/im.route.ts b/packages/openapi/src/routes/im.route.tsnew file mode 100644index 00000000000..735ad294f11--- /dev/null+++ b/packages/openapi/src/routes/im.route.ts@@ -0,0 +1,86 @@+import { Hono } from 'hono';+import { describeRoute } from 'hono-openapi';++import { getAllScopePermissions } from '@/utils/rbac';++import { zValidator } from '../common/validator';+import { ImController } from '../controllers/im.controller';+import { requireAuth } from '../middleware/auth';+import { requireAnyPermission, requireApiKeyScope } from '../middleware/permission-check';+import {+ ImReadRequestSchema,+ ImSendRequestSchema,+ ImSyncQuerySchema,+ ImTopicParamSchema,+} from '../types/im.type';++/**+ * IM channel routes — the asynchronous, whole-message conversation surface for+ * messaging-style clients. No token streaming: `send` acknowledges, the agent+ * works in the background, `sync` long-polls for whole replies, typing and read+ * receipts.+ */+const ImRoutes = new Hono();++const messageRead = requireAnyPermission(+ getAllScopePermissions('MESSAGE_READ'),+ 'You do not have permission to read messages',+);+const messageWrite = requireAnyPermission(+ getAllScopePermissions('MESSAGE_CREATE'),+ 'You do not have permission to send messages',+);++/**+ * POST /api/v1/im/messages — send a message; the agent replies asynchronously.+ * Starts an agent run, so restricted keys need the same trio as `/responses`.+ */+ImRoutes.post(+ '/messages',+ describeRoute({+ operationId: 'sendImMessage',+ summary: 'Send a message to an agent; the reply arrives asynchronously via sync',+ tags: ['im'],+ }),+ requireAuth,+ messageWrite,+ requireApiKeyScope('model:invoke'),+ requireApiKeyScope('chat:write'),+ requireApiKeyScope('agent:write'),+ zValidator('json', ImSendRequestSchema),+ async (c) => new ImController().send(c),+);++/** GET /api/v1/im/topics/:topicId/sync — whole new messages, typing and read state (long-poll). */+ImRoutes.get(+ '/topics/:topicId/sync',+ describeRoute({+ operationId: 'syncImTopic',+ summary: 'Long-poll a conversation for whole new messages, typing and read receipts',+ tags: ['im'],+ }),+ requireAuth,+ messageRead,+ requireApiKeyScope('chat:read'),+ zValidator('param', ImTopicParamSchema),+ zValidator('query', ImSyncQuerySchema),+ async (c) => new ImController().sync(c),+);++/** POST /api/v1/im/topics/:topicId/read — move the user's read cursor forward. */+ImRoutes.post(+ '/topics/:topicId/read',+ describeRoute({+ operationId: 'markImTopicRead',+ summary: "Mark the agent's messages read up to a message",+ tags: ['im'],+ }),+ requireAuth,+ messageRead,+ requireApiKeyScope('chat:write'),+ zValidator('param', ImTopicParamSchema),+ zValidator('json', ImReadRequestSchema),+ async (c) => new ImController().markRead(c),+);++export default ImRoutes;diff --git a/packages/openapi/src/routes/index.ts b/packages/openapi/src/routes/index.tsindex a5ad01841a2..69591aa7752 100644--- a/packages/openapi/src/routes/index.ts+++ b/packages/openapi/src/routes/index.ts@@ -6,6 +6,7 @@ import ChatRoutes from './chat.route';import EvalRoutes from './eval.route';import FileRoutes from './files.route';import GoalsRoutes from './goals.route';+import ImRoutes from './im.route';import KnowledgeBasesRoutes from './knowledge-bases.route';import McpServersRoutes from './mcp-servers.route';import MemoriesRoutes from './memories.route';@@ -17,6 +18,7 @@ import OpenAIRoutes from './openai.route';import PermissionsRoutes from './permissions.route';import { PluginsRoutes } from './plugins.route';import ProvidersRoutes from './providers.route';+import PushTokenRoutes from './push-tokens.route';import ResponsesRoutes from './responses.route';import RolesRoutes from './roles.route';import AgentSignalsRoutes from './signals.route';@@ -35,6 +37,7 @@ export default {'plugins': PluginsRoutes,'files': FileRoutes,'goals': GoalsRoutes,+ 'im': ImRoutes,'knowledge-bases': KnowledgeBasesRoutes,'mcp-servers': McpServersRoutes,'memories': MemoriesRoutes,@@ -45,6 +48,7 @@ export default {'openai': OpenAIRoutes,'permissions': PermissionsRoutes,'providers': ProvidersRoutes,+ 'push-tokens': PushTokenRoutes,'responses': ResponsesRoutes,'roles': RolesRoutes,'signals': AgentSignalsRoutes,diff --git a/packages/openapi/src/routes/push-tokens.route.ts b/packages/openapi/src/routes/push-tokens.route.tsnew file mode 100644index 00000000000..7be64ed8c1e--- /dev/null+++ b/packages/openapi/src/routes/push-tokens.route.ts@@ -0,0 +1,58 @@+import { Hono } from 'hono';+import { describeRoute } from 'hono-openapi';++import { zValidator } from '../common/validator';+import { ImController } from '../controllers/im.controller';+import { requireAuth } from '../middleware/auth';+import { requireApiKeyScope } from '../middleware/permission-check';+import {+ PushTokenParamSchema,+ PushTokenRegisterRequestSchema,+ PushTokenUnregisterQuerySchema,+} from '../types/im.type';++/**+ * Push-token routes — the REST twin of the mobile `pushToken` tRPC router, so a+ * client that talks to LobeHub only through the SDK can receive the completion+ * push of its conversations. One row per (user, device); re-registering a+ * device rotates its token.+ */+const PushTokenRoutes = new Hono();++/**+ * A registered device receives the completion push of the user's+ * conversations, i.e. chat content — a restricted key needs `chat:read`.+ */+const pushScope = requireApiKeyScope('chat:read');++/** PUT /api/v1/push-tokens/:deviceId */+PushTokenRoutes.put(+ '/:deviceId',+ describeRoute({+ operationId: 'registerPushToken',+ summary: "Register or rotate this device's push token",+ tags: ['push-tokens'],+ }),+ requireAuth,+ pushScope,+ zValidator('param', PushTokenParamSchema),+ zValidator('json', PushTokenRegisterRequestSchema),+ async (c) => new ImController().registerPushToken(c),+);++/** DELETE /api/v1/push-tokens/:deviceId */+PushTokenRoutes.delete(+ '/:deviceId',+ describeRoute({+ operationId: 'unregisterPushToken',+ summary: 'Stop pushing to this device (sign-out)',+ tags: ['push-tokens'],+ }),+ requireAuth,+ pushScope,+ zValidator('param', PushTokenParamSchema),+ zValidator('query', PushTokenUnregisterQuerySchema),+ async (c) => new ImController().unregisterPushToken(c),+);++export default PushTokenRoutes;diff --git a/packages/openapi/src/services/__tests__/im.service.test.ts b/packages/openapi/src/services/__tests__/im.service.test.tsnew file mode 100644index 00000000000..b8818646e0c--- /dev/null+++ b/packages/openapi/src/services/__tests__/im.service.test.ts@@ -0,0 +1,637 @@+// @vitest-environment node+import { eq, sql } from 'drizzle-orm';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { getTestDB } from '@/database/core/getTestDB';+import {+ agentOperations,+ messages,+ pushLiveActivities,+ pushTokens,+ topics,+ users,+ workspaces,+} from '@/database/schemas';++import { ImRestService } from '../im.service';++const { execAgentMock } = vi.hoisted(() => ({ execAgentMock: vi.fn() }));++vi.mock('@/server/services/aiAgent', () => ({+ AiAgentService: class {+ execAgent = execAgentMock;+ },+}));++const db = await getTestDB();+const USER = 'im-user';+const OTHER = 'im-other';+const TOPIC = 'tpc_im';+const AGENT = 'agt_im';++const service = new ImRestService(db, USER);++const at = (iso: string) => new Date(iso);+/** `created_at` with microseconds — the precision Postgres stores and a JS Date drops. */+const atUs = (iso: string) => sql`${iso}::timestamptz`;++const insertMessage = (+ id: string,+ role: 'assistant' | 'user' | 'tool',+ content: string | null,+ createdAt: string,+ extra: Partial<typeof messages.$inferInsert> = {},+) =>+ db.insert(messages).values({+ content,+ createdAt: atUs(createdAt) as unknown as Date,+ id,+ role,+ topicId: TOPIC,+ updatedAt: atUs(createdAt) as unknown as Date,+ userId: USER,+ ...extra,+ });++const insertRun = (id: string, status: string, createdAt: string) =>+ db.insert(agentOperations).values({+ createdAt: atUs(createdAt) as unknown as Date,+ id,+ startedAt: at(createdAt),+ status: status as any,+ topicId: TOPIC,+ userId: USER,+ });++beforeEach(async () => {+ execAgentMock.mockReset();+ await db.delete(pushLiveActivities);+ await db.delete(pushTokens);+ await db.delete(agentOperations);+ await db.delete(messages);+ await db.delete(topics);+ await db.delete(workspaces);+ await db.delete(users);+ await db.insert(users).values([{ id: USER }, { id: OTHER }]);+ await db.insert(topics).values({ id: TOPIC, title: 'toby', userId: USER });+});++describe('ImRestService.sync — whole-message delivery', () => {+ it('withholds the reply (placeholder included) while the run is in flight, then delivers it whole', async () => {+ await insertMessage('msg_u1', 'user', 'hi', '2026-10-04T10:00:00.000100Z');+ await insertMessage('msg_a1', 'assistant', '...', '2026-10-04T10:00:00.000300Z');+ await insertRun('op_1', 'running', '2026-10-04T10:00:00.000500Z');++ const typing = await service.sync(TOPIC, {});+ expect(typing.typing).toBe(true);+ expect(typing.messages.map((m) => m.id)).toEqual(['msg_u1']);+ // The agent picked the message up: that is the read receipt.+ expect(typing.readUpTo?.messageId).toBe('msg_u1');+ expect(typing.unread).toBe(0);++ // The run writes its words and settles.+ await db.update(messages).set({ content: 'hey! what is up?' }).where(eq(messages.id, 'msg_a1'));+ await db.update(agentOperations).set({ status: 'done' }).where(eq(agentOperations.id, 'op_1'));++ const landed = await service.sync(TOPIC, { cursor: typing.cursor });+ expect(landed.typing).toBe(false);+ expect(landed.messages).toEqual([+ expect.objectContaining({ content: 'hey! what is up?', id: 'msg_a1', role: 'assistant' }),+ ]);+ expect(landed.unread).toBe(1);+ });++ it('treats a fresh placeholder with no run row yet as the run starting (queue-mode gap)', async () => {+ // execAgent wrote the user turn and the placeholder; the run row lands ~1s later.+ const now = Date.now();+ const iso = (offsetMs: number) => new Date(now + offsetMs).toISOString();+ await insertMessage('msg_u1', 'user', 'hi', iso(-200));+ await insertMessage('msg_a1', 'assistant', '...', iso(-190));++ const gap = await service.sync(TOPIC, {});+ expect(gap.typing).toBe(true);+ expect(gap.readUpTo?.messageId).toBe('msg_u1');+ expect(gap.messages.map((m) => m.id)).toEqual(['msg_u1']);++ // The run is recorded, writes its words and settles.+ await insertRun('op_1', 'running', iso(800));+ await db.update(messages).set({ content: 'hey there' }).where(eq(messages.id, 'msg_a1'));+ await db.update(agentOperations).set({ status: 'done' }).where(eq(agentOperations.id, 'op_1'));++ // The cursor from the gap must not have skipped the (then empty) placeholder.+ const landed = await service.sync(TOPIC, { cursor: gap.cursor });+ expect(landed.messages.map((m) => [m.id, m.content])).toEqual([['msg_a1', 'hey there']]);+ });++ it('keeps a parked waiting_for_client run typing, so its in-place reply is not lost', async () => {+ await insertMessage('msg_u1', 'user', 'hi', '2026-10-04T10:00:00.000100Z');+ // The run streamed a few words, then parked on a call the device client has+ // to make. That partial row is visible text, but it is not the reply yet.+ await insertMessage('msg_a1', 'assistant', 'half a tho', '2026-10-04T10:00:00.000300Z');+ await insertRun('op_1', 'waiting_for_client', '2026-10-04T10:00:00.000500Z');++ const parked = await service.sync(TOPIC, {});+ expect(parked.typing).toBe(true);+ expect(parked.messages.map((m) => m.id)).toEqual(['msg_u1']);++ // Resuming finishes the SAME row in place, so its created_at does not move:+ // a cursor parked past it would hide the finished reply forever.+ await db+ .update(messages)+ .set({ content: 'half a thought, finished' })+ .where(eq(messages.id, 'msg_a1'));+ await db.update(agentOperations).set({ status: 'done' }).where(eq(agentOperations.id, 'op_1'));++ const landed = await service.sync(TOPIC, { cursor: parked.cursor });+ expect(landed.messages.map((m) => [m.id, m.content])).toEqual([+ ['msg_a1', 'half a thought, finished'],+ ]);+ });++ it('keeps a microsecond cursor so a row in the same millisecond is neither repeated nor skipped', async () => {+ await insertMessage('msg_u1', 'user', 'one', '2026-10-04T10:00:00.000100Z');+ const first = await service.sync(TOPIC, {});+ expect(first.messages.map((m) => m.id)).toEqual(['msg_u1']);++ // Same millisecond, later microsecond — a JS Date cursor would collapse these.+ await insertMessage('msg_u2', 'user', 'two', '2026-10-04T10:00:00.000900Z');+ const second = await service.sync(TOPIC, { cursor: first.cursor });+ expect(second.messages.map((m) => m.id)).toEqual(['msg_u2']);++ const third = await service.sync(TOPIC, { cursor: second.cursor });+ expect(third.messages).toEqual([]);+ });++ it('reads a row that shares the cursor’s microsecond (id breaks the tie)', async () => {+ // One transaction stamps every row it writes with the same microsecond, so a+ // cursor carrying only the timestamp skips the rows tied with it.+ const sameMicrosecond = '2026-10-04T10:00:00.000100Z';+ await insertMessage('msg_u1', 'user', 'one', sameMicrosecond);+ const first = await service.sync(TOPIC, {});+ expect(first.messages.map((m) => m.id)).toEqual(['msg_u1']);++ await insertMessage('msg_u2', 'user', 'two', sameMicrosecond);+ const second = await service.sync(TOPIC, { cursor: first.cursor });+ expect(second.messages.map((m) => m.id)).toEqual(['msg_u2']);+ });++ it('does not move the cursor past a withheld reply when the user keeps typing', async () => {+ await insertMessage('msg_u1', 'user', 'first', '2026-10-04T10:00:01Z');+ await insertMessage('msg_a1', 'assistant', 'half a tho', '2026-10-04T10:00:02Z');+ await insertRun('op_1', 'running', '2026-10-04T10:00:01.5Z');+ await insertMessage('msg_u2', 'user', 'also…', '2026-10-04T10:00:03Z');++ const during = await service.sync(TOPIC, {});+ expect(during.messages.map((m) => m.id)).toEqual(['msg_u1', 'msg_u2']);++ await db.update(agentOperations).set({ status: 'done' }).where(eq(agentOperations.id, 'op_1'));+ const after = await service.sync(TOPIC, { cursor: during.cursor });+ // The withheld reply is not lost; the user row past it is re-sent (deduped by id client-side).+ expect(after.messages.map((m) => m.id)).toEqual(['msg_a1', 'msg_u2']);+ });++ it('hides tool rows, tool-call-only steps and side threads; shows failed turns', async () => {+ await insertMessage('msg_u1', 'user', 'do it', '2026-10-04T10:00:01Z');+ await insertMessage('msg_a1', 'assistant', '', '2026-10-04T10:00:02Z');+ await insertMessage('msg_t1', 'tool', '{"ok":true}', '2026-10-04T10:00:03Z');+ await insertMessage('msg_a2', 'assistant', null, '2026-10-04T10:00:04Z', {+ error: { type: 'ProviderBizError' },+ });++ const result = await service.sync(TOPIC, {});+ expect(result.messages.map((m) => [m.id, m.error])).toEqual([+ ['msg_u1', false],+ ['msg_a2', true],+ ]);+ });++ it('applies the history limit to whole messages, not to hidden working rows', async () => {+ const base = Date.parse('2026-10-04T10:00:00Z');+ for (let i = 0; i < 5; i++) {+ await insertMessage(`msg_u${i}`, 'user', `m${i}`, new Date(base + i).toISOString());+ }+ // A tool-heavy turn leaves many invisible working rows at the top.+ for (let i = 0; i < 60; i++) {+ await insertMessage(`msg_h${i}`, 'assistant', '', new Date(base + 100 + i).toISOString());+ }++ const result = await service.sync(TOPIC, { limit: 5 });+ expect(result.messages.map((m) => m.id)).toEqual([+ 'msg_u0',+ 'msg_u1',+ 'msg_u2',+ 'msg_u3',+ 'msg_u4',+ ]);+ });++ it('answers a long-poll as soon as the state changes', async () => {+ await insertMessage('msg_u1', 'user', 'hi', '2026-10-04T10:00:01Z');+ await insertRun('op_1', 'running', '2026-10-04T10:00:02Z');+ const before = await service.sync(TOPIC, {});++ setTimeout(() => {+ // Drizzle builders are lazy thenables: `.then` is what actually runs it.+ db.update(agentOperations)+ .set({ status: 'done' })+ .where(eq(agentOperations.id, 'op_1'))+ .then(() => {});+ }, 300);++ const started = Date.now();+ const changed = await service.sync(TOPIC, {+ cursor: before.cursor,+ state: before.state,+ waitMs: 10_000,+ });+ expect(changed.typing).toBe(false);+ expect(Date.now() - started).toBeLessThan(5000);+ });++ it('keeps waiting while only already-delivered rows sit beyond the cursor', async () => {+ await insertMessage('msg_u1', 'user', 'first', '2026-10-04T10:00:01Z');+ await insertMessage('msg_a1', 'assistant', 'half a tho', '2026-10-04T10:00:02Z');+ await insertRun('op_1', 'running', '2026-10-04T10:00:01.5Z');+ await insertMessage('msg_u2', 'user', 'also…', '2026-10-04T10:00:03Z');++ const during = await service.sync(TOPIC, {});+ expect(during.messages.map((m) => m.id)).toEqual(['msg_u1', 'msg_u2']);++ // The user row past the withheld reply is re-sent, but that is not "news":+ // treating it as a change made every poll return at once (a tight loop).+ // 2000ms of waiting polls at most twice, and the loop always stops up to one+ // interval before the deadline — so ~1s is the whole wait, not an early return.+ const started = Date.now();+ const again = await service.sync(TOPIC, {+ cursor: during.cursor,+ state: during.state,+ waitMs: 2000,+ });+ expect(Date.now() - started).toBeGreaterThanOrEqual(950);+ expect(again.messages.map((m) => m.id)).toEqual(['msg_u2']);+ expect(again.state).toBe(during.state);+ });++ it('refuses another user’s conversation', async () => {+ await expect(new ImRestService(db, OTHER).sync(TOPIC, {})).rejects.toMatchObject({+ name: 'NotFoundError',+ });+ });+});++describe('ImRestService.markRead', () => {+ it('clears unread up to the message and never moves backwards', async () => {+ await insertMessage('msg_a1', 'assistant', 'one', '2026-10-04T10:00:00.000100Z');+ await insertMessage('msg_a2', 'assistant', 'two', '2026-10-04T10:00:00.000200Z');++ expect((await service.sync(TOPIC, {})).unread).toBe(2);+ expect(await service.markRead(TOPIC, { messageId: 'msg_a2' })).toEqual({ unread: 0 });+ // A stale device reporting an older message must not resurrect unread.+ expect(await service.markRead(TOPIC, { messageId: 'msg_a1' })).toEqual({ unread: 0 });++ const [topic] = await db.select().from(topics).where(eq(topics.id, TOPIC));+ expect(topic.metadata?.imReadCursors?.[USER]?.messageId).toBe('msg_a2');+ });++ it('refuses a read target that is not a delivered agent reply', async () => {+ await insertMessage('msg_u1', 'user', 'did it ship?', '2026-10-04T10:00:00.000100Z');+ await insertMessage('msg_a1', 'assistant', 'shipped', '2026-10-04T10:00:00.000200Z');+ // A working row: the placeholder a run is still writing into.+ await insertMessage('msg_writing', 'assistant', '...', '2026-10-04T10:00:00.000300Z');++ await expect(service.markRead(TOPIC, { messageId: 'msg_u1' })).rejects.toMatchObject({+ name: 'ValidationError',+ });+ await expect(service.markRead(TOPIC, { messageId: 'msg_writing' })).rejects.toMatchObject({+ name: 'ValidationError',+ });++ // Neither attempt moved the cursor, so the delivered reply is still unread.+ expect((await service.sync(TOPIC, {})).unread).toBe(1);+ const [topic] = await db.select().from(topics).where(eq(topics.id, TOPIC));+ expect(topic.metadata?.imReadCursors).toBeUndefined();+ });++ it('keeps unread after the read cursor’s own message is deleted', async () => {+ await insertMessage('msg_a1', 'assistant', 'one', '2026-10-04T10:00:00.000100Z');+ await insertMessage('msg_a2', 'assistant', 'two', '2026-10-04T10:00:00.000200Z');++ expect(await service.markRead(TOPIC, { messageId: 'msg_a1' })).toEqual({ unread: 1 });+ // The user deletes the reply they had read: the cursor has to keep ordering the+ // replies after it instead of comparing every one of them against NULL.+ await db.delete(messages).where(eq(messages.id, 'msg_a1'));++ expect((await service.sync(TOPIC, {})).unread).toBe(1);+ expect(await service.markRead(TOPIC, { messageId: 'msg_a2' })).toEqual({ unread: 0 });+ });++ it('does not read a reply that only shares the cursor’s microsecond', async () => {+ // One transaction stamps every row it writes with the same microsecond.+ await insertMessage('msg_same_1', 'assistant', 'one', '2026-10-04T10:00:00.000100Z');+ await insertMessage('msg_same_2', 'assistant', 'two', '2026-10-04T10:00:00.000100Z');++ expect((await service.sync(TOPIC, {})).unread).toBe(2);+ // The id breaks the tie: only the row the cursor names becomes read.+ expect(await service.markRead(TOPIC, { messageId: 'msg_same_1' })).toEqual({ unread: 1 });+ expect(await service.markRead(TOPIC, { messageId: 'msg_same_2' })).toEqual({ unread: 0 });+ });++ it('counts every unread reply, not just the newest page, and ignores hidden rows', async () => {+ const base = Date.parse('2026-10-04T10:00:00Z');+ for (let i = 0; i < 120; i++) {+ await insertMessage(`msg_a${i}`, 'assistant', `reply ${i}`, new Date(base + i).toISOString());+ }+ // Working rows: empty placeholders and a tool step, none of them a bubble.+ for (let i = 0; i < 5; i++) {+ await insertMessage(`msg_h${i}`, 'assistant', '', new Date(base + 200 + i).toISOString());+ }++ expect((await service.sync(TOPIC, {})).unread).toBe(120);+ expect(await service.markRead(TOPIC, { messageId: 'msg_a119' })).toEqual({ unread: 0 });+ });++ it('keeps a cursor per viewer so one member’s read does not clear another’s', async () => {+ await db+ .insert(workspaces)+ .values({ id: 'ws_1', name: 'Team', primaryOwnerId: USER, slug: 'team' });+ await db+ .insert(topics)+ .values({ id: 'tpc_ws', title: 'shared', userId: USER, workspaceId: 'ws_1' });+ await db.insert(messages).values({+ content: 'hello team',+ createdAt: atUs('2026-10-04T10:00:00.000100Z') as unknown as Date,+ id: 'msg_ws_a1',+ role: 'assistant',+ topicId: 'tpc_ws',+ updatedAt: atUs('2026-10-04T10:00:00.000100Z') as unknown as Date,+ userId: USER,+ workspaceId: 'ws_1',+ });++ const mine = new ImRestService(db, USER, 'ws_1');+ const theirs = new ImRestService(db, OTHER, 'ws_1');++ expect((await theirs.sync('tpc_ws', {})).unread).toBe(1);+ expect(await mine.markRead('tpc_ws', { messageId: 'msg_ws_a1' })).toEqual({ unread: 0 });+ // The shared topic carries one cursor per member: mine is read, theirs is not.+ expect((await theirs.sync('tpc_ws', {})).unread).toBe(1);+ });++ it('refuses another user’s conversation', async () => {+ await insertMessage('msg_a1', 'assistant', 'one', '2026-10-04T10:00:00.000100Z');++ await expect(+ new ImRestService(db, OTHER).markRead(TOPIC, { messageId: 'msg_a1' }),+ ).rejects.toMatchObject({ name: 'NotFoundError' });+ const [topic] = await db.select().from(topics).where(eq(topics.id, TOPIC));+ expect(topic.metadata?.imReadCursors).toBeUndefined();+ });++ it('refuses a message that belongs to a different conversation', async () => {+ await db.insert(topics).values({ id: 'tpc_second', title: 'second', userId: USER });+ await insertMessage('msg_elsewhere', 'assistant', 'hi', '2026-10-04T10:00:00.000100Z', {+ topicId: 'tpc_second',+ });++ await expect(service.markRead(TOPIC, { messageId: 'msg_elsewhere' })).rejects.toMatchObject({+ name: 'NotFoundError',+ });+ });+});++describe('ImRestService.send', () => {+ it('starts an interactive chat run and returns the stored user message', async () => {+ execAgentMock.mockImplementation(async () => {+ await insertMessage('msg_client0001', 'user', 'hello', '2026-10-04T10:00:01Z');+ return {+ operationId: 'op_1',+ success: true,+ topicId: TOPIC,+ userMessageId: 'msg_client0001',+ };+ });++ const result = await service.send({+ agentId: AGENT,+ clientMessageId: 'msg_client0001',+ content: 'hello',+ topicId: TOPIC,+ });++ expect(execAgentMock).toHaveBeenCalledWith(+ expect.objectContaining({+ agentId: AGENT,+ appContext: { topicId: TOPIC },+ clientIds: { userMessageId: 'msg_client0001' },+ interactiveStart: true,+ prompt: 'hello',+ trigger: 'chat',+ }),+ );+ expect(result).toMatchObject({+ accepted: true,+ operationId: 'op_1',+ topicId: TOPIC,+ userMessage: { content: 'hello', id: 'msg_client0001', role: 'user' },+ });+ });++ it('is idempotent on clientMessageId: a retry does not start a second run', async () => {+ // What a send that got through leaves behind: the user row plus the reply+ // placeholder its run writes into. Only that pair is an accepted send.+ await insertMessage('msg_client0001', 'user', 'hello', '2026-10-04T10:00:01Z');+ await insertMessage('msg_client0001_reply', 'assistant', '...', '2026-10-04T10:00:01.5Z');++ const retry = await service.send({+ agentId: AGENT,+ clientMessageId: 'msg_client0001',+ content: 'hello',+ topicId: TOPIC,+ });++ expect(execAgentMock).not.toHaveBeenCalled();+ expect(retry).toMatchObject({ accepted: false, operationId: null, topicId: TOPIC });+ });++ it('reports the winning receipt when a concurrent first send collides on the id', async () => {+ // Both sends miss the pre-check; the loser is told the message was received+ // already — including when the collision surfaces as a thrown error.+ execAgentMock.mockImplementation(async () => {+ await insertMessage('msg_client0001', 'user', 'hello', '2026-10-04T10:00:01Z');+ await insertMessage('msg_client0001_reply', 'assistant', '...', '2026-10-04T10:00:01.5Z');+ return { error: 'duplicate key value violates unique constraint', success: false };+ });++ const lost = await service.send({+ agentId: AGENT,+ clientMessageId: 'msg_client0001',+ content: 'hello',+ topicId: TOPIC,+ });+ expect(lost).toMatchObject({+ accepted: false,+ operationId: null,+ userMessage: { id: 'msg_client0001' },+ });++ execAgentMock.mockImplementation(async () => {+ await insertMessage('msg_client0002', 'user', 'hello again', '2026-10-04T10:00:02Z');+ await insertMessage('msg_client0002_reply', 'assistant', '...', '2026-10-04T10:00:02.5Z');+ throw new Error('duplicate key value violates unique constraint');+ });++ const threw = await service.send({+ agentId: AGENT,+ clientMessageId: 'msg_client0002',+ content: 'hello again',+ topicId: TOPIC,+ });+ expect(threw).toMatchObject({ accepted: false, userMessage: { id: 'msg_client0002' } });+ });++ it('does not report a receipt for a send that stored the message but never started a turn', async () => {+ // execAgent stores the user row before the placeholder and the operation, so a+ // failure in between leaves the row behind with nothing to wait for.+ execAgentMock.mockImplementation(async () => {+ await insertMessage('msg_client_failed', 'user', 'hello', '2026-10-04T10:00:03Z');+ throw new Error('operation creation failed');+ });++ await expect(+ service.send({+ agentId: AGENT,+ clientMessageId: 'msg_client_failed',+ content: 'hello',+ topicId: TOPIC,+ }),+ ).rejects.toThrow('operation creation failed');++ // A retry must not answer "already received" for a message no run picked up.+ execAgentMock.mockResolvedValue({ error: 'id taken', success: false });+ await expect(+ service.send({+ agentId: AGENT,+ clientMessageId: 'msg_client_failed',+ content: 'hello',+ topicId: TOPIC,+ }),+ ).rejects.toMatchObject({ name: 'BusinessError' });+ expect(execAgentMock).toHaveBeenCalledTimes(2);+ });++ it('refuses to post into another user’s conversation without starting a run', async () => {+ await expect(+ new ImRestService(db, OTHER).send({ agentId: AGENT, content: 'hi', topicId: TOPIC }),+ ).rejects.toMatchObject({ name: 'AuthorizationError' });+ expect(execAgentMock).not.toHaveBeenCalled();+ });++ it('does not treat another user’s message id as an idempotent retry', async () => {+ await insertMessage('msg_client0001', 'user', 'hello', '2026-10-04T10:00:01Z');+ await db.insert(topics).values({ id: 'tpc_other', title: 'other', userId: OTHER });+ execAgentMock.mockResolvedValue({ error: 'id taken', success: false });++ await expect(+ new ImRestService(db, OTHER).send({+ agentId: AGENT,+ clientMessageId: 'msg_client0001',+ content: 'hello',+ topicId: 'tpc_other',+ }),+ ).rejects.toMatchObject({ name: 'BusinessError' });+ // The lookup is owner-scoped, so the run is attempted (and the id clash+ // surfaces there) instead of leaking the first user's message back.+ expect(execAgentMock).toHaveBeenCalledTimes(1);+ });+});++describe('ImRestService push tokens', () => {+ it('registers, rotates and unregisters a device', async () => {+ await service.registerPushToken('device-1', {+ expoToken: 'ExponentPushToken[aaa]',+ platform: 'ios',+ });+ await service.registerPushToken('device-1', {+ expoToken: 'ExponentPushToken[bbb]',+ platform: 'ios',+ });+ let rows = await db.select().from(pushTokens).where(eq(pushTokens.userId, USER));+ expect(rows.map((row) => row.expoToken)).toEqual(['ExponentPushToken[bbb]']);++ await service.unregisterPushToken('device-1');+ rows = await db.select().from(pushTokens).where(eq(pushTokens.userId, USER));+ expect(rows).toEqual([]);+ });++ it('never deletes another user’s device, even with its exact token', async () => {+ await service.registerPushToken('device-1', {+ expoToken: 'ExponentPushToken[aaa]',+ platform: 'ios',+ });++ const other = new ImRestService(db, OTHER);+ await other.unregisterPushToken('device-1', 'ExponentPushToken[aaa]');+ await other.unregisterPushToken('device-1');++ const rows = await db.select().from(pushTokens).where(eq(pushTokens.userId, USER));+ expect(rows.map((row) => row.expoToken)).toEqual(['ExponentPushToken[aaa]']);+ });++ it('refuses a workspace-scoped credential, which would fan out beyond its workspace', async () => {+ const scoped = new ImRestService(db, USER, 'ws_1');++ await expect(+ scoped.registerPushToken('device-1', {+ expoToken: 'ExponentPushToken[aaa]',+ platform: 'ios',+ }),+ ).rejects.toMatchObject({ name: 'AuthorizationError' });+ await expect(scoped.unregisterPushToken('device-1')).rejects.toMatchObject({+ name: 'AuthorizationError',+ });++ expect(await db.select().from(pushTokens)).toEqual([]);+ });++ it('keeps a rotated token when a stale sign-out names the old one', async () => {+ await service.registerPushToken('device-1', {+ expoToken: 'ExponentPushToken[bbb]',+ platform: 'ios',+ });++ await service.unregisterPushToken('device-1', 'ExponentPushToken[aaa]');+ let rows = await db.select().from(pushTokens).where(eq(pushTokens.userId, USER));+ expect(rows).toHaveLength(1);++ await service.unregisterPushToken('device-1', 'ExponentPushToken[bbb]');+ rows = await db.select().from(pushTokens).where(eq(pushTokens.userId, USER));+ expect(rows).toEqual([]);+ });++ it('leaves the Live Activity tokens alone when a stale sign-out retires nothing', async () => {+ await service.registerPushToken('device-1', {+ expoToken: 'ExponentPushToken[bbb]',+ platform: 'ios',+ });+ await db.insert(pushLiveActivities).values({+ activityId: 'activity-1',+ activityKey: 'key-1',+ apnsEnvironment: 'production',+ deviceId: 'device-1',+ operationId: 'op-1',+ pushToken: 'ExponentPushToken[bbb]',+ userId: USER,+ });++ // A sign-out naming a token the device already rotated retires nothing, so+ // the newer registration and the activities it feeds must survive.+ await service.unregisterPushToken('device-1', 'ExponentPushToken[aaa]');+ expect(await db.select().from(pushTokens)).toHaveLength(1);+ expect(await db.select().from(pushLiveActivities)).toHaveLength(1);++ // An explicit sign-out still takes both.+ await service.unregisterPushToken('device-1');+ expect(await db.select().from(pushTokens)).toEqual([]);+ expect(await db.select().from(pushLiveActivities)).toEqual([]);+ });+});diff --git a/packages/openapi/src/services/im.service.ts b/packages/openapi/src/services/im.service.tsnew file mode 100644index 00000000000..335d8ea054d--- /dev/null+++ b/packages/openapi/src/services/im.service.ts@@ -0,0 +1,711 @@+import type { ChatTopicMetadata } from '@lobechat/types';+import { RequestTrigger } from '@lobechat/types';+import { and, asc, desc, eq, inArray, isNull, lte, type SQL, sql } from 'drizzle-orm';+import type { AnyPgColumn } from 'drizzle-orm/pg-core';++import { PushLiveActivityModel, PushTokenModel } from '@/database/models/pushToken';+import { TopicModel } from '@/database/models/topic';+import { agentOperations, messages, pushTokens, topics } from '@/database/schemas';+import type { LobeChatDatabase } from '@/database/type';+import { assertCanUseWorkspaceAgent } from '@/server/routers/lambda/_helpers/workspaceAgentGuard';+import { AiAgentService } from '@/server/services/aiAgent';++import { BaseService } from '../common/base.service';+import type { ServiceResult } from '../types';+import type {+ ImMessage,+ ImReadRequest,+ ImSendRequest,+ ImSendResult,+ ImSyncQuery,+ ImSyncResult,+ PushTokenRegisterRequest,+} from '../types/im.type';+import { IM_SYNC_MAX_WAIT_MS } from '../types/im.type';++/** How often a long-poll re-reads the conversation while nothing changed. */+const SYNC_POLL_INTERVAL_MS = 1000;+const DEFAULT_HISTORY_LIMIT = 50;+/** The assistant row a run creates before its first word (`LOADING_FLAT`). */+const LOADING_PLACEHOLDER = '...';++/**+ * A run in these states is still producing the reply, so the client shows+ * "typing…" and the reply is withheld until it lands whole. `waiting_for_human`+ * is deliberately absent: the agent stopped and is waiting on the user.+ * `waiting_for_client` is included even though the operation is parked: the+ * parked assistant row is the very row the resumed run finishes *in place*, so+ * publishing it would expose a half-written turn and — worse — advance the+ * cursor past a `created_at` the in-place update keeps, hiding the finished+ * reply from the client forever.+ */+const TYPING_STATUSES = new Set([+ 'idle',+ 'running',+ 'waiting_for_async_tool',+ 'waiting_for_client',+]);++type MessageRow = {+ content: string | null;+ createdAt: Date;+ /** Exact `created_at` in epoch microseconds; a JS Date drops the last three digits. */+ createdAtUs: string;+ error: unknown;+ id: string;+ role: string;+};++type LatestRun = { createdAtUs: string; startedAt: Date | null; status: string };++/**+ * What a viewer's read cursor stores: the newest agent message they have seen,+ * plus its own ordering value — the cursor must keep working after that message+ * is deleted, and `readAt` alone (a JS Date) drops the microseconds the+ * comparison needs.+ */+type ReadCursor = { createdAtUs: string; messageId: string; readAt: string };++/**+ * An incremental cursor: `<epoch micros>_<message id>`.+ *+ * `created_at` alone is not unique — one transaction stamps every row it writes+ * with the same microsecond, and a run writes several rows per turn — so a read+ * keyed on the timestamp alone permanently skips the rows tied with it. The id+ * is the tie-breaker; the whole value stays opaque to the client.+ */+type ParsedCursor = { id: string; us: bigint };++/** Epoch microseconds of a timestamp column, exact (as text, it exceeds 2^53). */+const epochUs = (column: AnyPgColumn) =>+ sql<string>`(extract(epoch from ${column}) * 1000000)::bigint::text`;+const fromEpochUs = (us: string) =>+ sql`'epoch'::timestamptz + (${us} || ' microseconds')::interval`;++const parseCursor = (cursor: string): ParsedCursor | undefined => {+ // Message ids contain `_` themselves, so the split is on the FIRST one.+ const separator = cursor.indexOf('_');+ const us = separator === -1 ? cursor : cursor.slice(0, separator);+ if (!/^\d+$/.test(us)) return undefined;+ return { id: separator === -1 ? '' : cursor.slice(separator + 1), us: BigInt(us) };+};++const formatCursor = ({ id, us }: ParsedCursor) => (us === 0n && id === '' ? '0' : `${us}_${id}`);++const compareCursor = (a: ParsedCursor, b: ParsedCursor) => {+ if (a.us !== b.us) return a.us < b.us ? -1 : 1;+ if (a.id === b.id) return 0;+ return a.id < b.id ? -1 : 1;+};++/** A stored read cursor in the shape the sync comparisons already use. */+const asCursor = ({ createdAtUs, messageId }: ReadCursor): ParsedCursor => ({+ id: messageId,+ us: BigInt(createdAtUs),+});++const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));++const toImMessage = (row: Omit<MessageRow, 'createdAtUs'>): ImMessage => ({+ content: row.content ?? '',+ createdAt: row.createdAt.toISOString(),+ error: row.error !== null && row.error !== undefined,+ id: row.id,+ role: row.role === 'user' ? 'user' : 'assistant',+});++/**+ * An agent row is a chat bubble only when it says something (or failed).+ * Tool-call-only steps and empty placeholders are the agent's working, not its+ * words. Expressed in SQL as well ({@link visibleRow}) so a `limit` counts+ * bubbles rather than the working rows hidden behind them.+ */+const VISIBLE_BUBBLE = sql`(${messages.error} is not null or (btrim(coalesce(${messages.content}, '')) <> '' and btrim(coalesce(${messages.content}, '')) <> ${LOADING_PLACEHOLDER}))`;++const visibleRow = (): SQL => sql`(${messages.role} = 'user' or ${VISIBLE_BUBBLE})`;++/** JS twin of {@link VISIBLE_BUBBLE}'s agent branch: a row that says something (or failed). */+const isDeliveredAgentRow = (row: { content: string | null; error: unknown }) => {+ if (row.error !== null && row.error !== undefined) return true;+ const content = (row.content ?? '').trim();+ return content !== '' && content !== LOADING_PLACEHOLDER;+};++/**+ * IM channel REST service — the asynchronous, whole-message view of an agent+ * conversation that messaging-style clients (toby) consume.+ *+ * - `send` persists the user's message and starts the agent run in the+ * background through the same `execAgent` entry the app composer uses+ * (interactive, `chat` trigger), so the run gets the agent's persona, tools,+ * memory and the existing completion push recall. It returns as soon as the+ * message is received.+ * - `sync` is the read side. Agent replies of a run that is still in flight are+ * withheld, so a client never sees a half-written message; it sees "typing"+ * instead, and the whole reply once the run settles.+ */+export class ImRestService extends BaseService {+ private readonly topicModel: TopicModel;++ constructor(db: LobeChatDatabase, userId: string | null, workspaceId?: string) {+ super(db, userId, workspaceId);+ this.topicModel = new TopicModel(db, this.userId, workspaceId);+ }++ async send(input: ImSendRequest): ServiceResult<ImSendResult> {+ const permission = await this.resolveOperationPermission(+ 'MESSAGE_CREATE',+ input.topicId ? { targetTopicId: input.topicId } : undefined,+ );+ if (!permission.isPermitted) {+ throw this.createAuthorizationError(permission.message || 'No permission to send messages');+ }++ await assertCanUseWorkspaceAgent({+ agentId: input.agentId,+ db: this.db,+ userId: this.userId,+ workspaceId: this.workspaceId,+ });++ if (input.topicId) await this.requireTopic(input.topicId);++ // Idempotent retry: the client minted this id and already got through once.+ const receipt = await this.idempotentReceipt(input.clientMessageId);+ if (receipt) return receipt;++ const aiAgentService = new AiAgentService(this.db, this.userId, {+ workspaceId: this.workspaceId,+ });++ let result: Awaited<ReturnType<typeof aiAgentService.execAgent>>;+ try {+ result = await aiAgentService.execAgent({+ agentId: input.agentId,+ appContext: input.topicId ? { topicId: input.topicId } : undefined,+ clientIds: input.clientMessageId ? { userMessageId: input.clientMessageId } : undefined,+ interactiveStart: true,+ prompt: input.content,+ trigger: RequestTrigger.Chat,+ });+ } catch (error) {+ // Two concurrent first sends can both miss the pre-check above; the loser+ // then collides with the winner on the message primary key. Report the+ // receipt that won instead of failing a request the client will retry.+ const raced = await this.idempotentReceipt(input.clientMessageId);+ if (raced) return raced;+ throw error;+ }++ if (!result.success) {+ const raced = await this.idempotentReceipt(input.clientMessageId);+ if (raced) return raced;+ throw this.createBusinessError(result.error || 'The agent could not take the message');+ }++ const userMessage = result.userMessageId+ ? await this.findOwnMessage(result.userMessageId)+ : undefined;+ if (!userMessage) throw this.createCommonError('The message was not stored');++ return {+ accepted: true,+ operationId: result.operationId,+ topicId: result.topicId,+ userMessage: toImMessage(userMessage),+ };+ }++ async sync(topicId: string, query: ImSyncQuery): ServiceResult<ImSyncResult> {+ await this.requireTopic(topicId);++ const deadline = Date.now() + Math.min(query.waitMs ?? 0, IM_SYNC_MAX_WAIT_MS);++ for (;;) {+ const snapshot = await this.snapshot(topicId, query);+ // Only `state` moves for something the client has not seen: it carries+ // typing, the read receipt, the unread count *and* the newest delivered+ // message. Re-sent rows (the ones parked beyond a withheld reply) leave it+ // untouched, so a long poll keeps waiting instead of busy-looping.+ const changed = snapshot.state !== query.state;+ if (changed || query.state === undefined || Date.now() + SYNC_POLL_INTERVAL_MS > deadline) {+ return snapshot;+ }+ await sleep(SYNC_POLL_INTERVAL_MS);+ }+ }++ async markRead(topicId: string, input: ImReadRequest): ServiceResult<{ unread: number }> {+ await this.requireTopic(topicId);++ const message = await this.findOwnMessage(input.messageId);+ if (!message || message.topicId !== topicId) {+ throw this.createNotFoundError('Message not found in this conversation');+ }+ // The cursor names the newest AGENT message the caller has seen, so only a+ // delivered agent bubble may move it: a later user row or a hidden working+ // row would otherwise mark earlier unread replies as read.+ if (+ message.threadId !== null ||+ message.role !== 'assistant' ||+ !isDeliveredAgentRow(message)+ ) {+ throw this.createValidationError(+ 'messageId must be an agent message this conversation has delivered',+ );+ }++ await this.advanceReadCursor(topicId, {+ createdAtUs: message.createdAtUs,+ messageId: message.id,+ readAt: message.createdAt.toISOString(),+ });++ const snapshot = await this.snapshot(topicId, { limit: 1 });+ return { unread: snapshot.unread };+ }++ async registerPushToken(+ deviceId: string,+ input: PushTokenRegisterRequest,+ ): ServiceResult<{+ deviceId: string;+ platform: string;+ }> {+ this.assertPersonalPushScope();++ const row = await new PushTokenModel(this.db, this.userId).upsert({+ appVersion: input.appVersion,+ deviceId,+ expoToken: input.expoToken,+ locale: input.locale,+ platform: input.platform,+ });+ return { deviceId: row.deviceId, platform: row.platform };+ }++ /**+ * Always scoped to the caller's own rows: unlike the public tRPC sign-out+ * endpoint, this route is authenticated, so holding a device's token is not+ * proof of owning it here. `expoToken` only guards against a stale delete —+ * a device that already rotated its token keeps the newer one.+ */+ async unregisterPushToken(deviceId: string, expoToken?: string): ServiceResult<void> {+ this.assertPersonalPushScope();++ // The token predicate belongs *in* the statement: read-then-delete let a+ // stale sign-out validate the old token, lose the race to a concurrent+ // rotation, and then delete the freshly rotated one.+ const retired = await this.db+ .delete(pushTokens)+ .where(+ and(+ eq(pushTokens.userId, this.userId),+ eq(pushTokens.deviceId, deviceId),+ expoToken ? eq(pushTokens.expoToken, expoToken) : undefined,+ ),+ )+ .returning({ id: pushTokens.id });++ // Live Activity tokens go with the registration they belonged to. A stale+ // sign-out that retired nothing must leave the newer device alone.+ if (retired.length > 0 || !expoToken) {+ await new PushLiveActivityModel(this.db, this.userId).unregisterDevice(deviceId);+ }+ }++ // ------------------------------------------------------------------ internals++ /**+ * The receipt for a `clientMessageId` this user already got through, or+ * `undefined` when the id is unused — or was consumed by a send that never got+ * a turn. `execAgent` stores the user row before the assistant placeholder and+ * the operation, so a failure in between leaves the row behind with nothing to+ * wait for; reporting that as an accepted duplicate would leave every retry+ * answering "already received" for a message no run will ever pick up.+ */+ private async idempotentReceipt(clientMessageId?: string): Promise<ImSendResult | undefined> {+ if (!clientMessageId) return undefined;++ const existing = await this.findOwnMessage(clientMessageId);+ if (!existing || existing.role !== 'user') return undefined;+ if (existing.topicId === null) {+ throw this.createConflictError('clientMessageId is already used outside a conversation');+ }+ if (!(await this.turnStarted(existing.topicId, existing.createdAt))) return undefined;++ return {+ accepted: false,+ operationId: null,+ topicId: existing.topicId,+ userMessage: toImMessage(existing),+ };+ }++ /** The reply placeholder or the operation a send's turn lands after the user row. */+ private async turnStarted(topicId: string, since: Date): Promise<boolean> {+ const [reply] = await this.db+ .select({ id: messages.id })+ .from(messages)+ .where(+ and(+ this.chatRows(topicId, ['assistant']),+ sql`${messages.createdAt} >= ${since.toISOString()}::timestamptz`,+ ),+ )+ .limit(1);+ if (reply) return true;++ const [operation] = await this.db+ .select({ id: agentOperations.id })+ .from(agentOperations)+ .where(+ and(+ eq(agentOperations.topicId, topicId),+ this.buildWorkspaceWhere(agentOperations),+ sql`${agentOperations.createdAt} >= ${since.toISOString()}::timestamptz`,+ ),+ )+ .limit(1);+ return !!operation;+ }++ private async requireTopic(topicId: string) {+ const topic = await this.topicModel.findById(topicId);+ if (!topic) throw this.createNotFoundError('Conversation not found');+ return topic;+ }++ /**+ * `push_tokens` carries no workspace and a notification is delivered to every+ * token the user owns, so a device registered through a workspace-scoped+ * credential would receive the user's personal and other-workspace+ * conversations. The resource is personal; refuse the credential instead.+ */+ private assertPersonalPushScope() {+ if (this.workspaceId) {+ throw this.createAuthorizationError(+ 'Push tokens are personal to the user and cannot be managed with a workspace-scoped credential',+ );+ }+ }++ private async findOwnMessage(id: string) {+ const [row] = await this.db+ .select({ ...this.rowSelect, threadId: messages.threadId, topicId: messages.topicId })+ .from(messages)+ .where(and(eq(messages.id, id), this.buildWorkspaceWhere(messages)))+ .limit(1);+ return row;+ }++ /** The newest top-level run on the conversation — the one the user is waiting on. */+ private async latestRun(topicId: string): Promise<LatestRun | undefined> {+ const [run] = await this.db+ .select({+ createdAtUs: epochUs(agentOperations.createdAt),+ startedAt: agentOperations.startedAt,+ status: agentOperations.status,+ })+ .from(agentOperations)+ .where(+ and(+ eq(agentOperations.topicId, topicId),+ isNull(agentOperations.parentOperationId),+ this.buildWorkspaceWhere(agentOperations),+ ),+ )+ .orderBy(desc(agentOperations.createdAt))+ .limit(1);+ return run;+ }++ /** Main-line chat rows of the conversation (sub-agent / branch threads excluded). */+ private chatRows(topicId: string, roles: string[]) {+ return and(+ eq(messages.topicId, topicId),+ isNull(messages.threadId),+ inArray(messages.role, roles),+ this.buildWorkspaceWhere(messages),+ );+ }++ /** The client does not get any agent row of the in-flight turn yet. */+ private notWithheld(withheldAfter?: bigint): SQL | undefined {+ if (withheldAfter === undefined) return undefined;+ return sql`(${messages.role} = 'user' or ${messages.createdAt} <= ${fromEpochUs(withheldAfter.toString())})`;+ }++ private readonly rowSelect = {+ content: messages.content,+ createdAt: messages.createdAt,+ createdAtUs: epochUs(messages.createdAt),+ error: messages.error,+ id: messages.id,+ role: messages.role,+ };++ private async snapshot(+ topicId: string,+ query: Pick<ImSyncQuery, 'cursor' | 'limit'>,+ ): Promise<ImSyncResult> {+ const run = await this.latestRun(topicId);+ // `execAgent` stores the user turn and the reply placeholder before the run+ // row exists (in queue mode the gap is about a second). A placeholder newer+ // than the latest run is that run starting: the agent already has the+ // message, so it counts as read and typing, and its reply is withheld.+ const starting = await this.startingReply(topicId, run);+ const typing = (!!run && TYPING_STATUSES.has(run.status)) || !!starting;+ const turn = starting+ ? { createdAtUs: starting.createdAtUs, readAt: starting.createdAt }+ : run && {+ createdAtUs: run.createdAtUs,+ readAt: run.startedAt ?? new Date(Number(BigInt(run.createdAtUs) / 1000n)),+ };++ const readUpTo = turn ? await this.readUpTo(topicId, turn) : null;++ // Whole-message rule: while the run is in flight, every agent row after the+ // message it is answering (its placeholder included) is not done yet. Rows+ // up to and including `withheldAfter` are the delivered part of the turn.+ const withheldAfter =+ typing && turn+ ? BigInt(readUpTo?.createdAtUs ?? turn.createdAtUs) - (readUpTo ? 0n : 1n)+ : undefined;++ const delivered = await this.deliveredRows(topicId, query, withheldAfter);+ const cursor = await this.nextCursor(topicId, query.cursor, withheldAfter, delivered);+ const unread = await this.countUnread(topicId, withheldAfter);+ const head = await this.conversationHead(topicId, withheldAfter);++ return {+ cursor,+ messages: delivered.map(toImMessage),+ readUpTo: readUpTo && { messageId: readUpTo.messageId, readAt: readUpTo.readAt },+ // `state` doubles as the long-poll's change token: it must move for every+ // fact the client can observe, including a new message. It is deliberately+ // computed from the conversation, not from this page — a state derived from+ // the caller's own cursor would differ on the very next poll (the page is+ // empty when nothing is new) and make every poll return at once.+ state: [typing ? 'typing' : 'idle', readUpTo?.messageId ?? '-', unread, head ?? '-'].join(+ ':',+ ),+ typing,+ unread,+ };+ }++ /** The newest whole message in the conversation: the long-poll's change signal. */+ private async conversationHead(+ topicId: string,+ withheldAfter?: bigint,+ ): Promise<string | undefined> {+ const [row] = await this.db+ .select({ id: messages.id })+ .from(messages)+ .where(+ and(+ this.chatRows(topicId, ['user', 'assistant']),+ visibleRow(),+ this.notWithheld(withheldAfter),+ ),+ )+ .orderBy(desc(messages.createdAt), desc(messages.id))+ .limit(1);+ return row?.id;+ }++ /** Whole messages newer than the client's cursor, oldest first. */+ private async deliveredRows(+ topicId: string,+ query: Pick<ImSyncQuery, 'cursor' | 'limit'>,+ withheldAfter?: bigint,+ ): Promise<MessageRow[]> {+ const scope = and(+ this.chatRows(topicId, ['user', 'assistant']),+ visibleRow(),+ this.notWithheld(withheldAfter),+ );+ // The visibility filter runs *inside* these queries on purpose: applied+ // afterwards it would count hidden working rows against `limit` and hand a+ // tool-heavy conversation back almost no bubbles.+ const cursor = query.cursor ? parseCursor(query.cursor) : undefined;++ if (cursor) {+ return this.db+ .select(this.rowSelect)+ .from(messages)+ .where(+ and(+ scope,+ sql`(${messages.createdAt}, ${messages.id}) > (${fromEpochUs(cursor.us.toString())}, ${cursor.id})`,+ ),+ )+ .orderBy(asc(messages.createdAt), asc(messages.id));+ }++ const rows = await this.db+ .select(this.rowSelect)+ .from(messages)+ .where(scope)+ .orderBy(desc(messages.createdAt), desc(messages.id))+ .limit(query.limit ?? DEFAULT_HISTORY_LIMIT);++ return rows.reverse();+ }++ /**+ * Where the client resumes. It advances to the newest delivered message, and+ * stops just before the first withheld reply — a reply sitting beyond the+ * cursor is re-sent until it lands (clients dedupe by id), never skipped.+ */+ private async nextCursor(+ topicId: string,+ start: string | undefined,+ withheldAfter: bigint | undefined,+ delivered: MessageRow[],+ ): Promise<string> {+ let cursor = start ? parseCursor(start) : undefined;++ const lastDelivered = delivered.length > 0 ? delivered.at(-1) : undefined;+ if (lastDelivered) {+ const reached = { id: lastDelivered.id, us: BigInt(lastDelivered.createdAtUs) };+ if (!cursor || compareCursor(reached, cursor) > 0) cursor = reached;+ }++ if (withheldAfter !== undefined) {+ const first = await this.firstWithheldRow(topicId, withheldAfter);+ if (first) {+ const boundary = { id: '', us: BigInt(first.createdAtUs) - 1n };+ if (!cursor || compareCursor(cursor, boundary) > 0) cursor = boundary;+ }+ }++ return cursor ? formatCursor(cursor) : '0';+ }++ /** The earliest agent row of the in-flight turn that has not landed yet. */+ private async firstWithheldRow(topicId: string, withheldAfter: bigint) {+ const [row] = await this.db+ .select({ createdAtUs: epochUs(messages.createdAt) })+ .from(messages)+ .where(+ and(+ this.chatRows(topicId, ['assistant']),+ sql`${messages.createdAt} > ${fromEpochUs(withheldAfter.toString())}`,+ ),+ )+ .orderBy(asc(messages.createdAt), asc(messages.id))+ .limit(1);+ return row;+ }++ /** A reply placeholder (`...`) written after the latest run: a run that is starting. */+ private async startingReply(topicId: string, run: LatestRun | undefined) {+ const [row] = await this.db+ .select({ createdAt: messages.createdAt, createdAtUs: epochUs(messages.createdAt) })+ .from(messages)+ .where(+ and(+ this.chatRows(topicId, ['assistant']),+ eq(messages.content, LOADING_PLACEHOLDER),+ isNull(messages.error),+ // A placeholder that never filled in is abandoned, not a run starting.+ sql`${messages.createdAt} > now() - interval '2 minutes'`,+ run ? sql`${messages.createdAt} > ${fromEpochUs(run.createdAtUs)}` : undefined,+ ),+ )+ .orderBy(desc(messages.createdAt))+ .limit(1);+ return row;+ }++ /**+ * The agent has "read" every user message that had arrived when its latest+ * turn started — the turn is the agent picking the conversation up.+ */+ private async readUpTo(topicId: string, turn: { createdAtUs: string; readAt: Date }) {+ const [read] = await this.db+ .select({ createdAtUs: epochUs(messages.createdAt), id: messages.id })+ .from(messages)+ .where(+ and(+ this.chatRows(topicId, ['user']),+ lte(messages.createdAt, fromEpochUs(turn.createdAtUs)),+ ),+ )+ .orderBy(desc(messages.createdAt), desc(messages.id))+ .limit(1);++ return read+ ? { createdAtUs: read.createdAtUs, messageId: read.id, readAt: turn.readAt.toISOString() }+ : null;+ }++ /** This viewer's read cursor, so two members of a shared topic don't share one. */+ private async readCursor(topicId: string): Promise<ReadCursor | undefined> {+ const topic = await this.topicModel.findById(topicId);+ const cursor = topic?.metadata?.imReadCursors?.[this.userId];+ // A cursor written before this shape existed carries no ordering value and+ // cannot be compared safely; treat it as unread rather than hiding replies.+ return cursor?.createdAtUs ? cursor : undefined;+ }++ /**+ * Move this viewer's read cursor forward, atomically. The comparison and the+ * write share one `SELECT … FOR UPDATE` on the topic row: with two devices+ * marking B and C, each would otherwise compare against the same old cursor,+ * both look newer, and the later write could move the cursor *backwards*.+ *+ * The cursor carries its own ordering value, so it keeps working after the+ * message it names is deleted, and it is compared in the same+ * `(created_at, id)` order as sync — two replies of one microsecond would+ * otherwise both count as read once the earlier one is marked.+ */+ private async advanceReadCursor(topicId: string, next: ReadCursor) {+ await this.db.transaction(async (tx) => {+ const [topic] = await tx+ .select({ metadata: topics.metadata })+ .from(topics)+ .where(and(eq(topics.id, topicId), this.buildWorkspaceWhere(topics)))+ .for('update');+ if (!topic) return;++ const current = topic.metadata?.imReadCursors?.[this.userId];+ // Read cursors only move forward: a stale device must not resurrect unread.+ if (current?.createdAtUs && compareCursor(asCursor(current), asCursor(next)) >= 0) return;++ await tx+ .update(topics)+ .set({+ metadata: {+ ...topic.metadata,+ imReadCursors: { ...topic.metadata?.imReadCursors, [this.userId]: next },+ } as ChatTopicMetadata,+ })+ .where(and(eq(topics.id, topicId), this.buildWorkspaceWhere(topics)));+ });+ }++ private async countUnread(topicId: string, withheldAfter?: bigint): Promise<number> {+ const readFrom = await this.readCursor(topicId);++ const [row] = await this.db+ .select({ count: sql<number>`count(*)::int` })+ .from(messages)+ .where(+ and(+ this.chatRows(topicId, ['assistant']),+ VISIBLE_BUBBLE,+ this.notWithheld(withheldAfter),+ // Same order as sync's incremental read, and independent of the cursor's+ // own row still existing.+ readFrom+ ? sql`(${messages.createdAt}, ${messages.id}) > (${fromEpochUs(readFrom.createdAtUs)}, ${readFrom.messageId})`+ : undefined,+ ),+ );++ return row?.count ?? 0;+ }+}diff --git a/packages/openapi/src/spec.ts b/packages/openapi/src/spec.tsindex b9b857b8685..8084a80a9f0 100644--- a/packages/openapi/src/spec.ts+++ b/packages/openapi/src/spec.ts@@ -432,6 +432,69 @@ const groupResources: Record<string, { listKey: string; schema: string }> = {const ref = (schema: string): SchemaObject => ({ $ref: `#/components/schemas/${schema}` });+/** One chat bubble of the IM channel — whole, never a partial stream. */+const imMessageSchema: SchemaObject = {+ additionalProperties: false,+ properties: {+ content: { type: 'string' },+ createdAt: dateTime,+ error: { type: 'boolean' },+ id: { type: 'string' },+ role: { enum: ['assistant', 'user'], type: 'string' },+ },+ required: ['content', 'createdAt', 'error', 'id', 'role'],+ type: 'object',+};++const imResponseSchema = (method: string, rest: string): SchemaObject => {+ if (method === 'post' && rest === 'messages') {+ return {+ additionalProperties: false,+ properties: {+ accepted: { type: 'boolean' },+ operationId: nullableString,+ topicId: { type: 'string' },+ userMessage: imMessageSchema,+ },+ required: ['accepted', 'operationId', 'topicId', 'userMessage'],+ type: 'object',+ };+ }++ if (rest.endsWith('/read')) {+ return {+ additionalProperties: false,+ properties: { unread: { minimum: 0, type: 'integer' } },+ required: ['unread'],+ type: 'object',+ };+ }++ return {+ additionalProperties: false,+ properties: {+ cursor: { type: 'string' },+ messages: { items: imMessageSchema, type: 'array' },+ readUpTo: {+ anyOf: [+ {+ additionalProperties: false,+ properties: { messageId: { type: 'string' }, readAt: dateTime },+ required: ['messageId', 'readAt'],+ type: 'object',+ },+ { type: 'null' },+ ],+ },+ state: { type: 'string' },+ typing: { type: 'boolean' },+ unread: { minimum: 0, type: 'integer' },+ },+ required: ['cursor', 'messages', 'readUpTo', 'state', 'typing', 'unread'],+ type: 'object',+ };+};+/*** Personal-agent resources whose payload is coordinator / inbox state rather* than a stable CRUD row (a goal's graph snapshot, a category of memory@@ -588,6 +651,18 @@ const getSuccessSchema = (group: string, rest: string, method: string): SchemaObrequired: ['plugins', 'total'],});+ if (group === 'im') return successEnvelope(imResponseSchema(method, rest));++ if (group === 'push-tokens') {+ if (method === 'delete') return successEnvelope({ type: 'null' });+ return successEnvelope({+ additionalProperties: false,+ properties: { deviceId: { type: 'string' }, platform: { type: 'string' } },+ required: ['deviceId', 'platform'],+ type: 'object',+ });+ }+const resource = groupResources[group];if (!resource) return successEnvelope({ additionalProperties: true, type: 'object' });diff --git a/packages/openapi/src/types/im.type.ts b/packages/openapi/src/types/im.type.tsnew file mode 100644index 00000000000..a918160b696--- /dev/null+++ b/packages/openapi/src/types/im.type.ts@@ -0,0 +1,121 @@+import { z } from 'zod';++/**+ * The IM channel: a messaging-app view of one agent conversation.+ *+ * Unlike `/responses` (token stream) this surface is asynchronous and+ * whole-message: sending only acknowledges receipt, the agent works in the+ * background, and its replies become visible to `sync` only once they are+ * complete. Clients learn about progress from three facts — new whole messages,+ * whether the agent is "typing" (a run is in flight), and how far the agent has+ * read the user's messages.+ */++export const ImSendRequestSchema = z.object({+ /** The agent the user is talking to. */+ agentId: z.string().min(1),+ /**+ * Client-minted id for the user message (`msg_…`). Makes the send idempotent:+ * retrying with the same id returns the original receipt instead of starting+ * a second run.+ */+ clientMessageId: z+ .string()+ .regex(/^msg_[\w-]{8,64}$/, 'clientMessageId must look like msg_<8-64 url-safe chars>')+ .optional(),+ /** The message text. */+ content: z.string().trim().min(1).max(100_000),+ /** The conversation to continue; omit to start a new one for the agent. */+ topicId: z.string().min(1).nullish(),+});+export type ImSendRequest = z.infer<typeof ImSendRequestSchema>;++export const ImTopicParamSchema = z.object({+ topicId: z.string().min(1),+});+export type ImTopicParam = z.infer<typeof ImTopicParamSchema>;++/** Hard ceiling on a long-poll, comfortably below serverless request limits. */+export const IM_SYNC_MAX_WAIT_MS = 25_000;++export const ImSyncQuerySchema = z.object({+ /**+ * Opaque cursor returned by the previous `sync`; omit for the full history.+ * `<epoch micros>_<message id>` — the id breaks ties between rows written in+ * the same microsecond, which a timestamp-only cursor would skip.+ */+ cursor: z+ .string()+ .regex(/^\d+(_[\w-]{1,128})?$/, 'cursor must be the value returned by a previous sync')+ .optional(),+ /** Max messages to return when there is no cursor (latest N). */+ limit: z.coerce.number().int().min(1).max(200).optional(),+ /**+ * The `state` string from the previous response. A long-poll returns early+ * when the server's state differs (a new message, the agent started or stopped+ * typing, it read more, or the unread count moved).+ */+ state: z.string().max(200).optional(),+ /** Long-poll up to this many ms when nothing changed; 0 answers immediately. */+ waitMs: z.coerce.number().int().min(0).max(IM_SYNC_MAX_WAIT_MS).optional(),+});+export type ImSyncQuery = z.infer<typeof ImSyncQuerySchema>;++export const ImReadRequestSchema = z.object({+ /** The newest agent message the user has seen. */+ messageId: z.string().min(1),+});+export type ImReadRequest = z.infer<typeof ImReadRequestSchema>;++export interface ImMessage {+ content: string;+ createdAt: string;+ /** Set when the agent's turn failed; the client shows a retry affordance. */+ error: boolean;+ id: string;+ role: 'assistant' | 'user';+}++export interface ImSendResult {+ /** `false` when this was an idempotent retry of an already-received message. */+ accepted: boolean;+ /** The agent run that will answer; null on an idempotent retry. */+ operationId: string | null;+ topicId: string;+ userMessage: ImMessage;+}++export interface ImSyncResult {+ /** Pass back as `cursor` to receive only what is new. */+ cursor: string;+ /** Whole messages newer than the cursor, oldest first. */+ messages: ImMessage[];+ /** The newest user message the agent has picked up (the "read" receipt). */+ readUpTo: { messageId: string; readAt: string } | null;+ /** Pass back as `state` to long-poll for a change. */+ state: string;+ /** The agent is working on a reply ("typing…"). */+ typing: boolean;+ /** Agent messages newer than the user's read cursor. */+ unread: number;+}++export const PushTokenParamSchema = z.object({+ deviceId: z.string().min(1).max(200),+});+export type PushTokenParam = z.infer<typeof PushTokenParamSchema>;++export const PushTokenRegisterRequestSchema = z.object({+ appVersion: z.string().max(64).optional(),+ /** Expo push token, `ExponentPushToken[…]`. */+ expoToken: z.string().min(1).max(512),+ locale: z.string().max(32).optional(),+ platform: z.enum(['ios', 'android']),+});+export type PushTokenRegisterRequest = z.infer<typeof PushTokenRegisterRequestSchema>;++export const PushTokenUnregisterQuerySchema = z.object({+ /** The token being retired; scopes the delete to the row this device owns. */+ expoToken: z.string().min(1).max(512).optional(),+});+export type PushTokenUnregisterQuery = z.infer<typeof PushTokenUnregisterQuerySchema>;diff --git a/packages/sdk/openapi-ts.config.ts b/packages/sdk/openapi-ts.config.tsindex 23f211c1670..d9cb50bc787 100644--- a/packages/sdk/openapi-ts.config.ts+++ b/packages/sdk/openapi-ts.config.ts@@ -42,6 +42,13 @@ const METHOD_NAME_OVERRIDES: Record<string, string> = {'POST /api/v1/notifications/{id}/archive': 'archive','POST /api/v1/signals/source-events': 'emit','POST /api/v1/signals/trigger': 'trigger',+ // IM channel: `send` / `sync` / `markRead` read like a messaging client;+ // push tokens are keyed by device, so PUT/DELETE are register/unregister.+ 'DELETE /api/v1/push-tokens/{deviceId}': 'unregister',+ 'GET /api/v1/im/topics/{topicId}/sync': 'sync',+ 'POST /api/v1/im/messages': 'send',+ 'POST /api/v1/im/topics/{topicId}/read': 'markRead',+ 'PUT /api/v1/push-tokens/{deviceId}': 'register',};const pascal = (segment: string) =>diff --git a/packages/sdk/src/generated/index.ts b/packages/sdk/src/generated/index.tsindex ea983ab0d0d..206e1a0ec7a 100644--- a/packages/sdk/src/generated/index.ts+++ b/packages/sdk/src/generated/index.ts@@ -1,4 +1,4 @@// This file is auto-generated by @hey-api/openapi-ts-export { AgentGroups, Agents, ApiKeys, Chat, Eval, Files, Goals, Health, KnowledgeBases, LobeHub, McpServers, Memories, Messages, MessageTranslations, Models, Notifications, type Options, Permissions, Plugins, Providers, Responses, Roles, Signals, Tasks, Topics, Usage as Usage2, Users } from './sdk.gen';-export type { Agent, AgentGroup, ApiError, ApiKey, ChatResponse, ClientOptions, DeleteApiV1AgentGroupsByIdData, DeleteApiV1AgentGroupsByIdError, DeleteApiV1AgentGroupsByIdErrors, DeleteApiV1AgentGroupsByIdResponse, DeleteApiV1AgentGroupsByIdResponses, DeleteApiV1AgentsByIdData, DeleteApiV1AgentsByIdError, DeleteApiV1AgentsByIdErrors, DeleteApiV1AgentsByIdResponse, DeleteApiV1AgentsByIdResponses, DeleteApiV1ApiKeysByIdData, DeleteApiV1ApiKeysByIdError, DeleteApiV1ApiKeysByIdErrors, DeleteApiV1ApiKeysByIdResponse, DeleteApiV1ApiKeysByIdResponses, DeleteApiV1EvalBenchmarksByIdData, DeleteApiV1EvalBenchmarksByIdError, DeleteApiV1EvalBenchmarksByIdErrors, DeleteApiV1EvalBenchmarksByIdResponse, DeleteApiV1EvalBenchmarksByIdResponses, DeleteApiV1EvalDatasetsByIdData, DeleteApiV1EvalDatasetsByIdError, DeleteApiV1EvalDatasetsByIdErrors, DeleteApiV1EvalDatasetsByIdResponse, DeleteApiV1EvalDatasetsByIdResponses, DeleteApiV1EvalTestCasesByIdData, DeleteApiV1EvalTestCasesByIdError, DeleteApiV1EvalTestCasesByIdErrors, DeleteApiV1EvalTestCasesByIdResponse, DeleteApiV1EvalTestCasesByIdResponses, DeleteApiV1FilesByIdData, DeleteApiV1FilesByIdError, DeleteApiV1FilesByIdErrors, DeleteApiV1FilesByIdResponse, DeleteApiV1FilesByIdResponses, DeleteApiV1GoalsByIdData, DeleteApiV1GoalsByIdError, DeleteApiV1GoalsByIdErrors, DeleteApiV1GoalsByIdResponse, DeleteApiV1GoalsByIdResponses, DeleteApiV1KnowledgeBasesByIdData, DeleteApiV1KnowledgeBasesByIdError, DeleteApiV1KnowledgeBasesByIdErrors, DeleteApiV1KnowledgeBasesByIdFilesBatchData, DeleteApiV1KnowledgeBasesByIdFilesBatchError, DeleteApiV1KnowledgeBasesByIdFilesBatchErrors, DeleteApiV1KnowledgeBasesByIdFilesBatchResponse, DeleteApiV1KnowledgeBasesByIdFilesBatchResponses, DeleteApiV1KnowledgeBasesByIdResponse, DeleteApiV1KnowledgeBasesByIdResponses, DeleteApiV1McpServersByIdData, DeleteApiV1McpServersByIdError, DeleteApiV1McpServersByIdErrors, DeleteApiV1McpServersByIdResponse, DeleteApiV1McpServersByIdResponses, DeleteApiV1MemoriesByCategoryByIdData, DeleteApiV1MemoriesByCategoryByIdError, DeleteApiV1MemoriesByCategoryByIdErrors, DeleteApiV1MemoriesByCategoryByIdResponse, DeleteApiV1MemoriesByCategoryByIdResponses, DeleteApiV1MemoriesData, DeleteApiV1MemoriesError, DeleteApiV1MemoriesErrors, DeleteApiV1MemoriesResponse, DeleteApiV1MemoriesResponses, DeleteApiV1MessagesByIdData, DeleteApiV1MessagesByIdError, DeleteApiV1MessagesByIdErrors, DeleteApiV1MessagesByIdResponse, DeleteApiV1MessagesByIdResponses, DeleteApiV1MessagesData, DeleteApiV1MessagesError, DeleteApiV1MessagesErrors, DeleteApiV1MessagesResponse, DeleteApiV1MessagesResponses, DeleteApiV1MessageTranslationsByMessageIdData, DeleteApiV1MessageTranslationsByMessageIdError, DeleteApiV1MessageTranslationsByMessageIdErrors, DeleteApiV1MessageTranslationsByMessageIdResponse, DeleteApiV1MessageTranslationsByMessageIdResponses, DeleteApiV1PermissionsByIdData, DeleteApiV1PermissionsByIdError, DeleteApiV1PermissionsByIdErrors, DeleteApiV1PermissionsByIdResponse, DeleteApiV1PermissionsByIdResponses, DeleteApiV1ProvidersByIdData, DeleteApiV1ProvidersByIdError, DeleteApiV1ProvidersByIdErrors, DeleteApiV1ProvidersByIdResponse, DeleteApiV1ProvidersByIdResponses, DeleteApiV1RolesByIdData, DeleteApiV1RolesByIdError, DeleteApiV1RolesByIdErrors, DeleteApiV1RolesByIdPermissionsData, DeleteApiV1RolesByIdPermissionsError, DeleteApiV1RolesByIdPermissionsErrors, DeleteApiV1RolesByIdPermissionsResponse, DeleteApiV1RolesByIdPermissionsResponses, DeleteApiV1RolesByIdResponse, DeleteApiV1RolesByIdResponses, DeleteApiV1TasksByIdData, DeleteApiV1TasksByIdError, DeleteApiV1TasksByIdErrors, DeleteApiV1TasksByIdResponse, DeleteApiV1TasksByIdResponses, DeleteApiV1TopicsByIdData, DeleteApiV1TopicsByIdError, DeleteApiV1TopicsByIdErrors, DeleteApiV1TopicsByIdResponse, DeleteApiV1TopicsByIdResponses, DeleteApiV1UsersByIdData, DeleteApiV1UsersByIdError, DeleteApiV1UsersByIdErrors, DeleteApiV1UsersByIdResponse, DeleteApiV1UsersByIdResponses, DeleteApiV1UsersByIdRolesData, DeleteApiV1UsersByIdRolesError, DeleteApiV1UsersByIdRolesErrors, DeleteApiV1UsersByIdRolesResponse, DeleteApiV1UsersByIdRolesResponses, EvalRun, EvalRunResult, File, GetApiV1AgentGroupsByIdData, GetApiV1AgentGroupsByIdError, GetApiV1AgentGroupsByIdErrors, GetApiV1AgentGroupsByIdResponse, GetApiV1AgentGroupsByIdResponses, GetApiV1AgentGroupsData, GetApiV1AgentGroupsError, GetApiV1AgentGroupsErrors, GetApiV1AgentGroupsResponse, GetApiV1AgentGroupsResponses, GetApiV1AgentsByIdData, GetApiV1AgentsByIdError, GetApiV1AgentsByIdErrors, GetApiV1AgentsByIdResponse, GetApiV1AgentsByIdResponses, GetApiV1AgentsData, GetApiV1AgentsError, GetApiV1AgentsErrors, GetApiV1AgentsResponse, GetApiV1AgentsResponses, GetApiV1ApiKeysByIdData, GetApiV1ApiKeysByIdError, GetApiV1ApiKeysByIdErrors, GetApiV1ApiKeysByIdResponse, GetApiV1ApiKeysByIdResponses, GetApiV1ApiKeysData, GetApiV1ApiKeysError, GetApiV1ApiKeysErrors, GetApiV1ApiKeysResponse, GetApiV1ApiKeysResponses, GetApiV1EvalBenchmarksByIdData, GetApiV1EvalBenchmarksByIdError, GetApiV1EvalBenchmarksByIdErrors, GetApiV1EvalBenchmarksByIdResponse, GetApiV1EvalBenchmarksByIdResponses, GetApiV1EvalBenchmarksData, GetApiV1EvalBenchmarksError, GetApiV1EvalBenchmarksErrors, GetApiV1EvalBenchmarksResponse, GetApiV1EvalBenchmarksResponses, GetApiV1EvalDatasetsByDatasetIdTestCasesData, GetApiV1EvalDatasetsByDatasetIdTestCasesError, GetApiV1EvalDatasetsByDatasetIdTestCasesErrors, GetApiV1EvalDatasetsByDatasetIdTestCasesResponse, GetApiV1EvalDatasetsByDatasetIdTestCasesResponses, GetApiV1EvalDatasetsByIdData, GetApiV1EvalDatasetsByIdError, GetApiV1EvalDatasetsByIdErrors, GetApiV1EvalDatasetsByIdResponse, GetApiV1EvalDatasetsByIdResponses, GetApiV1EvalDatasetsData, GetApiV1EvalDatasetsError, GetApiV1EvalDatasetsErrors, GetApiV1EvalDatasetsResponse, GetApiV1EvalDatasetsResponses, GetApiV1EvalRunsByIdData, GetApiV1EvalRunsByIdError, GetApiV1EvalRunsByIdErrors, GetApiV1EvalRunsByIdResponse, GetApiV1EvalRunsByIdResponses, GetApiV1EvalRunsByIdResultsData, GetApiV1EvalRunsByIdResultsError, GetApiV1EvalRunsByIdResultsErrors, GetApiV1EvalRunsByIdResultsResponse, GetApiV1EvalRunsByIdResultsResponses, GetApiV1EvalRunsByIdTopicsData, GetApiV1EvalRunsByIdTopicsError, GetApiV1EvalRunsByIdTopicsErrors, GetApiV1EvalRunsByIdTopicsResponse, GetApiV1EvalRunsByIdTopicsResponses, GetApiV1EvalRunsData, GetApiV1EvalRunsError, GetApiV1EvalRunsErrors, GetApiV1EvalRunsResponse, GetApiV1EvalRunsResponses, GetApiV1EvalTestCasesByIdData, GetApiV1EvalTestCasesByIdError, GetApiV1EvalTestCasesByIdErrors, GetApiV1EvalTestCasesByIdResponse, GetApiV1EvalTestCasesByIdResponses, GetApiV1FilesByIdChunksData, GetApiV1FilesByIdChunksError, GetApiV1FilesByIdChunksErrors, GetApiV1FilesByIdChunksResponse, GetApiV1FilesByIdChunksResponses, GetApiV1FilesByIdData, GetApiV1FilesByIdError, GetApiV1FilesByIdErrors, GetApiV1FilesByIdResponse, GetApiV1FilesByIdResponses, GetApiV1FilesByIdUrlData, GetApiV1FilesByIdUrlError, GetApiV1FilesByIdUrlErrors, GetApiV1FilesByIdUrlResponse, GetApiV1FilesByIdUrlResponses, GetApiV1FilesData, GetApiV1FilesError, GetApiV1FilesErrors, GetApiV1FilesResponse, GetApiV1FilesResponses, GetApiV1GoalsByIdData, GetApiV1GoalsByIdError, GetApiV1GoalsByIdErrors, GetApiV1GoalsByIdResponse, GetApiV1GoalsByIdResponses, GetApiV1GoalsByIdSupervisionData, GetApiV1GoalsByIdSupervisionError, GetApiV1GoalsByIdSupervisionErrors, GetApiV1GoalsByIdSupervisionResponse, GetApiV1GoalsByIdSupervisionResponses, GetApiV1GoalsData, GetApiV1GoalsError, GetApiV1GoalsErrors, GetApiV1GoalsResponse, GetApiV1GoalsResponses, GetApiV1HealthData, GetApiV1HealthError, GetApiV1HealthErrors, GetApiV1HealthResponse, GetApiV1HealthResponses, GetApiV1KnowledgeBasesByIdData, GetApiV1KnowledgeBasesByIdError, GetApiV1KnowledgeBasesByIdErrors, GetApiV1KnowledgeBasesByIdFilesData, GetApiV1KnowledgeBasesByIdFilesError, GetApiV1KnowledgeBasesByIdFilesErrors, GetApiV1KnowledgeBasesByIdFilesResponse, GetApiV1KnowledgeBasesByIdFilesResponses, GetApiV1KnowledgeBasesByIdResponse, GetApiV1KnowledgeBasesByIdResponses, GetApiV1KnowledgeBasesData, GetApiV1KnowledgeBasesError, GetApiV1KnowledgeBasesErrors, GetApiV1KnowledgeBasesResponse, GetApiV1KnowledgeBasesResponses, GetApiV1McpServersByIdData, GetApiV1McpServersByIdError, GetApiV1McpServersByIdErrors, GetApiV1McpServersByIdResponse, GetApiV1McpServersByIdResponses, GetApiV1McpServersData, GetApiV1McpServersError, GetApiV1McpServersErrors, GetApiV1McpServersResponse, GetApiV1McpServersResponses, GetApiV1MemoriesByCategoryData, GetApiV1MemoriesByCategoryError, GetApiV1MemoriesByCategoryErrors, GetApiV1MemoriesByCategoryResponse, GetApiV1MemoriesByCategoryResponses, GetApiV1MemoriesPersonaData, GetApiV1MemoriesPersonaError, GetApiV1MemoriesPersonaErrors, GetApiV1MemoriesPersonaResponse, GetApiV1MemoriesPersonaResponses, GetApiV1MemoriesPersonaVersionsData, GetApiV1MemoriesPersonaVersionsError, GetApiV1MemoriesPersonaVersionsErrors, GetApiV1MemoriesPersonaVersionsResponse, GetApiV1MemoriesPersonaVersionsResponses, GetApiV1MessagesByIdData, GetApiV1MessagesByIdError, GetApiV1MessagesByIdErrors, GetApiV1MessagesByIdResponse, GetApiV1MessagesByIdResponses, GetApiV1MessagesCountData, GetApiV1MessagesCountError, GetApiV1MessagesCountErrors, GetApiV1MessagesCountResponse, GetApiV1MessagesCountResponses, GetApiV1MessagesData, GetApiV1MessagesError, GetApiV1MessagesErrors, GetApiV1MessagesResponse, GetApiV1MessagesResponses, GetApiV1MessageTranslationsByMessageIdData, GetApiV1MessageTranslationsByMessageIdError, GetApiV1MessageTranslationsByMessageIdErrors, GetApiV1MessageTranslationsByMessageIdResponse, GetApiV1MessageTranslationsByMessageIdResponses, GetApiV1ModelsByProviderIdByModelIdData, GetApiV1ModelsByProviderIdByModelIdError, GetApiV1ModelsByProviderIdByModelIdErrors, GetApiV1ModelsByProviderIdByModelIdResponse, GetApiV1ModelsByProviderIdByModelIdResponses, GetApiV1ModelsData, GetApiV1ModelsError, GetApiV1ModelsErrors, GetApiV1ModelsResponse, GetApiV1ModelsResponses, GetApiV1NotificationsCountsData, GetApiV1NotificationsCountsError, GetApiV1NotificationsCountsErrors, GetApiV1NotificationsCountsResponse, GetApiV1NotificationsCountsResponses, GetApiV1NotificationsData, GetApiV1NotificationsError, GetApiV1NotificationsErrors, GetApiV1NotificationsResponse, GetApiV1NotificationsResponses, GetApiV1NotificationsUnreadCountData, GetApiV1NotificationsUnreadCountError, GetApiV1NotificationsUnreadCountErrors, GetApiV1NotificationsUnreadCountResponse, GetApiV1NotificationsUnreadCountResponses, GetApiV1PermissionsByIdData, GetApiV1PermissionsByIdError, GetApiV1PermissionsByIdErrors, GetApiV1PermissionsByIdResponse, GetApiV1PermissionsByIdResponses, GetApiV1PermissionsData, GetApiV1PermissionsError, GetApiV1PermissionsErrors, GetApiV1PermissionsResponse, GetApiV1PermissionsResponses, GetApiV1PluginsData, GetApiV1PluginsError, GetApiV1PluginsErrors, GetApiV1PluginsResponse, GetApiV1PluginsResponses, GetApiV1ProvidersByIdData, GetApiV1ProvidersByIdError, GetApiV1ProvidersByIdErrors, GetApiV1ProvidersByIdResponse, GetApiV1ProvidersByIdResponses, GetApiV1ProvidersData, GetApiV1ProvidersError, GetApiV1ProvidersErrors, GetApiV1ProvidersResponse, GetApiV1ProvidersResponses, GetApiV1RolesByIdData, GetApiV1RolesByIdError, GetApiV1RolesByIdErrors, GetApiV1RolesByIdPermissionsData, GetApiV1RolesByIdPermissionsError, GetApiV1RolesByIdPermissionsErrors, GetApiV1RolesByIdPermissionsResponse, GetApiV1RolesByIdPermissionsResponses, GetApiV1RolesByIdResponse, GetApiV1RolesByIdResponses, GetApiV1RolesData, GetApiV1RolesError, GetApiV1RolesErrors, GetApiV1RolesResponse, GetApiV1RolesResponses, GetApiV1SignalsReceiptsData, GetApiV1SignalsReceiptsError, GetApiV1SignalsReceiptsErrors, GetApiV1SignalsReceiptsResponse, GetApiV1SignalsReceiptsResponses, GetApiV1TasksByIdData, GetApiV1TasksByIdError, GetApiV1TasksByIdErrors, GetApiV1TasksByIdResponse, GetApiV1TasksByIdResponses, GetApiV1TasksData, GetApiV1TasksError, GetApiV1TasksErrors, GetApiV1TasksResponse, GetApiV1TasksResponses, GetApiV1TopicsByIdData, GetApiV1TopicsByIdError, GetApiV1TopicsByIdErrors, GetApiV1TopicsByIdResponse, GetApiV1TopicsByIdResponses, GetApiV1TopicsByTopicIdThreadsData, GetApiV1TopicsByTopicIdThreadsError, GetApiV1TopicsByTopicIdThreadsErrors, GetApiV1TopicsByTopicIdThreadsResponse, GetApiV1TopicsByTopicIdThreadsResponses, GetApiV1TopicsData, GetApiV1TopicsError, GetApiV1TopicsErrors, GetApiV1TopicsResponse, GetApiV1TopicsResponses, GetApiV1UsageData, GetApiV1UsageError, GetApiV1UsageErrors, GetApiV1UsageResponse, GetApiV1UsageResponses, GetApiV1UsersByIdData, GetApiV1UsersByIdError, GetApiV1UsersByIdErrors, GetApiV1UsersByIdResponse, GetApiV1UsersByIdResponses, GetApiV1UsersByIdRolesData, GetApiV1UsersByIdRolesError, GetApiV1UsersByIdRolesErrors, GetApiV1UsersByIdRolesResponse, GetApiV1UsersByIdRolesResponses, GetApiV1UsersData, GetApiV1UsersError, GetApiV1UsersErrors, GetApiV1UsersMeData, GetApiV1UsersMeError, GetApiV1UsersMeErrors, GetApiV1UsersMeResponse, GetApiV1UsersMeResponses, GetApiV1UsersResponse, GetApiV1UsersResponses, KnowledgeBase, McpServer, Message, Model, PatchApiV1AgentGroupsByIdData, PatchApiV1AgentGroupsByIdError, PatchApiV1AgentGroupsByIdErrors, PatchApiV1AgentGroupsByIdResponse, PatchApiV1AgentGroupsByIdResponses, PatchApiV1AgentsByIdData, PatchApiV1AgentsByIdError, PatchApiV1AgentsByIdErrors, PatchApiV1AgentsByIdResponse, PatchApiV1AgentsByIdResponses, PatchApiV1ApiKeysByIdData, PatchApiV1ApiKeysByIdError, PatchApiV1ApiKeysByIdErrors, PatchApiV1ApiKeysByIdResponse, PatchApiV1ApiKeysByIdResponses, PatchApiV1EvalBenchmarksByIdData, PatchApiV1EvalBenchmarksByIdError, PatchApiV1EvalBenchmarksByIdErrors, PatchApiV1EvalBenchmarksByIdResponse, PatchApiV1EvalBenchmarksByIdResponses, PatchApiV1EvalDatasetsByIdData, PatchApiV1EvalDatasetsByIdError, PatchApiV1EvalDatasetsByIdErrors, PatchApiV1EvalDatasetsByIdResponse, PatchApiV1EvalDatasetsByIdResponses, PatchApiV1EvalRunsByIdStatusData, PatchApiV1EvalRunsByIdStatusError, PatchApiV1EvalRunsByIdStatusErrors, PatchApiV1EvalRunsByIdStatusResponse, PatchApiV1EvalRunsByIdStatusResponses, PatchApiV1EvalTestCasesByIdData, PatchApiV1EvalTestCasesByIdError, PatchApiV1EvalTestCasesByIdErrors, PatchApiV1EvalTestCasesByIdResponse, PatchApiV1EvalTestCasesByIdResponses, PatchApiV1FilesByIdData, PatchApiV1FilesByIdError, PatchApiV1FilesByIdErrors, PatchApiV1FilesByIdResponse, PatchApiV1FilesByIdResponses, PatchApiV1GoalsByIdData, PatchApiV1GoalsByIdError, PatchApiV1GoalsByIdErrors, PatchApiV1GoalsByIdResponse, PatchApiV1GoalsByIdResponses, PatchApiV1KnowledgeBasesByIdData, PatchApiV1KnowledgeBasesByIdError, PatchApiV1KnowledgeBasesByIdErrors, PatchApiV1KnowledgeBasesByIdResponse, PatchApiV1KnowledgeBasesByIdResponses, PatchApiV1McpServersByIdData, PatchApiV1McpServersByIdError, PatchApiV1McpServersByIdErrors, PatchApiV1McpServersByIdResponse, PatchApiV1McpServersByIdResponses, PatchApiV1MessageTranslationsByMessageIdData, PatchApiV1MessageTranslationsByMessageIdError, PatchApiV1MessageTranslationsByMessageIdErrors, PatchApiV1MessageTranslationsByMessageIdResponse, PatchApiV1MessageTranslationsByMessageIdResponses, PatchApiV1ModelsByProviderIdByModelIdData, PatchApiV1ModelsByProviderIdByModelIdError, PatchApiV1ModelsByProviderIdByModelIdErrors, PatchApiV1ModelsByProviderIdByModelIdResponse, PatchApiV1ModelsByProviderIdByModelIdResponses, PatchApiV1PermissionsByIdData, PatchApiV1PermissionsByIdError, PatchApiV1PermissionsByIdErrors, PatchApiV1PermissionsByIdResponse, PatchApiV1PermissionsByIdResponses, PatchApiV1ProvidersByIdData, PatchApiV1ProvidersByIdError, PatchApiV1ProvidersByIdErrors, PatchApiV1ProvidersByIdResponse, PatchApiV1ProvidersByIdResponses, PatchApiV1RolesByIdData, PatchApiV1RolesByIdError, PatchApiV1RolesByIdErrors, PatchApiV1RolesByIdPermissionsData, PatchApiV1RolesByIdPermissionsError, PatchApiV1RolesByIdPermissionsErrors, PatchApiV1RolesByIdPermissionsResponse, PatchApiV1RolesByIdPermissionsResponses, PatchApiV1RolesByIdResponse, PatchApiV1RolesByIdResponses, PatchApiV1TasksByIdData, PatchApiV1TasksByIdError, PatchApiV1TasksByIdErrors, PatchApiV1TasksByIdResponse, PatchApiV1TasksByIdResponses, PatchApiV1TasksByIdStatusData, PatchApiV1TasksByIdStatusError, PatchApiV1TasksByIdStatusErrors, PatchApiV1TasksByIdStatusResponse, PatchApiV1TasksByIdStatusResponses, PatchApiV1TopicsByIdData, PatchApiV1TopicsByIdError, PatchApiV1TopicsByIdErrors, PatchApiV1TopicsByIdResponse, PatchApiV1TopicsByIdResponses, PatchApiV1UsersByIdData, PatchApiV1UsersByIdError, PatchApiV1UsersByIdErrors, PatchApiV1UsersByIdResponse, PatchApiV1UsersByIdResponses, PatchApiV1UsersByIdRolesData, PatchApiV1UsersByIdRolesError, PatchApiV1UsersByIdRolesErrors, PatchApiV1UsersByIdRolesResponse, PatchApiV1UsersByIdRolesResponses, Permission, PostApiV1AgentGroupsData, PostApiV1AgentGroupsError, PostApiV1AgentGroupsErrors, PostApiV1AgentGroupsResponse, PostApiV1AgentGroupsResponses, PostApiV1AgentsByIdDuplicateData, PostApiV1AgentsByIdDuplicateError, PostApiV1AgentsByIdDuplicateErrors, PostApiV1AgentsByIdDuplicateResponse, PostApiV1AgentsByIdDuplicateResponses, PostApiV1AgentsData, PostApiV1AgentsError, PostApiV1AgentsErrors, PostApiV1AgentsResponse, PostApiV1AgentsResponses, PostApiV1ApiKeysData, PostApiV1ApiKeysError, PostApiV1ApiKeysErrors, PostApiV1ApiKeysResponse, PostApiV1ApiKeysResponses, PostApiV1ChatData, PostApiV1ChatError, PostApiV1ChatErrors, PostApiV1ChatGenerateReplyData, PostApiV1ChatGenerateReplyError, PostApiV1ChatGenerateReplyErrors, PostApiV1ChatGenerateReplyResponse, PostApiV1ChatGenerateReplyResponses, PostApiV1ChatResponse, PostApiV1ChatResponses, PostApiV1ChatTranslateData, PostApiV1ChatTranslateError, PostApiV1ChatTranslateErrors, PostApiV1ChatTranslateResponse, PostApiV1ChatTranslateResponses, PostApiV1EvalBenchmarksData, PostApiV1EvalBenchmarksError, PostApiV1EvalBenchmarksErrors, PostApiV1EvalBenchmarksResponse, PostApiV1EvalBenchmarksResponses, PostApiV1EvalDatasetsByDatasetIdTestCasesData, PostApiV1EvalDatasetsByDatasetIdTestCasesError, PostApiV1EvalDatasetsByDatasetIdTestCasesErrors, PostApiV1EvalDatasetsByDatasetIdTestCasesResponse, PostApiV1EvalDatasetsByDatasetIdTestCasesResponses, PostApiV1EvalDatasetsData, PostApiV1EvalDatasetsError, PostApiV1EvalDatasetsErrors, PostApiV1EvalDatasetsResponse, PostApiV1EvalDatasetsResponses, PostApiV1EvalRunsByIdClaimData, PostApiV1EvalRunsByIdClaimError, PostApiV1EvalRunsByIdClaimErrors, PostApiV1EvalRunsByIdClaimResponse, PostApiV1EvalRunsByIdClaimResponses, PostApiV1EvalRunsByIdResultsData, PostApiV1EvalRunsByIdResultsError, PostApiV1EvalRunsByIdResultsErrors, PostApiV1EvalRunsByIdResultsResponse, PostApiV1EvalRunsByIdResultsResponses, PostApiV1EvalRunsByIdRetryErrorsData, PostApiV1EvalRunsByIdRetryErrorsError, PostApiV1EvalRunsByIdRetryErrorsErrors, PostApiV1EvalRunsByIdRetryErrorsResponse, PostApiV1EvalRunsByIdRetryErrorsResponses, PostApiV1EvalRunsData, PostApiV1EvalRunsError, PostApiV1EvalRunsErrors, PostApiV1EvalRunsResponse, PostApiV1EvalRunsResponses, PostApiV1FilesBatchesData, PostApiV1FilesBatchesError, PostApiV1FilesBatchesErrors, PostApiV1FilesBatchesResponse, PostApiV1FilesBatchesResponses, PostApiV1FilesByIdChunksData, PostApiV1FilesByIdChunksError, PostApiV1FilesByIdChunksErrors, PostApiV1FilesByIdChunksResponse, PostApiV1FilesByIdChunksResponses, PostApiV1FilesByIdParsesData, PostApiV1FilesByIdParsesError, PostApiV1FilesByIdParsesErrors, PostApiV1FilesByIdParsesResponse, PostApiV1FilesByIdParsesResponses, PostApiV1FilesData, PostApiV1FilesError, PostApiV1FilesErrors, PostApiV1FilesQueriesData, PostApiV1FilesQueriesError, PostApiV1FilesQueriesErrors, PostApiV1FilesQueriesResponse, PostApiV1FilesQueriesResponses, PostApiV1FilesResponse, PostApiV1FilesResponses, PostApiV1GoalsByIdAdvanceData, PostApiV1GoalsByIdAdvanceError, PostApiV1GoalsByIdAdvanceErrors, PostApiV1GoalsByIdAdvanceResponse, PostApiV1GoalsByIdAdvanceResponses, PostApiV1GoalsByIdPauseData, PostApiV1GoalsByIdPauseError, PostApiV1GoalsByIdPauseErrors, PostApiV1GoalsByIdPauseResponse, PostApiV1GoalsByIdPauseResponses, PostApiV1GoalsByIdRestartData, PostApiV1GoalsByIdRestartError, PostApiV1GoalsByIdRestartErrors, PostApiV1GoalsByIdRestartResponse, PostApiV1GoalsByIdRestartResponses, PostApiV1GoalsByIdResumeData, PostApiV1GoalsByIdResumeError, PostApiV1GoalsByIdResumeErrors, PostApiV1GoalsByIdResumeResponse, PostApiV1GoalsByIdResumeResponses, PostApiV1GoalsData, PostApiV1GoalsError, PostApiV1GoalsErrors, PostApiV1GoalsResponse, PostApiV1GoalsResponses, PostApiV1KnowledgeBasesByIdFilesBatchData, PostApiV1KnowledgeBasesByIdFilesBatchError, PostApiV1KnowledgeBasesByIdFilesBatchErrors, PostApiV1KnowledgeBasesByIdFilesBatchResponse, PostApiV1KnowledgeBasesByIdFilesBatchResponses, PostApiV1KnowledgeBasesByIdFilesMoveData, PostApiV1KnowledgeBasesByIdFilesMoveError, PostApiV1KnowledgeBasesByIdFilesMoveErrors, PostApiV1KnowledgeBasesByIdFilesMoveResponse, PostApiV1KnowledgeBasesByIdFilesMoveResponses, PostApiV1KnowledgeBasesData, PostApiV1KnowledgeBasesError, PostApiV1KnowledgeBasesErrors, PostApiV1KnowledgeBasesResponse, PostApiV1KnowledgeBasesResponses, PostApiV1McpServersByIdSyncData, PostApiV1McpServersByIdSyncError, PostApiV1McpServersByIdSyncErrors, PostApiV1McpServersByIdSyncResponse, PostApiV1McpServersByIdSyncResponses, PostApiV1McpServersData, PostApiV1McpServersError, PostApiV1McpServersErrors, PostApiV1McpServersResponse, PostApiV1McpServersResponses, PostApiV1MessagesData, PostApiV1MessagesError, PostApiV1MessagesErrors, PostApiV1MessagesRepliesData, PostApiV1MessagesRepliesError, PostApiV1MessagesRepliesErrors, PostApiV1MessagesRepliesResponse, PostApiV1MessagesRepliesResponses, PostApiV1MessagesResponse, PostApiV1MessagesResponses, PostApiV1MessageTranslationsByMessageIdData, PostApiV1MessageTranslationsByMessageIdError, PostApiV1MessageTranslationsByMessageIdErrors, PostApiV1MessageTranslationsByMessageIdResponse, PostApiV1MessageTranslationsByMessageIdResponses, PostApiV1ModelsData, PostApiV1ModelsError, PostApiV1ModelsErrors, PostApiV1ModelsResponse, PostApiV1ModelsResponses, PostApiV1NotificationsArchiveAllData, PostApiV1NotificationsArchiveAllError, PostApiV1NotificationsArchiveAllErrors, PostApiV1NotificationsArchiveAllResponse, PostApiV1NotificationsArchiveAllResponses, PostApiV1NotificationsByIdArchiveData, PostApiV1NotificationsByIdArchiveError, PostApiV1NotificationsByIdArchiveErrors, PostApiV1NotificationsByIdArchiveResponse, PostApiV1NotificationsByIdArchiveResponses, PostApiV1NotificationsReadAllData, PostApiV1NotificationsReadAllError, PostApiV1NotificationsReadAllErrors, PostApiV1NotificationsReadAllResponse, PostApiV1NotificationsReadAllResponses, PostApiV1NotificationsReadData, PostApiV1NotificationsReadError, PostApiV1NotificationsReadErrors, PostApiV1NotificationsReadResponse, PostApiV1NotificationsReadResponses, PostApiV1PermissionsData, PostApiV1PermissionsError, PostApiV1PermissionsErrors, PostApiV1PermissionsResponse, PostApiV1PermissionsResponses, PostApiV1ProvidersData, PostApiV1ProvidersError, PostApiV1ProvidersErrors, PostApiV1ProvidersResponse, PostApiV1ProvidersResponses, PostApiV1ResponsesData, PostApiV1ResponsesError, PostApiV1ResponsesErrors, PostApiV1ResponsesResponse, PostApiV1ResponsesResponses, PostApiV1RolesData, PostApiV1RolesError, PostApiV1RolesErrors, PostApiV1RolesResponse, PostApiV1RolesResponses, PostApiV1SignalsSourceEventsData, PostApiV1SignalsSourceEventsError, PostApiV1SignalsSourceEventsErrors, PostApiV1SignalsSourceEventsResponse, PostApiV1SignalsSourceEventsResponses, PostApiV1SignalsTriggerData, PostApiV1SignalsTriggerError, PostApiV1SignalsTriggerErrors, PostApiV1SignalsTriggerResponse, PostApiV1SignalsTriggerResponses, PostApiV1TasksData, PostApiV1TasksError, PostApiV1TasksErrors, PostApiV1TasksResponse, PostApiV1TasksResponses, PostApiV1TopicsData, PostApiV1TopicsError, PostApiV1TopicsErrors, PostApiV1TopicsResponse, PostApiV1TopicsResponses, PostApiV1UsersData, PostApiV1UsersError, PostApiV1UsersErrors, PostApiV1UsersResponse, PostApiV1UsersResponses, Provider, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultData, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultError, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultErrors, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultResponse, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultResponses, Role, Topic, Usage, User } from './types.gen';+export { AgentGroups, Agents, ApiKeys, Chat, Eval, Files, Goals, Health, Im, KnowledgeBases, LobeHub, McpServers, Memories, Messages, MessageTranslations, Models, Notifications, type Options, Permissions, Plugins, Providers, PushTokens, Responses, Roles, Signals, Tasks, Topics, Usage as Usage2, Users } from './sdk.gen';+export type { Agent, AgentGroup, ApiError, ApiKey, ChatResponse, ClientOptions, DeleteApiV1AgentGroupsByIdData, DeleteApiV1AgentGroupsByIdError, DeleteApiV1AgentGroupsByIdErrors, DeleteApiV1AgentGroupsByIdResponse, DeleteApiV1AgentGroupsByIdResponses, DeleteApiV1AgentsByIdData, DeleteApiV1AgentsByIdError, DeleteApiV1AgentsByIdErrors, DeleteApiV1AgentsByIdResponse, DeleteApiV1AgentsByIdResponses, DeleteApiV1ApiKeysByIdData, DeleteApiV1ApiKeysByIdError, DeleteApiV1ApiKeysByIdErrors, DeleteApiV1ApiKeysByIdResponse, DeleteApiV1ApiKeysByIdResponses, DeleteApiV1EvalBenchmarksByIdData, DeleteApiV1EvalBenchmarksByIdError, DeleteApiV1EvalBenchmarksByIdErrors, DeleteApiV1EvalBenchmarksByIdResponse, DeleteApiV1EvalBenchmarksByIdResponses, DeleteApiV1EvalDatasetsByIdData, DeleteApiV1EvalDatasetsByIdError, DeleteApiV1EvalDatasetsByIdErrors, DeleteApiV1EvalDatasetsByIdResponse, DeleteApiV1EvalDatasetsByIdResponses, DeleteApiV1EvalTestCasesByIdData, DeleteApiV1EvalTestCasesByIdError, DeleteApiV1EvalTestCasesByIdErrors, DeleteApiV1EvalTestCasesByIdResponse, DeleteApiV1EvalTestCasesByIdResponses, DeleteApiV1FilesByIdData, DeleteApiV1FilesByIdError, DeleteApiV1FilesByIdErrors, DeleteApiV1FilesByIdResponse, DeleteApiV1FilesByIdResponses, DeleteApiV1GoalsByIdData, DeleteApiV1GoalsByIdError, DeleteApiV1GoalsByIdErrors, DeleteApiV1GoalsByIdResponse, DeleteApiV1GoalsByIdResponses, DeleteApiV1KnowledgeBasesByIdData, DeleteApiV1KnowledgeBasesByIdError, DeleteApiV1KnowledgeBasesByIdErrors, DeleteApiV1KnowledgeBasesByIdFilesBatchData, DeleteApiV1KnowledgeBasesByIdFilesBatchError, DeleteApiV1KnowledgeBasesByIdFilesBatchErrors, DeleteApiV1KnowledgeBasesByIdFilesBatchResponse, DeleteApiV1KnowledgeBasesByIdFilesBatchResponses, DeleteApiV1KnowledgeBasesByIdResponse, DeleteApiV1KnowledgeBasesByIdResponses, DeleteApiV1McpServersByIdData, DeleteApiV1McpServersByIdError, DeleteApiV1McpServersByIdErrors, DeleteApiV1McpServersByIdResponse, DeleteApiV1McpServersByIdResponses, DeleteApiV1MemoriesByCategoryByIdData, DeleteApiV1MemoriesByCategoryByIdError, DeleteApiV1MemoriesByCategoryByIdErrors, DeleteApiV1MemoriesByCategoryByIdResponse, DeleteApiV1MemoriesByCategoryByIdResponses, DeleteApiV1MemoriesData, DeleteApiV1MemoriesError, DeleteApiV1MemoriesErrors, DeleteApiV1MemoriesResponse, DeleteApiV1MemoriesResponses, DeleteApiV1MessagesByIdData, DeleteApiV1MessagesByIdError, DeleteApiV1MessagesByIdErrors, DeleteApiV1MessagesByIdResponse, DeleteApiV1MessagesByIdResponses, DeleteApiV1MessagesData, DeleteApiV1MessagesError, DeleteApiV1MessagesErrors, DeleteApiV1MessagesResponse, DeleteApiV1MessagesResponses, DeleteApiV1MessageTranslationsByMessageIdData, DeleteApiV1MessageTranslationsByMessageIdError, DeleteApiV1MessageTranslationsByMessageIdErrors, DeleteApiV1MessageTranslationsByMessageIdResponse, DeleteApiV1MessageTranslationsByMessageIdResponses, DeleteApiV1PermissionsByIdData, DeleteApiV1PermissionsByIdError, DeleteApiV1PermissionsByIdErrors, DeleteApiV1PermissionsByIdResponse, DeleteApiV1PermissionsByIdResponses, DeleteApiV1ProvidersByIdData, DeleteApiV1ProvidersByIdError, DeleteApiV1ProvidersByIdErrors, DeleteApiV1ProvidersByIdResponse, DeleteApiV1ProvidersByIdResponses, DeleteApiV1PushTokensByDeviceIdData, DeleteApiV1PushTokensByDeviceIdError, DeleteApiV1PushTokensByDeviceIdErrors, DeleteApiV1PushTokensByDeviceIdResponse, DeleteApiV1PushTokensByDeviceIdResponses, DeleteApiV1RolesByIdData, DeleteApiV1RolesByIdError, DeleteApiV1RolesByIdErrors, DeleteApiV1RolesByIdPermissionsData, DeleteApiV1RolesByIdPermissionsError, DeleteApiV1RolesByIdPermissionsErrors, DeleteApiV1RolesByIdPermissionsResponse, DeleteApiV1RolesByIdPermissionsResponses, DeleteApiV1RolesByIdResponse, DeleteApiV1RolesByIdResponses, DeleteApiV1TasksByIdData, DeleteApiV1TasksByIdError, DeleteApiV1TasksByIdErrors, DeleteApiV1TasksByIdResponse, DeleteApiV1TasksByIdResponses, DeleteApiV1TopicsByIdData, DeleteApiV1TopicsByIdError, DeleteApiV1TopicsByIdErrors, DeleteApiV1TopicsByIdResponse, DeleteApiV1TopicsByIdResponses, DeleteApiV1UsersByIdData, DeleteApiV1UsersByIdError, DeleteApiV1UsersByIdErrors, DeleteApiV1UsersByIdResponse, DeleteApiV1UsersByIdResponses, DeleteApiV1UsersByIdRolesData, DeleteApiV1UsersByIdRolesError, DeleteApiV1UsersByIdRolesErrors, DeleteApiV1UsersByIdRolesResponse, DeleteApiV1UsersByIdRolesResponses, EvalRun, EvalRunResult, File, GetApiV1AgentGroupsByIdData, GetApiV1AgentGroupsByIdError, GetApiV1AgentGroupsByIdErrors, GetApiV1AgentGroupsByIdResponse, GetApiV1AgentGroupsByIdResponses, GetApiV1AgentGroupsData, GetApiV1AgentGroupsError, GetApiV1AgentGroupsErrors, GetApiV1AgentGroupsResponse, GetApiV1AgentGroupsResponses, GetApiV1AgentsByIdData, GetApiV1AgentsByIdError, GetApiV1AgentsByIdErrors, GetApiV1AgentsByIdResponse, GetApiV1AgentsByIdResponses, GetApiV1AgentsData, GetApiV1AgentsError, GetApiV1AgentsErrors, GetApiV1AgentsResponse, GetApiV1AgentsResponses, GetApiV1ApiKeysByIdData, GetApiV1ApiKeysByIdError, GetApiV1ApiKeysByIdErrors, GetApiV1ApiKeysByIdResponse, GetApiV1ApiKeysByIdResponses, GetApiV1ApiKeysData, GetApiV1ApiKeysError, GetApiV1ApiKeysErrors, GetApiV1ApiKeysResponse, GetApiV1ApiKeysResponses, GetApiV1EvalBenchmarksByIdData, GetApiV1EvalBenchmarksByIdError, GetApiV1EvalBenchmarksByIdErrors, GetApiV1EvalBenchmarksByIdResponse, GetApiV1EvalBenchmarksByIdResponses, GetApiV1EvalBenchmarksData, GetApiV1EvalBenchmarksError, GetApiV1EvalBenchmarksErrors, GetApiV1EvalBenchmarksResponse, GetApiV1EvalBenchmarksResponses, GetApiV1EvalDatasetsByDatasetIdTestCasesData, GetApiV1EvalDatasetsByDatasetIdTestCasesError, GetApiV1EvalDatasetsByDatasetIdTestCasesErrors, GetApiV1EvalDatasetsByDatasetIdTestCasesResponse, GetApiV1EvalDatasetsByDatasetIdTestCasesResponses, GetApiV1EvalDatasetsByIdData, GetApiV1EvalDatasetsByIdError, GetApiV1EvalDatasetsByIdErrors, GetApiV1EvalDatasetsByIdResponse, GetApiV1EvalDatasetsByIdResponses, GetApiV1EvalDatasetsData, GetApiV1EvalDatasetsError, GetApiV1EvalDatasetsErrors, GetApiV1EvalDatasetsResponse, GetApiV1EvalDatasetsResponses, GetApiV1EvalRunsByIdData, GetApiV1EvalRunsByIdError, GetApiV1EvalRunsByIdErrors, GetApiV1EvalRunsByIdResponse, GetApiV1EvalRunsByIdResponses, GetApiV1EvalRunsByIdResultsData, GetApiV1EvalRunsByIdResultsError, GetApiV1EvalRunsByIdResultsErrors, GetApiV1EvalRunsByIdResultsResponse, GetApiV1EvalRunsByIdResultsResponses, GetApiV1EvalRunsByIdTopicsData, GetApiV1EvalRunsByIdTopicsError, GetApiV1EvalRunsByIdTopicsErrors, GetApiV1EvalRunsByIdTopicsResponse, GetApiV1EvalRunsByIdTopicsResponses, GetApiV1EvalRunsData, GetApiV1EvalRunsError, GetApiV1EvalRunsErrors, GetApiV1EvalRunsResponse, GetApiV1EvalRunsResponses, GetApiV1EvalTestCasesByIdData, GetApiV1EvalTestCasesByIdError, GetApiV1EvalTestCasesByIdErrors, GetApiV1EvalTestCasesByIdResponse, GetApiV1EvalTestCasesByIdResponses, GetApiV1FilesByIdChunksData, GetApiV1FilesByIdChunksError, GetApiV1FilesByIdChunksErrors, GetApiV1FilesByIdChunksResponse, GetApiV1FilesByIdChunksResponses, GetApiV1FilesByIdData, GetApiV1FilesByIdError, GetApiV1FilesByIdErrors, GetApiV1FilesByIdResponse, GetApiV1FilesByIdResponses, GetApiV1FilesByIdUrlData, GetApiV1FilesByIdUrlError, GetApiV1FilesByIdUrlErrors, GetApiV1FilesByIdUrlResponse, GetApiV1FilesByIdUrlResponses, GetApiV1FilesData, GetApiV1FilesError, GetApiV1FilesErrors, GetApiV1FilesResponse, GetApiV1FilesResponses, GetApiV1GoalsByIdData, GetApiV1GoalsByIdError, GetApiV1GoalsByIdErrors, GetApiV1GoalsByIdResponse, GetApiV1GoalsByIdResponses, GetApiV1GoalsByIdSupervisionData, GetApiV1GoalsByIdSupervisionError, GetApiV1GoalsByIdSupervisionErrors, GetApiV1GoalsByIdSupervisionResponse, GetApiV1GoalsByIdSupervisionResponses, GetApiV1GoalsData, GetApiV1GoalsError, GetApiV1GoalsErrors, GetApiV1GoalsResponse, GetApiV1GoalsResponses, GetApiV1HealthData, GetApiV1HealthError, GetApiV1HealthErrors, GetApiV1HealthResponse, GetApiV1HealthResponses, GetApiV1ImTopicsByTopicIdSyncData, GetApiV1ImTopicsByTopicIdSyncError, GetApiV1ImTopicsByTopicIdSyncErrors, GetApiV1ImTopicsByTopicIdSyncResponse, GetApiV1ImTopicsByTopicIdSyncResponses, GetApiV1KnowledgeBasesByIdData, GetApiV1KnowledgeBasesByIdError, GetApiV1KnowledgeBasesByIdErrors, GetApiV1KnowledgeBasesByIdFilesData, GetApiV1KnowledgeBasesByIdFilesError, GetApiV1KnowledgeBasesByIdFilesErrors, GetApiV1KnowledgeBasesByIdFilesResponse, GetApiV1KnowledgeBasesByIdFilesResponses, GetApiV1KnowledgeBasesByIdResponse, GetApiV1KnowledgeBasesByIdResponses, GetApiV1KnowledgeBasesData, GetApiV1KnowledgeBasesError, GetApiV1KnowledgeBasesErrors, GetApiV1KnowledgeBasesResponse, GetApiV1KnowledgeBasesResponses, GetApiV1McpServersByIdData, GetApiV1McpServersByIdError, GetApiV1McpServersByIdErrors, GetApiV1McpServersByIdResponse, GetApiV1McpServersByIdResponses, GetApiV1McpServersData, GetApiV1McpServersError, GetApiV1McpServersErrors, GetApiV1McpServersResponse, GetApiV1McpServersResponses, GetApiV1MemoriesByCategoryData, GetApiV1MemoriesByCategoryError, GetApiV1MemoriesByCategoryErrors, GetApiV1MemoriesByCategoryResponse, GetApiV1MemoriesByCategoryResponses, GetApiV1MemoriesPersonaData, GetApiV1MemoriesPersonaError, GetApiV1MemoriesPersonaErrors, GetApiV1MemoriesPersonaResponse, GetApiV1MemoriesPersonaResponses, GetApiV1MemoriesPersonaVersionsData, GetApiV1MemoriesPersonaVersionsError, GetApiV1MemoriesPersonaVersionsErrors, GetApiV1MemoriesPersonaVersionsResponse, GetApiV1MemoriesPersonaVersionsResponses, GetApiV1MessagesByIdData, GetApiV1MessagesByIdError, GetApiV1MessagesByIdErrors, GetApiV1MessagesByIdResponse, GetApiV1MessagesByIdResponses, GetApiV1MessagesCountData, GetApiV1MessagesCountError, GetApiV1MessagesCountErrors, GetApiV1MessagesCountResponse, GetApiV1MessagesCountResponses, GetApiV1MessagesData, GetApiV1MessagesError, GetApiV1MessagesErrors, GetApiV1MessagesResponse, GetApiV1MessagesResponses, GetApiV1MessageTranslationsByMessageIdData, GetApiV1MessageTranslationsByMessageIdError, GetApiV1MessageTranslationsByMessageIdErrors, GetApiV1MessageTranslationsByMessageIdResponse, GetApiV1MessageTranslationsByMessageIdResponses, GetApiV1ModelsByProviderIdByModelIdData, GetApiV1ModelsByProviderIdByModelIdError, GetApiV1ModelsByProviderIdByModelIdErrors, GetApiV1ModelsByProviderIdByModelIdResponse, GetApiV1ModelsByProviderIdByModelIdResponses, GetApiV1ModelsData, GetApiV1ModelsError, GetApiV1ModelsErrors, GetApiV1ModelsResponse, GetApiV1ModelsResponses, GetApiV1NotificationsCountsData, GetApiV1NotificationsCountsError, GetApiV1NotificationsCountsErrors, GetApiV1NotificationsCountsResponse, GetApiV1NotificationsCountsResponses, GetApiV1NotificationsData, GetApiV1NotificationsError, GetApiV1NotificationsErrors, GetApiV1NotificationsResponse, GetApiV1NotificationsResponses, GetApiV1NotificationsUnreadCountData, GetApiV1NotificationsUnreadCountError, GetApiV1NotificationsUnreadCountErrors, GetApiV1NotificationsUnreadCountResponse, GetApiV1NotificationsUnreadCountResponses, GetApiV1PermissionsByIdData, GetApiV1PermissionsByIdError, GetApiV1PermissionsByIdErrors, GetApiV1PermissionsByIdResponse, GetApiV1PermissionsByIdResponses, GetApiV1PermissionsData, GetApiV1PermissionsError, GetApiV1PermissionsErrors, GetApiV1PermissionsResponse, GetApiV1PermissionsResponses, GetApiV1PluginsData, GetApiV1PluginsError, GetApiV1PluginsErrors, GetApiV1PluginsResponse, GetApiV1PluginsResponses, GetApiV1ProvidersByIdData, GetApiV1ProvidersByIdError, GetApiV1ProvidersByIdErrors, GetApiV1ProvidersByIdResponse, GetApiV1ProvidersByIdResponses, GetApiV1ProvidersData, GetApiV1ProvidersError, GetApiV1ProvidersErrors, GetApiV1ProvidersResponse, GetApiV1ProvidersResponses, GetApiV1RolesByIdData, GetApiV1RolesByIdError, GetApiV1RolesByIdErrors, GetApiV1RolesByIdPermissionsData, GetApiV1RolesByIdPermissionsError, GetApiV1RolesByIdPermissionsErrors, GetApiV1RolesByIdPermissionsResponse, GetApiV1RolesByIdPermissionsResponses, GetApiV1RolesByIdResponse, GetApiV1RolesByIdResponses, GetApiV1RolesData, GetApiV1RolesError, GetApiV1RolesErrors, GetApiV1RolesResponse, GetApiV1RolesResponses, GetApiV1SignalsReceiptsData, GetApiV1SignalsReceiptsError, GetApiV1SignalsReceiptsErrors, GetApiV1SignalsReceiptsResponse, GetApiV1SignalsReceiptsResponses, GetApiV1TasksByIdData, GetApiV1TasksByIdError, GetApiV1TasksByIdErrors, GetApiV1TasksByIdResponse, GetApiV1TasksByIdResponses, GetApiV1TasksData, GetApiV1TasksError, GetApiV1TasksErrors, GetApiV1TasksResponse, GetApiV1TasksResponses, GetApiV1TopicsByIdData, GetApiV1TopicsByIdError, GetApiV1TopicsByIdErrors, GetApiV1TopicsByIdResponse, GetApiV1TopicsByIdResponses, GetApiV1TopicsByTopicIdThreadsData, GetApiV1TopicsByTopicIdThreadsError, GetApiV1TopicsByTopicIdThreadsErrors, GetApiV1TopicsByTopicIdThreadsResponse, GetApiV1TopicsByTopicIdThreadsResponses, GetApiV1TopicsData, GetApiV1TopicsError, GetApiV1TopicsErrors, GetApiV1TopicsResponse, GetApiV1TopicsResponses, GetApiV1UsageData, GetApiV1UsageError, GetApiV1UsageErrors, GetApiV1UsageResponse, GetApiV1UsageResponses, GetApiV1UsersByIdData, GetApiV1UsersByIdError, GetApiV1UsersByIdErrors, GetApiV1UsersByIdResponse, GetApiV1UsersByIdResponses, GetApiV1UsersByIdRolesData, GetApiV1UsersByIdRolesError, GetApiV1UsersByIdRolesErrors, GetApiV1UsersByIdRolesResponse, GetApiV1UsersByIdRolesResponses, GetApiV1UsersData, GetApiV1UsersError, GetApiV1UsersErrors, GetApiV1UsersMeData, GetApiV1UsersMeError, GetApiV1UsersMeErrors, GetApiV1UsersMeResponse, GetApiV1UsersMeResponses, GetApiV1UsersResponse, GetApiV1UsersResponses, KnowledgeBase, McpServer, Message, Model, PatchApiV1AgentGroupsByIdData, PatchApiV1AgentGroupsByIdError, PatchApiV1AgentGroupsByIdErrors, PatchApiV1AgentGroupsByIdResponse, PatchApiV1AgentGroupsByIdResponses, PatchApiV1AgentsByIdData, PatchApiV1AgentsByIdError, PatchApiV1AgentsByIdErrors, PatchApiV1AgentsByIdResponse, PatchApiV1AgentsByIdResponses, PatchApiV1ApiKeysByIdData, PatchApiV1ApiKeysByIdError, PatchApiV1ApiKeysByIdErrors, PatchApiV1ApiKeysByIdResponse, PatchApiV1ApiKeysByIdResponses, PatchApiV1EvalBenchmarksByIdData, PatchApiV1EvalBenchmarksByIdError, PatchApiV1EvalBenchmarksByIdErrors, PatchApiV1EvalBenchmarksByIdResponse, PatchApiV1EvalBenchmarksByIdResponses, PatchApiV1EvalDatasetsByIdData, PatchApiV1EvalDatasetsByIdError, PatchApiV1EvalDatasetsByIdErrors, PatchApiV1EvalDatasetsByIdResponse, PatchApiV1EvalDatasetsByIdResponses, PatchApiV1EvalRunsByIdStatusData, PatchApiV1EvalRunsByIdStatusError, PatchApiV1EvalRunsByIdStatusErrors, PatchApiV1EvalRunsByIdStatusResponse, PatchApiV1EvalRunsByIdStatusResponses, PatchApiV1EvalTestCasesByIdData, PatchApiV1EvalTestCasesByIdError, PatchApiV1EvalTestCasesByIdErrors, PatchApiV1EvalTestCasesByIdResponse, PatchApiV1EvalTestCasesByIdResponses, PatchApiV1FilesByIdData, PatchApiV1FilesByIdError, PatchApiV1FilesByIdErrors, PatchApiV1FilesByIdResponse, PatchApiV1FilesByIdResponses, PatchApiV1GoalsByIdData, PatchApiV1GoalsByIdError, PatchApiV1GoalsByIdErrors, PatchApiV1GoalsByIdResponse, PatchApiV1GoalsByIdResponses, PatchApiV1KnowledgeBasesByIdData, PatchApiV1KnowledgeBasesByIdError, PatchApiV1KnowledgeBasesByIdErrors, PatchApiV1KnowledgeBasesByIdResponse, PatchApiV1KnowledgeBasesByIdResponses, PatchApiV1McpServersByIdData, PatchApiV1McpServersByIdError, PatchApiV1McpServersByIdErrors, PatchApiV1McpServersByIdResponse, PatchApiV1McpServersByIdResponses, PatchApiV1MessageTranslationsByMessageIdData, PatchApiV1MessageTranslationsByMessageIdError, PatchApiV1MessageTranslationsByMessageIdErrors, PatchApiV1MessageTranslationsByMessageIdResponse, PatchApiV1MessageTranslationsByMessageIdResponses, PatchApiV1ModelsByProviderIdByModelIdData, PatchApiV1ModelsByProviderIdByModelIdError, PatchApiV1ModelsByProviderIdByModelIdErrors, PatchApiV1ModelsByProviderIdByModelIdResponse, PatchApiV1ModelsByProviderIdByModelIdResponses, PatchApiV1PermissionsByIdData, PatchApiV1PermissionsByIdError, PatchApiV1PermissionsByIdErrors, PatchApiV1PermissionsByIdResponse, PatchApiV1PermissionsByIdResponses, PatchApiV1ProvidersByIdData, PatchApiV1ProvidersByIdError, PatchApiV1ProvidersByIdErrors, PatchApiV1ProvidersByIdResponse, PatchApiV1ProvidersByIdResponses, PatchApiV1RolesByIdData, PatchApiV1RolesByIdError, PatchApiV1RolesByIdErrors, PatchApiV1RolesByIdPermissionsData, PatchApiV1RolesByIdPermissionsError, PatchApiV1RolesByIdPermissionsErrors, PatchApiV1RolesByIdPermissionsResponse, PatchApiV1RolesByIdPermissionsResponses, PatchApiV1RolesByIdResponse, PatchApiV1RolesByIdResponses, PatchApiV1TasksByIdData, PatchApiV1TasksByIdError, PatchApiV1TasksByIdErrors, PatchApiV1TasksByIdResponse, PatchApiV1TasksByIdResponses, PatchApiV1TasksByIdStatusData, PatchApiV1TasksByIdStatusError, PatchApiV1TasksByIdStatusErrors, PatchApiV1TasksByIdStatusResponse, PatchApiV1TasksByIdStatusResponses, PatchApiV1TopicsByIdData, PatchApiV1TopicsByIdError, PatchApiV1TopicsByIdErrors, PatchApiV1TopicsByIdResponse, PatchApiV1TopicsByIdResponses, PatchApiV1UsersByIdData, PatchApiV1UsersByIdError, PatchApiV1UsersByIdErrors, PatchApiV1UsersByIdResponse, PatchApiV1UsersByIdResponses, PatchApiV1UsersByIdRolesData, PatchApiV1UsersByIdRolesError, PatchApiV1UsersByIdRolesErrors, PatchApiV1UsersByIdRolesResponse, PatchApiV1UsersByIdRolesResponses, Permission, PostApiV1AgentGroupsData, PostApiV1AgentGroupsError, PostApiV1AgentGroupsErrors, PostApiV1AgentGroupsResponse, PostApiV1AgentGroupsResponses, PostApiV1AgentsByIdDuplicateData, PostApiV1AgentsByIdDuplicateError, PostApiV1AgentsByIdDuplicateErrors, PostApiV1AgentsByIdDuplicateResponse, PostApiV1AgentsByIdDuplicateResponses, PostApiV1AgentsData, PostApiV1AgentsError, PostApiV1AgentsErrors, PostApiV1AgentsResponse, PostApiV1AgentsResponses, PostApiV1ApiKeysData, PostApiV1ApiKeysError, PostApiV1ApiKeysErrors, PostApiV1ApiKeysResponse, PostApiV1ApiKeysResponses, PostApiV1ChatData, PostApiV1ChatError, PostApiV1ChatErrors, PostApiV1ChatGenerateReplyData, PostApiV1ChatGenerateReplyError, PostApiV1ChatGenerateReplyErrors, PostApiV1ChatGenerateReplyResponse, PostApiV1ChatGenerateReplyResponses, PostApiV1ChatResponse, PostApiV1ChatResponses, PostApiV1ChatTranslateData, PostApiV1ChatTranslateError, PostApiV1ChatTranslateErrors, PostApiV1ChatTranslateResponse, PostApiV1ChatTranslateResponses, PostApiV1EvalBenchmarksData, PostApiV1EvalBenchmarksError, PostApiV1EvalBenchmarksErrors, PostApiV1EvalBenchmarksResponse, PostApiV1EvalBenchmarksResponses, PostApiV1EvalDatasetsByDatasetIdTestCasesData, PostApiV1EvalDatasetsByDatasetIdTestCasesError, PostApiV1EvalDatasetsByDatasetIdTestCasesErrors, PostApiV1EvalDatasetsByDatasetIdTestCasesResponse, PostApiV1EvalDatasetsByDatasetIdTestCasesResponses, PostApiV1EvalDatasetsData, PostApiV1EvalDatasetsError, PostApiV1EvalDatasetsErrors, PostApiV1EvalDatasetsResponse, PostApiV1EvalDatasetsResponses, PostApiV1EvalRunsByIdClaimData, PostApiV1EvalRunsByIdClaimError, PostApiV1EvalRunsByIdClaimErrors, PostApiV1EvalRunsByIdClaimResponse, PostApiV1EvalRunsByIdClaimResponses, PostApiV1EvalRunsByIdResultsData, PostApiV1EvalRunsByIdResultsError, PostApiV1EvalRunsByIdResultsErrors, PostApiV1EvalRunsByIdResultsResponse, PostApiV1EvalRunsByIdResultsResponses, PostApiV1EvalRunsByIdRetryErrorsData, PostApiV1EvalRunsByIdRetryErrorsError, PostApiV1EvalRunsByIdRetryErrorsErrors, PostApiV1EvalRunsByIdRetryErrorsResponse, PostApiV1EvalRunsByIdRetryErrorsResponses, PostApiV1EvalRunsData, PostApiV1EvalRunsError, PostApiV1EvalRunsErrors, PostApiV1EvalRunsResponse, PostApiV1EvalRunsResponses, PostApiV1FilesBatchesData, PostApiV1FilesBatchesError, PostApiV1FilesBatchesErrors, PostApiV1FilesBatchesResponse, PostApiV1FilesBatchesResponses, PostApiV1FilesByIdChunksData, PostApiV1FilesByIdChunksError, PostApiV1FilesByIdChunksErrors, PostApiV1FilesByIdChunksResponse, PostApiV1FilesByIdChunksResponses, PostApiV1FilesByIdParsesData, PostApiV1FilesByIdParsesError, PostApiV1FilesByIdParsesErrors, PostApiV1FilesByIdParsesResponse, PostApiV1FilesByIdParsesResponses, PostApiV1FilesData, PostApiV1FilesError, PostApiV1FilesErrors, PostApiV1FilesQueriesData, PostApiV1FilesQueriesError, PostApiV1FilesQueriesErrors, PostApiV1FilesQueriesResponse, PostApiV1FilesQueriesResponses, PostApiV1FilesResponse, PostApiV1FilesResponses, PostApiV1GoalsByIdAdvanceData, PostApiV1GoalsByIdAdvanceError, PostApiV1GoalsByIdAdvanceErrors, PostApiV1GoalsByIdAdvanceResponse, PostApiV1GoalsByIdAdvanceResponses, PostApiV1GoalsByIdPauseData, PostApiV1GoalsByIdPauseError, PostApiV1GoalsByIdPauseErrors, PostApiV1GoalsByIdPauseResponse, PostApiV1GoalsByIdPauseResponses, PostApiV1GoalsByIdRestartData, PostApiV1GoalsByIdRestartError, PostApiV1GoalsByIdRestartErrors, PostApiV1GoalsByIdRestartResponse, PostApiV1GoalsByIdRestartResponses, PostApiV1GoalsByIdResumeData, PostApiV1GoalsByIdResumeError, PostApiV1GoalsByIdResumeErrors, PostApiV1GoalsByIdResumeResponse, PostApiV1GoalsByIdResumeResponses, PostApiV1GoalsData, PostApiV1GoalsError, PostApiV1GoalsErrors, PostApiV1GoalsResponse, PostApiV1GoalsResponses, PostApiV1ImMessagesData, PostApiV1ImMessagesError, PostApiV1ImMessagesErrors, PostApiV1ImMessagesResponse, PostApiV1ImMessagesResponses, PostApiV1ImTopicsByTopicIdReadData, PostApiV1ImTopicsByTopicIdReadError, PostApiV1ImTopicsByTopicIdReadErrors, PostApiV1ImTopicsByTopicIdReadResponse, PostApiV1ImTopicsByTopicIdReadResponses, PostApiV1KnowledgeBasesByIdFilesBatchData, PostApiV1KnowledgeBasesByIdFilesBatchError, PostApiV1KnowledgeBasesByIdFilesBatchErrors, PostApiV1KnowledgeBasesByIdFilesBatchResponse, PostApiV1KnowledgeBasesByIdFilesBatchResponses, PostApiV1KnowledgeBasesByIdFilesMoveData, PostApiV1KnowledgeBasesByIdFilesMoveError, PostApiV1KnowledgeBasesByIdFilesMoveErrors, PostApiV1KnowledgeBasesByIdFilesMoveResponse, PostApiV1KnowledgeBasesByIdFilesMoveResponses, PostApiV1KnowledgeBasesData, PostApiV1KnowledgeBasesError, PostApiV1KnowledgeBasesErrors, PostApiV1KnowledgeBasesResponse, PostApiV1KnowledgeBasesResponses, PostApiV1McpServersByIdSyncData, PostApiV1McpServersByIdSyncError, PostApiV1McpServersByIdSyncErrors, PostApiV1McpServersByIdSyncResponse, PostApiV1McpServersByIdSyncResponses, PostApiV1McpServersData, PostApiV1McpServersError, PostApiV1McpServersErrors, PostApiV1McpServersResponse, PostApiV1McpServersResponses, PostApiV1MessagesData, PostApiV1MessagesError, PostApiV1MessagesErrors, PostApiV1MessagesRepliesData, PostApiV1MessagesRepliesError, PostApiV1MessagesRepliesErrors, PostApiV1MessagesRepliesResponse, PostApiV1MessagesRepliesResponses, PostApiV1MessagesResponse, PostApiV1MessagesResponses, PostApiV1MessageTranslationsByMessageIdData, PostApiV1MessageTranslationsByMessageIdError, PostApiV1MessageTranslationsByMessageIdErrors, PostApiV1MessageTranslationsByMessageIdResponse, PostApiV1MessageTranslationsByMessageIdResponses, PostApiV1ModelsData, PostApiV1ModelsError, PostApiV1ModelsErrors, PostApiV1ModelsResponse, PostApiV1ModelsResponses, PostApiV1NotificationsArchiveAllData, PostApiV1NotificationsArchiveAllError, PostApiV1NotificationsArchiveAllErrors, PostApiV1NotificationsArchiveAllResponse, PostApiV1NotificationsArchiveAllResponses, PostApiV1NotificationsByIdArchiveData, PostApiV1NotificationsByIdArchiveError, PostApiV1NotificationsByIdArchiveErrors, PostApiV1NotificationsByIdArchiveResponse, PostApiV1NotificationsByIdArchiveResponses, PostApiV1NotificationsReadAllData, PostApiV1NotificationsReadAllError, PostApiV1NotificationsReadAllErrors, PostApiV1NotificationsReadAllResponse, PostApiV1NotificationsReadAllResponses, PostApiV1NotificationsReadData, PostApiV1NotificationsReadError, PostApiV1NotificationsReadErrors, PostApiV1NotificationsReadResponse, PostApiV1NotificationsReadResponses, PostApiV1PermissionsData, PostApiV1PermissionsError, PostApiV1PermissionsErrors, PostApiV1PermissionsResponse, PostApiV1PermissionsResponses, PostApiV1ProvidersData, PostApiV1ProvidersError, PostApiV1ProvidersErrors, PostApiV1ProvidersResponse, PostApiV1ProvidersResponses, PostApiV1ResponsesData, PostApiV1ResponsesError, PostApiV1ResponsesErrors, PostApiV1ResponsesResponse, PostApiV1ResponsesResponses, PostApiV1RolesData, PostApiV1RolesError, PostApiV1RolesErrors, PostApiV1RolesResponse, PostApiV1RolesResponses, PostApiV1SignalsSourceEventsData, PostApiV1SignalsSourceEventsError, PostApiV1SignalsSourceEventsErrors, PostApiV1SignalsSourceEventsResponse, PostApiV1SignalsSourceEventsResponses, PostApiV1SignalsTriggerData, PostApiV1SignalsTriggerError, PostApiV1SignalsTriggerErrors, PostApiV1SignalsTriggerResponse, PostApiV1SignalsTriggerResponses, PostApiV1TasksData, PostApiV1TasksError, PostApiV1TasksErrors, PostApiV1TasksResponse, PostApiV1TasksResponses, PostApiV1TopicsData, PostApiV1TopicsError, PostApiV1TopicsErrors, PostApiV1TopicsResponse, PostApiV1TopicsResponses, PostApiV1UsersData, PostApiV1UsersError, PostApiV1UsersErrors, PostApiV1UsersResponse, PostApiV1UsersResponses, Provider, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultData, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultError, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultErrors, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultResponse, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultResponses, PutApiV1PushTokensByDeviceIdData, PutApiV1PushTokensByDeviceIdError, PutApiV1PushTokensByDeviceIdErrors, PutApiV1PushTokensByDeviceIdResponse, PutApiV1PushTokensByDeviceIdResponses, Role, Topic, Usage, User } from './types.gen';diff --git a/packages/sdk/src/generated/sdk.gen.ts b/packages/sdk/src/generated/sdk.gen.tsindex dfba84e0aec..3d8e8adea26 100644--- a/packages/sdk/src/generated/sdk.gen.ts+++ b/packages/sdk/src/generated/sdk.gen.ts@@ -2,7 +2,7 @@import { type Client, type ClientMeta, formDataBodySerializer, type Options as Options2, type RequestResult, type TDataShape } from './client';import { client } from './client.gen';-import type { DeleteApiV1AgentGroupsByIdData, DeleteApiV1AgentGroupsByIdErrors, DeleteApiV1AgentGroupsByIdResponses, DeleteApiV1AgentsByIdData, DeleteApiV1AgentsByIdErrors, DeleteApiV1AgentsByIdResponses, DeleteApiV1ApiKeysByIdData, DeleteApiV1ApiKeysByIdErrors, DeleteApiV1ApiKeysByIdResponses, DeleteApiV1EvalBenchmarksByIdData, DeleteApiV1EvalBenchmarksByIdErrors, DeleteApiV1EvalBenchmarksByIdResponses, DeleteApiV1EvalDatasetsByIdData, DeleteApiV1EvalDatasetsByIdErrors, DeleteApiV1EvalDatasetsByIdResponses, DeleteApiV1EvalTestCasesByIdData, DeleteApiV1EvalTestCasesByIdErrors, DeleteApiV1EvalTestCasesByIdResponses, DeleteApiV1FilesByIdData, DeleteApiV1FilesByIdErrors, DeleteApiV1FilesByIdResponses, DeleteApiV1GoalsByIdData, DeleteApiV1GoalsByIdErrors, DeleteApiV1GoalsByIdResponses, DeleteApiV1KnowledgeBasesByIdData, DeleteApiV1KnowledgeBasesByIdErrors, DeleteApiV1KnowledgeBasesByIdFilesBatchData, DeleteApiV1KnowledgeBasesByIdFilesBatchErrors, DeleteApiV1KnowledgeBasesByIdFilesBatchResponses, DeleteApiV1KnowledgeBasesByIdResponses, DeleteApiV1McpServersByIdData, DeleteApiV1McpServersByIdErrors, DeleteApiV1McpServersByIdResponses, DeleteApiV1MemoriesByCategoryByIdData, DeleteApiV1MemoriesByCategoryByIdErrors, DeleteApiV1MemoriesByCategoryByIdResponses, DeleteApiV1MemoriesData, DeleteApiV1MemoriesErrors, DeleteApiV1MemoriesResponses, DeleteApiV1MessagesByIdData, DeleteApiV1MessagesByIdErrors, DeleteApiV1MessagesByIdResponses, DeleteApiV1MessagesData, DeleteApiV1MessagesErrors, DeleteApiV1MessagesResponses, DeleteApiV1MessageTranslationsByMessageIdData, DeleteApiV1MessageTranslationsByMessageIdErrors, DeleteApiV1MessageTranslationsByMessageIdResponses, DeleteApiV1PermissionsByIdData, DeleteApiV1PermissionsByIdErrors, DeleteApiV1PermissionsByIdResponses, DeleteApiV1ProvidersByIdData, DeleteApiV1ProvidersByIdErrors, DeleteApiV1ProvidersByIdResponses, DeleteApiV1RolesByIdData, DeleteApiV1RolesByIdErrors, DeleteApiV1RolesByIdPermissionsData, DeleteApiV1RolesByIdPermissionsErrors, DeleteApiV1RolesByIdPermissionsResponses, DeleteApiV1RolesByIdResponses, DeleteApiV1TasksByIdData, DeleteApiV1TasksByIdErrors, DeleteApiV1TasksByIdResponses, DeleteApiV1TopicsByIdData, DeleteApiV1TopicsByIdErrors, DeleteApiV1TopicsByIdResponses, DeleteApiV1UsersByIdData, DeleteApiV1UsersByIdErrors, DeleteApiV1UsersByIdResponses, DeleteApiV1UsersByIdRolesData, DeleteApiV1UsersByIdRolesErrors, DeleteApiV1UsersByIdRolesResponses, GetApiV1AgentGroupsByIdData, GetApiV1AgentGroupsByIdErrors, GetApiV1AgentGroupsByIdResponses, GetApiV1AgentGroupsData, GetApiV1AgentGroupsErrors, GetApiV1AgentGroupsResponses, GetApiV1AgentsByIdData, GetApiV1AgentsByIdErrors, GetApiV1AgentsByIdResponses, GetApiV1AgentsData, GetApiV1AgentsErrors, GetApiV1AgentsResponses, GetApiV1ApiKeysByIdData, GetApiV1ApiKeysByIdErrors, GetApiV1ApiKeysByIdResponses, GetApiV1ApiKeysData, GetApiV1ApiKeysErrors, GetApiV1ApiKeysResponses, GetApiV1EvalBenchmarksByIdData, GetApiV1EvalBenchmarksByIdErrors, GetApiV1EvalBenchmarksByIdResponses, GetApiV1EvalBenchmarksData, GetApiV1EvalBenchmarksErrors, GetApiV1EvalBenchmarksResponses, GetApiV1EvalDatasetsByDatasetIdTestCasesData, GetApiV1EvalDatasetsByDatasetIdTestCasesErrors, GetApiV1EvalDatasetsByDatasetIdTestCasesResponses, GetApiV1EvalDatasetsByIdData, GetApiV1EvalDatasetsByIdErrors, GetApiV1EvalDatasetsByIdResponses, GetApiV1EvalDatasetsData, GetApiV1EvalDatasetsErrors, GetApiV1EvalDatasetsResponses, GetApiV1EvalRunsByIdData, GetApiV1EvalRunsByIdErrors, GetApiV1EvalRunsByIdResponses, GetApiV1EvalRunsByIdResultsData, GetApiV1EvalRunsByIdResultsErrors, GetApiV1EvalRunsByIdResultsResponses, GetApiV1EvalRunsByIdTopicsData, GetApiV1EvalRunsByIdTopicsErrors, GetApiV1EvalRunsByIdTopicsResponses, GetApiV1EvalRunsData, GetApiV1EvalRunsErrors, GetApiV1EvalRunsResponses, GetApiV1EvalTestCasesByIdData, GetApiV1EvalTestCasesByIdErrors, GetApiV1EvalTestCasesByIdResponses, GetApiV1FilesByIdChunksData, GetApiV1FilesByIdChunksErrors, GetApiV1FilesByIdChunksResponses, GetApiV1FilesByIdData, GetApiV1FilesByIdErrors, GetApiV1FilesByIdResponses, GetApiV1FilesByIdUrlData, GetApiV1FilesByIdUrlErrors, GetApiV1FilesByIdUrlResponses, GetApiV1FilesData, GetApiV1FilesErrors, GetApiV1FilesResponses, GetApiV1GoalsByIdData, GetApiV1GoalsByIdErrors, GetApiV1GoalsByIdResponses, GetApiV1GoalsByIdSupervisionData, GetApiV1GoalsByIdSupervisionErrors, GetApiV1GoalsByIdSupervisionResponses, GetApiV1GoalsData, GetApiV1GoalsErrors, GetApiV1GoalsResponses, GetApiV1HealthData, GetApiV1HealthErrors, GetApiV1HealthResponses, GetApiV1KnowledgeBasesByIdData, GetApiV1KnowledgeBasesByIdErrors, GetApiV1KnowledgeBasesByIdFilesData, GetApiV1KnowledgeBasesByIdFilesErrors, GetApiV1KnowledgeBasesByIdFilesResponses, GetApiV1KnowledgeBasesByIdResponses, GetApiV1KnowledgeBasesData, GetApiV1KnowledgeBasesErrors, GetApiV1KnowledgeBasesResponses, GetApiV1McpServersByIdData, GetApiV1McpServersByIdErrors, GetApiV1McpServersByIdResponses, GetApiV1McpServersData, GetApiV1McpServersErrors, GetApiV1McpServersResponses, GetApiV1MemoriesByCategoryData, GetApiV1MemoriesByCategoryErrors, GetApiV1MemoriesByCategoryResponses, GetApiV1MemoriesPersonaData, GetApiV1MemoriesPersonaErrors, GetApiV1MemoriesPersonaResponses, GetApiV1MemoriesPersonaVersionsData, GetApiV1MemoriesPersonaVersionsErrors, GetApiV1MemoriesPersonaVersionsResponses, GetApiV1MessagesByIdData, GetApiV1MessagesByIdErrors, GetApiV1MessagesByIdResponses, GetApiV1MessagesCountData, GetApiV1MessagesCountErrors, GetApiV1MessagesCountResponses, GetApiV1MessagesData, GetApiV1MessagesErrors, GetApiV1MessagesResponses, GetApiV1MessageTranslationsByMessageIdData, GetApiV1MessageTranslationsByMessageIdErrors, GetApiV1MessageTranslationsByMessageIdResponses, GetApiV1ModelsByProviderIdByModelIdData, GetApiV1ModelsByProviderIdByModelIdErrors, GetApiV1ModelsByProviderIdByModelIdResponses, GetApiV1ModelsData, GetApiV1ModelsErrors, GetApiV1ModelsResponses, GetApiV1NotificationsCountsData, GetApiV1NotificationsCountsErrors, GetApiV1NotificationsCountsResponses, GetApiV1NotificationsData, GetApiV1NotificationsErrors, GetApiV1NotificationsResponses, GetApiV1NotificationsUnreadCountData, GetApiV1NotificationsUnreadCountErrors, GetApiV1NotificationsUnreadCountResponses, GetApiV1PermissionsByIdData, GetApiV1PermissionsByIdErrors, GetApiV1PermissionsByIdResponses, GetApiV1PermissionsData, GetApiV1PermissionsErrors, GetApiV1PermissionsResponses, GetApiV1PluginsData, GetApiV1PluginsErrors, GetApiV1PluginsResponses, GetApiV1ProvidersByIdData, GetApiV1ProvidersByIdErrors, GetApiV1ProvidersByIdResponses, GetApiV1ProvidersData, GetApiV1ProvidersErrors, GetApiV1ProvidersResponses, GetApiV1RolesByIdData, GetApiV1RolesByIdErrors, GetApiV1RolesByIdPermissionsData, GetApiV1RolesByIdPermissionsErrors, GetApiV1RolesByIdPermissionsResponses, GetApiV1RolesByIdResponses, GetApiV1RolesData, GetApiV1RolesErrors, GetApiV1RolesResponses, GetApiV1SignalsReceiptsData, GetApiV1SignalsReceiptsErrors, GetApiV1SignalsReceiptsResponses, GetApiV1TasksByIdData, GetApiV1TasksByIdErrors, GetApiV1TasksByIdResponses, GetApiV1TasksData, GetApiV1TasksErrors, GetApiV1TasksResponses, GetApiV1TopicsByIdData, GetApiV1TopicsByIdErrors, GetApiV1TopicsByIdResponses, GetApiV1TopicsByTopicIdThreadsData, GetApiV1TopicsByTopicIdThreadsErrors, GetApiV1TopicsByTopicIdThreadsResponses, GetApiV1TopicsData, GetApiV1TopicsErrors, GetApiV1TopicsResponses, GetApiV1UsageData, GetApiV1UsageErrors, GetApiV1UsageResponses, GetApiV1UsersByIdData, GetApiV1UsersByIdErrors, GetApiV1UsersByIdResponses, GetApiV1UsersByIdRolesData, GetApiV1UsersByIdRolesErrors, GetApiV1UsersByIdRolesResponses, GetApiV1UsersData, GetApiV1UsersErrors, GetApiV1UsersMeData, GetApiV1UsersMeErrors, GetApiV1UsersMeResponses, GetApiV1UsersResponses, PatchApiV1AgentGroupsByIdData, PatchApiV1AgentGroupsByIdErrors, PatchApiV1AgentGroupsByIdResponses, PatchApiV1AgentsByIdData, PatchApiV1AgentsByIdErrors, PatchApiV1AgentsByIdResponses, PatchApiV1ApiKeysByIdData, PatchApiV1ApiKeysByIdErrors, PatchApiV1ApiKeysByIdResponses, PatchApiV1EvalBenchmarksByIdData, PatchApiV1EvalBenchmarksByIdErrors, PatchApiV1EvalBenchmarksByIdResponses, PatchApiV1EvalDatasetsByIdData, PatchApiV1EvalDatasetsByIdErrors, PatchApiV1EvalDatasetsByIdResponses, PatchApiV1EvalRunsByIdStatusData, PatchApiV1EvalRunsByIdStatusErrors, PatchApiV1EvalRunsByIdStatusResponses, PatchApiV1EvalTestCasesByIdData, PatchApiV1EvalTestCasesByIdErrors, PatchApiV1EvalTestCasesByIdResponses, PatchApiV1FilesByIdData, PatchApiV1FilesByIdErrors, PatchApiV1FilesByIdResponses, PatchApiV1GoalsByIdData, PatchApiV1GoalsByIdErrors, PatchApiV1GoalsByIdResponses, PatchApiV1KnowledgeBasesByIdData, PatchApiV1KnowledgeBasesByIdErrors, PatchApiV1KnowledgeBasesByIdResponses, PatchApiV1McpServersByIdData, PatchApiV1McpServersByIdErrors, PatchApiV1McpServersByIdResponses, PatchApiV1MessageTranslationsByMessageIdData, PatchApiV1MessageTranslationsByMessageIdErrors, PatchApiV1MessageTranslationsByMessageIdResponses, PatchApiV1ModelsByProviderIdByModelIdData, PatchApiV1ModelsByProviderIdByModelIdErrors, PatchApiV1ModelsByProviderIdByModelIdResponses, PatchApiV1PermissionsByIdData, PatchApiV1PermissionsByIdErrors, PatchApiV1PermissionsByIdResponses, PatchApiV1ProvidersByIdData, PatchApiV1ProvidersByIdErrors, PatchApiV1ProvidersByIdResponses, PatchApiV1RolesByIdData, PatchApiV1RolesByIdErrors, PatchApiV1RolesByIdPermissionsData, PatchApiV1RolesByIdPermissionsErrors, PatchApiV1RolesByIdPermissionsResponses, PatchApiV1RolesByIdResponses, PatchApiV1TasksByIdData, PatchApiV1TasksByIdErrors, PatchApiV1TasksByIdResponses, PatchApiV1TasksByIdStatusData, PatchApiV1TasksByIdStatusErrors, PatchApiV1TasksByIdStatusResponses, PatchApiV1TopicsByIdData, PatchApiV1TopicsByIdErrors, PatchApiV1TopicsByIdResponses, PatchApiV1UsersByIdData, PatchApiV1UsersByIdErrors, PatchApiV1UsersByIdResponses, PatchApiV1UsersByIdRolesData, PatchApiV1UsersByIdRolesErrors, PatchApiV1UsersByIdRolesResponses, PostApiV1AgentGroupsData, PostApiV1AgentGroupsErrors, PostApiV1AgentGroupsResponses, PostApiV1AgentsByIdDuplicateData, PostApiV1AgentsByIdDuplicateErrors, PostApiV1AgentsByIdDuplicateResponses, PostApiV1AgentsData, PostApiV1AgentsErrors, PostApiV1AgentsResponses, PostApiV1ApiKeysData, PostApiV1ApiKeysErrors, PostApiV1ApiKeysResponses, PostApiV1ChatData, PostApiV1ChatErrors, PostApiV1ChatGenerateReplyData, PostApiV1ChatGenerateReplyErrors, PostApiV1ChatGenerateReplyResponses, PostApiV1ChatResponses, PostApiV1ChatTranslateData, PostApiV1ChatTranslateErrors, PostApiV1ChatTranslateResponses, PostApiV1EvalBenchmarksData, PostApiV1EvalBenchmarksErrors, PostApiV1EvalBenchmarksResponses, PostApiV1EvalDatasetsByDatasetIdTestCasesData, PostApiV1EvalDatasetsByDatasetIdTestCasesErrors, PostApiV1EvalDatasetsByDatasetIdTestCasesResponses, PostApiV1EvalDatasetsData, PostApiV1EvalDatasetsErrors, PostApiV1EvalDatasetsResponses, PostApiV1EvalRunsByIdClaimData, PostApiV1EvalRunsByIdClaimErrors, PostApiV1EvalRunsByIdClaimResponses, PostApiV1EvalRunsByIdResultsData, PostApiV1EvalRunsByIdResultsErrors, PostApiV1EvalRunsByIdResultsResponses, PostApiV1EvalRunsByIdRetryErrorsData, PostApiV1EvalRunsByIdRetryErrorsErrors, PostApiV1EvalRunsByIdRetryErrorsResponses, PostApiV1EvalRunsData, PostApiV1EvalRunsErrors, PostApiV1EvalRunsResponses, PostApiV1FilesBatchesData, PostApiV1FilesBatchesErrors, PostApiV1FilesBatchesResponses, PostApiV1FilesByIdChunksData, PostApiV1FilesByIdChunksErrors, PostApiV1FilesByIdChunksResponses, PostApiV1FilesByIdParsesData, PostApiV1FilesByIdParsesErrors, PostApiV1FilesByIdParsesResponses, PostApiV1FilesData, PostApiV1FilesErrors, PostApiV1FilesQueriesData, PostApiV1FilesQueriesErrors, PostApiV1FilesQueriesResponses, PostApiV1FilesResponses, PostApiV1GoalsByIdAdvanceData, PostApiV1GoalsByIdAdvanceErrors, PostApiV1GoalsByIdAdvanceResponses, PostApiV1GoalsByIdPauseData, PostApiV1GoalsByIdPauseErrors, PostApiV1GoalsByIdPauseResponses, PostApiV1GoalsByIdRestartData, PostApiV1GoalsByIdRestartErrors, PostApiV1GoalsByIdRestartResponses, PostApiV1GoalsByIdResumeData, PostApiV1GoalsByIdResumeErrors, PostApiV1GoalsByIdResumeResponses, PostApiV1GoalsData, PostApiV1GoalsErrors, PostApiV1GoalsResponses, PostApiV1KnowledgeBasesByIdFilesBatchData, PostApiV1KnowledgeBasesByIdFilesBatchErrors, PostApiV1KnowledgeBasesByIdFilesBatchResponses, PostApiV1KnowledgeBasesByIdFilesMoveData, PostApiV1KnowledgeBasesByIdFilesMoveErrors, PostApiV1KnowledgeBasesByIdFilesMoveResponses, PostApiV1KnowledgeBasesData, PostApiV1KnowledgeBasesErrors, PostApiV1KnowledgeBasesResponses, PostApiV1McpServersByIdSyncData, PostApiV1McpServersByIdSyncErrors, PostApiV1McpServersByIdSyncResponses, PostApiV1McpServersData, PostApiV1McpServersErrors, PostApiV1McpServersResponses, PostApiV1MessagesData, PostApiV1MessagesErrors, PostApiV1MessagesRepliesData, PostApiV1MessagesRepliesErrors, PostApiV1MessagesRepliesResponses, PostApiV1MessagesResponses, PostApiV1MessageTranslationsByMessageIdData, PostApiV1MessageTranslationsByMessageIdErrors, PostApiV1MessageTranslationsByMessageIdResponses, PostApiV1ModelsData, PostApiV1ModelsErrors, PostApiV1ModelsResponses, PostApiV1NotificationsArchiveAllData, PostApiV1NotificationsArchiveAllErrors, PostApiV1NotificationsArchiveAllResponses, PostApiV1NotificationsByIdArchiveData, PostApiV1NotificationsByIdArchiveErrors, PostApiV1NotificationsByIdArchiveResponses, PostApiV1NotificationsReadAllData, PostApiV1NotificationsReadAllErrors, PostApiV1NotificationsReadAllResponses, PostApiV1NotificationsReadData, PostApiV1NotificationsReadErrors, PostApiV1NotificationsReadResponses, PostApiV1PermissionsData, PostApiV1PermissionsErrors, PostApiV1PermissionsResponses, PostApiV1ProvidersData, PostApiV1ProvidersErrors, PostApiV1ProvidersResponses, PostApiV1ResponsesData, PostApiV1ResponsesErrors, PostApiV1ResponsesResponses, PostApiV1RolesData, PostApiV1RolesErrors, PostApiV1RolesResponses, PostApiV1SignalsSourceEventsData, PostApiV1SignalsSourceEventsErrors, PostApiV1SignalsSourceEventsResponses, PostApiV1SignalsTriggerData, PostApiV1SignalsTriggerErrors, PostApiV1SignalsTriggerResponses, PostApiV1TasksData, PostApiV1TasksErrors, PostApiV1TasksResponses, PostApiV1TopicsData, PostApiV1TopicsErrors, PostApiV1TopicsResponses, PostApiV1UsersData, PostApiV1UsersErrors, PostApiV1UsersResponses, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultData, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultErrors, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultResponses } from './types.gen';+import type { DeleteApiV1AgentGroupsByIdData, DeleteApiV1AgentGroupsByIdErrors, DeleteApiV1AgentGroupsByIdResponses, DeleteApiV1AgentsByIdData, DeleteApiV1AgentsByIdErrors, DeleteApiV1AgentsByIdResponses, DeleteApiV1ApiKeysByIdData, DeleteApiV1ApiKeysByIdErrors, DeleteApiV1ApiKeysByIdResponses, DeleteApiV1EvalBenchmarksByIdData, DeleteApiV1EvalBenchmarksByIdErrors, DeleteApiV1EvalBenchmarksByIdResponses, DeleteApiV1EvalDatasetsByIdData, DeleteApiV1EvalDatasetsByIdErrors, DeleteApiV1EvalDatasetsByIdResponses, DeleteApiV1EvalTestCasesByIdData, DeleteApiV1EvalTestCasesByIdErrors, DeleteApiV1EvalTestCasesByIdResponses, DeleteApiV1FilesByIdData, DeleteApiV1FilesByIdErrors, DeleteApiV1FilesByIdResponses, DeleteApiV1GoalsByIdData, DeleteApiV1GoalsByIdErrors, DeleteApiV1GoalsByIdResponses, DeleteApiV1KnowledgeBasesByIdData, DeleteApiV1KnowledgeBasesByIdErrors, DeleteApiV1KnowledgeBasesByIdFilesBatchData, DeleteApiV1KnowledgeBasesByIdFilesBatchErrors, DeleteApiV1KnowledgeBasesByIdFilesBatchResponses, DeleteApiV1KnowledgeBasesByIdResponses, DeleteApiV1McpServersByIdData, DeleteApiV1McpServersByIdErrors, DeleteApiV1McpServersByIdResponses, DeleteApiV1MemoriesByCategoryByIdData, DeleteApiV1MemoriesByCategoryByIdErrors, DeleteApiV1MemoriesByCategoryByIdResponses, DeleteApiV1MemoriesData, DeleteApiV1MemoriesErrors, DeleteApiV1MemoriesResponses, DeleteApiV1MessagesByIdData, DeleteApiV1MessagesByIdErrors, DeleteApiV1MessagesByIdResponses, DeleteApiV1MessagesData, DeleteApiV1MessagesErrors, DeleteApiV1MessagesResponses, DeleteApiV1MessageTranslationsByMessageIdData, DeleteApiV1MessageTranslationsByMessageIdErrors, DeleteApiV1MessageTranslationsByMessageIdResponses, DeleteApiV1PermissionsByIdData, DeleteApiV1PermissionsByIdErrors, DeleteApiV1PermissionsByIdResponses, DeleteApiV1ProvidersByIdData, DeleteApiV1ProvidersByIdErrors, DeleteApiV1ProvidersByIdResponses, DeleteApiV1PushTokensByDeviceIdData, DeleteApiV1PushTokensByDeviceIdErrors, DeleteApiV1PushTokensByDeviceIdResponses, DeleteApiV1RolesByIdData, DeleteApiV1RolesByIdErrors, DeleteApiV1RolesByIdPermissionsData, DeleteApiV1RolesByIdPermissionsErrors, DeleteApiV1RolesByIdPermissionsResponses, DeleteApiV1RolesByIdResponses, DeleteApiV1TasksByIdData, DeleteApiV1TasksByIdErrors, DeleteApiV1TasksByIdResponses, DeleteApiV1TopicsByIdData, DeleteApiV1TopicsByIdErrors, DeleteApiV1TopicsByIdResponses, DeleteApiV1UsersByIdData, DeleteApiV1UsersByIdErrors, DeleteApiV1UsersByIdResponses, DeleteApiV1UsersByIdRolesData, DeleteApiV1UsersByIdRolesErrors, DeleteApiV1UsersByIdRolesResponses, GetApiV1AgentGroupsByIdData, GetApiV1AgentGroupsByIdErrors, GetApiV1AgentGroupsByIdResponses, GetApiV1AgentGroupsData, GetApiV1AgentGroupsErrors, GetApiV1AgentGroupsResponses, GetApiV1AgentsByIdData, GetApiV1AgentsByIdErrors, GetApiV1AgentsByIdResponses, GetApiV1AgentsData, GetApiV1AgentsErrors, GetApiV1AgentsResponses, GetApiV1ApiKeysByIdData, GetApiV1ApiKeysByIdErrors, GetApiV1ApiKeysByIdResponses, GetApiV1ApiKeysData, GetApiV1ApiKeysErrors, GetApiV1ApiKeysResponses, GetApiV1EvalBenchmarksByIdData, GetApiV1EvalBenchmarksByIdErrors, GetApiV1EvalBenchmarksByIdResponses, GetApiV1EvalBenchmarksData, GetApiV1EvalBenchmarksErrors, GetApiV1EvalBenchmarksResponses, GetApiV1EvalDatasetsByDatasetIdTestCasesData, GetApiV1EvalDatasetsByDatasetIdTestCasesErrors, GetApiV1EvalDatasetsByDatasetIdTestCasesResponses, GetApiV1EvalDatasetsByIdData, GetApiV1EvalDatasetsByIdErrors, GetApiV1EvalDatasetsByIdResponses, GetApiV1EvalDatasetsData, GetApiV1EvalDatasetsErrors, GetApiV1EvalDatasetsResponses, GetApiV1EvalRunsByIdData, GetApiV1EvalRunsByIdErrors, GetApiV1EvalRunsByIdResponses, GetApiV1EvalRunsByIdResultsData, GetApiV1EvalRunsByIdResultsErrors, GetApiV1EvalRunsByIdResultsResponses, GetApiV1EvalRunsByIdTopicsData, GetApiV1EvalRunsByIdTopicsErrors, GetApiV1EvalRunsByIdTopicsResponses, GetApiV1EvalRunsData, GetApiV1EvalRunsErrors, GetApiV1EvalRunsResponses, GetApiV1EvalTestCasesByIdData, GetApiV1EvalTestCasesByIdErrors, GetApiV1EvalTestCasesByIdResponses, GetApiV1FilesByIdChunksData, GetApiV1FilesByIdChunksErrors, GetApiV1FilesByIdChunksResponses, GetApiV1FilesByIdData, GetApiV1FilesByIdErrors, GetApiV1FilesByIdResponses, GetApiV1FilesByIdUrlData, GetApiV1FilesByIdUrlErrors, GetApiV1FilesByIdUrlResponses, GetApiV1FilesData, GetApiV1FilesErrors, GetApiV1FilesResponses, GetApiV1GoalsByIdData, GetApiV1GoalsByIdErrors, GetApiV1GoalsByIdResponses, GetApiV1GoalsByIdSupervisionData, GetApiV1GoalsByIdSupervisionErrors, GetApiV1GoalsByIdSupervisionResponses, GetApiV1GoalsData, GetApiV1GoalsErrors, GetApiV1GoalsResponses, GetApiV1HealthData, GetApiV1HealthErrors, GetApiV1HealthResponses, GetApiV1ImTopicsByTopicIdSyncData, GetApiV1ImTopicsByTopicIdSyncErrors, GetApiV1ImTopicsByTopicIdSyncResponses, GetApiV1KnowledgeBasesByIdData, GetApiV1KnowledgeBasesByIdErrors, GetApiV1KnowledgeBasesByIdFilesData, GetApiV1KnowledgeBasesByIdFilesErrors, GetApiV1KnowledgeBasesByIdFilesResponses, GetApiV1KnowledgeBasesByIdResponses, GetApiV1KnowledgeBasesData, GetApiV1KnowledgeBasesErrors, GetApiV1KnowledgeBasesResponses, GetApiV1McpServersByIdData, GetApiV1McpServersByIdErrors, GetApiV1McpServersByIdResponses, GetApiV1McpServersData, GetApiV1McpServersErrors, GetApiV1McpServersResponses, GetApiV1MemoriesByCategoryData, GetApiV1MemoriesByCategoryErrors, GetApiV1MemoriesByCategoryResponses, GetApiV1MemoriesPersonaData, GetApiV1MemoriesPersonaErrors, GetApiV1MemoriesPersonaResponses, GetApiV1MemoriesPersonaVersionsData, GetApiV1MemoriesPersonaVersionsErrors, GetApiV1MemoriesPersonaVersionsResponses, GetApiV1MessagesByIdData, GetApiV1MessagesByIdErrors, GetApiV1MessagesByIdResponses, GetApiV1MessagesCountData, GetApiV1MessagesCountErrors, GetApiV1MessagesCountResponses, GetApiV1MessagesData, GetApiV1MessagesErrors, GetApiV1MessagesResponses, GetApiV1MessageTranslationsByMessageIdData, GetApiV1MessageTranslationsByMessageIdErrors, GetApiV1MessageTranslationsByMessageIdResponses, GetApiV1ModelsByProviderIdByModelIdData, GetApiV1ModelsByProviderIdByModelIdErrors, GetApiV1ModelsByProviderIdByModelIdResponses, GetApiV1ModelsData, GetApiV1ModelsErrors, GetApiV1ModelsResponses, GetApiV1NotificationsCountsData, GetApiV1NotificationsCountsErrors, GetApiV1NotificationsCountsResponses, GetApiV1NotificationsData, GetApiV1NotificationsErrors, GetApiV1NotificationsResponses, GetApiV1NotificationsUnreadCountData, GetApiV1NotificationsUnreadCountErrors, GetApiV1NotificationsUnreadCountResponses, GetApiV1PermissionsByIdData, GetApiV1PermissionsByIdErrors, GetApiV1PermissionsByIdResponses, GetApiV1PermissionsData, GetApiV1PermissionsErrors, GetApiV1PermissionsResponses, GetApiV1PluginsData, GetApiV1PluginsErrors, GetApiV1PluginsResponses, GetApiV1ProvidersByIdData, GetApiV1ProvidersByIdErrors, GetApiV1ProvidersByIdResponses, GetApiV1ProvidersData, GetApiV1ProvidersErrors, GetApiV1ProvidersResponses, GetApiV1RolesByIdData, GetApiV1RolesByIdErrors, GetApiV1RolesByIdPermissionsData, GetApiV1RolesByIdPermissionsErrors, GetApiV1RolesByIdPermissionsResponses, GetApiV1RolesByIdResponses, GetApiV1RolesData, GetApiV1RolesErrors, GetApiV1RolesResponses, GetApiV1SignalsReceiptsData, GetApiV1SignalsReceiptsErrors, GetApiV1SignalsReceiptsResponses, GetApiV1TasksByIdData, GetApiV1TasksByIdErrors, GetApiV1TasksByIdResponses, GetApiV1TasksData, GetApiV1TasksErrors, GetApiV1TasksResponses, GetApiV1TopicsByIdData, GetApiV1TopicsByIdErrors, GetApiV1TopicsByIdResponses, GetApiV1TopicsByTopicIdThreadsData, GetApiV1TopicsByTopicIdThreadsErrors, GetApiV1TopicsByTopicIdThreadsResponses, GetApiV1TopicsData, GetApiV1TopicsErrors, GetApiV1TopicsResponses, GetApiV1UsageData, GetApiV1UsageErrors, GetApiV1UsageResponses, GetApiV1UsersByIdData, GetApiV1UsersByIdErrors, GetApiV1UsersByIdResponses, GetApiV1UsersByIdRolesData, GetApiV1UsersByIdRolesErrors, GetApiV1UsersByIdRolesResponses, GetApiV1UsersData, GetApiV1UsersErrors, GetApiV1UsersMeData, GetApiV1UsersMeErrors, GetApiV1UsersMeResponses, GetApiV1UsersResponses, PatchApiV1AgentGroupsByIdData, PatchApiV1AgentGroupsByIdErrors, PatchApiV1AgentGroupsByIdResponses, PatchApiV1AgentsByIdData, PatchApiV1AgentsByIdErrors, PatchApiV1AgentsByIdResponses, PatchApiV1ApiKeysByIdData, PatchApiV1ApiKeysByIdErrors, PatchApiV1ApiKeysByIdResponses, PatchApiV1EvalBenchmarksByIdData, PatchApiV1EvalBenchmarksByIdErrors, PatchApiV1EvalBenchmarksByIdResponses, PatchApiV1EvalDatasetsByIdData, PatchApiV1EvalDatasetsByIdErrors, PatchApiV1EvalDatasetsByIdResponses, PatchApiV1EvalRunsByIdStatusData, PatchApiV1EvalRunsByIdStatusErrors, PatchApiV1EvalRunsByIdStatusResponses, PatchApiV1EvalTestCasesByIdData, PatchApiV1EvalTestCasesByIdErrors, PatchApiV1EvalTestCasesByIdResponses, PatchApiV1FilesByIdData, PatchApiV1FilesByIdErrors, PatchApiV1FilesByIdResponses, PatchApiV1GoalsByIdData, PatchApiV1GoalsByIdErrors, PatchApiV1GoalsByIdResponses, PatchApiV1KnowledgeBasesByIdData, PatchApiV1KnowledgeBasesByIdErrors, PatchApiV1KnowledgeBasesByIdResponses, PatchApiV1McpServersByIdData, PatchApiV1McpServersByIdErrors, PatchApiV1McpServersByIdResponses, PatchApiV1MessageTranslationsByMessageIdData, PatchApiV1MessageTranslationsByMessageIdErrors, PatchApiV1MessageTranslationsByMessageIdResponses, PatchApiV1ModelsByProviderIdByModelIdData, PatchApiV1ModelsByProviderIdByModelIdErrors, PatchApiV1ModelsByProviderIdByModelIdResponses, PatchApiV1PermissionsByIdData, PatchApiV1PermissionsByIdErrors, PatchApiV1PermissionsByIdResponses, PatchApiV1ProvidersByIdData, PatchApiV1ProvidersByIdErrors, PatchApiV1ProvidersByIdResponses, PatchApiV1RolesByIdData, PatchApiV1RolesByIdErrors, PatchApiV1RolesByIdPermissionsData, PatchApiV1RolesByIdPermissionsErrors, PatchApiV1RolesByIdPermissionsResponses, PatchApiV1RolesByIdResponses, PatchApiV1TasksByIdData, PatchApiV1TasksByIdErrors, PatchApiV1TasksByIdResponses, PatchApiV1TasksByIdStatusData, PatchApiV1TasksByIdStatusErrors, PatchApiV1TasksByIdStatusResponses, PatchApiV1TopicsByIdData, PatchApiV1TopicsByIdErrors, PatchApiV1TopicsByIdResponses, PatchApiV1UsersByIdData, PatchApiV1UsersByIdErrors, PatchApiV1UsersByIdResponses, PatchApiV1UsersByIdRolesData, PatchApiV1UsersByIdRolesErrors, PatchApiV1UsersByIdRolesResponses, PostApiV1AgentGroupsData, PostApiV1AgentGroupsErrors, PostApiV1AgentGroupsResponses, PostApiV1AgentsByIdDuplicateData, PostApiV1AgentsByIdDuplicateErrors, PostApiV1AgentsByIdDuplicateResponses, PostApiV1AgentsData, PostApiV1AgentsErrors, PostApiV1AgentsResponses, PostApiV1ApiKeysData, PostApiV1ApiKeysErrors, PostApiV1ApiKeysResponses, PostApiV1ChatData, PostApiV1ChatErrors, PostApiV1ChatGenerateReplyData, PostApiV1ChatGenerateReplyErrors, PostApiV1ChatGenerateReplyResponses, PostApiV1ChatResponses, PostApiV1ChatTranslateData, PostApiV1ChatTranslateErrors, PostApiV1ChatTranslateResponses, PostApiV1EvalBenchmarksData, PostApiV1EvalBenchmarksErrors, PostApiV1EvalBenchmarksResponses, PostApiV1EvalDatasetsByDatasetIdTestCasesData, PostApiV1EvalDatasetsByDatasetIdTestCasesErrors, PostApiV1EvalDatasetsByDatasetIdTestCasesResponses, PostApiV1EvalDatasetsData, PostApiV1EvalDatasetsErrors, PostApiV1EvalDatasetsResponses, PostApiV1EvalRunsByIdClaimData, PostApiV1EvalRunsByIdClaimErrors, PostApiV1EvalRunsByIdClaimResponses, PostApiV1EvalRunsByIdResultsData, PostApiV1EvalRunsByIdResultsErrors, PostApiV1EvalRunsByIdResultsResponses, PostApiV1EvalRunsByIdRetryErrorsData, PostApiV1EvalRunsByIdRetryErrorsErrors, PostApiV1EvalRunsByIdRetryErrorsResponses, PostApiV1EvalRunsData, PostApiV1EvalRunsErrors, PostApiV1EvalRunsResponses, PostApiV1FilesBatchesData, PostApiV1FilesBatchesErrors, PostApiV1FilesBatchesResponses, PostApiV1FilesByIdChunksData, PostApiV1FilesByIdChunksErrors, PostApiV1FilesByIdChunksResponses, PostApiV1FilesByIdParsesData, PostApiV1FilesByIdParsesErrors, PostApiV1FilesByIdParsesResponses, PostApiV1FilesData, PostApiV1FilesErrors, PostApiV1FilesQueriesData, PostApiV1FilesQueriesErrors, PostApiV1FilesQueriesResponses, PostApiV1FilesResponses, PostApiV1GoalsByIdAdvanceData, PostApiV1GoalsByIdAdvanceErrors, PostApiV1GoalsByIdAdvanceResponses, PostApiV1GoalsByIdPauseData, PostApiV1GoalsByIdPauseErrors, PostApiV1GoalsByIdPauseResponses, PostApiV1GoalsByIdRestartData, PostApiV1GoalsByIdRestartErrors, PostApiV1GoalsByIdRestartResponses, PostApiV1GoalsByIdResumeData, PostApiV1GoalsByIdResumeErrors, PostApiV1GoalsByIdResumeResponses, PostApiV1GoalsData, PostApiV1GoalsErrors, PostApiV1GoalsResponses, PostApiV1ImMessagesData, PostApiV1ImMessagesErrors, PostApiV1ImMessagesResponses, PostApiV1ImTopicsByTopicIdReadData, PostApiV1ImTopicsByTopicIdReadErrors, PostApiV1ImTopicsByTopicIdReadResponses, PostApiV1KnowledgeBasesByIdFilesBatchData, PostApiV1KnowledgeBasesByIdFilesBatchErrors, PostApiV1KnowledgeBasesByIdFilesBatchResponses, PostApiV1KnowledgeBasesByIdFilesMoveData, PostApiV1KnowledgeBasesByIdFilesMoveErrors, PostApiV1KnowledgeBasesByIdFilesMoveResponses, PostApiV1KnowledgeBasesData, PostApiV1KnowledgeBasesErrors, PostApiV1KnowledgeBasesResponses, PostApiV1McpServersByIdSyncData, PostApiV1McpServersByIdSyncErrors, PostApiV1McpServersByIdSyncResponses, PostApiV1McpServersData, PostApiV1McpServersErrors, PostApiV1McpServersResponses, PostApiV1MessagesData, PostApiV1MessagesErrors, PostApiV1MessagesRepliesData, PostApiV1MessagesRepliesErrors, PostApiV1MessagesRepliesResponses, PostApiV1MessagesResponses, PostApiV1MessageTranslationsByMessageIdData, PostApiV1MessageTranslationsByMessageIdErrors, PostApiV1MessageTranslationsByMessageIdResponses, PostApiV1ModelsData, PostApiV1ModelsErrors, PostApiV1ModelsResponses, PostApiV1NotificationsArchiveAllData, PostApiV1NotificationsArchiveAllErrors, PostApiV1NotificationsArchiveAllResponses, PostApiV1NotificationsByIdArchiveData, PostApiV1NotificationsByIdArchiveErrors, PostApiV1NotificationsByIdArchiveResponses, PostApiV1NotificationsReadAllData, PostApiV1NotificationsReadAllErrors, PostApiV1NotificationsReadAllResponses, PostApiV1NotificationsReadData, PostApiV1NotificationsReadErrors, PostApiV1NotificationsReadResponses, PostApiV1PermissionsData, PostApiV1PermissionsErrors, PostApiV1PermissionsResponses, PostApiV1ProvidersData, PostApiV1ProvidersErrors, PostApiV1ProvidersResponses, PostApiV1ResponsesData, PostApiV1ResponsesErrors, PostApiV1ResponsesResponses, PostApiV1RolesData, PostApiV1RolesErrors, PostApiV1RolesResponses, PostApiV1SignalsSourceEventsData, PostApiV1SignalsSourceEventsErrors, PostApiV1SignalsSourceEventsResponses, PostApiV1SignalsTriggerData, PostApiV1SignalsTriggerErrors, PostApiV1SignalsTriggerResponses, PostApiV1TasksData, PostApiV1TasksErrors, PostApiV1TasksResponses, PostApiV1TopicsData, PostApiV1TopicsErrors, PostApiV1TopicsResponses, PostApiV1UsersData, PostApiV1UsersErrors, PostApiV1UsersResponses, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultData, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultErrors, PutApiV1EvalRunsByRunIdTopicsByTopicIdResultResponses, PutApiV1PushTokensByDeviceIdData, PutApiV1PushTokensByDeviceIdErrors, PutApiV1PushTokensByDeviceIdResponses } from './types.gen';const mergeMethodHeaders = (defaults: Record<string, unknown>,@@ -777,6 +777,43 @@ export class Goals extends HeyApiClient {}}+export class Im extends HeyApiClient {+ /**+ * Send a message to an agent; the reply arrives asynchronously via sync+ */+ public send<ThrowOnError extends boolean = false>(options: Options<PostApiV1ImMessagesData, ThrowOnError>): RequestResult<PostApiV1ImMessagesResponses, PostApiV1ImMessagesErrors, ThrowOnError> {+ return (options.client ?? this.client).post<PostApiV1ImMessagesResponses, PostApiV1ImMessagesErrors, ThrowOnError>({+ security: [{ scheme: 'bearer', type: 'http' }],+ url: '/api/v1/im/messages',+ ...options,+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)+ });+ }++ /**+ * Long-poll a conversation for whole new messages, typing and read receipts+ */+ public sync<ThrowOnError extends boolean = false>(options: Options<GetApiV1ImTopicsByTopicIdSyncData, ThrowOnError>): RequestResult<GetApiV1ImTopicsByTopicIdSyncResponses, GetApiV1ImTopicsByTopicIdSyncErrors, ThrowOnError> {+ return (options.client ?? this.client).get<GetApiV1ImTopicsByTopicIdSyncResponses, GetApiV1ImTopicsByTopicIdSyncErrors, ThrowOnError>({+ security: [{ scheme: 'bearer', type: 'http' }],+ url: '/api/v1/im/topics/{topicId}/sync',+ ...options+ });+ }++ /**+ * Mark the agent's messages read up to a message+ */+ public markRead<ThrowOnError extends boolean = false>(options: Options<PostApiV1ImTopicsByTopicIdReadData, ThrowOnError>): RequestResult<PostApiV1ImTopicsByTopicIdReadResponses, PostApiV1ImTopicsByTopicIdReadErrors, ThrowOnError> {+ return (options.client ?? this.client).post<PostApiV1ImTopicsByTopicIdReadResponses, PostApiV1ImTopicsByTopicIdReadErrors, ThrowOnError>({+ security: [{ scheme: 'bearer', type: 'http' }],+ url: '/api/v1/im/topics/{topicId}/read',+ ...options,+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)+ });+ }+}+export class KnowledgeBases extends HeyApiClient {public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1KnowledgeBasesData, ThrowOnError>): RequestResult<GetApiV1KnowledgeBasesResponses, GetApiV1KnowledgeBasesErrors, ThrowOnError> {return (options?.client ?? this.client).get<GetApiV1KnowledgeBasesResponses, GetApiV1KnowledgeBasesErrors, ThrowOnError>({@@ -1260,6 +1297,31 @@ export class Providers extends HeyApiClient {}}+export class PushTokens extends HeyApiClient {+ /**+ * Stop pushing to this device (sign-out)+ */+ public unregister<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1PushTokensByDeviceIdData, ThrowOnError>): RequestResult<DeleteApiV1PushTokensByDeviceIdResponses, DeleteApiV1PushTokensByDeviceIdErrors, ThrowOnError> {+ return (options.client ?? this.client).delete<DeleteApiV1PushTokensByDeviceIdResponses, DeleteApiV1PushTokensByDeviceIdErrors, ThrowOnError>({+ security: [{ scheme: 'bearer', type: 'http' }],+ url: '/api/v1/push-tokens/{deviceId}',+ ...options+ });+ }++ /**+ * Register or rotate this device's push token+ */+ public register<ThrowOnError extends boolean = false>(options: Options<PutApiV1PushTokensByDeviceIdData, ThrowOnError>): RequestResult<PutApiV1PushTokensByDeviceIdResponses, PutApiV1PushTokensByDeviceIdErrors, ThrowOnError> {+ return (options.client ?? this.client).put<PutApiV1PushTokensByDeviceIdResponses, PutApiV1PushTokensByDeviceIdErrors, ThrowOnError>({+ security: [{ scheme: 'bearer', type: 'http' }],+ url: '/api/v1/push-tokens/{deviceId}',+ ...options,+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)+ });+ }+}+export class Responses extends HeyApiClient {public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1ResponsesData, ThrowOnError>): RequestResult<PostApiV1ResponsesResponses, PostApiV1ResponsesErrors, ThrowOnError> {return (options.client ?? this.client).post<PostApiV1ResponsesResponses, PostApiV1ResponsesErrors, ThrowOnError>({@@ -1625,6 +1687,11 @@ export class LobeHub extends HeyApiClient {return this._goals ??= new Goals({ client: this.client });}+ private _im?: Im;+ get im(): Im {+ return this._im ??= new Im({ client: this.client });+ }+private _knowledgeBases?: KnowledgeBases;get knowledgeBases(): KnowledgeBases {return this._knowledgeBases ??= new KnowledgeBases({ client: this.client });@@ -1670,6 +1737,11 @@ export class LobeHub extends HeyApiClient {return this._providers ??= new Providers({ client: this.client });}+ private _pushTokens?: PushTokens;+ get pushTokens(): PushTokens {+ return this._pushTokens ??= new PushTokens({ client: this.client });+ }+private _responses?: Responses;get responses(): Responses {return this._responses ??= new Responses({ client: this.client });diff --git a/packages/sdk/src/generated/types.gen.ts b/packages/sdk/src/generated/types.gen.tsindex a8199bc5633..c72359136fe 100644--- a/packages/sdk/src/generated/types.gen.ts+++ b/packages/sdk/src/generated/types.gen.ts@@ -5864,6 +5864,225 @@ export type PostApiV1GoalsByIdRestartResponses = {export type PostApiV1GoalsByIdRestartResponse = PostApiV1GoalsByIdRestartResponses[keyof PostApiV1GoalsByIdRestartResponses];+export type PostApiV1ImMessagesData = {+ body: {+ agentId: string;+ clientMessageId?: string;+ content: string;+ topicId?: string | null;+ };+ path?: never;+ query?: never;+ url: '/api/v1/im/messages';+};++export type PostApiV1ImMessagesErrors = {+ /**+ * Validation Error+ */+ 400: {+ success: false;+ error: Array<unknown>;+ data: unknown;+ };+ /**+ * Authentication required+ */+ 401: ApiError;+ /**+ * Insufficient permission+ */+ 403: ApiError;+ /**+ * Resource not found+ */+ 404: ApiError;+ /**+ * Resource conflict+ */+ 409: ApiError;+ /**+ * Rate limit exceeded+ */+ 429: ApiError;+ /**+ * Internal server error+ */+ 500: ApiError;+};++export type PostApiV1ImMessagesError = PostApiV1ImMessagesErrors[keyof PostApiV1ImMessagesErrors];++export type PostApiV1ImMessagesResponses = {+ /**+ * Successful response+ */+ 200: {+ data?: {+ accepted: boolean;+ operationId: string | null;+ topicId: string;+ userMessage: {+ content: string;+ createdAt: string;+ error: boolean;+ id: string;+ role: 'assistant' | 'user';+ };+ };+ message?: string;+ success: true;+ timestamp: string;+ };+};++export type PostApiV1ImMessagesResponse = PostApiV1ImMessagesResponses[keyof PostApiV1ImMessagesResponses];++export type GetApiV1ImTopicsByTopicIdSyncData = {+ body?: never;+ path: {+ topicId: string;+ };+ query?: {+ cursor?: string;+ limit?: number;+ state?: string;+ waitMs?: number;+ };+ url: '/api/v1/im/topics/{topicId}/sync';+};++export type GetApiV1ImTopicsByTopicIdSyncErrors = {+ /**+ * Validation Error+ */+ 400: {+ success: false;+ error: Array<unknown>;+ data: unknown;+ };+ /**+ * Authentication required+ */+ 401: ApiError;+ /**+ * Insufficient permission+ */+ 403: ApiError;+ /**+ * Resource not found+ */+ 404: ApiError;+ /**+ * Resource conflict+ */+ 409: ApiError;+ /**+ * Rate limit exceeded+ */+ 429: ApiError;+ /**+ * Internal server error+ */+ 500: ApiError;+};++export type GetApiV1ImTopicsByTopicIdSyncError = GetApiV1ImTopicsByTopicIdSyncErrors[keyof GetApiV1ImTopicsByTopicIdSyncErrors];++export type GetApiV1ImTopicsByTopicIdSyncResponses = {+ /**+ * Successful response+ */+ 200: {+ data?: {+ cursor: string;+ messages: Array<{+ content: string;+ createdAt: string;+ error: boolean;+ id: string;+ role: 'assistant' | 'user';+ }>;+ readUpTo: {+ messageId: string;+ readAt: string;+ } | null;+ state: string;+ typing: boolean;+ unread: number;+ };+ message?: string;+ success: true;+ timestamp: string;+ };+};++export type GetApiV1ImTopicsByTopicIdSyncResponse = GetApiV1ImTopicsByTopicIdSyncResponses[keyof GetApiV1ImTopicsByTopicIdSyncResponses];++export type PostApiV1ImTopicsByTopicIdReadData = {+ body: {+ messageId: string;+ };+ path: {+ topicId: string;+ };+ query?: never;+ url: '/api/v1/im/topics/{topicId}/read';+};++export type PostApiV1ImTopicsByTopicIdReadErrors = {+ /**+ * Validation Error+ */+ 400: {+ success: false;+ error: Array<unknown>;+ data: unknown;+ };+ /**+ * Authentication required+ */+ 401: ApiError;+ /**+ * Insufficient permission+ */+ 403: ApiError;+ /**+ * Resource not found+ */+ 404: ApiError;+ /**+ * Resource conflict+ */+ 409: ApiError;+ /**+ * Rate limit exceeded+ */+ 429: ApiError;+ /**+ * Internal server error+ */+ 500: ApiError;+};++export type PostApiV1ImTopicsByTopicIdReadError = PostApiV1ImTopicsByTopicIdReadErrors[keyof PostApiV1ImTopicsByTopicIdReadErrors];++export type PostApiV1ImTopicsByTopicIdReadResponses = {+ /**+ * Successful response+ */+ 200: {+ data?: {+ unread: number;+ };+ message?: string;+ success: true;+ timestamp: string;+ };+};++export type PostApiV1ImTopicsByTopicIdReadResponse = PostApiV1ImTopicsByTopicIdReadResponses[keyof PostApiV1ImTopicsByTopicIdReadResponses];+export type GetApiV1KnowledgeBasesData = {body?: never;path?: never;@@ -9235,6 +9454,136 @@ export type PatchApiV1ProvidersByIdResponses = {export type PatchApiV1ProvidersByIdResponse = PatchApiV1ProvidersByIdResponses[keyof PatchApiV1ProvidersByIdResponses];+export type DeleteApiV1PushTokensByDeviceIdData = {+ body?: never;+ path: {+ deviceId: string;+ };+ query?: {+ expoToken?: string;+ };+ url: '/api/v1/push-tokens/{deviceId}';+};++export type DeleteApiV1PushTokensByDeviceIdErrors = {+ /**+ * Validation Error+ */+ 400: {+ success: false;+ error: Array<unknown>;+ data: unknown;+ };+ /**+ * Authentication required+ */+ 401: ApiError;+ /**+ * Insufficient permission+ */+ 403: ApiError;+ /**+ * Resource not found+ */+ 404: ApiError;+ /**+ * Resource conflict+ */+ 409: ApiError;+ /**+ * Rate limit exceeded+ */+ 429: ApiError;+ /**+ * Internal server error+ */+ 500: ApiError;+};++export type DeleteApiV1PushTokensByDeviceIdError = DeleteApiV1PushTokensByDeviceIdErrors[keyof DeleteApiV1PushTokensByDeviceIdErrors];++export type DeleteApiV1PushTokensByDeviceIdResponses = {+ /**+ * Successful response+ */+ 200: {+ data?: null;+ message?: string;+ success: true;+ timestamp: string;+ };+};++export type DeleteApiV1PushTokensByDeviceIdResponse = DeleteApiV1PushTokensByDeviceIdResponses[keyof DeleteApiV1PushTokensByDeviceIdResponses];++export type PutApiV1PushTokensByDeviceIdData = {+ body: {+ appVersion?: string;+ expoToken: string;+ locale?: string;+ platform: 'ios' | 'android';+ };+ path: {+ deviceId: string;+ };+ query?: never;+ url: '/api/v1/push-tokens/{deviceId}';+};++export type PutApiV1PushTokensByDeviceIdErrors = {+ /**+ * Validation Error+ */+ 400: {+ success: false;+ error: Array<unknown>;+ data: unknown;+ };+ /**+ * Authentication required+ */+ 401: ApiError;+ /**+ * Insufficient permission+ */+ 403: ApiError;+ /**+ * Resource not found+ */+ 404: ApiError;+ /**+ * Resource conflict+ */+ 409: ApiError;+ /**+ * Rate limit exceeded+ */+ 429: ApiError;+ /**+ * Internal server error+ */+ 500: ApiError;+};++export type PutApiV1PushTokensByDeviceIdError = PutApiV1PushTokensByDeviceIdErrors[keyof PutApiV1PushTokensByDeviceIdErrors];++export type PutApiV1PushTokensByDeviceIdResponses = {+ /**+ * Successful response+ */+ 200: {+ data?: {+ deviceId: string;+ platform: string;+ };+ message?: string;+ success: true;+ timestamp: string;+ };+};++export type PutApiV1PushTokensByDeviceIdResponse = PutApiV1PushTokensByDeviceIdResponses[keyof PutApiV1PushTokensByDeviceIdResponses];+export type PostApiV1ResponsesData = {body: {input: string | Array<{diff --git a/packages/types/src/topic/topic.ts b/packages/types/src/topic/topic.tsindex 08ba69bc7d9..3640b2c0245 100644--- a/packages/types/src/topic/topic.ts+++ b/packages/types/src/topic/topic.ts@@ -207,6 +207,16 @@ export interface ChatTopicMetadata {heteroSourceEndAt?: string;/** origin marker for imported topics, e.g. `claude-code-local` / `codex-local` */importedFrom?: string;+ /**+ * The newest agent message each viewer has seen in a messaging client (toby),+ * written by `POST /api/v1/im/topics/{topicId}/read`, keyed by viewer id.+ * Agent messages after the viewer's `readAt` count as unread. A viewer's entry+ * only ever moves forward, and tracking viewers separately keeps one member of+ * a shared workspace conversation from clearing everyone else's unread.+ * `createdAtUs` is the stored ordering value: it keeps the cursor comparable+ * after that message is deleted, and at the microseconds a Date drops.+ */+ imReadCursors?: Record<string, { createdAtUs: string; messageId: string; readAt: string }>;/*** Root operation that most recently consumed `runningOperation`.* Used to scope a post-terminal `unread` → `active` correction when the