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
attachment
What it is
Part of AI: the shared contract for turning a reference to any entity (a document, a channel message, a calendar event) into AI-consumable content, so AI tools and attachments behave the same way across every domain. No dependency on any domain crate.
Start here
src/lib.rs: theAttachmentServiceandAttachabletraits.src/models.rs:AttachmentContent,AttachmentPart,AttachmentReference,Attachments,FormattedParts.src/fmt.rs: XML formatting (XmlTag,ClosedXmlTag,Indent) used byAttachableimpls.src/provider.rs:AttachmentProviderrouter (featureprovider), dispatchingAttachmentReferencevariants to per-domain services.
Scope
- Owns: the
AttachmentService/Attachabletrait contracts and shared formatting types used to turn entities into AI context. - Not here: resolving a specific entity type — each domain crate implements
AttachmentServicein its owninbound/attachment/module (e.g.crates/chat,crates/channels,crates/documents,crates/email).
Boundaries
- Depends on:
macro_user_id,model-entity,non_empty. - Used by:
channels,email,ai_tools,agent,agent_inmem,static_file,chat,documents,image_generation— each implementingAttachmentService.
Recipes
- Add a new attachable entity type: implement
AttachmentServicein the owning domain crate'sinbound/attachment/module → add theAttachmentReferencevariant insrc/models.rs→ wire it intosrc/provider.rs(if used behind the router) → implementAttachablefor the new content type insrc/attachable.rs.
Checks
cargo test -p attachment(SQLX_OFFLINEunset).
Gotchas
AttachmentContent.contentisNonEmpty<Vec<AttachmentPart>>— never insert a placeholder to satisfy the non-empty constraint; returnAttachmentError::NoContentif resolution produces zero parts.- Individual resolution failures surface as
ResolutionErrorentries in theAttachmentsbatch; they never fail the whole batch.
Related
- Rules:
.agents/rules/rust/architecture.md· Skill:WRITE_ATTACHMENT_SERVICE(.claude/skills/here) for implementing a new domain'sAttachmentService.