Documentation
¶
Overview ¶
Package terminal is the terminal gateway plugin: a chat gateway whose "channels" are tabs in the local TUI. It self-registers like any gateway (init → contracts.Register) and implements Gateway + ChannelReader + EventSink so the daemon hub drives it exactly like Discord — polling Read for typed lines and fanning the live event stream to it via Emit. The TUI binds to the active instance through Active().
Index ¶
- Constants
- type Terminal
- func (t *Terminal) Archive(_ context.Context, id string) error
- func (t *Terminal) BindSessionControl(c contracts.SessionControl)
- func (t *Terminal) ChannelRef(id string) string
- func (t *Terminal) Close(name string, force bool) (string, error)
- func (t *Terminal) Commands() []tui.CommandSpec
- func (t *Terminal) Control() contracts.SessionControl
- func (t *Terminal) CreateUnder(_ context.Context, _, name string) (string, error)
- func (t *Terminal) DefaultChannel() string
- func (t *Terminal) Dispatch(args []string) (string, error)
- func (t *Terminal) Emit(e contracts.Event)
- func (t *Terminal) EmitTo(conv contracts.Conversation, e contracts.Event)
- func (t *Terminal) Enabled() bool
- func (t *Terminal) EnsureChannel(context.Context, string, string) (contracts.Channel, error)
- func (t *Terminal) ForumPost(ctx context.Context, parentID, name, _ string) (string, error)
- func (t *Terminal) Frontend() <-chan tui.RoutedEvent
- func (t *Terminal) Interrupt(name string) bool
- func (t *Terminal) Kind(_ context.Context, _ string) (string, error)
- func (t *Terminal) Manifest() contracts.Manifest
- func (t *Terminal) Menu(_ context.Context, conv contracts.Conversation, _ contracts.MessageID, ...) error
- func (t *Terminal) Post(_ context.Context, conv contracts.Conversation, text string) (contracts.MessageID, error)
- func (t *Terminal) React(context.Context, contracts.Conversation, contracts.MessageID, string) error
- func (t *Terminal) Read(_ context.Context, channelID string, _ int, _ string) ([]contracts.Message, error)
- func (t *Terminal) Reply(_ context.Context, conv contracts.Conversation, _ contracts.MessageID, ...) (contracts.MessageID, error)
- func (t *Terminal) Resume(name string) (string, error)
- func (t *Terminal) RunForeground(ctx context.Context, cancel context.CancelFunc) error
- func (t *Terminal) Scrollback(name string) []contracts.ScrollbackLine
- func (t *Terminal) Send(_ context.Context, channelID, content string) error
- func (t *Terminal) Sessions() []contracts.SessionInfo
- func (t *Terminal) Submit(channel, text string, attachments []tui.Attachment)
- func (t *Terminal) Unreact(context.Context, string, string, string) error
- func (t *Terminal) UpsertStatusMessage(_ context.Context, channelID, _, content string) (string, error)
Constants ¶
const ChannelID = "terminal"
ChannelID is the default conversation id used by the terminal gateway.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal is the in-process terminal gateway. Typed lines arrive via Submit (tagged with the active channel) and are drained per-channel by the hub through Read; outbound events (EmitTo/Emit/Post/Reply) are forwarded to the TUI as RoutedEvents on Frontend.
func (*Terminal) BindSessionControl ¶
func (t *Terminal) BindSessionControl(c contracts.SessionControl)
BindSessionControl stores the hub controller so the TUI can drive the session lifecycle (create/close/list) and enumerate sessions for tab labels.
func (*Terminal) ChannelRef ¶
ChannelRef renders a terminal channel id bare: a plain TUI has no mention markup, so the operator just sees the id.
func (*Terminal) Close ¶
Close tears a session down through the typed SessionControl seam, so the TUI's close action never assembles "session close" flag argv.
func (*Terminal) Commands ¶
func (t *Terminal) Commands() []tui.CommandSpec
Commands is the curated palette advertised to the TUI. Every entry's leading verb is a member of terminalVerbs, so the palette can never surface a command Dispatch would reject; terminal_test.go asserts this invariant.
func (*Terminal) Control ¶
func (t *Terminal) Control() contracts.SessionControl
Control exposes the bound SessionControl to the TUI (nil before bind).
func (*Terminal) CreateUnder ¶
func (*Terminal) DefaultChannel ¶
func (*Terminal) Dispatch ¶
Dispatch forwards an operator argv to the bound SessionControl, prepending --terminal_only when creating a session without an explicit gateway selector so TUI-created sessions bind to this terminal and appear as tabs. The first token is gated against terminalVerbs before it ever reaches the registry.
func (*Terminal) Emit ¶
Emit (legacy EventSink) routes to the default single channel. The hub calls this when it sees only EventSink; RoutedEventSink takes priority.
func (*Terminal) EmitTo ¶
func (t *Terminal) EmitTo(conv contracts.Conversation, e contracts.Event)
EmitTo routes a turn event to the conversation's tab in the TUI.
func (*Terminal) EnsureChannel ¶
func (*Terminal) Frontend ¶
func (t *Terminal) Frontend() <-chan tui.RoutedEvent
Frontend yields routed outbound events for the TUI to render.
func (*Terminal) Interrupt ¶
Interrupt cancels a session's in-flight turn through the bound SessionControl, for esc-to-interrupt from the TUI. Reports false when no control is bound or no live session by that name is driving.
func (*Terminal) Read ¶
func (t *Terminal) Read(_ context.Context, channelID string, _ int, _ string) ([]contracts.Message, error)
Read drains and returns the lines queued for channelID since the last Read. The hub polls this per-session with the session's own channel, so each session drains only its own input.
func (*Terminal) Resume ¶
Resume revives an archived session by name through the bound SessionControl, for the /resume picker.
func (*Terminal) RunForeground ¶
RunForeground satisfies contracts.Foreground: the terminal gateway owns the process's main thread by running its Bubbletea TUI, blocking until the user quits (which calls cancel to tear the daemon down) or ctx is cancelled. The composition root runs this for the one bound gateway that implements Foreground, on an interactive TTY only.
func (*Terminal) Scrollback ¶
func (t *Terminal) Scrollback(name string) []contracts.ScrollbackLine
Scrollback returns a session's recorded history lines through the bound SessionControl (nil until bound), so a reopened tab can seed its scrollback.
func (*Terminal) Sessions ¶
func (t *Terminal) Sessions() []contracts.SessionInfo
Sessions returns the hub's sessions for tab labels (nil until SessionControl is bound — see BindSessionControl).
func (*Terminal) Submit ¶
func (t *Terminal) Submit(channel, text string, attachments []tui.Attachment)
Submit enqueues a line the user typed in the TUI as an inbound message on the given channel (the active tab's session channel). Staged attachments are carried as file:// URLs so the host bridge reads them off local disk instead of a CDN.