Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/mobile/src/components/ProviderIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ export function ProviderIcon(props: ProviderIconProps) {
);
}

if (props.provider === "acpRegistry") {
return (
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
<Path
fill={mono}
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"
/>
</Svg>
);
}

// codex (and unknown drivers)
return (
<Svg width={size} height={size} viewBox="0 0 256 260" fill="none">
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/src/lib/modelOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function providerDisplayLabel(provider: {
if (provider.displayName) return provider.displayName;
if (provider.driver === "codex") return "Codex";
if (provider.driver === "claudeAgent") return "Claude";
if (provider.driver === "acpRegistry") return "ACP";
return provider.instanceId;
}

Expand Down
1 change: 1 addition & 0 deletions apps/server/src/auth/RpcAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const RPC_REQUIRED_SCOPES = {
[WS_METHODS.serverProbe]: AuthOrchestrationReadScope,
[WS_METHODS.serverGetConfig]: AuthOrchestrationReadScope,
[WS_METHODS.serverRefreshProviders]: AuthOrchestrationOperateScope,
[WS_METHODS.serverListAcpRegistry]: AuthOrchestrationReadScope,
[WS_METHODS.serverUpdateProvider]: AuthOrchestrationOperateScope,
[WS_METHODS.serverUpdateServer]: AuthOrchestrationOperateScope,
[WS_METHODS.serverUpdateServerWithProgress]: AuthOrchestrationOperateScope,
Expand Down
194 changes: 194 additions & 0 deletions apps/server/src/provider/Drivers/AcpRegistryDriver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/**
* AcpRegistryDriver — generic ACP catalog driver.
*
* One driver kind covers Gemini, Copilot, Pi, Hermes, Qwen, Kimi, and any
* custom ACP stdio agent. Launch command/args live on the instance config.
*
* @module provider/Drivers/AcpRegistryDriver
*/
import {
AcpRegistrySettings,
parseAcpLaunchArgs,
ProviderDriverKind,
TextGenerationError,
type ServerProvider,
} from "@t3tools/contracts";
import * as Crypto from "effect/Crypto";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Path from "effect/Path";
import * as Schema from "effect/Schema";
import { ChildProcessSpawner } from "effect/unstable/process";

import * as BackgroundPolicy from "../../background/BackgroundPolicy.ts";
import { ServerConfig } from "../../config.ts";
import { ServerSettingsService } from "../../serverSettings.ts";
import { ProviderDriverError } from "../Errors.ts";
import { makeGenericAcpAdapter } from "../Layers/GenericAcpAdapter.ts";
import {
buildInitialAcpRegistryProviderSnapshot,
checkAcpRegistryProviderStatus,
} from "../Layers/AcpRegistryProvider.ts";
import { ProviderEventLoggers } from "../Layers/ProviderEventLoggers.ts";
import { makeManagedServerProvider } from "../makeManagedServerProvider.ts";
import {
defaultProviderContinuationIdentity,
type ProviderDriver,
type ProviderInstance,
} from "../ProviderDriver.ts";
import type { ServerProviderDraft } from "../providerSnapshot.ts";
import { mergeProviderInstanceEnvironment } from "../ProviderInstanceEnvironment.ts";
import {
makeManualOnlyProviderMaintenanceCapabilities,
makeStaticProviderMaintenanceResolver,
resolveProviderMaintenanceCapabilitiesEffect,
} from "../providerMaintenance.ts";
import {
haveProviderSnapshotSettingsChanged,
makeProviderSnapshotSettingsSource,
type ProviderSnapshotSettings,
} from "../providerUpdateSettings.ts";

const decodeAcpRegistrySettings = Schema.decodeSync(AcpRegistrySettings);
const DRIVER_KIND = ProviderDriverKind.make("acpRegistry");
const UPDATE = makeStaticProviderMaintenanceResolver(
makeManualOnlyProviderMaintenanceCapabilities({
provider: DRIVER_KIND,
packageName: null,
}),
);

export type AcpRegistryDriverEnv =
| BackgroundPolicy.BackgroundPolicy
| ChildProcessSpawner.ChildProcessSpawner
| Crypto.Crypto
| FileSystem.FileSystem
| Path.Path
| ProviderEventLoggers
| ServerConfig
| ServerSettingsService;

const unsupportedTextGeneration = (operation: string) =>
Effect.fail(
new TextGenerationError({
operation,
detail: "Generic ACP providers do not support git text generation yet.",
}),
);

const makeTextGeneration = () => ({
generateCommitMessage: () => unsupportedTextGeneration("generateCommitMessage"),
generatePrContent: () => unsupportedTextGeneration("generatePrContent"),
generateBranchName: () => unsupportedTextGeneration("generateBranchName"),
generateThreadTitle: () => unsupportedTextGeneration("generateThreadTitle"),
});

const withInstanceIdentity =
(input: {
readonly instanceId: ProviderInstance["instanceId"];
readonly displayName: string | undefined;
readonly accentColor: string | undefined;
readonly continuationGroupKey: string;
}) =>
(snapshot: ServerProviderDraft): ServerProvider => ({
...snapshot,
instanceId: input.instanceId,
driver: DRIVER_KIND,
...(input.displayName ? { displayName: input.displayName } : {}),
...(input.accentColor ? { accentColor: input.accentColor } : {}),
continuation: { groupKey: input.continuationGroupKey },
});

export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryDriverEnv> = {
driverKind: DRIVER_KIND,
metadata: {
displayName: "ACP Registry",
supportsMultipleInstances: true,
},
configSchema: AcpRegistrySettings,
defaultConfig: (): AcpRegistrySettings => decodeAcpRegistrySettings({}),
create: ({ instanceId, displayName, accentColor, environment, enabled, config }) =>
Effect.gen(function* () {
const crypto = yield* Crypto.Crypto;
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const serverSettings = yield* ServerSettingsService;
const eventLoggers = yield* ProviderEventLoggers;
const processEnv = mergeProviderInstanceEnvironment(environment);
const continuationIdentity = defaultProviderContinuationIdentity({
driverKind: DRIVER_KIND,
instanceId,
});
const stampIdentity = withInstanceIdentity({
instanceId,
displayName,
accentColor,
continuationGroupKey: continuationIdentity.continuationKey,
});
const effectiveConfig = { ...config, enabled } satisfies AcpRegistrySettings;
const maintenanceCapabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(UPDATE, {
binaryPath: effectiveConfig.command,
env: processEnv,
});

const adapter = yield* makeGenericAcpAdapter(
{
enabled: effectiveConfig.enabled,
command: effectiveConfig.command.trim() || "acp",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High Drivers/AcpRegistryDriver.ts:136

An enabled ACP instance with a blank command silently launches an executable named acp from PATH instead of rejecting the invalid configuration. The makeGenericAcpAdapter call uses effectiveConfig.command.trim() || "acp", so an empty command falls back to the literal string "acp", bypassing the blank-command validation the adapter would otherwise enforce. This contradicts the snapshot/probe path, which treats a blank command as unconfigured/disabled. Require a non-empty command for enabled ACP instances — or at minimum drop the || "acp" fallback so the adapter's own validation rejects the empty value.

Suggested change
command: effectiveConfig.command.trim() || "acp",
command: effectiveConfig.command.trim(),
Also found in 1 other location(s)

packages/contracts/src/settings.ts:434

AcpRegistrySettings.command accepts an empty string and defaults to &#34;&#34;, even though the ACP provider treats an empty command as unconfigured/disabled and rejects session startup. Selecting “Custom ACP” produces no draft command, so the dialog can successfully save an enabled provider instance with blank command; it then appears added but cannot run until manually repaired. Require a non-empty command for enabled ACP instances or block saving the custom entry until one is supplied.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/provider/Drivers/AcpRegistryDriver.ts around line 136:

An enabled ACP instance with a blank `command` silently launches an executable named `acp` from `PATH` instead of rejecting the invalid configuration. The `makeGenericAcpAdapter` call uses `effectiveConfig.command.trim() || "acp"`, so an empty command falls back to the literal string `"acp"`, bypassing the blank-command validation the adapter would otherwise enforce. This contradicts the snapshot/probe path, which treats a blank command as unconfigured/disabled. Require a non-empty `command` for enabled ACP instances — or at minimum drop the `|| "acp"` fallback so the adapter's own validation rejects the empty value.

Also found in 1 other location(s):
- packages/contracts/src/settings.ts:434 -- `AcpRegistrySettings.command` accepts an empty string and defaults to `""`, even though the ACP provider treats an empty command as unconfigured/disabled and rejects session startup. Selecting “Custom ACP” produces no draft command, so the dialog can successfully save an enabled provider instance with blank `command`; it then appears added but cannot run until manually repaired. Require a non-empty command for enabled ACP instances or block saving the custom entry until one is supplied.

args: parseAcpLaunchArgs(effectiveConfig.launchArgs),
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty command spawns acp binary

Medium Severity

AcpRegistryDriver passes command: effectiveConfig.command.trim() || "acp" into the adapter. startSession only rejects a missing command when settings.command is empty, so an blank/whitespace command is rewritten to acp before that check and the guard never fires. A Custom ACP instance saved without a command can still attempt to spawn a non-existent acp binary instead of failing with a configuration error.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bba5635. Configure here.

{
provider: DRIVER_KIND,
instanceId,
environment: processEnv,
readyReason: "ACP session ready",
...(effectiveConfig.authMethodId.trim()
? { authMethodId: effectiveConfig.authMethodId.trim() }
: {}),
...(eventLoggers.native ? { nativeEventLogger: eventLoggers.native } : {}),
},
);

const checkProvider = checkAcpRegistryProviderStatus(effectiveConfig, processEnv).pipe(
Effect.map(stampIdentity),
Effect.provideService(Crypto.Crypto, crypto),
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
);

const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings);
const snapshot = yield* makeManagedServerProvider<
ProviderSnapshotSettings<AcpRegistrySettings>
>({
maintenanceCapabilities,
getSettings: snapshotSettings.getSettings,
streamSettings: snapshotSettings.streamSettings,
haveSettingsChanged: haveProviderSnapshotSettingsChanged,
initialSnapshot: (settings) =>
buildInitialAcpRegistryProviderSnapshot(settings.provider).pipe(
Effect.map(stampIdentity),
),
checkProvider,
}).pipe(
Effect.mapError(
(cause) =>
new ProviderDriverError({
driver: DRIVER_KIND,
instanceId,
detail: `Failed to build ACP Registry snapshot: ${cause.message ?? String(cause)}`,
cause,
}),
),
);

return {
instanceId,
driverKind: DRIVER_KIND,
continuationIdentity,
displayName,
accentColor,
enabled,
snapshot,
adapter,
textGeneration: makeTextGeneration(),
} satisfies ProviderInstance;
}),
};
68 changes: 68 additions & 0 deletions apps/server/src/provider/Layers/AcpRegistryProvider.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import * as NodeServices from "@effect/platform-node/NodeServices";
import { describe, expect, it } from "@effect/vitest";
import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";
import { AcpRegistrySettings } from "@t3tools/contracts";

import {
buildInitialAcpRegistryProviderSnapshot,
checkAcpRegistryProviderStatus,
} from "./AcpRegistryProvider.ts";

const decodeSettings = Schema.decodeSync(AcpRegistrySettings);

describe("buildInitialAcpRegistryProviderSnapshot", () => {
it.effect("returns a disabled snapshot when settings.enabled is false", () =>
Effect.gen(function* () {
const snapshot = yield* buildInitialAcpRegistryProviderSnapshot(
decodeSettings({ enabled: false, catalogId: "gemini", command: "gemini" }),
);
expect(snapshot.enabled).toBe(false);
expect(snapshot.status).toBe("disabled");
expect(snapshot.displayName).toBe("Gemini");
expect(snapshot.message).toContain("disabled");
}),
);

it.effect("asks for a launch command when none is configured", () =>
Effect.gen(function* () {
const snapshot = yield* buildInitialAcpRegistryProviderSnapshot(
decodeSettings({ enabled: true, catalogId: "gemini" }),
);
expect(snapshot.enabled).toBe(false);
expect(snapshot.status).toBe("disabled");
expect(snapshot.message).toMatch(/launch command/i);
expect(snapshot.message).toContain("gemini");
}),
);

it.effect("returns a pending snapshot while probing a configured command", () =>
Effect.gen(function* () {
const snapshot = yield* buildInitialAcpRegistryProviderSnapshot(
decodeSettings({ enabled: true, catalogId: "gemini", command: "gemini" }),
);
expect(snapshot.enabled).toBe(true);
expect(snapshot.installed).toBe(true);
expect(snapshot.status).toBe("warning");
expect(snapshot.message).toContain("Checking ACP");
}),
);
});

it.layer(NodeServices.layer)("checkAcpRegistryProviderStatus", (it) => {
it.effect("reports the command as missing when it does not resolve", () =>
Effect.gen(function* () {
const snapshot = yield* checkAcpRegistryProviderStatus(
decodeSettings({
enabled: true,
catalogId: "gemini",
command: "/definitely/not/installed/gemini-acp",
}),
);
expect(snapshot.enabled).toBe(true);
expect(snapshot.installed).toBe(false);
expect(snapshot.status).toBe("error");
expect(snapshot.message).toMatch(/not installed|not on PATH/i);
}),
);
});
Loading
Loading