Circle V2 API Docs
    Preparing search index...

    Function agentResultToAuditResponseRow

    Pure mappers from the deep audit-question runner's public result (AgentQuestionResult) onto (a) an audit_response persistence row and (b) the LegacyAuditRunResponseViewModel the review UI renders.

    Kept free of server-cli-only and any runtime import of the runner so the review UI can import it in the browser (exposed via @repo/ai-agents/mappers). All non-type imports resolve to client-safe modules.

    • Map a runner result to an audit_response insert row. Mirrors the legacy v2 mapping (see runQuestionsWithImmediateSave) but for the new Citation ({quote, documentId, fileName, page}) and ResultDocument ({id, title}) shapes, and folds the evidence trail into reason[].

      Not wired to a writer yet; delivered for the future persistence/migration path.

      Parameters

      Returns {} & {
          audit_question_id?: AuditQuestionId | null;
          audit_run_id?: string & { __brand: "AuditRunId" } | null;
          context_sources?: unknown[] | null;
          created_at?: DbDate;
          created_by?: string & { __brand: "UserId" } | null;
          icd_code?: unknown[] | null;
          id?: AuditResponseId;
          manual?: boolean;
          question?: string | null;
          question_ui?: string | null;
          reason?: string[] | null;
          recommendation?: string | null;
          response?: string | null;
          sessionId?: string & { __brand: "SessionId" } | null;
          short_form_response?: string | null;
          sources?: unknown[] | null;
          status?: string | null;
          user_action_status?: string | null;
      }