( options: QuickJsExecutorOptions, code: string, toolInvoker: SandboxToolInvoker, )
| 465 | }; |
| 466 | |
| 467 | const runInQuickJs = ( |
| 468 | options: QuickJsExecutorOptions, |
| 469 | code: string, |
| 470 | toolInvoker: SandboxToolInvoker, |
| 471 | ): Effect.Effect<ExecuteResult, QuickJsExecutionError> => |
| 472 | Effect.gen(function* () { |
| 473 | const context = yield* Effect.context<never>(); |
| 474 | const runPromise = Effect.runPromiseWith(context); |
| 475 | return yield* Effect.tryPromise({ |
| 476 | try: () => evaluateInQuickJs(options, code, toolInvoker, runPromise), |
| 477 | catch: (cause) => new QuickJsExecutionError({ message: String(cause) }), |
| 478 | }); |
| 479 | }).pipe( |
| 480 | Effect.withSpan("executor.code.exec.quickjs", { |
| 481 | attributes: { "executor.runtime": "quickjs" }, |
| 482 | }), |
| 483 | ); |
| 484 | |
| 485 | export const makeQuickJsExecutor = ( |
| 486 | options: QuickJsExecutorOptions = {}, |
no test coverage detected