Ассистент: API памяти, сессии и истории агентов; предложение по инструментам разбора; принцип про зависимые работы
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import { KeyedMutex, Semaphore } from "./agents/pool.js";
|
||||
import { parseSections } from "./agents/sections.js";
|
||||
import { AgentFailure, closeOrphanRuns, runManagerAgent, type AgentContext } from "./agents/session.js";
|
||||
import { runStep2, saveProblems } from "./agents/step2.js";
|
||||
import { buildApi } from "./http-api.js";
|
||||
import { handleManagerMessages } from "./slack/chat.js";
|
||||
import { DriveInbox } from "./slack/drive-inbox.js";
|
||||
import { SlackIntake } from "./slack/intake.js";
|
||||
@@ -254,6 +255,28 @@ d("консольные агенты (временная БД, фейковый
|
||||
const r = await db.pool.query("select claude_session_id from agent_manager_memory where manager_person_id = $1", [MGR]);
|
||||
expect(r.rows[0].claude_session_id).toBeNull();
|
||||
});
|
||||
it("API агентов: память читается и пишется с аудитом, сброс сессии, история", async () => {
|
||||
const app = buildApi({ pool: db.pool, token: "t", run: async () => { throw new Error("не нужен"); } });
|
||||
const h = { authorization: "Bearer t" };
|
||||
const un = await app.inject({ method: "GET", url: `/agents/${MGR}/memory` });
|
||||
expect(un.statusCode).toBe(401);
|
||||
await db.pool.query("update agent_manager_memory set memory_text = 'llmtest старая память', claude_session_id = $2 where manager_person_id = $1", [MGR, "11111111-2222-3333-4444-555555555555"]);
|
||||
const get = await app.inject({ method: "GET", url: `/agents/${MGR}/memory`, headers: h });
|
||||
expect(get.json()).toMatchObject({ memoryText: "llmtest старая память", hasSession: true });
|
||||
const bad = await app.inject({ method: "PUT", url: `/agents/${MGR}/memory`, headers: h, payload: {} });
|
||||
expect(bad.statusCode).toBe(400);
|
||||
expect((await app.inject({ method: "GET", url: "/agents/not-a-uuid/memory", headers: h })).statusCode).toBe(404);
|
||||
const put = await app.inject({ method: "PUT", url: `/agents/${MGR}/memory`, headers: h, payload: { memoryText: "llmtest новая память", note: "тест", resetSession: true } });
|
||||
expect(put.json()).toMatchObject({ ok: true, sessionReset: true });
|
||||
const after = await app.inject({ method: "GET", url: `/agents/${MGR}/memory`, headers: h });
|
||||
expect(after.json()).toMatchObject({ memoryText: "llmtest новая память", hasSession: false });
|
||||
const hist = (await app.inject({ method: "GET", url: `/agents/${MGR}/history?limit=5`, headers: h })).json();
|
||||
expect(hist.problems.some((p: { body: string }) => p.body.startsWith("[memory-edit] тест") && p.body.includes("llmtest старая память"))).toBe(true);
|
||||
expect(Array.isArray(hist.runs) && Array.isArray(hist.messages) && Array.isArray(hist.reminders)).toBe(true);
|
||||
const list = (await app.inject({ method: "GET", url: "/agents", headers: h })).json();
|
||||
expect(list.some((a: { id: string }) => a.id === MGR)).toBe(true);
|
||||
await app.close();
|
||||
});
|
||||
it("проектный канал: проект задан каналом, huddle принимается, чужой бот игнорируется", async () => {
|
||||
calls = [];
|
||||
const posted: string[] = [];
|
||||
|
||||
Reference in New Issue
Block a user