MCPcopy
hub / github.com/TanStack/ai / findSecretParams

Function findSecretParams

packages/ai-code-mode/src/validate-bindings.ts:92–137  ·  view source on GitHub ↗
(
  schema: JsonSchemaLike | undefined,
  root: JsonSchemaLike,
  seen: Set<object>,
  path: Array<string>,
  found: Array<{ path: Array<string>; name: string }>,
)

Source from the content-addressed store, hash-verified

90}
91
92function findSecretParams(
93 schema: JsonSchemaLike | undefined,
94 root: JsonSchemaLike,
95 seen: Set<object>,
96 path: Array<string>,
97 found: Array<{ path: Array<string>; name: string }>,
98): void {
99 if (!schema || typeof schema !== 'object' || seen.has(schema)) return
100 seen.add(schema)
101
102 if (schema.properties && typeof schema.properties === 'object') {
103 for (const [paramName, sub] of Object.entries(schema.properties)) {
104 if (looksLikeSecret(paramName)) {
105 found.push({ path: [...path, paramName], name: paramName })
106 }
107 findSecretParams(sub, root, seen, [...path, paramName], found)
108 }
109 }
110
111 if (Array.isArray(schema.items)) {
112 schema.items.forEach((s, i) =>
113 findSecretParams(s, root, seen, [...path, `[${i}]`], found),
114 )
115 } else if (schema.items && typeof schema.items === 'object') {
116 findSecretParams(schema.items, root, seen, [...path, '[]'], found)
117 }
118
119 if (
120 schema.additionalProperties &&
121 typeof schema.additionalProperties === 'object'
122 ) {
123 findSecretParams(schema.additionalProperties, root, seen, path, found)
124 }
125
126 for (const key of ['anyOf', 'oneOf', 'allOf'] as const) {
127 const arr = schema[key]
128 if (Array.isArray(arr)) {
129 arr.forEach((s) => findSecretParams(s, root, seen, path, found))
130 }
131 }
132
133 if (typeof schema.$ref === 'string') {
134 const target = resolveRef(schema.$ref, root)
135 if (target) findSecretParams(target, root, seen, path, found)
136 }
137}
138
139function buildMessage(toolName: string, paramPath: Array<string>): string {
140 return (

Callers 1

Calls 4

looksLikeSecretFunction · 0.85
resolveRefFunction · 0.85
hasMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected