🤯 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(channel): keep conversations between Agents out of the channel list (#23667)
Arvin Xu852b4e397e7a
diff --git a/packages/database/src/models/__tests__/agent.characterization.test.ts b/packages/database/src/models/__tests__/agent.characterization.test.tsindex b5e0377cdcc..5565570d8ac 100644--- a/packages/database/src/models/__tests__/agent.characterization.test.ts+++ b/packages/database/src/models/__tests__/agent.characterization.test.ts@@ -85,6 +85,7 @@ const PUBLIC_METHODS = ['getTopicShareSubject','hasTrashedOwner','listMessengerBindableAgents',+ 'listPluginModes','lockTrashedForPurge','publishToWorkspace','purge',@@ -94,6 +95,7 @@ const PUBLIC_METHODS = ['rank','resolveIdBySlug','restore',+ 'setPluginMode','setVisibility','softDelete','toggleFile',diff --git a/packages/database/src/models/agent/plugins.ts b/packages/database/src/models/agent/plugins.tsindex 71ff5e144dc..130beff89e6 100644--- a/packages/database/src/models/agent/plugins.ts+++ b/packages/database/src/models/agent/plugins.ts@@ -33,7 +33,7 @@ const ownPluginAgents = (ctx: AgentModelContext): SQL | undefined =>ctx.ownership(),eq(agents.userId, ctx.userId),or(isNull(agents.virtual), eq(agents.virtual, false), eq(agents.slug, INBOX_SESSION_ID)),- sql`jsonb_typeof(${agents.agencyConfig}->'heterogeneousProvider') IS DISTINCT FROM 'object'`,+ sql`COALESCE(jsonb_typeof(${agents.agencyConfig}->'heterogeneousProvider'), '') <> 'object'`,);/**diff --git a/packages/database/src/repositories/channel/__tests__/agentPair.test.ts b/packages/database/src/repositories/channel/__tests__/agentPair.test.tsindex af869ee98c2..ac185ed8974 100644--- a/packages/database/src/repositories/channel/__tests__/agentPair.test.ts+++ b/packages/database/src/repositories/channel/__tests__/agentPair.test.ts@@ -1,9 +1,16 @@// @vitest-environment node-import { eq } from 'drizzle-orm';+import { and, eq } from 'drizzle-orm';import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { getTestDB } from '../../../core/getTestDB';-import { agentOperations, agents, channelMessages, workspaceMembers } from '../../../schemas';+import {+ agentOperations,+ agents,+ channelMembers,+ channelMessages,+ channels,+ workspaceMembers,+} from '../../../schemas';import {ChannelError,ChannelExecutionRepository,@@ -84,13 +91,31 @@ const setup = async () => {describe('A conversation between Agents', () => {// An Agent's request is not the person reading: their unseen answers stay unread.it('leaves the person’s unread count alone when an Agent asks', async () => {- const { answer, ask, pair, repository } = await setup();+ const { answer, ask, pair } = await setup();const first = await ask('First?');await answer(first.id, 'First answer');await ask('Second?');- const listed = (await repository.list()).find((item) => item.id === pair.channel.id);- expect(listed?.unreadCount).toBe(3);+ const [row] = await db+ .select({ lastRead: channelMembers.lastReadSequence, sequence: channels.sequence })+ .from(channelMembers)+ .innerJoin(channels, eq(channels.id, channelMembers.channelId))+ .where(+ and(+ eq(channelMembers.channelId, pair.channel.id),+ eq(channelMembers.userId, fixture.ownerId),+ ),+ );+ expect(row.sequence - (row.lastRead ?? 0)).toBe(3);+ });++ // It opens from the report where the asking began, never as a row of its own.+ it("stays out of the person's list but still opens by id", async () => {+ const { pair, repository } = await setup();++ expect((await repository.list()).some((item) => item.id === pair.channel.id)).toBe(false);+ const detail = await repository.detail(pair.channel.id);+ expect(detail?.channel.agentPairKey).toBeTruthy();});it('is one per pair, whichever Agent opens it', async () => {diff --git a/packages/database/src/repositories/channel/index.ts b/packages/database/src/repositories/channel/index.tsindex 7faa3fbc55c..661067d621c 100644--- a/packages/database/src/repositories/channel/index.ts+++ b/packages/database/src/repositories/channel/index.ts@@ -558,7 +558,8 @@ export class ChannelRepository {/*** Channels the caller belongs to in the current scope, newest first. Archived ones are* included with their `status`, so they stay readable outside the active list. Active open- * project Channels the caller has not joined follow with `joined: false`.+ * project Channels the caller has not joined follow with `joined: false`. A conversation+ * between two Agents is left out: it opens from the report where the asking began.*/list = async (): Promise<Array<@@ -602,7 +603,9 @@ export class ChannelRepository {.innerJoin(channelMembers, eq(channelMembers.channelId, channels.id)).leftJoin(agents, eq(agents.id, channels.agentId)).leftJoin(agentShares, eq(agentShares.agentId, channels.agentId))- .where(and(this.membershipWhere(), notTrashed(channels.isDeleted)))+ .where(+ and(this.membershipWhere(), notTrashed(channels.isDeleted), isNull(channels.agentPairKey)),+ ).orderBy(desc(channels.createdAt));const open = await listUnjoinedOpenChannels(this.db, this.userId, this.workspaceId);const previewIds = [...rows.map(({ channel }) => channel.id), ...open.map(({ id }) => id)];