import { FastifyReply } from "fastify"; import { AuthenticatedRequest } from "../../../common/interfaces/authenticated.request.interface"; import { CreditValidatorInterface } from "../../../common/tokens"; import { JsonApiService } from "../../../core/jsonapi/services/jsonapi.service"; import { AssistantAppendDto } from "../dtos/assistant-append.dto"; import { AssistantPatchDto } from "../dtos/assistant-patch.dto"; import { AssistantPostDto } from "../dtos/assistant-post.dto"; import { AssistantService } from "../services/assistant.service"; /** * Merge two JSON:API `included` lists for the `create()` response. * * `buildSingle(Assistant)` traverses the Assistant's `messages` relationship and * emits slim message entries. `buildList([userMsg, assistantMsg])` serialises * the same messages as top-level resources, richer and carrying a * `relationships.assistant` back-pointer. Concatenating produced duplicates * (slim + rich per message) and leaked the back-pointer. We want one rich copy * per (type,id), minus the back-pointer to the primary Assistant. * * Dedup rule: last-wins by (type,id) — `buildList` output overrides * `buildSingle` traversal. Back-pointer rule: when an included resource's * relationship points to `stripBackrefsTo`, drop that relationship entry; * if the resulting `relationships` object is empty, drop the property too. */ export declare function mergeIncluded(base: unknown[] | undefined, additions: unknown[] | undefined, stripBackrefsTo: { type: string; id: string; } | null): any[]; export declare class AssistantController { private readonly assistants; private readonly jsonApi; private readonly creditValidator?; private readonly logger; private readonly crud; constructor(assistants: AssistantService, jsonApi: JsonApiService, creditValidator?: CreditValidatorInterface); /** * POST /assistants — create a new assistant thread with a first user message. * * Response shape: Assistant JSON:API document with `meta.toolCalls`. The * first user + assistant messages are embedded in the `included` array as * `assistant-messages` (pre-populated server-side so the client does not need * a round-trip to render the initial thread). */ create(body: AssistantPostDto, req: AuthenticatedRequest): Promise; /** * POST /assistants/:assistantId/assistant-messages — append a user message to an existing * assistant thread. Runs the agent turn synchronously and returns a JSON:API list * document containing the two new messages (user + assistant). `toolCalls` is surfaced * in the document's `meta`. */ append(assistantId: string, body: AssistantAppendDto, req: AuthenticatedRequest): Promise; /** * GET /assistants — list the current user's assistant threads. * RBAC (company + owner) is enforced by the repository's `buildUserHasAccess` override. * * `boundType` + `boundId` narrow the list to the threads bound to one * resource (e.g. a campaign). Both are required together: a bound id with no * type is ambiguous, and a type with no id names no resource. Supplying them * is a custom filter, so it bypasses the CRUD handler and calls the service. */ findAll(reply: FastifyReply, query: any, search?: string, fetchAll?: boolean, orderBy?: string, boundType?: string, boundId?: string): Promise; /** * GET /assistants/:assistantId — read a single assistant thread. */ findById(reply: FastifyReply, assistantId: string): Promise; /** * PATCH /assistants/:assistantId — partial update (e.g. rename) via JSON:API envelope. */ patch(reply: FastifyReply, body: AssistantPatchDto): Promise; /** * DELETE /assistants/:assistantId — permanently remove the assistant thread. */ delete(reply: FastifyReply, assistantId: string): Promise; } //# sourceMappingURL=assistant.controller.d.ts.map