mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 13:51:41 +00:00
refactor(test): dedupe fuzzy model directive config
This commit is contained in:
@@ -9,17 +9,8 @@ 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";
|
||||||
|
|
||||||
describe("directive behavior", () => {
|
function makeMoonshotConfig(home: string, storePath: string) {
|
||||||
installDirectiveBehaviorE2EHooks();
|
return {
|
||||||
|
|
||||||
it("supports fuzzy model matches on /model directive", async () => {
|
|
||||||
await withTempHome(async (home) => {
|
|
||||||
const storePath = path.join(home, "sessions.json");
|
|
||||||
|
|
||||||
const res = await getReplyFromConfig(
|
|
||||||
{ Body: "/model kimi", From: "+1222", To: "+1222", CommandAuthorized: true },
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
agents: {
|
agents: {
|
||||||
defaults: {
|
defaults: {
|
||||||
model: { primary: "anthropic/claude-opus-4-5" },
|
model: { primary: "anthropic/claude-opus-4-5" },
|
||||||
@@ -42,7 +33,20 @@ describe("directive behavior", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
session: { store: storePath },
|
session: { store: storePath },
|
||||||
},
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("directive behavior", () => {
|
||||||
|
installDirectiveBehaviorE2EHooks();
|
||||||
|
|
||||||
|
it("supports fuzzy model matches on /model directive", async () => {
|
||||||
|
await withTempHome(async (home) => {
|
||||||
|
const storePath = path.join(home, "sessions.json");
|
||||||
|
|
||||||
|
const res = await getReplyFromConfig(
|
||||||
|
{ Body: "/model kimi", From: "+1222", To: "+1222", CommandAuthorized: true },
|
||||||
|
{},
|
||||||
|
makeMoonshotConfig(home, storePath),
|
||||||
);
|
);
|
||||||
|
|
||||||
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
||||||
@@ -66,30 +70,7 @@ describe("directive behavior", () => {
|
|||||||
CommandAuthorized: true,
|
CommandAuthorized: true,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
{
|
makeMoonshotConfig(home, storePath),
|
||||||
agents: {
|
|
||||||
defaults: {
|
|
||||||
model: { primary: "anthropic/claude-opus-4-5" },
|
|
||||||
workspace: path.join(home, "openclaw"),
|
|
||||||
models: {
|
|
||||||
"anthropic/claude-opus-4-5": {},
|
|
||||||
"moonshot/kimi-k2-0905-preview": {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
models: {
|
|
||||||
mode: "merge",
|
|
||||||
providers: {
|
|
||||||
moonshot: {
|
|
||||||
baseUrl: "https://api.moonshot.ai/v1",
|
|
||||||
apiKey: "sk-test",
|
|
||||||
api: "openai-completions",
|
|
||||||
models: [{ id: "kimi-k2-0905-preview", name: "Kimi K2" }],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
session: { store: storePath },
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
||||||
@@ -108,30 +89,7 @@ describe("directive behavior", () => {
|
|||||||
const res = await getReplyFromConfig(
|
const res = await getReplyFromConfig(
|
||||||
{ Body: "/model moonshot/kimi", From: "+1222", To: "+1222", CommandAuthorized: true },
|
{ Body: "/model moonshot/kimi", From: "+1222", To: "+1222", CommandAuthorized: true },
|
||||||
{},
|
{},
|
||||||
{
|
makeMoonshotConfig(home, storePath),
|
||||||
agents: {
|
|
||||||
defaults: {
|
|
||||||
model: { primary: "anthropic/claude-opus-4-5" },
|
|
||||||
workspace: path.join(home, "openclaw"),
|
|
||||||
models: {
|
|
||||||
"anthropic/claude-opus-4-5": {},
|
|
||||||
"moonshot/kimi-k2-0905-preview": {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
models: {
|
|
||||||
mode: "merge",
|
|
||||||
providers: {
|
|
||||||
moonshot: {
|
|
||||||
baseUrl: "https://api.moonshot.ai/v1",
|
|
||||||
apiKey: "sk-test",
|
|
||||||
api: "openai-completions",
|
|
||||||
models: [{ id: "kimi-k2-0905-preview", name: "Kimi K2" }],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
session: { store: storePath },
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
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