History

more clean up

Rhys Sullivan committed 8 months ago

Commit ffbd44d1 parent 50606af9 files · +25 −63Browse files

Unified · Split

9 files
  1. v2/apps/convex/convex/run_executor.ts +0 −8
  2. v2/apps/convex/package.json +1 −0
  3. v2/apps/pm/package.json +1 −0
  4. v2/bun.lock +2 −2
  5. v2/packages/engine/src/runtime-adapters.ts +8 −3
  6. v2/packages/runtime-deno-subprocess/package.json +0 −1
  7. v2/packages/runtime-deno-subprocess/src/index.ts +8 −36
  8. v2/packages/runtime-local-inproc/package.json +0 −1
  9. v2/packages/runtime-local-inproc/src/index.ts +5 −12
v2/apps/convex/convex/run_executor.ts+0−8
@@ -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";
5import {
6 ToolProviderRegistryService,
7 makeToolProviderRegistry,
8} from "@executor-v2/engine";
9import type { ExecuteRunInput, ExecuteRunResult } from "@executor-v2/sdk";5import type { ExecuteRunInput, ExecuteRunResult } from "@executor-v2/sdk";
10import * as Context from "effect/Context";6import * as Context from "effect/Context";
11import * as Effect from "effect/Effect";7import * 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
39export const ConvexToolProviderRegistryLive = Layer.succeed(
40 ToolProviderRegistryService,
41 makeToolProviderRegistry([]),
42);
v2/apps/convex/package.json+1−0
@@ -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:*",
v2/apps/pm/package.json+1−0
@@ -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}
v2/bun.lock+2−2
@@ -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 },
v2/packages/engine/src/runtime-adapters.ts+8−3
@@ -3,13 +3,18 @@ import * as Data from "effect/Data"; · 2 unmodified lines
3import * as Effect from "effect/Effect";3import * as Effect from "effect/Effect";
4import * as Layer from "effect/Layer";4import * as Layer from "effect/Layer";
5 5
6import type { ToolProviderRegistryService } from "./tool-providers";6import type { Source } from "@executor-v2/schema";
7
8import type {
9 CanonicalToolDescriptor,
10 ToolProviderRegistryService,
11} from "./tool-providers";
7 12
8export type RuntimeAdapterKind = string;13export type RuntimeAdapterKind = string;
9 14
10export type RuntimeRunnableTool = {15export type RuntimeRunnableTool = {
11 descriptor: unknown;16 descriptor: CanonicalToolDescriptor;
12 source: unknown | null;17 source: Source | null;
13};18};
14 19
15export type RuntimeExecuteInput = {20export type RuntimeExecuteInput = {
v2/packages/runtime-deno-subprocess/package.json+0−1
@@ -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}
v2/packages/runtime-deno-subprocess/src/index.ts+8−36
@@ -1,19 +1,14 @@
1import { existsSync } from "node:fs";1import { existsSync } from "node:fs";
2import { fileURLToPath } from "node:url";2import { fileURLToPath } from "node:url";
3 3
4import type { Source } from "@executor-v2/schema";
5import * as Effect from "effect/Effect";4import * as Effect from "effect/Effect";
6import * as Runtime from "effect/Runtime";5import * as Runtime from "effect/Runtime";
7import * as Schema from "effect/Schema";6import * as Schema from "effect/Schema";
8 7
9import {8import {
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";
19import { spawnDenoWorkerProcess } from "./deno-worker-process";14import { spawnDenoWorkerProcess } from "./deno-worker-process";
@@ -23,14 +18,11 @@ const runtimeKind = "deno-subprocess"; · 3 unmodified lines
23export const DenoSubprocessRunnerError = RuntimeAdapterError;18export const DenoSubprocessRunnerError = RuntimeAdapterError;
24export type DenoSubprocessRunnerError = RuntimeAdapterError;19export type DenoSubprocessRunnerError = RuntimeAdapterError;
25 20
26export type DenoRunnableTool = {21export type DenoRunnableTool = RuntimeRunnableTool;
27 descriptor: CanonicalToolDescriptor;
28 source: Source | null;
29};
30 22
31export type ExecuteJavaScriptInDenoInput = {23export 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
261export const executeJavaScriptInDenoSubprocess = (250export 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
443const 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
454export const makeDenoSubprocessRuntimeAdapter = (428export 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
470export type { RuntimeRunnableTool };442export type { RuntimeRunnableTool };
v2/packages/runtime-local-inproc/package.json+0−1
@@ -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}
v2/packages/runtime-local-inproc/src/index.ts+5−12
@@ -1,10 +1,8 @@
1import type { Source } from "@executor-v2/schema";
2import * as Effect from "effect/Effect";1import * as Effect from "effect/Effect";
3import * as Runtime from "effect/Runtime";2import * as Runtime from "effect/Runtime";
4 3
5import {4import {
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
13const runtimeKind = "local-inproc";11const runtimeKind = "local-inproc";
14 12
15export type RunnableTool = {
16 descriptor: CanonicalToolDescriptor;
17 source: Source | null;
18};
19
20export type ExecuteJavaScriptInput = {13export type ExecuteJavaScriptInput = {
21 code: string;14 code: string;
22 tools: ReadonlyArray<RunnableTool>;15 tools: ReadonlyArray<RuntimeRunnableTool>;
23};16};
24 17
25const runtimeError = (18const runtimeError = (
@@ -56,10 +49,10 @@ const toExecutionError = (cause: unknown): RuntimeAdapterError => · 30 unmodified lines
56 );49 );
57 50
58const buildToolBindings = (51const 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