mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:41:37 +00:00
test(auto-reply): dedupe command spawn test harness
This commit is contained in:
@@ -1,46 +1,11 @@
|
|||||||
import type { OpenClawConfig } from "../../config/config.js";
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
import type { MsgContext } from "../templating.js";
|
import type { MsgContext } from "../templating.js";
|
||||||
import { buildCommandContext } from "./commands-context.js";
|
import { buildCommandTestParams as buildBaseCommandTestParams } from "./commands.test-harness.js";
|
||||||
import { parseInlineDirectives } from "./directive-handling.js";
|
|
||||||
|
|
||||||
export function buildCommandTestParams(
|
export function buildCommandTestParams(
|
||||||
commandBody: string,
|
commandBody: string,
|
||||||
cfg: OpenClawConfig,
|
cfg: OpenClawConfig,
|
||||||
ctxOverrides?: Partial<MsgContext>,
|
ctxOverrides?: Partial<MsgContext>,
|
||||||
) {
|
) {
|
||||||
const ctx = {
|
return buildBaseCommandTestParams(commandBody, cfg, ctxOverrides);
|
||||||
Body: commandBody,
|
|
||||||
CommandBody: commandBody,
|
|
||||||
CommandSource: "text",
|
|
||||||
CommandAuthorized: true,
|
|
||||||
Provider: "whatsapp",
|
|
||||||
Surface: "whatsapp",
|
|
||||||
...ctxOverrides,
|
|
||||||
} as MsgContext;
|
|
||||||
|
|
||||||
const command = buildCommandContext({
|
|
||||||
ctx,
|
|
||||||
cfg,
|
|
||||||
isGroup: false,
|
|
||||||
triggerBodyNormalized: commandBody.trim().toLowerCase(),
|
|
||||||
commandAuthorized: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
ctx,
|
|
||||||
cfg,
|
|
||||||
command,
|
|
||||||
directives: parseInlineDirectives(commandBody),
|
|
||||||
elevated: { enabled: true, allowed: true, failures: [] },
|
|
||||||
sessionKey: "agent:main:main",
|
|
||||||
workspaceDir: "/tmp",
|
|
||||||
defaultGroupActivation: () => "mention",
|
|
||||||
resolvedVerboseLevel: "off" as const,
|
|
||||||
resolvedReasoningLevel: "off" as const,
|
|
||||||
resolveDefaultThinkingLevel: async () => undefined,
|
|
||||||
provider: "whatsapp",
|
|
||||||
model: "test-model",
|
|
||||||
contextTokens: 0,
|
|
||||||
isGroup: false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user