Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chat
What it is
Part of AI chat: chats and chat messages, persistence, HTTP/toolset
adapters, and lifecycle events. See README.md for the Kafka event schema.
Start here
src/domain.rs:ChatService/MessageService— chat and message CRUD, copy, revert-delete, and project bookkeeping.src/domain/events.rs:chat.*/chat.message_*events published tomacro.chats(schema inREADME.md).src/inbound/attachment.rs: theAttachmentServiceimpl for chat messages.src/inbound/toolset.rs: AI tools over chats (featureai_tools).src/outbound/postgres.rs: storage (featureoutbound).PLAN.md: in-progress plan for user-level resolved attachments — check its "What's Broken" section before assuming it's finished.
Scope
- Owns: the
Chat/ChatMessagetables, chat sharing/ownership, and message send/store/delete. - Not here: channel messages →
crates/channels; model selection and provider calls →crates/agent.
Boundaries
- Depends on:
attachment(featureattachment),entity_access_db_utils,share_permission_db_utils,macro_uuid. - Used by:
ai_tools,agent_inmem,soup_realtime.
Recipes
- Add a chat/message field or mutation:
src/domain.rs→src/outbound/postgres.rs→src/inbound/mod.rs(router) → emit/update the matching event insrc/domain/events.rs.
Checks
cargo test -p chat(SQLX_OFFLINEunset).
Gotchas
- Kafka events key on the chat's bare UUID (no
chat|prefix);chat.updatedmetadata describes the requested PATCH — an omitted field serializes asnull, andproject_id: ""means "removed from its project" (seeREADME.md). - Sharing a chat with a team is gated through
SharePermission.team_share_*and only the persisted owner may setteamShareAccessLevel. FREE_MODELis published as theFreeTierModelOpenAPI schema; the web client's free tier is generated from it. After changing it, runbun run gen-api document-cognitioninapps/web, update the web model catalog if the id is new, and keepai_projections::FREE_TIER_MODELSequal (document_cognition_servicetests both).
Related
- Rules:
.agents/rules/rust/architecture.md,.agents/rules/observability.md