mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:51:25 +00:00
refactor(test): dedupe agent and discord test fixtures
This commit is contained in:
15
src/agents/test-helpers/model-fallback-config-fixture.ts
Normal file
15
src/agents/test-helpers/model-fallback-config-fixture.ts
Normal 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;
|
||||
}
|
||||
44
src/agents/test-helpers/sandbox-agent-config-fixtures.ts
Normal file
44
src/agents/test-helpers/sandbox-agent-config-fixtures.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user