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

Function isValidConfigPath

core/commands.ts:67–79  ·  view source on GitHub ↗

Check if a config path is allowed to be modified at runtime.

(config: Record<string, unknown>, path: string)

Source from the content-addressed store, hash-verified

65
66/** Check if a config path is allowed to be modified at runtime. */
67function isValidConfigPath(config: Record<string, unknown>, path: string): boolean {
68 if (!(path.startsWith("layers.") || path.startsWith("notifications."))) return false;
69
70 const parts = path.split(".");
71 let current: unknown = config;
72 for (let i = 0; i < parts.length; i++) {
73 if (current === null || typeof current !== "object") return false;
74 if (!(parts[i] in current)) return false;
75 current = (current as Record<string, unknown>)[parts[i]];
76 }
77 // Must be a leaf value, not an intermediate object that would wipe children.
78 return current === null || typeof current !== "object";
79}
80
81/** Format the entire config as a readable tree (leaf values only). */
82function formatConfigTree(config: PluginConfig): string {

Callers 2

formatConfigTreeFunction · 0.85
handleAgentWardCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected