|
1 | 1 | // Qa Lab plugin module implements suite runtime flow behavior. |
2 | | -import { randomUUID } from "node:crypto"; |
| 2 | +import { createHash, randomUUID } from "node:crypto"; |
3 | 3 | import fs from "node:fs/promises"; |
4 | 4 | import path from "node:path"; |
5 | 5 | import { setTimeout as sleep } from "node:timers/promises"; |
6 | 6 | import { formatMemoryDreamingDay } from "openclaw/plugin-sdk/memory-core-host-status"; |
7 | 7 | import { resolveSessionTranscriptsDirForAgent } from "openclaw/plugin-sdk/memory-host-core"; |
8 | 8 | import { buildAgentSessionKey } from "openclaw/plugin-sdk/routing"; |
| 9 | +import { createPluginStateSyncKeyedStore } from "openclaw/plugin-sdk/runtime-doctor"; |
9 | 10 | import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime"; |
10 | 11 | import { |
11 | 12 | callQaBrowserRequest, |
@@ -85,6 +86,39 @@ type QaSuiteScenarioFlowEnv = {
|
85 | 86 | transport: QaSuiteRuntimeEnv["transport"] & QaScenarioRuntimeEnv["transport"]; |
86 | 87 | } & Omit<QaSuiteRuntimeEnv, "transport">; |
87 | 88 | |
| 89 | +function activeMemoryToggleKey(sessionKey: string) { |
| 90 | +return createHash("sha256").update(sessionKey, "utf8").digest("hex"); |
| 91 | +} |
| 92 | + |
| 93 | +function setActiveMemorySessionDisabled( |
| 94 | +env: QaSuiteScenarioFlowEnv, |
| 95 | +sessionKey: string, |
| 96 | +disabled: boolean, |
| 97 | +) { |
| 98 | +const store = createPluginStateSyncKeyedStore<{ |
| 99 | +sessionKey: string; |
| 100 | +disabled: true; |
| 101 | +updatedAt: number; |
| 102 | +}>("active-memory", { |
| 103 | +namespace: "session-toggles", |
| 104 | +maxEntries: 10_000, |
| 105 | +env: { |
| 106 | + ...process.env, |
| 107 | +OPENCLAW_STATE_DIR: path.join(env.gateway.tempRoot, "state"), |
| 108 | +}, |
| 109 | +}); |
| 110 | +const key = activeMemoryToggleKey(sessionKey); |
| 111 | +if (disabled) { |
| 112 | +store.register(key, { |
| 113 | + sessionKey, |
| 114 | +disabled: true, |
| 115 | +updatedAt: Date.now(), |
| 116 | +}); |
| 117 | +return; |
| 118 | +} |
| 119 | +store.delete(key); |
| 120 | +} |
| 121 | + |
88 | 122 | type QaSuiteStep = { |
89 | 123 | name: string; |
90 | 124 | run: () => Promise<string | void>; |
@@ -204,6 +238,8 @@ function createQaSuiteScenarioDeps(params: QaSuiteScenarioDepsParams) {
|
204 | 238 | extractQaToolPayload, |
205 | 239 | formatMemoryDreamingDay, |
206 | 240 | resolveSessionTranscriptsDirForAgent, |
| 241 | + activeMemoryToggleKey, |
| 242 | + setActiveMemorySessionDisabled, |
207 | 243 | buildAgentSessionKey, |
208 | 244 | normalizeLowercaseStringOrEmpty, |
209 | 245 | formatErrorMessage: params.formatErrorMessage, |
|