Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.
TypeScript
feat(byoa): name the project in the wake digest
Xialie Zhuangbbaf6aec0ee0
diff --git a/server/src/__tests__/agents-computer-inbox-digest.test.ts b/server/src/__tests__/agents-computer-inbox-digest.test.tsindex c817175..f69171a 100644--- a/server/src/__tests__/agents-computer-inbox-digest.test.ts+++ b/server/src/__tests__/agents-computer-inbox-digest.test.ts@@ -13,7 +13,7 @@*/import { test } from 'node:test'import assert from 'node:assert/strict'-import { renderInboxDigest } from '../agents/computer/daemon.js'+import { conversationHeader, renderInboxDigest } from '../agents/computer/daemon.js'type Convo = { head: string; msgs: string[] }@@ -89,3 +89,48 @@ test('a conversation budgeted to zero shows none of its messages, not all of thetest('an empty inbox renders as an empty digest', () => {assert.equal(renderInboxDigest(new Map(), 40), '')})++// ── conversation header ──────────────────────────────────────────────────────+// A BYOA agent that sits in several project groups has to be able to tell them+// apart from the digest alone. The cloud turn has always rendered a project+// line; without it here, everything the agent knows reads as one context and+// work from one project gets quoted as background in another.++test('the header names the project the group belongs to', () => {+ const head = conversationHeader({+ conversation_id: 'c-1',+ conversation_kind: 'group',+ conversation_title: 'Paper review',+ project_name: 'Paper review',+ conversation_topic: 'ICML submission',+ })+ assert.match(head, /^# c-1 \[group\] "Paper review"/)+ assert.match(head, /\n {2}Project: Paper review/)+ assert.match(head, /\n {2}Topic: ICML submission/)+ // Project reads before topic: which project, then what this group is for.+ assert.ok(head.indexOf('Project:') < head.indexOf('Topic:'))+})++test('a project-less conversation is unchanged', () => {+ // Direct chats and ungrouped conversations are genuinely project-less; they+ // must render exactly as they did before.+ const head = conversationHeader({+ conversation_id: 'c-2',+ conversation_kind: 'dm',+ conversation_title: 'yetone',+ conversation_topic: null,+ })+ assert.equal(head, '# c-2 [dm] "yetone"')+})++test('a project with no topic still renders its project line', () => {+ const head = conversationHeader({ conversation_id: 'c-3', project_name: 'OpenRouter plan' })+ assert.equal(head, '# c-3\n Project: OpenRouter plan')+})++test('an explicitly null project is treated as absent', () => {+ // loadInbox LEFT JOINs projects, so an unassigned conversation arrives as null+ // rather than undefined.+ const head = conversationHeader({ conversation_id: 'c-4', project_name: null, conversation_topic: 'ship it' })+ assert.equal(head, '# c-4\n Topic: ship it')+})diff --git a/server/src/agents/computer/daemon.ts b/server/src/agents/computer/daemon.tsindex 9b1d890..58dbee8 100644--- a/server/src/agents/computer/daemon.ts+++ b/server/src/agents/computer/daemon.ts@@ -313,6 +313,7 @@ interface RuntimeInboxResponse {conversation_kind?: stringconversation_title?: stringconversation_topic?: string | null+ project_name?: string | nullauthor_name?: stringauthor_kind?: stringbody?: string@@ -344,6 +345,31 @@ const DIGEST_MAX_MESSAGE_LINES = 40* shown, exactly as before.** Exported for tests — pure, no server and no engine. */+/** The per-conversation header the wake digest opens each group with: the id,+ * its kind/title, the project it belongs to, and the topic it exists for.+ *+ * Project matters as much as topic here. An agent that sits in several project+ * groups otherwise cannot tell them apart from the digest alone, so everything+ * it has learned reads as one undifferentiated context — which is how work from+ * one project ends up quoted as background in another. The cloud turn has+ * always rendered a project line; this is the BYOA counterpart.+ *+ * Exported for tests — pure, no server and no engine. */+export function conversationHeader(row: {+ conversation_id?: string+ conversation_kind?: string+ conversation_title?: string+ project_name?: string | null+ conversation_topic?: string | null+}): string {+ const kind = row.conversation_kind ? ` [${row.conversation_kind}]` : ''+ const title = row.conversation_title ? ` "${row.conversation_title}"` : ''+ let head = `# ${row.conversation_id}${kind}${title}`+ if (row.project_name) head += `\n Project: ${row.project_name}`+ if (row.conversation_topic) head += `\n Topic: ${row.conversation_topic}`+ return head+}+export function renderInboxDigest(byConvo: Map<string, { head: string; msgs: string[] }>,budget = DIGEST_MAX_MESSAGE_LINES,@@ -1487,11 +1513,7 @@ class AgentRunner {if (row.kind !== 'system' || (alarm && (!alarm.assigneeId || alarm.assigneeId === this.agent.id))) hasReal = truelet convo = byConvo.get(row.conversation_id)if (!convo) {- const kind = row.conversation_kind ? ` [${row.conversation_kind}]` : ''- const title = row.conversation_title ? ` "${row.conversation_title}"` : ''- let head = `# ${row.conversation_id}${kind}${title}`- if (row.conversation_topic) head += `\n Topic: ${row.conversation_topic}`- convo = { head, msgs: [] }+ convo = { head: conversationHeader(row), msgs: [] }byConvo.set(row.conversation_id, convo)}const author = row.author_name ?? 'someone'diff --git a/server/src/agents/runtime/client.ts b/server/src/agents/runtime/client.tsindex e138a60..997c0e0 100644--- a/server/src/agents/runtime/client.ts+++ b/server/src/agents/runtime/client.ts@@ -59,6 +59,13 @@ export interface InboxRow {/** The group's topic ("what this group is for"), so every agent — the cloud* turn context AND the BYOA inbox digest — stays on-task. Null if unset. */conversation_topic: string | null+ /** The project this group belongs to. Optional because not every row source+ * selects it, and null because direct chats and ungrouped conversations are+ * genuinely project-less. `loadInbox` populates it; the cloud turn has always+ * rendered a project, and carrying it here is what lets the BYOA wake digest+ * do the same. */+ project_id?: string | null+ project_name?: string | nullauthor_id: string/** Joined from participants.kind. Lets prompt-building code (turn.ts)* identify human vs agent messages without a hardcoded id allow-list. */diff --git a/server/src/agents/runtime/inproc-client.ts b/server/src/agents/runtime/inproc-client.tsindex 2c01e32..8e1117d 100644--- a/server/src/agents/runtime/inproc-client.ts+++ b/server/src/agents/runtime/inproc-client.ts@@ -124,6 +124,12 @@ export class InProcRuntimeClient implements AgentRuntimeClient {`WITH convos AS (SELECT c.id, c.company_id,c.title AS conversation_title, c.kind AS conversation_kind, c.topic AS conversation_topic,+ -- Which project this group belongs to. The cloud turn already+ -- shows it (turn.ts renders "Project: <name>"); BYOA agents saw+ -- nothing, so an agent in several project groups had no way to+ -- tell them apart. PK join on a tiny table inside the CTE that+ -- already walks the agent's conversations.+ c.project_id, pr.name AS project_name,COALESCE(cr.last_read_at, '1970-01-01T00:00:00Z'::timestamptz) AS lr_at,COALESCE(cr.last_read_message_id, '') AS lr_id,EXISTS (@@ -133,11 +139,13 @@ export class InProcRuntimeClient implements AgentRuntimeClient {) AS mutedFROM conversations cLEFT JOIN conversation_reads cr ON cr.user_id = $1 AND cr.conversation_id = c.id+ LEFT JOIN projects pr ON pr.id = c.project_idWHERE c.members @> to_jsonb(ARRAY[$1::text]))SELECTm.id, m.conversation_id, co.company_id,co.conversation_title, co.conversation_kind, co.conversation_topic,+ co.project_id, co.project_name,m.author_id, p.kind AS author_kind, COALESCE(p.name, m.author_id) AS author_name,m.body, m.kind, m.sequence, m.created_at, m.attachment, m.quoted_message_id,(