mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 15:45:01 +00:00
refactor(test): dedupe fuzzy model directive config
This commit is contained in:
@@ -9,6 +9,33 @@ 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 makeMoonshotConfig(home: string, storePath: string) {
|
||||||
|
return {
|
||||||
|
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 },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
describe("directive behavior", () => {
|
describe("directive behavior", () => {
|
||||||
installDirectiveBehaviorE2EHooks();
|
installDirectiveBehaviorE2EHooks();
|
||||||
|
|
||||||
@@ -19,30 +46,7 @@ describe("directive behavior", () => {
|
|||||||
const res = await getReplyFromConfig(
|
const res = await getReplyFromConfig(
|
||||||
{ Body: "/model kimi", From: "+1222", To: "+1222", CommandAuthorized: true },
|
{ Body: "/model 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;
|
||||||
@@ -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