mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:08:37 +00:00
refactor(test): trim pi-embedded-runner e2e scaffolding
This commit is contained in:
@@ -1,105 +1,8 @@
|
|||||||
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
||||||
import { SessionManager } from "@mariozechner/pi-coding-agent";
|
import { SessionManager } from "@mariozechner/pi-coding-agent";
|
||||||
import fs from "node:fs/promises";
|
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
|
||||||
import { ensureOpenClawModelsJson } from "./models-config.js";
|
|
||||||
import { applyGoogleTurnOrderingFix } from "./pi-embedded-runner.js";
|
import { applyGoogleTurnOrderingFix } from "./pi-embedded-runner.js";
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-ai", async () => {
|
|
||||||
const actual = await vi.importActual<typeof import("@mariozechner/pi-ai")>("@mariozechner/pi-ai");
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
streamSimple: (model: { api: string; provider: string; id: string }) => {
|
|
||||||
if (model.id === "mock-error") {
|
|
||||||
throw new Error("boom");
|
|
||||||
}
|
|
||||||
const stream = new actual.AssistantMessageEventStream();
|
|
||||||
queueMicrotask(() => {
|
|
||||||
stream.push({
|
|
||||||
type: "done",
|
|
||||||
reason: "stop",
|
|
||||||
message: {
|
|
||||||
role: "assistant",
|
|
||||||
content: [{ type: "text", text: "ok" }],
|
|
||||||
stopReason: "stop",
|
|
||||||
api: model.api,
|
|
||||||
provider: model.provider,
|
|
||||||
model: model.id,
|
|
||||||
usage: {
|
|
||||||
input: 1,
|
|
||||||
output: 1,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
totalTokens: 2,
|
|
||||||
cost: {
|
|
||||||
input: 0,
|
|
||||||
output: 0,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
total: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
timestamp: Date.now(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return stream;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const _makeOpenAiConfig = (modelIds: string[]) =>
|
|
||||||
({
|
|
||||||
models: {
|
|
||||||
providers: {
|
|
||||||
openai: {
|
|
||||||
api: "openai-responses",
|
|
||||||
apiKey: "sk-test",
|
|
||||||
baseUrl: "https://example.com",
|
|
||||||
models: modelIds.map((id) => ({
|
|
||||||
id,
|
|
||||||
name: `Mock ${id}`,
|
|
||||||
reasoning: false,
|
|
||||||
input: ["text"],
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
contextWindow: 16_000,
|
|
||||||
maxTokens: 2048,
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}) satisfies OpenClawConfig;
|
|
||||||
|
|
||||||
const _ensureModels = (cfg: OpenClawConfig, agentDir: string) =>
|
|
||||||
ensureOpenClawModelsJson(cfg, agentDir) as unknown;
|
|
||||||
|
|
||||||
const _textFromContent = (content: unknown) => {
|
|
||||||
if (typeof content === "string") {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
if (Array.isArray(content) && content[0]?.type === "text") {
|
|
||||||
return (content[0] as { text?: string }).text;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const _readSessionMessages = async (sessionFile: string) => {
|
|
||||||
const raw = await fs.readFile(sessionFile, "utf-8");
|
|
||||||
return raw
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.filter(Boolean)
|
|
||||||
.map(
|
|
||||||
(line) =>
|
|
||||||
JSON.parse(line) as {
|
|
||||||
type?: string;
|
|
||||||
message?: { role?: string; content?: unknown };
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.filter((entry) => entry.type === "message")
|
|
||||||
.map((entry) => entry.message as { role?: string; content?: unknown });
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("applyGoogleTurnOrderingFix", () => {
|
describe("applyGoogleTurnOrderingFix", () => {
|
||||||
const makeAssistantFirst = () =>
|
const makeAssistantFirst = () =>
|
||||||
[
|
[
|
||||||
@@ -141,6 +44,7 @@ describe("applyGoogleTurnOrderingFix", () => {
|
|||||||
});
|
});
|
||||||
expect(warn).toHaveBeenCalledTimes(1);
|
expect(warn).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("skips non-Google models", () => {
|
it("skips non-Google models", () => {
|
||||||
const sessionManager = SessionManager.inMemory();
|
const sessionManager = SessionManager.inMemory();
|
||||||
const warn = vi.fn();
|
const warn = vi.fn();
|
||||||
|
|||||||
@@ -1,108 +1,12 @@
|
|||||||
import fs from "node:fs/promises";
|
import { describe, expect, it } from "vitest";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
|
||||||
import type { SandboxContext } from "./sandbox.js";
|
import type { SandboxContext } from "./sandbox.js";
|
||||||
import { ensureOpenClawModelsJson } from "./models-config.js";
|
|
||||||
import { buildEmbeddedSandboxInfo } from "./pi-embedded-runner.js";
|
import { buildEmbeddedSandboxInfo } from "./pi-embedded-runner.js";
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-ai", async () => {
|
|
||||||
const actual = await vi.importActual<typeof import("@mariozechner/pi-ai")>("@mariozechner/pi-ai");
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
streamSimple: (model: { api: string; provider: string; id: string }) => {
|
|
||||||
if (model.id === "mock-error") {
|
|
||||||
throw new Error("boom");
|
|
||||||
}
|
|
||||||
const stream = new actual.AssistantMessageEventStream();
|
|
||||||
queueMicrotask(() => {
|
|
||||||
stream.push({
|
|
||||||
type: "done",
|
|
||||||
reason: "stop",
|
|
||||||
message: {
|
|
||||||
role: "assistant",
|
|
||||||
content: [{ type: "text", text: "ok" }],
|
|
||||||
stopReason: "stop",
|
|
||||||
api: model.api,
|
|
||||||
provider: model.provider,
|
|
||||||
model: model.id,
|
|
||||||
usage: {
|
|
||||||
input: 1,
|
|
||||||
output: 1,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
totalTokens: 2,
|
|
||||||
cost: {
|
|
||||||
input: 0,
|
|
||||||
output: 0,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
total: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
timestamp: Date.now(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return stream;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const _makeOpenAiConfig = (modelIds: string[]) =>
|
|
||||||
({
|
|
||||||
models: {
|
|
||||||
providers: {
|
|
||||||
openai: {
|
|
||||||
api: "openai-responses",
|
|
||||||
apiKey: "sk-test",
|
|
||||||
baseUrl: "https://example.com",
|
|
||||||
models: modelIds.map((id) => ({
|
|
||||||
id,
|
|
||||||
name: `Mock ${id}`,
|
|
||||||
reasoning: false,
|
|
||||||
input: ["text"],
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
contextWindow: 16_000,
|
|
||||||
maxTokens: 2048,
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}) satisfies OpenClawConfig;
|
|
||||||
|
|
||||||
const _ensureModels = (cfg: OpenClawConfig, agentDir: string) =>
|
|
||||||
ensureOpenClawModelsJson(cfg, agentDir) as unknown;
|
|
||||||
|
|
||||||
const _textFromContent = (content: unknown) => {
|
|
||||||
if (typeof content === "string") {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
if (Array.isArray(content) && content[0]?.type === "text") {
|
|
||||||
return (content[0] as { text?: string }).text;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const _readSessionMessages = async (sessionFile: string) => {
|
|
||||||
const raw = await fs.readFile(sessionFile, "utf-8");
|
|
||||||
return raw
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.filter(Boolean)
|
|
||||||
.map(
|
|
||||||
(line) =>
|
|
||||||
JSON.parse(line) as {
|
|
||||||
type?: string;
|
|
||||||
message?: { role?: string; content?: unknown };
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.filter((entry) => entry.type === "message")
|
|
||||||
.map((entry) => entry.message as { role?: string; content?: unknown });
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("buildEmbeddedSandboxInfo", () => {
|
describe("buildEmbeddedSandboxInfo", () => {
|
||||||
it("returns undefined when sandbox is missing", () => {
|
it("returns undefined when sandbox is missing", () => {
|
||||||
expect(buildEmbeddedSandboxInfo()).toBeUndefined();
|
expect(buildEmbeddedSandboxInfo()).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("maps sandbox context into prompt info", () => {
|
it("maps sandbox context into prompt info", () => {
|
||||||
const sandbox = {
|
const sandbox = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
@@ -145,6 +49,7 @@ describe("buildEmbeddedSandboxInfo", () => {
|
|||||||
hostBrowserAllowed: true,
|
hostBrowserAllowed: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("includes elevated info when allowed", () => {
|
it("includes elevated info when allowed", () => {
|
||||||
const sandbox = {
|
const sandbox = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|||||||
@@ -1,108 +1,12 @@
|
|||||||
import fs from "node:fs/promises";
|
import { describe, expect, it } from "vitest";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
|
||||||
import { ensureOpenClawModelsJson } from "./models-config.js";
|
|
||||||
import { createSystemPromptOverride } from "./pi-embedded-runner.js";
|
import { createSystemPromptOverride } from "./pi-embedded-runner.js";
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-ai", async () => {
|
|
||||||
const actual = await vi.importActual<typeof import("@mariozechner/pi-ai")>("@mariozechner/pi-ai");
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
streamSimple: (model: { api: string; provider: string; id: string }) => {
|
|
||||||
if (model.id === "mock-error") {
|
|
||||||
throw new Error("boom");
|
|
||||||
}
|
|
||||||
const stream = new actual.AssistantMessageEventStream();
|
|
||||||
queueMicrotask(() => {
|
|
||||||
stream.push({
|
|
||||||
type: "done",
|
|
||||||
reason: "stop",
|
|
||||||
message: {
|
|
||||||
role: "assistant",
|
|
||||||
content: [{ type: "text", text: "ok" }],
|
|
||||||
stopReason: "stop",
|
|
||||||
api: model.api,
|
|
||||||
provider: model.provider,
|
|
||||||
model: model.id,
|
|
||||||
usage: {
|
|
||||||
input: 1,
|
|
||||||
output: 1,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
totalTokens: 2,
|
|
||||||
cost: {
|
|
||||||
input: 0,
|
|
||||||
output: 0,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
total: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
timestamp: Date.now(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return stream;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const _makeOpenAiConfig = (modelIds: string[]) =>
|
|
||||||
({
|
|
||||||
models: {
|
|
||||||
providers: {
|
|
||||||
openai: {
|
|
||||||
api: "openai-responses",
|
|
||||||
apiKey: "sk-test",
|
|
||||||
baseUrl: "https://example.com",
|
|
||||||
models: modelIds.map((id) => ({
|
|
||||||
id,
|
|
||||||
name: `Mock ${id}`,
|
|
||||||
reasoning: false,
|
|
||||||
input: ["text"],
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
contextWindow: 16_000,
|
|
||||||
maxTokens: 2048,
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}) satisfies OpenClawConfig;
|
|
||||||
|
|
||||||
const _ensureModels = (cfg: OpenClawConfig, agentDir: string) =>
|
|
||||||
ensureOpenClawModelsJson(cfg, agentDir) as unknown;
|
|
||||||
|
|
||||||
const _textFromContent = (content: unknown) => {
|
|
||||||
if (typeof content === "string") {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
if (Array.isArray(content) && content[0]?.type === "text") {
|
|
||||||
return (content[0] as { text?: string }).text;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const _readSessionMessages = async (sessionFile: string) => {
|
|
||||||
const raw = await fs.readFile(sessionFile, "utf-8");
|
|
||||||
return raw
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.filter(Boolean)
|
|
||||||
.map(
|
|
||||||
(line) =>
|
|
||||||
JSON.parse(line) as {
|
|
||||||
type?: string;
|
|
||||||
message?: { role?: string; content?: unknown };
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.filter((entry) => entry.type === "message")
|
|
||||||
.map((entry) => entry.message as { role?: string; content?: unknown });
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("createSystemPromptOverride", () => {
|
describe("createSystemPromptOverride", () => {
|
||||||
it("returns the override prompt trimmed", () => {
|
it("returns the override prompt trimmed", () => {
|
||||||
const override = createSystemPromptOverride("OVERRIDE");
|
const override = createSystemPromptOverride("OVERRIDE");
|
||||||
expect(override()).toBe("OVERRIDE");
|
expect(override()).toBe("OVERRIDE");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns an empty string for blank overrides", () => {
|
it("returns an empty string for blank overrides", () => {
|
||||||
const override = createSystemPromptOverride(" \n ");
|
const override = createSystemPromptOverride(" \n ");
|
||||||
expect(override()).toBe("");
|
expect(override()).toBe("");
|
||||||
|
|||||||
@@ -1,103 +1,7 @@
|
|||||||
import fs from "node:fs/promises";
|
import { describe, expect, it } from "vitest";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { OpenClawConfig } from "../config/config.js";
|
||||||
import { ensureOpenClawModelsJson } from "./models-config.js";
|
|
||||||
import { getDmHistoryLimitFromSessionKey } from "./pi-embedded-runner.js";
|
import { getDmHistoryLimitFromSessionKey } from "./pi-embedded-runner.js";
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-ai", async () => {
|
|
||||||
const actual = await vi.importActual<typeof import("@mariozechner/pi-ai")>("@mariozechner/pi-ai");
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
streamSimple: (model: { api: string; provider: string; id: string }) => {
|
|
||||||
if (model.id === "mock-error") {
|
|
||||||
throw new Error("boom");
|
|
||||||
}
|
|
||||||
const stream = new actual.AssistantMessageEventStream();
|
|
||||||
queueMicrotask(() => {
|
|
||||||
stream.push({
|
|
||||||
type: "done",
|
|
||||||
reason: "stop",
|
|
||||||
message: {
|
|
||||||
role: "assistant",
|
|
||||||
content: [{ type: "text", text: "ok" }],
|
|
||||||
stopReason: "stop",
|
|
||||||
api: model.api,
|
|
||||||
provider: model.provider,
|
|
||||||
model: model.id,
|
|
||||||
usage: {
|
|
||||||
input: 1,
|
|
||||||
output: 1,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
totalTokens: 2,
|
|
||||||
cost: {
|
|
||||||
input: 0,
|
|
||||||
output: 0,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
total: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
timestamp: Date.now(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return stream;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const _makeOpenAiConfig = (modelIds: string[]) =>
|
|
||||||
({
|
|
||||||
models: {
|
|
||||||
providers: {
|
|
||||||
openai: {
|
|
||||||
api: "openai-responses",
|
|
||||||
apiKey: "sk-test",
|
|
||||||
baseUrl: "https://example.com",
|
|
||||||
models: modelIds.map((id) => ({
|
|
||||||
id,
|
|
||||||
name: `Mock ${id}`,
|
|
||||||
reasoning: false,
|
|
||||||
input: ["text"],
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
contextWindow: 16_000,
|
|
||||||
maxTokens: 2048,
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}) satisfies OpenClawConfig;
|
|
||||||
|
|
||||||
const _ensureModels = (cfg: OpenClawConfig, agentDir: string) =>
|
|
||||||
ensureOpenClawModelsJson(cfg, agentDir);
|
|
||||||
|
|
||||||
const _textFromContent = (content: unknown) => {
|
|
||||||
if (typeof content === "string") {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
if (Array.isArray(content) && content[0]?.type === "text") {
|
|
||||||
return (content[0] as { text?: string }).text;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const _readSessionMessages = async (sessionFile: string) => {
|
|
||||||
const raw = await fs.readFile(sessionFile, "utf-8");
|
|
||||||
return raw
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.filter(Boolean)
|
|
||||||
.map(
|
|
||||||
(line) =>
|
|
||||||
JSON.parse(line) as {
|
|
||||||
type?: string;
|
|
||||||
message?: { role?: string; content?: unknown };
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.filter((entry) => entry.type === "message")
|
|
||||||
.map((entry) => entry.message as { role?: string; content?: unknown });
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("getDmHistoryLimitFromSessionKey", () => {
|
describe("getDmHistoryLimitFromSessionKey", () => {
|
||||||
it("falls back to provider default when per-DM not set", () => {
|
it("falls back to provider default when per-DM not set", () => {
|
||||||
const config = {
|
const config = {
|
||||||
|
|||||||
@@ -1,103 +1,7 @@
|
|||||||
import fs from "node:fs/promises";
|
import { describe, expect, it } from "vitest";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { OpenClawConfig } from "../config/config.js";
|
||||||
import { ensureOpenClawModelsJson } from "./models-config.js";
|
|
||||||
import { getDmHistoryLimitFromSessionKey } from "./pi-embedded-runner.js";
|
import { getDmHistoryLimitFromSessionKey } from "./pi-embedded-runner.js";
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-ai", async () => {
|
|
||||||
const actual = await vi.importActual<typeof import("@mariozechner/pi-ai")>("@mariozechner/pi-ai");
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
streamSimple: (model: { api: string; provider: string; id: string }) => {
|
|
||||||
if (model.id === "mock-error") {
|
|
||||||
throw new Error("boom");
|
|
||||||
}
|
|
||||||
const stream = new actual.AssistantMessageEventStream();
|
|
||||||
queueMicrotask(() => {
|
|
||||||
stream.push({
|
|
||||||
type: "done",
|
|
||||||
reason: "stop",
|
|
||||||
message: {
|
|
||||||
role: "assistant",
|
|
||||||
content: [{ type: "text", text: "ok" }],
|
|
||||||
stopReason: "stop",
|
|
||||||
api: model.api,
|
|
||||||
provider: model.provider,
|
|
||||||
model: model.id,
|
|
||||||
usage: {
|
|
||||||
input: 1,
|
|
||||||
output: 1,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
totalTokens: 2,
|
|
||||||
cost: {
|
|
||||||
input: 0,
|
|
||||||
output: 0,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
total: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
timestamp: Date.now(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return stream;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const _makeOpenAiConfig = (modelIds: string[]) =>
|
|
||||||
({
|
|
||||||
models: {
|
|
||||||
providers: {
|
|
||||||
openai: {
|
|
||||||
api: "openai-responses",
|
|
||||||
apiKey: "sk-test",
|
|
||||||
baseUrl: "https://example.com",
|
|
||||||
models: modelIds.map((id) => ({
|
|
||||||
id,
|
|
||||||
name: `Mock ${id}`,
|
|
||||||
reasoning: false,
|
|
||||||
input: ["text"],
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
contextWindow: 16_000,
|
|
||||||
maxTokens: 2048,
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}) satisfies OpenClawConfig;
|
|
||||||
|
|
||||||
const _ensureModels = (cfg: OpenClawConfig, agentDir: string) =>
|
|
||||||
ensureOpenClawModelsJson(cfg, agentDir) as unknown;
|
|
||||||
|
|
||||||
const _textFromContent = (content: unknown) => {
|
|
||||||
if (typeof content === "string") {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
if (Array.isArray(content) && content[0]?.type === "text") {
|
|
||||||
return (content[0] as { text?: string }).text;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const _readSessionMessages = async (sessionFile: string) => {
|
|
||||||
const raw = await fs.readFile(sessionFile, "utf-8");
|
|
||||||
return raw
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.filter(Boolean)
|
|
||||||
.map(
|
|
||||||
(line) =>
|
|
||||||
JSON.parse(line) as {
|
|
||||||
type?: string;
|
|
||||||
message?: { role?: string; content?: unknown };
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.filter((entry) => entry.type === "message")
|
|
||||||
.map((entry) => entry.message as { role?: string; content?: unknown });
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("getDmHistoryLimitFromSessionKey", () => {
|
describe("getDmHistoryLimitFromSessionKey", () => {
|
||||||
it("returns undefined when sessionKey is undefined", () => {
|
it("returns undefined when sessionKey is undefined", () => {
|
||||||
expect(getDmHistoryLimitFromSessionKey(undefined, {})).toBeUndefined();
|
expect(getDmHistoryLimitFromSessionKey(undefined, {})).toBeUndefined();
|
||||||
|
|||||||
@@ -1,104 +1,7 @@
|
|||||||
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
||||||
import fs from "node:fs/promises";
|
import { describe, expect, it } from "vitest";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
|
||||||
import { ensureOpenClawModelsJson } from "./models-config.js";
|
|
||||||
import { limitHistoryTurns } from "./pi-embedded-runner.js";
|
import { limitHistoryTurns } from "./pi-embedded-runner.js";
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-ai", async () => {
|
|
||||||
const actual = await vi.importActual<typeof import("@mariozechner/pi-ai")>("@mariozechner/pi-ai");
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
streamSimple: (model: { api: string; provider: string; id: string }) => {
|
|
||||||
if (model.id === "mock-error") {
|
|
||||||
throw new Error("boom");
|
|
||||||
}
|
|
||||||
const stream = new actual.AssistantMessageEventStream();
|
|
||||||
queueMicrotask(() => {
|
|
||||||
stream.push({
|
|
||||||
type: "done",
|
|
||||||
reason: "stop",
|
|
||||||
message: {
|
|
||||||
role: "assistant",
|
|
||||||
content: [{ type: "text", text: "ok" }],
|
|
||||||
stopReason: "stop",
|
|
||||||
api: model.api,
|
|
||||||
provider: model.provider,
|
|
||||||
model: model.id,
|
|
||||||
usage: {
|
|
||||||
input: 1,
|
|
||||||
output: 1,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
totalTokens: 2,
|
|
||||||
cost: {
|
|
||||||
input: 0,
|
|
||||||
output: 0,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
total: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
timestamp: Date.now(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return stream;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const _makeOpenAiConfig = (modelIds: string[]) =>
|
|
||||||
({
|
|
||||||
models: {
|
|
||||||
providers: {
|
|
||||||
openai: {
|
|
||||||
api: "openai-responses",
|
|
||||||
apiKey: "sk-test",
|
|
||||||
baseUrl: "https://example.com",
|
|
||||||
models: modelIds.map((id) => ({
|
|
||||||
id,
|
|
||||||
name: `Mock ${id}`,
|
|
||||||
reasoning: false,
|
|
||||||
input: ["text"],
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
contextWindow: 16_000,
|
|
||||||
maxTokens: 2048,
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}) satisfies OpenClawConfig;
|
|
||||||
|
|
||||||
const _ensureModels = (cfg: OpenClawConfig, agentDir: string) =>
|
|
||||||
ensureOpenClawModelsJson(cfg, agentDir) as unknown;
|
|
||||||
|
|
||||||
const _textFromContent = (content: unknown) => {
|
|
||||||
if (typeof content === "string") {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
if (Array.isArray(content) && content[0]?.type === "text") {
|
|
||||||
return (content[0] as { text?: string }).text;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const _readSessionMessages = async (sessionFile: string) => {
|
|
||||||
const raw = await fs.readFile(sessionFile, "utf-8");
|
|
||||||
return raw
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.filter(Boolean)
|
|
||||||
.map(
|
|
||||||
(line) =>
|
|
||||||
JSON.parse(line) as {
|
|
||||||
type?: string;
|
|
||||||
message?: { role?: string; content?: unknown };
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.filter((entry) => entry.type === "message")
|
|
||||||
.map((entry) => entry.message as { role?: string; content?: unknown });
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("limitHistoryTurns", () => {
|
describe("limitHistoryTurns", () => {
|
||||||
const makeMessages = (roles: ("user" | "assistant")[]): AgentMessage[] =>
|
const makeMessages = (roles: ("user" | "assistant")[]): AgentMessage[] =>
|
||||||
roles.map((role, i) => ({
|
roles.map((role, i) => ({
|
||||||
@@ -110,27 +13,33 @@ describe("limitHistoryTurns", () => {
|
|||||||
const messages = makeMessages(["user", "assistant", "user", "assistant"]);
|
const messages = makeMessages(["user", "assistant", "user", "assistant"]);
|
||||||
expect(limitHistoryTurns(messages, undefined)).toBe(messages);
|
expect(limitHistoryTurns(messages, undefined)).toBe(messages);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns all messages when limit is 0", () => {
|
it("returns all messages when limit is 0", () => {
|
||||||
const messages = makeMessages(["user", "assistant", "user", "assistant"]);
|
const messages = makeMessages(["user", "assistant", "user", "assistant"]);
|
||||||
expect(limitHistoryTurns(messages, 0)).toBe(messages);
|
expect(limitHistoryTurns(messages, 0)).toBe(messages);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns all messages when limit is negative", () => {
|
it("returns all messages when limit is negative", () => {
|
||||||
const messages = makeMessages(["user", "assistant", "user", "assistant"]);
|
const messages = makeMessages(["user", "assistant", "user", "assistant"]);
|
||||||
expect(limitHistoryTurns(messages, -1)).toBe(messages);
|
expect(limitHistoryTurns(messages, -1)).toBe(messages);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns empty array when messages is empty", () => {
|
it("returns empty array when messages is empty", () => {
|
||||||
expect(limitHistoryTurns([], 5)).toEqual([]);
|
expect(limitHistoryTurns([], 5)).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps all messages when fewer user turns than limit", () => {
|
it("keeps all messages when fewer user turns than limit", () => {
|
||||||
const messages = makeMessages(["user", "assistant", "user", "assistant"]);
|
const messages = makeMessages(["user", "assistant", "user", "assistant"]);
|
||||||
expect(limitHistoryTurns(messages, 10)).toBe(messages);
|
expect(limitHistoryTurns(messages, 10)).toBe(messages);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("limits to last N user turns", () => {
|
it("limits to last N user turns", () => {
|
||||||
const messages = makeMessages(["user", "assistant", "user", "assistant", "user", "assistant"]);
|
const messages = makeMessages(["user", "assistant", "user", "assistant", "user", "assistant"]);
|
||||||
const limited = limitHistoryTurns(messages, 2);
|
const limited = limitHistoryTurns(messages, 2);
|
||||||
expect(limited.length).toBe(4);
|
expect(limited.length).toBe(4);
|
||||||
expect(limited[0].content).toEqual([{ type: "text", text: "message 2" }]);
|
expect(limited[0].content).toEqual([{ type: "text", text: "message 2" }]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("handles single user turn limit", () => {
|
it("handles single user turn limit", () => {
|
||||||
const messages = makeMessages(["user", "assistant", "user", "assistant", "user", "assistant"]);
|
const messages = makeMessages(["user", "assistant", "user", "assistant", "user", "assistant"]);
|
||||||
const limited = limitHistoryTurns(messages, 1);
|
const limited = limitHistoryTurns(messages, 1);
|
||||||
@@ -138,6 +47,7 @@ describe("limitHistoryTurns", () => {
|
|||||||
expect(limited[0].content).toEqual([{ type: "text", text: "message 4" }]);
|
expect(limited[0].content).toEqual([{ type: "text", text: "message 4" }]);
|
||||||
expect(limited[1].content).toEqual([{ type: "text", text: "message 5" }]);
|
expect(limited[1].content).toEqual([{ type: "text", text: "message 5" }]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("handles messages with multiple assistant responses per user turn", () => {
|
it("handles messages with multiple assistant responses per user turn", () => {
|
||||||
const messages = makeMessages(["user", "assistant", "assistant", "user", "assistant"]);
|
const messages = makeMessages(["user", "assistant", "assistant", "user", "assistant"]);
|
||||||
const limited = limitHistoryTurns(messages, 1);
|
const limited = limitHistoryTurns(messages, 1);
|
||||||
@@ -145,6 +55,7 @@ describe("limitHistoryTurns", () => {
|
|||||||
expect(limited[0].role).toBe("user");
|
expect(limited[0].role).toBe("user");
|
||||||
expect(limited[1].role).toBe("assistant");
|
expect(limited[1].role).toBe("assistant");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("preserves message content integrity", () => {
|
it("preserves message content integrity", () => {
|
||||||
const messages: AgentMessage[] = [
|
const messages: AgentMessage[] = [
|
||||||
{ role: "user", content: [{ type: "text", text: "first" }] },
|
{ role: "user", content: [{ type: "text", text: "first" }] },
|
||||||
|
|||||||
@@ -1,102 +1,6 @@
|
|||||||
import fs from "node:fs/promises";
|
import { describe, expect, it } from "vitest";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { OpenClawConfig } from "../config/config.js";
|
||||||
import { resolveSessionAgentIds } from "./agent-scope.js";
|
import { resolveSessionAgentIds } from "./agent-scope.js";
|
||||||
import { ensureOpenClawModelsJson } from "./models-config.js";
|
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-ai", async () => {
|
|
||||||
const actual = await vi.importActual<typeof import("@mariozechner/pi-ai")>("@mariozechner/pi-ai");
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
streamSimple: (model: { api: string; provider: string; id: string }) => {
|
|
||||||
if (model.id === "mock-error") {
|
|
||||||
throw new Error("boom");
|
|
||||||
}
|
|
||||||
const stream = new actual.AssistantMessageEventStream();
|
|
||||||
queueMicrotask(() => {
|
|
||||||
stream.push({
|
|
||||||
type: "done",
|
|
||||||
reason: "stop",
|
|
||||||
message: {
|
|
||||||
role: "assistant",
|
|
||||||
content: [{ type: "text", text: "ok" }],
|
|
||||||
stopReason: "stop",
|
|
||||||
api: model.api,
|
|
||||||
provider: model.provider,
|
|
||||||
model: model.id,
|
|
||||||
usage: {
|
|
||||||
input: 1,
|
|
||||||
output: 1,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
totalTokens: 2,
|
|
||||||
cost: {
|
|
||||||
input: 0,
|
|
||||||
output: 0,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
total: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
timestamp: Date.now(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return stream;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const _makeOpenAiConfig = (modelIds: string[]) =>
|
|
||||||
({
|
|
||||||
models: {
|
|
||||||
providers: {
|
|
||||||
openai: {
|
|
||||||
api: "openai-responses",
|
|
||||||
apiKey: "sk-test",
|
|
||||||
baseUrl: "https://example.com",
|
|
||||||
models: modelIds.map((id) => ({
|
|
||||||
id,
|
|
||||||
name: `Mock ${id}`,
|
|
||||||
reasoning: false,
|
|
||||||
input: ["text"],
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
contextWindow: 16_000,
|
|
||||||
maxTokens: 2048,
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}) satisfies OpenClawConfig;
|
|
||||||
|
|
||||||
const _ensureModels = (cfg: OpenClawConfig, agentDir: string) =>
|
|
||||||
ensureOpenClawModelsJson(cfg, agentDir) as unknown;
|
|
||||||
|
|
||||||
const _textFromContent = (content: unknown) => {
|
|
||||||
if (typeof content === "string") {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
if (Array.isArray(content) && content[0]?.type === "text") {
|
|
||||||
return (content[0] as { text?: string }).text;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const _readSessionMessages = async (sessionFile: string) => {
|
|
||||||
const raw = await fs.readFile(sessionFile, "utf-8");
|
|
||||||
return raw
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.filter(Boolean)
|
|
||||||
.map(
|
|
||||||
(line) =>
|
|
||||||
JSON.parse(line) as {
|
|
||||||
type?: string;
|
|
||||||
message?: { role?: string; content?: unknown };
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.filter((entry) => entry.type === "message")
|
|
||||||
.map((entry) => entry.message as { role?: string; content?: unknown });
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("resolveSessionAgentIds", () => {
|
describe("resolveSessionAgentIds", () => {
|
||||||
const cfg = {
|
const cfg = {
|
||||||
@@ -112,6 +16,7 @@ describe("resolveSessionAgentIds", () => {
|
|||||||
expect(defaultAgentId).toBe("beta");
|
expect(defaultAgentId).toBe("beta");
|
||||||
expect(sessionAgentId).toBe("beta");
|
expect(sessionAgentId).toBe("beta");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("falls back to the configured default when sessionKey is non-agent", () => {
|
it("falls back to the configured default when sessionKey is non-agent", () => {
|
||||||
const { sessionAgentId } = resolveSessionAgentIds({
|
const { sessionAgentId } = resolveSessionAgentIds({
|
||||||
sessionKey: "telegram:slash:123",
|
sessionKey: "telegram:slash:123",
|
||||||
@@ -119,6 +24,7 @@ describe("resolveSessionAgentIds", () => {
|
|||||||
});
|
});
|
||||||
expect(sessionAgentId).toBe("beta");
|
expect(sessionAgentId).toBe("beta");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("falls back to the configured default for global sessions", () => {
|
it("falls back to the configured default for global sessions", () => {
|
||||||
const { sessionAgentId } = resolveSessionAgentIds({
|
const { sessionAgentId } = resolveSessionAgentIds({
|
||||||
sessionKey: "global",
|
sessionKey: "global",
|
||||||
@@ -126,6 +32,7 @@ describe("resolveSessionAgentIds", () => {
|
|||||||
});
|
});
|
||||||
expect(sessionAgentId).toBe("beta");
|
expect(sessionAgentId).toBe("beta");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps the agent id for provider-qualified agent sessions", () => {
|
it("keeps the agent id for provider-qualified agent sessions", () => {
|
||||||
const { sessionAgentId } = resolveSessionAgentIds({
|
const { sessionAgentId } = resolveSessionAgentIds({
|
||||||
sessionKey: "agent:beta:slack:channel:c1",
|
sessionKey: "agent:beta:slack:channel:c1",
|
||||||
@@ -133,6 +40,7 @@ describe("resolveSessionAgentIds", () => {
|
|||||||
});
|
});
|
||||||
expect(sessionAgentId).toBe("beta");
|
expect(sessionAgentId).toBe("beta");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses the agent id from agent session keys", () => {
|
it("uses the agent id from agent session keys", () => {
|
||||||
const { sessionAgentId } = resolveSessionAgentIds({
|
const { sessionAgentId } = resolveSessionAgentIds({
|
||||||
sessionKey: "agent:main:main",
|
sessionKey: "agent:main:main",
|
||||||
|
|||||||
@@ -1,104 +1,7 @@
|
|||||||
import type { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core";
|
import type { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||||
import fs from "node:fs/promises";
|
import { describe, expect, it } from "vitest";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
|
||||||
import { ensureOpenClawModelsJson } from "./models-config.js";
|
|
||||||
import { splitSdkTools } from "./pi-embedded-runner.js";
|
import { splitSdkTools } from "./pi-embedded-runner.js";
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-ai", async () => {
|
|
||||||
const actual = await vi.importActual<typeof import("@mariozechner/pi-ai")>("@mariozechner/pi-ai");
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
streamSimple: (model: { api: string; provider: string; id: string }) => {
|
|
||||||
if (model.id === "mock-error") {
|
|
||||||
throw new Error("boom");
|
|
||||||
}
|
|
||||||
const stream = new actual.AssistantMessageEventStream();
|
|
||||||
queueMicrotask(() => {
|
|
||||||
stream.push({
|
|
||||||
type: "done",
|
|
||||||
reason: "stop",
|
|
||||||
message: {
|
|
||||||
role: "assistant",
|
|
||||||
content: [{ type: "text", text: "ok" }],
|
|
||||||
stopReason: "stop",
|
|
||||||
api: model.api,
|
|
||||||
provider: model.provider,
|
|
||||||
model: model.id,
|
|
||||||
usage: {
|
|
||||||
input: 1,
|
|
||||||
output: 1,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
totalTokens: 2,
|
|
||||||
cost: {
|
|
||||||
input: 0,
|
|
||||||
output: 0,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
total: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
timestamp: Date.now(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return stream;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const _makeOpenAiConfig = (modelIds: string[]) =>
|
|
||||||
({
|
|
||||||
models: {
|
|
||||||
providers: {
|
|
||||||
openai: {
|
|
||||||
api: "openai-responses",
|
|
||||||
apiKey: "sk-test",
|
|
||||||
baseUrl: "https://example.com",
|
|
||||||
models: modelIds.map((id) => ({
|
|
||||||
id,
|
|
||||||
name: `Mock ${id}`,
|
|
||||||
reasoning: false,
|
|
||||||
input: ["text"],
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
contextWindow: 16_000,
|
|
||||||
maxTokens: 2048,
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}) satisfies OpenClawConfig;
|
|
||||||
|
|
||||||
const _ensureModels = (cfg: OpenClawConfig, agentDir: string) =>
|
|
||||||
ensureOpenClawModelsJson(cfg, agentDir) as unknown;
|
|
||||||
|
|
||||||
const _textFromContent = (content: unknown) => {
|
|
||||||
if (typeof content === "string") {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
if (Array.isArray(content) && content[0]?.type === "text") {
|
|
||||||
return (content[0] as { text?: string }).text;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const _readSessionMessages = async (sessionFile: string) => {
|
|
||||||
const raw = await fs.readFile(sessionFile, "utf-8");
|
|
||||||
return raw
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.filter(Boolean)
|
|
||||||
.map(
|
|
||||||
(line) =>
|
|
||||||
JSON.parse(line) as {
|
|
||||||
type?: string;
|
|
||||||
message?: { role?: string; content?: unknown };
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.filter((entry) => entry.type === "message")
|
|
||||||
.map((entry) => entry.message as { role?: string; content?: unknown });
|
|
||||||
};
|
|
||||||
|
|
||||||
function createStubTool(name: string): AgentTool<unknown, unknown> {
|
function createStubTool(name: string): AgentTool<unknown, unknown> {
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
@@ -132,6 +35,7 @@ describe("splitSdkTools", () => {
|
|||||||
"browser",
|
"browser",
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("routes all tools to customTools even when not sandboxed", () => {
|
it("routes all tools to customTools even when not sandboxed", () => {
|
||||||
const { builtInTools, customTools } = splitSdkTools({
|
const { builtInTools, customTools } = splitSdkTools({
|
||||||
tools,
|
tools,
|
||||||
|
|||||||
Reference in New Issue
Block a user