gatewayrun

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 92 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 (
	DefaultIdleExitSeconds = 600.0
	IdleExitReason         = "idle_exit"
	IdleExitStopPrefix     = "auto-started gateway idle"
)
View Source
const MigrateCommand = gateway.HostMigrateCommand

Command that converges every per profile gateway onto the host gateway

View Source
const MigrationManifestName = "gateway_migration.json"

File in the default home recording the pre migration footprint

Variables ¶

View Source
var (
	CheckRuntime          func(ctx context.Context, projectRoot string) (string, error)
	MaybeRunBootBootstrap func(ctx context.Context, projectRoot string)
	ConfigureWindowsStdio func() bool
)

Steps of packages above this one that the module entry runs, assigned by cmd/icebath, the update steps nil without the updater

View Source
var (
	ActivePersonalityName  func(cfg map[string]any) string
	AvailablePersonalities func(cfg map[string]any) map[string]any
	DescribePersonality    func(value any, width int) string
	PersistPersonality     func(ctx context.Context, value any) bool
	ResolvePersonality     func(value any, cfg map[string]any) (string, string, error)
)

Personality catalog operations of the commands package, assigned in cmd/icebath wiring

View Source
var BindTeamsPipelineRuntime func(ctx context.Context, runner *GatewayRunner) (bool, error)

Binds the Teams meeting pipeline to the Graph webhook ingress

View Source
var BuildInitPromptForCwd func(env *tools.Env, cwd, extra string, sessionKey *string) string

The init prompt for the session's active directory, its AGENTS.md read when present

View Source
var ErrKeyboardInterrupt error = &gateway.PyError{Kind: "KeyboardInterrupt"}

Error of a start an interrupt ended before the gateway routed its own signals, the KeyboardInterrupt of asyncio.run

View Source
var ExecuteSlashCommand func(ctx context.Context, name, surface, args string, options map[string]any) (SlashCommandReply, error)

Shared slash executor of pkg/commands run on a surface with its args and options, assigned in cmd/icebath wiring

View Source
var GatewayDebugLocalReport func(ctx context.Context) (string, error)

Redacted local debug report of the profile, assigned in cmd/icebath wiring

View Source
var GatewayDebugUploadReply func(ctx context.Context) (string, error)

Summary only debug upload and its chat reply, assigned in cmd/icebath wiring

View Source
var GatewayKnownCommand func(name string) bool

Whether a name is one of the builtin gateway commands

View Source
var IsGatewayKnownCommand func(name string) bool

Whether a name is a builtin or registered plugin gateway command

View Source
var MigrateS6 struct {
	Running         func() bool
	Scandir         func() string
	NamedSlotName   func(profile string) string
	SlotIsUp        func(profile string) bool
	ParkNamedSlot   func(ctx context.Context, profile string) error
	BringRootSlotUp func() (string, error)
}

s6 legs the migration drives, assigned in cmd/icebath/wiring.go from pkg/gatewaycli

View Source
var ParseServiceTierConfig func(raw string) string

Persisted /fast preference parsed like the CLI, empty when unset or unknown, assigned by the app package

View Source
var RandomTip func(ctx context.Context) string

Random tip in the active language, assigned in cmd/icebath wiring

View Source
var ResolveCommand func(name string) (string, bool)

Canonical command name of a typed slash name or alias, false when no command is registered under it

View Source
var ResolveCommandBusy func(name string) (canonical, busyPolicy, busyHandler string, ok bool)

Canonical name, busy policy and busy handler key of a registered command, false when none is registered

View Source
var ResolveEphemeralSystemPromptFromConfig func(cfg map[string]any) string

Ephemeral system prompt of a config from its personality or system prompt, assigned by the command package

View Source
var RunApprovalModeCommand func(ctx context.Context, h string, env *tools.Env, requestedMode string) (message string, err error)

Profile approval mode shown or persisted with its reply message, assigned in cmd/icebath wiring

View Source
var RunCuratorSlash func(ctx context.Context, env *tools.Env, argv []string, out io.Writer)

Curator CLI run on argv writing its report, help and errors to out, assigned in cmd/icebath wiring

View Source
var RunGatewayExecQuickCommand func(ctx context.Context, env *tools.Env, execCmd any, cwd string) (string, error)

Runs a type exec quick command as a host shell of the gateway with a sanitized env and redacted output

View Source
var SanitizeTelegramName func(raw string) string

Lowercased hyphen folded command name Telegram accepts, assigned in cmd/icebath wiring

View Source
var SaveConfigValue func(ctx context.Context, keyPath string, value any) bool

Writes one dotted config key into config.yaml, false when the write did not land

View Source
var ServeSessionSocket func(ctx context.Context, sock SessionSocket, identity map[string]any, subprotocol *string, operator bool) error

Session handler an admitted socket runs, assigned by the command wiring

View Source
var SlashConfirmClear func(sessionKey string)

Clears a session's pending slash confirm, the tools slash_confirm module the command layer owns

View Source
var SlashConfirmClearIfStale func(sessionKey string) bool

Drops a pending slash confirm older than the default timeout, true when it did

View Source
var SlashConfirmGetPending func(sessionKey string) (string, bool)

Confirm id of the slash confirm pending for the session, false when none is

View Source
var SlashConfirmPending func(sessionKey string) bool

Whether a destructive slash command confirmation is pending for the session

View Source
var SlashConfirmRegister func(sessionKey, confirmID, command string, handler func(ctx context.Context, choice string) (string, error))

Records a pending slash confirm whose handler runs with the chosen answer, superseding any prior one

View Source
var SlashConfirmResolve func(ctx context.Context, sessionKey, confirmID, choice string) string

Runs the pending slash confirm handler with a choice, empty when stale, superseded or already resolved

View Source
var SweepExpiredPastes func(ctx context.Context, now *float64) (deleted, remaining int, err error)

Paste sweep of pkg/selfupdate deleting expired pending pastes, set by the command wiring

Functions ¶

func ApplyMigration ¶

func ApplyMigration(ctx context.Context, w io.Writer, plan *MigrationPlan, servedWait time.Duration) (bool, error)

Flips the flag, removes every secondary gateway, brings the multiplexer up and verifies it serves every profile

func AutoMigrationBlockers ¶

func AutoMigrationBlockers(plan *MigrationPlan) []string

Every boundary a standalone secondary sits behind, each distinct finding once in order

func AutoMigrationOptedOut ¶

func AutoMigrationOptedOut(ctx context.Context, defaultHome string) (bool, error)

Whether the default profile's effective config sets gateway.auto_multiplex_migration false

func BootstrapAtExit ¶

func BootstrapAtExit()

Runs and clears the exit functions the gateway bootstrap registered, newest first, a panic not stopping the rest

func CmdMigrate ¶

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

Prints the plan and applies it, exiting 1 on a refusal or failed apply and 0 on success

func DispatchGatewayRunModuleEntry ¶

func DispatchGatewayRunModuleEntry(ctx context.Context, exit func(int))

Runs the gateway module entry and exits when argv carries its entry word

func DuplicateCredentialFindings ¶

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

Duplicate credential findings read straight from the local profile homes, unloadable configs skipped

func DuplicateCredentialLines ¶

func DuplicateCredentialLines(ctx context.Context, configs []ProfileGatewayConfig) []string

One finding per platform credential two profiles both hold, naming profiles and key names only

func ExitAfterGracefulShutdown ¶

func ExitAfterGracefulShutdown(ctx context.Context, exitCode int)

Releases the pid file and lock, stamps the clean exit, flushes metrics and logs, then hard exits with code

func FormatPlan ¶

func FormatPlan(plan *MigrationPlan, dryRun bool) []string

Plan table, the steps apply takes and every process it will signal, then blockers and notices

func FormatUpdateWarning ¶

func FormatUpdateWarning(plan *MigrationPlan, autoBlockers []string) []string

Update hook block naming every blocker the automatic migration will not cross

func HomeEnv ¶

func HomeEnv(ctx context.Context, h string) (context.Context, func())

Runs service helpers as if h were the active home, the launch identity pinned while swapped

func ImplicitMultiplexBlocker ¶

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

Why this process must not multiplex right now, empty when it may

func ImportRunModule ¶

func ImportRunModule(ctx context.Context) error

Runs once what importing the runner module does, the gateway marker, dotenv, config env bridge and startup warnings

func Main ¶

func Main(ctx context.Context, argv []string, stdout, stderr io.Writer) int

Runs the gateway module entry and returns its exit status, hard exiting after a started gateway tore down

func MaskedDefaultUnit ¶

func MaskedDefaultUnit(ctx context.Context, defaultHome string) (string, error)

Default profile systemd unit the operator masked to dev null, empty when neither scope is masked

func MaybeAutoMigrateAfterUpdate ¶

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

Update hook folding per profile gateways into one multiplexer when unblocked, else printing the blockers

func ProfileAdaptersAndConfig ¶

func ProfileAdaptersAndConfig(ctx context.Context, runner any, profile string) (*gateway.AdapterMap, *gateway.GatewayConfig, error)

Adapter map and gateway config of an adapter's owning profile, the runner's own for the primary profile

func RegisterAtExit ¶

func RegisterAtExit(fn func())

Registers a function the process exit path runs, the atexit registration of the gateway command

func ResolutionFailureReply ¶

func ResolutionFailureReply(ctx context.Context, err error, platform gateway.Platform) (string, string, bool)

Chat text, failure reason and retryable flag a messaging turn answers a resolution failure with

func ResolveMultiplexMode ¶

func ResolveMultiplexMode(ctx context.Context, cfg *gateway.GatewayConfig) (gateway.MultiplexDecision, error)

Settles the config's multiplex flag for one boot in place, refusing while any blocker holds

func RollbackMigration ¶

func RollbackMigration(ctx context.Context, w io.Writer, defaultHome string) (bool, error)

Compensator of a failed apply, puts the default's one gateway back on the recorded flag

func RunGateway ¶

func RunGateway(ctx context.Context, o StartGatewayOptions) (bool, error)

Runs StartGateway as asyncio.run does, a first unrouted interrupt cancelling the start and a second ending the wait

func StartGateway ¶

func StartGateway(ctx context.Context, o StartGatewayOptions) (bool, error)

Starts the gateway and runs until interrupted, false when it failed to start so supervisors restart it

Types ¶

type CommentAgentRun ¶

type CommentAgentRun struct {
	FinalResponse string
	APICalls      int
	Messages      []map[string]any
}

Outcome of one comment agent turn

func RunCommentAgent ¶

func RunCommentAgent(ctx context.Context, prompt string, toolsets []any, onRuntime func(CommentAgentRuntime) []map[string]any, onRun func()) (*CommentAgentRun, error)

Runs one platform comment agent turn on toolsets, onRuntime returning the history and onRun marking the start

type CommentAgentRuntime ¶

type CommentAgentRuntime struct {
	Model    string
	Provider string
	BaseURL  string
}

Model and provider route a comment agent turn runs on

type ConversationState ¶

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

State scoped to one conversation that survives turns but not boundaries

type DeliveryQueueWatch ¶

type DeliveryQueueWatch struct {
	Drain func()
	// contains filtered or unexported fields
}

Stamp comparison of every served profile's delivery queue file, draining when a stamp moved

func NewDeliveryQueueWatch ¶

func NewDeliveryQueueWatch(ctx context.Context, homes func() []*string, drain func()) *DeliveryQueueWatch

Watch over the served homes, a nil home standing for the active one, stamped once at creation

func (*DeliveryQueueWatch) Changed ¶

func (w *DeliveryQueueWatch) Changed(ctx context.Context) bool

Whether any queue stamp moved since the last look, remembering the new stamps

type GatewayRunner ¶

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

Main gateway controller that manages adapter lifecycles and routes messages to and from the agent

func NewGatewayRunner ¶

func NewGatewayRunner(ctx context.Context, config *gateway.GatewayConfig) (*GatewayRunner, error)

Runner over an explicit config with the standalone opt out applied, else over the loaded runner config

func (*GatewayRunner) ActiveProfileName ¶

func (r *GatewayRunner) ActiveProfileName(ctx context.Context) string

Profile the home in scope belongs to, default for the root home

func (*GatewayRunner) AdapterCredentialFingerprint ¶

func (r *GatewayRunner) AdapterCredentialFingerprint(adapter gateway.PlatformAdapter) *string

Salted log safe hash of an adapter credential, nil when none is discoverable

func (*GatewayRunner) AdapterFlag ¶

func (r *GatewayRunner) AdapterFlag(ctx context.Context, platform gateway.Platform, name string, profile *string) bool

Truth of a named flag on the adapter that authorizes the platform for the profile

func (*GatewayRunner) AdapterForSource ¶

func (r *GatewayRunner) AdapterForSource(ctx context.Context, source *gateway.SessionSource) (gateway.PlatformAdapter, error)

Adapter owning the source for the session authority, the delivery seam under its historical name

func (*GatewayRunner) AdapterProfileForSource ¶

func (r *GatewayRunner) AdapterProfileForSource(source *gateway.SessionSource) *string

Profile whose adapter received the source, nil for the launch profile

func (*GatewayRunner) Adapters ¶

Primary profile's live adapters by platform

func (*GatewayRunner) AdaptersForProfile ¶

func (r *GatewayRunner) AdaptersForProfile(profile *string) *pydict.Dict[gateway.Platform, gateway.PlatformAdapter]

Live adapter map of the profile a source names, the profile adapters seam of the session authority

func (*GatewayRunner) AdmitPrimarySource ¶

func (r *GatewayRunner) AdmitPrimarySource(ctx context.Context, source *gateway.SessionSource, defaultHome string) (string, bool)

Runtime home of a primary adapter source, false for a route to an unserved profile

func (*GatewayRunner) ApplyReasoningSelection ¶

func (r *GatewayRunner) ApplyReasoningSelection(ctx context.Context, sessionKey, platformKey, value string, persistGlobal bool) string

Applies a reasoning pick to a route for the session controls, the reply text returned

func (*GatewayRunner) AsyncSessionStore ¶

func (r *GatewayRunner) AsyncSessionStore() *gateway.AsyncSessionStore

The one async facade over this runner's session store, rebuilt when the store was swapped

func (*GatewayRunner) AttachClient ¶

func (r *GatewayRunner) AttachClient() (release func())

Counts an attached native client until the returned release runs

func (*GatewayRunner) AuthorizationAdapter ¶

func (r *GatewayRunner) AuthorizationAdapter(ctx context.Context, platform gateway.Platform, profile *string) gateway.PlatformAdapter

Live adapter of a profile whose intake policy gates authorization, the API server platform callback target

func (*GatewayRunner) CachedAgentFor ¶

func (r *GatewayRunner) CachedAgentFor(sessionKey string) any

Cached agent of the session key peeked under the cache lock without evicting it, nil when absent

func (*GatewayRunner) Canonicalize ¶

func (r *GatewayRunner) Canonicalize(ctx context.Context, source *gateway.SessionSource, transportProfile, primaryHome string) *gateway.RoutingIdentity

Runner side identity seam of producer ingress

func (*GatewayRunner) ChannelOverrideFor ¶

func (r *GatewayRunner) ChannelOverrideFor(source *gateway.SessionSource) *gateway.ChannelOverride

Channel overrides entry of the chat a source arrived on, nil when none applies

func (*GatewayRunner) ClassifyCompletionOwner ¶

func (r *GatewayRunner) ClassifyCompletionOwner(ctx context.Context, parentSessionID, sessionKey string) (string, string, string, error)

Verdict, owner and target of the conversation a background result belongs to

func (*GatewayRunner) ClearDurableActiveTurn ¶

func (r *GatewayRunner) ClearDurableActiveTurn(ctx context.Context, event *gateway.MessageEvent) error

Clears the durable crash marker the event owns, a failed clear only logged

func (*GatewayRunner) CompletionDeliveryIdentity ¶

func (r *GatewayRunner) CompletionDeliveryIdentity(_ context.Context, event map[string]any) []any

Producer stable identity of a background result as its three element tuple, nil when it carries none

func (*GatewayRunner) DeliveryAdapterFor ¶

func (r *GatewayRunner) DeliveryAdapterFor(ctx context.Context, source *gateway.SessionSource) (gateway.PlatformAdapter, error)

Adapter that answers the source, the receiving bot when known and else its unique owner

func (*GatewayRunner) Draining ¶

func (r *GatewayRunner) Draining() bool

Whether the runner is draining

func (*GatewayRunner) EffectiveBusyInputMode ¶

func (r *GatewayRunner) EffectiveBusyInputMode(ctx context.Context, source *gateway.SessionSource) string

Busy input mode of the routed profile startup snapshot for the session controls

func (*GatewayRunner) EvictCachedAgent ¶

func (r *GatewayRunner) EvictCachedAgent(route string)

Evicts the cached agent of a route, the session retirement surface

func (*GatewayRunner) EvictCachedAgentAtBoundary ¶

func (r *GatewayRunner) EvictCachedAgentAtBoundary(route string)

Evicts the cached agent of a route with its memory committed, the session boundary surface

func (*GatewayRunner) EvictIdleStaleAgent ¶

func (r *GatewayRunner) EvictIdleStaleAgent(ctx context.Context, route string)

Frees the running slot of a route whose agent went idle past its stale bound

func (*GatewayRunner) EvictReapedAgent ¶

func (r *GatewayRunner) EvictReapedAgent(ctx context.Context, route string)

Frees the running slot of a route whose stored session was reaped

func (*GatewayRunner) ExitCode ¶

func (r *GatewayRunner) ExitCode() *int

Exit status the gateway asked for, nil while it runs

func (*GatewayRunner) ExitReason ¶

func (r *GatewayRunner) ExitReason() *string

Reason the gateway gave for exiting, nil while it runs

func (*GatewayRunner) ExpandInboundContextReferences ¶

func (r *GatewayRunner) ExpandInboundContextReferences(ctx context.Context, source *gateway.SessionSource, sessionKey, text string) (*string, error)

Expanded inbound text, nil after a refused injection whose refusal went to the chat

func (*GatewayRunner) FinalizeSessionOffLoop ¶

func (r *GatewayRunner) FinalizeSessionOffLoop(ctx context.Context, sessionID, platform, reason, sessionKey string) ([]string, error)

Session finalize hooks off the loop for the session boundary surface of pkg/gateway

func (*GatewayRunner) GatewayConfig ¶

func (r *GatewayRunner) GatewayConfig() *gateway.GatewayConfig

Launch profile's gateway config the session key derivation reads

func (*GatewayRunner) GatewayLoop ¶

func (r *GatewayRunner) GatewayLoop() gateway.EventLoop

Event loop the runner serves on, nil until gateway startup binds one and after the runtime resets it

func (*GatewayRunner) GetUnauthorizedDMBehavior ¶

func (r *GatewayRunner) GetUnauthorizedDMBehavior(ctx context.Context, platform gateway.Platform, profile *string) string

Unauthorized DM behavior of the platform for the profile, pair, decline or ignore

func (*GatewayRunner) GoalManagerForEvent ¶

func (r *GatewayRunner) GoalManagerForEvent(ctx context.Context, event *gateway.MessageEvent) (*goals.GoalManager, *gateway.SessionEntry)

Goal manager and session entry of the event's session

func (*GatewayRunner) GoalMaxTurnsFromConfig ¶

func (r *GatewayRunner) GoalMaxTurnsFromConfig(ctx context.Context) int64

Goal turn budget of the user config, the default when unset or invalid

func (*GatewayRunner) HMBusyPreempt ¶

func (r *GatewayRunner) HMBusyPreempt(ctx context.Context, event *gateway.MessageEvent, source *gateway.SessionSource, sessionKey string) (bool, error)

Busy input mode of a producer delivery against the running turn, true when its text landed inside that turn

func (*GatewayRunner) HMPendingReplyIntercepts ¶

func (r *GatewayRunner) HMPendingReplyIntercepts(ctx context.Context, event *gateway.MessageEvent, source *gateway.SessionSource, sessionKey string) (*string, error)

Reply of a pending update prompt, clarify or slash confirm to a producer delivery, nil when none answers

func (*GatewayRunner) HMPreGatewayDispatchHook ¶

func (r *GatewayRunner) HMPreGatewayDispatchHook(ctx context.Context, event *gateway.MessageEvent, source *gateway.SessionSource) *gateway.MessageEvent

Producer path pre gateway dispatch hook, nil to drop the delivery, else the event or its rewrite

func (*GatewayRunner) HandleMessage ¶

func (r *GatewayRunner) HandleMessage(ctx context.Context, event *gateway.MessageEvent) (any, error)

Runs one inbound message through the gateway turn pipeline and returns its reply

func (*GatewayRunner) HandleModelReset ¶

func (r *GatewayRunner) HandleModelReset(ctx context.Context, event *gateway.MessageEvent, sw *gateway.ModelSwitchContext) (*string, error)

Drops the session model override so the next turn runs the channel or config route, the reply returned

func (*GatewayRunner) HasPendingSlashConfirm ¶

func (r *GatewayRunner) HasPendingSlashConfirm(route string) bool

Whether a slash confirm prompt awaits its answer under the session key

func (*GatewayRunner) InboundModelContextLength ¶

func (r *GatewayRunner) InboundModelContextLength(ctx context.Context, source *gateway.SessionSource, sessionKey string) (int, error)

Context window of the turn model, a global pin only for the configured route, custom limits winning

func (*GatewayRunner) InjectWatchNotification ¶

func (r *GatewayRunner) InjectWatchNotification(ctx context.Context, text string, event map[string]any) (*bool, error)

Injects a watch or completion notification as a synthetic event, true on acceptance, false to retry, nil with no route

func (*GatewayRunner) IsSessionRunning ¶

func (r *GatewayRunner) IsSessionRunning(route string) bool

Whether a turn holds the running slot of the session key

func (*GatewayRunner) IsSharedBotSatellite ¶

func (r *GatewayRunner) IsSharedBotSatellite(ctx context.Context, profileName string, platform gateway.Platform) bool

Whether a served profile rides the default bot through a profile route, owning no bot on the platform

func (*GatewayRunner) IsUserAuthorized ¶

func (r *GatewayRunner) IsUserAuthorized(ctx context.Context, source *gateway.SessionSource, allowAdapterDelegation bool) (bool, error)

Whether the sender of the source passes the full gateway authorization chain

func (*GatewayRunner) IsUserAuthorizedForSource ¶

func (r *GatewayRunner) IsUserAuthorizedForSource(ctx context.Context, source *gateway.SessionSource, allowAdapterDelegation bool) (bool, error)

Whether the sender of the source may talk to the agent, adapter delegation honoured when allowed

func (*GatewayRunner) JoinStartupRestore ¶

func (r *GatewayRunner) JoinStartupRestore(ctx context.Context, name string, wait func(ctx context.Context) error)

Holds the startup restore gate open for an adapter recovery task while startup restore runs

func (*GatewayRunner) LegacyAdapterCredentialFingerprint ¶

func (r *GatewayRunner) LegacyAdapterCredentialFingerprint(adapter gateway.PlatformAdapter) *string

Credential fingerprint under the salt an older icebath used, nil when none is discoverable

func (*GatewayRunner) LocalBusySlashCommand ¶

func (r *GatewayRunner) LocalBusySlashCommand(ctx context.Context, event *gateway.MessageEvent, def gateway.RegistryCommand, quickKey string, source *gateway.SessionSource) (any, error)

Mid run dispatch of a recognized command, its variant, its handler or the rejection text

func (*GatewayRunner) LocalCommandHandler ¶

func (r *GatewayRunner) LocalCommandHandler(canonical string) func(ctx context.Context, event *gateway.MessageEvent) (any, error)

Slash handler of a canonical name as the handler table resolves it, nil when the runner has none

func (*GatewayRunner) LocalExecQuickCommand ¶

func (r *GatewayRunner) LocalExecQuickCommand(ctx context.Context, command, shell, cwd string) (string, error)

Runs an exec quick command in a local session's folder with a sanitized env and redacted output

func (*GatewayRunner) LocalPluginCommand ¶

func (r *GatewayRunner) LocalPluginCommand(ctx context.Context, handler plugins.PluginCommandHandler, event *gateway.MessageEvent, source *gateway.SessionSource, entry *gateway.SessionEntry, args string) (any, error)

Runs a plugin command handler under the session env of the source with the argument as typed

func (*GatewayRunner) LocalPromptCommand ¶

func (r *GatewayRunner) LocalPromptCommand(ctx context.Context, canonical string, event *gateway.MessageEvent, source *gateway.SessionSource, quickKey string) (bool, any, error)

Idle path rewrite of a prompt command, false with the rewritten event text when it becomes a turn

func (*GatewayRunner) LocalSlashAccess ¶

func (r *GatewayRunner) LocalSlashAccess(ctx context.Context, source *gateway.SessionSource, canonical string) string

Operator slash access refusal text for the command, empty when allowed

func (*GatewayRunner) MCPReloadRefreshCachedAgents ¶

func (r *GatewayRunner) MCPReloadRefreshCachedAgents(multiplex bool, profile string)

Refreshes cached agents with the reloaded MCP tools, under multiplex only the profile's own sessions

func (*GatewayRunner) MediaDeliveryScopeForSource ¶

func (r *GatewayRunner) MediaDeliveryScopeForSource(ctx context.Context, source *gateway.SessionSource) (context.Context, func(), error)

Home and terminal policy scope the adapter validates a turn's media paths in, unscoped without multiplexing

func (*GatewayRunner) ModelSwitchLock ¶

func (r *GatewayRunner) ModelSwitchLock() *sync.Mutex

Runner wide lock over a model command's read, resolve and commit

func (*GatewayRunner) MultiplexProfiles ¶

func (r *GatewayRunner) MultiplexProfiles() bool

Whether the runner multiplexes every served profile

func (*GatewayRunner) OnGatewayLoop ¶

func (r *GatewayRunner) OnGatewayLoop(ctx context.Context) bool

Whether ctx runs as a task of the runner's gateway loop rather than on a worker thread

func (*GatewayRunner) OwningProfile ¶

func (r *GatewayRunner) OwningProfile(adapter gateway.PlatformAdapter, platform gateway.Platform) (bool, string)

Registered flag and owning secondary profile of a live adapter, empty for the primary

func (*GatewayRunner) ParsePlatform ¶

func (r *GatewayRunner) ParsePlatform(ctx context.Context, value string) (string, error)

Enum value gateway.config.Platform accepts for the platform name, a ValueError for any other value given

func (*GatewayRunner) ParseReasoningCommandArgs ¶

func (r *GatewayRunner) ParseReasoningCommandArgs(arg string) (string, bool)

Value and global flag of reasoning command arguments

func (*GatewayRunner) PeekSessionState ¶

func (r *GatewayRunner) PeekSessionState(route string) gateway.PeekedSessionState

State of a route without creating one, nil when absent

func (*GatewayRunner) PerformModelSwitch ¶

func (r *GatewayRunner) PerformModelSwitch(ctx context.Context, sw *gateway.ModelSwitchContext, rawInput, explicitProvider string, source *gateway.SessionSource) (*provider.ModelSwitchResult, string, error)

Resolves a model switch to its result, or a nil result with the error reply text

func (*GatewayRunner) PersistActiveAgents ¶

func (r *GatewayRunner) PersistActiveAgents()

Republishes the in flight count once owner work the session authority counts ends

func (*GatewayRunner) PluginLocalSession ¶

func (r *GatewayRunner) PluginLocalSession(ctx context.Context, source *gateway.SessionSource, sessionKey, pluginHome, pluginID string) (*gateway.LiveSession, error)

Live local session the plugin profile's own authority holds under the key, nil when it holds none

func (*GatewayRunner) PluginMessagingSessionOwned ¶

func (r *GatewayRunner) PluginMessagingSessionOwned(ctx context.Context, sessionKey, pluginHome, pluginID string) bool

Whether a messaging session belongs to the plugin's own profile, true for a caller without a home

func (*GatewayRunner) PrimaryProfileName ¶

func (r *GatewayRunner) PrimaryProfileName() string

Profile that owns the primary adapter map, default under multiplexing

func (*GatewayRunner) ProfileAdapterMap ¶

func (r *GatewayRunner) ProfileAdapterMap(name string) *pydict.Dict[gateway.Platform, gateway.PlatformAdapter]

Adapter map of a served profile, created on first use

func (*GatewayRunner) ProfileAdapters ¶

Adapter maps of the served secondary profiles by profile name

func (*GatewayRunner) ProfileConfigs ¶

func (r *GatewayRunner) ProfileConfigs() map[string]*gateway.GatewayConfig

Gateway config of every served profile as loaded once at startup

func (*GatewayRunner) ProfileNameForSource ¶

func (r *GatewayRunner) ProfileNameForSource(ctx context.Context, source *gateway.SessionSource, adapterProfile *string) (*string, error)

Profile a configured route sends the source to, nil without a match, a refused route raising ProfileRouteRejected

func (*GatewayRunner) RecordModelSwitch ¶

func (r *GatewayRunner) RecordModelSwitch(ctx context.Context, result *provider.ModelSwitchResult, sw *gateway.ModelSwitchContext, source *gateway.SessionSource, oneTurn, picker bool) string

Persists a committed switch as the session override, the global write warning when one failed

func (*GatewayRunner) RedeliverFailedObligationsForPlatform ¶

func (r *GatewayRunner) RedeliverFailedObligationsForPlatform(ctx context.Context, platform gateway.Platform, profile *string) int

Replays the failed obligations of one bot identity after its adapter reconnected, the count redelivered

func (*GatewayRunner) RefreshAgentCacheMessageCount ¶

func (r *GatewayRunner) RefreshAgentCacheMessageCount(ctx context.Context, route, target string) error

Rebaselines the cached agent of a route after a completion note wrote its rows

func (*GatewayRunner) RefreshFallbackModel ¶

func (r *GatewayRunner) RefreshFallbackModel(ctx context.Context) []map[string]any

Fallback model chain read again from the config, nil when none is configured

func (*GatewayRunner) RehydrateSessionModelOverride ¶

func (r *GatewayRunner) RehydrateSessionModelOverride(ctx context.Context, sessionKey string)

Restores a persisted model override after a restart unless one is already in memory

func (*GatewayRunner) RequestRestart ¶

func (r *GatewayRunner) RequestRestart(detached, viaService bool) bool

Starts the restart orchestration once, refusing new turns while the requesting turn can still deliver

func (*GatewayRunner) ResetSessionOffLoop ¶

func (r *GatewayRunner) ResetSessionOffLoop(ctx context.Context, sessionKey string, sessionID *string, reason, platform string, oldSessionID, newSessionID *string) error

Plugin on_session_reset hooks off the loop under the profile owning the session key, bounded like finalize

func (*GatewayRunner) ResidentAgentFor ¶

func (r *GatewayRunner) ResidentAgentFor(sessionKey string) any

Live running agent of the session key, else its cached one, nil when neither is held

func (*GatewayRunner) ResolvePolicyAgentRuntime ¶

func (r *GatewayRunner) ResolvePolicyAgentRuntime(ctx context.Context, policy *gateway.LocalSessionPolicy, fallback bool) (string, map[string]any, error)

Model and agent kwargs of a policy's route, its fallback chain walked only when asked

func (*GatewayRunner) ResolveProfileHomeForSource ¶

func (r *GatewayRunner) ResolveProfileHomeForSource(ctx context.Context, source *gateway.SessionSource) (string, error)

Runtime home of a routed source with its missing profile fallback

func (*GatewayRunner) ResolveSessionAgentRuntime ¶

func (r *GatewayRunner) ResolveSessionAgentRuntime(ctx context.Context, source *gateway.SessionSource, sessionKey string, userConfig map[string]any, fallback bool) (string, map[string]any, error)

Model and runtime of a session, its model override first, then channel overrides, then the config

func (*GatewayRunner) ResolveSessionReasoningConfig ¶

func (r *GatewayRunner) ResolveSessionReasoningConfig(ctx context.Context, source *gateway.SessionSource, sessionKey, model string) (map[string]any, error)

Reasoning of a session, its override, a local policy level, else the per model or global config

func (*GatewayRunner) ResolveSessionServiceTier ¶

func (r *GatewayRunner) ResolveSessionServiceTier(ctx context.Context, source *gateway.SessionSource, sessionKey string) (*string, error)

Service tier the session's next turn runs, its fast pick else the routed profile's

func (*GatewayRunner) RestoredSource ¶

func (r *GatewayRunner) RestoredSource(ctx context.Context, entry *gateway.SessionEntry) (*gateway.SessionSource, error)

Origin of a routing entry with its identity pinned again from the persisted receiving bot

func (*GatewayRunner) RoutePlaintextApprovalWhileBusy ¶

func (r *GatewayRunner) RoutePlaintextApprovalWhileBusy(ctx context.Context, event *gateway.MessageEvent, sessionKey string) bool

Routes a bare approval word of a producer delivery to the running turn's blocking approval, true when it was one

func (*GatewayRunner) RunPostAdmissionHook ¶

func (r *GatewayRunner) RunPostAdmissionHook(ctx context.Context, event *gateway.MessageEvent, source *gateway.SessionSource, sessionKey string) (bool, *string, error)

Post admission plugin hook of a producer delivery, whether a plugin consumed it and the reply it gave

func (*GatewayRunner) RunnerConfig ¶

func (r *GatewayRunner) RunnerConfig() *gateway.GatewayConfig

Launch profile's gateway config, the runner config attribute

func (*GatewayRunner) Running ¶

func (r *GatewayRunner) Running() bool

Whether the runner is running

func (*GatewayRunner) RunningAgent ¶

func (r *GatewayRunner) RunningAgent(key string) (any, bool)

Agent the running slot of a key holds and whether it is the pending claim sentinel

func (*GatewayRunner) ScheduleFloodRedelivery ¶

func (r *GatewayRunner) ScheduleFloodRedelivery(ctx context.Context, platform gateway.Platform, profile *string)

Wakes or starts the deadline driven ledger worker of one bot identity after a refused final

func (*GatewayRunner) SessionAuthorities ¶

func (r *GatewayRunner) SessionAuthorities() *gateway.SessionAuthorities

Registry of every profile authority the runtime serves, nil before the runtime initializes

func (*GatewayRunner) SessionAuthority ¶

func (r *GatewayRunner) SessionAuthority() *gateway.SessionAuthority

Launch session authority bound by its initialization, nil before it is

func (*GatewayRunner) SessionControlServer ¶

func (r *GatewayRunner) SessionControlServer() *gateway.GatewayControlServer

Private control listener the hosted room transport registers its attest and producer verbs on

func (*GatewayRunner) SessionDB ¶

func (r *GatewayRunner) SessionDB(ctx context.Context) *state.SessionDB

Store wrapped by the session database of the active scope, nil when it is unavailable

func (*GatewayRunner) SessionEnvScope ¶

func (r *GatewayRunner) SessionEnvScope(ctx context.Context, sc *gateway.SessionContext, body func(env *tools.Env) error) error

Runs body with a session's turn variables bound, for owner verbs that act as that session's caller

func (*GatewayRunner) SessionKeyForSource ¶

func (r *GatewayRunner) SessionKeyForSource(ctx context.Context, source *gateway.SessionSource) (string, error)

Current session key of the source, the store derivation first and the configured fallback after

func (*GatewayRunner) SessionModelOverride ¶

func (r *GatewayRunner) SessionModelOverride(sessionKey string) map[string]any

In memory model override of a session, nil when it holds none

func (*GatewayRunner) SessionModelOverrideFor ¶

func (r *GatewayRunner) SessionModelOverrideFor(ctx context.Context, sessionKey string) map[string]any

Session model override of a key after rehydrating a persisted one, a copy the caller may keep

func (*GatewayRunner) SessionRuntimeDescriptor ¶

func (r *GatewayRunner) SessionRuntimeDescriptor() map[string]any

Session runtime descriptor the drain checks read and stamp

func (*GatewayRunner) SessionStore ¶

func (r *GatewayRunner) SessionStore() *gateway.SessionStore

Store routing sessions and their transcripts

func (*GatewayRunner) SessionTicketStore ¶

func (r *GatewayRunner) SessionTicketStore() *gateway.TicketStore

Private bootstrap ticket store of the session runtime, nil before the runtime starts

func (*GatewayRunner) SetRuntimeDescriptorField ¶

func (r *GatewayRunner) SetRuntimeDescriptorField(key string, value any)

Sets one descriptor field, the write a holder outside this package makes through the runner

func (*GatewayRunner) SetSessionAuthority ¶

func (r *GatewayRunner) SetSessionAuthority(a *gateway.SessionAuthority)

Binds the launch session authority

func (*GatewayRunner) SetSessionReasoningOverride ¶

func (r *GatewayRunner) SetSessionReasoningOverride(sessionKey string, reasoningConfig map[string]any)

Sets the session scoped reasoning override, a nil config clearing it

func (*GatewayRunner) SetSessionServiceTierOverride ¶

func (r *GatewayRunner) SetSessionServiceTierOverride(sessionKey string, serviceTier *string, clear bool)

Sets or clears the session scoped fast tier pick for the session controls

func (*GatewayRunner) SetTeamsPipelineRuntime ¶

func (r *GatewayRunner) SetTeamsPipelineRuntime(runtime any)

Records the bound Teams meeting pipeline runtime

func (*GatewayRunner) SetTeamsPipelineRuntimeError ¶

func (r *GatewayRunner) SetTeamsPipelineRuntimeError(message *string)

Records why the Teams meeting pipeline runtime could not be built

func (*GatewayRunner) ShouldExitCleanly ¶

func (r *GatewayRunner) ShouldExitCleanly() bool

Whether the gateway asked to exit cleanly

func (*GatewayRunner) ShouldExitWithFailure ¶

func (r *GatewayRunner) ShouldExitWithFailure() bool

Whether the gateway asked to exit with a failure status

func (*GatewayRunner) SideBackground ¶

func (r *GatewayRunner) SideBackground(ctx context.Context, env *tools.Env, a *gateway.SessionAuthority, policy *gateway.LocalSessionPolicy, live *gateway.LiveSession, taskID, text string, hold func(agent any)) (string, error)

Background prompt run to completion by a fresh agent on the session's frozen route, closed afterwards

func (*GatewayRunner) SideQuestion ¶

func (r *GatewayRunner) SideQuestion(ctx context.Context, a *gateway.SessionAuthority, ref gateway.SessionRef, policy *gateway.LocalSessionPolicy, text string, parent any, history []map[string]any, onFork func(fork any), shouldStop func() bool) (string, error)

Side question answered over the history snapshot on the session's frozen route

func (*GatewayRunner) Start ¶

func (r *GatewayRunner) Start(ctx context.Context) (bool, error)

Starts the gateway and every configured platform adapter, flushing the runtime status on every path

func (*GatewayRunner) Stop ¶

func (r *GatewayRunner) Stop(ctx context.Context, restart, detachedRestart, serviceRestart bool) error

Stops the gateway and disconnects every adapter, a second call waiting on the first

func (*GatewayRunner) StopRequestedBySignal ¶

func (r *GatewayRunner) StopRequestedBySignal() bool

Whether a signal handler started this stop, read by adapters that tell shutdown exits from crashes

func (*GatewayRunner) StoreVoiceMode ¶

func (r *GatewayRunner) StoreVoiceMode(source *gateway.SessionSource, mode string)

Stores and persists the voice mode of the chat a source arrived on

func (*GatewayRunner) SystemPromptForChannel ¶

func (r *GatewayRunner) SystemPromptForChannel(ctx context.Context, platform gateway.Platform, chatID string, threadID, parentID *string) string

Gateway prompt of a channel, the agent prompt, the personality and the channel override combined

func (*GatewayRunner) TeamsPipelineRuntime ¶

func (r *GatewayRunner) TeamsPipelineRuntime() any

Teams meeting pipeline runtime bound to the Graph webhook ingress, nil before binding

func (*GatewayRunner) ThreadMetadataForSource ¶

func (r *GatewayRunner) ThreadMetadataForSource(source *gateway.SessionSource, replyToMessageID *string) map[string]any

Metadata platforms need for a thread aware reply to the source, nil without thread or route state

func (*GatewayRunner) TransportOwner ¶

func (r *GatewayRunner) TransportOwner(source *gateway.SessionSource) (gateway.PlatformAdapter, string, bool)

Adapter that created source and its profile name, empty for the primary profile

func (*GatewayRunner) UpdatePromptPending ¶

func (r *GatewayRunner) UpdatePromptPending(route string) bool

Whether an /update prompt awaits its reply under the session key, read without building the session state

func (*GatewayRunner) VoiceModeFor ¶

func (r *GatewayRunner) VoiceModeFor(source *gateway.SessionSource) string

Voice mode of the chat a source arrived on, off when none was stored

func (*GatewayRunner) WaitForShutdown ¶

func (r *GatewayRunner) WaitForShutdown(ctx context.Context) error

Blocks until the shutdown event is set

type HookRegistry ¶

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

Discovers, loads and fires the event hooks of one home

func NewHookRegistry ¶

func NewHookRegistry() *HookRegistry

Registry with no hooks loaded

func (*HookRegistry) LoadedHooks ¶

func (h *HookRegistry) LoadedHooks() []map[string]any

Metadata of every loaded hook

type MigrationPlan ¶

type MigrationPlan struct {
	DefaultHome        string
	Profiles           []*ProfileGateway
	MultiplexFlagOn    bool
	LiveServed         []string
	LiveServedRecorded bool
	Manifest           *pyjson.Object
	Interrupted        bool
	Blockers           []string
	Notices            []string
	StandaloneByConfig []string
}

Profiles, their gateway footprints, the flag, the live served record and the preflight verdicts

func BuildMigrationPlan ¶

func BuildMigrationPlan(ctx context.Context) (*MigrationPlan, error)

Profiles and their own gateway footprints with every preflight check run against them

func (*MigrationPlan) AlreadyMultiplexed ¶

func (m *MigrationPlan) AlreadyMultiplexed() bool

Converged by topology, no secondary owning a gateway and the flag on or several profiles served

func (*MigrationPlan) Blocked ¶

func (m *MigrationPlan) Blocked() bool

func (*MigrationPlan) Default ¶

func (m *MigrationPlan) Default() *ProfileGateway

Default profile footprint, nil when the inventory has none

func (*MigrationPlan) ExpectedServedNames ¶

func (m *MigrationPlan) ExpectedServedNames() map[string]bool

Default plus every profile that is not parked

func (*MigrationPlan) Secondaries ¶

func (m *MigrationPlan) Secondaries() []*ProfileGateway

func (*MigrationPlan) StandaloneSecondaries ¶

func (m *MigrationPlan) StandaloneSecondaries() []*ProfileGateway

func (*MigrationPlan) TargetRunAsUser ¶

func (m *MigrationPlan) TargetRunAsUser() string

System unit User the default unit keeps, its own else the first a secondary recorded

func (*MigrationPlan) TargetServiceKind ¶

func (m *MigrationPlan) TargetServiceKind() *ServiceUnit

Service manager the default ends up on, its own else the first one a secondary used

type MultiplexConfigError ¶

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

Invalid profile multiplexer config the operator must fix, propagated to the startup guard instead of retried

func (*MultiplexConfigError) Error ¶

func (e *MultiplexConfigError) Error() string

type PersistentState ¶

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

State with its own lifecycle that turn and boundary resets leave in place

type ProfileGateway ¶

type ProfileGateway struct {
	Name        string
	Home        string
	PID         int
	Services    []ServiceUnit
	RunAsUser   string
	UID         *int
	RuntimeHome string
}

One profile's own gateway footprint, live pid and every installed service unit

func (*ProfileGateway) HasGateway ¶

func (p *ProfileGateway) HasGateway() bool

func (*ProfileGateway) HasSystemUnit ¶

func (p *ProfileGateway) HasSystemUnit() bool

func (*ProfileGateway) IsDefault ¶

func (p *ProfileGateway) IsDefault() bool

func (*ProfileGateway) Service ¶

func (p *ProfileGateway) Service() *ServiceUnit

Unit the default gateway is restarted through, nil when nothing is installed

func (*ProfileGateway) ServiceLabel ¶

func (p *ProfileGateway) ServiceLabel() string

Every installed unit joined with a plus, none when nothing is installed

func (*ProfileGateway) ToDict ¶

func (p *ProfileGateway) ToDict() *pyjson.Object

Manifest record of the footprint with None for every unknown field

type ProfileGatewayConfig ¶

type ProfileGatewayConfig struct {
	Name string
	Cfg  *gateway.GatewayConfig
}

Profile name and its gateway config read the way the multiplexer reads it

type ProfileHookRegistries ¶

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

Hook registry per served profile home, picked at emit time from the active home

func NewProfileHookRegistries ¶

func NewProfileHookRegistries() *ProfileHookRegistries

Registries with no home loaded yet

func (*ProfileHookRegistries) LoadedHooks ¶

func (p *ProfileHookRegistries) LoadedHooks(ctx context.Context) ([]map[string]any, error)

Metadata of every hook loaded for the active home

type ProfileOwnershipRetained ¶

type ProfileOwnershipRetained struct{ Msg string }

A retired attempt's writer is still live, so the profile keeps its reservation and authority

func (*ProfileOwnershipRetained) Error ¶

func (e *ProfileOwnershipRetained) Error() string

func (*ProfileOwnershipRetained) PyTypeName ¶

func (e *ProfileOwnershipRetained) PyTypeName() string

Python exception class of the retained ownership refusal

type ServiceUnit ¶

type ServiceUnit struct {
	Kind   string
	System bool
}

Service manager kind and scope of one installed gateway unit

type SessionFieldView ¶

type SessionFieldView[T any] struct {
	// contains filtered or unexported fields
}

Live dict shaped view of one SessionState field across the sessions of a runner

func (SessionFieldView[T]) Clear ¶

func (v SessionFieldView[T]) Clear()

Resets the field on every session

func (SessionFieldView[T]) Contains ¶

func (v SessionFieldView[T]) Contains(key string) bool

Whether the field of key is present

func (SessionFieldView[T]) Delete ¶

func (v SessionFieldView[T]) Delete(key string) bool

Resets the field of key to its default in one hold of the lock, false when it was not present

func (SessionFieldView[T]) Get ¶

func (v SessionFieldView[T]) Get(key string) (T, bool)

Field value of key and whether it is present

func (SessionFieldView[T]) Items ¶

func (v SessionFieldView[T]) Items() map[string]T

Present fields as a plain map, each value read with its presence under one hold

func (SessionFieldView[T]) Keys ¶

func (v SessionFieldView[T]) Keys() []string

Session keys whose field is present, in session map order of a snapshot

func (SessionFieldView[T]) Len ¶

func (v SessionFieldView[T]) Len() int

Count of sessions whose field is present

func (SessionFieldView[T]) Replace ¶

func (v SessionFieldView[T]) Replace(mapping map[string]T)

Assigns the view from a plain map, clearing every session first

func (SessionFieldView[T]) Set ¶

func (v SessionFieldView[T]) Set(key string, value T)

Stores value on the session state of key under its lock, creating that state when absent

func (SessionFieldView[T]) String ¶

func (v SessionFieldView[T]) String() string

Debug text naming the viewed scope field with its present entries

type SessionSocket ¶

type SessionSocket interface {
	SendText(ctx context.Context, text string) error
	Close(code int) error
	Accept(ctx context.Context, subprotocol *string) error
	ReceiveText(ctx context.Context) (string, error)
	Peer() (host string, port int, known bool)
	RawConn() net.Conn
	SessionAuthority() *gateway.SessionAuthority
}

Socket of one admitted session as the session handler drives it

type SessionSocketClosed ¶

type SessionSocketClosed struct {
	Code   int
	Reason string
}

Peer close a session socket read reports, with its close code and reason

func (*SessionSocketClosed) Error ¶

func (e *SessionSocketClosed) Error() string

type SessionState ¶

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

All per session gateway state grouped by lifecycle scope, every scope field read and written under mu

func (*SessionState) ReasoningOverride ¶

func (s *SessionState) ReasoningOverride() map[string]any

Reasoning override of the state as session info reads it, read under the state lock

func (*SessionState) ServiceTierOverride ¶

func (s *SessionState) ServiceTierOverride() (*string, bool)

The /fast override of the state and whether one is set, read together under the state lock

type SessionTurnLeaseRegistry ¶

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

Lease per resolved session id serializing the load history, run and flush region

func NewSessionTurnLeaseRegistry ¶

func NewSessionTurnLeaseRegistry(maxEntries int) *SessionTurnLeaseRegistry

Registry capped at maxEntries leases, never fewer than one

func (*SessionTurnLeaseRegistry) Acquire ¶

func (r *SessionTurnLeaseRegistry) Acquire(ctx context.Context, sessionID, ownerKey string, generation int, timeout *float64) (*TurnLeaseToken, error)

Acquires the lease of sessionID waiting while held, nil for an empty id, a timeout error when the budget expires

func (*SessionTurnLeaseRegistry) Rebind ¶

func (r *SessionTurnLeaseRegistry) Rebind(token *TurnLeaseToken, newSessionID string) bool

Aliases a held lease onto a rotated session id, false for a non holder or a live target

func (*SessionTurnLeaseRegistry) Release ¶

func (r *SessionTurnLeaseRegistry) Release(token *TurnLeaseToken) bool

Releases the lease of token, true only when this exact token was the current holder

type SlashCommandReply ¶

type SlashCommandReply struct {
	Text   string
	Data   map[string]any
	Format string
}

Canonical reply of a shared slash executor, its text and structured data

type StartGatewayOptions ¶

type StartGatewayOptions struct {
	Config    *gateway.GatewayConfig
	Replace   bool
	Force     bool
	Verbosity *int
	IdleExit  bool
}

Arguments of start_gateway, a nil config loading the runner config and a nil verbosity meaning quiet

type TurnContext ¶

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

Per turn context shared between the agent run and its TurnRunner, the message the one rebindable field

type TurnLeaseTimeoutError ¶

type TurnLeaseTimeoutError struct {
	SessionID   string
	OwnerKey    string
	Generation  int
	WaitSeconds float64
}

Lease held for the whole wait budget, so the caller must not enter the turn region

func (*TurnLeaseTimeoutError) Error ¶

func (e *TurnLeaseTimeoutError) Error() string

Message naming the session, routing key, generation and the rounded wait

type TurnLeaseToken ¶

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

Held lease handle whose released flag makes release idempotent

func (*TurnLeaseToken) String ¶

func (t *TurnLeaseToken) String() string

Debug text of the handle with its session, routing key, generation and released flag

type TurnLeaseTokenView ¶

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

Legacy view of held turn lease tokens keyed by session key and generation

func (TurnLeaseTokenView) Clear ¶

func (v TurnLeaseTokenView) Clear()

Drops every held token

func (TurnLeaseTokenView) Contains ¶

func (v TurnLeaseTokenView) Contains(key leaseTokenKey) bool

Whether a token is held for key

func (TurnLeaseTokenView) Delete ¶

func (v TurnLeaseTokenView) Delete(key leaseTokenKey) bool

Drops the token of key in one hold of the state lock, false when none was held

func (TurnLeaseTokenView) Get ¶

func (v TurnLeaseTokenView) Get(key leaseTokenKey) (*TurnLeaseToken, bool)

Token held for key and whether one is held, both read under one hold of the state lock

func (TurnLeaseTokenView) Items ¶

func (v TurnLeaseTokenView) Items() map[leaseTokenKey]*TurnLeaseToken

Held tokens as a plain map keyed by session and generation, each session read under its own lock

func (TurnLeaseTokenView) Keys ¶

func (v TurnLeaseTokenView) Keys() []leaseTokenKey

Every held session key and generation pair

func (TurnLeaseTokenView) Len ¶

func (v TurnLeaseTokenView) Len() int

Count of held tokens

func (TurnLeaseTokenView) Replace ¶

func (v TurnLeaseTokenView) Replace(mapping map[leaseTokenKey]*TurnLeaseToken)

Assigns the view from a plain map, clearing every held token first

func (TurnLeaseTokenView) Set ¶

func (v TurnLeaseTokenView) Set(key leaseTokenKey, token *TurnLeaseToken)

Records token for key on the session state under its lock, creating that state when absent

type TurnRunner ¶

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

Per turn collaborator carrying the progress, status, approval and clarify callbacks of one agent run

type TurnState ¶

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

State scoped to one running gateway turn, lease tokens owned by the turn lease release

type UnauthorizedOwnerNotifier ¶

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

Remembers which unrecognized senders the owner was already told about, bounded and least recent first

func NewUnauthorizedOwnerNotifier ¶

func NewUnauthorizedOwnerNotifier(maxSeen int) *UnauthorizedOwnerNotifier

Notifier remembering at most maxSeen senders, at least one

func (*UnauthorizedOwnerNotifier) FirstTime ¶

func (n *UnauthorizedOwnerNotifier) FirstTime(platformName, userID string) bool

True on the first drop of a platform user, evicting the oldest remembered sender past the bound

func (*UnauthorizedOwnerNotifier) Notify ¶

Posts the hint to the home channel of the source platform unless that channel is the sender's DM

Source Files ¶

Jump to

Keyboard shortcuts

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