agentsend

package
v0.0.261 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 11 Imported by: 1 module, 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

Index

Constants

View Source
const DefaultDeliveryTimeout = 2 * time.Minute

DefaultDeliveryTimeout bounds WaitDefault.

Without a bound, a message that never actually reaches the composer leaves the queue entry forever and the caller blocks indefinitely — the original failure mode where a session parked on a first-launch modal looked like a silent hang. The default mirrors the drainer's own retry budget so a caller learns about the failure on roughly the same timescale.

Variables

This section is empty.

Functions

func Cancel

func Cancel(home string, sess Session, msgID string) error

Cancel removes a pending message from the queue.

func Enqueue

func Enqueue(home string, sess Session, text string) (string, error)

Enqueue appends a message to the session queue under flock and returns its id.

func EnqueueWith added in v0.0.55

func EnqueueWith(home string, sess Session, text string, opts EnqueueOptions) (string, error)

EnqueueWith is Enqueue with options (e.g. NoSubmit from send --no-submit).

func MessageStatus

func MessageStatus(home string, sess Session, msgID string) (string, error)

MessageStatus reports whether a session-local message is still queued. Returns "pending" when the message is in the queue, "delivered" when the id was assigned but is no longer queued (delivered, cancelled, or timed out).

func QueueLen added in v0.0.135

func QueueLen(home, runner, terminalSessionID string) (int, error)

QueueLen returns the number of pending send-queue entries for the session. A missing queue file is length 0.

func RunSessionDrainer added in v0.0.55

func RunSessionDrainer(ctx context.Context, home string, sess Session, provider agenttty.Provider)

RunSessionDrainer is a durable session-owned queue consumer. It reuses drainStep (flock + WaitUntilWritable + SendMessage + FIFO dequeue) and keeps polling while the queue is empty until ctx is cancelled. Intended to run inside the live TTY serve process so --no-wait enqueues deliver without a blocking CLI send.

func SendToAgentSession added in v0.0.51

func SendToAgentSession(store agentstorage.Store, runner, agentSessionID, message string, waitOpts WaitOptions) (msgID string, err error)

SendToAgentSession resolves an agent session to a live TTY, enqueues a message, optionally starts the drainer, and waits per waitOpts.

func StartDrainer

func StartDrainer(home string, sess Session, provider agenttty.Provider)

StartDrainer launches a background loop that elects a drainer via flock and delivers pending messages FIFO when the terminal becomes writable. The loop exits when the queue is empty or a drain step fails unrecoverably. Prefer RunSessionDrainer for session-owned consumers that must survive empty queues.

func StartSessionDrainer added in v0.0.55

func StartSessionDrainer(ctx context.Context, home string, sess Session, provider agenttty.Provider)

StartSessionDrainer starts RunSessionDrainer in a new goroutine.

func WaitForDelivery

func WaitForDelivery(home string, sess Session, msgID string, opts WaitOptions) error

WaitForDelivery polls until msgID is absent from the queue or the delivery deadline expires.

Absence from the queue means the drainer delivered it: for claude-tty the drainer only dequeues after the transcript records the prompt, so a dequeued message is a delivered one.

Types

type EnqueueOptions added in v0.0.55

type EnqueueOptions struct {
	// NoSubmit stores Entry.NoSubmit so drain does not auto-submit (no forced \n / Enter).
	NoSubmit bool
}

EnqueueOptions configures Enqueue behavior.

type Entry

type Entry struct {
	ID                string    `json:"id"`
	Text              string    `json:"text"`
	TerminalSessionID string    `json:"terminal_session_id"`
	Runner            string    `json:"runner"`
	EnqueuedAt        time.Time `json:"enqueued_at"`
	// NoSubmit: when true, drain injects without trailing Enter / forced grok \n.
	NoSubmit bool `json:"no_submit,omitempty"`
}

Entry is one pending send-queue message.

type Session

type Session struct {
	Home              string
	Runner            string
	TerminalSessionID string
	ListenAddr        string
}

Session identifies a live terminal send queue.

type WaitMode

type WaitMode int

WaitMode controls how long the caller blocks after enqueue.

const (
	WaitDefault WaitMode = iota
	WaitNoWait
	WaitMaxWait
)

type WaitOptions

type WaitOptions struct {
	Mode         WaitMode
	MaxWait      time.Duration
	EnqueuedAt   time.Time
	StartDrainer bool
}

WaitOptions configures post-enqueue behavior.

Jump to

Keyboard shortcuts

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