feat(features): add claude-code-agent-loader, mcp-loader, session-state

This commit is contained in:
YeonGyu-Kim
2025-12-09 16:27:46 +09:00
parent c7a65af475
commit 376bf363af
13 changed files with 488 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
export function expandEnvVars(value: string): string {
return value.replace(
/\$\{([^}:]+)(?::-([^}]*))?\}/g,
(_, varName: string, defaultValue?: string) => {
const envValue = process.env[varName]
if (envValue !== undefined) return envValue
if (defaultValue !== undefined) return defaultValue
return ""
}
)
}
export function expandEnvVarsInObject<T>(obj: T): T {
if (obj === null || obj === undefined) return obj
if (typeof obj === "string") return expandEnvVars(obj) as T
if (Array.isArray(obj)) {
return obj.map((item) => expandEnvVarsInObject(item)) as T
}
if (typeof obj === "object") {
const result: Record<string, unknown> = {}
for (const [key, value] of Object.entries(obj)) {
result[key] = expandEnvVarsInObject(value)
}
return result as T
}
return obj
}