mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-02 19:08:33 +01:00
merge: apply core provider review fixes to setup and qualification
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
commit
ec1e5a330b
8 files changed
+65
-9
No files matched your search
@@ -68,8 +68,9 @@ export function managedProviderRouting(
|
||||
env.OPENROUTER_API_KEY = route.kind === "openrouter" ? credential : "";
|
||||
config.provider = route.kind === "openrouter" ? "openrouter" : "auto";
|
||||
// Hermes now reads custom endpoint routing from config.yaml, not OPENAI_BASE_URL.
|
||||
env.PAPERCLIP_AI_PROVIDER_KEY = credential;
|
||||
hermesConfig = `model:\n provider: ${route.kind === "openrouter" ? '"openrouter"' : '"custom"'}\n default: ${JSON.stringify(model)}\n base_url: ${JSON.stringify(baseUrl)}\n api_mode: "chat_completions"\n${route.auth === "none" ? "" : ' api_key: "${PAPERCLIP_AI_PROVIDER_KEY}"\n'}`;
|
||||
// Hermes strips OPENAI_API_KEY from terminal children. A custom variable
|
||||
// would expose the reusable gateway key to task-controlled shell commands.
|
||||
hermesConfig = `model:\n provider: ${route.kind === "openrouter" ? '"openrouter"' : '"custom"'}\n default: ${JSON.stringify(model)}\n base_url: ${JSON.stringify(baseUrl)}\n api_mode: "chat_completions"\n${route.auth === "none" ? "" : ' api_key: "${OPENAI_API_KEY}"\n'}`;
|
||||
}
|
||||
return { env, config, codexConfig, hermesConfig };
|
||||
}
|
||||
@@ -61,8 +61,8 @@ describe.skipIf(process.platform === "win32")("local browser subscription login"
|
||||
let pid = 0;
|
||||
await vi.waitFor(async () => { pid = Number(await readFile(path.join(home, "login.pid"), "utf8")); expect(pid).toBeGreaterThan(0); });
|
||||
login.abort();
|
||||
await vi.waitFor(() => expect(login.outcome).toBe("failure"));
|
||||
await vi.waitFor(() => expect(() => process.kill(pid, 0)).toThrow());
|
||||
await vi.waitFor(() => expect(login.outcome).toBe("failure"), { timeout: 5000 });
|
||||
await vi.waitFor(() => expect(() => process.kill(pid, 0)).toThrow(), { timeout: 5000 });
|
||||
});
|
||||
|
||||
it("cancels Claude while waiting for its browser code and terminates the provider", async () => {
|
||||
@@ -77,15 +77,15 @@ describe.skipIf(process.platform === "win32")("local browser subscription login"
|
||||
await vi.waitFor(() => expect(login.authorizationUrl).toBeDefined());
|
||||
const pid = Number(await readFile(path.join(home, "login.pid"), "utf8"));
|
||||
login.abort();
|
||||
await vi.waitFor(() => expect(login.outcome).toBe("failure"));
|
||||
await vi.waitFor(() => expect(() => process.kill(pid, 0)).toThrow());
|
||||
await vi.waitFor(() => expect(login.outcome).toBe("failure"), { timeout: 5000 });
|
||||
await vi.waitFor(() => expect(() => process.kill(pid, 0)).toThrow(), { timeout: 5000 });
|
||||
await expect(readFile(path.join(home, ".credentials.json"))).rejects.toThrow();
|
||||
});
|
||||
|
||||
it("returns a fixed failure without exposing provider error output", async () => {
|
||||
const home = await fakeCli("codex", 'echo "private-provider-error" >&2\nexit 1');
|
||||
const login = startLocalBrowserLogin("openai", home);
|
||||
await vi.waitFor(() => expect(login.outcome).toBe("failure"));
|
||||
await vi.waitFor(() => expect(login.outcome).toBe("failure"), { timeout: 5000 });
|
||||
expect(JSON.stringify(login)).not.toContain("private-provider-error");
|
||||
expect(login.authorizationUrl).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -168,7 +168,11 @@ export function localAiLoginService(db: Db) {
|
||||
} catch {
|
||||
const login = id ? browserLogins.get(id) : undefined;
|
||||
return { status: "sign_in_required", authorizationUrl: login?.authorizationUrl, code: login?.code,
|
||||
...(login?.outcome === "failure" ? { error: "Sign-in ended before the account was connected. Start sign-in again." } : {}) };
|
||||
...(!login && intent.provider !== "xai"
|
||||
? { error: "The server restarted during sign-in. Start sign-in again." }
|
||||
: login?.outcome === "failure"
|
||||
? { error: "Sign-in ended before the account was connected. Start sign-in again." }
|
||||
: {}) };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user