Documentation
¶
Overview ¶
Package wingsession owns the session operations shared by wing transports.
Index ¶
- Constants
- func SteerPrompt(request, result, priorError, direction string) string
- func UserPrincipal(userID string) string
- type Authority
- type Launch
- type MCPTaskRecord
- type Policy
- type Run
- type RunBackend
- type RunEvent
- type RunInventory
- type RunInventoryRequest
- type RunLaunch
- type RunRequest
- type Runs
- func (m *Runs) Admit(launch *Launch, request RunRequest, options StartOptions, actor string) (*Run, bool, error)
- func (m *Runs) CancelTask(a Authority, id string) (control.MCPTask, error)
- func (m *Runs) Close() error
- func (m *Runs) Events(a Authority, id string, cursor int64, limit int) ([]RunEvent, error)
- func (m *Runs) Get(a Authority, id string) (*Run, error)
- func (m *Runs) List(ctx context.Context, a Authority, req RunInventoryRequest) (RunInventory, error)
- func (m *Runs) ReservedSessions(a Authority) int
- func (m *Runs) Retry(launch *Launch, request RunRequest) (*Run, error)
- func (m *Runs) Stop(a Authority, id string) (*Run, error)
- func (m *Runs) Task(a Authority, id string) (control.MCPTask, error)
- func (m *Runs) Tasks(a Authority) []control.MCPTask
- func (m *Runs) Wait(ctx context.Context, a Authority, ids []string) error
- func (m *Runs) WaitTask(ctx context.Context, a Authority, id string) error
- type Service
- func (s *Service) Attach(ctx context.Context, a Authority, client *egg.Client, id string, ...) (pb.Egg_SessionClient, error)
- func (s *Service) Fork(ctx context.Context, a Authority, ref, label string, ...) (*eggclient.SessionForkResult, error)
- func (s *Service) Input(stream pb.Egg_SessionClient, id string, data []byte) error
- func (s *Service) List(ctx context.Context, a Authority) ([]eggclient.LocalSession, error)
- func (s *Service) ListWeb(ctx context.Context, a Authority) ([]ws.SessionInfo, error)
- func (s *Service) Observe(ctx context.Context, client *egg.Client, id, owner string) (pb.Egg_SessionClient, error)
- func (s *Service) Owns(a Authority, session eggclient.LocalSession) bool
- func (s *Service) PrepareLaunch(a Authority, cwd string) (*Launch, error)
- func (s *Service) PrepareWebStart(start *ws.PTYStart) (*Launch, string, func(bool), error)
- func (s *Service) Prompt(ctx context.Context, a Authority, ref, request, input string, ...) (eggclient.LocalSession, egg.SessionPromptResult, error)
- func (s *Service) Read(ctx context.Context, a Authority, ref string, after int64, limit int) (egg.SessionView, error)
- func (s *Service) ReleaseTools(id string)
- func (s *Service) Resolve(ctx context.Context, a Authority, ref string, archived bool) (eggclient.LocalSession, error)
- func (s *Service) Send(ctx context.Context, a Authority, ref string, input []byte, enter bool) (eggclient.LocalSession, error)
- func (s *Service) Snapshot(ctx context.Context, a Authority, ref string) (eggclient.LocalSession, []byte, error)
- func (s *Service) Start(ctx context.Context, launch *Launch, opts StartOptions) (*egg.Client, error)
- func (s *Service) StartRuns(ctx context.Context) error
- func (s *Service) Stop(ctx context.Context, a Authority, ref string) (eggclient.LocalSession, error)
- func (s *Service) StopAttached(ctx context.Context, client *egg.Client, id string) error
- func (s *Service) ToolListener(id string) *egg.ToolListener
- func (s *Service) Wait(ctx context.Context, a Authority, ref string, after int64, state string) (egg.SessionView, bool, error)
- type StartOptions
Constants ¶
const DefaultRunInventoryWindow = 7 * 24 * 60 * 60
const MaxRunInventoryWindow = 30 * 24 * 60 * 60
Variables ¶
This section is empty.
Functions ¶
func SteerPrompt ¶
func UserPrincipal ¶
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 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 ¶
type RunBackend struct {
Reserve func(context.Context, *config.Config, eggclient.LocalSession, egg.RunTurnRequest) (egg.RunTurnResult, error)
Ready func(context.Context, *config.Config, eggclient.LocalSession) error
Submit func(context.Context, *config.Config, eggclient.LocalSession, egg.RunTurnRequest) (egg.RunTurnResult, error)
Status func(context.Context, *config.Config, eggclient.LocalSession, string) (egg.RunTurnResult, error)
Wait func(context.Context, *config.Config, eggclient.LocalSession, string) (egg.RunTurnResult, error)
Result func(context.Context, *config.Config, eggclient.LocalSession, string) (egg.RunTurnResult, error)
Stop func(context.Context, *config.Config, eggclient.LocalSession, string) (egg.RunTurnResult, error)
}
RunBackend only substitutes egg transport in isolated protocol fixtures. Production execution is exclusively the egg RunTurns RPC service.
type RunInventory ¶ added in v0.149.4
type RunInventory struct {
WingID string `json:"wing_id"`
Runs []store.RunInventoryItem `json:"runs"`
Count int `json:"count"`
NextCursor string `json:"next_cursor,omitempty"`
SnapshotRevision string `json:"snapshot_revision"`
ObservedAt string `json:"observed_at"`
TerminalSince string `json:"terminal_since"`
}
type RunInventoryRequest ¶ added in v0.149.4
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 ¶
CancelTask durably publishes cancellation before responding. The ordinary stop path still owns descendant cleanup, independently of the request lifetime.
func (*Runs) List ¶ added in v0.149.4
func (m *Runs) List(ctx context.Context, a Authority, req RunInventoryRequest) (RunInventory, error)
List is a store-backed read. It deliberately avoids the mutable manager map and egg RPCs, so committed admissions remain discoverable without client IDs.
func (*Runs) ReservedSessions ¶
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.
type Service ¶
type Service struct {
Config *config.Config
Home string
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 ¶
func (s *Service) Fork(ctx context.Context, a Authority, ref, label string, scope eggclient.SessionForkScope) (*eggclient.SessionForkResult, error)
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 ¶
Input uses the already acknowledged attachment capability. The transport verifies its controller/key binding before passing decrypted bytes here.
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) PrepareLaunch ¶
func (*Service) PrepareWebStart ¶
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) ReleaseTools ¶
func (*Service) StartRuns ¶
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) StopAttached ¶
StopAttached is for a wing bridge holding an authenticated attachment.
func (*Service) ToolListener ¶
func (s *Service) ToolListener(id string) *egg.ToolListener
type StartOptions ¶
type StartOptions struct {
SessionID, Agent string
Rows, Cols uint32
Debug, VTE, Trace bool
IdleTimeout time.Duration
Egg eggclient.SpawnEggOpts
Tools []*config.ToolConfig
}