

























@@ -229,7 +229,10 @@ describe("Crestodian rescue message", () => {
229229runRescue("/crestodian plugins search calendar", cfg, commandContext(), deps),
230230).resolves.toContain("search rows: calendar");
231231expect(deps.runPluginsList).toHaveBeenCalledTimes(1);
232-expect(deps.runPluginsSearch).toHaveBeenCalledWith("calendar", expect.any(Object));
232+expect(deps.runPluginsSearch).toHaveBeenCalledTimes(1);
233+const [searchQuery, searchRuntime] = deps.runPluginsSearch.mock.calls[0] ?? [];
234+expect(searchQuery).toBe("calendar");
235+expect(searchRuntime).toBeTypeOf("object");
233236});
234237235238it("queues and applies persistent writes through conversational approval", async () => {
@@ -244,16 +247,17 @@ describe("Crestodian rescue message", () => {
244247"Default model: openai/gpt-5.2",
245248);
246249247-expect(mockConfig.currentConfig()).toMatchObject({
248-agents: { defaults: { model: { primary: "openai/gpt-5.2" } } },
249-});
250+const currentConfig = mockConfig.currentConfig() as {
251+agents?: { defaults?: { model?: { primary?: string } } };
252+};
253+expect(currentConfig.agents?.defaults?.model?.primary).toBe("openai/gpt-5.2");
250254const auditPath = path.join(tempDir, "audit", "crestodian.jsonl");
251-const audit = JSON.parse((await fs.readFile(auditPath, "utf8")).trim());
252-expect(audit.details).toMatchObject({
253- rescue: true,
254- channel: "whatsapp",
255- senderId: "user:owner",
256-});
255+const audit = JSON.parse((await fs.readFile(auditPath, "utf8")).trim()) as {
256+ details?: { rescue?: boolean; channel?: string; senderId?: string };
257+};
258+expect(audit.details?.rescue).toBe(true);
259+expect(audit.details?.channel).toBe("whatsapp");
260+expect(audit.details?.senderId).toBe("user:owner");
257261});
258262259263it("queues and applies gateway restart through conversational approval", async () => {
@@ -271,15 +275,14 @@ describe("Crestodian rescue message", () => {
271275272276expect(deps.runGatewayRestart).toHaveBeenCalledTimes(1);
273277const auditPath = path.join(tempDir, "audit", "crestodian.jsonl");
274-const audit = JSON.parse((await fs.readFile(auditPath, "utf8")).trim());
275-expect(audit).toMatchObject({
276-operation: "gateway.restart",
277-details: {
278-rescue: true,
279-channel: "whatsapp",
280-senderId: "user:owner",
281-},
282-});
278+const audit = JSON.parse((await fs.readFile(auditPath, "utf8")).trim()) as {
279+operation?: string;
280+details?: { rescue?: boolean; channel?: string; senderId?: string };
281+};
282+expect(audit.operation).toBe("gateway.restart");
283+expect(audit.details?.rescue).toBe(true);
284+expect(audit.details?.channel).toBe("whatsapp");
285+expect(audit.details?.senderId).toBe("user:owner");
283286});
284287285288it("queues and applies agent creation through conversational approval", async () => {
@@ -298,26 +301,35 @@ describe("Crestodian rescue message", () => {
298301);
299302300303expect(deps.runAgentsAdd).toHaveBeenCalledTimes(1);
301-expect(deps.runAgentsAdd).toHaveBeenCalledWith(
302-{
303-name: "work",
304-workspace: "/tmp/work",
305-nonInteractive: true,
306-},
307-expect.any(Object),
308-{ hasFlags: true },
309-);
310-const auditPath = path.join(tempDir, "audit", "crestodian.jsonl");
311-const audit = JSON.parse((await fs.readFile(auditPath, "utf8")).trim());
312-expect(audit).toMatchObject({
313-operation: "agents.create",
314-details: {
315-rescue: true,
316-channel: "whatsapp",
317-senderId: "user:owner",
318-agentId: "work",
319-workspace: "/tmp/work",
320-},
304+const [agentParams, agentRuntime, agentOptions] = deps.runAgentsAdd.mock
305+.calls[0] as unknown as [
306+{ name: string; workspace: string; nonInteractive: boolean },
307+object,
308+{ hasFlags: boolean },
309+];
310+expect(agentParams).toEqual({
311+name: "work",
312+workspace: "/tmp/work",
313+nonInteractive: true,
321314});
315+expect(agentRuntime).toBeTypeOf("object");
316+expect(agentOptions).toEqual({ hasFlags: true });
317+const auditPath = path.join(tempDir, "audit", "crestodian.jsonl");
318+const audit = JSON.parse((await fs.readFile(auditPath, "utf8")).trim()) as {
319+operation?: string;
320+details?: {
321+rescue?: boolean;
322+channel?: string;
323+senderId?: string;
324+agentId?: string;
325+workspace?: string;
326+};
327+};
328+expect(audit.operation).toBe("agents.create");
329+expect(audit.details?.rescue).toBe(true);
330+expect(audit.details?.channel).toBe("whatsapp");
331+expect(audit.details?.senderId).toBe("user:owner");
332+expect(audit.details?.agentId).toBe("work");
333+expect(audit.details?.workspace).toBe("/tmp/work");
322334});
323335});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。