feat(api): expose REST-only agent routes
Agent CI/CD / docker-image (push) Failing after 35s
Agent CI/CD / deploy-fallback-log (push) Successful in 1s

This commit is contained in:
2026-07-30 20:38:52 +08:00
parent 2415f75841
commit 94529cb141
29 changed files with 3525 additions and 378 deletions
+75
View File
@@ -61,4 +61,79 @@ describe("SessionMetadataStore", () => {
);
expect(fetched?.title).toBe("新标题");
});
it("does not expose a session across users or projects", async () => {
await store.ensure({
actorKey: "actor-a",
projectId: "project-a",
projectKey: "project-key-a",
sessionId: "private-session",
userId: "user-a",
});
expect(
await store.get(
{
actorKey: "actor-b",
projectId: "project-a",
projectKey: "project-key-a",
userId: "user-b",
},
"private-session",
),
).toBeNull();
expect(
await store.get(
{
actorKey: "actor-a",
projectId: "project-b",
projectKey: "project-key-b",
userId: "user-a",
},
"private-session",
),
).toBeNull();
});
it("rejects idempotent creation when the session belongs to another scope", async () => {
await store.ensure({
actorKey: "actor-a",
projectId: "project-a",
projectKey: "project-key-a",
sessionId: "claimed-session",
userId: "user-a",
});
await expect(
store.ensure({
actorKey: "actor-b",
projectId: "project-b",
projectKey: "project-key-b",
sessionId: "claimed-session",
userId: "user-b",
}),
).rejects.toThrow("session metadata ownership mismatch");
});
it("keeps long session ids with the same slug prefix distinct", async () => {
const prefix = "s".repeat(64);
const firstSessionId = `${prefix}-first`;
const secondSessionId = `${prefix}-second`;
const context = {
actorKey: "actor-long",
projectId: "project-long",
projectKey: "project-key-long",
userId: "user-long",
};
await store.ensure({ ...context, sessionId: firstSessionId });
await store.ensure({ ...context, sessionId: secondSessionId });
expect((await store.get(context, firstSessionId))?.sessionId).toBe(
firstSessionId,
);
expect((await store.get(context, secondSessionId))?.sessionId).toBe(
secondSessionId,
);
});
});