Ассистент: llmtest- только для тестовых проектов (agent.testJobIds), POST /chat/apply для разового поручения агенту
All checks were successful
ci / test (push) Successful in 21s
ci / deploy (push) Successful in 1m37s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 22:25:04 +03:00
parent 9b5f445ba1
commit 1722a87915
4 changed files with 20 additions and 1 deletions

View File

@@ -8,6 +8,8 @@ export interface ChatApi {
simulate(opts: { managerId?: string; text: string; files?: string[]; publish?: boolean }): Promise<unknown>;
/** Системное событие ассистента (напоминания 12:00/13:00/16:00 и т.п.) всем менеджерам режима. */
event(kind: string): Promise<unknown>;
/** Разовое поручение агенту менеджера от ИТ/владельца (например, применить подтверждённые изменения); ответ уходит в чат менеджера, если publish. */
apply(opts: { managerId: string; text: string; publish?: boolean }): Promise<unknown>;
}
export interface PrepApiDeps {
@@ -84,6 +86,12 @@ export function buildApi(deps: PrepApiDeps): FastifyInstance {
if (!kind) return reply.code(400).send({ error: "нужен kind" });
return reply.code(202).send({ chatRunId: startChat(() => deps.chat!.event(kind)) });
});
app.post<{ Body: { managerId?: string; text?: string; publish?: boolean } }>("/chat/apply", async (req, reply) => {
if (!deps.chat) return reply.code(501).send({ error: "chat не настроен" });
const b = req.body ?? {};
if (!b.managerId || !b.text) return reply.code(400).send({ error: "нужны managerId и text" });
return reply.code(202).send({ chatRunId: startChat(() => deps.chat!.apply({ managerId: b.managerId!, text: b.text!, publish: b.publish })) });
});
app.get<{ Params: { id: string } }>("/chat/runs/:id", async (req, reply) => chatRuns.get(req.params.id) ?? reply.code(404).send({ error: "not found" }));
app.get("/agent/runs", async () => (await deps.pool.query("select id, manager_person_id, step, attempt, resumed, status, started_at, duration_ms, cost_usd, error, changes from agent_run order by started_at desc limit 20")).rows);