mirror of https://github.com/openclaw/openclaw.git
refactor: share compact hook success harness
This commit is contained in:
parent
e6a26e82ca
commit
df2bda63c6
|
|
@ -278,6 +278,7 @@ vi.mock("../../config/channel-capabilities.js", () => ({
|
|||
}));
|
||||
|
||||
vi.mock("../../utils/message-channel.js", () => ({
|
||||
INTERNAL_MESSAGE_CHANNEL: "webchat",
|
||||
normalizeMessageChannel: vi.fn(() => undefined),
|
||||
}));
|
||||
|
||||
|
|
@ -375,6 +376,16 @@ describe("compactEmbeddedPiSessionDirect hooks", () => {
|
|||
unregisterApiProviders(getCustomApiRegistrySourceId("ollama"));
|
||||
});
|
||||
|
||||
async function runDirectCompaction(customInstructions = "focus on decisions") {
|
||||
return await compactEmbeddedPiSessionDirect({
|
||||
sessionId: "session-1",
|
||||
sessionKey: "agent:main:session-1",
|
||||
sessionFile: "/tmp/session.jsonl",
|
||||
workspaceDir: "/tmp",
|
||||
customInstructions,
|
||||
});
|
||||
}
|
||||
|
||||
it("bootstraps runtime plugins with the resolved workspace", async () => {
|
||||
await compactEmbeddedPiSessionDirect({
|
||||
sessionId: "session-1",
|
||||
|
|
@ -472,13 +483,7 @@ describe("compactEmbeddedPiSessionDirect hooks", () => {
|
|||
hookRunner.hasHooks.mockReturnValue(true);
|
||||
sanitizeSessionHistoryMock.mockResolvedValue([]);
|
||||
|
||||
const result = await compactEmbeddedPiSessionDirect({
|
||||
sessionId: "session-1",
|
||||
sessionKey: "agent:main:session-1",
|
||||
sessionFile: "/tmp/session.jsonl",
|
||||
workspaceDir: "/tmp",
|
||||
customInstructions: "focus on decisions",
|
||||
});
|
||||
const result = await runDirectCompaction();
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
const beforeContext = sessionHook("compact:before")?.context;
|
||||
|
|
@ -528,13 +533,7 @@ describe("compactEmbeddedPiSessionDirect hooks", () => {
|
|||
details: { ok: true },
|
||||
});
|
||||
|
||||
const result = await compactEmbeddedPiSessionDirect({
|
||||
sessionId: "session-1",
|
||||
sessionKey: "agent:main:session-1",
|
||||
sessionFile: "/tmp/session.jsonl",
|
||||
workspaceDir: "/tmp",
|
||||
customInstructions: "focus on decisions",
|
||||
});
|
||||
const result = await runDirectCompaction();
|
||||
|
||||
expect(result).toMatchObject({
|
||||
ok: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue