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

Function getOutputFileDeclarations

apps/sim/lib/copilot/request/tools/files.ts:154–199  ·  view source on GitHub ↗
(
  params: Record<string, unknown> | undefined
)

Source from the content-addressed store, hash-verified

152}
153
154export function getOutputFileDeclarations(
155 params: Record<string, unknown> | undefined
156): OutputFileDeclaration[] {
157 const args = params?.args as Record<string, unknown> | undefined
158 const outputs =
159 (params?.outputs as { files?: unknown[] } | undefined) ??
160 (args?.outputs as { files?: unknown[] } | undefined)
161
162 if (Array.isArray(outputs?.files)) {
163 return outputs.files.flatMap((item): OutputFileDeclaration[] => {
164 if (!item || typeof item !== 'object') return []
165 const file = item as Record<string, unknown>
166 if (typeof file.path !== 'string') return []
167 return [
168 {
169 path: file.path,
170 mode: file.mode === 'overwrite' ? 'overwrite' : 'create',
171 format: typeof file.format === 'string' ? (file.format as OutputFormat) : undefined,
172 mimeType: typeof file.mimeType === 'string' ? file.mimeType : undefined,
173 sandboxPath: typeof file.sandboxPath === 'string' ? file.sandboxPath : undefined,
174 },
175 ]
176 })
177 }
178
179 const outputPath =
180 (params?.outputPath as string | undefined) ?? (args?.outputPath as string | undefined)
181 if (!outputPath) return []
182 const overwriteFileId =
183 (params?.overwriteFileId as string | undefined) ?? (args?.overwriteFileId as string | undefined)
184 return [
185 {
186 path: overwriteFileId || outputPath,
187 mode: overwriteFileId ? 'overwrite' : 'create',
188 formatPath: outputPath,
189 format: ((params?.outputFormat as string | undefined) ??
190 (args?.outputFormat as string | undefined)) as OutputFormat | undefined,
191 mimeType:
192 (params?.outputMimeType as string | undefined) ??
193 (args?.outputMimeType as string | undefined),
194 sandboxPath:
195 (params?.outputSandboxPath as string | undefined) ??
196 (args?.outputSandboxPath as string | undefined),
197 },
198 ]
199}
200
201export async function maybeWriteOutputToFile(
202 toolName: string,

Callers 2

route.tsFile · 0.90
maybeWriteOutputToFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected