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

Function setConfigAtPath

core/commands.ts:37–47  ·  view source on GitHub ↗

Set a value in a nested object by dot-path (mutates).

(obj: Record<string, unknown>, path: string, value: unknown)

Source from the content-addressed store, hash-verified

35
36/** Set a value in a nested object by dot-path (mutates). */
37function setConfigAtPath(obj: Record<string, unknown>, path: string, value: unknown): boolean {
38 const parts = path.split(".");
39 let current: unknown = obj;
40 for (let i = 0; i < parts.length - 1; i++) {
41 if (current === null || typeof current !== "object") return false;
42 current = (current as Record<string, unknown>)[parts[i]];
43 }
44 if (current === null || typeof current !== "object") return false;
45 (current as Record<string, unknown>)[parts[parts.length - 1]] = value;
46 return true;
47}
48
49/** Parse a raw string value into the appropriate type. */
50function parseValue(raw: string): unknown {

Callers 1

handleAgentWardCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected