MCPcopy Create free account
hub / github.com/FIND-Lab/AgentWard / SessionState

Class SessionState

core/state.ts:17–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15};
16
17export class SessionState {
18 block_tool_call: boolean;
19 block_persistence: boolean;
20 cover_response_by_warning: boolean;
21 temp_block_tool_call: boolean;
22 warning_queue: Warning[];
23 warning_head: number;
24 blockedToolCalls: Set<string>;
25
26 historyMessages?: unknown[];
27 currentMessages?: unknown[];
28 systemPrompt?: string;
29 decisionAlignmentInfo: string[];
30
31 channelId?: string;
32 targetId?: string;
33
34 llmContext?: LlmCallContext;
35
36 defaultModelRef?: string;
37
38 clear_tags() {
39 this.block_tool_call = false;
40 this.block_persistence = false;
41 this.cover_response_by_warning = false;
42 this.temp_block_tool_call = false;
43 this.warning_queue = [];
44 this.warning_head = 0;
45 this.blockedToolCalls = new Set();
46 }
47
48 constructor(api: OpenClawPluginApi,event, ctx ) {
49 this.clear_tags();
50
51 this.historyMessages = event?.messages;
52 this.currentMessages = [];
53 this.decisionAlignmentInfo = [];
54
55 const messageProvider = ctx?.messageProvider;
56 if (messageProvider?.toLowerCase() == "feishu") {
57 this.channelId = 'feishu';
58 this.targetId = ctx.sessionKey.split(":").pop();
59 } else if (messageProvider?.toLowerCase() == "qqbot") {
60 this.channelId = 'qqbot';
61 this.targetId = ctx.sessionKey.split(":").pop();
62 }
63 }
64
65 private static readString(value: unknown): string {
66 return typeof value === "string" ? value.trim() : "";
67 }
68
69 private trySetLLMContextFromPluginConfig(api: OpenClawPluginApi): boolean {
70 const pluginConfig = api.pluginConfig as Record<string, unknown> | undefined;
71 const llm = (pluginConfig?.llm ?? null) as Record<string, unknown> | null;
72 if (!llm || typeof llm !== "object") return false;
73
74 const provider = SessionState.readString(llm.provider);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected