Documentation
¶
Index ¶
- Constants
- Variables
- func AckConfirmed(answer *pyjson.Object, key, name string) bool
- func AckFailure(answer *pyjson.Object) string
- func BootNotice(folded []string) string
- func BringRootSlotUp(manager s6SlotManager) (string, error)
- func ClientEnvPolicy(ctx context.Context, parameters []any) (map[string]any, error)
- func CmdGatewayEnroll(ctx context.Context, ns map[string]any, w io.Writer) (int, error)
- func CmdGatewayEnsure(ctx context.Context, ns map[string]any, w io.Writer) (int, error)
- func ContainerBootMain(ctx context.Context, out io.Writer) int
- func CreateTitledSession(ctx context.Context, title string) (string, error)
- func DetectServiceManager() (string, error)
- func EnsureExitCode(result gateway.ObservedEndpoint) int
- func EnvLaunchFlags() *pyjson.Object
- func ExecSchtasks(args []string) (int, string, string, error)
- func ExplainServiceFailure(err error) []string
- func FormatGatewayPids(pids []int, limit int) string
- func GatewayCommand(ctx context.Context, ns map[string]any, w, errw io.Writer) (int, error)
- func GatewayDeclaresExternalSupervisor(pid int, h string) bool
- func GetStartupEntryPath(ctx context.Context) (string, error)
- func GetTaskName(ctx context.Context) (string, error)
- func InstallMigrateS6Hooks()
- func IsTaskRegistered(ctx context.Context) (bool, error)
- func LegacyStartupEntryPath(ctx context.Context) (string, error)
- func LiveWork(h, profile string) (*pyjson.Object, error)
- func LostBefore(frame any, epoch int) bool
- func ManualGatewayIdentity(h string, identify func(string) *pyjson.Object, ...) (*pyjson.Object, error)
- func NamedSlotName(profile string) string
- func ParkNamedSlot(ctx context.Context, profile string, manager s6SlotManager) error
- func PauseAcked(response, identity *pyjson.Object) bool
- func PauseSnapshotOwner(h, controlHome string, identity *pyjson.Object) (bool, error)
- func PrintDuplicateCredentialWarnings(ctx context.Context, w io.Writer)
- func PrintParkedStatus(ctx context.Context, w io.Writer) (bool, error)
- func PrintStandaloneByConfig(ctx context.Context, w io.Writer) error
- func ProfileLifecycle(ctx context.Context, w io.Writer, command string, ns map[string]any) (bool, error)
- func RefusalLines(ctx context.Context, verb string, homes []string, flagHint, profile string) ([]string, error)
- func RefuseRestartOfServiceManagedGateway(ctx context.Context, w io.Writer, pid int) error
- func RefuseWhileSessionsLive(ctx context.Context, w io.Writer, verb string, ns map[string]any, ...) error
- func RegisterUnregisteredProfileGateway(mgr ServiceManager, profile string) (bool, error)
- func ReportIncompatibleOwner(ctx context.Context, w io.Writer, pids []int) bool
- func RequestedPolicy(args map[string]any) *pyjson.Object
- func RestartExternallySupervisedGateway(ctx context.Context, w io.Writer, supervisedPid int) error
- func ResumeOverrides(ctx context.Context, args map[string]any, snapshot any) (map[string]any, error)
- func RunningNamedSlots(profiles []string, manager s6SlotManager) []string
- func S6Running() bool
- func SendCommand(ctx context.Context, h string, ns map[string]any, w, errw io.Writer) (int, error)
- func ShellClientEnv(ctx context.Context) (map[string]string, error)
- func SlotIsUp(profile string, manager s6SlotManager) bool
- func StripContainerArgvPrefix(argv []string) []string
- func ValidateServiceProfileName(name string) error
- func WebhookCommand(ctx context.Context, w io.Writer, args WebhookArgs) (int, error)
- type CallFunc
- type CallOptions
- type CallStopped
- type ConnectFunc
- type ConnectionClient
- type ConnectionLoss
- type FoldDecision
- type GatewayConnection
- func (c *GatewayConnection) Call(ctx context.Context, method string, params map[string]any) (any, error)
- func (c *GatewayConnection) CallTagged(ctx context.Context, method string, params map[string]any, o CallOptions) (any, int, error)
- func (c *GatewayConnection) CallWith(ctx context.Context, method string, params map[string]any, o CallOptions) (any, error)
- func (c *GatewayConnection) Client() ConnectionClient
- func (c *GatewayConnection) Close(ctx context.Context)
- func (c *GatewayConnection) Closed() bool
- func (c *GatewayConnection) Epoch() int
- func (c *GatewayConnection) Final() bool
- func (c *GatewayConnection) LaunchKey() (string, bool)
- func (c *GatewayConnection) LookupState(sessionID string) *SessionState
- func (c *GatewayConnection) Reattach(ctx context.Context, sessionID string, abandon func() bool) (any, error)
- func (c *GatewayConnection) Reply(requestID any, result any) bool
- func (c *GatewayConnection) Resume(ctx context.Context, call CallFunc, sessionID string, typed bool) (any, error)
- func (c *GatewayConnection) SetLaunchKey(key string, typed bool)
- func (c *GatewayConnection) SideWaiter(taskID string) *gateway.EventQueue
- func (c *GatewayConnection) Start(ctx context.Context, timeout time.Duration) error
- func (c *GatewayConnection) State(sessionID string) *SessionState
- type GatewayNotRegisteredError
- type GatewayRuntimeSnapshot
- type GatewaySessionStore
- func (s *GatewaySessionStore) AppendMessagesBatch(args ...any)
- func (s *GatewaySessionStore) AssertResumeSafe(ctx context.Context, sessionID string, maxMessages *int, tipOnly bool) (int, error)
- func (s *GatewaySessionStore) Attach(ctx context.Context, sessionID string, typed bool) (*pyjson.Object, error)
- func (s *GatewaySessionStore) Call(ctx context.Context, method string, params map[string]any) (any, error)
- func (s *GatewaySessionStore) ClientEnv(ctx context.Context) (map[string]any, error)
- func (s *GatewaySessionStore) CloseReader() error
- func (s *GatewaySessionStore) Create(ctx context.Context, launch map[string]any, title string, recordCwd bool) (string, error)
- func (s *GatewaySessionStore) CreateSession(args ...any)
- func (s *GatewaySessionStore) Current() *pyjson.Object
- func (s *GatewaySessionStore) EndSession(ctx context.Context, sessionID, reason string) error
- func (s *GatewaySessionStore) FinalizeOrphanedCompressionSessions(args ...any) int
- func (s *GatewaySessionStore) FlushTokenCounts(timeoutS float64) bool
- func (s *GatewaySessionStore) GetCompressionTip(ctx context.Context, sessionID string) (string, error)
- func (s *GatewaySessionStore) GetMessages(ctx context.Context, sessionID string, o state.GetMessagesOptions) ([]*pyjson.Object, error)
- func (s *GatewaySessionStore) GetMessagesAsConversation(ctx context.Context, sessionID string, o state.ConversationOptions) ([]map[string]any, error)
- func (s *GatewaySessionStore) GetMeta(ctx context.Context, key string) (string, bool, error)
- func (s *GatewaySessionStore) GetNextTitleInLineage(ctx context.Context, baseTitle string) (string, error)
- func (s *GatewaySessionStore) GetSession(ctx context.Context, sessionID string) (map[string]any, error)
- func (s *GatewaySessionStore) GetSessionModelConfigValue(ctx context.Context, sessionID, key string, def any) (any, error)
- func (s *GatewaySessionStore) GetSessionTitle(ctx context.Context, sessionID string) (string, bool, error)
- func (s *GatewaySessionStore) IsKanbanOwnedSession(ctx context.Context, sessionID string) (bool, error)
- func (s *GatewaySessionStore) ListSessionsRich(ctx context.Context, o state.ListSessionsRichOptions) ([]*pyjson.Object, error)
- func (s *GatewaySessionStore) MaybeAutoArchive(args ...any)
- func (s *GatewaySessionStore) MaybeAutoPruneAndVacuum(args ...any)
- func (s *GatewaySessionStore) Mutate(ctx context.Context, sessionID, operation string, payload map[string]any, ...) (any, error)
- func (s *GatewaySessionStore) OpenSession(ctx context.Context, cli OpenSessionCLI, launch map[string]any) (string, error)
- func (s *GatewaySessionStore) PruneEmptyGhostSessions(args ...any) int
- func (s *GatewaySessionStore) Reader(ctx context.Context) *SurfaceLabelReader
- func (s *GatewaySessionStore) ReopenSession(args ...any)
- func (s *GatewaySessionStore) ResolveResumeSessionID(ctx context.Context, sessionID string) (string, error)
- func (s *GatewaySessionStore) ResolveSessionByTitle(ctx context.Context, title string) (string, error)
- func (s *GatewaySessionStore) RewindUserTurn(ctx context.Context, sessionID string, userOrdinal int, ...) (*state.RewindOutcome, error)
- func (s *GatewaySessionStore) SanitizeTitle(title string) (string, error)
- func (s *GatewaySessionStore) SearchSessions(ctx context.Context, o SearchSessionsOptions) ([]map[string]any, error)
- func (s *GatewaySessionStore) SessionCount(ctx context.Context, o state.SessionCountOptions) (int, error)
- func (s *GatewaySessionStore) SessionYoloEnabled(sessionMeta map[string]any) bool
- func (s *GatewaySessionStore) SetMeta(args ...any)
- func (s *GatewaySessionStore) SetSessionTitle(ctx context.Context, sessionID, title string) (bool, error)
- func (s *GatewaySessionStore) UpdateTokenCounts(args ...any)
- type InspectError
- type LoopThreadError
- type NamedSlotState
- type NotImplementedError
- type OpenSessionCLI
- type ProcessIdentity
- type ProfileGatewayProcess
- type ReconcileAction
- type S6CommandError
- type S6Error
- type S6ServiceManager
- func (m *S6ServiceManager) IsRunning(name string) (bool, error)
- func (m *S6ServiceManager) Kind() string
- func (m *S6ServiceManager) ListProfileGateways() ([]string, error)
- func (m *S6ServiceManager) RegisterProfileGateway(profile string, startNow bool) error
- func (m *S6ServiceManager) RegisterProfileGatewayEnv(profile string, extraEnv map[string]string, startNow bool) error
- func (m *S6ServiceManager) Restart(name string) error
- func (m *S6ServiceManager) SlotScandir() string
- func (m *S6ServiceManager) Start(name string) error
- func (m *S6ServiceManager) Stop(ctx context.Context, name string) error
- func (m *S6ServiceManager) SupportsRuntimeRegistration() bool
- func (m *S6ServiceManager) UnregisterProfileGateway(profile string) error
- type SearchSessionsOptions
- type ServiceManager
- type SessionListener
- type SessionState
- type SnapshotCommand
- func (s SnapshotCommand) Create(parts []string) ([]string, error)
- func (s SnapshotCommand) List() ([]string, error)
- func (s SnapshotCommand) Prune(parts []string) ([]string, error)
- func (s SnapshotCommand) RestoreReport(snapID string, restored bool, restoreErr error, onGateway bool) ([]string, error)
- func (s SnapshotCommand) RestoreTarget(parts []string) (string, []string, error)
- type SnapshotRestore
- type SurfaceLabelReader
- func (r *SurfaceLabelReader) Close() error
- func (r *SurfaceLabelReader) DB() *state.SessionDB
- func (r *SurfaceLabelReader) GetCompressionTip(ctx context.Context, sessionID string) (string, error)
- func (r *SurfaceLabelReader) GetSession(ctx context.Context, sessionID string) (map[string]any, error)
- func (r *SurfaceLabelReader) ListSessionsRich(ctx context.Context, o state.ListSessionsRichOptions) ([]*pyjson.Object, error)
- func (r *SurfaceLabelReader) LocalReceipt(ctx context.Context, sessionID string) (map[string]any, error)
- func (r *SurfaceLabelReader) ResolveSessionByTitle(ctx context.Context, title string) (string, error)
- func (r *SurfaceLabelReader) ResolveSessionID(ctx context.Context, idOrPrefix string) (string, error)
- func (r *SurfaceLabelReader) SearchSessions(ctx context.Context, o SearchSessionsOptions) ([]map[string]any, error)
- func (r *SurfaceLabelReader) SessionCount(ctx context.Context, o state.SessionCountOptions) (int, error)
- type TitleInUseError
- type WebhookArgs
- type WinService
- type WindowsGatewayService
- type WindowsServiceError
- type WindowsServiceManager
- func (m *WindowsServiceManager) Install(o gateway.WindowsInstallOptions) error
- func (m *WindowsServiceManager) IsRunning(string) (bool, error)
- func (m *WindowsServiceManager) Kind() string
- func (m *WindowsServiceManager) ListProfileGateways() ([]string, error)
- func (m *WindowsServiceManager) RegisterProfileGateway(string, bool) error
- func (m *WindowsServiceManager) RegisterProfileGatewayEnv(string, map[string]string, bool) error
- func (m *WindowsServiceManager) Restart(string) error
- func (m *WindowsServiceManager) Start(string) error
- func (m *WindowsServiceManager) Stop(context.Context, string) error
- func (m *WindowsServiceManager) SupportsRuntimeRegistration() bool
- func (m *WindowsServiceManager) UnregisterProfileGateway(string) error
Constants ¶
const ( S6DynamicScandir = "/run/service" S6ServicePrefix = "gateway-" )
const DefaultStartTimeout = 90 * time.Second
Dial budget of one connection start
Variables ¶
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} )
var AutostartStates = map[string]bool{"running": true}
Desired states that autostart, everything else waits for the operator
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
var ( // Tree the one shot chat recorded for its worktree flag, assigned by the CLI package RecordedWorktree = func() map[string]string { return nil } )
var SealedSteward func(projectRoot string) *string
Steward owning the sealed install tree, installed by cmd/icebath over the self update steward probe
Send message tool of the messaging platforms, installed by the plugins tier that carries the send command
Functions ¶
func AckConfirmed ¶
Whether a host control answer confirms name under key without an error
func AckFailure ¶
Why a host control answer did not confirm the operation
func BootNotice ¶
Notice naming the named slots whose autostart the root slot took over
func BringRootSlotUp ¶
Starts the root slot or restarts it so it rereads its config, the one line description returned
func ClientEnvPolicy ¶
client_env of a new session when the gateway create contract takes it, nothing for an older gateway
func CmdGatewayEnroll ¶
Enrolls this gateway with a relay connector and persists the relay auth credentials to the profile env file
func CmdGatewayEnsure ¶
Ensures a local runtime for this home and prints one credential free JSON verdict, exiting with its code
func ContainerBootMain ¶
Boot reconcile entry, printing the notice and one line per slot
func CreateTitledSession ¶
Creates a titled session through the gateway with no cwd stamp, returning its id
func DetectServiceManager ¶
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 ¶
Creation flags set truthy in this shell's environment, in declaration order
func ExecSchtasks ¶
The Windows only RuntimeError schtasks raises on every other host
func ExplainServiceFailure ¶
Guidance lines for a systemd failure escaping the gateway command, nil for a failure it cannot explain
func FormatGatewayPids ¶
Comma joined positive pids, the first limit of them and an ellipsis when more exist, every pid for a negative limit
func GatewayCommand ¶
Handles the gateway subcommands, systemd failures ending as guidance instead of a traceback
func GatewayDeclaresExternalSupervisor ¶
Whether the running gateway pid was launched for an external supervisor by identify, live argv or recorded argv
func GetStartupEntryPath ¶
Startup folder VBS launcher of the task
func GetTaskName ¶
Scheduled Task name scoped per profile
func InstallMigrateS6Hooks ¶
func InstallMigrateS6Hooks()
Installs the s6 legs the multiplex migration in pkg/gatewayrun drives
func IsTaskRegistered ¶
Whether schtasks answers the task query with exit code zero
func LegacyStartupEntryPath ¶
Startup folder cmd entry older installs wrote
func LiveWork ¶
What the gateway serving home runs now, the control socket first then the state file when no profile narrows it
func LostBefore ¶
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) *pyjson.Object, fail func(string, ...any) error) (*pyjson.Object, error)
Identify answer of the manually launched gateway owning the home, nil when none runs, an error for a supervised one
func NamedSlotName ¶
s6 service directory name of a profile's slot
func ParkNamedSlot ¶
Stops a named slot and writes its down file so a supervisor restart does not revive it
func PauseAcked ¶
Whether the identified gateway itself accepted the drain or is already stopping
func PauseSnapshotOwner ¶
Hands the profile off to maintenance, true when this restore parked a satellite and must serve it again
func PrintDuplicateCredentialWarnings ¶
Prints the migrate preflight duplicate credential findings as status warnings
func PrintParkedStatus ¶
Prints the parked line of this satellite or the parked roster of the default profile, true for a parked satellite
func PrintStandaloneByConfig ¶
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 ¶
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 ¶
Prints the cross version refusal with its fix when the running gateway cannot serve this version
func RequestedPolicy ¶
Launch flags as session.create policy, toolsets and skills as lists and the source as its create label
func RestartExternallySupervisedGateway ¶
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 ¶
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 ¶
Sends text from a shell to a configured messaging platform, exit 0 ok, 1 delivery error, 2 usage error
func ShellClientEnv ¶
Allowlisted environment of this shell with the extra names of the profile config, code defaults on a bypass launch
func StripContainerArgvPrefix ¶
Container command with everything through the supervisor or wrapper token and a leading icebath dropped
func ValidateServiceProfileName ¶
Error unless the name is a filesystem and s6 safe profile name
func WebhookCommand ¶
WebhookCommand runs icebath webhook and returns the exit status, 1 when a refusal wrote nothing
Types ¶
type CallOptions ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 (*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) (*pyjson.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 ¶
client_env of this shell when the gateway takes it, the create contract described once per store
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() *pyjson.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) ([]*pyjson.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) 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 ¶
func (s *GatewaySessionStore) ListSessionsRich(ctx context.Context, o state.ListSessionsRichOptions) ([]*pyjson.Object, error)
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 *pyjson.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 ¶
func (s *GatewaySessionStore) Reader(ctx context.Context) *SurfaceLabelReader
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 ¶
func (s *GatewaySessionStore) SessionCount(ctx context.Context, o state.SessionCountOptions) (int, error)
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 ¶
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) PyTypeName ¶
func (e *LoopThreadError) PyTypeName() string
type NamedSlotState ¶
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 ¶
Pid and creation time of one process incarnation
type ProfileGatewayProcess ¶
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 ¶
s6 command failure other than a missing slot, with its stderr
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 ¶
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 *pyjson.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 ¶
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 ¶
Outcome of a restore that handed the profile off the gateway
func RestoreSnapshotOffGateway ¶
func RestoreSnapshotOffGateway(ctx context.Context, h, snapID string, identity func(string) (*pyjson.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 ¶
func (r *SurfaceLabelReader) DB() *state.SessionDB
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 ¶
func (r *SurfaceLabelReader) ListSessionsRich(ctx context.Context, o state.ListSessionsRichOptions) ([]*pyjson.Object, error)
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 ¶
func (r *SurfaceLabelReader) SessionCount(ctx context.Context, o state.SessionCountOptions) (int, error)
Session count under the list filters with the same created surface matching as the listings
type TitleInUseError ¶
Raised when another session already holds a title the gateway refused
func (*TitleInUseError) Error ¶
func (e *TitleInUseError) Error() string
func (*TitleInUseError) PyTypeName ¶
func (e *TitleInUseError) PyTypeName() 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 ¶
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 ¶
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 ¶
func (m *WindowsServiceManager) Install(o gateway.WindowsInstallOptions) error
Installs the Windows gateway task with its platform options
func (*WindowsServiceManager) ListProfileGateways ¶
func (*WindowsServiceManager) RegisterProfileGateway ¶
func (*WindowsServiceManager) RegisterProfileGatewayEnv ¶
func (*WindowsServiceManager) SupportsRuntimeRegistration ¶
func (m *WindowsServiceManager) SupportsRuntimeRegistration() bool
func (*WindowsServiceManager) UnregisterProfileGateway ¶
Source Files
¶
- container_boot.go
- format_gateway_pids.go
- gateway.go
- gateway_chat_policy.go
- gateway_cmd.go
- gateway_cmd_console_other.go
- gateway_cmd_run.go
- gateway_cmd_status.go
- gateway_cmd_support.go
- gateway_command_errors.go
- gateway_connection.go
- gateway_enroll.go
- gateway_multiplex_s6.go
- gateway_runner_ref.go
- gateway_runtime_cli.go
- gateway_session_store.go
- gateway_session_store_reads.go
- gateway_snapshot_rejoin.go
- gateway_windows_exec_other.go
- gateway_windows_names.go
- log.go
- runtime_snapshot.go
- send_cmd.go
- service_manager.go
- service_manager_unix.go
- snapshot_command.go
- surface_label_reader.go
- webhook.go
- webhook_cron.go
- windows_service_get.go
- windows_services.go