mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-26 02:05:31 +00:00
Hub login prints a one-click URL, and an uninstalled Muse Code shows as unavailable (#10751)
* fix(cli): print the one-click Hub login URL
`paseo hub login` opened verificationUriComplete in a browser but printed
the bare verificationUri. Over SSH or on a remote host the browser launch
does nothing, so users had to open the bare page and type the code by hand.
Print the URL that carries ?code= and keep the code next to it so the user
can check it matches the Hub approval page.
* fix(providers): report uninstalled plugin providers as unavailable
A fresh host with only Claude Code installed listed Muse Code as an
error ("muse not found on PATH"). The snapshot manager resolves a
provider's catalogue key before it checks availability, and treats any
failure there as an error. For a plugin provider with a command, the key
lookup required a resolved executable and threw when it was missing.
A command that does not resolve has no catalogue identity. Fall back to
the target key so the availability check runs and reports unavailable.
* fix(providers): keep a removed plugin executable off its cached catalogue
The previous fix returned no catalogue key for a missing executable. A
plugin that returns no key asks for a per-workspace catalogue, so after
its executable was removed the next read bound to the catalogue cached
while it was installed and kept reporting ready.
Give a missing executable its own key. Removal now moves the provider to
a fresh catalogue, and its refresh reports unavailable.
This commit is contained in:
@@ -38,7 +38,9 @@ describe("Hub CLI login browser flow", () => {
|
||||
assert.equal(credential, "paseo_cli_prefix_durable-secret-value");
|
||||
assert.deepEqual(journey.waits, [5_000, 5_000, 10_000]);
|
||||
assert.deepEqual(journey.opened, ["https://hub.test/cli-login?code=ABCD-EFGH"]);
|
||||
assert.deepEqual(journey.instructions, ["https://hub.test/cli-login ABCD-EFGH"]);
|
||||
assert.deepEqual(journey.instructions, [
|
||||
"Open https://hub.test/cli-login?code=ABCD-EFGH to approve CLI login (code: ABCD-EFGH)",
|
||||
]);
|
||||
});
|
||||
|
||||
it("does not open a browser in noninteractive mode", async () => {
|
||||
@@ -57,7 +59,9 @@ describe("Hub CLI login browser flow", () => {
|
||||
await journey.authorize();
|
||||
|
||||
assert.deepEqual(journey.opened, []);
|
||||
assert.equal(journey.instructions.length, 1);
|
||||
assert.deepEqual(journey.instructions, [
|
||||
"Open https://hub.test/cli-login?code=ABCD-EFGH to approve CLI login (code: ABCD-EFGH)",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -95,7 +99,7 @@ class LoginJourney {
|
||||
now: () => this.now,
|
||||
},
|
||||
browser: { open: async (url) => void this.opened.push(url) },
|
||||
instructions: (url, code) => void this.instructions.push(`${url} ${code}`),
|
||||
instructions: (message) => void this.instructions.push(message),
|
||||
openBrowser,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ interface CliLoginFlowOptions {
|
||||
hub: Pick<HubHttpClient, "startCliAuthorization" | "pollCliAuthorization">;
|
||||
waiter: LoginWaiter;
|
||||
browser: BrowserOpener;
|
||||
instructions(verificationUri: string, userCode: string): void;
|
||||
instructions(message: string): void;
|
||||
openBrowser: boolean;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,9 @@ export class CliLoginFlow {
|
||||
|
||||
async authorize(origin: string): Promise<string> {
|
||||
const authorization = await this.options.hub.startCliAuthorization(origin);
|
||||
this.options.instructions(authorization.verificationUri, authorization.userCode);
|
||||
this.options.instructions(
|
||||
`Open ${authorization.verificationUriComplete} to approve CLI login (code: ${authorization.userCode})`,
|
||||
);
|
||||
if (this.options.openBrowser) {
|
||||
await this.options.browser.open(authorization.verificationUriComplete).catch(() => undefined);
|
||||
}
|
||||
@@ -84,8 +86,8 @@ export function createCliLoginFlow(hub: HubHttpClient): CliLoginFlow {
|
||||
now: Date.now,
|
||||
},
|
||||
browser: new SystemBrowser(),
|
||||
instructions(verificationUri, userCode) {
|
||||
process.stderr.write(`Open ${verificationUri} and enter code ${userCode}\n`);
|
||||
instructions(message) {
|
||||
process.stderr.write(`${message}\n`);
|
||||
},
|
||||
openBrowser: process.stderr.isTTY === true,
|
||||
});
|
||||
|
||||
@@ -150,6 +150,10 @@ function describeVersion(inspection: ProviderInstallationInspection): string {
|
||||
return inspection.version?.trim() || "unknown";
|
||||
}
|
||||
|
||||
function toProviderLaunch(launch: ProviderInstallationLaunch): ProviderLaunch {
|
||||
return { command: launch.command, args: launch.args, env: launch.env };
|
||||
}
|
||||
|
||||
class ProviderRuntime {
|
||||
private connection: ProviderConnection | null = null;
|
||||
connectedLaunch: ProviderLaunch | undefined;
|
||||
@@ -212,13 +216,13 @@ class ProviderRuntime {
|
||||
const launch = await this.resolveEffectiveLaunch();
|
||||
if (!launch) return undefined;
|
||||
if (!launch.resolved) throw new Error(`${launch.command} not found on PATH`);
|
||||
return { command: launch.command, args: launch.args, env: launch.env };
|
||||
return toProviderLaunch(launch);
|
||||
}
|
||||
|
||||
async resolveUsageLaunch(): Promise<ProviderLaunch | undefined> {
|
||||
const launch = await this.resolveEffectiveLaunch();
|
||||
if (!launch?.resolved) return undefined;
|
||||
return { command: launch.command, args: launch.args, env: launch.env };
|
||||
return toProviderLaunch(launch);
|
||||
}
|
||||
|
||||
async inspectInstallation(signal: AbortSignal): Promise<ProviderInspection> {
|
||||
@@ -281,7 +285,11 @@ class ProviderRuntime {
|
||||
async catalogCacheKey(options: FetchCatalogOptions): Promise<string | undefined> {
|
||||
const callback = this.registration.getCatalogCacheKey;
|
||||
if (!callback) return undefined;
|
||||
return callback({ ...options, launch: await this.resolveLaunch() });
|
||||
const launch = await this.resolveEffectiveLaunch();
|
||||
// A missing executable gets its own catalogue, so refresh reports it unavailable instead of
|
||||
// failing the key or reusing a catalogue cached while it was installed.
|
||||
if (launch && !launch.resolved) return JSON.stringify(["unresolved", launch.command]);
|
||||
return callback({ ...options, launch: launch && toProviderLaunch(launch) });
|
||||
}
|
||||
|
||||
get negotiatedCapabilities(): readonly string[] {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import pino from "pino";
|
||||
import { homedir } from "node:os";
|
||||
import { resolve } from "node:path";
|
||||
import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { homedir, tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import type {
|
||||
ProviderEvent,
|
||||
@@ -8,6 +9,7 @@ import type {
|
||||
ProviderLaunch,
|
||||
} from "@getpaseo/plugin/server/provider";
|
||||
|
||||
import { isPlatform } from "../../test-utils/platform.js";
|
||||
import { createTestLogger } from "../../test-utils/test-logger.js";
|
||||
import type {
|
||||
AgentClient,
|
||||
@@ -217,6 +219,97 @@ describe("ProviderSnapshotManager public surface", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("reports a plugin provider whose command is not installed as unavailable", async () => {
|
||||
const manager = new ProviderSnapshotManager({ logger: createTestLogger() });
|
||||
manager.replacePluginProviders([
|
||||
{
|
||||
id: "uninstalled-plugin",
|
||||
label: "Uninstalled plugin",
|
||||
command: ["paseo-test-command-that-is-not-installed"],
|
||||
async getCatalogCacheKey({ launch }) {
|
||||
if (!launch) throw new Error("requires a daemon-resolved executable");
|
||||
return launch.command;
|
||||
},
|
||||
async status({ launch }) {
|
||||
return launch ? { available: true } : { available: false, diagnostic: "Install it" };
|
||||
},
|
||||
async connect() {
|
||||
throw new Error("an uninstalled provider is never connected");
|
||||
},
|
||||
},
|
||||
]);
|
||||
try {
|
||||
const entry = await manager.getProvider({
|
||||
provider: "uninstalled-plugin",
|
||||
cwd: "/tmp/project",
|
||||
wait: true,
|
||||
});
|
||||
expect(entry).toMatchObject({ status: "unavailable" });
|
||||
expect(entry.error).toBeUndefined();
|
||||
} finally {
|
||||
manager.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
test.skipIf(isPlatform("win32"))(
|
||||
"reports a workspace-cached plugin provider as unavailable after its executable is removed",
|
||||
async () => {
|
||||
const directory = mkdtempSync(join(tmpdir(), "paseo-removed-plugin-"));
|
||||
const executable = join(directory, "removed-plugin");
|
||||
writeFileSync(executable, "#!/bin/sh\necho 1.0.0\n");
|
||||
chmodSync(executable, 0o755);
|
||||
const manager = new ProviderSnapshotManager({ logger: createTestLogger() });
|
||||
manager.replacePluginProviders([
|
||||
{
|
||||
id: "removed-plugin",
|
||||
label: "Removed plugin",
|
||||
command: [executable],
|
||||
// undefined asks the snapshot manager to cache the catalogue per workspace.
|
||||
async getCatalogCacheKey() {
|
||||
return undefined;
|
||||
},
|
||||
async status({ launch }) {
|
||||
return launch ? { available: true } : { available: false, diagnostic: "Install it" };
|
||||
},
|
||||
async connect() {
|
||||
let listener: ((event: ProviderEvent) => void) | undefined;
|
||||
return {
|
||||
version: 1,
|
||||
capabilities: [],
|
||||
async send(input) {
|
||||
if (input.type === "catalog")
|
||||
listener?.({
|
||||
type: "catalog",
|
||||
requestId: input.requestId,
|
||||
catalog: { models: [{ id: "model", label: "Model" }], modes: [] },
|
||||
});
|
||||
},
|
||||
onEvent(next) {
|
||||
listener = next;
|
||||
return () => {
|
||||
listener = undefined;
|
||||
};
|
||||
},
|
||||
async close() {},
|
||||
};
|
||||
},
|
||||
},
|
||||
]);
|
||||
try {
|
||||
const read = () =>
|
||||
manager.getProvider({ provider: "removed-plugin", cwd: "/tmp/project", wait: true });
|
||||
expect(await read()).toMatchObject({ status: "ready" });
|
||||
|
||||
rmSync(directory, { recursive: true, force: true });
|
||||
|
||||
expect(await read()).toMatchObject({ status: "unavailable" });
|
||||
} finally {
|
||||
manager.destroy();
|
||||
rmSync(directory, { recursive: true, force: true });
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
test("carries a plugin provider icon and docs link in snapshot metadata", () => {
|
||||
const iconSvg = '<svg viewBox="0 0 24 24"><path d="M4 4h16v16H4z" /></svg>';
|
||||
const docsUrl = "https://example.com/docs";
|
||||
|
||||
Reference in New Issue
Block a user