惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
B
Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
博客园_首页
C
Check Point Blog
博客园 - 【当耐特】
美团技术团队
Last Week in AI
Last Week in AI
A
About on SuperTechFans
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
M
MIT News - Artificial intelligence
Martin Fowler
Martin Fowler
J
Java Code Geeks
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
Google Developers Blog
F
Fortinet All Blogs

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
chore(deadcode): drop memory dreaming registration shim ·...
vincentkoc · 2026-06-20 · via Recent Commits to openclaw:main
11

// Memory Core tests cover dreaming command plugin behavior.

22

import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";

3-

import type {

4-

OpenClawPluginCommandDefinition,

5-

PluginCommandContext,

6-

} from "openclaw/plugin-sdk/core";

3+

import type { PluginCommandContext } from "openclaw/plugin-sdk/core";

74

import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";

85

import { describe, expect, it, vi } from "vitest";

9-

import { registerDreamingCommand } from "./dreaming-command.js";

6+

import { handleDreamingCommand } from "./dreaming-command.js";

107118

function asRecord(value: unknown): Record<string, unknown> | null {

129

if (!value || typeof value !== "object" || Array.isArray(value)) {

@@ -22,7 +19,6 @@ function resolveStoredDreaming(config: OpenClawConfig): Record<string, unknown>

2219

}

23202421

function createHarness(initialConfig: OpenClawConfig = {}) {

25-

const registered: { command?: OpenClawPluginCommandDefinition } = {};

2622

let runtimeConfig: OpenClawConfig = initialConfig;

27232824

const runtime = {

@@ -55,19 +51,10 @@ function createHarness(initialConfig: OpenClawConfig = {}) {

55515652

const api = {

5753

runtime,

58-

registerCommand: vi.fn((definition: OpenClawPluginCommandDefinition) => {

59-

registered.command = definition;

60-

}),

6154

} as unknown as OpenClawPluginApi;

625563-

registerDreamingCommand(api);

64-65-

if (!registered.command) {

66-

throw new Error("memory-core did not register /dreaming");

67-

}

68-6956

return {

70-

command: registered.command,

57+

api,

7158

runtime,

7259

getRuntimeConfig: () => runtimeConfig,

7360

};

@@ -90,17 +77,18 @@ function createCommandContext(

9077

};

9178

}

927993-

describe("memory-core /dreaming command", () => {

94-

it("registers with an enable/disable description", () => {

95-

const { command } = createHarness();

96-

expect(command.name).toBe("dreaming");

97-

expect(command.acceptsArgs).toBe(true);

98-

expect(command.description).toContain("Enable or disable");

99-

});

80+

async function runDreamingCommand(

81+

harness: ReturnType<typeof createHarness>,

82+

args?: string,

83+

overrides?: Partial<Pick<PluginCommandContext, "gatewayClientScopes">>,

84+

) {

85+

return await handleDreamingCommand(harness.api, createCommandContext(args, overrides));

86+

}

1008788+

describe("memory-core /dreaming command", () => {

10189

it("shows phase explanations when invoked without args", async () => {

102-

const { command } = createHarness();

103-

const result = await command.handler(createCommandContext());

90+

const harness = createHarness();

91+

const result = await runDreamingCommand(harness);

1049210593

expect(result.text).toContain("Usage: /dreaming status");

10694

expect(result.text).toContain("Dreaming status:");

@@ -111,7 +99,7 @@ describe("memory-core /dreaming command", () => {

11199

});

112100113101

it("persists global enablement under plugins.entries.memory-core.config.dreaming.enabled", async () => {

114-

const { command, runtime, getRuntimeConfig } = createHarness({

102+

const harness = createHarness({

115103

plugins: {

116104

entries: {

117105

"memory-core": {

@@ -130,57 +118,51 @@ describe("memory-core /dreaming command", () => {

130118

},

131119

});

132120133-

const result = await command.handler(createCommandContext("off"));

121+

const result = await runDreamingCommand(harness, "off");

134122135-

expect(runtime.config.mutateConfigFile).toHaveBeenCalledTimes(1);

136-

const storedDreaming = resolveStoredDreaming(getRuntimeConfig());

123+

expect(harness.runtime.config.mutateConfigFile).toHaveBeenCalledTimes(1);

124+

const storedDreaming = resolveStoredDreaming(harness.getRuntimeConfig());

137125

expect(storedDreaming.enabled).toBe(false);

138126

expect(storedDreaming.frequency).toBe("0 */6 * * *");

139127

expect(result.text).toContain("Dreaming disabled.");

140128

});

141129142130

it("blocks unscoped gateway callers from persisting dreaming config", async () => {

143-

const { command, runtime } = createHarness();

131+

const harness = createHarness();

144132145-

const result = await command.handler(

146-

createCommandContext("off", {

147-

gatewayClientScopes: [],

148-

}),

149-

);

133+

const result = await runDreamingCommand(harness, "off", {

134+

gatewayClientScopes: [],

135+

});

150136151137

expect(result.text).toContain("requires operator.admin");

152-

expect(runtime.config.mutateConfigFile).not.toHaveBeenCalled();

138+

expect(harness.runtime.config.mutateConfigFile).not.toHaveBeenCalled();

153139

});

154140155141

it("blocks write-scoped gateway callers from persisting dreaming config", async () => {

156-

const { command, runtime } = createHarness();

142+

const harness = createHarness();

157143158-

const result = await command.handler(

159-

createCommandContext("off", {

160-

gatewayClientScopes: ["operator.write"],

161-

}),

162-

);

144+

const result = await runDreamingCommand(harness, "off", {

145+

gatewayClientScopes: ["operator.write"],

146+

});

163147164148

expect(result.text).toContain("requires operator.admin");

165-

expect(runtime.config.mutateConfigFile).not.toHaveBeenCalled();

149+

expect(harness.runtime.config.mutateConfigFile).not.toHaveBeenCalled();

166150

});

167151168152

it("allows admin-scoped gateway callers to persist dreaming config", async () => {

169-

const { command, runtime, getRuntimeConfig } = createHarness();

153+

const harness = createHarness();

170154171-

const result = await command.handler(

172-

createCommandContext("on", {

173-

gatewayClientScopes: ["operator.admin"],

174-

}),

175-

);

155+

const result = await runDreamingCommand(harness, "on", {

156+

gatewayClientScopes: ["operator.admin"],

157+

});

176158177-

expect(runtime.config.mutateConfigFile).toHaveBeenCalledTimes(1);

178-

expect(resolveStoredDreaming(getRuntimeConfig()).enabled).toBe(true);

159+

expect(harness.runtime.config.mutateConfigFile).toHaveBeenCalledTimes(1);

160+

expect(resolveStoredDreaming(harness.getRuntimeConfig()).enabled).toBe(true);

179161

expect(result.text).toContain("Dreaming enabled.");

180162

});

181163182164

it("returns status without mutating config", async () => {

183-

const { command, runtime } = createHarness({

165+

const harness = createHarness({

184166

plugins: {

185167

entries: {

186168

"memory-core": {

@@ -199,20 +181,20 @@ describe("memory-core /dreaming command", () => {

199181

},

200182

});

201183202-

const result = await command.handler(createCommandContext("status"));

184+

const result = await runDreamingCommand(harness, "status");

203185204186

expect(result.text).toContain("Dreaming status:");

205187

expect(result.text).toContain("- enabled: off (America/Los_Angeles)");

206188

expect(result.text).toContain("- sweep cadence: 15 */8 * * *");

207189

expect(result.text).toContain("- promotion policy: score>=0.8, recalls>=3, uniqueQueries>=3");

208-

expect(runtime.config.mutateConfigFile).not.toHaveBeenCalled();

190+

expect(harness.runtime.config.mutateConfigFile).not.toHaveBeenCalled();

209191

});

210192211193

it("shows usage for invalid args and does not mutate config", async () => {

212-

const { command, runtime } = createHarness();

213-

const result = await command.handler(createCommandContext("unknown-mode"));

194+

const harness = createHarness();

195+

const result = await runDreamingCommand(harness, "unknown-mode");

214196215197

expect(result.text).toContain("Usage: /dreaming status");

216-

expect(runtime.config.mutateConfigFile).not.toHaveBeenCalled();

198+

expect(harness.runtime.config.mutateConfigFile).not.toHaveBeenCalled();

217199

});

218200

});