Fix Effect type warnings to pass typecheck
- Use generic type parameter for stream errors instead of unknown - Type ServerShape errors as ServerLifecycleError instead of unknown - Add error mapping for autoBootstrapProject and httpServerListen - Type makeServerProviderLayer with ProviderUnsupportedError - Use Effect.try with decodeUnknownSync in projector to avoid unknown requirements - Fix test layer types from any/unknown to never Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
1 parent
c8989287d3
commit
3907e5e8c5
6 files changed
+41
-29
No files matched your search
@@ -129,9 +129,9 @@ const makeCodexTextGeneration = Effect.gen(function* () {
|
||||
const path = yield* Path.Path;
|
||||
const commandSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
|
||||
const readStreamAsString = (
|
||||
const readStreamAsString = <E>(
|
||||
operation: string,
|
||||
stream: Stream.Stream<Uint8Array, unknown>,
|
||||
stream: Stream.Stream<Uint8Array, E>,
|
||||
): Effect.Effect<string, TextGenerationError> =>
|
||||
Effect.gen(function* () {
|
||||
let text = "";
|
||||
|
||||
@@ -39,9 +39,9 @@ function toGitCommandError(
|
||||
});
|
||||
}
|
||||
|
||||
const collectOutput = Effect.fn(function* (
|
||||
const collectOutput = Effect.fn(function* <E>(
|
||||
input: Pick<ExecuteGitInput, "operation" | "cwd" | "args">,
|
||||
stream: Stream.Stream<Uint8Array, unknown>,
|
||||
stream: Stream.Stream<Uint8Array, E>,
|
||||
maxOutputBytes: number,
|
||||
): Effect.fn.Return<string, GitCommandError> {
|
||||
const decoder = new TextDecoder();
|
||||
|
||||
@@ -40,9 +40,12 @@ function decodeForEvent<A>(
|
||||
eventType: OrchestrationEvent["type"],
|
||||
field: string,
|
||||
): Effect.Effect<A, OrchestrationProjectorDecodeError> {
|
||||
return Schema.decodeUnknownEffect(schema)(value).pipe(
|
||||
Effect.mapError(toProjectorDecodeError(`${eventType}:${field}`)),
|
||||
) as Effect.Effect<A, OrchestrationProjectorDecodeError>;
|
||||
return Effect.try({
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
try: () => Schema.decodeUnknownSync(schema as any)(value) as A,
|
||||
catch: (error) =>
|
||||
toProjectorDecodeError(`${eventType}:${field}`)(error as Schema.SchemaError),
|
||||
});
|
||||
}
|
||||
|
||||
function retainThreadMessagesAfterRevert(
|
||||
|
||||
@@ -17,6 +17,7 @@ import { ProviderCommandReactorLive } from "./orchestration/Layers/ProviderComma
|
||||
import { OrchestrationProjectionPipelineLive } from "./orchestration/Layers/ProjectionPipeline";
|
||||
import { OrchestrationProjectionSnapshotQueryLive } from "./orchestration/Layers/ProjectionSnapshotQuery";
|
||||
import { ProviderRuntimeIngestionLive } from "./orchestration/Layers/ProviderRuntimeIngestion";
|
||||
import { ProviderUnsupportedError } from "./provider/Errors";
|
||||
import { makeCodexAdapterLive } from "./provider/Layers/CodexAdapter";
|
||||
import { ProviderAdapterRegistryLive } from "./provider/Layers/ProviderAdapterRegistry";
|
||||
import { makeProviderServiceLive } from "./provider/Layers/ProviderService";
|
||||
@@ -35,7 +36,7 @@ import { NodePtyAdapterLive } from "./terminal/Layers/NodePTY";
|
||||
|
||||
export function makeServerProviderLayer(): Layer.Layer<
|
||||
ProviderService,
|
||||
unknown,
|
||||
ProviderUnsupportedError,
|
||||
SqlClient.SqlClient | ServerConfig
|
||||
> {
|
||||
return Effect.gen(function* () {
|
||||
|
||||
@@ -323,14 +323,14 @@ describe("WebSocket Server", () => {
|
||||
|
||||
async function createTestServer(
|
||||
options: {
|
||||
persistenceLayer?: Layer.Layer<SqlClient.SqlClient, any>;
|
||||
persistenceLayer?: Layer.Layer<SqlClient.SqlClient, never>;
|
||||
cwd?: string;
|
||||
autoBootstrapProjectFromCwd?: boolean;
|
||||
logWebSocketEvents?: boolean;
|
||||
devUrl?: string;
|
||||
authToken?: string;
|
||||
stateDir?: string;
|
||||
providerLayer?: Layer.Layer<ProviderService, unknown>;
|
||||
providerLayer?: Layer.Layer<ProviderService, never>;
|
||||
open?: OpenShape;
|
||||
gitManager?: GitManagerShape;
|
||||
gitCore?: Pick<GitCoreShape, "listBranches" | "initRepo" | "pullCurrentBranch">;
|
||||
|
||||
+27
-19
@@ -66,14 +66,14 @@ export interface ServerShape {
|
||||
*/
|
||||
readonly start: Effect.Effect<
|
||||
http.Server,
|
||||
unknown,
|
||||
ServerLifecycleError,
|
||||
Scope.Scope | ServerRuntimeServices | ServerConfig
|
||||
>;
|
||||
|
||||
/**
|
||||
* Wait for process shutdown signals.
|
||||
*/
|
||||
readonly stopSignal: Effect.Effect<unknown, never>;
|
||||
readonly stopSignal: Effect.Effect<void, never>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ class RouteRequestError extends Schema.TaggedErrorClass<RouteRequestError>()("Ro
|
||||
|
||||
export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
http.Server,
|
||||
unknown, // TODO: This should not be unknown
|
||||
ServerLifecycleError,
|
||||
Scope.Scope | ServerRuntimeServices | ServerConfig
|
||||
> {
|
||||
const serverConfig = yield* ServerConfig;
|
||||
@@ -338,21 +338,27 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
yield* Scope.provide(orchestrationReactor.start, subscriptionsScope);
|
||||
|
||||
if (autoBootstrapProjectFromCwd) {
|
||||
const snapshot = yield* projectionReadModelQuery.getSnapshot();
|
||||
const existing = snapshot.projects.find((project) => project.workspaceRoot === cwd);
|
||||
if (!existing) {
|
||||
const createdAt = new Date().toISOString();
|
||||
const projectName = path.basename(cwd) || "project";
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "project.create",
|
||||
commandId: CommandId.makeUnsafe(crypto.randomUUID()),
|
||||
projectId: ProjectId.makeUnsafe(crypto.randomUUID()),
|
||||
title: projectName,
|
||||
workspaceRoot: cwd,
|
||||
defaultModel: "gpt-5-codex",
|
||||
createdAt,
|
||||
});
|
||||
}
|
||||
yield* Effect.gen(function* () {
|
||||
const snapshot = yield* projectionReadModelQuery.getSnapshot();
|
||||
const existing = snapshot.projects.find((project) => project.workspaceRoot === cwd);
|
||||
if (!existing) {
|
||||
const createdAt = new Date().toISOString();
|
||||
const projectName = path.basename(cwd) || "project";
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "project.create",
|
||||
commandId: CommandId.makeUnsafe(crypto.randomUUID()),
|
||||
projectId: ProjectId.makeUnsafe(crypto.randomUUID()),
|
||||
title: projectName,
|
||||
workspaceRoot: cwd,
|
||||
defaultModel: "gpt-5-codex",
|
||||
createdAt,
|
||||
});
|
||||
}
|
||||
}).pipe(
|
||||
Effect.mapError(
|
||||
(cause) => new ServerLifecycleError({ operation: "autoBootstrapProject", cause }),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const routeRequest = Effect.fnUntraced(function* (request: WebSocketRequest) {
|
||||
@@ -618,7 +624,9 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
);
|
||||
yield* Effect.addFinalizer(() => Effect.sync(() => unsubscribeTerminalEvents()));
|
||||
|
||||
yield* NodeHttpServer.make(() => httpServer, listenOptions);
|
||||
yield* NodeHttpServer.make(() => httpServer, listenOptions).pipe(
|
||||
Effect.mapError((cause) => new ServerLifecycleError({ operation: "httpServerListen", cause })),
|
||||
);
|
||||
|
||||
yield* Effect.addFinalizer(() =>
|
||||
Effect.all([
|
||||
|
||||
Reference in new issue
Block a user