MCPcopy Index your code
hub / github.com/TanStack/ai / wrapCode

Function wrapCode

packages/ai-code-mode/src/code-wrapper.ts:9–24  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

7 * 3. Errors propagate correctly
8 */
9export function wrapCode(code: string): string {
10 // Results must be serialized to JSON because objects can't be transferred
11 // directly across the isolate boundary in isolated-vm
12 return `
13(async function() {
14 try {
15 const __userResult = await (async function() {
16${code}
17 })();
18 return JSON.stringify(__userResult);
19 } catch (__error) {
20 throw __error;
21 }
22})()
23`
24}

Callers 3

executeMethod · 0.90
executeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected