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

Function stripInternalFields

apps/sim/tools/index.ts:618–629  ·  view source on GitHub ↗

* Strips internal fields (keys starting with `__`) from tool output before * returning to users. The double-underscore prefix is reserved for transient * data (e.g. `__costDollars`) and will never collide with legitimate API * fields like `_id`.

(output: Record<string, unknown>)

Source from the content-addressed store, hash-verified

616 * fields like `_id`.
617 */
618function stripInternalFields(output: Record<string, unknown>): Record<string, unknown> {
619 if (typeof output !== 'object' || output === null || Array.isArray(output)) {
620 return output
621 }
622 const result: Record<string, unknown> = {}
623 for (const [key, value] of Object.entries(output)) {
624 if (!key.startsWith('__')) {
625 result[key] = value
626 }
627 }
628 return result
629}
630
631export function postProcessToolOutput(toolId: string, output: Record<string, unknown>) {
632 return isCustomTool(toolId) ? output : stripInternalFields(output)

Callers 1

postProcessToolOutputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected