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
12 changes: 6 additions & 6 deletions apps/server/integration/transferBudgetV2.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ import { OrchestrationEventStoreLive } from "../src/persistence/Layers/Orchestra
import * as EventStore from "../src/orchestration-v2/EventStore.ts";
import * as EventSink from "../src/orchestration-v2/EventSink.ts";
import * as ProjectionStore from "../src/orchestration-v2/ProjectionStore.ts";
import { ThreadManagementService } from "../src/orchestration-v2/ThreadManagementService.ts";
import * as ThreadManagementService from "../src/orchestration-v2/ThreadManagementService.ts";
import * as ProjectStore from "../src/orchestration-v2/ProjectStore.ts";
import { ProjectService } from "../src/project/ProjectService.ts";
import { ProjectEnrichmentService } from "../src/project/ProjectEnrichmentService.ts";
import * as ProjectService from "../src/project/ProjectService.ts";
import * as ProjectEnrichmentService from "../src/project/ProjectEnrichmentService.ts";
import { orchestrationHttpApiLayer } from "../src/orchestration-v2/http.ts";
import { httpCompressionLayer } from "../src/http.ts";
import { subscribeOrchestrationV2Thread, subscribeOrchestrationV2Shell } from "../src/ws.ts";
Expand Down Expand Up @@ -81,7 +81,7 @@ const management = Layer.unwrap(
Effect.gen(function* () {
const projections = yield* ProjectionStore.ProjectionStoreV2;
const sink = yield* EventSink.EventSinkV2;
return Layer.mock(ThreadManagementService)({
return Layer.mock(ThreadManagementService.ThreadManagementService)({
ensureLegacyTranscript: () => Effect.void,
getThreadSnapshot: (id) => projections.getThreadSnapshot(id).pipe(Effect.orDie),
getThreadSnapshotWindow: (id, options) =>
Expand All @@ -96,7 +96,7 @@ const management = Layer.unwrap(
const enrichment = Layer.unwrap(
Effect.gen(function* () {
const changes = yield* PubSub.unbounded<never>();
return Layer.mock(ProjectEnrichmentService)({
return Layer.mock(ProjectEnrichmentService.ProjectEnrichmentService)({
getAvailable: () =>
Effect.succeed({
repositoryIdentity: null,
Expand All @@ -110,7 +110,7 @@ const enrichment = Layer.unwrap(
// The transfer history has no project events, so shell streams never read a project shell.
const services = management.pipe(
Layer.provideMerge(ProjectStore.layer),
Layer.provideMerge(Layer.mock(ProjectService)({})),
Layer.provideMerge(Layer.mock(ProjectService.ProjectService)({})),
Layer.provideMerge(enrichment),
Layer.provideMerge(persistence),
);
Expand Down
11 changes: 6 additions & 5 deletions apps/server/scripts/record-grok-acp-replay-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import * as Schema from "effect/Schema";
import { ChildProcessSpawner } from "effect/unstable/process";
import type * as EffectAcpProtocol from "effect-acp/protocol";

import { ServerConfig } from "../src/config.ts";
import * as ServerConfig from "../src/config.ts";
import {
GROK_DEFAULT_INSTANCE_ID,
GROK_PROVIDER,
Expand Down Expand Up @@ -457,7 +457,7 @@ const recordScenario = Effect.fn("recordGrokScenario")(function* (fixtureName: s
crypto: yield* Crypto.Crypto,
fileSystem: yield* FileSystem.FileSystem,
idAllocator: yield* IdAllocator.IdAllocatorV2,
serverConfig: yield* ServerConfig,
serverConfig: yield* ServerConfig.ServerConfig,
selfInvocation: yield* resolveSelfInvocation(),
continuationRequests: yield* ProviderContinuationRequests.ProviderContinuationRequests,
// Production's runtime factory, with the protocol logger teeing raw lines.
Expand Down Expand Up @@ -498,9 +498,10 @@ const recordScenario = Effect.fn("recordGrokScenario")(function* (fixtureName: s
).pipe(
Layer.provide(
Layer.mergeAll(
Layer.effect(ServerConfig, makeReplayServerConfig(`grok-record-${fixtureName}`)).pipe(
Layer.provide(NodeServices.layer),
),
Layer.effect(
ServerConfig.ServerConfig,
makeReplayServerConfig(`grok-record-${fixtureName}`),
).pipe(Layer.provide(NodeServices.layer)),
NodeServices.layer,
IdAllocator.layer,
),
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/auth/EnvironmentAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import * as ServerSecretStore from "./ServerSecretStore.ts";
import * as SessionStore from "./SessionStore.ts";
import { REUSABLE_DEV_SESSION_EXPIRES_AT, resolveReusableDevAuth } from "./ReusableDevAuth.ts";
import { verifyRequestDpopProof } from "./dpop.ts";
import { layerConfig as SqlitePersistenceLayer } from "../persistence/Layers/Sqlite.ts";
import * as SqlitePersistence from "../persistence/Layers/Sqlite.ts";

const DEFAULT_SESSION_SUBJECT = "cli-issued-session";
export const INTERNAL_ADMINISTRATIVE_BOOTSTRAP_SUBJECT = "administrative-bootstrap";
Expand Down Expand Up @@ -1125,7 +1125,7 @@ export const layer = Layer.effect(EnvironmentAuth, make).pipe(
Layer.provideMerge(EnvironmentAuthPolicy.layer),
);

const storageLayer = Layer.mergeAll(ServerSecretStore.layer, SqlitePersistenceLayer);
const storageLayer = Layer.mergeAll(ServerSecretStore.layer, SqlitePersistence.layerConfig);

export const runtimeLayer = layer.pipe(
Layer.provideMerge(storageLayer),
Expand Down
8 changes: 4 additions & 4 deletions apps/server/src/background/BackgroundPolicy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as PubSub from "effect/PubSub";
import * as Ref from "effect/Ref";
import * as Stream from "effect/Stream";

import { ServerSettingsService } from "../serverSettings.ts";
import * as ServerSettings from "../serverSettings.ts";
import * as BackgroundPolicy from "./BackgroundPolicy.ts";
import * as HostPowerMonitor from "./HostPowerMonitor.ts";

Expand Down Expand Up @@ -55,7 +55,7 @@ function makeReport(overrides: Partial<ClientActivityReportInput> = {}): ClientA

function makeLayer(
hostPower: HostPowerSnapshot,
settingsOverrides: Parameters<typeof ServerSettingsService.layerTest>[0] = {},
settingsOverrides: Parameters<typeof ServerSettings.layerTest>[0] = {},
) {
const hostLayer = Layer.effect(
HostPowerMonitor.HostPowerMonitor,
Expand All @@ -73,7 +73,7 @@ function makeLayer(
}),
);
return BackgroundPolicy.layer.pipe(
Layer.provide(Layer.merge(hostLayer, ServerSettingsService.layerTest(settingsOverrides))),
Layer.provide(Layer.merge(hostLayer, ServerSettings.layerTest(settingsOverrides))),
);
}

Expand Down Expand Up @@ -162,7 +162,7 @@ describe("BackgroundPolicy", () => {
}),
);
const layer = BackgroundPolicy.layer.pipe(
Layer.provide(Layer.merge(hostLayer, ServerSettingsService.layerTest())),
Layer.provide(Layer.merge(hostLayer, ServerSettings.layerTest())),
);

yield* Effect.gen(function* () {
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/background/BackgroundPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as Scope from "effect/Scope";
import * as Semaphore from "effect/Semaphore";
import * as Stream from "effect/Stream";

import { ServerSettingsService } from "../serverSettings.ts";
import * as ServerSettings from "../serverSettings.ts";
import { subscribeBeforeSnapshot } from "../utils/subscribeBeforeSnapshot.ts";
import * as HostPowerMonitor from "./HostPowerMonitor.ts";

Expand Down Expand Up @@ -211,7 +211,7 @@ function computeSnapshot(input: {
/** @public Service construction is part of the canonical Effect module API. */
export const make = Effect.fn("background.policy.make")(function* () {
const hostPowerMonitor = yield* HostPowerMonitor.HostPowerMonitor;
const serverSettings = yield* ServerSettingsService;
const serverSettings = yield* ServerSettings.ServerSettingsService;
const leasesRef = yield* Ref.make(new Map<string, ClientActivityLease>());
const changes = yield* PubSub.sliding<BackgroundPolicySnapshot>(1);
const publishMutex = yield* Semaphore.make(1);
Expand Down
10 changes: 5 additions & 5 deletions apps/server/src/cli/project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import { Command } from "effect/unstable/cli";

import { cli } from "../binCli.ts";
import * as ServerConfig from "../config.ts";
import { EventSinkV2 } from "../orchestration-v2/EventSink.ts";
import * as EventSink from "../orchestration-v2/EventSink.ts";
import * as EventStore from "../orchestration-v2/EventStore.ts";
import * as ProjectionStore from "../orchestration-v2/ProjectionStore.ts";
import {
OrchestrationV2EventSinkLayerLive,
ProjectServiceLayerLive,
} from "../orchestration-v2/runtimeLayer.ts";
import { layerConfig as SqlitePersistenceLayerLive } from "../persistence/Layers/Sqlite.ts";
import * as SqlitePersistence from "../persistence/Layers/Sqlite.ts";
import * as ProjectEnrichmentService from "../project/ProjectEnrichmentService.ts";
import * as ProjectFaviconResolver from "../project/ProjectFaviconResolver.ts";
import * as ProjectService from "../project/ProjectService.ts";
Expand Down Expand Up @@ -96,7 +96,7 @@ const readProjects = (baseDir: string) =>
Layer.provideMerge(ProjectFaviconResolver.layer),
Layer.provideMerge(T3ProjectFileLoader.layer),
Layer.provideMerge(WorkspacePaths.layer),
Layer.provideMerge(SqlitePersistenceLayerLive),
Layer.provideMerge(SqlitePersistence.layerConfig),
Layer.provideMerge(NodeServices.layer),
Layer.provide(ServerConfig.layer(config)),
Layer.provide(Layer.succeed(References.MinimumLogLevel, config.logLevel)),
Expand Down Expand Up @@ -175,7 +175,7 @@ const makeThreadPersistenceLayer = Effect.fn("ProjectCliTest.makeThreadPersisten
ProjectionStore.layer,
EventStore.layer,
).pipe(
Layer.provideMerge(SqlitePersistenceLayerLive),
Layer.provideMerge(SqlitePersistence.layerConfig),
Layer.provideMerge(NodeServices.layer),
Layer.provide(ServerConfig.layer(config)),
Layer.provide(Layer.succeed(References.MinimumLogLevel, config.logLevel)),
Expand All @@ -195,7 +195,7 @@ const seedNativeThreads = Effect.fn("ProjectCliTest.seedNativeThreads")(function
const createdAt = DateTime.makeUnsafe("2026-09-04T12:00:00.000Z");
const providerInstanceId = ProviderInstanceId.make("codex");
yield* Effect.gen(function* () {
const eventSink = yield* EventSinkV2;
const eventSink = yield* EventSink.EventSinkV2;
yield* eventSink.write({
commandId: CommandId.make("project-cli-seed-threads"),
events: threads.map(({ id, projectId, archived }) => {
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/cli/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import * as HttpApiClient from "effect/unstable/httpapi/HttpApiClient";
import * as EnvironmentAuth from "../auth/EnvironmentAuth.ts";

import * as ServerConfig from "../config.ts";
import { layerConfig as SqlitePersistenceLayerLive } from "../persistence/Layers/Sqlite.ts";
import * as SqlitePersistence from "../persistence/Layers/Sqlite.ts";
import { ProjectServiceLayerLive } from "../orchestration-v2/runtimeLayer.ts";
import * as ProjectEnrichmentService from "../project/ProjectEnrichmentService.ts";
import * as ProjectFaviconResolver from "../project/ProjectFaviconResolver.ts";
Expand Down Expand Up @@ -206,7 +206,7 @@ const ProjectCliRuntimeLive = ProjectServiceLayerLive.pipe(
),
),
Layer.provideMerge(WorkspacePaths.layer),
Layer.provideMerge(SqlitePersistenceLayerLive),
Layer.provideMerge(SqlitePersistence.layerConfig),
);

const PROJECT_CLI_LIVE_SERVER_TIMEOUT = Duration.seconds(1);
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/cli/server.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import * as Effect from "effect/Effect";
import { Command, GlobalFlag } from "effect/unstable/cli";

import { ServerConfig, type StartupPresentation } from "../config.ts";
import * as ServerConfig from "../config.ts";
import { runServer } from "../server.ts";
import { type CliServerFlags, resolveServerConfig, sharedServerCommandFlags } from "./config.ts";

export const runServerCommand = (
flags: CliServerFlags,
options?: {
readonly startupPresentation?: StartupPresentation;
readonly startupPresentation?: ServerConfig.StartupPresentation;
readonly forceAutoBootstrapProjectFromCwd?: boolean;
},
) =>
Effect.gen(function* () {
const logLevel = yield* GlobalFlag.LogLevel;
const config = yield* resolveServerConfig(flags, logLevel, options);
return yield* runServer.pipe(Effect.provideService(ServerConfig, config));
return yield* runServer.pipe(Effect.provideService(ServerConfig.ServerConfig, config));
});

export const startCommand = Command.make("start", { ...sharedServerCommandFlags }).pipe(
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/cloud/CliState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as Layer from "effect/Layer";
import * as Option from "effect/Option";

import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
import { ServerConfig } from "../config.ts";
import * as ServerConfig from "../config.ts";
import * as CliState from "./CliState.ts";
import {
CLOUD_ENDPOINT_CONFIRMED_ORIGIN,
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/desktopUpdate/DesktopAppUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as Ref from "effect/Ref";
import * as Result from "effect/Result";
import * as Stream from "effect/Stream";

import { ServerConfig } from "../config.ts";
import * as ServerConfig from "../config.ts";
import * as DesktopTelemetryReceiver from "../resourceTelemetry/DesktopTelemetryReceiver.ts";

/** Backstop for a desktop updater that hangs without ever reporting a
Expand Down Expand Up @@ -63,7 +63,7 @@ export class DesktopAppUpdate extends Context.Service<
>()("t3/desktopUpdate/DesktopAppUpdate") {}

export const make = Effect.fn("desktopUpdate.desktopAppUpdate.make")(function* () {
const config = yield* ServerConfig;
const config = yield* ServerConfig.ServerConfig;
const crypto = yield* Crypto.Crypto;
const receiver = yield* DesktopTelemetryReceiver.DesktopTelemetryReceiver;
const inFlight = yield* Ref.make(false);
Expand Down
24 changes: 9 additions & 15 deletions apps/server/src/device/DeviceHubProxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ import {
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import { HttpClient, HttpClientResponse, HttpRouter } from "effect/unstable/http";
import {
EnvironmentAuth,
ServerAuthMissingCredentialError,
ServerAuthSessionCredentialValidationError,
type ServerAuthCredentialError,
type ServerAuthInternalError,
} from "../auth/EnvironmentAuth.ts";
import { DeviceService } from "./DeviceService.ts";
import * as EnvironmentAuth from "../auth/EnvironmentAuth.ts";
import * as DeviceService from "./DeviceService.ts";
import { deviceHubProxyRouteLayer } from "./DeviceHubProxy.ts";

const disposers: Array<() => Promise<void>> = [];
Expand All @@ -27,7 +21,7 @@ afterEach(async () => {
const fixture = (
scopes: ReadonlyArray<AuthEnvironmentScope>,
fail = false,
authError?: ServerAuthCredentialError | ServerAuthInternalError,
authError?: EnvironmentAuth.ServerAuthCredentialError | EnvironmentAuth.ServerAuthInternalError,
) => {
let finalized = 0;
const requests: string[] = [];
Expand All @@ -44,7 +38,7 @@ const fixture = (
const { handler, dispose } = HttpRouter.toWebHandler(
deviceHubProxyRouteLayer.pipe(
Layer.provideMerge(
Layer.succeed(EnvironmentAuth, {
Layer.succeed(EnvironmentAuth.EnvironmentAuth, {
authenticateWebSocketUpgrade: () =>
authError
? Effect.fail(authError)
Expand All @@ -54,13 +48,13 @@ const fixture = (
method: "bearer-access-token",
scopes,
}),
} as unknown as EnvironmentAuth["Service"]),
} as unknown as EnvironmentAuth.EnvironmentAuth["Service"]),
),
Layer.provideMerge(
Layer.succeed(DeviceService, {
Layer.succeed(DeviceService.DeviceService, {
currentReadiness: () =>
Effect.succeed({ hostId: LOCAL_DEVICE_HOST_ID, hub: { origin: "http://hub.test" } }),
} as DeviceService["Service"]),
} as DeviceService.DeviceService["Service"]),
),
Layer.provideMerge(Layer.succeed(HttpClient.HttpClient, client)),
),
Expand Down Expand Up @@ -151,9 +145,9 @@ describe("device hub proxy", () => {
});

it.each([
[new ServerAuthMissingCredentialError({}), 401],
[new EnvironmentAuth.ServerAuthMissingCredentialError({}), 401],
[
new ServerAuthSessionCredentialValidationError({
new EnvironmentAuth.ServerAuthSessionCredentialValidationError({
cause: new Error("private credential diagnostic"),
}),
500,
Expand Down
21 changes: 14 additions & 7 deletions apps/server/src/device/DeviceMultiHost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import * as Deferred from "effect/Deferred";
import * as Fiber from "effect/Fiber";
import * as Effect from "effect/Effect";
import { HttpClient, HttpClientResponse } from "effect/unstable/http";
import { ServerSettingsService } from "../serverSettings.ts";
import { DeviceHostError, DeviceHost } from "./DeviceHost.ts";
import { makeWithHosts } from "./DeviceService.ts";
import * as ServerSettings from "../serverSettings.ts";
import * as DeviceHost from "./DeviceHost.ts";
import * as DeviceService from "./DeviceService.ts";

it.effect("keeps hosts independent when serials collide and another host fails", () =>
Effect.gen(function* () {
const host = (id: string, failed = false): DeviceHost["Service"] => {
const host = (id: string, failed = false): DeviceHost.DeviceHost["Service"] => {
const ready = {
nodePath: process.execPath,
hub: { origin: `http://${id}` },
Expand All @@ -32,7 +32,11 @@ it.effect("keeps hosts independent when serials collide and another host fails",
ensureReady: () =>
failed
? Effect.fail(
new DeviceHostError({ hostId: id, step: "connect", cause: new Error("offline") }),
new DeviceHost.DeviceHostError({
hostId: id,
step: "connect",
cause: new Error("offline"),
}),
)
: Effect.succeed(ready),
ensureAgentReady: () => Effect.succeed(ready),
Expand Down Expand Up @@ -65,7 +69,7 @@ it.effect("keeps hosts independent when serials collide and another host fails",
const writeStarted = yield* Deferred.make<void>();
const finishWrite = yield* Deferred.make<void>();
const order: string[] = [];
const service = yield* makeWithHosts(hosts, undefined, () =>
const service = yield* DeviceService.makeWithHosts(hosts, undefined, () =>
Effect.gen(function* () {
order.push("write started");
yield* Deferred.succeed(writeStarted, undefined);
Expand Down Expand Up @@ -120,7 +124,10 @@ it.effect("keeps hosts independent when serials collide and another host fails",
expect((yield* service.state).hostStatuses).toEqual({});
}).pipe(
Effect.provide(
ServerSettingsService.layerTest({ enableDeviceSupport: true, enableAgentDeviceAccess: true }),
ServerSettings.layerTest({
enableDeviceSupport: true,
enableAgentDeviceAccess: true,
}),
),
),
);
Loading
Loading