mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 09:41:23 +00:00
refactor(auto-reply): share directive handling params
This commit is contained in:
@@ -1,50 +1,12 @@
|
|||||||
import type { ModelAliasIndex } from "../../agents/model-selection.js";
|
|
||||||
import type { OpenClawConfig } from "../../config/config.js";
|
|
||||||
import type { SessionEntry } from "../../config/sessions.js";
|
|
||||||
import type { MsgContext } from "../templating.js";
|
|
||||||
import type { ReplyPayload } from "../types.js";
|
import type { ReplyPayload } from "../types.js";
|
||||||
import type { InlineDirectives } from "./directive-handling.parse.js";
|
import type { ApplyInlineDirectivesFastLaneParams } from "./directive-handling.params.js";
|
||||||
import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "./directives.js";
|
import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "./directives.js";
|
||||||
import { handleDirectiveOnly } from "./directive-handling.impl.js";
|
import { handleDirectiveOnly } from "./directive-handling.impl.js";
|
||||||
import { isDirectiveOnly } from "./directive-handling.parse.js";
|
import { isDirectiveOnly } from "./directive-handling.parse.js";
|
||||||
|
|
||||||
export async function applyInlineDirectivesFastLane(params: {
|
export async function applyInlineDirectivesFastLane(
|
||||||
directives: InlineDirectives;
|
params: ApplyInlineDirectivesFastLaneParams,
|
||||||
commandAuthorized: boolean;
|
): Promise<{ directiveAck?: ReplyPayload; provider: string; model: string }> {
|
||||||
ctx: MsgContext;
|
|
||||||
cfg: OpenClawConfig;
|
|
||||||
agentId?: string;
|
|
||||||
isGroup: boolean;
|
|
||||||
sessionEntry: SessionEntry;
|
|
||||||
sessionStore: Record<string, SessionEntry>;
|
|
||||||
sessionKey: string;
|
|
||||||
storePath?: string;
|
|
||||||
elevatedEnabled: boolean;
|
|
||||||
elevatedAllowed: boolean;
|
|
||||||
elevatedFailures?: Array<{ gate: string; key: string }>;
|
|
||||||
messageProviderKey?: string;
|
|
||||||
defaultProvider: string;
|
|
||||||
defaultModel: string;
|
|
||||||
aliasIndex: ModelAliasIndex;
|
|
||||||
allowedModelKeys: Set<string>;
|
|
||||||
allowedModelCatalog: Awaited<
|
|
||||||
ReturnType<typeof import("../../agents/model-catalog.js").loadModelCatalog>
|
|
||||||
>;
|
|
||||||
resetModelOverride: boolean;
|
|
||||||
provider: string;
|
|
||||||
model: string;
|
|
||||||
initialModelLabel: string;
|
|
||||||
formatModelSwitchEvent: (label: string, alias?: string) => string;
|
|
||||||
agentCfg?: NonNullable<OpenClawConfig["agents"]>["defaults"];
|
|
||||||
modelState: {
|
|
||||||
resolveDefaultThinkingLevel: () => Promise<ThinkLevel | undefined>;
|
|
||||||
allowedModelKeys: Set<string>;
|
|
||||||
allowedModelCatalog: Awaited<
|
|
||||||
ReturnType<typeof import("../../agents/model-catalog.js").loadModelCatalog>
|
|
||||||
>;
|
|
||||||
resetModelOverride: boolean;
|
|
||||||
};
|
|
||||||
}): Promise<{ directiveAck?: ReplyPayload; provider: string; model: string }> {
|
|
||||||
const {
|
const {
|
||||||
directives,
|
directives,
|
||||||
commandAuthorized,
|
commandAuthorized,
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import type { ModelAliasIndex } from "../../agents/model-selection.js";
|
|
||||||
import type { OpenClawConfig } from "../../config/config.js";
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
import type { ExecAsk, ExecHost, ExecSecurity } from "../../infra/exec-approvals.js";
|
import type { ExecAsk, ExecHost, ExecSecurity } from "../../infra/exec-approvals.js";
|
||||||
import type { ReplyPayload } from "../types.js";
|
import type { ReplyPayload } from "../types.js";
|
||||||
import type { InlineDirectives } from "./directive-handling.parse.js";
|
import type { HandleDirectiveOnlyParams } from "./directive-handling.params.js";
|
||||||
import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "./directives.js";
|
import type { ElevatedLevel, ReasoningLevel, ThinkLevel } from "./directives.js";
|
||||||
import {
|
import {
|
||||||
resolveAgentConfig,
|
resolveAgentConfig,
|
||||||
resolveAgentDir,
|
resolveAgentDir,
|
||||||
@@ -58,35 +57,9 @@ function resolveExecDefaults(params: {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function handleDirectiveOnly(params: {
|
export async function handleDirectiveOnly(
|
||||||
cfg: OpenClawConfig;
|
params: HandleDirectiveOnlyParams,
|
||||||
directives: InlineDirectives;
|
): Promise<ReplyPayload | undefined> {
|
||||||
sessionEntry: SessionEntry;
|
|
||||||
sessionStore: Record<string, SessionEntry>;
|
|
||||||
sessionKey: string;
|
|
||||||
storePath?: string;
|
|
||||||
elevatedEnabled: boolean;
|
|
||||||
elevatedAllowed: boolean;
|
|
||||||
elevatedFailures?: Array<{ gate: string; key: string }>;
|
|
||||||
messageProviderKey?: string;
|
|
||||||
defaultProvider: string;
|
|
||||||
defaultModel: string;
|
|
||||||
aliasIndex: ModelAliasIndex;
|
|
||||||
allowedModelKeys: Set<string>;
|
|
||||||
allowedModelCatalog: Awaited<
|
|
||||||
ReturnType<typeof import("../../agents/model-catalog.js").loadModelCatalog>
|
|
||||||
>;
|
|
||||||
resetModelOverride: boolean;
|
|
||||||
provider: string;
|
|
||||||
model: string;
|
|
||||||
initialModelLabel: string;
|
|
||||||
formatModelSwitchEvent: (label: string, alias?: string) => string;
|
|
||||||
currentThinkLevel?: ThinkLevel;
|
|
||||||
currentVerboseLevel?: VerboseLevel;
|
|
||||||
currentReasoningLevel?: ReasoningLevel;
|
|
||||||
currentElevatedLevel?: ElevatedLevel;
|
|
||||||
surface?: string;
|
|
||||||
}): Promise<ReplyPayload | undefined> {
|
|
||||||
const {
|
const {
|
||||||
directives,
|
directives,
|
||||||
sessionEntry,
|
sessionEntry,
|
||||||
|
|||||||
55
src/auto-reply/reply/directive-handling.params.ts
Normal file
55
src/auto-reply/reply/directive-handling.params.ts
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import type { ModelAliasIndex } from "../../agents/model-selection.js";
|
||||||
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
|
import type { SessionEntry } from "../../config/sessions.js";
|
||||||
|
import type { MsgContext } from "../templating.js";
|
||||||
|
import type { InlineDirectives } from "./directive-handling.parse.js";
|
||||||
|
import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "./directives.js";
|
||||||
|
|
||||||
|
export type HandleDirectiveOnlyCoreParams = {
|
||||||
|
cfg: OpenClawConfig;
|
||||||
|
directives: InlineDirectives;
|
||||||
|
sessionEntry: SessionEntry;
|
||||||
|
sessionStore: Record<string, SessionEntry>;
|
||||||
|
sessionKey: string;
|
||||||
|
storePath?: string;
|
||||||
|
elevatedEnabled: boolean;
|
||||||
|
elevatedAllowed: boolean;
|
||||||
|
elevatedFailures?: Array<{ gate: string; key: string }>;
|
||||||
|
messageProviderKey?: string;
|
||||||
|
defaultProvider: string;
|
||||||
|
defaultModel: string;
|
||||||
|
aliasIndex: ModelAliasIndex;
|
||||||
|
allowedModelKeys: Set<string>;
|
||||||
|
allowedModelCatalog: Awaited<
|
||||||
|
ReturnType<typeof import("../../agents/model-catalog.js").loadModelCatalog>
|
||||||
|
>;
|
||||||
|
resetModelOverride: boolean;
|
||||||
|
provider: string;
|
||||||
|
model: string;
|
||||||
|
initialModelLabel: string;
|
||||||
|
formatModelSwitchEvent: (label: string, alias?: string) => string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type HandleDirectiveOnlyParams = HandleDirectiveOnlyCoreParams & {
|
||||||
|
currentThinkLevel?: ThinkLevel;
|
||||||
|
currentVerboseLevel?: VerboseLevel;
|
||||||
|
currentReasoningLevel?: ReasoningLevel;
|
||||||
|
currentElevatedLevel?: ElevatedLevel;
|
||||||
|
surface?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ApplyInlineDirectivesFastLaneParams = HandleDirectiveOnlyCoreParams & {
|
||||||
|
commandAuthorized: boolean;
|
||||||
|
ctx: MsgContext;
|
||||||
|
agentId?: string;
|
||||||
|
isGroup: boolean;
|
||||||
|
agentCfg?: NonNullable<OpenClawConfig["agents"]>["defaults"];
|
||||||
|
modelState: {
|
||||||
|
resolveDefaultThinkingLevel: () => Promise<ThinkLevel | undefined>;
|
||||||
|
allowedModelKeys: Set<string>;
|
||||||
|
allowedModelCatalog: Awaited<
|
||||||
|
ReturnType<typeof import("../../agents/model-catalog.js").loadModelCatalog>
|
||||||
|
>;
|
||||||
|
resetModelOverride: boolean;
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user