mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 03:49:31 +00:00
fix(link): add pi and cursor to agent auto-detection (#3309)
KNOWN_AGENTS was missing pi and cursor, so `spawn link` could not auto-detect these agents on remote servers. Also adds a binary-name mapping for cursor (whose CLI binary is `agent`). Bump CLI to 1.0.14. Agent: code-health Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a179fdbbab
commit
84331173fd
2 changed files with 17 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@openrouter/spawn",
|
||||
"version": "1.0.13",
|
||||
"version": "1.0.14",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"spawn": "cli.js"
|
||||
|
|
|
|||
|
|
@ -71,14 +71,28 @@ const KNOWN_AGENTS = [
|
|||
"kilocode",
|
||||
"hermes",
|
||||
"junie",
|
||||
"pi",
|
||||
"cursor",
|
||||
] as const;
|
||||
type KnownAgent = (typeof KNOWN_AGENTS)[number];
|
||||
|
||||
/** Map manifest agent key → CLI binary name (only where they differ). */
|
||||
const AGENT_BINARY: Partial<Record<KnownAgent, string>> = {
|
||||
cursor: "agent",
|
||||
};
|
||||
|
||||
/** Get the CLI binary name for an agent (defaults to the agent key itself). */
|
||||
function agentBinary(agent: KnownAgent): string {
|
||||
return AGENT_BINARY[agent] ?? agent;
|
||||
}
|
||||
|
||||
/** Auto-detect which agent is installed/running on the remote host. */
|
||||
function detectAgent(host: string, user: string, keyOpts: string[], runCmd: SshCommandFn): string | null {
|
||||
// First: check running processes
|
||||
// Note: cursor's binary is "agent" which is too generic for ps grep, so it's
|
||||
// detected only via the installed-binary check below.
|
||||
const psCmd =
|
||||
"ps aux 2>/dev/null | grep -oE 'claude(-code)?|openclaw|codex|opencode|kilocode|hermes|junie' | grep -v grep | head -1 || true";
|
||||
"ps aux 2>/dev/null | grep -oE 'claude(-code)?|openclaw|codex|opencode|kilocode|hermes|junie|pi' | grep -v grep | head -1 || true";
|
||||
const psOut = runCmd(host, user, keyOpts, psCmd);
|
||||
if (psOut) {
|
||||
const match = KNOWN_AGENTS.find((b: KnownAgent) => psOut.includes(b));
|
||||
|
|
@ -89,7 +103,7 @@ function detectAgent(host: string, user: string, keyOpts: string[], runCmd: SshC
|
|||
|
||||
// Second: check installed binaries — one SSH call per agent to avoid shell injection
|
||||
for (const agent of KNOWN_AGENTS) {
|
||||
const whichOut = runCmd(host, user, keyOpts, `command -v ${agent}`);
|
||||
const whichOut = runCmd(host, user, keyOpts, `command -v ${agentBinary(agent)}`);
|
||||
if (whichOut) {
|
||||
return agent;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue