Unified · Split
| @@ -1,7 +1,7 @@ | |||
| 1 | // Local-only: custom tool local-directory sources can browse the user's own | 1 | // Local-only: custom tool local-directory sources can browse the user's own |
| 2 | // filesystem through the local app. The shared self-host target intentionally | 2 | // filesystem through the local app. The shared self-host target intentionally |
| 3 | // does not expose this source kind. | 3 | // does not expose this source kind. |
| 4 | import { mkdtempSync, mkdirSync, rmSync } from "node:fs"; | 4 | import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs"; |
| 5 | import { homedir } from "node:os"; | 5 | import { homedir } from "node:os"; |
| 6 | import { join } from "node:path"; | 6 | import { join } from "node:path"; |
| 7 | 7 | ||
| @@ -23,7 +23,31 @@ scenario( · 15 unmodified lines | |||
| 23 | const identity = yield* target.newIdentity(); | 23 | const identity = yield* target.newIdentity(); |
| 24 | const fixtureRoot = mkdtempSync(join(homedir(), ".executor-picker-e2e-")); | 24 | const fixtureRoot = mkdtempSync(join(homedir(), ".executor-picker-e2e-")); |
| 25 | const fixtureDir = join(fixtureRoot, "picked-tools"); | 25 | const fixtureDir = join(fixtureRoot, "picked-tools"); |
| 26 | mkdirSync(fixtureDir); | 26 | mkdirSync(join(fixtureDir, "tools"), { recursive: true }); |
| 27 | writeFileSync( | ||
| 28 | join(fixtureDir, "package.json"), | ||
| 29 | JSON.stringify({ | ||
| 30 | name: "picked-tools", | ||
| 31 | version: "0.0.0", | ||
| 32 | private: true, | ||
| 33 | dependencies: { zod: "^4.1.13" }, | ||
| 34 | }), | ||
| 35 | ); | ||
| 36 | writeFileSync( | ||
| 37 | join(fixtureDir, "tools", "echo.ts"), | ||
| 38 | ` | ||
| 39 | import { z } from "zod"; | ||
| 40 | import { defineTool } from "executor:app"; | ||
| 41 | |||
| 42 | export default defineTool({ | ||
| 43 | description: "Echo a picker message.", | ||
| 44 | input: z.object({ message: z.string() }), | ||
| 45 | handler(input) { | ||
| 46 | return { echoed: \`local-picker:\${input.message}\` }; | ||
| 47 | }, | ||
| 48 | }); | ||
| 49 | `, | ||
| 50 | ); | ||
| 27 | 51 | ||
| 28 | yield* withLocalServer(cli, runDir, ({ url }) => | 52 | yield* withLocalServer(cli, runDir, ({ url }) => |
| 29 | browser.session(identity, async ({ page, step }) => { | 53 | browser.session(identity, async ({ page, step }) => { |
| @@ -48,6 +72,35 @@ scenario( · 18 unmodified lines | |||
| 48 | await dialog.getByRole("button", { name: "Select" }).click(); | 72 | await dialog.getByRole("button", { name: "Select" }).click(); |
| 49 | expect(await pathInput.inputValue()).toBe(fixtureDir); | 73 | expect(await pathInput.inputValue()).toBe(fixtureDir); |
| 50 | }); | 74 | }); |
| 75 | |||
| 76 | await step("Sync the picked directory as a custom tools source", async () => { | ||
| 77 | await page.getByRole("button", { name: "Sync source" }).click(); | ||
| 78 | await page.waitForURL(/\/integrations\/picked-tools(?:\?|$)/, { timeout: 90_000 }); | ||
| 79 | await page.getByLabel("Source").getByText("1 tool").waitFor({ timeout: 90_000 }); | ||
| 80 | }); | ||
| 81 | |||
| 82 | await step("Run the published local tool from the console", async () => { | ||
| 83 | await page.getByRole("tab", { name: "Tools" }).click(); | ||
| 84 | await page.getByRole("button", { name: /picked-tools\s+1/ }).click(); | ||
| 85 | await page.getByRole("button", { name: "echo", exact: true }).click(); | ||
| 86 | await page.getByRole("tab", { name: "Run" }).click(); | ||
| 87 | await page.getByLabel("message").fill("from directory picker"); | ||
| 88 | await page.getByRole("button", { name: "Run", exact: true }).click(); | ||
| 89 | await page | ||
| 90 | .locator("pre") | ||
| 91 | .filter({ hasText: "local-picker:from directory picker" }) | ||
| 92 | .last() | ||
| 93 | .waitFor({ timeout: 90_000 }); | ||
| 94 | }); | ||
| 95 | |||
| 96 | await step("Remove the local directory source", async () => { | ||
| 97 | await page.goto(new URL("/integrations/picked-tools?tab=source", url).toString(), { | ||
| 98 | waitUntil: "networkidle", | ||
| 99 | }); | ||
| 100 | await page.getByRole("button", { name: "Remove" }).click(); | ||
| 101 | await page.getByRole("button", { name: "Remove source" }).click(); | ||
| 102 | await page.waitForURL(/\/integrations(?:\?|$)/, { timeout: 90_000 }); | ||
| 103 | }); | ||
| 51 | }), | 104 | }), |
| 52 | ).pipe( | 105 | ).pipe( |
| 53 | Effect.ensuring(Effect.sync(() => rmSync(fixtureRoot, { recursive: true, force: true }))), | 106 | Effect.ensuring(Effect.sync(() => rmSync(fixtureRoot, { recursive: true, force: true }))), |