mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 09:32:42 +00:00
refactor(test): reuse directive per-agent allowlist config
This commit is contained in:
@@ -8,6 +8,34 @@ import {
|
|||||||
} from "./reply.directive.directive-behavior.e2e-harness.js";
|
} from "./reply.directive.directive-behavior.e2e-harness.js";
|
||||||
import { getReplyFromConfig } from "./reply.js";
|
import { getReplyFromConfig } from "./reply.js";
|
||||||
|
|
||||||
|
function makeWorkElevatedAllowlistConfig(home: string) {
|
||||||
|
return {
|
||||||
|
agents: {
|
||||||
|
defaults: {
|
||||||
|
model: "anthropic/claude-opus-4-5",
|
||||||
|
workspace: path.join(home, "openclaw"),
|
||||||
|
},
|
||||||
|
list: [
|
||||||
|
{
|
||||||
|
id: "work",
|
||||||
|
tools: {
|
||||||
|
elevated: {
|
||||||
|
allowFrom: { whatsapp: ["+1333"] },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
tools: {
|
||||||
|
elevated: {
|
||||||
|
allowFrom: { whatsapp: ["+1222", "+1333"] },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
channels: { whatsapp: { allowFrom: ["+1222", "+1333"] } },
|
||||||
|
session: { store: path.join(home, "sessions.json") },
|
||||||
|
} as const;
|
||||||
|
}
|
||||||
|
|
||||||
describe("directive behavior", () => {
|
describe("directive behavior", () => {
|
||||||
installDirectiveBehaviorE2EHooks();
|
installDirectiveBehaviorE2EHooks();
|
||||||
|
|
||||||
@@ -24,31 +52,7 @@ describe("directive behavior", () => {
|
|||||||
CommandAuthorized: true,
|
CommandAuthorized: true,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
{
|
makeWorkElevatedAllowlistConfig(home),
|
||||||
agents: {
|
|
||||||
defaults: {
|
|
||||||
model: "anthropic/claude-opus-4-5",
|
|
||||||
workspace: path.join(home, "openclaw"),
|
|
||||||
},
|
|
||||||
list: [
|
|
||||||
{
|
|
||||||
id: "work",
|
|
||||||
tools: {
|
|
||||||
elevated: {
|
|
||||||
allowFrom: { whatsapp: ["+1333"] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
tools: {
|
|
||||||
elevated: {
|
|
||||||
allowFrom: { whatsapp: ["+1222", "+1333"] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
channels: { whatsapp: { allowFrom: ["+1222", "+1333"] } },
|
|
||||||
session: { store: path.join(home, "sessions.json") },
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
||||||
@@ -69,31 +73,7 @@ describe("directive behavior", () => {
|
|||||||
CommandAuthorized: true,
|
CommandAuthorized: true,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
{
|
makeWorkElevatedAllowlistConfig(home),
|
||||||
agents: {
|
|
||||||
defaults: {
|
|
||||||
model: "anthropic/claude-opus-4-5",
|
|
||||||
workspace: path.join(home, "openclaw"),
|
|
||||||
},
|
|
||||||
list: [
|
|
||||||
{
|
|
||||||
id: "work",
|
|
||||||
tools: {
|
|
||||||
elevated: {
|
|
||||||
allowFrom: { whatsapp: ["+1333"] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
tools: {
|
|
||||||
elevated: {
|
|
||||||
allowFrom: { whatsapp: ["+1222", "+1333"] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
channels: { whatsapp: { allowFrom: ["+1222", "+1333"] } },
|
|
||||||
session: { store: path.join(home, "sessions.json") },
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
||||||
|
|||||||
Reference in New Issue
Block a user