Showing the changes to apps (8 of 16 files). Show all
Unified · Split
| @@ -652,18 +652,16 @@ const stopServer = (baseUrl: string) => · 651 unmodified lines | ||
| 652 | 652 | const pid = typeof pidRecord?.pid === "number" ? pidRecord.pid : null; |
| 653 | 653 | |
| 654 | 654 | if (pid === null) { |
| 655 | − yield* Effect.tryPromise({ | |
| 656 | − try: () => rm(DEFAULT_SERVER_PID_FILE, { force: true }), | |
| 657 | − catch: () => undefined, | |
| 658 | − }); | |
| 655 | + yield* Effect.tryPromise(() => rm(DEFAULT_SERVER_PID_FILE, { force: true })).pipe( | |
| 656 | + Effect.ignore, | |
| 657 | + ); | |
| 659 | 658 | return false; |
| 660 | 659 | } |
| 661 | 660 | |
| 662 | 661 | if (!isPidRunning(pid)) { |
| 663 | − yield* Effect.tryPromise({ | |
| 664 | − try: () => rm(DEFAULT_SERVER_PID_FILE, { force: true }), | |
| 665 | − catch: () => undefined, | |
| 666 | − }); | |
| 662 | + yield* Effect.tryPromise(() => rm(DEFAULT_SERVER_PID_FILE, { force: true })).pipe( | |
| 663 | + Effect.ignore, | |
| 664 | + ); | |
| 667 | 665 | return false; |
| 668 | 666 | } |
| 669 | 667 | |
| @@ -674,10 +672,10 @@ const stopServer = (baseUrl: string) => · 4 unmodified lines | ||
| 674 | 672 | |
| 675 | 673 | yield* waitForReachability(baseUrl, false).pipe( |
| 676 | 674 | Effect.catchAll(() => |
| 677 | − Effect.tryPromise({ | |
| 678 | − try: () => rm(DEFAULT_SERVER_PID_FILE, { force: true }), | |
| 679 | − catch: () => undefined, | |
| 680 | − }).pipe(Effect.zipRight(Effect.fail(new Error(`Timed out stopping local executor server pid ${pid}`)))), | |
| 675 | + Effect.tryPromise(() => rm(DEFAULT_SERVER_PID_FILE, { force: true })).pipe( | |
| 676 | + Effect.ignore, | |
| 677 | + Effect.zipRight(Effect.fail(new Error(`Timed out stopping local executor server pid ${pid}`))), | |
| 678 | + ), | |
| 681 | 679 | ), |
| 682 | 680 | ); |
| 683 | 681 | |
| @@ -176,7 +176,8 @@ export const LocalDistributionHarnessLive = Layer.scoped( · 175 unmodified lines | ||
| 176 | 176 | }), |
| 177 | 177 | (path) => Effect.tryPromise({ |
| 178 | 178 | try: () => rm(path, { recursive: true, force: true }), |
| 179 | − catch: () => undefined, | |
| 179 | + catch: (cause) => | |
| 180 | + cause instanceof Error ? cause : new Error(String(cause ?? "temp dir cleanup failed")), | |
| 180 | 181 | }).pipe(Effect.orDie), |
| 181 | 182 | ); |
| 182 | 183 | |
| @@ -647,12 +647,13 @@ describe("local-executor-server", () => { · 646 unmodified lines | ||
| 647 | 647 | }); |
| 648 | 648 | |
| 649 | 649 | const listed = yield* Effect.promise( |
| 650 | − () => mcp.client.listTools() as Promise<{ tools: Array<{ name: string }> }>, | |
| 650 | + () => mcp.client.listTools() as Promise<{ tools: Array<{ name: string; description?: string }> }>, | |
| 651 | 651 | ); |
| 652 | 652 | expect(listed.tools.map((tool) => tool.name)).toEqual(["execute"]); |
| 653 | − expect(mcp.client.getInstructions()).toContain( | |
| 654 | − `npx add-mcp \"${server.baseUrl}/mcp\" --transport http --name \"executor\"`, | |
| 655 | − ); | |
| 653 | + expect(listed.tools[0]?.description).toContain("Workflow:"); | |
| 654 | + expect(listed.tools[0]?.description).toContain("tools.discover"); | |
| 655 | + expect(listed.tools[0]?.description).toContain("tools.executor.sources.add"); | |
| 656 | + | |
| 656 | 657 | |
| 657 | 658 | const executed = yield* Effect.promise( |
| 658 | 659 | () => |
| @@ -686,12 +687,12 @@ describe("local-executor-server", () => { · 27 unmodified lines | ||
| 686 | 687 | }); |
| 687 | 688 | |
| 688 | 689 | const listed = yield* Effect.promise( |
| 689 | − () => mcp.client.listTools() as Promise<{ tools: Array<{ name: string }> }>, | |
| 690 | + () => mcp.client.listTools() as Promise<{ tools: Array<{ name: string; description?: string }> }>, | |
| 690 | 691 | ); |
| 691 | 692 | expect(listed.tools.map((tool) => tool.name).sort()).toEqual(["execute", "resume"]); |
| 692 | − expect(mcp.client.getInstructions()).toContain( | |
| 693 | − `npx add-mcp \"${server.baseUrl}/mcp\" --transport http --name \"executor\"`, | |
| 694 | − ); | |
| 693 | + expect(listed.tools.find((tool) => tool.name === "execute")?.description).toContain("Workflow:"); | |
| 694 | + expect(listed.tools.find((tool) => tool.name === "execute")?.description).toContain("tools.discover"); | |
| 695 | + | |
| 695 | 696 | |
| 696 | 697 | const executed = yield* Effect.promise( |
| 697 | 698 | () => |
| @@ -0,0 +1,37 @@ | ||
| 1 | +import { useEffect, useMemo, useState } from "react"; | |
| 2 | +import { CodeBlock } from "./code-block"; | |
| 3 | + | |
| 4 | +export function LocalMcpInstallCard(props: { | |
| 5 | + title?: string; | |
| 6 | + description?: string; | |
| 7 | + className?: string; | |
| 8 | +}) { | |
| 9 | + const [origin, setOrigin] = useState<string | null>(null); | |
| 10 | + | |
| 11 | + useEffect(() => { | |
| 12 | + setOrigin(window.location.origin); | |
| 13 | + }, []); | |
| 14 | + | |
| 15 | + const command = useMemo( | |
| 16 | + () => | |
| 17 | + origin | |
| 18 | + ? `npx add-mcp "${origin}/mcp" --transport http --name "executor"` | |
| 19 | + : 'npx add-mcp "<this-server>/mcp" --transport http --name "executor"', | |
| 20 | + [origin], | |
| 21 | + ); | |
| 22 | + | |
| 23 | + return ( | |
| 24 | + <section className={props.className ?? "rounded-2xl border border-border bg-card/80 p-5"}> | |
| 25 | + <div className="mb-3 space-y-1"> | |
| 26 | + <h2 className="text-sm font-semibold text-foreground"> | |
| 27 | + {props.title ?? "Install local MCP"} | |
| 28 | + </h2> | |
| 29 | + <p className="text-[13px] text-muted-foreground"> | |
| 30 | + {props.description | |
| 31 | + ?? "Add this local executor server to an MCP client with one command. The URL uses the same origin as this web app."} | |
| 32 | + </p> | |
| 33 | + </div> | |
| 34 | + <CodeBlock code={command} lang="bash" className="rounded-xl border border-border bg-background/70" /> | |
| 35 | + </section> | |
| 36 | + ); | |
| 37 | +} | |
| @@ -5,7 +5,10 @@ · 4 unmodified lines | ||
| 5 | 5 | * control-plane handler. Everything else (frontend assets, HMR) is |
| 6 | 6 | * handled by Vite itself. |
| 7 | 7 | */ |
| 8 | +import * as Cause from "effect/Cause"; | |
| 8 | 9 | import * as Effect from "effect/Effect"; |
| 10 | +import * as Exit from "effect/Exit"; | |
| 11 | +import * as Runtime from "effect/Runtime"; | |
| 9 | 12 | import * as Scope from "effect/Scope"; |
| 10 | 13 | import { createLocalExecutorRequestHandler } from "@executor-v3/server"; |
| 11 | 14 | |
| @@ -16,28 +19,53 @@ const truncateForLog = (value: string): string => · 4 unmodified lines | ||
| 16 | 19 | ? `${value.slice(0, MAX_LOGGED_ERROR_BODY_LENGTH)}... [truncated]` |
| 17 | 20 | : value; |
| 18 | 21 | |
| 19 | −const formatErrorForLog = (error: unknown) => | |
| 20 | − error instanceof Error | |
| 21 | − ? { | |
| 22 | − name: error.name, | |
| 23 | − message: error.message, | |
| 24 | − stack: error.stack, | |
| 25 | − } | |
| 26 | − : error; | |
| 22 | +/** | |
| 23 | + * Extract a detailed, human-readable description from an error. | |
| 24 | + * | |
| 25 | + * When Effect rejects via `runPromise`, the thrown value is a | |
| 26 | + * `FiberFailure` wrapping a `Cause`. `Cause.pretty` renders the full | |
| 27 | + * failure tree (defects, interrupts, tagged errors, etc.) rather than the | |
| 28 | + * opaque fallback message ("An error has occurred"). | |
| 29 | + */ | |
| 30 | +const formatErrorForLog = (error: unknown): string => { | |
| 31 | + if (Runtime.isFiberFailure(error)) { | |
| 32 | + const cause = error[Runtime.FiberFailureCauseId]; | |
| 33 | + return Cause.pretty(cause); | |
| 34 | + } | |
| 35 | + | |
| 36 | + if (error instanceof Error) { | |
| 37 | + return error.stack ?? error.message; | |
| 38 | + } | |
| 39 | + | |
| 40 | + return String(error); | |
| 41 | +}; | |
| 27 | 42 | |
| 28 | 43 | // Create a long-lived scope that stays open for the lifetime of the process. |
| 29 | −const handlerPromise = Effect.runPromise( | |
| 30 | − Effect.gen(function* () { | |
| 31 | − const scope = yield* Scope.make(); | |
| 32 | − const handler = yield* createLocalExecutorRequestHandler().pipe( | |
| 33 | − Effect.provideService(Scope.Scope, scope), | |
| 34 | − ); | |
| 35 | − return handler; | |
| 36 | − }), | |
| 37 | −).catch((error) => { | |
| 38 | − console.error("[executor dev api] failed to initialize request handler", formatErrorForLog(error)); | |
| 39 | − throw error; | |
| 40 | −}); | |
| 44 | +const handlerPromise = (async () => { | |
| 45 | + const exit = await Effect.runPromiseExit( | |
| 46 | + Effect.gen(function* () { | |
| 47 | + const scope = yield* Scope.make(); | |
| 48 | + const handler = yield* createLocalExecutorRequestHandler().pipe( | |
| 49 | + Effect.provideService(Scope.Scope, scope), | |
| 50 | + ); | |
| 51 | + return handler; | |
| 52 | + }), | |
| 53 | + ); | |
| 54 | + | |
| 55 | + if (Exit.isSuccess(exit)) { | |
| 56 | + return exit.value; | |
| 57 | + } | |
| 58 | + | |
| 59 | + // Log the full Cause tree — this captures typed errors, defects (uncaught | |
| 60 | + // throws), and interrupts with their original stack traces. | |
| 61 | + console.error( | |
| 62 | + "[executor dev api] failed to initialize request handler\n\n" + | |
| 63 | + Cause.pretty(exit.cause), | |
| 64 | + ); | |
| 65 | + | |
| 66 | + // Re-throw so every subsequent request sees the init failure. | |
| 67 | + throw Cause.squash(exit.cause); | |
| 68 | +})(); | |
| 41 | 69 | |
| 42 | 70 | export default { |
| 43 | 71 | async fetch(request: Request) { |
| @@ -18,6 +18,7 @@ import { · 17 unmodified lines | ||
| 18 | 18 | } from "@executor-v3/react"; |
| 19 | 19 | import { Badge } from "../components/ui/badge"; |
| 20 | 20 | import { Button } from "../components/ui/button"; |
| 21 | +import { LocalMcpInstallCard } from "../components/local-mcp-install-card"; | |
| 21 | 22 | import { SourceFavicon } from "../components/source-favicon"; |
| 22 | 23 | import { |
| 23 | 24 | IconArrowLeft, |
| @@ -737,6 +738,14 @@ export function AddSourcePage() { · 713 unmodified lines | ||
| 737 | 738 | |
| 738 | 739 | {statusBanner && <StatusBanner state={statusBanner} className="mb-6" />} |
| 739 | 740 | |
| 741 | + | |
| 742 | + {(phase === "idle" || phase === "discovering") && ( | |
| 743 | + <LocalMcpInstallCard | |
| 744 | + className="mb-6 rounded-xl border border-border bg-card/80 p-5" | |
| 745 | + title="Install this executor as MCP" | |
| 746 | + description="Prefer a one-command setup? Install this local executor server into your MCP client, or add an external MCP source below." | |
| 747 | + /> | |
| 748 | + )} | |
| 740 | 749 | {/* Step 1: Discovery */} |
| 741 | 750 | {(phase === "idle" || phase === "discovering") && ( |
| 742 | 751 | <div className="space-y-6"> |
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | import { Link } from "@tanstack/react-router"; |
| 2 | 2 | import { useSources, type Source } from "@executor-v3/react"; |
| 3 | 3 | import { LoadableBlock } from "../components/loadable"; |
| 4 | +import { LocalMcpInstallCard } from "../components/local-mcp-install-card"; | |
| 4 | 5 | import { SourceFavicon } from "../components/source-favicon"; |
| 5 | 6 | import { Badge } from "../components/ui/badge"; |
| 6 | 7 | import { Button } from "../components/ui/button"; |
| @@ -30,6 +31,8 @@ export function HomePage() { · 23 unmodified lines | ||
| 30 | 31 | </Link> |
| 31 | 32 | </div> |
| 32 | 33 | |
| 34 | + <LocalMcpInstallCard className="mb-8" /> | |
| 35 | + | |
| 33 | 36 | {/* Source list */} |
| 34 | 37 | <LoadableBlock loadable={sources} loading="Loading sources..."> |
| 35 | 38 | {(items) => |
| @@ -11,8 +11,8 @@ export default defineConfig({ · 10 unmodified lines | ||
| 11 | 11 | devServer({ |
| 12 | 12 | entry: "src/dev.ts", |
| 13 | 13 | exclude: [ |
| 14 | − // Only let /v1 requests reach the API handler | |
| 15 | − /^\/(?!v1(\/|$))/, | |
| 14 | + // Only let /v1 and /mcp requests reach the API handler | |
| 15 | + /^\/(?!(v1|mcp)(\/|$))/, | |
| 16 | 16 | /^\/(src|node_modules|@vite|@id|@react-refresh)/, |
| 17 | 17 | /\.(css|ts|tsx|js|jsx|svg|png|jpg|gif|ico|woff2?|json|map)(\?.*)?$/, |
| 18 | 18 | ], |