( options: QuickJsExecutorOptions, code: string, toolInvoker: SandboxToolInvoker, )
| 548 | }; |
| 549 | |
| 550 | const runInQuickJs = ( |
| 551 | options: QuickJsExecutorOptions, |
| 552 | code: string, |
| 553 | toolInvoker: SandboxToolInvoker, |
| 554 | ): Effect.Effect<ExecuteResult, QuickJsExecutionError> => |
| 555 | Effect.gen(function* () { |
| 556 | const context = yield* Effect.context<never>(); |
| 557 | const runPromise = Effect.runPromiseWith(context); |
| 558 | return yield* Effect.tryPromise({ |
| 559 | try: () => evaluateInQuickJs(options, code, toolInvoker, runPromise), |
| 560 | catch: (cause) => new QuickJsExecutionError({ message: String(cause) }), |
| 561 | }); |
| 562 | }).pipe( |
| 563 | Effect.withSpan("executor.code.exec.quickjs", { |
| 564 | attributes: { "executor.runtime": "quickjs" }, |
| 565 | }), |
| 566 | ); |
| 567 | |
| 568 | export const makeQuickJsExecutor = ( |
| 569 | options: QuickJsExecutorOptions = {}, |
no test coverage detected