refactor(test): dedupe agent and discord test fixtures

This commit is contained in:
Peter Steinberger
2026-02-22 20:01:43 +00:00
parent 5547a2275c
commit 3c75bc0e41
26 changed files with 632 additions and 737 deletions

View File

@@ -0,0 +1,15 @@
import type { OpenClawConfig } from "../../config/config.js";
export function makeModelFallbackCfg(overrides: Partial<OpenClawConfig> = {}): OpenClawConfig {
return {
agents: {
defaults: {
model: {
primary: "openai/gpt-4.1-mini",
fallbacks: ["anthropic/claude-haiku-3-5"],
},
},
},
...overrides,
} as OpenClawConfig;
}

View File

@@ -0,0 +1,44 @@
import type { OpenClawConfig } from "../../config/config.js";
type AgentToolsConfig = NonNullable<NonNullable<OpenClawConfig["agents"]>["list"]>[number]["tools"];
type SandboxToolsConfig = {
allow?: string[];
deny?: string[];
};
export function createRestrictedAgentSandboxConfig(params: {
agentTools?: AgentToolsConfig;
globalSandboxTools?: SandboxToolsConfig;
workspace?: string;
}): OpenClawConfig {
return {
agents: {
defaults: {
sandbox: {
mode: "all",
scope: "agent",
},
},
list: [
{
id: "restricted",
workspace: params.workspace ?? "~/openclaw-restricted",
sandbox: {
mode: "all",
scope: "agent",
},
...(params.agentTools ? { tools: params.agentTools } : {}),
},
],
},
...(params.globalSandboxTools
? {
tools: {
sandbox: {
tools: params.globalSandboxTools,
},
},
}
: {}),
} as OpenClawConfig;
}