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
+40
View File
@@ -0,0 +1,40 @@
import { Rpc, RpcGroup } from "@effect/rpc";
import { Schema } from "effect";
const SourceSummarySchema = Schema.Struct({
id: Schema.String,
kind: Schema.String,
enabled: Schema.Boolean,
description: Schema.NullOr(Schema.String),
tool_count: Schema.Number,
node_spec_count: Schema.Number,
reducer_count: Schema.Number,
prompt_count: Schema.Number,
resource_count: Schema.Number,
});
export const WorkflowHealth = Rpc.make("workflow.health", {
payload: Schema.Struct({}),
success: Schema.Struct({
status: Schema.Literal("ok"),
store_root: Schema.String,
}),
error: Schema.Never,
});
export const WorkflowSourcesList = Rpc.make("workflow.sources.list", {
payload: Schema.Struct({
cursor: Schema.optional(Schema.String),
limit: Schema.optional(
Schema.Number.pipe(Schema.greaterThan(0), Schema.lessThan(101)),
),
}),
success: Schema.Struct({
sources: Schema.Array(SourceSummarySchema),
next_cursor: Schema.NullOr(Schema.String),
total: Schema.Number,
}),
error: Schema.Never,
});
export const WorkflowRpcs = RpcGroup.make(WorkflowHealth, WorkflowSourcesList);