gatewaycli

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 66 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 (
	S6DynamicScandir = "/run/service"
	S6ServicePrefix  = "gateway-"
)
View Source
const DefaultStartTimeout = 90 * time.Second

Dial budget of one connection start

Variables

View Source
var (
	// Resume refusals meaning this viewer may not open the session, so the caller keeps the one it is on
	ResumeRefusals = map[string]bool{"not_found": true, "permission_denied": true}
	// Resume refusals meaning the session is gone for this viewer
	ResumeGone = map[string]bool{"not_found": true, "permission_denied": true, "profile_mismatch": true}
)
View Source
var (

	// Tree the one shot chat recorded for its worktree flag, assigned by the CLI package
	RecordedWorktree = func() map[string]string { return nil }
	// Folder the one shot chat's sessions work in, assigned by the CLI package; else the TERMINAL_CWD the process that started this one handed it
	LaunchFolder = func() string { return os.Getenv("TERMINAL_CWD") }
)
View Source
var AutostartStates = map[string]bool{"running": true}

Desired states that autostart, everything else waits for the operator

View Source
var DescribeActiveWorkUnit func(ctx context.Context, unit any, h string) (string, error)

One human line of an active work entry, installed by cmd/icebath over the update drain report

View Source
var SealedSteward func(projectRoot string) *string

Steward owning the sealed install tree, installed by cmd/icebath over the self update steward probe

View Source
var SendMessageTool func(ctx context.Context, args map[string]any) (string, error)

Send message tool of the messaging platforms, installed by the plugins tier that carries the send command

Functions

func AckConfirmed

func AckConfirmed(answer *jsonutil.Object, key, name string) bool

Whether a host control answer confirms name under key without an error

func AckFailure

func AckFailure(answer *jsonutil.Object) string

Why a host control answer did not confirm the operation

func BootNotice

func BootNotice(folded []string) string

Notice naming the named slots whose autostart the root slot took over

func BringRootSlotUp

func BringRootSlotUp(manager s6SlotManager) (string, error)

Starts the root slot or restarts it so it rereads its config, the one line description returned

func ClientEnvPolicy

func ClientEnvPolicy(ctx context.Context) (map[string]any, error)

client_env of a new session created from this shell

func CmdGatewayEnroll

func CmdGatewayEnroll(ctx context.Context, ns map[string]any, w io.Writer) (int, error)

Enrolls this gateway with a relay connector and persists the relay auth credentials to the profile env file

func CmdGatewayEnsure

func CmdGatewayEnsure(ctx context.Context, ns map[string]any, w io.Writer) (int, error)

Ensures a local runtime for this home and prints one credential free JSON verdict, exiting with its code

func ContainerBootMain

func ContainerBootMain(ctx context.Context, out io.Writer) int

Boot reconcile entry, printing the notice and one line per slot

func CreateTitledSession

func CreateTitledSession(ctx context.Context, title string) (string, error)

Creates a titled session through the gateway with no cwd stamp, returning its id

func DetectServiceManager

func DetectServiceManager() (string, error)

Service manager kind of this environment, s6 first then windows, launchd, systemd or none

func EnsureExitCode

func EnsureExitCode(result gateway.ObservedEndpoint) int

Process exit status of an ensure verdict, deadline 5, authorization 4, else by state

func EnvLaunchFlags

func EnvLaunchFlags() *jsonutil.Object

Creation flags set truthy in this shell's environment, in declaration order

func ExecSchtasks

func ExecSchtasks(args []string) (int, string, string, error)

The Windows only RuntimeError schtasks raises on every other host

func ExplainServiceFailure

func ExplainServiceFailure(err error) []string

Guidance lines for a systemd failure escaping the gateway command, nil for a failure it cannot explain

func FormatGatewayPids

func FormatGatewayPids(pids []int, limit int) string

Comma joined positive pids, the first limit of them and an ellipsis when more exist, every pid for a negative limit

func GatewayCommand

func GatewayCommand(ctx context.Context, ns map[string]any, w, errw io.Writer) (int, error)

Handles the gateway subcommands, systemd failures ending as guidance instead of a traceback

func GatewayDeclaresExternalSupervisor

func GatewayDeclaresExternalSupervisor(pid int, h string) bool

Whether the running gateway pid was launched for an external supervisor by identify, live argv or recorded argv

func GetStartupEntryPath

func GetStartupEntryPath(ctx context.Context) (string, error)

Startup folder VBS launcher of the task

func GetTaskName

func GetTaskName(ctx context.Context) (string, error)

Scheduled Task name scoped per profile

func InstallMigrateS6Hooks

func InstallMigrateS6Hooks()

Installs the s6 legs the multiplex migration in pkg/gatewayrun drives

func IsTaskRegistered

func IsTaskRegistered(ctx context.Context) (bool, error)

Whether schtasks answers the task query with exit code zero

func LegacyStartupEntryPath

func LegacyStartupEntryPath(ctx context.Context) (string, error)

Startup folder cmd entry older installs wrote

func LiveWork

func LiveWork(h, profile string) (*jsonutil.Object, error)

What the gateway serving home runs now, the control socket first then the state file when no profile narrows it

func LostBefore

func LostBefore(frame any, epoch int) bool

True for a transport error from a connection older than epoch, so no outcome of work submitted on epoch

func ManualGatewayIdentity

func ManualGatewayIdentity(h string, identify func(string) *jsonutil.Object, fail func(string, ...any) error) (*jsonutil.Object, error)

Identify answer of the manually launched gateway owning the home, nil when none runs, an error for a supervised one

func NamedSlotName

func NamedSlotName(profile string) string

s6 service directory name of a profile's slot

func ParkNamedSlot

func ParkNamedSlot(ctx context.Context, profile string, manager s6SlotManager) error

Stops a named slot and writes its down file so a supervisor restart does not revive it

func PauseAcked

func PauseAcked(response, identity *jsonutil.Object) bool

Whether the identified gateway itself accepted the drain or is already stopping

func PauseSnapshotOwner

func PauseSnapshotOwner(h, controlHome string, identity *jsonutil.Object) (bool, error)

Hands the profile off to maintenance, true when this restore parked a satellite and must serve it again

func PrintDuplicateCredentialWarnings

func PrintDuplicateCredentialWarnings(ctx context.Context, w io.Writer)

Prints the migrate preflight duplicate credential findings as status warnings

func PrintParkedStatus

func PrintParkedStatus(ctx context.Context, w io.Writer) (bool, error)

Prints the parked line of this satellite or the parked roster of the default profile, true for a parked satellite

func PrintStandaloneByConfig

func PrintStandaloneByConfig(ctx context.Context, w io.Writer) error

Names the profiles that opted out of the host multiplexer by config, default profile only

func ProfileLifecycle

func ProfileLifecycle(ctx context.Context, w io.Writer, command string, ns map[string]any) (bool, error)

Handles start, stop or restart of a named profile inside the host gateway, true when handled

func RefusalLines

func RefusalLines(ctx context.Context, verb string, homes []string, flagHint, profile string) ([]string, error)

Refusal text for verb while the first answering gateway among homes has live work, empty otherwise

func RefuseRestartOfServiceManagedGateway

func RefuseRestartOfServiceManagedGateway(ctx context.Context, w io.Writer, pid int) error

Refuses the manual restart fallback when systemd owns the gateway pid under any unit name

func RefuseWhileSessionsLive

func RefuseWhileSessionsLive(ctx context.Context, w io.Writer, verb string, ns map[string]any, hostHome, profile string) error

Exits 1 naming the live work unless interrupt was passed or a terminal user confirms

func RegisterUnregisteredProfileGateway

func RegisterUnregisteredProfileGateway(mgr ServiceManager, profile string) (bool, error)

Registers a down s6 slot for an existing profile directory carrying SOUL.md, false otherwise

func ReportIncompatibleOwner

func ReportIncompatibleOwner(ctx context.Context, w io.Writer, pids []int) bool

Prints the cross version refusal with its fix when the running gateway cannot serve this version

func RequestedPolicy

func RequestedPolicy(args map[string]any) *jsonutil.Object

Launch flags as session.create policy, toolsets and skills as lists and the source as its create label

func RestartExternallySupervisedGateway

func RestartExternallySupervisedGateway(ctx context.Context, w io.Writer, supervisedPid int) error

Hands the gateway back to its supervisor with a SIGUSR1 drain and reports the fresh pid, exit 1 on failure

func ResumeOverrides

func ResumeOverrides(ctx context.Context, args map[string]any, snapshot any) (map[string]any, error)

Launch flags of a resume that differ from the session's frozen launch, the payload of its launch mutation

func RunningNamedSlots

func RunningNamedSlots(profiles []string, manager s6SlotManager) []string

Named profiles whose slot is up right now, an unprobeable slot counting as down

func S6Running

func S6Running() bool

S6Running reports whether s6-svscan is PID 1 with its base directory present

func SendCommand

func SendCommand(ctx context.Context, h string, ns map[string]any, w, errw io.Writer) (int, error)

Sends text from a shell to a configured messaging platform, exit 0 ok, 1 delivery error, 2 usage error

func ShellClientEnv

func ShellClientEnv(ctx context.Context) (map[string]string, error)

Allowlisted environment of this shell with the extra names of the profile config, code defaults on a bypass launch

func SlotIsUp

func SlotIsUp(profile string, manager s6SlotManager) bool

func StripContainerArgvPrefix

func StripContainerArgvPrefix(argv []string) []string

Container command with everything through the supervisor or wrapper token and a leading icebath dropped

func ValidateServiceProfileName

func ValidateServiceProfileName(name string) error

Error unless the name is a filesystem and s6 safe profile name

func WebhookCommand

func WebhookCommand(ctx context.Context, w io.Writer, args WebhookArgs) (int, error)

WebhookCommand runs icebath webhook and returns the exit status, 1 when a refusal wrote nothing

Types

type CallFunc

type CallFunc func(ctx context.Context, method string, params map[string]any) (any, error)

One request through a connection or a store, the call argument of a resume

type CallOptions

type CallOptions struct {
	Timeout time.Duration
	Abandon func() bool
}

Answer budget and give up poll of one call, a zero Timeout the default budget and a negative one unbounded

type CallStopped

type CallStopped struct{ Method string }

Raised when the caller stopped waiting for an answer whose request was sent

func (*CallStopped) As

func (e *CallStopped) As(target any) bool

Lets a stopped call match a GatewayClientError target like the Python subclass

func (*CallStopped) Error

func (e *CallStopped) Error() string

type ConnectFunc

type ConnectFunc func(ctx context.Context) (ConnectionClient, error)

Dials one gateway socket, the connect context manager of the Python connection

var DefaultConnect ConnectFunc = connectGateway

Dial every connection built without its own uses, the home owner's socket

type ConnectionClient

type ConnectionClient interface {
	RPCTimeout(ctx context.Context, method string, params map[string]any, timeout time.Duration) (any, error)
	EventQueue() *gateway.EventQueue
	SendFrame(text string) error
	Close() error
}

Client surface one connection drives, satisfied by the gateway client

type ConnectionLoss

type ConnectionLoss struct {
	Err             error
	ConnectionEpoch int
}

Transport error tagged with the connection epoch it ended

func (*ConnectionLoss) Error

func (e *ConnectionLoss) Error() string

func (*ConnectionLoss) Unwrap

func (e *ConnectionLoss) Unwrap() error

type FoldDecision

type FoldDecision struct {
	Folded          []string
	RootShouldStart bool
}

Named profiles whose autostart intent the root slot takes over and whether the root must be up

func FoldNamedSlotIntent

func FoldNamedSlotIntent(defaultPriorState *string, namedStates []NamedSlotState) FoldDecision

Folds every running named slot intent into the root slot, which starts when it or any folded slot was running

type GatewayConnection

type GatewayConnection struct {
	Events *gateway.EventQueue
	// contains filtered or unexported fields
}

One gateway connection per one shot chat process, its loop goroutine feeding Events and the session caches

func NewGatewayConnection

func NewGatewayConnection(connect ConnectFunc) *GatewayConnection

Connection dialing through connect, the home owner when connect is nil

func SharedGatewayConnection

func SharedGatewayConnection() *GatewayConnection

Process wide connection, replaced once the previous one is final

func (*GatewayConnection) Call

func (c *GatewayConnection) Call(ctx context.Context, method string, params map[string]any) (any, error)

One request and its answer on the live socket under the default budget

func (*GatewayConnection) CallTagged

func (c *GatewayConnection) CallTagged(ctx context.Context, method string, params map[string]any, o CallOptions) (any, int, error)

One request with the epoch of the socket that carried it, so admitted work is tied to that gateway life

func (*GatewayConnection) CallWith

func (c *GatewayConnection) CallWith(ctx context.Context, method string, params map[string]any, o CallOptions) (any, error)

One request and its answer under an explicit budget and give up poll

func (*GatewayConnection) Client

func (c *GatewayConnection) Client() ConnectionClient

Client of the open socket, nil while hung up

func (*GatewayConnection) Close

func (c *GatewayConnection) Close(ctx context.Context)

Ends the viewer and stops its loop so no later call dials again, the teardown test fixtures run

func (*GatewayConnection) Closed

func (c *GatewayConnection) Closed() bool

True after a close and while the gateway is hung up

func (*GatewayConnection) Epoch

func (c *GatewayConnection) Epoch() int

Count of sockets this connection has opened

func (*GatewayConnection) Final

func (c *GatewayConnection) Final() bool

True when no call dials again, the viewer closed it or its first connect failed

func (*GatewayConnection) LaunchKey

func (c *GatewayConnection) LaunchKey() (string, bool)

Launch only key of this CLI and whether it is the typed flag rather than a keyed startup alias

func (*GatewayConnection) LookupState

func (c *GatewayConnection) LookupState(sessionID string) *SessionState

Cached view of a session this viewer has used, nil for any other id

func (*GatewayConnection) Reattach

func (c *GatewayConnection) Reattach(ctx context.Context, sessionID string, abandon func() bool) (any, error)

Resumes a session after a replay gap, its snapshot naming the subscription to detach

func (*GatewayConnection) Reply

func (c *GatewayConnection) Reply(requestID any, result any) bool

Answers one server request with a response frame carrying its id, false when the frame was not sent

func (*GatewayConnection) Resume

func (c *GatewayConnection) Resume(ctx context.Context, call CallFunc, sessionID string, typed bool) (any, error)

Resumes a session through call with the launch key, a refused keyed resume retried plain when allowed

func (*GatewayConnection) SetLaunchKey

func (c *GatewayConnection) SetLaunchKey(key string, typed bool)

Records the launch only key every resume supplies again and whether the user typed it

func (*GatewayConnection) SideWaiter

func (c *GatewayConnection) SideWaiter(taskID string) *gateway.EventQueue

Answer queue of a side task, created by whichever of the waiter or the frame comes first

func (*GatewayConnection) Start

func (c *GatewayConnection) Start(ctx context.Context, timeout time.Duration) error

Dials when no socket is open and waits for the dial in progress, redialing after a gateway hang up

func (*GatewayConnection) State

func (c *GatewayConnection) State(sessionID string) *SessionState

Cached view of a session, created on first use

type GatewayNotRegisteredError

type GatewayNotRegisteredError struct {
	S6Error
	Profile string
}

Lifecycle call against a missing s6 slot

type GatewayRuntimeSnapshot

type GatewayRuntimeSnapshot struct {
	Manager          string
	ServiceInstalled bool
	ServiceRunning   bool
	GatewayPIDs      []int
	ServiceScope     string
}

Unified view of gateway liveness for the current profile

func GetGatewayRuntimeSnapshot

func GetGatewayRuntimeSnapshot(ctx context.Context, system bool) (GatewayRuntimeSnapshot, error)

Gateway liveness of the current profile under its service manager, Termux, s6, docker, systemd, launchd or a bare process

func (GatewayRuntimeSnapshot) HasProcessServiceMismatch

func (s GatewayRuntimeSnapshot) HasProcessServiceMismatch() bool

Reports an installed service whose gateway runs outside it

func (GatewayRuntimeSnapshot) Running

func (s GatewayRuntimeSnapshot) Running() bool

Reports a running service or a scanned gateway process

type GatewaySessionStore

type GatewaySessionStore struct {
	Connection *GatewayConnection
	// Destination of the config warning a create prints
	Stderr io.Writer
	// contains filtered or unexported fields
}

Session store of the one shot chat backed by the shared gateway session, reads local and writes gateway verbs

func NewGatewaySessionStore

func NewGatewaySessionStore(connection *GatewayConnection) *GatewaySessionStore

Store over a connection, the process wide one when connection is nil

func SessionStore

func SessionStore() *GatewaySessionStore

Store over the process wide connection

func (*GatewaySessionStore) AppendMessagesBatch

func (s *GatewaySessionStore) AppendMessagesBatch(args ...any)

Transcript flush the gateway performs itself

func (*GatewaySessionStore) AssertResumeSafe

func (s *GatewaySessionStore) AssertResumeSafe(ctx context.Context, sessionID string, maxMessages *int, tipOnly bool) (int, error)

Resume safety check of a session through the reader

func (*GatewaySessionStore) Attach

func (s *GatewaySessionStore) Attach(ctx context.Context, sessionID string, typed bool) (*jsonutil.Object, error)

Resumes a session once per id this viewer uses, carrying the launch key the way the thin client does

func (*GatewaySessionStore) Call

func (s *GatewaySessionStore) Call(ctx context.Context, method string, params map[string]any) (any, error)

One gateway request on this store's connection

func (*GatewaySessionStore) ClientEnv

func (s *GatewaySessionStore) ClientEnv(ctx context.Context) (map[string]any, error)

client_env of this shell, the environment a session created from here starts with

func (*GatewaySessionStore) CloseReader

func (s *GatewaySessionStore) CloseReader() error

Releases this viewer's SQLite handles before offline maintenance, keeping its RPC store

func (*GatewaySessionStore) Create

func (s *GatewaySessionStore) Create(ctx context.Context, launch map[string]any, title string, recordCwd bool) (string, error)

Creates a gateway session with the launch policy and an optional title, adopting and returning its id

func (*GatewaySessionStore) CreateSession

func (s *GatewaySessionStore) CreateSession(args ...any)

Row creation the gateway performs itself

func (*GatewaySessionStore) Current

func (s *GatewaySessionStore) Current() *jsonutil.Object

Snapshot of the opened session, nil until one is open

func (*GatewaySessionStore) EndSession

func (s *GatewaySessionStore) EndSession(ctx context.Context, sessionID, reason string) error

Detaches this viewer with an end reason, the owner ending the idle row once no viewer is left

func (*GatewaySessionStore) FinalizeOrphanedCompressionSessions

func (s *GatewaySessionStore) FinalizeOrphanedCompressionSessions(args ...any) int

Orphaned compression repair the gateway owns, zero rows repaired here

func (*GatewaySessionStore) FlushTokenCounts

func (s *GatewaySessionStore) FlushTokenCounts(timeoutS float64) bool

Token accounting flush the gateway performs itself, answering false like the store method that returns nothing

func (*GatewaySessionStore) GetCompressionTip

func (s *GatewaySessionStore) GetCompressionTip(ctx context.Context, sessionID string) (string, error)

Live compression tip of a lineage from the reader

func (*GatewaySessionStore) GetMessages

func (s *GatewaySessionStore) GetMessages(ctx context.Context, sessionID string, o state.GetMessagesOptions) ([]*jsonutil.Object, error)

Stored message rows of a session from the reader

func (*GatewaySessionStore) GetMessagesAsConversation

func (s *GatewaySessionStore) GetMessagesAsConversation(ctx context.Context, sessionID string, o state.ConversationOptions) ([]map[string]any, error)

Transcript of a session as conversation messages from the reader

func (*GatewaySessionStore) GetMeta

func (s *GatewaySessionStore) GetMeta(ctx context.Context, key string) (string, bool, error)

Store metadata value from the reader

func (*GatewaySessionStore) GetNextTitleInLineage

func (s *GatewaySessionStore) GetNextTitleInLineage(ctx context.Context, baseTitle string) (string, error)

Next free numbered title of a lineage from the reader

func (*GatewaySessionStore) GetSession

func (s *GatewaySessionStore) GetSession(ctx context.Context, sessionID string) (map[string]any, error)

Stored session row from the read only reader, nil without a reader or a row

func (*GatewaySessionStore) GetSessionModelConfigValue

func (s *GatewaySessionStore) GetSessionModelConfigValue(ctx context.Context, sessionID, key string, def any) (any, error)

One model config value of a session from the reader

func (*GatewaySessionStore) GetSessionTitle

func (s *GatewaySessionStore) GetSessionTitle(ctx context.Context, sessionID string) (string, bool, error)

Title of a session from the reader

func (*GatewaySessionStore) IsKanbanOwnedSession

func (s *GatewaySessionStore) IsKanbanOwnedSession(ctx context.Context, sessionID string) (bool, error)

Whether a kanban task owns the session, read from the reader

func (*GatewaySessionStore) ListSessionsRich

Rich session page from the reader with created surface matching

func (*GatewaySessionStore) MaybeAutoArchive

func (s *GatewaySessionStore) MaybeAutoArchive(args ...any)

Archive maintenance the gateway performs itself

func (*GatewaySessionStore) MaybeAutoPruneAndVacuum

func (s *GatewaySessionStore) MaybeAutoPruneAndVacuum(args ...any)

Prune and vacuum maintenance the gateway performs itself

func (*GatewaySessionStore) Mutate

func (s *GatewaySessionStore) Mutate(ctx context.Context, sessionID, operation string, payload map[string]any, snapshot *jsonutil.Object) (any, error)

One session.mutate at the revision of a fresh read, fenced by generation for the operations that need it

func (*GatewaySessionStore) OpenSession

func (s *GatewaySessionStore) OpenSession(ctx context.Context, cli OpenSessionCLI, launch map[string]any) (string, error)

Creates or resumes the gateway session of a CLI and adopts its id, empty when the gateway refuses the target

func (*GatewaySessionStore) PruneEmptyGhostSessions

func (s *GatewaySessionStore) PruneEmptyGhostSessions(args ...any) int

Ghost session repair the gateway owns, zero rows repaired here

func (*GatewaySessionStore) Reader

Read only reader opened on first use, nil while the gateway has not created state.db yet

func (*GatewaySessionStore) ReopenSession

func (s *GatewaySessionStore) ReopenSession(args ...any)

Row reopening the gateway performs itself

func (*GatewaySessionStore) ResolveResumeSessionID

func (s *GatewaySessionStore) ResolveResumeSessionID(ctx context.Context, sessionID string) (string, error)

Resume target of a session id from the reader

func (*GatewaySessionStore) ResolveSessionByTitle

func (s *GatewaySessionStore) ResolveSessionByTitle(ctx context.Context, title string) (string, error)

Session id a title resolves to from the reader

func (*GatewaySessionStore) RewindUserTurn

func (s *GatewaySessionStore) RewindUserTurn(ctx context.Context, sessionID string, userOrdinal int, o state.RewindUserTurnOptions) (*state.RewindOutcome, error)

Rewinds to just before a user turn located on the gateway transcript and checked against the warm view

func (*GatewaySessionStore) SanitizeTitle

func (s *GatewaySessionStore) SanitizeTitle(title string) (string, error)

Validated title text, the session store rule that needs no database

func (*GatewaySessionStore) SearchSessions

func (s *GatewaySessionStore) SearchSessions(ctx context.Context, o SearchSessionsOptions) ([]map[string]any, error)

Recent sessions from the reader with created surface matching

func (*GatewaySessionStore) SessionCount

Session count from the reader with created surface matching

func (*GatewaySessionStore) SessionYoloEnabled

func (s *GatewaySessionStore) SessionYoloEnabled(sessionMeta map[string]any) bool

Whether session metadata carries the approval bypass, the session store rule that needs no database

func (*GatewaySessionStore) SetMeta

func (s *GatewaySessionStore) SetMeta(args ...any)

Metadata write the gateway performs itself

func (*GatewaySessionStore) SetSessionTitle

func (s *GatewaySessionStore) SetSessionTitle(ctx context.Context, sessionID, title string) (bool, error)

Renames a session on the gateway, a refusal caused by another holder reported with that holder's id

func (*GatewaySessionStore) UpdateTokenCounts

func (s *GatewaySessionStore) UpdateTokenCounts(args ...any)

Token accounting the gateway performs itself

type InspectError

type InspectError struct {
	Profile string
	Err     error
}

InspectError reports a profile whose gateway pid could not be inspected under strict discovery

func (*InspectError) Error

func (e *InspectError) Error() string

func (*InspectError) Unwrap

func (e *InspectError) Unwrap() error

type LoopThreadError

type LoopThreadError struct{ Msg string }

Call on the connection loop goroutine, which would wait on itself

func (*LoopThreadError) Error

func (e *LoopThreadError) Error() string

func (*LoopThreadError) ErrorKind

func (e *LoopThreadError) ErrorKind() string

type NamedSlotState

type NamedSlotState struct {
	Profile string
	Prior   *string
}

Named profile and the desired state its slot recorded before the boot, nil when none

type NotImplementedError

type NotImplementedError struct{ Msg string }

Error of a runtime registration verb no host backend supports

func (*NotImplementedError) Error

func (e *NotImplementedError) Error() string

type OpenSessionCLI

type OpenSessionCLI struct {
	SessionID           string
	Resumed             bool
	TypedAPIKey         any
	TypedToolsets       any
	ExplicitIgnoreRules any
}

What a session open reads off the one shot chat

type ProcessIdentity

type ProcessIdentity struct {
	PID        int
	CreateTime float64
}

Pid and creation time of one process incarnation

type ProfileGatewayProcess

type ProfileGatewayProcess struct {
	Profile    string
	Path       string
	PID        int
	CreateTime float64
}

ProfileGatewayProcess is a running gateway pid mapped to the profile whose pid file names it

func FindProfileGatewayProcesses

func FindProfileGatewayProcesses(ctx context.Context, excludePIDs map[int]bool, strict bool) ([]ProfileGatewayProcess, error)

Running gateway pids mapped to profiles through their pid files, strict mode fails on ambiguous state

type ReconcileAction

type ReconcileAction struct {
	Profile        string
	PriorState     *string
	Action         string
	PriorExit      string
	FoldedIntoRoot bool
}

What the boot reconcile did with one profile slot

func ReconcileProfileGateways

func ReconcileProfileGateways(ctx context.Context, home, scandir string, dryRun bool, containerArgv []string) ([]ReconcileAction, error)

Recreates the s6 slot of the root profile and of every persistent named profile after a container restart

type S6CommandError

type S6CommandError struct {
	S6Error
	Action     string
	ReturnCode int
	Stderr     string
}

s6 command failure other than a missing slot, with its stderr

type S6Error

type S6Error struct {
	Msg     string
	Service string
}

Base error of the s6 lifecycle carrying the slot name

func (*S6Error) Error

func (e *S6Error) Error() string

type S6ServiceManager

type S6ServiceManager struct{ Scandir string }

Per profile gateway supervision of runtime registered s6 services

func NewS6ServiceManager

func NewS6ServiceManager(scandir string) *S6ServiceManager

func (*S6ServiceManager) IsRunning

func (m *S6ServiceManager) IsRunning(name string) (bool, error)

func (*S6ServiceManager) Kind

func (m *S6ServiceManager) Kind() string

func (*S6ServiceManager) ListProfileGateways

func (m *S6ServiceManager) ListProfileGateways() ([]string, error)

Profile names of every registered gateway service

func (*S6ServiceManager) RegisterProfileGateway

func (m *S6ServiceManager) RegisterProfileGateway(profile string, startNow bool) error

func (*S6ServiceManager) RegisterProfileGatewayEnv

func (m *S6ServiceManager) RegisterProfileGatewayEnv(profile string, extraEnv map[string]string, startNow bool) error

Creates the s6 service directory atomically and rescans so the slot is supervised at once

func (*S6ServiceManager) Restart

func (m *S6ServiceManager) Restart(name string) error

func (*S6ServiceManager) SlotScandir

func (m *S6ServiceManager) SlotScandir() string

Scan directory of the supervised slots

func (*S6ServiceManager) Start

func (m *S6ServiceManager) Start(name string) error

func (*S6ServiceManager) Stop

func (m *S6ServiceManager) Stop(ctx context.Context, name string) error

func (*S6ServiceManager) SupportsRuntimeRegistration

func (m *S6ServiceManager) SupportsRuntimeRegistration() bool

func (*S6ServiceManager) UnregisterProfileGateway

func (m *S6ServiceManager) UnregisterProfileGateway(profile string) error

Stops the slot, waits for it to go down, rescans and removes its directory, absent slots a no op

type SearchSessionsOptions

type SearchSessionsOptions struct {
	Sources         []string
	Limit           int
	Offset          int
	WorkspaceKey    string
	SkipLaunchStubs bool
}

Arguments of a source filtered session search, a zero Limit meaning the default page of 20

type ServiceManager

type ServiceManager interface {
	Kind() string
	Start(name string) error
	Stop(ctx context.Context, name string) error
	Restart(name string) error
	IsRunning(name string) (bool, error)
	SupportsRuntimeRegistration() bool
	RegisterProfileGateway(profile string, startNow bool) error
	RegisterProfileGatewayEnv(profile string, extraEnv map[string]string, startNow bool) error
	UnregisterProfileGateway(profile string) error
	ListProfileGateways() ([]string, error)
}

Init system specific gateway service operations, runtime registration only on s6

func GetServiceManager

func GetServiceManager() (ServiceManager, error)

Service manager of the current environment, an error when none is supported

func NewLaunchdServiceManager

func NewLaunchdServiceManager() ServiceManager

Launchd backend over the launchd lifecycle

func NewSystemdServiceManager

func NewSystemdServiceManager() ServiceManager

Systemd backend over the user scope systemd lifecycle

func NewWindowsServiceManager

func NewWindowsServiceManager() ServiceManager

Windows backend whose running check needs the installed task and a live gateway pid

type SessionListener

type SessionListener func(ctx context.Context, payload map[string]any)

Callback a session state hands one usage dict or one withdrawn request, registered and removed by its pointer

type SessionState

type SessionState struct {
	sync.Mutex
	SessionID           string
	Info                map[string]any
	Title               string
	PlanState           map[string]any
	Revision            any
	SubscriptionID      any
	ExecutionGeneration any
	Messages            []any
	Usage               map[string]any
	UsageListeners      []*SessionListener
	AdmittedTurn        map[string]any
	Pending             []any
	QueuedInputs        *jsonutil.Object
	Adopted             map[string]any
	ArmedAdmission      string
	PendingSeq          int
	RecoveredSeq        int
	Missed              map[string]bool
	Gaps                int
	AttachedGaps        int
	ServiceTierSent     *string
}

What the gateway last told this viewer about one session, locked by its embedded mutex

func NewSessionState

func NewSessionState(sessionID string) *SessionState

func (*SessionState) AdoptSnapshot

func (s *SessionState) AdoptSnapshot(snapshot any)

Replaces the cached view with a resume or create snapshot, keeping fields the snapshot does not carry

func (*SessionState) ApplyEvent

func (s *SessionState) ApplyEvent(ctx context.Context, kind any, payload any)

Folds one session event frame into the cached view and calls the listeners it concerns

func (*SessionState) ApplyUsage

func (s *SessionState) ApplyUsage(ctx context.Context, usage any)

Stores one session cumulative usage dict and hands it to every usage listener

func (*SessionState) RunsRoute

func (s *SessionState) RunsRoute(model, provider string) bool

Whether the session runs model, and provider when both sides name one

type SnapshotCommand

type SnapshotCommand struct {
	Home string
	T    func(key string, kwargs map[string]any) string
}

Home and catalog lookup of one /snapshot run, T taking the snapshot keys of cli.commands

func (SnapshotCommand) Create

func (s SnapshotCommand) Create(parts []string) ([]string, error)

Line of a new quick snapshot whose label is every word after the subcommand

func (SnapshotCommand) List

func (s SnapshotCommand) List() ([]string, error)

Lines of the newest twenty quick snapshots as a table, or the hint to create the first one

func (SnapshotCommand) Prune

func (s SnapshotCommand) Prune(parts []string) ([]string, error)

Line of a prune down to the newest N quick snapshots, twenty when no count is given

func (SnapshotCommand) RestoreReport

func (s SnapshotCommand) RestoreReport(snapID string, restored bool, restoreErr error, onGateway bool) ([]string, error)

Lines reporting a finished restore, onGateway telling the gateway reloads the state by itself

func (SnapshotCommand) RestoreTarget

func (s SnapshotCommand) RestoreTarget(parts []string) (string, []string, error)

Snapshot id a restore names by id or list number, with lines instead when none is named or the number is off

type SnapshotRestore

type SnapshotRestore struct {
	Restored bool
	Detached bool
	Profile  string
	Ack      *jsonutil.Object
}

Outcome of a restore that handed the profile off the gateway

func RestoreSnapshotOffGateway

func RestoreSnapshotOffGateway(ctx context.Context, h, snapID string, identity func(string) (*jsonutil.Object, error), detach func(home string) error) (res SnapshotRestore, err error)

Restores a quick snapshot with the profile handed off the gateway, detach closing the caller's hold first

func (SnapshotRestore) ReserveLine

func (r SnapshotRestore) ReserveLine() string

Line telling a parked satellite profile is not served again yet, empty when it is or none was parked

type SurfaceLabelReader

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

Read only session store whose source filtered listings also match gateway local rows by created surface

func NewSurfaceLabelReader

func NewSurfaceLabelReader(db *state.SessionDB) *SurfaceLabelReader

Wraps a session store so its listings read the labels CLI sessions were stored under

func (*SurfaceLabelReader) Close

func (r *SurfaceLabelReader) Close() error

Releases the wrapped store handles

func (*SurfaceLabelReader) DB

Wrapped session store serving every read the label reader does not rewrite

func (*SurfaceLabelReader) GetCompressionTip

func (r *SurfaceLabelReader) GetCompressionTip(ctx context.Context, sessionID string) (string, error)

Live compression tip of a session lineage

func (*SurfaceLabelReader) GetSession

func (r *SurfaceLabelReader) GetSession(ctx context.Context, sessionID string) (map[string]any, error)

Stored session row as a plain map, nil when the id is unknown

func (*SurfaceLabelReader) ListSessionsRich

Rich session page whose source filter also matches local rows created by the requested surfaces

func (*SurfaceLabelReader) LocalReceipt

func (r *SurfaceLabelReader) LocalReceipt(ctx context.Context, sessionID string) (map[string]any, error)

Durable local receipt of a session as a plain map, nil without one

func (*SurfaceLabelReader) ResolveSessionByTitle

func (r *SurfaceLabelReader) ResolveSessionByTitle(ctx context.Context, title string) (string, error)

Session id a title resolves to, empty when no session carries it

func (*SurfaceLabelReader) ResolveSessionID

func (r *SurfaceLabelReader) ResolveSessionID(ctx context.Context, idOrPrefix string) (string, error)

Exact session id or the single unambiguous prefix match, empty otherwise

func (*SurfaceLabelReader) SearchSessions

func (r *SurfaceLabelReader) SearchSessions(ctx context.Context, o SearchSessionsOptions) ([]map[string]any, error)

Sessions most recently active first, a cli filter also matching local rows the CLI created

func (*SurfaceLabelReader) SessionCount

Session count under the list filters with the same created surface matching as the listings

type TitleInUseError

type TitleInUseError struct {
	Msg   string
	Cause error
}

Raised when another session already holds a title the gateway refused

func (*TitleInUseError) Error

func (e *TitleInUseError) Error() string

func (*TitleInUseError) ErrorKind

func (e *TitleInUseError) ErrorKind() string

func (*TitleInUseError) Unwrap

func (e *TitleInUseError) Unwrap() error

type WebhookArgs

type WebhookArgs struct {
	Action, Name, Prompt, Events, Description, Skills, Deliver, DeliverChatID string
	Secret, Payload, Script, CronJob                                          string
	RouteProfile                                                              *string
	DeliverOnly, MirrorToSession                                              bool
}

WebhookArgs is one parsed icebath webhook command line, RouteProfile nil when the flag was not given

type WinService

type WinService interface {
	Status() (string, error)
	PID() (int, error)
}

One SCM service whose state and process are queried when read

func WinServiceGet

func WinServiceGet(name string) (WinService, error)

The named SCM service, an error when the SCM cannot be listed or holds no service of that name

type WindowsGatewayService

type WindowsGatewayService struct {
	Name                 string
	Profile              string
	ServicePID           int
	GatewayPID           int
	DescendantPIDs       []int
	DescendantIdentities []ProcessIdentity
	ServiceCreateTime    float64
	GatewayCreateTime    float64
}

A real Windows service supervising a profile gateway process tree

func FindWindowsGatewayServices

func FindWindowsGatewayServices(ctx context.Context) ([]WindowsGatewayService, error)

Profile gateways supervised by Icebath owned Windows services, sorted by service name, none off Windows

func FindWindowsGatewayServicesFor

func FindWindowsGatewayServicesFor(ctx context.Context, profileProcesses []ProfileGatewayProcess) ([]WindowsGatewayService, error)

Gateways of the given profile processes that descend from a running Icebath owned service

type WindowsServiceError

type WindowsServiceError struct {
	Msg   string
	Cause error
}

RuntimeError of SCM discovery with the failure that caused it

func (*WindowsServiceError) Error

func (e *WindowsServiceError) Error() string

func (*WindowsServiceError) Unwrap

func (e *WindowsServiceError) Unwrap() error

type WindowsServiceManager

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

Windows backend over the scheduled task or startup folder lifecycle

func (*WindowsServiceManager) Install

Installs the Windows gateway task with its platform options

func (*WindowsServiceManager) IsRunning

func (m *WindowsServiceManager) IsRunning(string) (bool, error)

func (*WindowsServiceManager) Kind

func (m *WindowsServiceManager) Kind() string

func (*WindowsServiceManager) ListProfileGateways

func (m *WindowsServiceManager) ListProfileGateways() ([]string, error)

func (*WindowsServiceManager) RegisterProfileGateway

func (m *WindowsServiceManager) RegisterProfileGateway(string, bool) error

func (*WindowsServiceManager) RegisterProfileGatewayEnv

func (m *WindowsServiceManager) RegisterProfileGatewayEnv(string, map[string]string, bool) error

func (*WindowsServiceManager) Restart

func (m *WindowsServiceManager) Restart(string) error

func (*WindowsServiceManager) Start

func (m *WindowsServiceManager) Start(string) error

func (*WindowsServiceManager) Stop

func (m *WindowsServiceManager) Stop(context.Context, string) error

func (*WindowsServiceManager) SupportsRuntimeRegistration

func (m *WindowsServiceManager) SupportsRuntimeRegistration() bool

func (*WindowsServiceManager) UnregisterProfileGateway

func (m *WindowsServiceManager) UnregisterProfileGateway(string) error

Jump to

Keyboard shortcuts

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