feat(paperclip-runtime): route Paperclip calls through paperclipai CLI in Local CLI mode

The Paperclip runtime card's Local CLI tab previously only derived an apiUrl
from the local config and then made HTTP calls itself, so the Test action and
the company/agent pickers ignored the user's onboarded CLI auth context.

Add CLI-backed variants for every Paperclip call that has a `paperclipai`
counterpart, and route through them when transport=cli — both from the
settings card and from the runtime adapter's prompt path.

- New plugin functions spawning `paperclipai … --json`:
  * probePaperclipViaCli, listCompaniesViaCli, listCompanyAgentsViaCli
    (settings card test + pickers)
  * createIssueViaCli, getIssueViaCli, agentsMeViaCli (runtime hot path)
- New dashboard routes: /providers/paperclip/cli-status, /cli-companies,
  /cli-agents (read-only façades over the plugin's CLI helpers)
- PaperclipRuntimeCard: branches on transport=cli to use the cli-* fetchers
- PaperclipRuntimeAdapter: stores transport on the session and routes
  createIssue/getIssue + identity derivation through CLI variants in CLI mode;
  raises a clear error when agentId is unset in CLI mode (paperclipai has no
  /agents/me equivalent)
- getIssueComments / wakeAgent / getRunEvents stay on HTTP (no matching
  paperclipai subcommands) and continue to use the apiKey discovered from
  the local paperclipai config, so CLI mode still works end-to-end
- Tests: 9 new paperclip-client tests covering each CLI variant + 5 new
  adapter tests for the Local-CLI transport branch (64/64 plugin tests pass)
- Update routes.test for the existing BUNDLED_PLUGIN_RUNTIMES fallback so
  the bundled hermes/openclaw/paperclip entries are expected alongside
  installed plugins

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-27 23:06:20 -07:00
parent 08a4ae01f7
commit a6697ee7ca
11 changed files with 968 additions and 43 deletions

View File

@@ -500,7 +500,7 @@ describe("GET /api/plugins/runtimes", () => {
return app;
}
it("returns plugin runtime metadata with 200 status", async () => {
it("returns plugin runtime metadata with 200 status, with installed entries overriding bundled fallbacks by runtimeId", async () => {
const pluginLoader = {
getPluginRuntimes: () => [
{
@@ -521,22 +521,29 @@ describe("GET /api/plugins/runtimes", () => {
const res = await GET(buildApp(pluginLoader), "/api/plugins/runtimes");
expect(res.status).toBe(200);
expect(res.body).toEqual([
{
pluginId: "plugin-openclaw",
runtimeId: "openclaw",
name: "OpenClaw Runtime",
description: "Executes OpenClaw prompts",
version: "1.2.3",
},
]);
const body = res.body as Array<{ pluginId: string; runtimeId: string }>;
// Installed runtime appears first and shadows the bundled openclaw entry.
expect(body[0]).toEqual({
pluginId: "plugin-openclaw",
runtimeId: "openclaw",
name: "OpenClaw Runtime",
description: "Executes OpenClaw prompts",
version: "1.2.3",
});
const ids = body.map((r) => r.runtimeId);
expect(ids).toContain("hermes");
expect(ids).toContain("paperclip");
// Only one openclaw entry (installed wins over bundled).
expect(ids.filter((id) => id === "openclaw")).toHaveLength(1);
});
it("returns an empty array with 200 status when plugin runtimes are unavailable", async () => {
it("returns the bundled plugin runtime fallbacks when no plugins are installed", async () => {
const res = await GET(buildApp(), "/api/plugins/runtimes");
expect(res.status).toBe(200);
expect(res.body).toEqual([]);
const body = res.body as Array<{ pluginId: string; runtimeId: string }>;
const ids = body.map((r) => r.runtimeId).sort();
expect(ids).toEqual(["hermes", "openclaw", "paperclip"]);
});
});