gatewayapi

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 45 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 (
	// Host the adapter binds when neither config nor env names one
	DefaultHost = "127.0.0.1"
	// Port the adapter binds when neither config nor env names one
	DefaultPort = 8642

	// English failure label a gateway auth error sniffer keys on
	ProviderAuthFailedLabel = "Provider authentication failed"
	// English failure label a gateway rate limit sniffer keys on
	ProviderRateLimitedLabel = "Provider rate-limited"
)

Variables

This section is empty.

Functions

func CheckAPIServerRequirements

func CheckAPIServerRequirements() bool

Whether the API server can run, the HTTP server being built in

func ListenAddress

func ListenAddress(extra map[string]any) (any, int)

Host and port the adapter binds, config winning over the env fallbacks

Types

type APIServerAdapter

type APIServerAdapter struct {
	*gateway.BasePlatformAdapter
	// contains filtered or unexported fields
}

APIServerAdapter serves OpenAI format requests through real agents on an HTTP listener

func NewAPIServerAdapter

func NewAPIServerAdapter(ctx context.Context, cfg *gateway.PlatformConfig) (*APIServerAdapter, error)

Adapter for an API server platform config

func (*APIServerAdapter) ActiveAgentWorkCount

func (a *APIServerAdapter) ActiveAgentWorkCount() int

Pending admissions plus in flight turns plus live structured run tasks

func (*APIServerAdapter) BindRunAdmissionAlias

func (a *APIServerAdapter) BindRunAdmissionAlias(key, admissionID string)

Binds a streaming run id to the admission whose shared approval prompt it answers

func (*APIServerAdapter) ConfiguredModelRoute

func (a *APIServerAdapter) ConfiguredModelRoute(alias any) map[string]any

Configured route of a model alias with its credentials, nil when the alias is unknown

func (*APIServerAdapter) Connect

func (a *APIServerAdapter) Connect(ctx context.Context, isReconnect bool) (bool, error)

Starts the HTTP listener, a rejected key or a held port being a non retryable fatal error

func (*APIServerAdapter) Disconnect

func (a *APIServerAdapter) Disconnect(ctx context.Context) error

Stops the listener and releases every owned store, memory manager and session handle

func (*APIServerAdapter) EnsureSessionDB

func (a *APIServerAdapter) EnsureSessionDB(ctx context.Context) (*state.SessionDB, error)

Session store of the active profile home, the stateless adapter surface delegation deliveries write through

func (*APIServerAdapter) GetChatInfo

func (a *APIServerAdapter) GetChatInfo(ctx context.Context, chatID string) (map[string]any, error)

Basic info about the API server

func (*APIServerAdapter) InterruptActiveRuns

func (a *APIServerAdapter) InterruptActiveRuns(reason string) int

Interrupts every adapter owned agent during shutdown and returns how many were interrupted

func (*APIServerAdapter) MarkShutdownRequested

func (a *APIServerAdapter) MarkShutdownRequested() int

Persists the gateway drain start on every nonterminal API run

func (*APIServerAdapter) PrepareTurnRuntime

func (a *APIServerAdapter) PrepareTurnRuntime(ctx context.Context, model string, runtimeKwargs map[string]any, settings any) (string, error)

Model a gateway turn runs for an API admission, the settings route selecting over the resolved runtime kwargs

func (*APIServerAdapter) ReleaseRunAdmissionAlias

func (a *APIServerAdapter) ReleaseRunAdmissionAlias(key, admissionID string)

Drops a streaming run id's binding while it still names this admission

func (*APIServerAdapter) RunAdmission

func (a *APIServerAdapter) RunAdmission(ctx context.Context, runID string) (*gateway.SessionAuthority, *pyjson.Object, error)

Authority and ledger row of a run's canonical admission, the ownership check's view of the adapter

func (*APIServerAdapter) RunInternalSessionTurn

func (a *APIServerAdapter) RunInternalSessionTurn(ctx context.Context, sessionID, text, profile, notificationCategory string) error

Runs one background wake turn against a raw session id in process

func (*APIServerAdapter) SelfPostTarget

func (a *APIServerAdapter) SelfPostTarget() (string, int, string, string)

Bind address, key and model name of this listener for a wake self post

func (*APIServerAdapter) Send

func (a *APIServerAdapter) Send(ctx context.Context, chatID, content, replyTo string, metadata map[string]any) (gateway.SendResult, error)

Delivery is the HTTP request and response cycle itself, never send

func (*APIServerAdapter) SendClarify

func (a *APIServerAdapter) SendClarify(ctx context.Context, chatID, question string, choices []string, clarifyID, sessionKey string, metadata map[string]any) (gateway.SendResult, error)

Clarify question routed to the authority run that asked it

func (*APIServerAdapter) TurnRuntimeMetadata

func (a *APIServerAdapter) TurnRuntimeMetadata(ag *agent.AIAgent, settings any, confirmedRuntimeLock bool) (*pyjson.Object, error)

Served runtime of a finished gateway turn under a confirmed model lock, an error when it differs from the lock

type APIServerMemorySessions

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

APIServerMemorySessions keeps one initialised memory manager per profile home and session across requests

func NewAPIServerMemorySessions

func NewAPIServerMemorySessions(maxSize *int, idleTTLSecs *float64) *APIServerMemorySessions

Registry with optional fixed bounds, the gateway agent cache bounds resolved lazily otherwise

func (*APIServerMemorySessions) Checkin

func (m *APIServerMemorySessions) Checkin(ctx context.Context, a *agent.AIAgent)

Parks the agent's manager under its final session, shutting down displaced or idle managers

func (*APIServerMemorySessions) Checkout

func (m *APIServerMemorySessions) Checkout(ctx context.Context, sessionID string) *memory.MemoryManager

Manager an earlier request on the session checked in, nil when none or parked past the retry horizon

func (*APIServerMemorySessions) CloseAll

func (m *APIServerMemorySessions) CloseAll(ctx context.Context)

Drains and shuts down every parked manager inline at adapter shutdown

func (*APIServerMemorySessions) Parked

func (m *APIServerMemorySessions) Parked() map[[2]string]*memory.MemoryManager

Parked managers by key, for tests

type HTTPEventAdapter

type HTTPEventAdapter interface {
	VerifyHTTPEventRequest(ctx context.Context, authHeader string) (bool, string, error)
	DispatchHTTPEvent(ctx context.Context, payload *pyjson.Object) (any, error)
}

Platform adapter answering HTTP events with its own verifier and dispatcher

type RoomGrantReauthorizationRequired

type RoomGrantReauthorizationRequired struct{ Msg string }

RoomGrantReauthorizationRequired is a validly signed room grant that was revoked or superseded

func (*RoomGrantReauthorizationRequired) Error

func (*RoomGrantReauthorizationRequired) PyTypeName

func (e *RoomGrantReauthorizationRequired) PyTypeName() string

Jump to

Keyboard shortcuts

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