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:
@@ -15,7 +15,10 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
fetchPaperclipAgents,
|
||||
fetchPaperclipCliAgents,
|
||||
fetchPaperclipCliCompanies,
|
||||
fetchPaperclipCliDiscovery,
|
||||
fetchPaperclipCliStatus,
|
||||
fetchPaperclipCompanies,
|
||||
fetchPaperclipStatus,
|
||||
fetchPluginSettings,
|
||||
@@ -190,13 +193,29 @@ export function PaperclipRuntimeCard() {
|
||||
}, [settings.transport, settings.cliConfigPath]);
|
||||
|
||||
// Probe + load companies/agents whenever effective auth changes.
|
||||
// In CLI mode we shell out via the cli-* endpoints instead of hitting the
|
||||
// Paperclip HTTP API directly, so the test exercises the same auth path the
|
||||
// user has onboarded with `paperclipai`.
|
||||
const useCli = settings.transport === "cli";
|
||||
const cliOpts = useMemo(
|
||||
() => ({
|
||||
cliBinaryPath: settings.cliBinaryPath || undefined,
|
||||
cliConfigPath: settings.cliConfigPath || undefined,
|
||||
}),
|
||||
[settings.cliBinaryPath, settings.cliConfigPath],
|
||||
);
|
||||
|
||||
const probe = useCallback(async (): Promise<PaperclipProviderStatus | null> => {
|
||||
if (!effectiveAuth.apiUrl) return null;
|
||||
if (!useCli && !effectiveAuth.apiUrl) return null;
|
||||
try {
|
||||
const next = await fetchPaperclipStatus(effectiveAuth);
|
||||
const next = useCli
|
||||
? await fetchPaperclipCliStatus(cliOpts)
|
||||
: await fetchPaperclipStatus(effectiveAuth);
|
||||
if (mountedRef.current) setStatus(next);
|
||||
// Then load companies + agents for the picker.
|
||||
const cs = await fetchPaperclipCompanies(effectiveAuth);
|
||||
const cs = useCli
|
||||
? await fetchPaperclipCliCompanies(cliOpts)
|
||||
: await fetchPaperclipCompanies(effectiveAuth);
|
||||
if (!mountedRef.current) return next;
|
||||
setCompanies(cs);
|
||||
// Auto-pick a company: keep current selection if it exists in cs;
|
||||
@@ -210,10 +229,9 @@ export function PaperclipRuntimeCard() {
|
||||
}
|
||||
}
|
||||
if (picked) {
|
||||
const ag = await fetchPaperclipAgents({
|
||||
...effectiveAuth,
|
||||
companyId: picked,
|
||||
});
|
||||
const ag = useCli
|
||||
? await fetchPaperclipCliAgents({ ...cliOpts, companyId: picked })
|
||||
: await fetchPaperclipAgents({ ...effectiveAuth, companyId: picked });
|
||||
if (mountedRef.current) {
|
||||
setAgents(ag);
|
||||
// Auto-pick agent the same way.
|
||||
@@ -234,9 +252,16 @@ export function PaperclipRuntimeCard() {
|
||||
setToast({ kind: "err", message: err instanceof Error ? err.message : String(err) });
|
||||
return null;
|
||||
}
|
||||
// Deliberately keyed only on the URL/key — companyId/agentId changes are
|
||||
// handled by a separate effect below.
|
||||
}, [effectiveAuth.apiUrl, effectiveAuth.apiKey, settings.companyId, settings.agentId]);
|
||||
// Deliberately keyed only on transport+auth — companyId/agentId changes
|
||||
// are handled by a separate effect below.
|
||||
}, [
|
||||
useCli,
|
||||
cliOpts,
|
||||
effectiveAuth.apiUrl,
|
||||
effectiveAuth.apiKey,
|
||||
settings.companyId,
|
||||
settings.agentId,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
void probe();
|
||||
@@ -244,25 +269,33 @@ export function PaperclipRuntimeCard() {
|
||||
|
||||
// Reload agent list when the user manually changes companyId.
|
||||
useEffect(() => {
|
||||
if (!effectiveAuth.apiUrl || !settings.companyId) {
|
||||
if (!settings.companyId) {
|
||||
setAgents([]);
|
||||
return;
|
||||
}
|
||||
if (!useCli && !effectiveAuth.apiUrl) {
|
||||
setAgents([]);
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
fetchPaperclipAgents({
|
||||
...effectiveAuth,
|
||||
companyId: settings.companyId,
|
||||
})
|
||||
.then((ag) => {
|
||||
if (!cancelled && mountedRef.current) setAgents(ag);
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled && mountedRef.current) setAgents([]);
|
||||
});
|
||||
const p = useCli
|
||||
? fetchPaperclipCliAgents({ ...cliOpts, companyId: settings.companyId })
|
||||
: fetchPaperclipAgents({ ...effectiveAuth, companyId: settings.companyId });
|
||||
p.then((ag) => {
|
||||
if (!cancelled && mountedRef.current) setAgents(ag);
|
||||
}).catch(() => {
|
||||
if (!cancelled && mountedRef.current) setAgents([]);
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [effectiveAuth.apiUrl, effectiveAuth.apiKey, settings.companyId]);
|
||||
}, [
|
||||
useCli,
|
||||
cliOpts,
|
||||
effectiveAuth.apiUrl,
|
||||
effectiveAuth.apiKey,
|
||||
settings.companyId,
|
||||
]);
|
||||
|
||||
const buildPayload = useCallback((): Record<string, unknown> => {
|
||||
const payload: Record<string, unknown> = {
|
||||
|
||||
Reference in New Issue
Block a user