Skip to content

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


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>

Source

Since v0.0.0

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.watch as ViewFrames.
  • WatchEvents: AgentEvent.watch, one array per commit, the snapshot event first.

Signature

declare class Rpcs

Source

Since v0.0.0

Conversation.submit’s draft on the wire.

Signature

declare const SubmissionDraftSchema: any

Source

Since v0.0.0

A SubmissionRecord on the wire.

Signature

declare const SubmissionRecordSchema: any

Source

Since v0.0.0

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: any

Source

Since v0.0.0

Signature

type ViewFrame = typeof ViewFrame.Type

Source

Since 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: any

Source

Since v0.0.0

Wait for a submission through the client, typed as the settled record.

Signature

declare const waitSubmission: (client: Client, submissionId: SubmissionId) => any

Source

Since v0.0.0

A conversation’s agent events: the snapshot event, then every later event (see AgentEvent.watch).

Signature

declare const watchEvents: (client: Client, conversationId: ConversationId) => any

Source

Since v0.0.0

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) => any

Source

Since v0.0.0