Skip to content

Commit bba5635

Browse files
feat(providers): add ACP registry driver for Gemini, Pi, and more
Ship one generic acpRegistry driver with a featured catalog and live ACP index so extra agents can be added as catalog rows without new adapters. Co-authored-by: Cursor <[email protected]>
1 parent 9afef94 commit bba5635

33 files changed

Lines changed: 3137 additions & 86 deletions

‎apps/mobile/src/components/ProviderIcon.tsx‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ export function ProviderIcon(props: ProviderIconProps) {
5858
);
5959
}
6060

61+
if (props.provider === "acpRegistry") {
62+
return (
63+
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
64+
<Path
65+
fill={mono}
66+
d="M20.5 8.2 17.2 2.6A3.2 3.2 0 0 0 14.4 1h-.1A3.2 3.2 0 0 0 11.6 2.6L8.8 7.4 6.2 2.8A3.2 3.2 0 0 0 3.4 1H3.3A3.2 3.2 0 0 0 .5 2.8L.1 3.5 3.4 9.1c.4.7 1.2 1.1 2 1.1h3.2L6.4 14c-.3.5-.3 1.1 0 1.6.3.5.8.8 1.4.8h3.4l-.4.7c-.2.3-.2.7 0 1 .2.3.5.5.9.5h1.2c.4 0 .7-.2.9-.5l.6-1 4.3 0c.8 0 1.6-.4 2-1.1.6-1.1.6-2.4 0-3.4L20.5 8.2Z"
67+
/>
68+
</Svg>
69+
);
70+
}
71+
6172
// codex (and unknown drivers)
6273
return (
6374
<Svg width={size} height={size} viewBox="0 0 256 260" fill="none">

‎apps/mobile/src/lib/modelOptions.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function providerDisplayLabel(provider: {
3535
if (provider.displayName) return provider.displayName;
3636
if (provider.driver === "codex") return "Codex";
3737
if (provider.driver === "claudeAgent") return "Claude";
38+
if (provider.driver === "acpRegistry") return "ACP";
3839
return provider.instanceId;
3940
}
4041

‎apps/server/src/auth/RpcAuthorization.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const RPC_REQUIRED_SCOPES = {
3232
[WS_METHODS.serverProbe]: AuthOrchestrationReadScope,
3333
[WS_METHODS.serverGetConfig]: AuthOrchestrationReadScope,
3434
[WS_METHODS.serverRefreshProviders]: AuthOrchestrationOperateScope,
35+
[WS_METHODS.serverListAcpRegistry]: AuthOrchestrationReadScope,
3536
[WS_METHODS.serverUpdateProvider]: AuthOrchestrationOperateScope,
3637
[WS_METHODS.serverUpdateServer]: AuthOrchestrationOperateScope,
3738
[WS_METHODS.serverUpdateServerWithProgress]: AuthOrchestrationOperateScope,
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/**
2+
* AcpRegistryDriver — generic ACP catalog driver.
3+
*
4+
* One driver kind covers Gemini, Copilot, Pi, Hermes, Qwen, Kimi, and any
5+
* custom ACP stdio agent. Launch command/args live on the instance config.
6+
*
7+
* @module provider/Drivers/AcpRegistryDriver
8+
*/
9+
import {
10+
AcpRegistrySettings,
11+
parseAcpLaunchArgs,
12+
ProviderDriverKind,
13+
TextGenerationError,
14+
type ServerProvider,
15+
} from "@t3tools/contracts";
16+
import * as Crypto from "effect/Crypto";
17+
import * as Effect from "effect/Effect";
18+
import * as FileSystem from "effect/FileSystem";
19+
import * as Path from "effect/Path";
20+
import * as Schema from "effect/Schema";
21+
import { ChildProcessSpawner } from "effect/unstable/process";
22+
23+
import * as BackgroundPolicy from "../../background/BackgroundPolicy.ts";
24+
import { ServerConfig } from "../../config.ts";
25+
import { ServerSettingsService } from "../../serverSettings.ts";
26+
import { ProviderDriverError } from "../Errors.ts";
27+
import { makeGenericAcpAdapter } from "../Layers/GenericAcpAdapter.ts";
28+
import {
29+
buildInitialAcpRegistryProviderSnapshot,
30+
checkAcpRegistryProviderStatus,
31+
} from "../Layers/AcpRegistryProvider.ts";
32+
import { ProviderEventLoggers } from "../Layers/ProviderEventLoggers.ts";
33+
import { makeManagedServerProvider } from "../makeManagedServerProvider.ts";
34+
import {
35+
defaultProviderContinuationIdentity,
36+
type ProviderDriver,
37+
type ProviderInstance,
38+
} from "../ProviderDriver.ts";
39+
import type { ServerProviderDraft } from "../providerSnapshot.ts";
40+
import { mergeProviderInstanceEnvironment } from "../ProviderInstanceEnvironment.ts";
41+
import {
42+
makeManualOnlyProviderMaintenanceCapabilities,
43+
makeStaticProviderMaintenanceResolver,
44+
resolveProviderMaintenanceCapabilitiesEffect,
45+
} from "../providerMaintenance.ts";
46+
import {
47+
haveProviderSnapshotSettingsChanged,
48+
makeProviderSnapshotSettingsSource,
49+
type ProviderSnapshotSettings,
50+
} from "../providerUpdateSettings.ts";
51+
52+
const decodeAcpRegistrySettings = Schema.decodeSync(AcpRegistrySettings);
53+
const DRIVER_KIND = ProviderDriverKind.make("acpRegistry");
54+
const UPDATE = makeStaticProviderMaintenanceResolver(
55+
makeManualOnlyProviderMaintenanceCapabilities({
56+
provider: DRIVER_KIND,
57+
packageName: null,
58+
}),
59+
);
60+
61+
export type AcpRegistryDriverEnv =
62+
| BackgroundPolicy.BackgroundPolicy
63+
| ChildProcessSpawner.ChildProcessSpawner
64+
| Crypto.Crypto
65+
| FileSystem.FileSystem
66+
| Path.Path
67+
| ProviderEventLoggers
68+
| ServerConfig
69+
| ServerSettingsService;
70+
71+
const unsupportedTextGeneration = (operation: string) =>
72+
Effect.fail(
73+
new TextGenerationError({
74+
operation,
75+
detail: "Generic ACP providers do not support git text generation yet.",
76+
}),
77+
);
78+
79+
const makeTextGeneration = () => ({
80+
generateCommitMessage: () => unsupportedTextGeneration("generateCommitMessage"),
81+
generatePrContent: () => unsupportedTextGeneration("generatePrContent"),
82+
generateBranchName: () => unsupportedTextGeneration("generateBranchName"),
83+
generateThreadTitle: () => unsupportedTextGeneration("generateThreadTitle"),
84+
});
85+
86+
const withInstanceIdentity =
87+
(input: {
88+
readonly instanceId: ProviderInstance["instanceId"];
89+
readonly displayName: string | undefined;
90+
readonly accentColor: string | undefined;
91+
readonly continuationGroupKey: string;
92+
}) =>
93+
(snapshot: ServerProviderDraft): ServerProvider => ({
94+
...snapshot,
95+
instanceId: input.instanceId,
96+
driver: DRIVER_KIND,
97+
...(input.displayName ? { displayName: input.displayName } : {}),
98+
...(input.accentColor ? { accentColor: input.accentColor } : {}),
99+
continuation: { groupKey: input.continuationGroupKey },
100+
});
101+
102+
export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryDriverEnv> = {
103+
driverKind: DRIVER_KIND,
104+
metadata: {
105+
displayName: "ACP Registry",
106+
supportsMultipleInstances: true,
107+
},
108+
configSchema: AcpRegistrySettings,
109+
defaultConfig: (): AcpRegistrySettings => decodeAcpRegistrySettings({}),
110+
create: ({ instanceId, displayName, accentColor, environment, enabled, config }) =>
111+
Effect.gen(function* () {
112+
const crypto = yield* Crypto.Crypto;
113+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
114+
const serverSettings = yield* ServerSettingsService;
115+
const eventLoggers = yield* ProviderEventLoggers;
116+
const processEnv = mergeProviderInstanceEnvironment(environment);
117+
const continuationIdentity = defaultProviderContinuationIdentity({
118+
driverKind: DRIVER_KIND,
119+
instanceId,
120+
});
121+
const stampIdentity = withInstanceIdentity({
122+
instanceId,
123+
displayName,
124+
accentColor,
125+
continuationGroupKey: continuationIdentity.continuationKey,
126+
});
127+
const effectiveConfig = { ...config, enabled } satisfies AcpRegistrySettings;
128+
const maintenanceCapabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(UPDATE, {
129+
binaryPath: effectiveConfig.command,
130+
env: processEnv,
131+
});
132+
133+
const adapter = yield* makeGenericAcpAdapter(
134+
{
135+
enabled: effectiveConfig.enabled,
136+
command: effectiveConfig.command.trim() || "acp",
137+
args: parseAcpLaunchArgs(effectiveConfig.launchArgs),
138+
},
139+
{
140+
provider: DRIVER_KIND,
141+
instanceId,
142+
environment: processEnv,
143+
readyReason: "ACP session ready",
144+
...(effectiveConfig.authMethodId.trim()
145+
? { authMethodId: effectiveConfig.authMethodId.trim() }
146+
: {}),
147+
...(eventLoggers.native ? { nativeEventLogger: eventLoggers.native } : {}),
148+
},
149+
);
150+
151+
const checkProvider = checkAcpRegistryProviderStatus(effectiveConfig, processEnv).pipe(
152+
Effect.map(stampIdentity),
153+
Effect.provideService(Crypto.Crypto, crypto),
154+
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
155+
);
156+
157+
const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings);
158+
const snapshot = yield* makeManagedServerProvider<
159+
ProviderSnapshotSettings<AcpRegistrySettings>
160+
>({
161+
maintenanceCapabilities,
162+
getSettings: snapshotSettings.getSettings,
163+
streamSettings: snapshotSettings.streamSettings,
164+
haveSettingsChanged: haveProviderSnapshotSettingsChanged,
165+
initialSnapshot: (settings) =>
166+
buildInitialAcpRegistryProviderSnapshot(settings.provider).pipe(
167+
Effect.map(stampIdentity),
168+
),
169+
checkProvider,
170+
}).pipe(
171+
Effect.mapError(
172+
(cause) =>
173+
new ProviderDriverError({
174+
driver: DRIVER_KIND,
175+
instanceId,
176+
detail: `Failed to build ACP Registry snapshot: ${cause.message ?? String(cause)}`,
177+
cause,
178+
}),
179+
),
180+
);
181+
182+
return {
183+
instanceId,
184+
driverKind: DRIVER_KIND,
185+
continuationIdentity,
186+
displayName,
187+
accentColor,
188+
enabled,
189+
snapshot,
190+
adapter,
191+
textGeneration: makeTextGeneration(),
192+
} satisfies ProviderInstance;
193+
}),
194+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import * as NodeServices from "@effect/platform-node/NodeServices";
2+
import { describe, expect, it } from "@effect/vitest";
3+
import * as Effect from "effect/Effect";
4+
import * as Schema from "effect/Schema";
5+
import { AcpRegistrySettings } from "@t3tools/contracts";
6+
7+
import {
8+
buildInitialAcpRegistryProviderSnapshot,
9+
checkAcpRegistryProviderStatus,
10+
} from "./AcpRegistryProvider.ts";
11+
12+
const decodeSettings = Schema.decodeSync(AcpRegistrySettings);
13+
14+
describe("buildInitialAcpRegistryProviderSnapshot", () => {
15+
it.effect("returns a disabled snapshot when settings.enabled is false", () =>
16+
Effect.gen(function* () {
17+
const snapshot = yield* buildInitialAcpRegistryProviderSnapshot(
18+
decodeSettings({ enabled: false, catalogId: "gemini", command: "gemini" }),
19+
);
20+
expect(snapshot.enabled).toBe(false);
21+
expect(snapshot.status).toBe("disabled");
22+
expect(snapshot.displayName).toBe("Gemini");
23+
expect(snapshot.message).toContain("disabled");
24+
}),
25+
);
26+
27+
it.effect("asks for a launch command when none is configured", () =>
28+
Effect.gen(function* () {
29+
const snapshot = yield* buildInitialAcpRegistryProviderSnapshot(
30+
decodeSettings({ enabled: true, catalogId: "gemini" }),
31+
);
32+
expect(snapshot.enabled).toBe(false);
33+
expect(snapshot.status).toBe("disabled");
34+
expect(snapshot.message).toMatch(/launch command/i);
35+
expect(snapshot.message).toContain("gemini");
36+
}),
37+
);
38+
39+
it.effect("returns a pending snapshot while probing a configured command", () =>
40+
Effect.gen(function* () {
41+
const snapshot = yield* buildInitialAcpRegistryProviderSnapshot(
42+
decodeSettings({ enabled: true, catalogId: "gemini", command: "gemini" }),
43+
);
44+
expect(snapshot.enabled).toBe(true);
45+
expect(snapshot.installed).toBe(true);
46+
expect(snapshot.status).toBe("warning");
47+
expect(snapshot.message).toContain("Checking ACP");
48+
}),
49+
);
50+
});
51+
52+
it.layer(NodeServices.layer)("checkAcpRegistryProviderStatus", (it) => {
53+
it.effect("reports the command as missing when it does not resolve", () =>
54+
Effect.gen(function* () {
55+
const snapshot = yield* checkAcpRegistryProviderStatus(
56+
decodeSettings({
57+
enabled: true,
58+
catalogId: "gemini",
59+
command: "/definitely/not/installed/gemini-acp",
60+
}),
61+
);
62+
expect(snapshot.enabled).toBe(true);
63+
expect(snapshot.installed).toBe(false);
64+
expect(snapshot.status).toBe("error");
65+
expect(snapshot.message).toMatch(/not installed|not on PATH/i);
66+
}),
67+
);
68+
});

0 commit comments

Comments
 (0)