Documentation
¶
Overview ¶
Package wire holds the frames of Appendix B: the types both ends of a connection share, so the bridge and the broker cannot drift apart.
Index ¶
Constants ¶
const ( ReasonUnauthenticated = "unauthenticated" // 401: no valid token for this API ReasonNotPermitted = "not_permitted" // 403: a valid token outside the allowlist ReasonRunNotLive = "run_not_live" // 403: the run ended, was revoked, or is not watched ReasonRunHasNoRoom = "run_has_no_room" // 403: the run names no room ReasonRoomBusy = "room_busy" // 409 on hello: another live run holds the room ReasonLeaseLost = "lease_lost" // 409 on events: another run took the room's bridge lease ReasonSealed = "sealed" // 410: the room's log is sealed ReasonBadBatch = "bad_batch" // 400: the body is not a batch ReasonBatchTooLarge = "batch_too_large" // 413: over the byte or item cap; split it ReasonBadItem = "bad_item" // 400: an item a bridge may not push (review M5), or keys spelled two ways ReasonBadPayload = "bad_payload" // 400: a payload that is not a JSON object ReasonBadRoom = "bad_room" // 400: not a C2 room id ReasonBadMessage = "bad_message" // 400: not a task_state message, or not a message to queue ReasonBadStream = "bad_stream" // 400: a queue stream that is not [a-z]{1,16} ReasonBadConsume = "bad_consume" // 400: a consume without a C2 run id, or over 100 refs ReasonNoQueue = "no_queue" // 501: this broker serves no queue routes ReasonBadApproval = "bad_approval" // 400: not an approval request: no eventId or callId, or an unknown class ReasonBadAction = "bad_action" // 400: an approval's action that is not a JSON object, or over the cap ReasonNoRoom = "no_room" // 404 (system API) or 503 (hello, before the Room's first reconcile) ReasonRateLimited = "rate_limited" // 429: over the principal's request rate or requests in flight; retry after Retry-After ReasonTimedOut = "timed_out" // 503: the request's deadline passed before it was written; retry ReasonStreamingFailed = "streaming_refused" // 500: the connection cannot stream ReasonBadSlackUser = "bad_slack_user" // 400: a Slack link read without a T… team and a U…/W… user ReasonNotLinked = "not_linked" // 404: the Slack user has no self-serve link ReasonBadGrant = "bad_grant" // 400: a grant lookup or move that is not one: a bad id, repository, class, hash or version ReasonNoGrant = "no_grant" // 404: no approval grant has that id ReasonGrantState = "grant_state" // 409: the grant's status or version does not allow the move ReasonBadBundle = "bad_bundle" // 400: a bundle read without a 64-hex digest and a C2 run id ReasonNoBundle = "no_bundle" // 404: the room holds no bundle for that run and digest ReasonNoApproval = "no_approval" // 404: no approval has that id ReasonBindingConflict = "binding_conflict" // 409: the output's approval already binds another digest or branch )
The refusal reasons of :8443. A bridge never drops its buffer on a 409: both room_busy and lease_lost mean another run holds the room (Ruling Y), and the bridge says hello again later.
const ( EventDeliver = "deliver" EventDecision = "decision" EventInterrupt = "interrupt" )
SSE event names, broker → bridge.
const ( FrameHello = "hello" FrameAct = "act" FramePing = "ping" FrameState = "state" FrameSync = "sync" FrameEvent = "event" FrameAck = "ack" FrameTransient = "transient" )
The browser's frame types (Appendix B): one JSON object per WebSocket text frame.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApprovalAck ¶
type ApprovalAck struct {
ApprovalID string `json:"approvalId"`
ExpiresAt time.Time `json:"expiresAt"`
}
ApprovalAck answers an ApprovalRequest: the approval's id, which a later decision names, and when the broker expires it.
type ApprovalPolicy ¶
type ApprovalPolicy struct {
Profile string `json:"profile"`
Overrides map[string]string `json:"overrides,omitempty"`
TTL string `json:"ttl,omitempty"`
}
ApprovalPolicy is the room's approval profile, handed to the bridge at hello (phase 5; empty until then).
type ApprovalRequest ¶
type ApprovalRequest struct {
EventID string `json:"eventId"`
CallID string `json:"callId"`
Class string `json:"class"`
Action json.RawMessage `json:"action"`
}
ApprovalRequest is the body of POST /v1/bridge/approvals: a pending action whose class the room's policy sends to its approvers (phase 5). EventID, the harness event's id, keys the request's idempotency: a model provider may reuse a tool call id (review I2).
type ApprovalView ¶
type ApprovalView struct {
ApprovalID string `json:"approvalId"`
RunID string `json:"runId"`
CallID string `json:"callId"`
Class string `json:"class"`
Action json.RawMessage `json:"action"`
ExpiresAt time.Time `json:"expiresAt"`
Seq int64 `json:"seq"` // its approval_requested event
// Prompters are who prompted the turn; with the room's FourEyes on, none of them decides.
Prompters []string `json:"prompters"`
}
ApprovalView is one approval still pending: its card (§6). Action is the raw, redacted call, never agent prose (T3).
type Batch ¶
type Batch struct {
Items []Item `json:"items"`
}
Batch is the body of POST /v1/bridge/events.
type BatchAck ¶
type BatchAck struct {
AfterHarnessSeq int64 `json:"afterHarnessSeq"`
AfterStatusSeq int64 `json:"afterStatusSeq"`
}
BatchAck is the highest seq of each stream the log now holds from the batch.
type ClientFrame ¶
type ClientFrame struct {
Type string `json:"type"`
RoomID string `json:"roomId,omitempty"`
AfterSeq *int64 `json:"afterSeq,omitempty"`
Tail int `json:"tail,omitempty"`
ClientSeq int64 `json:"clientSeq,omitempty"`
Action json.RawMessage `json:"action,omitempty"`
DriverEpoch *int64 `json:"driverEpoch,omitempty"`
}
ClientFrame is a frame from a browser or maku: hello first, then acts and pings.
type Decision ¶
type Decision struct {
ApprovalID string `json:"approvalId"`
Allow bool `json:"allow"`
Reason string `json:"reason,omitempty"`
Ref int64 `json:"ref"`
}
Decision answers an approval the harness is waiting on (phase 5). Ref is the approval_decided event's seq, which the bridge acknowledges as decision_applied.
type Error ¶
type Error struct {
Reason string `json:"error"`
}
Error is the body of every refusal on :8443. Reason is one of the Reason constants: stable strings a client may branch on, unlike the status text.
type Interrupt ¶
type Interrupt struct {
Ref int64 `json:"ref"`
}
Interrupt stops the run's current turn (phase 4).
type Item ¶
type Item struct {
Stream Stream `json:"stream"`
Seq int64 `json:"seq"`
Type envelope.Type `json:"type"`
Payload json.RawMessage `json:"payload"`
}
Item is one event a bridge pushes. Seq is its idempotency key within Stream.
type QueuedView ¶
type QueuedView struct {
Ref int64 `json:"ref"`
Author string `json:"author"`
Text string `json:"text"`
}
QueuedView is one message still queued for the next run.
type Resume ¶
type Resume struct {
RoomID string `json:"roomId"`
AfterHarnessSeq int64 `json:"afterHarnessSeq"`
AfterStatusSeq int64 `json:"afterStatusSeq"`
Approvals ApprovalPolicy `json:"approvals"`
}
Resume answers the bridge's hello: where the log already is.
type RunView ¶
type RunView struct {
ID string `json:"id"`
Role string `json:"role"`
Phase string `json:"phase"`
// Unsandboxed: the run's pod has no RuntimeClass.
Unsandboxed bool `json:"unsandboxed,omitempty"`
}
RunView is one run of the room, as the snapshot shows it.
type ServerFrame ¶
type ServerFrame struct {
Type string `json:"type"`
ThroughSeq int64 `json:"throughSeq,omitempty"`
FromSeq int64 `json:"fromSeq,omitempty"`
Snapshot *Snapshot `json:"snapshot,omitempty"`
Event *envelope.Event `json:"event,omitempty"`
ClientSeq int64 `json:"clientSeq,omitempty"`
Seq int64 `json:"seq,omitempty"`
Rejected string `json:"rejected,omitempty"`
Result json.RawMessage `json:"result,omitempty"` // e.g. a rendered AgentRun before SP3
}
ServerFrame is a frame from the broker: state, sync, event, ack or transient.
type Snapshot ¶
type Snapshot struct {
RoomID string `json:"roomId"`
Phase string `json:"phase"`
Driver string `json:"driver"`
DriverEpoch int64 `json:"driverEpoch"`
DataClass string `json:"dataClass"`
You You `json:"you"`
Runs []RunView `json:"runs"`
// Queue is read after the mark: the client applies events past ThroughSeq over
// it, so a row queued or moved in between is idempotent either way.
Queue []QueuedView `json:"queue"`
// Sealed is the log's own seal at the mark; Phase follows the Room CR and lags it.
Sealed bool `json:"sealed"`
// Approvals are the pending ones, read after the mark like Queue: a request
// may be far behind the page's tail.
Approvals []ApprovalView `json:"approvals"`
// FourEyes is the room's rule that nobody who prompted a turn decides its approvals.
FourEyes bool `json:"fourEyes"`
}
Snapshot is the room's state at the high-water mark of a state frame.