mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 23:02:02 +03:00
refactor(test): share directive elevated config
This commit is contained in:
@@ -56,3 +56,29 @@ export function installDirectiveBehaviorE2EHooks() {
|
|||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function makeRestrictedElevatedDisabledConfig(home: string) {
|
||||||
|
return {
|
||||||
|
agents: {
|
||||||
|
defaults: {
|
||||||
|
model: "anthropic/claude-opus-4-5",
|
||||||
|
workspace: path.join(home, "openclaw"),
|
||||||
|
},
|
||||||
|
list: [
|
||||||
|
{
|
||||||
|
id: "restricted",
|
||||||
|
tools: {
|
||||||
|
elevated: { enabled: false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
tools: {
|
||||||
|
elevated: {
|
||||||
|
allowFrom: { whatsapp: ["+1222"] },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
channels: { whatsapp: { allowFrom: ["+1222"] } },
|
||||||
|
session: { store: path.join(home, "sessions.json") },
|
||||||
|
} as const;
|
||||||
|
}
|
||||||
|
|||||||
+2
-23
@@ -4,6 +4,7 @@ import { describe, expect, it } from "vitest";
|
|||||||
import { loadSessionStore } from "../config/sessions.js";
|
import { loadSessionStore } from "../config/sessions.js";
|
||||||
import {
|
import {
|
||||||
installDirectiveBehaviorE2EHooks,
|
installDirectiveBehaviorE2EHooks,
|
||||||
|
makeRestrictedElevatedDisabledConfig,
|
||||||
runEmbeddedPiAgent,
|
runEmbeddedPiAgent,
|
||||||
withTempHome,
|
withTempHome,
|
||||||
} from "./reply.directive.directive-behavior.e2e-harness.js";
|
} from "./reply.directive.directive-behavior.e2e-harness.js";
|
||||||
@@ -68,29 +69,7 @@ describe("directive behavior", () => {
|
|||||||
CommandAuthorized: true,
|
CommandAuthorized: true,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
{
|
makeRestrictedElevatedDisabledConfig(home),
|
||||||
agents: {
|
|
||||||
defaults: {
|
|
||||||
model: "anthropic/claude-opus-4-5",
|
|
||||||
workspace: path.join(home, "openclaw"),
|
|
||||||
},
|
|
||||||
list: [
|
|
||||||
{
|
|
||||||
id: "restricted",
|
|
||||||
tools: {
|
|
||||||
elevated: { enabled: false },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
tools: {
|
|
||||||
elevated: {
|
|
||||||
allowFrom: { whatsapp: ["+1222"] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
channels: { whatsapp: { allowFrom: ["+1222"] } },
|
|
||||||
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;
|
||||||
|
|||||||
+2
-23
@@ -4,6 +4,7 @@ import { describe, expect, it } from "vitest";
|
|||||||
import { loadSessionStore } from "../config/sessions.js";
|
import { loadSessionStore } from "../config/sessions.js";
|
||||||
import {
|
import {
|
||||||
installDirectiveBehaviorE2EHooks,
|
installDirectiveBehaviorE2EHooks,
|
||||||
|
makeRestrictedElevatedDisabledConfig,
|
||||||
runEmbeddedPiAgent,
|
runEmbeddedPiAgent,
|
||||||
withTempHome,
|
withTempHome,
|
||||||
} from "./reply.directive.directive-behavior.e2e-harness.js";
|
} from "./reply.directive.directive-behavior.e2e-harness.js";
|
||||||
@@ -159,29 +160,7 @@ describe("directive behavior", () => {
|
|||||||
CommandAuthorized: true,
|
CommandAuthorized: true,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
{
|
makeRestrictedElevatedDisabledConfig(home),
|
||||||
agents: {
|
|
||||||
defaults: {
|
|
||||||
model: "anthropic/claude-opus-4-5",
|
|
||||||
workspace: path.join(home, "openclaw"),
|
|
||||||
},
|
|
||||||
list: [
|
|
||||||
{
|
|
||||||
id: "restricted",
|
|
||||||
tools: {
|
|
||||||
elevated: { enabled: false },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
tools: {
|
|
||||||
elevated: {
|
|
||||||
allowFrom: { whatsapp: ["+1222"] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
channels: { whatsapp: { allowFrom: ["+1222"] } },
|
|
||||||
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