MCPcopy
hub / github.com/promptfoo/promptfoo / processConfigFileReferences

Function processConfigFileReferences

src/util/fileReference.ts:70–103  ·  view source on GitHub ↗
(
  config: any,
  basePath: string = '',
)

Source from the content-addressed store, hash-verified

68 * @returns A new configuration object with file references resolved
69 */
70export async function processConfigFileReferences(
71 config: any,
72 basePath: string = '',
73): Promise<any> {
74 if (config === null || config === undefined) {
75 return config;
76 }
77
78 // Handle string values with file:// protocol
79 if (typeof config === 'string' && config.startsWith('file://')) {
80 return await loadFileReference(config, basePath);
81 }
82
83 // Handle arrays
84 if (Array.isArray(config)) {
85 const result = [];
86 for (const item of config) {
87 result.push(await processConfigFileReferences(item, basePath));
88 }
89 return result;
90 }
91
92 // Handle objects
93 if (typeof config === 'object') {
94 const result: Record<string, any> = {};
95 for (const [key, value] of Object.entries(config)) {
96 result[key] = await processConfigFileReferences(value, basePath);
97 }
98 return result;
99 }
100
101 // Return primitive values as is
102 return config;
103}

Callers 4

basic.test.tsFile · 0.90
initializeMethod · 0.90
initializeMethod · 0.90

Calls 2

loadFileReferenceFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…