turnevent

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package turnevent defines the neutral, daemon-owned outbound turn-event model for Phase 2 structured streaming (EPIC #596).

These are pure value types — no transport, no I/O, standard library only. They are the stable internal contract that the event-stream bridge (#608) maps tui-driver Events() INTO and that the v2 wire types (#607) map OUT of. The mobile wire (now) and the future pyry acp adapter (#600) are thin adapters over this one model: it is shaped ~90% like ACP so the ACP adapter is near pass-through, but it is owned by us — so churn in the external ACP spec stays inside the ACP adapter and never reaches the daemon core or the mobile wire. Same containment logic the tui-driver substrate seal applies to claude's screen.

This is the outbound turn-event core only. No Events() draining and no envelope mapping live here. Inbound commands (Prompt, Cancel, …) and the internal-only BusyState event are out of scope and get a home in a later ticket. The internal-only Stall event now lives here (mobile-sent, ACP-dropped); see its type doc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cancel

type Cancel struct{}

Cancel is an inbound command: stop the current turn (the neutral form of a remote Esc / ACP session/cancel, #600). Fieldless — the daemon has one live turn context, so no correlation id is needed yet; #600 adds a session/turn id additively if ACP needs one.

Cancel is declared vocabulary in this slice: the mobile interrupt frame routes to Esc directly via the relay seam (internal/relay handleInterrupt), it does not construct a Cancel value — mirroring how the mobile modal_cancel frame routes to ModalResolver.ResolveCancel rather than building a PermissionResponse. The mobile-wire → neutral-Cancel translator is the ACP adapter's job (#600); Cancel exists now so #600 has its target.

type DiffContent

type DiffContent struct {
	Path    string
	OldText string
	NewText string
}

DiffContent is a file edit a tool produced.

type Event

type Event interface {
	// contains filtered or unexported methods
}

Event is the sealed sum type of outbound turn events: TextChunk, ThoughtChunk, ToolStart, ToolUpdate, TurnEnd, and the internal-only Stall. The unexported marker keeps the variant set closed to this package, so external ACP-spec churn cannot inject a variant. The bridge (#608) ranges a stream of Event and the wire adapter (#607) type-switches to map each kind.

type Inbound

type Inbound interface {
	// contains filtered or unexported methods
}

Inbound is the sealed sum type of inbound commands the consumer sends back to the daemon. The unexported marker keeps the variant set closed to this package, mirroring Event and ToolContent. PermissionResponse is the first member; #707 adds Cancel. The remaining deferred inbound commands (Prompt / DropQueued) join the same set when their tickets land. Cancel keeps the marker here beside its sibling — the relocation to a separate file hinted above is optional churn this slice declines.

type Location

type Location struct {
	Path string
	Line int
}

Location is a file a tool call touches (ACP tool-call location). Line is 1-based; 0 means unspecified.

type PermissionOption

type PermissionOption struct {
	ID    string               // referenced by PermissionResponse.OptionID
	Label string               // human-readable ("Yes", "No, and don't ask again")
	Kind  PermissionOptionKind // the ACP semantic kind
}

PermissionOption is one selectable answer in a PermissionRequest. Order within PermissionRequest.Options is significant — the consumer renders in order.

type PermissionOptionKind

type PermissionOptionKind string

PermissionOptionKind is the ACP session/request_permission option-kind taxonomy.

const (
	PermissionOptionKindAllowOnce    PermissionOptionKind = "allow_once"
	PermissionOptionKindAllowAlways  PermissionOptionKind = "allow_always"
	PermissionOptionKindRejectOnce   PermissionOptionKind = "reject_once"
	PermissionOptionKindRejectAlways PermissionOptionKind = "reject_always"
)

func (PermissionOptionKind) Valid

func (k PermissionOptionKind) Valid() bool

Valid reports whether k is one of the ACP permission-option kinds.

type PermissionRequest

type PermissionRequest struct {
	RequestID  string             // correlates request <-> response
	ToolCallID string             // the tool call this gates; "" if not tool-triggered
	Title      string             // human-readable prompt text (e.g. "Do you want to proceed?")
	Options    []PermissionOption // ordered; the consumer renders + selects from these
}

PermissionRequest is an outbound Event: the daemon asks the consumer (phone / ACP client) to answer a permission modal, correlated to its inbound PermissionResponse by RequestID. ACP's session/request_permission (#600) maps onto this same shape, so it is adapter-neutral, not mobile-specific.

It references the gating tool call by ToolCallID — the same by-id reference style ToolUpdate uses — rather than re-embedding tool details; the consumer already saw the matching ToolStart in the stream. ToolCallID is empty when a permission prompt has no backing tool call.

func NewPermissionRequest

func NewPermissionRequest(requestID, toolCallID, title string, options []PermissionOption) PermissionRequest

NewPermissionRequest assembles a PermissionRequest from its parts. It does NOT validate — constructing an invalid one (e.g. an option with an out-of-taxonomy Kind) is allowed and caught downstream via PermissionOptionKind.Valid(), matching the package's construct-then-validate-downstream convention.

type PermissionResponse

type PermissionResponse struct {
	RequestID string // the PermissionRequest this answers
	OptionID  string // the selected PermissionOption.ID; "" when Cancelled
	Cancelled bool   // true => the consumer dismissed the modal without selecting
}

PermissionResponse is an inbound command answering a PermissionRequest, matched by RequestID. Exactly one outcome is meaningful: either OptionID names the selected PermissionOption.ID, or Cancelled is true (the consumer dismissed the modal without selecting). The package does not enforce that exclusivity — validation is the inbound parser's job, consistent with the package's stance.

type Stall

type Stall struct{}

Stall is an internal-only onset marker: tui-driver raised a one-shot stall_detected signal (no payload, no clearing edge). It carries no fields — onset only, no "cleared" state, and (like every variant here) no conversation identity; the bridge injects that when mapping to the wire. The mobile adapter sends it as the wire "stall" event; the future ACP adapter (#600) drops it (no ACP equivalent).

type TerminalContent

type TerminalContent struct {
	TerminalID string
}

TerminalContent references, by id, a terminal a tool is driving.

type TextChunk

type TextChunk struct {
	MessageID string
	Text      string
}

TextChunk is incremental assistant text, grouped by message.

type TextContent

type TextContent struct {
	Text string
}

TextContent is plain text tool output.

type ThoughtChunk

type ThoughtChunk struct {
	MessageID string
	Text      string
}

ThoughtChunk is streaming reasoning ("thinking") text, grouped by message.

type ToolContent

type ToolContent interface {
	// contains filtered or unexported methods
}

ToolContent is the sealed sum type a ToolUpdate carries: text, diff, or terminal. A consumer recovers the concrete shape with a type switch. A nil ToolContent is a valid "no content change" (status-only ToolUpdate), not an error. The unexported marker keeps the variant set closed to this package.

type ToolKind

type ToolKind string

ToolKind is the ACP tool-call kind taxonomy.

const (
	ToolKindRead    ToolKind = "read"
	ToolKindEdit    ToolKind = "edit"
	ToolKindDelete  ToolKind = "delete"
	ToolKindMove    ToolKind = "move"
	ToolKindSearch  ToolKind = "search"
	ToolKindExecute ToolKind = "execute"
	ToolKindThink   ToolKind = "think"
	ToolKindFetch   ToolKind = "fetch"
	ToolKindOther   ToolKind = "other"
)

func (ToolKind) Valid

func (k ToolKind) Valid() bool

Valid reports whether k is one of the ACP tool kinds. The seam consumer (#608/#607) calls this to reject an out-of-taxonomy value.

type ToolStart

type ToolStart struct {
	ToolCallID string
	Title      string
	Kind       ToolKind
	RawInput   json.RawMessage
	Locations  []Location
}

ToolStart announces a new tool invocation.

RawInput is opaque pass-through tool input the model never parses or mutates; it is carried as json.RawMessage (undecoded bytes) precisely because that does not force a parse — consumers decode it on their own terms.

type ToolStatus

type ToolStatus string

ToolStatus is the ACP tool-call status taxonomy.

const (
	ToolStatusPending    ToolStatus = "pending"
	ToolStatusInProgress ToolStatus = "in_progress"
	ToolStatusCompleted  ToolStatus = "completed"
	ToolStatusFailed     ToolStatus = "failed"
)

func (ToolStatus) Valid

func (s ToolStatus) Valid() bool

Valid reports whether s is one of the ACP tool statuses.

type ToolUpdate

type ToolUpdate struct {
	ToolCallID string
	Status     ToolStatus
	Content    ToolContent
}

ToolUpdate carries changed fields of an existing tool call. Content may be nil for a status-only update.

type TurnEnd

type TurnEnd struct {
	Reason TurnEndReason
}

TurnEnd marks the end of a claude turn, carrying the reason only.

ACP models end-of-turn as the stopReason return value of session/prompt, not as an event; converting TurnEnd back into that RPC return is the ACP adapter's job, not this model's. Here we just carry the reason.

type TurnEndReason

type TurnEndReason string

TurnEndReason is the ACP turn stop-reason taxonomy.

const (
	TurnEndReasonEndTurn         TurnEndReason = "end_turn"
	TurnEndReasonMaxTokens       TurnEndReason = "max_tokens"
	TurnEndReasonMaxTurnRequests TurnEndReason = "max_turn_requests"
	TurnEndReasonRefusal         TurnEndReason = "refusal"
	TurnEndReasonCancelled       TurnEndReason = "cancelled"
)

func (TurnEndReason) Valid

func (r TurnEndReason) Valid() bool

Valid reports whether r is one of the ACP turn-end reasons.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL