feat(provider): add configurable ACP agents #9060
ClosedSoulcreek(GitHub profile, opens in a new tab)wants to merge 23 commits into
main fromrefs/pull/9060/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/server/src/provider/Drivers/AcpDriver.ts line 221Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +190,21 @@190+ const observedOptions = yield* Ref.get(observedConfigRef);191+ const modelCapabilities = buildAcpModelCapabilities(observedOptions);192+ const models = extractModelOptions(observedOptions).map((model) => ({193+ slug: model.id,194+ name: model.name,195+ isCustom: false,196+ ...(model.isDefault ? { isDefault: true } : {}),197+ capabilities: modelCapabilities,198+ }));199+ const discoveredDisplayName = agentInfo?.title?.trim() || agentInfo?.name.trim();200+ return makeSnapshot({201+ checkedAt,202+ installed: true,203+ status: "ready",204+ message:205+ models.length > 0206+ ? `${models.length} ACP models discovered.`207+ : "ACP handshake succeeded. Models are discovered from the first active session.",208+ ...(discoveredDisplayName ? { displayName: discoveredDisplayName } : {}),209+ version: agentInfo?.version.trim() || null,210+ models: [...defaultModels(modelCapabilities), ...models],apps/server/src/provider/Layers/CursorAdapter.ts line 1242OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1175,4 +1237,6 @@1175123711761238 return {11771239 provider: PROVIDER,1178- capabilities: { sessionModelSwitch: "in-session" },1240+ capabilities: {1241+ sessionModelSwitch: hasCursorExtensions ? "in-session" : "unsupported",1242+ },
- apps/server/src/provider/acp/AcpAdapterSupport.ts lines 21 to 21OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -13,3 +14,8 @@1314 } from "../Errors.ts";1415 const isAcpProcessExitedError = Schema.is(EffectAcpErrors.AcpProcessExitedError);1516 const isAcpRequestError = Schema.is(EffectAcpErrors.AcpRequestError);17+const ACP_PERMISSION_KINDS_BY_DECISION = {18+ accept: ["allow_once"],19+ acceptForSession: ["allow_always", "allow_once"],20+ acceptAlways: ["allow_always", "allow_once"],21+ decline: ["reject_once"],apps/server/src/provider/Drivers/AcpDriver.ts line 46OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +26,21 @@26+import { makeUnsupportedTextGeneration } from "../../textGeneration/TextGeneration.ts";27+import * as AcpSessionRuntime from "../acp/AcpSessionRuntime.ts";28+import { buildAcpModelCapabilities, extractModelOptions } from "../acp/AcpRuntimeModel.ts";29+import { ProviderDriverError } from "../Errors.ts";30+import { type AcpAdapterProfile, makeAcpAdapter } from "../Layers/CursorAdapter.ts";31+import { makeManagedServerProvider } from "../makeManagedServerProvider.ts";32+import { defaultProviderContinuationIdentity, type ProviderDriver } from "../ProviderDriver.ts";33+import { mergeProviderInstanceEnvironment } from "../ProviderInstanceEnvironment.ts";34+import { buildServerProvider, providerModelsFromSettings } from "../providerSnapshot.ts";35+import { makeManualOnlyProviderMaintenanceCapabilities } from "../providerMaintenance.ts";36+37+const DRIVER_KIND = ProviderDriverKind.make("acp");38+const decodeSettings = Schema.decodeSync(AcpSettings);39+const MAINTENANCE_CAPABILITIES = makeManualOnlyProviderMaintenanceCapabilities({40+ provider: DRIVER_KIND,41+ packageName: null,42+});43+const EMPTY_CAPABILITIES = createModelCapabilities({ optionDescriptors: [] });44+const defaultModels = (capabilities: ModelCapabilities = EMPTY_CAPABILITIES) => [45+ {46+ slug: "agent-default",apps/server/src/provider/Layers/ProviderRegistry.ts lines 83 to 83OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -79,3 +79,5 @@7979 (model.capabilities?.optionDescriptors?.length ?? 0) > 0;80808181 const shouldRetainMissingProviderModels = (provider: ServerProvider): boolean => {82+ if (provider.driver === ProviderDriverKind.make("acp")) {83+ return provider.enabled && provider.installed && provider.status !== "ready";apps/server/src/provider/Layers/CursorAdapter.ts line 334OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -274,0 +314,21 @@314+ .setConfigOption(modelConfig.id, input.modelSelection.model)315+ .pipe(Effect.mapError(mapConfigError));316+ appliedModel = input.modelSelection.model;317+ } else if (input.modelSelection.model === "agent-default") {318+ appliedModel = input.modelSelection.model;319+ }320+321+ for (const selection of input.modelSelection.options ?? []) {322+ const configOption = findSessionConfigOption(323+ yield* input.runtime.getConfigOptions,324+ selection.id,325+ );326+ if (327+ !configOption ||328+ configOption.category === "model" ||329+ configOption.category === "mode"330+ ) {331+ continue;332+ }333+ yield* input.runtime334+ .setConfigOption(configOption.id, selection.value)
- @@ -44,4 +44,6 @@4444 export function SourceControlWritingSettingsSection() {4545 const settings = usePrimarySettings();4646 const updateSettings = useUpdatePrimarySettings();47- const serverProviders = useAtomValue(primaryServerProvidersAtom);47+ const serverProviders = useAtomValue(primaryServerProvidersAtom).filter(48+ (provider) => provider.driver !== ProviderDriverKind.make("acp"),49+ );apps/web/src/components/settings/SettingsPanels.tsx lines 1880 to 1882OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1877,3 +1877,6 @@18771877 const serverProviders = useAtomValue(primaryServerProvidersAtom);18781878 const supportsAutoSettlement =18791879 useAtomValue(primaryServerConfigAtom)?.environment.capabilities.threadAutoSettlement === true;1880+ const textGenerationProviders = serverProviders.filter(1881+ (provider) => provider.driver !== ProviderDriverKind.make("acp"),1882+ );
- apps/server/src/provider/acp/AcpAdapterSupport.ts lines 44 to 45OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -31,4 +41,5 @@3141 return new ProviderAdapterRequestError({3242 provider,3343 method,34- detail: error.message,44+ detail:45+ provider === "acp" && error.code === -32000apps/server/src/provider/acp/AcpSessionRuntime.ts lines 577 to 577OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -550,12 +571,7 @@550571 acp.agent.initialize(initializePayload),551572 );552573553- const authenticatePayload = {554- methodId: options.authMethodId,555- } satisfies EffectAcpSchema.AuthenticateRequest;574+ return initializeResult;575+ });556576557- yield* runLoggedRequest(558- "authenticate",559- authenticatePayload,560- acp.agent.authenticate(authenticatePayload),561- );577+ const connect = yield* Effect.cached(connectOnce);
- apps/server/src/provider/Layers/CursorAdapter.ts line 516OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -465,3 +513,4 @@465513 if (ctx.notificationFiber) {466514 yield* Fiber.interrupt(ctx.notificationFiber);467515 }516+ yield* ctx.acp.close.pipe(Effect.timeout("2 seconds"), Effect.ignore);apps/server/src/provider/Layers/CursorAdapter.ts line 582OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -523,19 +575,8 @@523- // leaves `options.resolveSettings` undefined so we use the value524- // captured at adapter construction — per-instance isolation is525- // enforced by the hydration layer rebuilding this adapter whenever526- // its config changes. Tests set `resolveSettings` to pull the latest527- // snapshot from `ServerSettingsService` so that mid-suite528- // `updateSettings({ providers: { cursor: { binaryPath } } })` calls529- // actually take effect when the next session spawns.530- const effectiveCursorSettings = options?.resolveSettings531- ? yield* options.resolveSettings532- : cursorSettings;533-534575 const mcpSession = McpProviderSession.readMcpProviderSession(input.threadId);535- const acp = yield* makeCursorAcpRuntime({536- cursorSettings: effectiveCursorSettings,576+ const acp = yield* makeRuntime({537577 ...(options?.environment ? { environment: options.environment } : {}),538578 childProcessSpawner,539579 cwd,540580 ...(resumeSessionId ? { resumeSessionId } : {}),541581 clientInfo: { name: "t3-code", version: "0.0.0" },582+ ...(profile.onConfigOptionsChangedapps/server/src/provider/Drivers/AcpDriver.ts line 172OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +152,21 @@152+ checkedAt,153+ "ACP agent is disabled in T3 Code settings.",154+ false,155+ "warning",156+ );157+ }158+ const installed =159+ config.binaryPath.length > 0 &&160+ (yield* isCommandAvailable(config.binaryPath, { env: processEnv }));161+ if (!installed) {162+ return unavailableSnapshot(checkedAt, missingCommandMessage(config.binaryPath));163+ }164+165+ const connected = yield* makeRuntime({166+ childProcessSpawner: spawner,167+ environment: processEnv,168+ cwd: serverConfig.cwd,169+ clientInfo: { name: "t3-code", version: "0.0.0" },170+ }).pipe(171+ Effect.provideService(Crypto.Crypto, crypto),172+ Effect.flatMap((runtime) => runtime.connect()),apps/server/src/provider/Drivers/AcpDriver.ts line 98Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +72,21 @@72+ const fileSystem = yield* FileSystem.FileSystem;73+ const path = yield* Path.Path;74+ const crypto = yield* Crypto.Crypto;75+ const driverScope = yield* Scope.Scope;76+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;77+ const serverConfig = yield* ServerConfig;78+ const processEnv = mergeProviderInstanceEnvironment(environment);79+ const continuationIdentity = defaultProviderContinuationIdentity({80+ driverKind: DRIVER_KIND,81+ instanceId,82+ });83+ const observedConfigRef = yield* Ref.make<ReadonlyArray<EffectAcpSchema.SessionConfigOption>>(84+ [],85+ );86+ const agentName = displayName?.trim() || path.basename(config.binaryPath) || "ACP Agent";87+ const makeRuntime: AcpAdapterProfile["makeRuntime"] = ({88+ childProcessSpawner,89+ environment: runtimeEnvironment,90+ ...input91+ }) =>92+ AcpSessionRuntime.make({
- apps/server/src/provider/Drivers/AcpDriver.ts line 172OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +152,21 @@152+ checkedAt,153+ "ACP agent is disabled in T3 Code settings.",154+ false,155+ "warning",156+ );157+ }158+ const installed =159+ config.binaryPath.length > 0 &&160+ (yield* isCommandAvailable(config.binaryPath, { env: processEnv }));161+ if (!installed) {162+ return unavailableSnapshot(checkedAt, missingCommandMessage(config.binaryPath));163+ }164+165+ const connected = yield* makeRuntime({166+ childProcessSpawner: spawner,167+ environment: processEnv,168+ cwd: serverConfig.cwd,169+ clientInfo: { name: "t3-code", version: "0.0.0" },170+ }).pipe(171+ Effect.provideService(Crypto.Crypto, crypto),172+ Effect.flatMap((runtime) => runtime.connect()),apps/server/src/provider/Layers/CursorAdapter.ts line 583OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -524,18 +575,9 @@524- // captured at adapter construction — per-instance isolation is525- // enforced by the hydration layer rebuilding this adapter whenever526- // its config changes. Tests set `resolveSettings` to pull the latest527- // snapshot from `ServerSettingsService` so that mid-suite528- // `updateSettings({ providers: { cursor: { binaryPath } } })` calls529- // actually take effect when the next session spawns.530- const effectiveCursorSettings = options?.resolveSettings531- ? yield* options.resolveSettings532- : cursorSettings;533-534575 const mcpSession = McpProviderSession.readMcpProviderSession(input.threadId);535- const acp = yield* makeCursorAcpRuntime({536- cursorSettings: effectiveCursorSettings,576+ const acp = yield* makeRuntime({537577 ...(options?.environment ? { environment: options.environment } : {}),538578 childProcessSpawner,539579 cwd,540580 ...(resumeSessionId ? { resumeSessionId } : {}),541581 clientInfo: { name: "t3-code", version: "0.0.0" },582+ ...(profile.onConfigOptionsChanged583+ ? { onConfigOptionsChanged: profile.onConfigOptionsChanged }apps/server/src/provider/Layers/CursorAdapter.ts line 516OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -465,3 +513,4 @@465513 if (ctx.notificationFiber) {466514 yield* Fiber.interrupt(ctx.notificationFiber);467515 }516+ yield* ctx.acp.close.pipe(Effect.timeout("2 seconds"), Effect.ignore);apps/server/src/provider/Drivers/AcpDriver.ts line 98Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +72,21 @@72+ const fileSystem = yield* FileSystem.FileSystem;73+ const path = yield* Path.Path;74+ const crypto = yield* Crypto.Crypto;75+ const driverScope = yield* Scope.Scope;76+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;77+ const serverConfig = yield* ServerConfig;78+ const processEnv = mergeProviderInstanceEnvironment(environment);79+ const continuationIdentity = defaultProviderContinuationIdentity({80+ driverKind: DRIVER_KIND,81+ instanceId,82+ });83+ const observedConfigRef = yield* Ref.make<ReadonlyArray<EffectAcpSchema.SessionConfigOption>>(84+ [],85+ );86+ const agentName = displayName?.trim() || path.basename(config.binaryPath) || "ACP Agent";87+ const makeRuntime: AcpAdapterProfile["makeRuntime"] = ({88+ childProcessSpawner,89+ environment: runtimeEnvironment,90+ ...input91+ }) =>92+ AcpSessionRuntime.make({
- apps/server/src/provider/Layers/CursorAdapter.ts line 333OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -274,0 +313,21 @@313+ yield* input.runtime314+ .setConfigOption(modelConfig.id, input.modelSelection.model)315+ .pipe(Effect.mapError(mapConfigError));316+ appliedModel = input.modelSelection.model;317+ } else if (input.modelSelection.model === "agent-default") {318+ appliedModel = input.modelSelection.model;319+ }320+321+ for (const selection of input.modelSelection.options ?? []) {322+ const configOption = findSessionConfigOption(323+ yield* input.runtime.getConfigOptions,324+ selection.id,325+ );326+ if (327+ !configOption ||328+ configOption.category === "model" ||329+ configOption.category === "mode"330+ ) {331+ continue;332+ }333+ yield* input.runtime
- apps/server/src/provider/Drivers/AcpDriver.ts line 265Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +234,21 @@234+ );235+ const onConfigOptionsChanged = (236+ options: ReadonlyArray<EffectAcpSchema.SessionConfigOption>,237+ ) =>238+ Ref.set(observedConfigRef, options).pipe(239+ Effect.andThen(240+ snapshot.refresh.pipe(241+ Effect.catchCause((cause) =>242+ Effect.logWarning("Failed to refresh ACP model metadata.", { cause }),243+ ),244+ Effect.forkIn(driverScope),245+ Effect.asVoid,246+ ),247+ ),248+ );249+ const adapter = yield* makeAcpAdapter(250+ {251+ provider: DRIVER_KIND,252+ displayName: agentName,253+ modelSelection: "standard",254+ onConfigOptionsChanged,apps/server/src/provider/acp/AcpRuntimeModel.ts line 891Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -771,10 +847,16 @@771847772848 export function parseSessionUpdateEvent(params: EffectAcpSchema.SessionNotification): {773849 readonly modeId?: string;850+ readonly configOptions?: ReadonlyArray<EffectAcpSchema.SessionConfigOption>;774851 readonly events: ReadonlyArray<AcpParsedSessionEvent>;775852 } {776853 const upd = params.update;777854 const events: Array<AcpParsedSessionEvent> = [];778855 let modeId: string | undefined;779856780857 switch (upd.sessionUpdate) {858+ case "config_option_update":859+ return {860+ configOptions: upd.configOptions,861+ events,862+ };apps/server/src/provider/acp/AcpAdapterSupport.ts line 95Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -43,13 +56,12 @@4356 });4457 }455846-export function acpPermissionOutcome(decision: ProviderApprovalDecision): string {47- switch (decision) {48- case "acceptForSession":49- return "allow-always";50- case "accept":51- return "allow-once";52- case "decline":53- default:54- return "reject-once";59+export function selectAcpPermissionOptionId(60+ request: Pick<EffectAcpSchema.RequestPermissionRequest, "options">,61+ decision: ProviderApprovalDecision,62+): string | undefined {63+ for (const kind of ACP_PERMISSION_KINDS_BY_DECISION[decision]) {64+ const optionId = request.options.find((option) => option.kind === kind)?.optionId.trim();65+ if (optionId) return optionId;5566 }67+ return undefined;
- @@ -67,3 +69,6 @@6769 icon: OpenCodeIcon,6870 settingsSchema: OpenCodeSettings,6971 },72+ {73+ value: ProviderDriverKind.make("acp"),74+ label: "ACP Agent",
- apps/server/src/provider/Layers/CursorAdapter.ts lines 321 to 325OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -272,3 +306,20 @@272306 method: "session/set_config_option",273307 }),274308 });309+ appliedModel = input.modelSelection.model;310+ } else if (input.modelSelection && input.modelSelectionKind === "standard") {311+ const requestedModel = input.modelSelection.model;312+ if (isAcpAgentDefaultModel(requestedModel)) {313+ // The synthetic default keeps whatever model the agent chose; never314+ // forward the sentinel to the agent.315+ appliedModel = ACP_AGENT_DEFAULT_MODEL_SLUG;316+ } else {317+ const modelConfig = findModelConfigOption(yield* input.runtime.getConfigOptions);318+ const advertisedModel = modelConfig319+ ? resolveSessionConfigOptionValue(modelConfig, requestedModel)320+ : undefined;321+ if (modelConfig && advertisedModel !== undefined) {322+ yield* input.runtime323+ .setConfigOption(modelConfig.id, advertisedModel)324+ .pipe(Effect.mapError(mapConfigError));325+ appliedModel = requestedModel;
- apps/server/src/provider/Layers/ProviderRegistry.ts line 109OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -101,3 +101,9 @@101101 }102102103103 const shouldRetainMissingProviderModels = (provider: ServerProvider): boolean => {104+ // A generic ACP probe only runs `initialize`; the model inventory arrives105+ // from active sessions. A ready probe therefore carries just the synthetic106+ // default and must not evict what earlier sessions discovered. Disabled and107+ // missing-CLI snapshots remain authoritative removals.108+ if (provider.driver === ProviderDriverKind.make("acp")) {109+ return provider.enabled && provider.installed;
- apps/web/src/components/chat/providerIconUtils.ts line 6OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1,4 +1,6 @@11 import { ProviderDriverKind } from "@t3tools/contracts";2+import { ACPRegistryIcon } from "../Icons";23 import { ClaudeAI, CursorIcon, GrokIcon, Icon, OpenAI, OpenCodeIcon } from "../Icons";3445 export const PROVIDER_ICON_BY_PROVIDER: Partial<Record<ProviderDriverKind, Icon>> = {6+ [ProviderDriverKind.make("acp")]: ACPRegistryIcon,
- apps/server/src/provider/Drivers/AcpDriver.ts line 99Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +79,21 @@79+ const path = yield* Path.Path;80+ const crypto = yield* Crypto.Crypto;81+ const driverScope = yield* Scope.Scope;82+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;83+ const serverConfig = yield* ServerConfig;84+ const processEnv = mergeProviderInstanceEnvironment(environment);85+ const continuationIdentity = defaultProviderContinuationIdentity({86+ driverKind: DRIVER_KIND,87+ instanceId,88+ });89+ const observedConfigRef = yield* Ref.make<ReadonlyArray<EffectAcpSchema.SessionConfigOption>>(90+ [],91+ );92+ const agentName = displayName?.trim() || path.basename(config.binaryPath) || "ACP Agent";93+ const makeRuntime: AcpAdapterProfile["makeRuntime"] = ({94+ childProcessSpawner,95+ environment: runtimeEnvironment,96+ ...input97+ }) =>98+ AcpSessionRuntime.make({99+ ...input,
- apps/server/src/provider/acp/AcpSessionRuntime.ts line 93Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -76,5 +76,18 @@7676 readonly name: string;7777 readonly version: string;7878 };79- readonly authMethodId: string;79+ /** Omit for agents that are authenticated outside T3 Code; `authenticate` is then skipped. */80+ readonly authMethodId?: string;8081 readonly mcpServers?: ReadonlyArray<EffectAcpSchema.McpServer>;82+ /**83+ * Honor the agent's advertised `agentCapabilities` during session setup: drop84+ * MCP servers whose transport the agent did not advertise and create a new85+ * session when `loadSession` is unsupported. Off by default so vendor86+ * runtimes keep their established behavior.87+ */88+ readonly respectAgentCapabilities?: boolean;89+ /**90+ * Surface `agent_thought_chunk` updates as `reasoning_text` deltas. Off by91+ * default so vendor runtimes keep their assistant-only stream.92+ */93+ readonly reasoningStream?: boolean;
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/server/src/provider/Layers/CursorAdapter.ts line 377OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -297,20 +377 @@297-function selectAutoApprovedPermissionOption(298- request: EffectAcpSchema.RequestPermissionRequest,299-): string | undefined {300- const allowAlwaysOption = request.options.find((option) => option.kind === "allow_always");301- if (typeof allowAlwaysOption?.optionId === "string" && allowAlwaysOption.optionId.trim()) {302- return allowAlwaysOption.optionId.trim();303- }304-305- const allowOnceOption = request.options.find((option) => option.kind === "allow_once");306- if (typeof allowOnceOption?.optionId === "string" && allowOnceOption.optionId.trim()) {307- return allowOnceOption.optionId.trim();308- }309-310- return undefined;311-}312-313-export function makeCursorAdapter(314- cursorSettings: CursorSettings,315- options?: CursorAdapterLiveOptions,316-) {377+export function makeAcpAdapter(profile: AcpAdapterProfile, options?: AcpAdapterOptions) {
- apps/server/src/provider/Drivers/AcpDriver.ts line 127OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +107,21 @@107+ },108+ }).pipe(109+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, childProcessSpawner),110+ );111+ const makeSnapshot = (input: {112+ readonly checkedAt: string;113+ readonly installed: boolean;114+ readonly status: "ready" | "warning" | "error";115+ readonly message: string;116+ readonly displayName?: string;117+ readonly version?: string | null;118+ readonly models?: ReadonlyArray<ServerProviderModel>;119+ }) => ({120+ ...buildServerProvider({121+ presentation: { displayName: displayName?.trim() || input.displayName || agentName },122+ enabled,123+ checkedAt: input.checkedAt,124+ models: providerModelsFromSettings(125+ input.models ?? defaultModels(),126+ config.customModels,127+ EMPTY_CAPABILITIES,@@ -0,0 +352,21 @@352+ cause,353+ }),354+ ),355+ );356+ const nextEventId = Effect.map(randomUUIDv4, (id) => EventId.make(id));357+ const makeEventStamp = () => Effect.all({ eventId: nextEventId, createdAt: nowIso });358+ const mapCallbackFailure = <A, E, R>(effect: Effect.Effect<A, E, R>) =>359+ effect.pipe(360+ Effect.mapError(361+ (cause) =>362+ new EffectAcpErrors.AcpTransportError({363+ detail: `Failed to process ${profile.displayName} ACP callback.`,364+ cause,365+ }),366+ ),367+ );368+369+ const offerRuntimeEvent = (event: ProviderRuntimeEvent) =>370+ PubSub.publish(runtimeEventPubSub, event).pipe(Effect.asVoid);371+372+ const getThreadSemaphore = (threadId: string) =>apps/server/src/provider/Layers/AcpAdapter.ts line 884Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +862,21 @@862+ cause,863+ }),864+ ),865+ );866+ promptParts.push({867+ type: "image",868+ data: Buffer.from(bytes).toString("base64"),869+ mimeType: attachment.mimeType,870+ });871+ }872+ }873+874+ if (promptParts.length === 0) {875+ return yield* new ProviderAdapterValidationError({876+ provider: PROVIDER,877+ operation: "sendTurn",878+ issue: "Turn requires non-empty text or attachments.",879+ });880+ }881+882+ const result = yield* ctx.acp@@ -0,0 +971,21 @@971+ }),972+ ),973+ );974+975+ const readThread: AcpAdapterShape["readThread"] = (threadId) =>976+ Effect.gen(function* () {977+ const ctx = yield* requireSession(threadId);978+ return { threadId, turns: ctx.turns };979+ });980+981+ const rollbackThread: AcpAdapterShape["rollbackThread"] = (threadId, numTurns) =>982+ Effect.gen(function* () {983+ const ctx = yield* requireSession(threadId);984+ if (!Number.isInteger(numTurns) || numTurns < 1) {985+ return yield* new ProviderAdapterValidationError({986+ provider: PROVIDER,987+ operation: "rollbackThread",988+ issue: "numTurns must be an integer >= 1.",989+ });990+ }991+ const nextLength = Math.max(0, ctx.turns.length - numTurns);apps/server/src/provider/Layers/AcpAdapter.ts line 307Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +287,21 @@287+ // validation reports them instead of silently dropping the selection.288+ const value =289+ typeof selection.value === "string" && configOption.type === "select"290+ ? (resolveSessionConfigOptionValue(configOption, selection.value) ?? selection.value)291+ : selection.value;292+ yield* input.runtime293+ .setConfigOption(configOption.id, value)294+ .pipe(Effect.mapError(mapConfigError));295+ }296+ }297+298+ const requestedModeId = resolveRequestedModeId({299+ interactionMode: input.interactionMode,300+ runtimeMode: input.runtimeMode,301+ modeState: yield* input.runtime.getModeState,302+ });303+ if (!requestedModeId) {304+ return appliedModel;305+ }306+307+ yield* input.runtime.setMode(requestedModeId).pipe(
- apps/server/src/provider/Layers/AcpAdapter.test.ts line 1OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1 @@1+// @effect-diagnostics nodeBuiltinImport:off
- @@ -0,0 +940,21 @@940+ provider: PROVIDER,941+ threadId: input.threadId,942+ turnId,943+ payload: { state: "failed", errorMessage: error.message },944+ });945+ })946+ : Effect.void,947+ ),948+ Effect.ensuring(949+ Effect.sync(() => {950+ ctx.promptsInFlight = Math.max(0, ctx.promptsInFlight - 1);951+ }),952+ ),953+ );954+ });955+956+ const interruptTurn: AcpAdapterShape["interruptTurn"] = (threadId) =>957+ Effect.gen(function* () {958+ const ctx = yield* requireSession(threadId);959+ yield* settlePendingApprovalsAsCancelled(ctx.pendingApprovals);960+ yield* Effect.ignore(
- @@ -0,0 +926,21 @@926+ turnId,927+ };928+ }).pipe(929+ // A prompt that fails after `turn.started` must still settle the turn930+ // it opened, otherwise the thread keeps a running turn with no end.931+ Effect.tapError((error) =>932+ turnStartedEmitted && ctx.promptsInFlight === 1933+ ? Effect.gen(function* () {934+ const { activeTurnId: _activeTurnId, ...session } = ctx.session;935+ ctx.session = { ...session, updatedAt: yield* nowIso };936+ ctx.activeTurnId = undefined;937+ yield* offerRuntimeEvent({938+ type: "turn.completed",939+ ...(yield* makeEventStamp()),940+ provider: PROVIDER,941+ threadId: input.threadId,942+ turnId,943+ payload: { state: "failed", errorMessage: error.message },944+ });945+ })946+ : Effect.void,@@ -0,0 +926,21 @@926+ turnId,927+ };928+ }).pipe(929+ // A prompt that fails after `turn.started` must still settle the turn930+ // it opened, otherwise the thread keeps a running turn with no end.931+ Effect.tapError((error) =>932+ turnStartedEmitted && ctx.promptsInFlight === 1933+ ? Effect.gen(function* () {934+ const { activeTurnId: _activeTurnId, ...session } = ctx.session;935+ ctx.session = { ...session, updatedAt: yield* nowIso };936+ ctx.activeTurnId = undefined;937+ yield* offerRuntimeEvent({938+ type: "turn.completed",939+ ...(yield* makeEventStamp()),940+ provider: PROVIDER,941+ threadId: input.threadId,942+ turnId,943+ payload: { state: "failed", errorMessage: error.message },944+ });945+ })946+ : Effect.void,
- apps/web/src/components/Icons.tsx line 645OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -642,4 +642,4 @@642642 );643643644644 const ANTIGRAVITY_ICON_DATA_URL =645- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAgKADAAQAAAABAAAAgAAAAABIjgR3AAAjOElEQVR4Ae1dCYxkV3W9tfdW3T0z3bMvPcxge2zGy2BjY0MwxEAWEBACihSCEiMUSFCiRJEsRygIiIKySUlYAkmMQSxJQAKi4AQngDcM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h9XtFnCsZC+ePS42ysSCv7vEq2MbwQZbQp/rSTzrjhY0puVUacPc7mF7lQepj3TBqwVd44e9QWjbMCcbawYqeR7uftBH0hUOLSo7ZonPcdZ2tnb2qrhUBg5nZ5/DRfj57XLs0qFM1j9herjAMuavPjvs428eO+Hm2vdmltwWVBrUDx7S+U7lfcL9O3d7reCgzf/kLpflv5Zfr2lgAzUxwIUZvFo9I/v12an4+6BTvH4i8WGQeEb4vTzWaSbWF6VFo7md3i/jm+LRZkZogDwLeZfq4y7lpWZlNFX0SRKDh+3PRzlWwuK8Nvunm2uMZeyGbpvjwdnRXx8/nxqM44g+V3sc79nNfwuBXfZno76ae10tlClhbVGWfw0yXrbOFnXIObrZ1kmp++UJwX9PNbBcxmcZOt7JaeVNnU2F4lfbvpcZI2Hrx/01mMxam3Cv55fp6mc/2G9XU7wWxxkjbfbvGoZFmp3t6+wtDwim25XO6KdDp9JUyXpFKpMaT143gph6lGo7EX+D5Ur9d/XKlU7jl18sRT09OlGTQKQWQw8ONkNN3icZI2C1q2D6AlmIym+XHqCx4AOr127YZduXz+9wD2r1n
- apps/web/src/components/Icons.tsx lines 705 to 705OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -688,3 +688,18 @@688688 </svg>689689 );690690691+/**692+ * Square mark for generic ACP agent instances. The official ACP logo693+ * (`ACPRegistryIcon`) is ~2.6:1 and collapses to a sliver in the square slots694+ * every other provider glyph fills; this plug mirrors the mobile app's choice.695+ */696+export const AcpAgentIcon: Icon = ({ className, ...props }) => (697+ <svg698+ {...props}699+ viewBox="0 0 24 24"700+ fill="none"701+ stroke="currentColor"702+ strokeWidth="2"703+ strokeLinecap="round"704+ strokeLinejoin="round"705+ className={cn("text-black dark:text-white", className)}
- apps/web/src/components/Icons.tsx line 645OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -642,4 +642,4 @@642642 );643643644644 const ANTIGRAVITY_ICON_DATA_URL =645- "data:image/png;base64,iVBORw0KGgoAA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AAABAAEAAKACAAQAAAABAAAAgKADAAQAAAABAAAAgAAAAABIjgR3AAAjOElEQVR4Ae1dCYxkV3W9tfdW3T0z3bMvPcxge2zGy2BjY0MwxEAWEBACihSCEiMUSFCiRJEsRygIiIKySUlYAkmMQSxJQAKi4AQngDcMAe87nsF4xuPxrJ6ll+rqri3n3Pfv71e/f1XP4u7+Zdeb+XXvu+/9999/77z7lv+rOiVnF1ILnNYuvV3aAsW+JJIbbe6yXRpPWyh9XtFnCsZC+ePS42ysSCv7vEq2MbwQZbQp/rSTzrjhY0puVUacPc7mF7lQepj3TBqwVd44e9QWjbMCcbawYqeR7uftBH0hUOLSo7ZonPcdZ2tnb2qrhUBg5nZ5/DRfj57XLs0qFM1j9herjAMuavPjvs428eO+Hm2vdmltwWVBrUDx7S+U7lfcL9O3d7reCgzf/kLpflv5Zfr2lgAzUxwIUZvFo9I/v12an4+6BTvH4i8WGQeEb4vTzWaSbWF6VFo7md3i/jm+LRZkZogDwLeZfq4y7lpWZlNFX0SRKDh+3PRzlWwuK8Nvunm2uMZeyGbpvjwdnRXx8/nxqM44g+V3sc79nNfwuBXfZno76ae10tlClhbVGWfw0yXrbOFnXIObrZ1kmp++UJwX9PNbBcxmcZOt7JaeVNnU2F4lfbvpcZI2Hrx/01mMxam3Cv55fp6mc/2G9XU7wWxxkjbfbvGoZFmp3t6+wtDwim25XO6KdDp9JUyXpFKpMaT143gph6lGo7EX+D5Ur9d/XKlU7jl18sRT09OlGTQKQWQw8ONkNN3icZI2C1q2D6AlmIym+XHqCx4AOr127YZduXz+9wD2r1n
- @@ -0,0 +1,18 @@1+import type { Icon } from "./Icons";2+import { cn } from "~/lib/utils";3+4+/**5+ * Square mark for generic ACP agent instances. The official ACP logo6+ * (`ACPRegistryIcon`) is ~2.6:1 and collapses to a sliver in the square slots7+ * every other provider glyph fills; this plug mirrors the mobile app's choice.8+ */9+export const AcpAgentIcon: Icon = ({ className, ...props }) => (10+ <svg11+ {...props}12+ viewBox="0 0 24 24"13+ fill="none"14+ stroke="currentColor"15+ strokeWidth="2"16+ strokeLinecap="round"17+ strokeLinejoin="round"18+ className={cn("text-black dark:text-white", className)}
Sign in to join this conversation.


cursor[bot](GitHub profile, opens in a new tab) reviewed