/** * Comments domain — feed orchestration behind service methods; the HTTP layer * lives in `routes.ts` and only maps their result statuses. Service methods * take the author as a `FactoryActorRef` (never derived from the request * inside), so agent-authored comments later become a thin tool over * `createComment` instead of a re-implementation. */ import type { PubSub } from '@mastra/core/events'; import type { ApiRoute } from '@mastra/core/server'; import type { RouteAuth } from '../../../routes/route.js'; import type { AuditEmitter } from '../audit/domain.js'; import type { ChannelIdentityStorage } from '../channel-identity/base.js'; import type { FactoryProjectsStorage } from '../projects/base.js'; import type { ExternalWorkItemSource, WorkItemRow, WorkItemsStorage } from '../work-items/base.js'; import type { FactoryActorRef } from './actor.js'; import type { EditWorkItemCommentResult, FactoryMentionRef, WorkItemCommentRow, WorkItemCommentsStorage } from './base.js'; import type { WorkItemFeedPublisher } from './feed-sync.js'; export interface FactoryRosterMember { id: string; name?: string; avatarUrl?: string; } export interface OrganizationMembersProvider { listOrganizationMembers(orgId: string): Promise; } export interface CommentsDomainOptions { auth: RouteAuth; comments: WorkItemCommentsStorage; workItems: WorkItemsStorage; projects: FactoryProjectsStorage; channelIdentity?: ChannelIdentityStorage; /** Host-wired org membership listing for the mention roster (e.g. WorkOS). */ members?: OrganizationMembersProvider; audit?: AuditEmitter; /** Outbound platform mirrors (COR-1174); empty until a platform wires one. */ publishers?: WorkItemFeedPublisher[]; /** Carries feed touches to every replica's open SSE streams. */ pubsub: PubSub; } export interface CreateCommentServiceInput { orgId: string; workItemId: string; author: FactoryActorRef; body: string; replyTo?: { commentId: string; quote?: string; }; mentions?: FactoryMentionRef[]; clientToken?: string; /** Set when the comment is a platform message being ingested, never by the web UI. */ externalSource?: ExternalWorkItemSource; /** The platform's own timestamp; defaults to now for locally authored comments. */ occurredAt?: Date; } export type CreateCommentServiceResult = /** `mirrored` settles when the platforms have been posted to; nothing in the response waits on it. */ { status: 'created'; comment: WorkItemCommentRow; workItem: WorkItemRow; mirrored: Promise; } | { status: 'work_item_not_found'; } | { status: 'token_conflict'; } | { status: 'invalid'; message: string; }; export interface CommentEditor { userId: string; /** Lazily checked, only when the caller is not the author. */ canModerate: () => Promise; } export interface EditCommentServiceInput { orgId: string; workItemId: string; commentId: string; editor: CommentEditor; body: string; mentions?: FactoryMentionRef[]; expectedRevision?: number; } export type EditCommentServiceResult = ({ status: 'edited'; previousBody: string; } & EditWorkItemCommentResult) | { status: 'not_found'; } | { status: 'forbidden'; } | { status: 'not_editable'; } | { status: 'conflict'; } | { status: 'invalid'; message: string; }; export interface DeleteCommentServiceInput { orgId: string; workItemId: string; commentId: string; editor: CommentEditor; } export type DeleteCommentServiceResult = { status: 'deleted'; comment: WorkItemCommentRow; } | { status: 'not_found'; } | { status: 'forbidden'; } | { status: 'not_editable'; }; export declare class CommentsDomain { #private; constructor({ auth, comments, workItems, projects, channelIdentity, members, audit, publishers, pubsub, }: CommentsDomainOptions); createComment(input: CreateCommentServiceInput): Promise; editComment(input: EditCommentServiceInput): Promise; deleteComment(input: DeleteCommentServiceInput): Promise; /** * Mentionable people: the host's org roster when it answers, otherwise the * people the project has actually seen (comment authors, linked channel * accounts). Cached per project so a dropdown session costs one read. */ mentionRoster({ orgId, factoryProjectId, }: { orgId: string; factoryProjectId: string; }): Promise; routes(): ApiRoute[]; } export { toWireComment } from './wire.js'; export type { WireComment, WireCommentPage } from './wire.js'; //# sourceMappingURL=domain.d.ts.map