MCPcopy Create free account
hub / github.com/cortexkit/magic-context / resolveConfigValue

Function resolveConfigValue

packages/plugin/src/plugin/rpc-handlers.ts:115–134  ·  view source on GitHub ↗
(
    cfg: Record<string, unknown> | undefined,
    key: string,
    modelKey: string | undefined,
    defaultValue: T,
)

Source from the content-addressed store, hash-verified

113}
114
115function resolveConfigValue<T>(
116 cfg: Record<string, unknown> | undefined,
117 key: string,
118 modelKey: string | undefined,
119 defaultValue: T,
120): T {
121 if (!cfg) return defaultValue;
122 const val = cfg[key];
123 if (typeof val === typeof defaultValue) return val as T;
124 if (val && typeof val === "object") {
125 const obj = val as Record<string, T>;
126 if (modelKey && obj[modelKey] !== undefined) return obj[modelKey];
127 if (modelKey) {
128 const bare = modelKey.split("/").slice(1).join("/");
129 if (bare && obj[bare] !== undefined) return obj[bare];
130 }
131 if (obj.default !== undefined) return obj.default;
132 }
133 return defaultValue;
134}
135
136// Exported for test access. Production code reaches this via the
137// "sidebar-snapshot" RPC handler registered below.

Callers 1

buildStatusDetailFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected