MCPcopy Index your code
hub / github.com/simstudioai/sim / normalizeCopilotFileParams

Function normalizeCopilotFileParams

apps/sim/tools/index.ts:141–176  ·  view source on GitHub ↗
(
  tool: ToolConfig,
  params: Record<string, unknown>,
  scope: ToolExecutionScope
)

Source from the content-addressed store, hash-verified

139}
140
141async function normalizeCopilotFileParams(
142 tool: ToolConfig,
143 params: Record<string, unknown>,
144 scope: ToolExecutionScope
145): Promise<void> {
146 if (!scope.copilotToolExecution) {
147 return
148 }
149
150 for (const [paramId, paramDef] of Object.entries(tool.params || {})) {
151 const paramType = paramDef?.type
152 const currentValue = params[paramId]
153 if (currentValue === undefined || currentValue === null) {
154 continue
155 }
156
157 if (paramType === 'file') {
158 if (!scope.workspaceId) {
159 throw new Error(`Missing workspaceId while resolving file parameter "${paramId}"`)
160 }
161 params[paramId] = await resolveCopilotFileReference(currentValue, scope.workspaceId, paramId)
162 continue
163 }
164
165 if (paramType === 'file[]') {
166 if (!scope.workspaceId) {
167 throw new Error(`Missing workspaceId while resolving file parameter "${paramId}"`)
168 }
169
170 const values = Array.isArray(currentValue) ? currentValue : [currentValue]
171 params[paramId] = await Promise.all(
172 values.map((item) => resolveCopilotFileReference(item, scope.workspaceId!, paramId))
173 )
174 }
175 }
176}
177
178function readExplicitCredentialSelector(params: Record<string, unknown>): string | undefined {
179 for (const key of ['credentialId', 'oauthCredential', 'credential'] as const) {

Callers 1

executeToolFunction · 0.85

Calls 1

Tested by

no test coverage detected