Skip to content
Merged
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
9 changes: 1 addition & 8 deletions apps/server/scripts/record-grok-acp-replay-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { HostProcessEnvironment, HostProcessPlatform } from "@t3tools/shared/hos
import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime";
import * as Clock from "effect/Clock";
import * as Console from "effect/Console";
import * as Crypto from "effect/Crypto";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
Expand All @@ -25,7 +24,6 @@ import * as Schema from "effect/Schema";
import { ChildProcessSpawner } from "effect/process";
import type * as EffectAcpProtocol from "effect-acp/protocol";

import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
import { layerTestProviderHost } from "@t3tools/provider-testing/host";
import {
GROK_DEFAULT_INSTANCE_ID,
Expand Down Expand Up @@ -447,16 +445,11 @@ const recordScenario = Effect.fn("recordGrokScenario")(function* (fixtureName: s
Effect.gen(function* () {
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const environment = yield* HostProcessEnvironment;
const adapter = makeGrokAdapterV2({
const adapter = yield* makeGrokAdapterV2({
instanceId: GROK_DEFAULT_INSTANCE_ID,
settings,
environment,
hostPlatform: yield* HostProcessPlatform,
childProcessSpawner,
crypto: yield* Crypto.Crypto,
fileSystem: yield* FileSystem.FileSystem,
idAllocator: yield* IdAllocator.IdAllocatorV2,
host: yield* ProviderHost.ProviderHost,
selfInvocation: yield* resolveSelfInvocation(),
continuationRequests: yield* ProviderContinuationRequests.ProviderContinuationRequests,
// Production's runtime factory, with the protocol logger teeing raw lines.
Expand Down
709 changes: 86 additions & 623 deletions apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ProviderInstanceId, ProviderSessionId, ThreadId } from "@t3tools/contra
import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime";
import * as Deferred from "effect/Deferred";
import * as Effect from "effect/Effect";
import * as Crypto from "effect/Crypto";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Option from "effect/Option";
Expand Down Expand Up @@ -188,8 +187,7 @@ describe("AcpRegistryAdapterV2", () => {
ACP_REGISTRY_PROVIDER,
);
const instanceId = ProviderInstanceId.make("acp-registry-mode-pick");
const adapter = makeAcpRegistryAdapterV2({
crypto: yield* Crypto.Crypto,
const adapter = yield* makeAcpRegistryAdapterV2({
selfInvocation: yield* resolveSelfInvocation(),
instanceId,
settings: yield* decodeAcpRegistryAdapterSettings({
Expand All @@ -198,10 +196,7 @@ describe("AcpRegistryAdapterV2", () => {
}),
environment: {},
childProcessSpawner,
fileSystem,
idAllocator: yield* IdAllocator.IdAllocatorV2,
resolver: { resolve: () => Effect.die("the runtime is injected") },
host: yield* ProviderHost.ProviderHost,
makeRuntime: makeAcpReplayRuntime({
transcript,
statusPath,
Expand Down Expand Up @@ -268,10 +263,7 @@ describe("AcpRegistryAdapterV2", () => {
it.effect("offers client terminals to Devin only and client fs to no registry agent", () =>
Effect.gen(function* () {
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const fileSystem = yield* FileSystem.FileSystem;
const idAllocator = yield* IdAllocator.IdAllocatorV2;
const path = yield* Path.Path;
const host = yield* ProviderHost.ProviderHost;
const mockAgentPath = yield* path.fromFileUrl(
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
Expand All @@ -280,17 +272,13 @@ describe("AcpRegistryAdapterV2", () => {
) {
let clientCapabilities: unknown;
const instanceId = ProviderInstanceId.make(`acp-registry-capabilities-${agentId}`);
const adapter = makeAcpRegistryAdapterV2({
crypto: yield* Crypto.Crypto,
const adapter = yield* makeAcpRegistryAdapterV2({
selfInvocation: yield* resolveSelfInvocation(),
instanceId,
settings: yield* decodeAcpRegistryAdapterSettings({ agentId, authMethodId: "test" }),
environment: {},
childProcessSpawner,
fileSystem,
idAllocator,
resolver: { resolve: () => Effect.die("the runtime is injected") },
host,
makeRuntime: (input) =>
Effect.gen(function* () {
clientCapabilities = input.clientCapabilities;
Expand Down Expand Up @@ -344,8 +332,6 @@ describe("AcpRegistryAdapterV2", () => {
it.effect("opens a real ACP child process resolved from registry configuration", () =>
Effect.gen(function* () {
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const fileSystem = yield* FileSystem.FileSystem;
const idAllocator = yield* IdAllocator.IdAllocatorV2;
const path = yield* Path.Path;
const host = yield* ProviderHost.ProviderHost;
const mockAgentPath = yield* path.fromFileUrl(
Expand All @@ -369,8 +355,7 @@ describe("AcpRegistryAdapterV2", () => {
readonly commands: AcpRegistryAvailableCommands;
}>();
const configurationPublished = yield* Deferred.make<AcpRegistryLiveConfiguration>();
const adapter = makeAcpRegistryAdapterV2({
crypto: yield* Crypto.Crypto,
const adapter = yield* makeAcpRegistryAdapterV2({
selfInvocation: yield* resolveSelfInvocation(),
instanceId,
settings,
Expand All @@ -379,8 +364,6 @@ describe("AcpRegistryAdapterV2", () => {
T3_ACP_COMMAND_ADVERTISEMENT_DELAY_MS: "750",
},
childProcessSpawner,
fileSystem,
idAllocator,
runtimeCoordinator: {
withForegroundStartup: (agentId, effect) =>
Effect.acquireUseRelease(
Expand Down Expand Up @@ -428,7 +411,6 @@ describe("AcpRegistryAdapterV2", () => {
})),
),
},
host,
});
const threadId = ThreadId.make("thread-acp-registry-fixture");
const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
import { AcpRegistrySettings } from "@t3tools/contracts";
import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime";
import * as Effect from "effect/Effect";
import * as Crypto from "effect/Crypto";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Path from "effect/Path";
import * as Schema from "effect/Schema";
import { ChildProcessSpawner } from "effect/process";

import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
import { layerTestProviderHost } from "@t3tools/provider-testing/host";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
Expand Down Expand Up @@ -44,9 +42,6 @@ function layerAcpRegistryProviderAdapterRegistryReplay(
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const crypto = yield* Crypto.Crypto;
const idAllocator = yield* IdAllocator.IdAllocatorV2;
const host = yield* ProviderHost.ProviderHost;
const replayGate = options.replayGate;
const replayDir = yield* fileSystem
.makeTempDirectory({
Expand All @@ -57,18 +52,14 @@ function layerAcpRegistryProviderAdapterRegistryReplay(
const scriptPath = yield* path
.fromFileUrl(new URL("../../../scripts/acp-replay-agent.ts", import.meta.url))
.pipe(Effect.orDie);
const adapter = makeAcpRegistryAdapterV2({
const adapter = yield* makeAcpRegistryAdapterV2({
instanceId: ACP_REGISTRY_DEFAULT_INSTANCE_ID,
settings: REPLAY_SETTINGS,
environment: {},
childProcessSpawner,
crypto,
fileSystem,
idAllocator,
resolver: {
resolve: () => Effect.die("ACP registry resolver must not run during replay"),
},
host,
selfInvocation: yield* resolveSelfInvocation(),
makeRuntime: makeAcpReplayRuntime({
transcript,
Expand Down
26 changes: 6 additions & 20 deletions apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ export interface AcpRegistryAdapterV2Options {
readonly settings: AcpRegistrySettings;
readonly environment: NodeJS.ProcessEnv;
readonly childProcessSpawner: ChildProcessSpawner.ChildProcessSpawner["Service"];
readonly crypto: Crypto.Crypto;
readonly selfInvocation: SelfInvocation;
readonly fileSystem: FileSystem.FileSystem;
readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly resolver: Pick<AcpRegistrySupport.AcpRegistryCatalog["Service"], "resolve">;
readonly runtimeCoordinator?: AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator["Service"];
readonly host: ProviderHost.ProviderHostShape;
readonly nativeLogging?: Parameters<typeof makeAcpAdapterV2>[0]["nativeLogging"];
readonly makeRuntime?: (
input: AcpAdapterV2RuntimeInput,
Expand Down Expand Up @@ -181,7 +177,9 @@ function makeAcpRegistryRuntime(options: AcpRegistryAdapterV2Options) {
});
}

export function makeAcpRegistryAdapterV2(options: AcpRegistryAdapterV2Options) {
export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(function* (
options: AcpRegistryAdapterV2Options,
) {
const runtimeCoordinator = options.runtimeCoordinator;
const registryAgentId = options.settings.source === "local" ? "" : options.settings.agentId;
const startupKey =
Expand Down Expand Up @@ -237,13 +235,9 @@ export function makeAcpRegistryAdapterV2(options: AcpRegistryAdapterV2Options) {
}),
...(options.assertComplete === undefined ? {} : { assertComplete: options.assertComplete }),
};
return makeAcpAdapterV2({
return yield* makeAcpAdapterV2({
instanceId: options.instanceId,
flavor,
crypto: options.crypto,
fileSystem: options.fileSystem,
idAllocator: options.idAllocator,
host: options.host,
selfInvocation: options.selfInvocation,
// Per-agent exception (see the note above registerMistralVibeAcpExtensions):
// Devin runs commands through client terminals and has no ask mode over
Expand All @@ -259,7 +253,7 @@ export function makeAcpRegistryAdapterV2(options: AcpRegistryAdapterV2Options) {
: {}),
...(options.nativeLogging === undefined ? {} : { nativeLogging: options.nativeLogging }),
});
}
});

export type AcpRegistryAdapterV2DriverEnv =
| ChildProcessSpawner.ChildProcessSpawner
Expand All @@ -283,29 +277,21 @@ export const AcpRegistryAdapterV2Driver: ProviderAdapterDriver<
const hostEnvironment = yield* HostProcessEnvironment;
const selfInvocation = yield* resolveSelfInvocation();
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const crypto = yield* Crypto.Crypto;
const fileSystem = yield* FileSystem.FileSystem;
const idAllocator = yield* IdAllocator.IdAllocatorV2;
const providerEventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers;
const host = yield* ProviderHost.ProviderHost;
const makeNativeLogger = yield* makeAcpNativeLoggerFactory();
const resolver = yield* AcpRegistrySupport.AcpRegistryCatalog;
const runtimeCoordinator = yield* Effect.serviceOption(
AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator,
);
return makeAcpRegistryAdapterV2({
return yield* makeAcpRegistryAdapterV2({
instanceId: input.instanceId,
settings: { ...input.config, enabled: input.enabled },
environment: mergeProviderInstanceEnvironment(input.environment, hostEnvironment),
childProcessSpawner,
crypto,
fileSystem,
idAllocator,
resolver,
...(Option.isSome(runtimeCoordinator)
? { runtimeCoordinator: runtimeCoordinator.value }
: {}),
host,
selfInvocation,
nativeLogging: (threadId) =>
makeNativeLogger({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const flavor = makeAntigravityAcpAdapterFlavor({
crypto: undefined as never,
fileSystem: undefined as never,
path: undefined as never,
idAllocator: undefined as never,
host: undefined as never,
selfInvocation: undefined as never,
makeRuntime: () => Effect.die("not spawned in this test"),
Expand Down Expand Up @@ -149,14 +148,9 @@ describe("AntigravityAdapterV2 client file system", () => {
let writeTextFile: Parameters<RuntimeService["handleWriteTextFile"]>[0] | undefined;
const crypto = yield* Crypto.Crypto;
const instanceId = ProviderInstanceId.make("antigravity-containment-test");
const adapter = makeAntigravityAdapterV2({
const adapter = yield* makeAntigravityAdapterV2({
instanceId,
crypto,
selfInvocation: yield* resolveSelfInvocation(),
fileSystem,
path,
idAllocator: yield* IdAllocator.IdAllocatorV2,
host,
makeRuntime: (input) =>
makeAntigravityAcpRuntime({
...input,
Expand Down Expand Up @@ -293,22 +287,16 @@ describe("AntigravityAdapterV2 workspace changes", () => {
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const host = yield* ProviderHost.ProviderHost;
const crypto = yield* Crypto.Crypto;
const mockAgentPath = yield* path.fromFileUrl(
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let readTextFile: Parameters<RuntimeService["handleReadTextFile"]>[0] | undefined;
const instanceId = ProviderInstanceId.make("antigravity-workspace-change-test");
const adapter = makeAntigravityAdapterV2({
const adapter = yield* makeAntigravityAdapterV2({
instanceId,
crypto,
selfInvocation: yield* resolveSelfInvocation(),
fileSystem,
path,
idAllocator: yield* IdAllocator.IdAllocatorV2,
host,
makeRuntime: (input) =>
makeAntigravityAcpRuntime({
...input,
Expand Down Expand Up @@ -430,7 +418,6 @@ describe("AntigravityAdapterV2 client file system under restrictive policies", (
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const host = yield* ProviderHost.ProviderHost;
const crypto = yield* Crypto.Crypto;
const mockAgentPath = yield* path.fromFileUrl(
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
Expand All @@ -451,14 +438,9 @@ describe("AntigravityAdapterV2 client file system under restrictive policies", (
let readTextFile: Parameters<RuntimeService["handleReadTextFile"]>[0] | undefined;
let writeTextFile: Parameters<RuntimeService["handleWriteTextFile"]>[0] | undefined;
const instanceId = ProviderInstanceId.make(`antigravity-restrictive-${policy.runtimeMode}`);
const adapter = makeAntigravityAdapterV2({
const adapter = yield* makeAntigravityAdapterV2({
instanceId,
crypto,
selfInvocation: yield* resolveSelfInvocation(),
fileSystem,
path,
idAllocator: yield* IdAllocator.IdAllocatorV2,
host,
makeRuntime: (input) =>
makeAntigravityAcpRuntime({
...input,
Expand Down
Loading
Loading