feat: expose workflow console api and RPC service with @effect/rpc

- Replace manual JSON-RPC protocol handling with @effect/rpc typed RPCs
- Add evidence capture layer (per-call Ref, response body buffering/reconstruction)
- Add service module with typed dispatch and layer composition via Layer.mergeAll
- Add Hono API with /api/health, /api/connect, /api/rpc routes
- Add browser DTO contracts, error mapping, body size limits
- Add 13 Hono route tests and 12 target-policy tests passing
- Delete old protocol.ts and protocol.test.ts (replaced by rpcs.ts/service.ts)
This commit is contained in:
lda
2026-07-02 12:18:25 +07:00 Verified
parent e149a39b9e
commit 60a7dd2830
16 changed files with 1188 additions and 205 deletions
+39
View File
@@ -0,0 +1,39 @@
import { Effect, Layer } from "effect";
import { serve } from "@hono/node-server";
import {
WorkflowRpc,
makeWorkflowRpcLayer,
type OperationExchange,
type OperationName,
} from "@lda/workflow-rpc";
import { createApp, type RunOperation } from "./app.js";
const port = Number(process.env.WEB_PORT ?? "8787");
if (Number.isNaN(port) || port < 1 || port > 65535) {
console.error(`Invalid WEB_PORT: ${process.env.WEB_PORT}`);
process.exit(1);
}
const hostname = process.env.WEB_HOST ?? "127.0.0.1";
const liveLayer = makeWorkflowRpcLayer;
const runOperation: RunOperation = async (
operation: OperationName,
target: string,
params: unknown,
): Promise<OperationExchange> =>
Effect.gen(function* () {
const { execute } = yield* WorkflowRpc;
return yield* execute(operation, target, params);
}).pipe(Effect.provide(liveLayer), Effect.runPromise);
const app = createApp({ runOperation });
serve({
fetch: app.fetch,
hostname,
port,
});
console.log(`workflow console server listening on http://${hostname}:${port}`);