agentsend

package
v0.0.58 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 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 a max-wait deadline expires.

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