




























@@ -3329,14 +3329,40 @@ describe("gateway server sessions", () => {
33293329ws.close();
33303330});
333133313332-test("webchat clients cannot patch or delete sessions", async () => {
3333-await createSessionStoreDir();
3332+test("webchat clients cannot patch, delete, compact, or restore sessions", async () => {
3333+const { dir } = await createSessionStoreDir();
3334+const fixture = await createCheckpointFixture(dir);
3334333533353336await writeSessionStore({
33363337entries: {
33373338main: {
3338-sessionId: "sess-main",
3339+sessionId: fixture.sessionId,
3340+sessionFile: fixture.sessionFile,
33393341updatedAt: Date.now(),
3342+compactionCheckpoints: [
3343+{
3344+checkpointId: "checkpoint-1",
3345+sessionKey: "agent:main:main",
3346+sessionId: fixture.sessionId,
3347+createdAt: Date.now(),
3348+reason: "manual",
3349+tokensBefore: 123,
3350+tokensAfter: 45,
3351+summary: "checkpoint summary",
3352+firstKeptEntryId: fixture.preCompactionLeafId,
3353+preCompaction: {
3354+sessionId: fixture.preCompactionSession.getSessionId(),
3355+sessionFile: fixture.preCompactionSessionFile,
3356+leafId: fixture.preCompactionLeafId,
3357+},
3358+postCompaction: {
3359+sessionId: fixture.sessionId,
3360+sessionFile: fixture.sessionFile,
3361+leafId: fixture.postCompactionLeafId,
3362+entryId: fixture.postCompactionLeafId,
3363+},
3364+},
3365+],
33403366},
33413367"discord:group:dev": {
33423368sessionId: "sess-group",
@@ -3373,6 +3399,20 @@ describe("gateway server sessions", () => {
33733399expect(deleted.ok).toBe(false);
33743400expect(deleted.error?.message ?? "").toMatch(/webchat clients cannot delete sessions/i);
337534013402+const compacted = await rpcReq(ws, "sessions.compact", {
3403+key: "main",
3404+maxLines: 3,
3405+});
3406+expect(compacted.ok).toBe(false);
3407+expect(compacted.error?.message ?? "").toMatch(/webchat clients cannot compact sessions/i);
3408+3409+const restored = await rpcReq(ws, "sessions.compaction.restore", {
3410+key: "main",
3411+checkpointId: "checkpoint-1",
3412+});
3413+expect(restored.ok).toBe(false);
3414+expect(restored.error?.message ?? "").toMatch(/webchat clients cannot restore sessions/i);
3415+33763416ws.close();
33773417});
33783418此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。