MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / evaluate

Function evaluate

packages/kernel/runtime-quickjs/src/sealed-bundle.ts:87–100  ·  view source on GitHub ↗
(context: QuickJSContext, source: string, filename: string)

Source from the content-addressed store, hash-verified

85/** Evaluate one chunk, converting QuickJS's error handle into a thrown Error
86 * whose message is the sandbox's own. */
87const evaluate = (context: QuickJSContext, source: string, filename: string): void => {
88 const result = context.evalCode(source, filename);
89 if (result.error) {
90 const dumped: unknown = context.dump(result.error);
91 result.error.dispose();
92 // oxlint-disable-next-line executor/no-try-catch-or-throw, executor/no-error-constructor -- boundary: QuickJS reports failure as a handle; this is where it becomes a JS error
93 throw new Error(
94 typeof dumped === "object" && dumped !== null && "message" in dumped
95 ? String((dumped as { message: unknown }).message)
96 : String(dumped),
97 );
98 }
99 result.value.dispose();
100};
101
102const runSealedBundle = async (
103 options: SealedBundleOptions,

Callers 1

runSealedBundleFunction · 0.70

Calls 1

disposeMethod · 0.80

Tested by

no test coverage detected