clisession

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseEnv

func BaseEnv(config bridgeconfig.Config) []string

func BootstrapTargets

func BootstrapTargets(config bridgeconfig.Config) []protocol.Target

func ConversationContextIDForTarget

func ConversationContextIDForTarget(networkID string, target protocol.Target, fallbackMessageID ...string) string

func DefaultSessionStorePath

func DefaultSessionStorePath(workspacePath string) string

func EnsureWorkspaceClientConfig added in v0.1.1

func EnsureWorkspaceClientConfig(config bridgeconfig.Config) error

func GenerateUUID

func GenerateUUID() (string, error)

func Run

func Run(
	ctx context.Context,
	config bridgeconfig.Config,
	driver Driver,
	streamer eventStreamer,
	backoff backoffPolicy,
) error

func RunAttached added in v0.1.21

func RunAttached(
	ctx context.Context,
	config bridgeconfig.Config,
	notifier Notifier,
	streamer eventStreamer,
	backoff backoffPolicy,
) error

func SessionKey

func SessionKey(config bridgeconfig.Config, message *protocol.Message) string

func SessionKeyForTarget

func SessionKeyForTarget(config bridgeconfig.Config, target protocol.Target) string

func SessionKeyFromContext

func SessionKeyFromContext(config bridgeconfig.Config, contextID string) string

Types

type CommandResult

type CommandResult struct {
	Stdout string
	Stderr string
}

func RunCommand

func RunCommand(ctx context.Context, spec CommandSpec) (CommandResult, error)

type CommandSpec

type CommandSpec struct {
	Command string
	Args    []string
	Stdin   string
	Env     []string
	Dir     string
	Timeout time.Duration
}

type Delivery

type Delivery struct {
	ContextKey       string
	RuntimeSessionID string
	ExistingSession  bool
	Prompt           string
	Bootstrap        bool
	Target           protocol.Target
	MessageID        string
}

type Driver

type Driver interface {
	Name() string
	DefaultCommand() string
	UsesSessionIDForFirstDelivery() bool
	BuildCommand(config bridgeconfig.Config, delivery Delivery) (CommandSpec, error)
	ExtractRuntimeSessionID(result CommandResult) string
}

type Notifier added in v0.1.21

type Notifier interface {
	Name() string
	Notify(ctx context.Context, config bridgeconfig.Config, text string) error
}

Notifier delivers a nudge into an already-open runtime session (runtime.mode: attached). It never starts the runtime.

type Nudge added in v0.1.21

type Nudge struct {
	Target  protocol.Target
	Count   int
	Senders []string
	// LatestID is the newest message id; it keeps consecutive nudges distinct
	// so a runtime's repeated-input filter never drops one.
	LatestID string
}

Nudge is the coalesced notice for one Moltnet conversation that an attached session has unread messages. It never carries message bodies: the session pulls them itself with `moltnet read --since-last`.

func (*Nudge) Add added in v0.1.21

func (n *Nudge) Add(message *protocol.Message)

Add folds one more message into the nudge.

func (*Nudge) Merge added in v0.1.21

func (n *Nudge) Merge(later *Nudge)

Merge folds a later nudge for the same conversation into this one.

func (Nudge) Text added in v0.1.21

func (n Nudge) Text(networkID string, memberID string) string

Text renders the one-line nudge delivered into the attached session. The read command names the network and member so it resolves even when the session's client config holds several attachments.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

func NewAttachedRunner added in v0.1.21

func NewAttachedRunner(
	config bridgeconfig.Config,
	notifier Notifier,
	streamer eventStreamer,
	backoff backoffPolicy,
) *Runner

NewAttachedRunner builds a runner that shares the managed runner's event stream, wake policy, and per-conversation queues, but nudges an open session through notifier instead of running a CLI command per wake.

func NewRunner

func NewRunner(
	config bridgeconfig.Config,
	driver Driver,
	streamer eventStreamer,
	backoff backoffPolicy,
) *Runner

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) error

func (*Runner) SetObserver added in v0.1.14

func (r *Runner) SetObserver(observer RunnerObserver)

type RunnerEvent added in v0.1.14

type RunnerEvent struct {
	ContextKey       string
	MessageID        string
	QueuedCount      int
	RuntimeSessionID string
	ExistingSession  bool
	Bootstrap        bool
	Error            error
}

type RunnerEventType added in v0.1.14

type RunnerEventType string
const (
	RunnerEventWakeQueued    RunnerEventType = "agent.wake.queued"
	RunnerEventTurnStarted   RunnerEventType = "agent.turn.started"
	RunnerEventTurnCompleted RunnerEventType = "agent.turn.completed"
	RunnerEventTurnFailed    RunnerEventType = "agent.turn.failed"
)

type RunnerObserver added in v0.1.14

type RunnerObserver func(eventType RunnerEventType, payload RunnerEvent)

type SessionRecord

type SessionRecord struct {
	RuntimeSessionID string    `json:"runtime_session_id"`
	CreatedAt        time.Time `json:"created_at"`
	UpdatedAt        time.Time `json:"updated_at"`
}

type SessionStore

type SessionStore struct {
	// contains filtered or unexported fields
}

func NewSessionStore

func NewSessionStore(path string) *SessionStore

func (*SessionStore) Delete added in v0.1.9

func (s *SessionStore) Delete(key string) error

func (*SessionStore) Get

func (s *SessionStore) Get(key string) (SessionRecord, bool, error)

func (*SessionStore) GetOrCreate

func (s *SessionStore) GetOrCreate(key string) (SessionRecord, bool, error)

func (*SessionStore) Put

func (s *SessionStore) Put(key string, runtimeSessionID string) (SessionRecord, error)

Jump to

Keyboard shortcuts

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