mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
chore: Fix types in tests 32/N.
This commit is contained in:
@@ -20,7 +20,7 @@ describe("bash process registry", () => {
|
||||
const session: ProcessSession = {
|
||||
id: "sess",
|
||||
command: "echo test",
|
||||
child: { pid: 123, removeAllListeners: vi.fn() } as ChildProcessWithoutNullStreams,
|
||||
child: { pid: 123, removeAllListeners: vi.fn() } as unknown as ChildProcessWithoutNullStreams,
|
||||
startedAt: Date.now(),
|
||||
cwd: "/tmp",
|
||||
maxOutputChars: 10,
|
||||
@@ -51,7 +51,7 @@ describe("bash process registry", () => {
|
||||
const session: ProcessSession = {
|
||||
id: "sess",
|
||||
command: "echo test",
|
||||
child: { pid: 123, removeAllListeners: vi.fn() } as ChildProcessWithoutNullStreams,
|
||||
child: { pid: 123, removeAllListeners: vi.fn() } as unknown as ChildProcessWithoutNullStreams,
|
||||
startedAt: Date.now(),
|
||||
cwd: "/tmp",
|
||||
maxOutputChars: 100_000,
|
||||
@@ -85,7 +85,7 @@ describe("bash process registry", () => {
|
||||
const session: ProcessSession = {
|
||||
id: "sess",
|
||||
command: "echo test",
|
||||
child: { pid: 123, removeAllListeners: vi.fn() } as ChildProcessWithoutNullStreams,
|
||||
child: { pid: 123, removeAllListeners: vi.fn() } as unknown as ChildProcessWithoutNullStreams,
|
||||
startedAt: Date.now(),
|
||||
cwd: "/tmp",
|
||||
maxOutputChars: 5_000,
|
||||
@@ -116,7 +116,7 @@ describe("bash process registry", () => {
|
||||
const session: ProcessSession = {
|
||||
id: "sess",
|
||||
command: "echo test",
|
||||
child: { pid: 123, removeAllListeners: vi.fn() } as ChildProcessWithoutNullStreams,
|
||||
child: { pid: 123, removeAllListeners: vi.fn() } as unknown as ChildProcessWithoutNullStreams,
|
||||
startedAt: Date.now(),
|
||||
cwd: "/tmp",
|
||||
maxOutputChars: 100,
|
||||
@@ -150,7 +150,7 @@ describe("bash process registry", () => {
|
||||
const session: ProcessSession = {
|
||||
id: "sess",
|
||||
command: "echo test",
|
||||
child: { pid: 123, removeAllListeners: vi.fn() } as ChildProcessWithoutNullStreams,
|
||||
child: { pid: 123, removeAllListeners: vi.fn() } as unknown as ChildProcessWithoutNullStreams,
|
||||
startedAt: Date.now(),
|
||||
cwd: "/tmp",
|
||||
maxOutputChars: 100,
|
||||
|
||||
@@ -4,9 +4,9 @@ import {
|
||||
getFinishedSession,
|
||||
getSession,
|
||||
resetProcessRegistryForTests,
|
||||
} from "./bash-process-registry";
|
||||
import { createExecTool } from "./bash-tools.exec";
|
||||
import { killProcessTree } from "./shell-utils";
|
||||
} from "./bash-process-registry.js";
|
||||
import { createExecTool } from "./bash-tools.exec.js";
|
||||
import { killProcessTree } from "./shell-utils.js";
|
||||
|
||||
afterEach(() => {
|
||||
resetProcessRegistryForTests();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, expect, test, vi } from "vitest";
|
||||
import { resetProcessRegistryForTests } from "./bash-process-registry";
|
||||
import { createExecTool } from "./bash-tools.exec";
|
||||
import { resetProcessRegistryForTests } from "./bash-process-registry.js";
|
||||
import { createExecTool } from "./bash-tools.exec.js";
|
||||
|
||||
const { ptySpawnMock } = vi.hoisted(() => ({
|
||||
ptySpawnMock: vi.fn(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, expect, test, vi } from "vitest";
|
||||
import { listRunningSessions, resetProcessRegistryForTests } from "./bash-process-registry";
|
||||
import { createExecTool } from "./bash-tools.exec";
|
||||
import { listRunningSessions, resetProcessRegistryForTests } from "./bash-process-registry.js";
|
||||
import { createExecTool } from "./bash-tools.exec.js";
|
||||
|
||||
const { supervisorSpawnMock } = vi.hoisted(() => ({
|
||||
supervisorSpawnMock: vi.fn(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, expect, test, vi } from "vitest";
|
||||
import { resetProcessRegistryForTests } from "./bash-process-registry";
|
||||
import { createExecTool } from "./bash-tools.exec";
|
||||
import { resetProcessRegistryForTests } from "./bash-process-registry.js";
|
||||
import { createExecTool } from "./bash-tools.exec.js";
|
||||
|
||||
vi.mock("@lydell/node-pty", () => ({
|
||||
spawn: () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, expect, test } from "vitest";
|
||||
import { resetProcessRegistryForTests } from "./bash-process-registry";
|
||||
import { createExecTool } from "./bash-tools.exec";
|
||||
import { resetProcessRegistryForTests } from "./bash-process-registry.js";
|
||||
import { createExecTool } from "./bash-tools.exec.js";
|
||||
|
||||
afterEach(() => {
|
||||
resetProcessRegistryForTests();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { afterEach, expect, test } from "vitest";
|
||||
import { sleep } from "../utils";
|
||||
import { resetProcessRegistryForTests } from "./bash-process-registry";
|
||||
import { createExecTool } from "./bash-tools.exec";
|
||||
import { createProcessTool } from "./bash-tools.process";
|
||||
import { sleep } from "../utils.js";
|
||||
import { resetProcessRegistryForTests } from "./bash-process-registry.js";
|
||||
import { createExecTool } from "./bash-tools.exec.js";
|
||||
import { createProcessTool } from "./bash-tools.process.js";
|
||||
|
||||
afterEach(() => {
|
||||
resetProcessRegistryForTests();
|
||||
|
||||
@@ -24,15 +24,15 @@ describe("compaction retry integration", () => {
|
||||
vi.clearAllTimers();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
const testMessages: AgentMessage[] = [
|
||||
const testMessages = [
|
||||
{ role: "user", content: "Test message" },
|
||||
{ role: "assistant", content: "Test response" },
|
||||
];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const testModel: NonNullable<ExtensionContext["model"]> = {
|
||||
const testModel = {
|
||||
provider: "anthropic",
|
||||
model: "claude-3-opus",
|
||||
};
|
||||
} as unknown as NonNullable<ExtensionContext["model"]>;
|
||||
|
||||
it("should successfully call generateSummary with retry wrapper", async () => {
|
||||
mockGenerateSummary.mockResolvedValueOnce("Test summary");
|
||||
|
||||
@@ -30,7 +30,7 @@ describe("compaction toolResult details stripping", () => {
|
||||
role: "assistant",
|
||||
content: [{ type: "toolUse", id: "call_1", name: "browser", input: { action: "tabs" } }],
|
||||
timestamp: 1,
|
||||
} as AgentMessage,
|
||||
} as unknown as AgentMessage,
|
||||
{
|
||||
role: "toolResult",
|
||||
toolCallId: "call_1",
|
||||
@@ -57,7 +57,9 @@ describe("compaction toolResult details stripping", () => {
|
||||
expect(summary).toBe("summary");
|
||||
expect(piCodingAgentMocks.generateSummary).toHaveBeenCalled();
|
||||
|
||||
const [chunk] = piCodingAgentMocks.generateSummary.mock.calls[0] ?? [];
|
||||
const chunk = (
|
||||
piCodingAgentMocks.generateSummary.mock.calls as unknown as Array<[unknown]>
|
||||
)[0]?.[0];
|
||||
const serialized = JSON.stringify(chunk);
|
||||
expect(serialized).not.toContain("Ignore previous instructions");
|
||||
expect(serialized).not.toContain('"details"');
|
||||
|
||||
@@ -287,7 +287,7 @@ describe("createOllamaStreamFn", () => {
|
||||
expect(events.at(-1)?.type).toBe("done");
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
const [url, requestInit] = fetchMock.mock.calls[0] as [string, RequestInit];
|
||||
const [url, requestInit] = fetchMock.mock.calls[0] as unknown as [string, RequestInit];
|
||||
expect(url).toBe("http://ollama-host:11434/api/chat");
|
||||
expect(requestInit.signal).toBe(signal);
|
||||
if (typeof requestInit.body !== "string") {
|
||||
|
||||
@@ -140,7 +140,11 @@ describe("sessions tools", () => {
|
||||
|
||||
const result = await tool.execute("call1", { messageLimit: 1 });
|
||||
const details = result.details as {
|
||||
sessions?: Array<Record<string, unknown>>;
|
||||
sessions?: Array<{
|
||||
key?: string;
|
||||
channel?: string;
|
||||
messages?: Array<{ role?: string }>;
|
||||
}>;
|
||||
};
|
||||
expect(details.sessions).toHaveLength(3);
|
||||
const main = details.sessions?.find((s) => s.key === "main");
|
||||
@@ -178,7 +182,7 @@ describe("sessions tools", () => {
|
||||
}
|
||||
|
||||
const result = await tool.execute("call3", { sessionKey: "main" });
|
||||
const details = result.details as { messages?: unknown[] };
|
||||
const details = result.details as { messages?: Array<{ role?: string }> };
|
||||
expect(details.messages).toHaveLength(1);
|
||||
expect(details.messages?.[0]?.role).toBe("assistant");
|
||||
|
||||
@@ -764,6 +768,8 @@ describe("sessions tools", () => {
|
||||
.spyOn(sessionsModule, "loadSessionStore")
|
||||
.mockImplementation(() => ({
|
||||
"agent:main:subagent:usage-active": {
|
||||
sessionId: "session-usage-active",
|
||||
updatedAt: now,
|
||||
modelProvider: "anthropic",
|
||||
model: "claude-opus-4-6",
|
||||
inputTokens: 12,
|
||||
|
||||
@@ -269,7 +269,7 @@ describe("installSessionToolResultGuard", () => {
|
||||
? ({
|
||||
...(message as unknown as Record<string, unknown>),
|
||||
provenance: { kind: "inter_session", sourceTool: "sessions_send" },
|
||||
} as AgentMessage)
|
||||
} as unknown as AgentMessage)
|
||||
: message,
|
||||
});
|
||||
|
||||
|
||||
@@ -34,12 +34,13 @@ function writeTempPlugin(params: { dir: string; id: string; body: string }): str
|
||||
}
|
||||
|
||||
function appendToolCallAndResult(sm: ReturnType<typeof SessionManager.inMemory>) {
|
||||
sm.appendMessage({
|
||||
const appendMessage = sm.appendMessage.bind(sm) as unknown as (message: AgentMessage) => void;
|
||||
appendMessage({
|
||||
role: "assistant",
|
||||
content: [{ type: "toolCall", id: "call_1", name: "read", arguments: {} }],
|
||||
} as AgentMessage);
|
||||
|
||||
sm.appendMessage({
|
||||
appendMessage({
|
||||
role: "toolResult",
|
||||
toolCallId: "call_1",
|
||||
isError: false,
|
||||
|
||||
Reference in New Issue
Block a user