feat(web): 站点按类型分组、列表模式修样式、下掉自定义 RSS 源与索引器入口;智能体会话分对话 / 自动巡检两栏
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
8da8679a04
commit
8eb8a68295
11 files changed
+364
-312
No files matched your search
@@ -122,6 +122,12 @@ export function registerAgentRoutes(
|
||||
if (query.status) q = q.where("status", "=", query.status);
|
||||
if (query.trigger) q = q.where("trigger", "=", query.trigger);
|
||||
if (query.parentRunId) q = q.where("parent_run_id", "=", query.parentRunId);
|
||||
if (query.group) {
|
||||
// 自动 = 定时 / 事件触发,子会话按父会话归类
|
||||
const auto = sql<boolean>`(trigger in ('schedule', 'event') or (trigger = 'subagent' and parent_run_id in
|
||||
(select p.id from agent_run p where p.trigger in ('schedule', 'event'))))`;
|
||||
q = q.where(query.group === "auto" ? auto : sql<boolean>`not ${auto}`);
|
||||
}
|
||||
const cur = decode(query.cursor);
|
||||
if (cur) q = q.where(sql<boolean>`(created_at, id) < (${cur.at}::timestamptz, ${cur.id}::uuid)`);
|
||||
const rows = await q
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
||||
import { createAgentModule } from "../../src/modules/agent/index.ts";
|
||||
import { createHarness, type Harness, pgAvailable } from "../auth-settings/harness.ts";
|
||||
import { DEV_KEY, json } from "../helpers.ts";
|
||||
|
||||
// 智能体页会话分栏:对话(用户发起)/ 自动巡检(定时、事件触发);子会话随父会话归类
|
||||
const hasPg = await pgAvailable();
|
||||
|
||||
describe.skipIf(!hasPg)("会话列表 group 筛选(真实 PG)", () => {
|
||||
let h: Harness;
|
||||
beforeAll(async () => {
|
||||
h = await createHarness({ extraModules: [createAgentModule()] });
|
||||
}, 120_000);
|
||||
afterAll(async () => {
|
||||
await h?.close();
|
||||
});
|
||||
|
||||
it("auto = schedule / event 及其子会话;conversation = 其余", async () => {
|
||||
const run = async (trigger: string, goal: string, parent?: string) =>
|
||||
(
|
||||
await h.db
|
||||
.insertInto("agent_run")
|
||||
.values({ trigger, goal, status: "succeeded", mode: "execute", parent_run_id: parent ?? null } as never)
|
||||
.returning("id")
|
||||
.executeTakeFirstOrThrow()
|
||||
).id;
|
||||
const patrol = await run("schedule", "巡检");
|
||||
await run("subagent", "巡检子会话", patrol);
|
||||
await run("event", "事件");
|
||||
const chat = await run("user", "对话");
|
||||
await run("subagent", "对话子会话", chat);
|
||||
const goals = async (group: string) =>
|
||||
(
|
||||
await json(
|
||||
await h.app.request(`/api/v1/agent/runs?group=${group}`, { headers: { authorization: `Bearer ${DEV_KEY}` } }),
|
||||
)
|
||||
).data.items
|
||||
.map((r: { goal: string }) => r.goal)
|
||||
.sort();
|
||||
expect(await goals("auto")).toEqual(["事件", "巡检", "巡检子会话"].sort());
|
||||
expect(await goals("conversation")).toEqual(["对话", "对话子会话"].sort());
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user