






















@@ -187,16 +187,48 @@ describe("gateway tool", () => {
187187});
188188189189it("passes config.apply through gateway call", async () => {
190+vi.mocked(callGatewayTool).mockImplementation(async (method: string) => {
191+if (method === "config.get") {
192+return {
193+hash: "hash-1",
194+config: {
195+tools: {
196+exec: {
197+ask: "on-miss",
198+security: "allowlist",
199+},
200+},
201+},
202+};
203+}
204+if (method === "config.apply") {
205+return {
206+ok: true,
207+path: "/tmp/openclaw.json",
208+config: { agents: { defaults: { systemPromptOverride: "You are a terse assistant." } } },
209+restart: { ok: true, config: "nested field preserved" },
210+};
211+}
212+return { ok: true };
213+});
190214const sessionKey = "agent:main:whatsapp:dm:+15555550123";
191215const tool = requireGatewayTool(sessionKey);
192216193217const raw =
194218'{\n agents: { defaults: { systemPromptOverride: "You are a terse assistant." } },\n tools: { exec: { ask: "on-miss", security: "allowlist" } }\n}\n';
195-await tool.execute("call2", {
219+const result = await tool.execute("call2", {
196220action: "config.apply",
197221 raw,
198222});
199223224+expect(result.details).toEqual({
225+ok: true,
226+result: {
227+ok: true,
228+path: "/tmp/openclaw.json",
229+restart: { ok: true, config: "nested field preserved" },
230+},
231+});
200232expectConfigMutationCall({
201233callGatewayTool: vi.mocked(callGatewayTool),
202234action: "config.apply",
@@ -206,15 +238,47 @@ describe("gateway tool", () => {
206238});
207239208240it("passes config.patch through gateway call", async () => {
241+vi.mocked(callGatewayTool).mockImplementation(async (method: string) => {
242+if (method === "config.get") {
243+return {
244+hash: "hash-1",
245+config: {
246+tools: {
247+exec: {
248+ask: "on-miss",
249+security: "allowlist",
250+},
251+},
252+},
253+};
254+}
255+if (method === "config.patch") {
256+return {
257+ok: true,
258+noop: true,
259+path: "/tmp/openclaw.json",
260+config: { channels: { telegram: { groups: {} } } },
261+};
262+}
263+return { ok: true };
264+});
209265const sessionKey = "agent:main:whatsapp:dm:+15555550123";
210266const tool = requireGatewayTool(sessionKey);
211267212268const raw = '{\n channels: { telegram: { groups: { "*": { requireMention: false } } } }\n}\n';
213-await tool.execute("call4", {
269+const result = await tool.execute("call4", {
214270action: "config.patch",
215271 raw,
216272});
217273274+expect(result.details).toEqual({
275+ok: true,
276+result: {
277+ok: true,
278+noop: true,
279+path: "/tmp/openclaw.json",
280+},
281+});
218282expectConfigMutationCall({
219283callGatewayTool: vi.mocked(callGatewayTool),
220284action: "config.patch",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。