wingsession

package
v0.149.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package wingsession owns the session operations shared by wing transports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SteerPrompt

func SteerPrompt(request, result, priorError, direction string) string

func UserPrincipal

func UserPrincipal(userID string) string

Types

type Authority

type Authority struct {
	Principal            string
	UserID, Email, Role  string
	DisplayName          string
	Browser              bool
	PublicKey, AuthToken string
	AllowedPaths         []string
	EnforcePaths         bool
	LegacyLocalDefault   bool
	Unsandboxed          bool
	SealedFS             bool
}

Authority is supplied by an authenticated adapter, never by tool arguments.

func AuthorityForWeb

func AuthorityForWeb(wc *config.WingConfig, req ws.TunnelRequest, home string) Authority

AuthorityForWeb preserves authenticated roles and the wing's path ACLs.

type Launch

type Launch struct {
	Config   *egg.EggConfig
	CWD      string
	Identity eggclient.EggIdentity
	// contains filtered or unexported fields
}

type MCPTaskRecord

type MCPTaskRecord struct {
	RetentionMillis *int64             `json:"retention_millis"`
	CancelledAt     time.Time          `json:"cancelled_at,omitempty"`
	CancelledResult *egg.RunTurnResult `json:"cancelled_result,omitempty"`
}

MCPTaskRecord is committed in the same admission transaction as the run. Retention starts at completion; active runs never expire or lose their timeout.

type Policy

type Policy struct {
	Wing  *config.WingConfig
	Egg   *egg.EggConfig
	Keys  []config.AllowKey
	Audit bool
}

type Run

type Run struct {
	ID             string            `json:"run_id"`
	SessionID      string            `json:"session_id"`
	RequestKey     string            `json:"idempotency_key,omitempty"`
	SpecHash       string            `json:"spec_hash"`
	Prompt         string            `json:"prompt"`
	OriginalPrompt string            `json:"original_prompt"`
	Agent          string            `json:"agent"`
	Model          string            `json:"model"`
	CWD            string            `json:"cwd"`
	Label          string            `json:"label,omitempty"`
	TimeoutSeconds int               `json:"timeout_seconds"`
	Isolation      string            `json:"isolation"`
	CreatedAt      time.Time         `json:"created_at"`
	ParentID       string            `json:"parent_id,omitempty"`
	Direction      string            `json:"direction,omitempty"`
	QueueExpiresAt time.Time         `json:"queue_expires_at,omitempty"`
	Launch         RunLaunch         `json:"launch"`
	Phase          string            `json:"phase"`
	Cancelled      bool              `json:"cancelled,omitempty"`
	Result         egg.RunTurnResult `json:"result"`
	MCPTask        *MCPTaskRecord    `json:"mcp_task,omitempty"`
	// contains filtered or unexported fields
}

type RunBackend

RunBackend only substitutes egg transport in isolated protocol fixtures. Production execution is exclusively the egg RunTurns RPC service.

type RunEvent

type RunEvent struct {
	Cursor                   int64
	Timestamp, Event, Detail string
}

type RunLaunch

type RunLaunch struct {
	Authority  Authority
	Identity   eggclient.EggIdentity
	ConfigYAML string
	Options    StartOptions
	Actor      string
}

RunLaunch is captured at admission. Reconciliation uses this exact launch, never a reconnecting client's arguments or credentials.

type RunRequest

type RunRequest struct {
	Prompt, Agent, Model, CWD, Label, RequestKey, ParentID, Direction string
	TimeoutSeconds                                                    int
	MCPTask                                                           *control.MCPTaskParams `json:"mcp_task,omitempty"`
}

type Runs

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

func (*Runs) Admit

func (m *Runs) Admit(launch *Launch, request RunRequest, options StartOptions, actor string) (*Run, bool, error)

func (*Runs) CancelTask

func (m *Runs) CancelTask(a Authority, id string) (control.MCPTask, error)

CancelTask durably publishes cancellation before responding. The ordinary stop path still owns descendant cleanup, independently of the request lifetime.

func (*Runs) Close

func (m *Runs) Close() error

func (*Runs) Events

func (m *Runs) Events(a Authority, id string, cursor int64, limit int) ([]RunEvent, error)

func (*Runs) Get

func (m *Runs) Get(a Authority, id string) (*Run, error)

func (*Runs) ReservedSessions

func (m *Runs) ReservedSessions(a Authority) int

ReservedSessions includes durable queue slots not yet represented in egg inventory, so async launches cannot race through a principal's last slot.

func (*Runs) Retry

func (m *Runs) Retry(launch *Launch, request RunRequest) (*Run, error)

Retry resolves accepted work before charging admission bounds again.

func (*Runs) Stop

func (m *Runs) Stop(a Authority, id string) (*Run, error)

func (*Runs) Task

func (m *Runs) Task(a Authority, id string) (control.MCPTask, error)

func (*Runs) Tasks

func (m *Runs) Tasks(a Authority) []control.MCPTask

func (*Runs) Wait

func (m *Runs) Wait(ctx context.Context, a Authority, ids []string) error

Wait uses one subscription for all selected IDs. Client cancellation only removes this observer and never cancels accepted execution.

func (*Runs) WaitTask

func (m *Runs) WaitTask(ctx context.Context, a Authority, id string) error

WaitTask observes the durable state without imposing a tool wait timeout.

type Service

type Service struct {
	Config     *config.Config
	Home       string
	SharedHost bool
	Policy     func() Policy
	AuthCache  *auth.AuthCache
	Inventory  func(*config.Config) []ws.SessionInfo
	// Spawn is replaceable by isolated protocol fixtures; production uses SpawnEgg.
	Spawn func(*Launch, StartOptions) (*egg.Client, error)
	// Register installs wing input routing before Start acknowledges the egg.
	Register func(string) error

	RunManager *Runs
	RunBackend *RunBackend
	// contains filtered or unexported fields
}

Service belongs to one wing. Local stdio does not instantiate this runtime.

func (*Service) Attach

func (s *Service) Attach(ctx context.Context, a Authority, client *egg.Client, id string, opts egg.AttachOptions, tools *egg.ToolListener) (pb.Egg_SessionClient, error)

Attach authenticates the session separately from transport key exchange.

func (*Service) Fork

Fork keeps provider/name reservations and the resulting egg under the same wing lifecycle as fresh launches. Prepare/Admit preserve the caller's bounds and conversation metadata without handing it a process executor.

func (*Service) Input

func (s *Service) Input(stream pb.Egg_SessionClient, id string, data []byte) error

Input uses the already acknowledged attachment capability. The transport verifies its controller/key binding before passing decrypted bytes here.

func (*Service) List

func (*Service) ListWeb

func (s *Service) ListWeb(ctx context.Context, a Authority) ([]ws.SessionInfo, error)

func (*Service) Observe

func (s *Service) Observe(ctx context.Context, client *egg.Client, id, owner string) (pb.Egg_SessionClient, error)

Observe belongs to the wing, so it does not acquire a client writer lease.

func (*Service) Owns

func (s *Service) Owns(a Authority, session eggclient.LocalSession) bool

func (*Service) PrepareLaunch

func (s *Service) PrepareLaunch(a Authority, cwd string) (*Launch, error)

func (*Service) PrepareWebStart

func (s *Service) PrepareWebStart(start *ws.PTYStart) (*Launch, string, func(bool), error)

PrepareWebStart also owns resume admission and provider reservation. It uses one policy snapshot for the launch and the source's owner/path checks.

func (*Service) Prompt

func (s *Service) Prompt(ctx context.Context, a Authority, ref, request, input string, timeout time.Duration, actor string) (eggclient.LocalSession, egg.SessionPromptResult, error)

func (*Service) Read

func (s *Service) Read(ctx context.Context, a Authority, ref string, after int64, limit int) (egg.SessionView, error)

func (*Service) ReleaseTools

func (s *Service) ReleaseTools(id string)

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, a Authority, ref string, archived bool) (eggclient.LocalSession, error)

func (*Service) Send

func (s *Service) Send(ctx context.Context, a Authority, ref string, input []byte, enter bool) (eggclient.LocalSession, error)

func (*Service) Snapshot

func (s *Service) Snapshot(ctx context.Context, a Authority, ref string) (eggclient.LocalSession, []byte, error)

func (*Service) Start

func (s *Service) Start(ctx context.Context, launch *Launch, opts StartOptions) (*egg.Client, error)

func (*Service) StartRuns

func (s *Service) StartRuns(ctx context.Context) error

StartRuns is called by the wing, including while its relay is disconnected. Closing it cancels observations only; admitted eggs keep their own deadlines.

func (*Service) Stop

func (*Service) StopAttached

func (s *Service) StopAttached(ctx context.Context, client *egg.Client, id string) error

StopAttached is for a wing bridge holding an authenticated attachment.

func (*Service) ToolListener

func (s *Service) ToolListener(id string) *egg.ToolListener

func (*Service) Wait

func (s *Service) Wait(ctx context.Context, a Authority, ref string, after int64, state string) (egg.SessionView, bool, error)

type StartOptions

type StartOptions struct {
	SessionID, Agent  string
	Rows, Cols        uint32
	Debug, VTE, Trace bool
	IdleTimeout       time.Duration
	Egg               eggclient.SpawnEggOpts
	Tools             []*config.ToolConfig
}

Jump to

Keyboard shortcuts

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