@parlor/agent-host 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter-launch.d.ts.map +1 -1
- package/dist/adapter-launch.js +6 -6
- package/dist/adapter-launch.js.map +1 -1
- package/dist/agents.d.ts +6 -0
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +8 -0
- package/dist/agents.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-launch.d.ts","sourceRoot":"","sources":["../src/adapter-launch.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"adapter-launch.d.ts","sourceRoot":"","sources":["../src/adapter-launch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAKjF,wBAAgB,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG;IAChD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,CAoBA;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,YAAY,EACrB,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACpC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAOjC"}
|
package/dist/adapter-launch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ADAPTER_BINARY_ENV } from "./agents.js";
|
|
1
|
+
import { ADAPTER_BINARY_ENV, ADAPTER_ENV } from "./agents.js";
|
|
2
2
|
import { adapterKey, embeddedAdapters } from "./embedded.js";
|
|
3
3
|
import { selfInvocation } from "./self.js";
|
|
4
4
|
import { resolveBinary } from "./shell-path.js";
|
|
@@ -24,12 +24,12 @@ export function commandOf(profile) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
export async function launchEnvironment(profile, env) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const adapter = profile.launch.kind === "adapter" ? profile.launch.package : undefined;
|
|
28
|
+
const own = { ...env, ...(adapter ? ADAPTER_ENV[adapter] : undefined) };
|
|
29
|
+
const variable = adapter ? ADAPTER_BINARY_ENV[adapter] : undefined;
|
|
30
30
|
if (variable === undefined || env[variable] !== undefined)
|
|
31
|
-
return
|
|
31
|
+
return own;
|
|
32
32
|
const found = await resolveBinary(profile.binary, env.PATH ?? "");
|
|
33
|
-
return found === undefined ?
|
|
33
|
+
return found === undefined ? own : { ...own, [variable]: found };
|
|
34
34
|
}
|
|
35
35
|
//# sourceMappingURL=adapter-launch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-launch.js","sourceRoot":"","sources":["../src/adapter-launch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter-launch.js","sourceRoot":"","sources":["../src/adapter-launch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAqB,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,UAAU,SAAS,CAAC,OAAqB;IAI7C,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACxE,CAAC;IACD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,UAA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AAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAClE,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;AACnE,CAAC","sourcesContent":["import { ADAPTER_BINARY_ENV, ADAPTER_ENV, type AgentProfile } from \"./agents.js\";\nimport { adapterKey, embeddedAdapters } from \"./embedded.js\";\nimport { selfInvocation } from \"./self.js\";\nimport { resolveBinary } from \"./shell-path.js\";\n\nexport function commandOf(profile: AgentProfile): {\n readonly command: string;\n readonly args: readonly string[];\n} {\n if (profile.launch.kind === \"native\") {\n return { command: profile.launch.command, args: profile.launch.args };\n }\n const embedded = embeddedAdapters.get(adapterKey(profile.launch));\n if (embedded !== undefined) {\n const self = selfInvocation([\"adapter\", embedded]);\n return {\n command: self.command,\n args: [...self.args, ...(profile.launch.args ?? [])],\n };\n }\n return {\n command: \"npx\",\n args: [\n \"--yes\",\n `${profile.launch.package}@${profile.launch.version}`,\n ...(profile.launch.args ?? []),\n ],\n };\n}\n\nexport async function launchEnvironment(\n profile: AgentProfile,\n env: Readonly<Record<string, string>>,\n): Promise<Record<string, string>> {\n const adapter = profile.launch.kind === \"adapter\" ? profile.launch.package : undefined;\n const own = { ...env, ...(adapter ? ADAPTER_ENV[adapter] : undefined) };\n const variable = adapter ? ADAPTER_BINARY_ENV[adapter] : undefined;\n if (variable === undefined || env[variable] !== undefined) return own;\n const found = await resolveBinary(profile.binary, env.PATH ?? \"\");\n return found === undefined ? own : { ...own, [variable]: found };\n}\n"]}
|
package/dist/agents.d.ts
CHANGED
|
@@ -29,6 +29,12 @@ export type AgentLaunch = {
|
|
|
29
29
|
export declare const AGENT_PROFILES: readonly AgentProfile[];
|
|
30
30
|
/** Where each adapter looks for the agent CLI it drives; its own search does not survive a single executable. */
|
|
31
31
|
export declare const ADAPTER_BINARY_ENV: Readonly<Record<string, string>>;
|
|
32
|
+
/**
|
|
33
|
+
* What each adapter needs set to serve an app's turn. Codex's adapter skips a requested MCP
|
|
34
|
+
* server whose name the user's own config already uses, so a turn would reach the app through
|
|
35
|
+
* the registration for agents outside the sidebar instead, which asks before the first change.
|
|
36
|
+
*/
|
|
37
|
+
export declare const ADAPTER_ENV: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
32
38
|
export declare const DETECT_TIMEOUT_MS = 3000;
|
|
33
39
|
/** Built-ins plus the user's own `agents.json`, which only this computer's user edits. */
|
|
34
40
|
export declare function loadProfiles(file: string): Promise<readonly AgentProfile[]>;
|
package/dist/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI9C,mGAAmG;AACnG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,gEAAgE;IAChE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAC/C,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC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CAAC,CAEtB"}
|
package/dist/agents.js
CHANGED
|
@@ -35,6 +35,14 @@ export const ADAPTER_BINARY_ENV = {
|
|
|
35
35
|
"@agentclientprotocol/claude-agent-acp": "CLAUDE_CODE_EXECUTABLE",
|
|
36
36
|
"@agentclientprotocol/codex-acp": "CODEX_PATH",
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* What each adapter needs set to serve an app's turn. Codex's adapter skips a requested MCP
|
|
40
|
+
* server whose name the user's own config already uses, so a turn would reach the app through
|
|
41
|
+
* the registration for agents outside the sidebar instead, which asks before the first change.
|
|
42
|
+
*/
|
|
43
|
+
export const ADAPTER_ENV = {
|
|
44
|
+
"@agentclientprotocol/codex-acp": { DISABLE_MCP_CONFIG_FILTERING: "true" },
|
|
45
|
+
};
|
|
38
46
|
export const DETECT_TIMEOUT_MS = 3_000;
|
|
39
47
|
const isFields = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
40
48
|
const isStrings = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
package/dist/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAiC5C,MAAM,CAAC,MAAM,cAAc,GAA4B;IACrD;QACE,EAAE,EAAE,QAAQ;QACZ,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE;YACN,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,uCAAuC;YAChD,OAAO,EAAE,QAAQ;SAClB;QACD,MAAM,EAAE,QAAQ;KACjB;IACD;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,OAAO;QACb,MAAM,EAAE;YACN,IAAI,EAAE,SAAS;YACf,OAAO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:child_process\";\nimport { readFile } from \"node:fs/promises\";\n\nimport type { AgentInfo } from \"@parlor/chat\";\n\nimport { agentPath } from \"./shell-path.js\";\n\n/** The app picks an agent by `id` only, never by command, so no remote party chooses what runs. */\nexport interface AgentProfile {\n readonly id: string;\n readonly name: string;\n readonly launch: AgentLaunch;\n /** The CLI behind it, for the installed-and-logged-in check. */\n readonly binary: string;\n /**\n * Where a desktop app ships the same CLI, for a computer with the app and no CLI on its\n * PATH: the app reads the CLI's own settings, so the agent behaves the same either way.\n */\n readonly apps?: readonly string[] | undefined;\n}\n\n/**\n * `adapter`: an npm ACP adapter at an exact version, run from the copy this build embeds\n * and else through `npx`. `native`: an agent CLI that speaks ACP itself, found on the login-shell PATH.\n */\nexport type AgentLaunch =\n | {\n readonly kind: \"adapter\";\n readonly package: string;\n readonly version: string;\n readonly args?: readonly string[] | undefined;\n }\n | {\n readonly kind: \"native\";\n readonly command: string;\n readonly args: readonly string[];\n };\n\nexport const AGENT_PROFILES: readonly AgentProfile[] = [\n {\n id: \"claude\",\n name: \"Claude Code\",\n launch: {\n kind: \"adapter\",\n package: \"@agentclientprotocol/claude-agent-acp\",\n version: \"0.93.0\",\n },\n binary: \"claude\",\n },\n {\n id: \"codex\",\n name: \"Codex\",\n launch: {\n kind: \"adapter\",\n package: \"@agentclientprotocol/codex-acp\",\n version: \"2.2.2\",\n },\n binary: \"codex\",\n apps: [\"/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex\"],\n },\n {\n id: \"gemini\",\n name: \"Gemini CLI\",\n launch: { kind: \"native\", command: \"gemini\", args: [\"--acp\"] },\n binary: \"gemini\",\n },\n];\n\n/** Where each adapter looks for the agent CLI it drives; its own search does not survive a single executable. */\nexport const ADAPTER_BINARY_ENV: Readonly<Record<string, string>> = {\n \"@agentclientprotocol/claude-agent-acp\": \"CLAUDE_CODE_EXECUTABLE\",\n \"@agentclientprotocol/codex-acp\": \"CODEX_PATH\",\n};\n\nexport const DETECT_TIMEOUT_MS = 3_000;\n\ntype Fields = Readonly<Record<string, unknown>>;\n\nconst isFields = (value: unknown): value is Fields =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isStrings = (value: unknown): value is string[] =>\n Array.isArray(value) && value.every((entry) => typeof entry === \"string\");\n\nfunction launchOf(value: unknown): AgentLaunch | undefined {\n if (!isFields(value)) return undefined;\n if (\n value.kind === \"native\" &&\n typeof value.command === \"string\" &&\n isStrings(value.args)\n ) {\n return { kind: \"native\", command: value.command, args: value.args };\n }\n if (\n value.kind === \"adapter\" &&\n typeof value.package === \"string\" &&\n typeof value.version === \"string\" &&\n (value.args === undefined || isStrings(value.args))\n ) {\n return {\n kind: \"adapter\",\n package: value.package,\n version: value.version,\n args: value.args,\n };\n }\n return undefined;\n}\n\nfunction profileOf(value: unknown): AgentProfile | undefined {\n if (!isFields(value)) return undefined;\n const launch = launchOf(value.launch);\n const { id, name, binary, apps } = value;\n if (!launch || typeof id !== \"string\" || typeof name !== \"string\") return undefined;\n if (typeof binary !== \"string\" || id === \"\") return undefined;\n if (apps !== undefined && !isStrings(apps)) return undefined;\n return { id, name, launch, binary, ...(apps ? { apps } : {}) };\n}\n\n/** Built-ins plus the user's own `agents.json`, which only this computer's user edits. */\nexport async function loadProfiles(file: string): Promise<readonly AgentProfile[]> {\n let text: string;\n try {\n text = await readFile(file, \"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return AGENT_PROFILES;\n throw error;\n }\n const listed: unknown = JSON.parse(text);\n if (!Array.isArray(listed))\n throw new Error(`${file} must hold a JSON array of agent profiles.`);\n const own = listed.map((entry, at) => {\n const profile = profileOf(entry);\n if (!profile) throw new Error(`${file}: entry ${at + 1} is not an agent profile.`);\n return profile;\n });\n const ids = new Set(own.map((profile) => profile.id));\n return [...AGENT_PROFILES.filter((profile) => !ids.has(profile.id)), ...own];\n}\n\nfunction versionOf(binary: string, path: string): Promise<string | \"missing\" | \"broken\"> {\n return new Promise((resolve) => {\n execFile(\n binary,\n [\"--version\"],\n { timeout: DETECT_TIMEOUT_MS, env: { ...process.env, PATH: path } },\n (error, stdout) => {\n if ((error as NodeJS.ErrnoException | null)?.code === \"ENOENT\")\n resolve(\"missing\");\n else if (error) resolve(\"broken\");\n else resolve(stdout.trim());\n },\n );\n });\n}\n\n/** The agents installed here, each with its profile's `binary` set to the CLI that answered. */\nexport interface FoundAgents {\n readonly agents: readonly AgentInfo[];\n readonly profiles: readonly AgentProfile[];\n}\n\n/**\n * Looks for each agent's CLI on the login-shell PATH, then inside the desktop apps that ship\n * it. An agent found nowhere is left out; the profiles it returns run what was found.\n */\nexport async function findAgents(\n profiles: readonly AgentProfile[],\n): Promise<FoundAgents> {\n const path = await agentPath();\n const found = await Promise.all(\n profiles.map(async (profile) => {\n let binary = profile.binary;\n let output = await versionOf(binary, path);\n for (const app of profile.apps ?? []) {\n if (output !== \"missing\") break;\n binary = app;\n output = await versionOf(app, path);\n }\n if (output === \"missing\") return undefined;\n const resolved = binary === profile.binary ? profile : { ...profile, binary };\n if (output === \"broken\") {\n const info: AgentInfo = {\n id: profile.id,\n name: profile.name,\n ready: false,\n problem: `\\`${binary} --version\\` failed: check that ${profile.name} runs in a terminal.`,\n };\n return { info, profile: resolved };\n }\n const version = /\\d+\\.\\d+\\.\\d+[\\w.-]*/.exec(output)?.[0];\n const info: AgentInfo = {\n id: profile.id,\n name: profile.name,\n ready: true,\n ...(version ? { version } : {}),\n };\n return { info, profile: resolved };\n }),\n );\n const present = found.filter((entry) => entry !== undefined);\n return {\n agents: present.map((entry) => entry.info),\n profiles: profiles.map(\n (profile) =>\n present.find((entry) => entry.profile.id === profile.id)?.profile ?? profile,\n ),\n };\n}\n\n/** What `hostReport` sends: the installed agents; one that is not installed is left out. */\nexport async function detectAgents(\n profiles: readonly AgentProfile[],\n): Promise<AgentInfo[]> {\n return [...(await findAgents(profiles)).agents];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"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CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IAC7D,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;QAC1C,QAAQ,EAAE,QAAQ,CAAC,GAAG,CACpB,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC,EAAE,OAAO,IAAI,OAAO,CAC/E;KACF,CAAC;AACJ,CAAC;AAED,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAiC;IAEjC,OAAO,CAAC,GAAG,CAAC,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC","sourcesContent":["import { execFile } from \"node:child_process\";\nimport { readFile } from \"node:fs/promises\";\n\nimport type { AgentInfo } from \"@parlor/chat\";\n\nimport { agentPath } from \"./shell-path.js\";\n\n/** The app picks an agent by `id` only, never by command, so no remote party chooses what runs. */\nexport interface AgentProfile {\n readonly id: string;\n readonly name: string;\n readonly launch: AgentLaunch;\n /** The CLI behind it, for the installed-and-logged-in check. */\n readonly binary: string;\n /**\n * Where a desktop app ships the same CLI, for a computer with the app and no CLI on its\n * PATH: the app reads the CLI's own settings, so the agent behaves the same either way.\n */\n readonly apps?: readonly string[] | undefined;\n}\n\n/**\n * `adapter`: an npm ACP adapter at an exact version, run from the copy this build embeds\n * and else through `npx`. `native`: an agent CLI that speaks ACP itself, found on the login-shell PATH.\n */\nexport type AgentLaunch =\n | {\n readonly kind: \"adapter\";\n readonly package: string;\n readonly version: string;\n readonly args?: readonly string[] | undefined;\n }\n | {\n readonly kind: \"native\";\n readonly command: string;\n readonly args: readonly string[];\n };\n\nexport const AGENT_PROFILES: readonly AgentProfile[] = [\n {\n id: \"claude\",\n name: \"Claude Code\",\n launch: {\n kind: \"adapter\",\n package: \"@agentclientprotocol/claude-agent-acp\",\n version: \"0.93.0\",\n },\n binary: \"claude\",\n },\n {\n id: \"codex\",\n name: \"Codex\",\n launch: {\n kind: \"adapter\",\n package: \"@agentclientprotocol/codex-acp\",\n version: \"2.2.2\",\n },\n binary: \"codex\",\n apps: [\"/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex\"],\n },\n {\n id: \"gemini\",\n name: \"Gemini CLI\",\n launch: { kind: \"native\", command: \"gemini\", args: [\"--acp\"] },\n binary: \"gemini\",\n },\n];\n\n/** Where each adapter looks for the agent CLI it drives; its own search does not survive a single executable. */\nexport const ADAPTER_BINARY_ENV: Readonly<Record<string, string>> = {\n \"@agentclientprotocol/claude-agent-acp\": \"CLAUDE_CODE_EXECUTABLE\",\n \"@agentclientprotocol/codex-acp\": \"CODEX_PATH\",\n};\n\n/**\n * What each adapter needs set to serve an app's turn. Codex's adapter skips a requested MCP\n * server whose name the user's own config already uses, so a turn would reach the app through\n * the registration for agents outside the sidebar instead, which asks before the first change.\n */\nexport const ADAPTER_ENV: Readonly<Record<string, Readonly<Record<string, string>>>> = {\n \"@agentclientprotocol/codex-acp\": { DISABLE_MCP_CONFIG_FILTERING: \"true\" },\n};\n\nexport const DETECT_TIMEOUT_MS = 3_000;\n\ntype Fields = Readonly<Record<string, unknown>>;\n\nconst isFields = (value: unknown): value is Fields =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isStrings = (value: unknown): value is string[] =>\n Array.isArray(value) && value.every((entry) => typeof entry === \"string\");\n\nfunction launchOf(value: unknown): AgentLaunch | undefined {\n if (!isFields(value)) return undefined;\n if (\n value.kind === \"native\" &&\n typeof value.command === \"string\" &&\n isStrings(value.args)\n ) {\n return { kind: \"native\", command: value.command, args: value.args };\n }\n if (\n value.kind === \"adapter\" &&\n typeof value.package === \"string\" &&\n typeof value.version === \"string\" &&\n (value.args === undefined || isStrings(value.args))\n ) {\n return {\n kind: \"adapter\",\n package: value.package,\n version: value.version,\n args: value.args,\n };\n }\n return undefined;\n}\n\nfunction profileOf(value: unknown): AgentProfile | undefined {\n if (!isFields(value)) return undefined;\n const launch = launchOf(value.launch);\n const { id, name, binary, apps } = value;\n if (!launch || typeof id !== \"string\" || typeof name !== \"string\") return undefined;\n if (typeof binary !== \"string\" || id === \"\") return undefined;\n if (apps !== undefined && !isStrings(apps)) return undefined;\n return { id, name, launch, binary, ...(apps ? { apps } : {}) };\n}\n\n/** Built-ins plus the user's own `agents.json`, which only this computer's user edits. */\nexport async function loadProfiles(file: string): Promise<readonly AgentProfile[]> {\n let text: string;\n try {\n text = await readFile(file, \"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return AGENT_PROFILES;\n throw error;\n }\n const listed: unknown = JSON.parse(text);\n if (!Array.isArray(listed))\n throw new Error(`${file} must hold a JSON array of agent profiles.`);\n const own = listed.map((entry, at) => {\n const profile = profileOf(entry);\n if (!profile) throw new Error(`${file}: entry ${at + 1} is not an agent profile.`);\n return profile;\n });\n const ids = new Set(own.map((profile) => profile.id));\n return [...AGENT_PROFILES.filter((profile) => !ids.has(profile.id)), ...own];\n}\n\nfunction versionOf(binary: string, path: string): Promise<string | \"missing\" | \"broken\"> {\n return new Promise((resolve) => {\n execFile(\n binary,\n [\"--version\"],\n { timeout: DETECT_TIMEOUT_MS, env: { ...process.env, PATH: path } },\n (error, stdout) => {\n if ((error as NodeJS.ErrnoException | null)?.code === \"ENOENT\")\n resolve(\"missing\");\n else if (error) resolve(\"broken\");\n else resolve(stdout.trim());\n },\n );\n });\n}\n\n/** The agents installed here, each with its profile's `binary` set to the CLI that answered. */\nexport interface FoundAgents {\n readonly agents: readonly AgentInfo[];\n readonly profiles: readonly AgentProfile[];\n}\n\n/**\n * Looks for each agent's CLI on the login-shell PATH, then inside the desktop apps that ship\n * it. An agent found nowhere is left out; the profiles it returns run what was found.\n */\nexport async function findAgents(\n profiles: readonly AgentProfile[],\n): Promise<FoundAgents> {\n const path = await agentPath();\n const found = await Promise.all(\n profiles.map(async (profile) => {\n let binary = profile.binary;\n let output = await versionOf(binary, path);\n for (const app of profile.apps ?? []) {\n if (output !== \"missing\") break;\n binary = app;\n output = await versionOf(app, path);\n }\n if (output === \"missing\") return undefined;\n const resolved = binary === profile.binary ? profile : { ...profile, binary };\n if (output === \"broken\") {\n const info: AgentInfo = {\n id: profile.id,\n name: profile.name,\n ready: false,\n problem: `\\`${binary} --version\\` failed: check that ${profile.name} runs in a terminal.`,\n };\n return { info, profile: resolved };\n }\n const version = /\\d+\\.\\d+\\.\\d+[\\w.-]*/.exec(output)?.[0];\n const info: AgentInfo = {\n id: profile.id,\n name: profile.name,\n ready: true,\n ...(version ? { version } : {}),\n };\n return { info, profile: resolved };\n }),\n );\n const present = found.filter((entry) => entry !== undefined);\n return {\n agents: present.map((entry) => entry.info),\n profiles: profiles.map(\n (profile) =>\n present.find((entry) => entry.profile.id === profile.id)?.profile ?? profile,\n ),\n };\n}\n\n/** What `hostReport` sends: the installed agents; one that is not installed is left out. */\nexport async function detectAgents(\n profiles: readonly AgentProfile[],\n): Promise<AgentInfo[]> {\n return [...(await findAgents(profiles)).agents];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parlor/agent-host",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"homepage": "https://cychien.github.io/parlor",
|
|
5
5
|
"bugs": "https://github.com/cychien/parlor/issues",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"@agentclientprotocol/sdk": "^1.9.0",
|
|
32
32
|
"citty": "^0.2.2",
|
|
33
33
|
"tsx": "^4.23.15",
|
|
34
|
-
"@parlor/auth": "0.3.
|
|
35
|
-
"@parlor/capabilities": "0.3.
|
|
36
|
-
"@parlor/
|
|
37
|
-
"@parlor/core": "0.3.
|
|
38
|
-
"@parlor/
|
|
39
|
-
"@parlor/
|
|
40
|
-
"@parlor/sync": "0.3.
|
|
34
|
+
"@parlor/auth": "0.3.3",
|
|
35
|
+
"@parlor/capabilities": "0.3.3",
|
|
36
|
+
"@parlor/client": "0.3.3",
|
|
37
|
+
"@parlor/core": "0.3.3",
|
|
38
|
+
"@parlor/chat": "0.3.3",
|
|
39
|
+
"@parlor/server": "0.3.3",
|
|
40
|
+
"@parlor/sync": "0.3.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@agentclientprotocol/claude-agent-acp": "0.93.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"typescript": "^7.0.2",
|
|
51
51
|
"vitest": "^5.0.3",
|
|
52
52
|
"zod": "^4.6.5",
|
|
53
|
-
"@parlor/data": "0.3.
|
|
53
|
+
"@parlor/data": "0.3.3"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsc -p tsconfig.json",
|