import { db, recordAgentActivity } from '../src/feltdb'; import { projectSearch } from '../capabilities/project-search'; import { projectSummary, type ProjectSummary } from '../capabilities/project-summary'; export const projectAssistant = db.defineAgent({ name: 'project-assistant', version: 1, description: 'Summarizes authorized project state.', capabilities: [projectSearch.id, projectSummary.id], goals: ['Explain project state without widening the actor authorization boundary'], constraints: { maxIterations: 1 } }); export async function runProjectAssistant(input: { projectId: string; organization: string; user: string }): Promise { const execution = await db.createAgentExecution(projectAssistant, 'Summarize the selected project', [input.projectId]); try { await db.startAgentExecution(execution); const result = await projectSummary.execute(input.projectId) as ProjectSummary; await recordAgentActivity({ organization: input.organization, user: input.user, assistant: 'Project Assistant', subject: input.projectId }); await db.completeAgentExecution(execution, input.projectId); return result; } catch (error) { await db.failAgentExecution(execution, error instanceof Error ? error.message : String(error)); throw error; } }