zlacker

[parent] [thread] 5 comments
1. mavdol+(OP)[view] [source] 2026-02-03 16:41:04
Thanks! Got it, I will add more examples for that. Currently you can do both: run dynamically untrusted code with eval, or run fully encapsulated logic (like in the existing examples).

I made a small example that might give you a better idea (it's not eval, but shows how to isolate a specific data processing task): https://github.com/mavdol/capsule/tree/main/examples/javascr...

And yes, you are spot on regarding LeetCode platforms. The resource limits are also designed for that kind of usage.

replies(2): >>zachri+Ka >>fix4fu+bh1
2. zachri+Ka[view] [source] 2026-02-03 17:26:51
>>mavdol+(OP)
Would like to see the eval version - the dialogue version just seems like normal code with extra steps?
replies(1): >>mavdol+Fg
◧◩
3. mavdol+Fg[view] [source] [discussion] 2026-02-03 17:49:21
>>zachri+Ka
yeah, the previous example was quite basic. I will write a complete example for that, but here is how you can run dynamic code:

   import { task } from "@capsule-run/sdk";

   export default task({
     name: "main",
     compute: "HIGH",
   }, async () => {
     const untrustedCode = "const x = 10; x * 2 + 5;";
     const result = eval(untrustedCode);
     return result;
   });
Hope that helps!
replies(1): >>zachri+TK6
4. fix4fu+bh1[view] [source] 2026-02-03 22:26:06
>>mavdol+(OP)
yep, more examples with agents use will be helpful
◧◩◪
5. zachri+TK6[view] [source] [discussion] 2026-02-05 13:16:05
>>mavdol+Fg
Is the code in the eval also turned into wasm first then? Does this work as a JIT for wasm?
replies(1): >>mavdol+SL8
◧◩◪◨
6. mavdol+SL8[view] [source] [discussion] 2026-02-05 23:40:26
>>zachri+TK6
It actually works a bit differently. The eval is executed by the interpreter running inside the isolated wasm sandbox (StarlingMonkey). You can think of it as each sandbox having its own dedicated JavaScript engine.
[go to top]