mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:21:23 +00:00
chore: merge origin/main into main
This commit is contained in:
@@ -4,10 +4,12 @@ import { beforeEach, describe, expect, it, type MockInstance, vi } from "vitest"
|
||||
import { telegramPlugin } from "../../extensions/telegram/src/channel.js";
|
||||
import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js";
|
||||
import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js";
|
||||
import * as cliRunnerModule from "../agents/cli-runner.js";
|
||||
import { loadModelCatalog } from "../agents/model-catalog.js";
|
||||
import { runEmbeddedPiAgent } from "../agents/pi-embedded.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import * as configModule from "../config/config.js";
|
||||
import * as sessionsModule from "../config/sessions.js";
|
||||
import { emitAgentEvent, onAgentEvent } from "../infra/agent-events.js";
|
||||
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import { createPluginRuntime } from "../plugins/runtime/index.js";
|
||||
@@ -40,6 +42,7 @@ const runtime: RuntimeEnv = {
|
||||
};
|
||||
|
||||
const configSpy = vi.spyOn(configModule, "loadConfig");
|
||||
const runCliAgentSpy = vi.spyOn(cliRunnerModule, "runCliAgent");
|
||||
|
||||
async function withTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
|
||||
return withTempHomeBase(fn, { prefix: "openclaw-agent-" });
|
||||
@@ -79,6 +82,13 @@ function writeSessionStoreSeed(
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
runCliAgentSpy.mockResolvedValue({
|
||||
payloads: [{ text: "ok" }],
|
||||
meta: {
|
||||
durationMs: 5,
|
||||
agentMeta: { sessionId: "s", provider: "p", model: "m" },
|
||||
},
|
||||
} as never);
|
||||
vi.mocked(runEmbeddedPiAgent).mockResolvedValue({
|
||||
payloads: [{ text: "ok" }],
|
||||
meta: {
|
||||
@@ -146,6 +156,28 @@ describe("agentCommand", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves resumed session transcript path from custom session store directory", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const customStoreDir = path.join(home, "custom-state");
|
||||
const store = path.join(customStoreDir, "sessions.json");
|
||||
writeSessionStoreSeed(store, {});
|
||||
mockConfig(home, store);
|
||||
const resolveSessionFilePathSpy = vi.spyOn(sessionsModule, "resolveSessionFilePath");
|
||||
|
||||
await agentCommand({ message: "resume me", sessionId: "session-custom-123" }, runtime);
|
||||
|
||||
const matchingCall = resolveSessionFilePathSpy.mock.calls.find(
|
||||
(call) => call[0] === "session-custom-123",
|
||||
);
|
||||
expect(matchingCall?.[2]).toEqual(
|
||||
expect.objectContaining({
|
||||
agentId: "main",
|
||||
sessionsDir: customStoreDir,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("does not duplicate agent events from embedded runs", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const store = path.join(home, "sessions.json");
|
||||
|
||||
Reference in New Issue
Block a user