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", () => ({
|
vi.mock("../../utils/message-channel.js", () => ({
|
||||||
|
INTERNAL_MESSAGE_CHANNEL: "webchat",
|
||||||
normalizeMessageChannel: vi.fn(() => undefined),
|
normalizeMessageChannel: vi.fn(() => undefined),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -375,6 +376,16 @@ describe("compactEmbeddedPiSessionDirect hooks", () => {
|
||||||
unregisterApiProviders(getCustomApiRegistrySourceId("ollama"));
|
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 () => {
|
it("bootstraps runtime plugins with the resolved workspace", async () => {
|
||||||
await compactEmbeddedPiSessionDirect({
|
await compactEmbeddedPiSessionDirect({
|
||||||
sessionId: "session-1",
|
sessionId: "session-1",
|
||||||
|
|
@ -472,13 +483,7 @@ describe("compactEmbeddedPiSessionDirect hooks", () => {
|
||||||
hookRunner.hasHooks.mockReturnValue(true);
|
hookRunner.hasHooks.mockReturnValue(true);
|
||||||
sanitizeSessionHistoryMock.mockResolvedValue([]);
|
sanitizeSessionHistoryMock.mockResolvedValue([]);
|
||||||
|
|
||||||
const result = await compactEmbeddedPiSessionDirect({
|
const result = await runDirectCompaction();
|
||||||
sessionId: "session-1",
|
|
||||||
sessionKey: "agent:main:session-1",
|
|
||||||
sessionFile: "/tmp/session.jsonl",
|
|
||||||
workspaceDir: "/tmp",
|
|
||||||
customInstructions: "focus on decisions",
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(result.ok).toBe(true);
|
expect(result.ok).toBe(true);
|
||||||
const beforeContext = sessionHook("compact:before")?.context;
|
const beforeContext = sessionHook("compact:before")?.context;
|
||||||
|
|
@ -528,13 +533,7 @@ describe("compactEmbeddedPiSessionDirect hooks", () => {
|
||||||
details: { ok: true },
|
details: { ok: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await compactEmbeddedPiSessionDirect({
|
const result = await runDirectCompaction();
|
||||||
sessionId: "session-1",
|
|
||||||
sessionKey: "agent:main:session-1",
|
|
||||||
sessionFile: "/tmp/session.jsonl",
|
|
||||||
workspaceDir: "/tmp",
|
|
||||||
customInstructions: "focus on decisions",
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
ok: true,
|
ok: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue