Skip to content

HostProtocol

The RPC group a host serves over its unix socket (effect/rpc, NDJSON). Every payload, result and error is a Schema, so typed failures (TurnFailure members, SessionError members, EventsTrimmed) arrive as the same classes on the client.

Since v0.1.0

subscribeFrom asked for events the host no longer has: older than its in-memory cache (HostSpec.maxEvents) when events aren’t persisted (persistEvents: false), or when the events file is missing or unreadable.

Signature

declare class EventsTrimmed

Source

Since v0.1.0

A hook’s input: ToolHookInput (plus output/isError for afterTool); null for beforeStop.

Signature

declare const HookCall: Schema.Struct<{
readonly callId: Schema.String
readonly name: Schema.String
readonly input: Schema.Unknown
readonly output: Schema.optionalKey<Schema.String>
readonly isError: Schema.optionalKey<Schema.Boolean>
}>

Source

Since v0.1.0

Signature

type HookCall = typeof HookCall.Type

Source

Since v0.1.0

The hooks a client can answer for a host.

Signature

declare const HookName: Schema.Literals<
readonly ["beforeTool", "afterTool", "beforeStop"]
>

Source

Since v0.1.0

Signature

type HookName = typeof HookName.Type

Source

Since v0.1.0

The host asks a client to run one of its hooks.

Signature

declare const HookRequest: Schema.TaggedStruct<
"HookRequest",
{
readonly hookId: Schema.String
readonly hook: Schema.Literals<readonly ["beforeTool", "afterTool", "beforeStop"]>
readonly call: Schema.NullOr<
Schema.Struct<{
readonly callId: Schema.String
readonly name: Schema.String
readonly input: Schema.Unknown
readonly output: Schema.optionalKey<Schema.String>
readonly isError: Schema.optionalKey<Schema.Boolean>
}>
>
}
>

Source

Since v0.1.0

Signature

type HookRequest = typeof HookRequest.Type

Source

Since v0.1.0

HookRequests items: Registered first (the client is answering from now on), then requests.

Signature

declare const HookStreamItem: Schema.Union<
readonly [
Schema.TaggedStruct<"Registered", {}>,
Schema.TaggedStruct<
"HookRequest",
{
readonly hookId: Schema.String
readonly hook: Schema.Literals<
readonly ["beforeTool", "afterTool", "beforeStop"]
>
readonly call: Schema.NullOr<
Schema.Struct<{
readonly callId: Schema.String
readonly name: Schema.String
readonly input: Schema.Unknown
readonly output: Schema.optionalKey<Schema.String>
readonly isError: Schema.optionalKey<Schema.Boolean>
}>
>
}
>,
]
>

Source

Since v0.1.0

Signature

type HookStreamItem = typeof HookStreamItem.Type

Source

Since v0.1.0

What Info returns: the session, the host, and the range of events it can serve.

Signature

declare const HostInfo: Schema.Struct<{
readonly sessionId: Schema.brand<Schema.String, "effect-agent/SessionId">
readonly provider: Schema.String
readonly location: Schema.NullOr<Schema.String>
readonly pid: Schema.NullOr<Schema.Number>
readonly hostPid: Schema.Number
readonly capabilities: Schema.Struct<{
readonly provider: Schema.String
readonly version: Schema.NullOr<Schema.String>
readonly steer: Schema.Boolean
readonly queue: Schema.Boolean
readonly resume: Schema.Boolean
readonly cost: Schema.Literals<readonly ["reported", "estimated", "none"]>
readonly spendCap: Schema.Literals<readonly ["native", "estimated", "none"]>
readonly resetTimes: Schema.Boolean
readonly hooks: Schema.Boolean
readonly refuseTool: Schema.optionalKey<Schema.Boolean>
readonly reattach: Schema.Boolean
readonly disable: Schema.Struct<{
readonly askUser: Schema.Boolean
readonly subagents: Schema.Boolean
readonly tools: Schema.Literals<readonly ["any", "some"]>
}>
}>
readonly lastSeq: Schema.Number
readonly oldestSeq: Schema.Number
readonly ended: Schema.Boolean
}>

Source

Since v0.1.0

Signature

type HostInfo = typeof HostInfo.Type

Source

Since v0.1.0

An event and its position in the session’s log (0, 1, 2, …).

Signature

declare const SeqEvent: Schema.Struct<{
readonly seq: Schema.Number
readonly event: Schema.Union<
readonly [
Schema.TaggedStruct<
"SessionStarted",
{
readonly sessionId: Schema.brand<Schema.String, "effect-agent/SessionId">
readonly provider: Schema.String
readonly version: Schema.NullOr<Schema.String>
readonly model: Schema.NullOr<Schema.String>
readonly resumed: Schema.Boolean
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"TurnStarted",
{
readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId">
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"MessageLanded",
{
readonly messageId: Schema.brand<Schema.String, "effect-agent/MessageId">
readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId">
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"MessageDropped",
{
readonly messageId: Schema.brand<Schema.String, "effect-agent/MessageId">
readonly reason: Schema.String
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"UserMessage",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly messageId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/MessageId">
>
readonly text: Schema.String
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"Text",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly text: Schema.String
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"ToolCall",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly callId: Schema.String
readonly name: Schema.String
readonly summary: Schema.String
readonly input: Schema.Unknown
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"ToolResult",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly callId: Schema.String
readonly isError: Schema.Boolean
readonly output: Schema.String
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"Retrying",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly attempt: Schema.NullOr<Schema.Number>
readonly maxAttempts: Schema.NullOr<Schema.Number>
readonly delayMs: Schema.NullOr<Schema.Number>
readonly message: Schema.String
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"LimitsUpdated",
{
readonly windows: Schema.$Array<
Schema.Struct<{
readonly window: Schema.Literals<
readonly ["five_hour", "weekly", "other"]
>
readonly label: Schema.String
readonly usedPercent: Schema.NullOr<Schema.Number>
readonly resetsAt: Schema.NullOr<Schema.DateTimeUtcFromMillis>
readonly model: Schema.OptionFromNullOr<Schema.String>
}>
>
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"Compacted",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly trigger: Schema.NullOr<Schema.Literals<readonly ["auto", "manual"]>>
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"Heartbeat",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"TurnEnded",
{
readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId">
readonly outcome: Schema.Union<
readonly [
Schema.TaggedStruct<
"Succeeded",
{
readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId">
readonly finalText: Schema.String
}
>,
Schema.Union<
readonly [
typeof AgentFailed,
typeof UsageLimited,
typeof Throttled,
typeof AuthFailed,
typeof SpendCapReached,
typeof ContextExhausted,
typeof ProcessKilled,
typeof Stalled,
typeof Interrupted,
]
>,
]
>
readonly usage: Schema.NullOr<
Schema.Struct<{
readonly inputTokens: Schema.Number
readonly cachedInputTokens: Schema.Number
readonly outputTokens: Schema.Number
readonly reasoningTokens: Schema.NullOr<Schema.Number>
}>
>
readonly cost: Schema.NullOr<
Schema.Struct<{
readonly usd: Schema.Number
readonly source: Schema.Literals<readonly ["reported", "estimated"]>
}>
>
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<"Other", { readonly raw: Schema.Unknown }>,
]
>
}>

Source

Since v0.1.0

Signature

type SeqEvent = typeof SeqEvent.Type

Source

Since v0.1.0

Signature

declare class HostRpcs

Source

Since v0.1.0