feat: add fx provider #7865
Closedt3-code-bot[bot](GitHub profile, opens in a new tab)wants to merge 5 commits into
main fromfeat/fx-provideropened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/server/src/provider/Layers/FxAdapter.ts line 276OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +256,21 @@256+ new EffectAcpErrors.AcpTransportError({257+ detail: "Failed to process Fx ACP callback.",258+ cause,259+ }),260+ ),261+ );262+263+ const offerRuntimeEvent = (event: ProviderRuntimeEvent) =>264+ PubSub.publish(runtimeEventPubSub, event).pipe(Effect.asVoid);265+266+ const getThreadSemaphore = (threadId: string) =>267+ SynchronizedRef.modifyEffect(threadLocksRef, (current) => {268+ const existing: Option.Option<Semaphore.Semaphore> = Option.fromNullishOr(269+ current.get(threadId),270+ );271+ return Option.match(existing, {272+ onNone: () =>273+ Semaphore.make(1).pipe(274+ Effect.map((semaphore) => {275+ const next = new Map(current);276+ next.set(threadId, semaphore);apps/server/src/textGeneration/FxTextGeneration.ts line 142Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +78,21 @@78+ if (content.type !== "text") {79+ return Effect.void;80+ }81+ return Ref.update(outputRef, (current) => current + content.text);82+ });83+84+ const promptResult = yield* Effect.gen(function* () {85+ const started = yield* runtime.start();86+ yield* applyFxAcpModelSelection({87+ runtime,88+ currentModelId: currentFxModelIdFromSessionSetup(started.sessionSetupResult),89+ requestedModelId: resolvedModel,90+ mapError: (cause) =>91+ new TextGenerationError({92+ operation,93+ detail: "Failed to set Fx ACP base model for text generation.",94+ cause,95+ }),96+ });97+98+ return yield* runtime.prompt({
- apps/server/src/provider/Drivers/FxDriver.ts line 145OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +125,21 @@125+ getSettings: snapshotSettings.getSettings,126+ streamSettings: snapshotSettings.streamSettings,127+ haveSettingsChanged: haveProviderSnapshotSettingsChanged,128+ initialSnapshot: (settings) =>129+ buildInitialFxProviderSnapshot(settings.provider).pipe(Effect.map(stampIdentity)),130+ checkProvider,131+ enrichSnapshot: ({ settings, snapshot: currentSnapshot, publishSnapshot }) =>132+ enrichFxSnapshot({133+ snapshot: currentSnapshot,134+ maintenanceCapabilities,135+ enableProviderUpdateChecks: settings.enableProviderUpdateChecks,136+ publishSnapshot,137+ httpClient,138+ }),139+ }).pipe(140+ Effect.mapError(141+ (cause) =>142+ new ProviderDriverError({143+ driver: DRIVER_KIND,144+ instanceId,145+ detail: `Failed to build Fx snapshot: ${cause.message ?? String(cause)}`,apps/server/src/provider/acp/FxAcpSupport.ts line 17OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,17 @@1+import { type FxSettings } from "@t3tools/contracts";2+import * as Crypto from "effect/Crypto";3+import * as Effect from "effect/Effect";4+import * as Layer from "effect/Layer";5+import * as Scope from "effect/Scope";6+import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner";7+import * as EffectAcpErrors from "effect-acp/errors";8+import type * as EffectAcpSchema from "effect-acp/schema";9+import * as AcpSessionRuntime from "./AcpSessionRuntime.ts";10+11+type FxAcpRuntimeFxSettings = Pick<FxSettings, "binaryPath">;12+13+interface FxAcpRuntimeInput extends Omit<14+ AcpSessionRuntime.AcpSessionRuntimeOptions,15+ "authMethodId" | "clientCapabilities" | "spawn"16+> {17+ readonly childProcessSpawner: ChildProcessSpawner.ChildProcessSpawner["Service"];
- @@ -130,3 +130,4 @@130130 const CODEX_DRIVER_KIND = ProviderDriverKind.make("codex");131131 const CLAUDE_DRIVER_KIND = ProviderDriverKind.make("claudeAgent");132132 const CURSOR_DRIVER_KIND = ProviderDriverKind.make("cursor");133+const FX_DRIVER_KIND = ProviderDriverKind.make("fx");
- apps/server/src/provider/Layers/FxAdapter.ts lines 928 to 929Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +901,21 @@901+ const turnModelSelection =902+ input.modelSelection?.instanceId === boundInstanceId903+ ? input.modelSelection904+ : undefined;905+ const requestedTurnModelId = turnModelSelection?.model906+ ? resolveFxAcpBaseModelId(turnModelSelection.model)907+ : undefined;908+ const currentModelId = yield* applyFxAcpModelSelection({909+ runtime: ctx.acp,910+ currentModelId: ctx.currentModelId,911+ requestedModelId: requestedTurnModelId,912+ mapError: (cause) =>913+ mapAcpToAdapterError(914+ PROVIDER,915+ input.threadId,916+ "session/set_config_option",917+ cause,918+ ),919+ });920+921+ const text = input.input?.trim();
- apps/server/src/provider/acp/FxAcpSupport.ts line 83OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +63,21 @@63+ | EffectAcpSchema.LoadSessionResponse64+ | EffectAcpSchema.NewSessionResponse65+ | EffectAcpSchema.ResumeSessionResponse,66+): string | undefined {67+ const modelOption = sessionSetupResult.configOptions?.find(68+ (option) => option.category === "model" && option.type === "select",69+ );70+ return typeof modelOption?.currentValue === "string"71+ ? modelOption.currentValue.trim() || undefined72+ : undefined;73+}74+75+export function applyFxAcpModelSelection<E>(input: {76+ readonly runtime: Pick<AcpSessionRuntime.AcpSessionRuntime["Service"], "setModel">;77+ readonly currentModelId: string | undefined;78+ readonly requestedModelId: string | undefined;79+ readonly mapError: (cause: EffectAcpErrors.AcpError) => E;80+}): Effect.Effect<string | undefined, E> {81+ if (input.requestedModelId === "default") {82+ return Effect.succeed(input.currentModelId);83+ }
- apps/web/src/components/Icons.tsx lines 210 to 213OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -202,3 +202,12 @@202202 </svg>203203 );204204205+export const FxIcon: Icon = ({ className, ...props }) => (206+ <svg207+ {...props}208+ viewBox="166.241 0 155.861 156"209+ fill="none"210+ className={cn("text-[#171717] dark:text-[#F5F5F5]", className)}211+ >212+ <path213+ fill="currentColor"
juliusmarminge closed this
Sign in to join this conversation.





Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
592c598· PR result:04bd65c· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.