Unified · Split
| @@ -2,10 +2,6 @@ import { · 1 unmodified line | |||
| 2 | RunExecutionService, | 2 | RunExecutionService, |
| 3 | RunExecutionServiceLive, | 3 | RunExecutionServiceLive, |
| 4 | } from "@executor-v2/domain"; | 4 | } from "@executor-v2/domain"; |
| 5 | import { | ||
| 6 | ToolProviderRegistryService, | ||
| 7 | makeToolProviderRegistry, | ||
| 8 | } from "@executor-v2/engine"; | ||
| 9 | import type { ExecuteRunInput, ExecuteRunResult } from "@executor-v2/sdk"; | 5 | import type { ExecuteRunInput, ExecuteRunResult } from "@executor-v2/sdk"; |
| 10 | import * as Context from "effect/Context"; | 6 | import * as Context from "effect/Context"; |
| 11 | import * as Effect from "effect/Effect"; | 7 | import * as Effect from "effect/Effect"; |
| @@ -36,7 +32,3 @@ export const ConvexRunExecutorLive = Layer.effect( · 24 unmodified lines | |||
| 36 | }), | 32 | }), |
| 37 | ).pipe(Layer.provide(ConvexRunExecutionLive)); | 33 | ).pipe(Layer.provide(ConvexRunExecutionLive)); |
| 38 | 34 | ||
| 39 | export const ConvexToolProviderRegistryLive = Layer.succeed( | ||
| 40 | ToolProviderRegistryService, | ||
| 41 | makeToolProviderRegistry([]), | ||
| 42 | ); | ||
| @@ -14,6 +14,7 @@ · 13 unmodified lines | |||
| 14 | "@executor-v2/domain": "workspace:*", | 14 | "@executor-v2/domain": "workspace:*", |
| 15 | "@executor-v2/engine": "workspace:*", | 15 | "@executor-v2/engine": "workspace:*", |
| 16 | "@executor-v2/mcp-gateway": "workspace:*", | 16 | "@executor-v2/mcp-gateway": "workspace:*", |
| 17 | "@executor-v2/persistence-ports": "workspace:*", | ||
| 17 | "@executor-v2/runtime-local-inproc": "workspace:*", | 18 | "@executor-v2/runtime-local-inproc": "workspace:*", |
| 18 | "@executor-v2/schema": "workspace:*", | 19 | "@executor-v2/schema": "workspace:*", |
| 19 | "@executor-v2/sdk": "workspace:*", | 20 | "@executor-v2/sdk": "workspace:*", |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | |||
| 24 | }, | 24 | }, |
| 25 | "devDependencies": { | 25 | "devDependencies": { |
| 26 | "@effect/vitest": "catalog:", | 26 | "@effect/vitest": "catalog:", |
| 27 | "@modelcontextprotocol/sdk": "^1.26.0", | ||
| 27 | "vitest": "catalog:" | 28 | "vitest": "catalog:" |
| 28 | } | 29 | } |
| 29 | } | 30 | } |
| @@ -26,6 +26,7 @@ · 25 unmodified lines | |||
| 26 | "@executor-v2/domain": "workspace:*", | 26 | "@executor-v2/domain": "workspace:*", |
| 27 | "@executor-v2/engine": "workspace:*", | 27 | "@executor-v2/engine": "workspace:*", |
| 28 | "@executor-v2/mcp-gateway": "workspace:*", | 28 | "@executor-v2/mcp-gateway": "workspace:*", |
| 29 | "@executor-v2/persistence-ports": "workspace:*", | ||
| 29 | "@executor-v2/runtime-local-inproc": "workspace:*", | 30 | "@executor-v2/runtime-local-inproc": "workspace:*", |
| 30 | "@executor-v2/schema": "workspace:*", | 31 | "@executor-v2/schema": "workspace:*", |
| 31 | "@executor-v2/sdk": "workspace:*", | 32 | "@executor-v2/sdk": "workspace:*", |
| @@ -56,6 +57,7 @@ · 24 unmodified lines | |||
| 56 | }, | 57 | }, |
| 57 | "devDependencies": { | 58 | "devDependencies": { |
| 58 | "@effect/vitest": "catalog:", | 59 | "@effect/vitest": "catalog:", |
| 60 | "@modelcontextprotocol/sdk": "^1.26.0", | ||
| 59 | "vitest": "catalog:", | 61 | "vitest": "catalog:", |
| 60 | }, | 62 | }, |
| 61 | }, | 63 | }, |
| @@ -174,7 +176,6 @@ · 112 unmodified lines | |||
| 174 | "name": "@executor-v2/runtime-deno-subprocess", | 176 | "name": "@executor-v2/runtime-deno-subprocess", |
| 175 | "dependencies": { | 177 | "dependencies": { |
| 176 | "@executor-v2/engine": "workspace:*", | 178 | "@executor-v2/engine": "workspace:*", |
| 177 | "@executor-v2/schema": "workspace:*", | ||
| 178 | "effect": "catalog:", | 179 | "effect": "catalog:", |
| 179 | }, | 180 | }, |
| 180 | }, | 181 | }, |
| @@ -182,7 +183,6 @@ · 1 unmodified line | |||
| 182 | "name": "@executor-v2/runtime-local-inproc", | 183 | "name": "@executor-v2/runtime-local-inproc", |
| 183 | "dependencies": { | 184 | "dependencies": { |
| 184 | "@executor-v2/engine": "workspace:*", | 185 | "@executor-v2/engine": "workspace:*", |
| 185 | "@executor-v2/schema": "workspace:*", | ||
| 186 | "effect": "catalog:", | 186 | "effect": "catalog:", |
| 187 | }, | 187 | }, |
| 188 | }, | 188 | }, |
| @@ -3,13 +3,18 @@ import * as Data from "effect/Data"; · 2 unmodified lines | |||
| 3 | import * as Effect from "effect/Effect"; | 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as Layer from "effect/Layer"; | 4 | import * as Layer from "effect/Layer"; |
| 5 | 5 | ||
| 6 | import type { ToolProviderRegistryService } from "./tool-providers"; | 6 | import type { Source } from "@executor-v2/schema"; |
| 7 | |||
| 8 | import type { | ||
| 9 | CanonicalToolDescriptor, | ||
| 10 | ToolProviderRegistryService, | ||
| 11 | } from "./tool-providers"; | ||
| 7 | 12 | ||
| 8 | export type RuntimeAdapterKind = string; | 13 | export type RuntimeAdapterKind = string; |
| 9 | 14 | ||
| 10 | export type RuntimeRunnableTool = { | 15 | export type RuntimeRunnableTool = { |
| 11 | descriptor: unknown; | 16 | descriptor: CanonicalToolDescriptor; |
| 12 | source: unknown | null; | 17 | source: Source | null; |
| 13 | }; | 18 | }; |
| 14 | 19 | ||
| 15 | export type RuntimeExecuteInput = { | 20 | export type RuntimeExecuteInput = { |
| @@ -10,7 +10,6 @@ · 9 unmodified lines | |||
| 10 | }, | 10 | }, |
| 11 | "dependencies": { | 11 | "dependencies": { |
| 12 | "@executor-v2/engine": "workspace:*", | 12 | "@executor-v2/engine": "workspace:*", |
| 13 | "@executor-v2/schema": "workspace:*", | ||
| 14 | "effect": "catalog:" | 13 | "effect": "catalog:" |
| 15 | } | 14 | } |
| 16 | } | 15 | } |
| @@ -1,19 +1,14 @@ | |||
| 1 | import { existsSync } from "node:fs"; | 1 | import { existsSync } from "node:fs"; |
| 2 | import { fileURLToPath } from "node:url"; | 2 | import { fileURLToPath } from "node:url"; |
| 3 | 3 | ||
| 4 | import type { Source } from "@executor-v2/schema"; | ||
| 5 | import * as Effect from "effect/Effect"; | 4 | import * as Effect from "effect/Effect"; |
| 6 | import * as Runtime from "effect/Runtime"; | 5 | import * as Runtime from "effect/Runtime"; |
| 7 | import * as Schema from "effect/Schema"; | 6 | import * as Schema from "effect/Schema"; |
| 8 | 7 | ||
| 9 | import { | 8 | import { |
| 10 | RuntimeAdapterError, | 9 | RuntimeAdapterError, |
| 11 | type CanonicalToolDescriptor, | ||
| 12 | type RuntimeAdapter, | 10 | type RuntimeAdapter, |
| 13 | type RuntimeAdapterKind, | ||
| 14 | type RuntimeRunnableTool, | 11 | type RuntimeRunnableTool, |
| 15 | type ToolProviderError, | ||
| 16 | type ToolProviderRegistryError, | ||
| 17 | ToolProviderRegistryService, | 12 | ToolProviderRegistryService, |
| 18 | } from "@executor-v2/engine"; | 13 | } from "@executor-v2/engine"; |
| 19 | import { spawnDenoWorkerProcess } from "./deno-worker-process"; | 14 | import { spawnDenoWorkerProcess } from "./deno-worker-process"; |
| @@ -23,14 +18,11 @@ const runtimeKind = "deno-subprocess"; · 3 unmodified lines | |||
| 23 | export const DenoSubprocessRunnerError = RuntimeAdapterError; | 18 | export const DenoSubprocessRunnerError = RuntimeAdapterError; |
| 24 | export type DenoSubprocessRunnerError = RuntimeAdapterError; | 19 | export type DenoSubprocessRunnerError = RuntimeAdapterError; |
| 25 | 20 | ||
| 26 | export type DenoRunnableTool = { | 21 | export type DenoRunnableTool = RuntimeRunnableTool; |
| 27 | descriptor: CanonicalToolDescriptor; | ||
| 28 | source: Source | null; | ||
| 29 | }; | ||
| 30 | 22 | ||
| 31 | export type ExecuteJavaScriptInDenoInput = { | 23 | export type ExecuteJavaScriptInDenoInput = { |
| 32 | code: string; | 24 | code: string; |
| 33 | tools: ReadonlyArray<DenoRunnableTool>; | 25 | tools: ReadonlyArray<RuntimeRunnableTool>; |
| 34 | timeoutMs?: number; | 26 | timeoutMs?: number; |
| 35 | denoExecutable?: string; | 27 | denoExecutable?: string; |
| 36 | }; | 28 | }; |
| @@ -199,13 +191,10 @@ const handleToolCall = ( · 162 unmodified lines | |||
| 199 | toolBindings: ReadonlyMap<string, DenoRunnableTool>, | 191 | toolBindings: ReadonlyMap<string, DenoRunnableTool>, |
| 200 | runPromise: <A, E>(effect: Effect.Effect<A, E, never>) => Promise<A>, | 192 | runPromise: <A, E>(effect: Effect.Effect<A, E, never>) => Promise<A>, |
| 201 | invokeTool: (input: { | 193 | invokeTool: (input: { |
| 202 | source: Source | null; | 194 | source: RuntimeRunnableTool["source"]; |
| 203 | tool: CanonicalToolDescriptor; | 195 | tool: RuntimeRunnableTool["descriptor"]; |
| 204 | args: unknown; | 196 | args: unknown; |
| 205 | }) => Effect.Effect< | 197 | }) => Effect.Effect<{ output: unknown; isError: boolean }, unknown>, |
| 206 | { output: unknown; isError: boolean }, | ||
| 207 | ToolProviderRegistryError | ToolProviderError | ||
| 208 | >, | ||
| 209 | stdin: NodeJS.WritableStream, | 198 | stdin: NodeJS.WritableStream, |
| 210 | ): Effect.Effect<void, DenoSubprocessRunnerError> => | 199 | ): Effect.Effect<void, DenoSubprocessRunnerError> => |
| 211 | Effect.gen(function* () { | 200 | Effect.gen(function* () { |
| @@ -260,11 +249,7 @@ export const isDenoSubprocessRuntimeAvailable = ( · 48 unmodified lines | |||
| 260 | 249 | ||
| 261 | export const executeJavaScriptInDenoSubprocess = ( | 250 | export const executeJavaScriptInDenoSubprocess = ( |
| 262 | input: ExecuteJavaScriptInDenoInput, | 251 | input: ExecuteJavaScriptInDenoInput, |
| 263 | ): Effect.Effect< | 252 | ): Effect.Effect<unknown, DenoSubprocessRunnerError, ToolProviderRegistryService> => |
| 264 | unknown, | ||
| 265 | DenoSubprocessRunnerError | ToolProviderRegistryError | ToolProviderError, | ||
| 266 | ToolProviderRegistryService | ||
| 267 | > => | ||
| 268 | Effect.gen(function* () { | 253 | Effect.gen(function* () { |
| 269 | const registry = yield* ToolProviderRegistryService; | 254 | const registry = yield* ToolProviderRegistryService; |
| 270 | const runtime = yield* Effect.runtime<never>(); | 255 | const runtime = yield* Effect.runtime<never>(); |
| @@ -440,17 +425,6 @@ export const executeJavaScriptInDenoSubprocess = ( · 169 unmodified lines | |||
| 440 | }); | 425 | }); |
| 441 | }); | 426 | }); |
| 442 | 427 | ||
| 443 | const toRuntimeAdapterError = ( | ||
| 444 | runtimeKind: RuntimeAdapterKind, | ||
| 445 | error: DenoSubprocessRunnerError | ToolProviderRegistryError | ToolProviderError, | ||
| 446 | ): RuntimeAdapterError => | ||
| 447 | new RuntimeAdapterError({ | ||
| 448 | operation: error.operation, | ||
| 449 | runtimeKind, | ||
| 450 | message: error.message, | ||
| 451 | details: "details" in error ? error.details : null, | ||
| 452 | }); | ||
| 453 | |||
| 454 | export const makeDenoSubprocessRuntimeAdapter = ( | 428 | export const makeDenoSubprocessRuntimeAdapter = ( |
| 455 | options: DenoSubprocessRuntimeAdapterOptions = {}, | 429 | options: DenoSubprocessRuntimeAdapterOptions = {}, |
| 456 | ): RuntimeAdapter => ({ | 430 | ): RuntimeAdapter => ({ |
| @@ -459,12 +433,10 @@ export const makeDenoSubprocessRuntimeAdapter = ( · 2 unmodified lines | |||
| 459 | execute: (input) => | 433 | execute: (input) => |
| 460 | executeJavaScriptInDenoSubprocess({ | 434 | executeJavaScriptInDenoSubprocess({ |
| 461 | code: input.code, | 435 | code: input.code, |
| 462 | tools: input.tools as ReadonlyArray<DenoRunnableTool>, | 436 | tools: input.tools, |
| 463 | timeoutMs: input.timeoutMs ?? options.defaultTimeoutMs, | 437 | timeoutMs: input.timeoutMs ?? options.defaultTimeoutMs, |
| 464 | denoExecutable: options.denoExecutable, | 438 | denoExecutable: options.denoExecutable, |
| 465 | }).pipe( | 439 | }), |
| 466 | Effect.mapError((error) => toRuntimeAdapterError("deno-subprocess", error)), | ||
| 467 | ), | ||
| 468 | }); | 440 | }); |
| 469 | 441 | ||
| 470 | export type { RuntimeRunnableTool }; | 442 | export type { RuntimeRunnableTool }; |
| @@ -10,7 +10,6 @@ · 9 unmodified lines | |||
| 10 | }, | 10 | }, |
| 11 | "dependencies": { | 11 | "dependencies": { |
| 12 | "@executor-v2/engine": "workspace:*", | 12 | "@executor-v2/engine": "workspace:*", |
| 13 | "@executor-v2/schema": "workspace:*", | ||
| 14 | "effect": "catalog:" | 13 | "effect": "catalog:" |
| 15 | } | 14 | } |
| 16 | } | 15 | } |
| @@ -1,10 +1,8 @@ | |||
| 1 | import type { Source } from "@executor-v2/schema"; | ||
| 2 | import * as Effect from "effect/Effect"; | 1 | import * as Effect from "effect/Effect"; |
| 3 | import * as Runtime from "effect/Runtime"; | 2 | import * as Runtime from "effect/Runtime"; |
| 4 | 3 | ||
| 5 | import { | 4 | import { |
| 6 | RuntimeAdapterError, | 5 | RuntimeAdapterError, |
| 7 | type CanonicalToolDescriptor, | ||
| 8 | type RuntimeAdapter, | 6 | type RuntimeAdapter, |
| 9 | type RuntimeRunnableTool, | 7 | type RuntimeRunnableTool, |
| 10 | ToolProviderRegistryService, | 8 | ToolProviderRegistryService, |
| @@ -12,14 +10,9 @@ import { · 1 unmodified line | |||
| 12 | 10 | ||
| 13 | const runtimeKind = "local-inproc"; | 11 | const runtimeKind = "local-inproc"; |
| 14 | 12 | ||
| 15 | export type RunnableTool = { | ||
| 16 | descriptor: CanonicalToolDescriptor; | ||
| 17 | source: Source | null; | ||
| 18 | }; | ||
| 19 | |||
| 20 | export type ExecuteJavaScriptInput = { | 13 | export type ExecuteJavaScriptInput = { |
| 21 | code: string; | 14 | code: string; |
| 22 | tools: ReadonlyArray<RunnableTool>; | 15 | tools: ReadonlyArray<RuntimeRunnableTool>; |
| 23 | }; | 16 | }; |
| 24 | 17 | ||
| 25 | const runtimeError = ( | 18 | const runtimeError = ( |
| @@ -56,10 +49,10 @@ const toExecutionError = (cause: unknown): RuntimeAdapterError => · 30 unmodified lines | |||
| 56 | ); | 49 | ); |
| 57 | 50 | ||
| 58 | const buildToolBindings = ( | 51 | const buildToolBindings = ( |
| 59 | tools: ReadonlyArray<RunnableTool>, | 52 | tools: ReadonlyArray<RuntimeRunnableTool>, |
| 60 | ): Effect.Effect<Map<string, RunnableTool>, RuntimeAdapterError> => | 53 | ): Effect.Effect<Map<string, RuntimeRunnableTool>, RuntimeAdapterError> => |
| 61 | Effect.gen(function* () { | 54 | Effect.gen(function* () { |
| 62 | const byToolId = new Map<string, RunnableTool>(); | 55 | const byToolId = new Map<string, RuntimeRunnableTool>(); |
| 63 | 56 | ||
| 64 | for (const tool of tools) { | 57 | for (const tool of tools) { |
| 65 | const toolId = tool.descriptor.toolId; | 58 | const toolId = tool.descriptor.toolId; |
| @@ -129,7 +122,7 @@ export const makeLocalInProcessRuntimeAdapter = (): RuntimeAdapter => ({ · 63 unmodified lines | |||
| 129 | execute: (input) => | 122 | execute: (input) => |
| 130 | executeJavaScriptWithTools({ | 123 | executeJavaScriptWithTools({ |
| 131 | code: input.code, | 124 | code: input.code, |
| 132 | tools: input.tools as ReadonlyArray<RunnableTool>, | 125 | tools: input.tools, |
| 133 | }), | 126 | }), |
| 134 | }); | 127 | }); |
| 135 | 128 | ||