Remote
Remote views and control over effect/rpc: an RpcGroup exposing a Harness’s conversations to another process —
submit, abort, wait, the view as a stream of JSON Patch frames, and the agent events — with the server handlers
over a Harness and typed client helpers.
import { Remote } from "@effective-harness/core"import * as Effect from "effect/Effect"import * as Layer from "effect/Layer"import * as RpcClient from "effect/rpc/RpcClient"import * as RpcServer from "effect/rpc/RpcServer"import * as Stream from "effect/Stream"
// Server: serve the group over any protocol (HTTP, WebSocket, stdio, workers).declare const Protocol: Layer.Layer<RpcServer.Protocol>const Server = RpcServer.layer(Remote.Rpcs).pipe(Layer.provide(Remote.layer), Layer.provide(Protocol))
// Client: a typed client, then the view as values.const program = Effect.gen(function* () { const client = yield* RpcClient.make(Remote.Rpcs) const id = yield* client.Submit({ conversationId: 1 as never, draft: { type: "input", content: "hi" } }) yield* Stream.runForEach(Remote.watchView(client, 1 as never), (view) => Effect.log(view.entries.length))})The view stream sends the current view as one root replace frame, then each commit’s operations; a client that
falls behind gets one root replace (see View.watch). Reconnecting starts a new stream from the current view.
Since v0.0.0
Client (type alias)
Section titled “Client (type alias)”A client of Rpcs, as RpcClient.make(Remote.Rpcs) or RpcTest.makeClient(Remote.Rpcs) build it.
Signature
type Client = RpcClient.RpcClient<RpcGroup.Rpcs<typeof Rpcs>, RpcClientError.RpcClientError>Since v0.0.0
Rpcs (class)
Section titled “Rpcs (class)”The remote control group.
Submit:Conversation.submit.Abort:Conversation.abort;WaitForIdle:Conversation.waitForIdle.SubmissionStatus,WaitSubmission,AbortSubmission:Submission.status/wait/abort.View:View.get, as JSON;WatchView:View.watchasViewFrames.WatchEvents:AgentEvent.watch, one array per commit, thesnapshotevent first.
Signature
declare class RpcsSince v0.0.0
SubmissionDraftSchema
Section titled “SubmissionDraftSchema”Conversation.submit’s draft on the wire.
Signature
declare const SubmissionDraftSchema: anySince v0.0.0
SubmissionRecordSchema
Section titled “SubmissionRecordSchema”A SubmissionRecord on the wire.
Signature
declare const SubmissionRecordSchema: anySince v0.0.0
ViewFrame
Section titled “ViewFrame”One frame of a view stream: JSON Patch operations from the previous frame’s value. The first frame (seq absent)
and an overflow replace the root.
Signature
declare const ViewFrame: anySince v0.0.0
ViewFrame (type alias)
Section titled “ViewFrame (type alias)”Signature
type ViewFrame = typeof ViewFrame.TypeSince v0.0.0
The handlers of Rpcs over the Harness in context. Serve them with RpcServer.layer(Remote.Rpcs) and a protocol.
Signature
declare const layer: anySince v0.0.0
waitSubmission
Section titled “waitSubmission”Wait for a submission through the client, typed as the settled record.
Signature
declare const waitSubmission: (client: Client, submissionId: SubmissionId) => anySince v0.0.0
watchEvents
Section titled “watchEvents”A conversation’s agent events: the snapshot event, then every later event (see AgentEvent.watch).
Signature
declare const watchEvents: (client: Client, conversationId: ConversationId) => anySince v0.0.0
watchView
Section titled “watchView”A conversation’s view as values: the frames of WatchView applied in order, starting with the current view.
Signature
declare const watchView: (client: Client, conversationId: ConversationId) => anySince v0.0.0