( options: QuickJsExecutorOptions, code: string, toolInvoker: SandboxToolInvoker, )
| 475 | }; |
| 476 | |
| 477 | const runInQuickJs = ( |
| 478 | options: QuickJsExecutorOptions, |
| 479 | code: string, |
| 480 | toolInvoker: SandboxToolInvoker, |
| 481 | ): Effect.Effect<ExecuteResult, QuickJsExecutionError> => |
| 482 | Effect.gen(function* () { |
| 483 | const context = yield* Effect.context<never>(); |
| 484 | const runPromise = Effect.runPromiseWith(context); |
| 485 | return yield* Effect.tryPromise({ |
| 486 | try: () => evaluateInQuickJs(options, code, toolInvoker, runPromise), |
| 487 | catch: (cause) => new QuickJsExecutionError({ message: String(cause) }), |
| 488 | }); |
| 489 | }).pipe( |
| 490 | Effect.withSpan("executor.code.exec.quickjs", { |
| 491 | attributes: { "executor.runtime": "quickjs" }, |
| 492 | }), |
| 493 | ); |
| 494 | |
| 495 | export const makeQuickJsExecutor = ( |
| 496 | options: QuickJsExecutorOptions = {}, |
no test coverage detected