Skip to content

SessionHost

The program a session host process runs. The library ships no executable: add a one-line entry to your app, give it your platform’s services, and point DetachedAgent.layer({ host }) at it.

host.ts
import { NodeRuntime, NodeServices } from "@effect/platform-node"
import { Effect } from "effect"
import { SessionHost } from "@jpowersdev/effect-agent/host"
NodeRuntime.runMain(SessionHost.run.pipe(Effect.provide(NodeServices.layer)))

(On Bun: BunRuntime and BunServices from @effect/platform-bun.)

run reads a JSON HostSpec from Stdio.stdin and writes one readiness line to Stdio.stdout (Ready or Failed). After that, all output goes to <dir>/<sessionId>.log, and it serves one session until it ends.

It owns the process while it runs (stdio, signals), so run nothing else in that process. Bundling and the runtime are up to the entry, as for any other entry point in your app.

Since v0.1.0

The host could not start, or its session failed in a way it couldn’t recover from.

Signature

declare class HostFailed

Source

Since v0.1.0

Signature

declare const run: Effect.Effect<
void,
HostFailed,
Stdio.Stdio | ChildProcessSpawner.ChildProcessSpawner
>

Source

Since v0.1.0