diff --git a/src/secrets/path-utils.test.ts b/src/secrets/path-utils.test.ts index 5c40fe2d9a8..40f4bed1b42 100644 --- a/src/secrets/path-utils.test.ts +++ b/src/secrets/path-utils.test.ts @@ -76,4 +76,15 @@ describe("secrets path utils", () => { expect(changed).toBe(false); expect(getPath(config, ["talk", "apiKey"])).toBe("same"); }); + + it("setPathCreateStrict works on nested config sub-objects", () => { + const pluginConfig: Record = {}; + const changed = setPathCreateStrict(pluginConfig, ["webSearch", "mode"], "llm-context"); + expect(changed).toBe(true); + expect(pluginConfig).toEqual({ + webSearch: { + mode: "llm-context", + }, + }); + }); }); diff --git a/src/secrets/path-utils.ts b/src/secrets/path-utils.ts index b04066560c8..9560302f930 100644 --- a/src/secrets/path-utils.ts +++ b/src/secrets/path-utils.ts @@ -1,5 +1,4 @@ import { isDeepStrictEqual } from "node:util"; -import type { OpenClawConfig } from "../config/config.js"; import { isRecord } from "./shared.js"; function isArrayIndexSegment(segment: string): boolean { @@ -89,7 +88,7 @@ export function getPath(root: unknown, segments: string[]): unknown { } export function setPathCreateStrict( - root: OpenClawConfig, + root: Record, segments: string[], value: unknown, ): boolean { @@ -153,7 +152,7 @@ export function setPathCreateStrict( } export function setPathExistingStrict( - root: OpenClawConfig, + root: Record, segments: string[], value: unknown, ): boolean { @@ -184,7 +183,7 @@ export function setPathExistingStrict( return false; } -export function deletePathStrict(root: OpenClawConfig, segments: string[]): boolean { +export function deletePathStrict(root: Record, segments: string[]): boolean { const cursor = traverseToLeafParent({ root, segments, requireExistingSegment: false }); const leaf = segments[segments.length - 1] ?? "";