Documentation
¶
Index ¶
- func IsDelivery(err error) bool
- func ResponsesBody(resp chat.Response) (any, error)
- type Catalog
- type Handler
- type Option
- func WithAssetResolver(resolver chat.AssetResolver) Option
- func WithErrorLog(logf func(context.Context, error)) Option
- func WithLimits(limits chat.Limits) Option
- func WithMCP() Option
- func WithSpeaker(speaker audio.Speaker) Option
- func WithStore(store Store) Option
- func WithStoreDefault(retain bool) Option
- func WithTranscriber(transcriber audio.Transcriber) Option
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDelivery ¶
IsDelivery reports whether err is or wraps ErrDelivery.
Types ¶
type Catalog ¶
type Catalog interface {
List(context.Context) (map[string]chat.Info, error)
Load(context.Context, string) (chat.Agent, chat.Info, error)
}
Catalog is the application integration for agent discovery and loading. Both methods receive the authenticated request context.
List returns caller-visible targets and their Info without constructing agents. Map keys are the targets accepted by Load. llmux reads the returned map and never mutates it or its values. List failures are operational errors and are never exposed to clients.
Load obtains one executable agent and independently checks execution authorization. It returns current Info for capability validation; execution never calls List merely to obtain capabilities. Listing visibility never replaces Load authorization.
A nil Catalog is allowed: List projects an empty catalog, and Load fails with a clear operational error. llmux never implements Load by scanning List and never caches catalogs across authenticated callers.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler exposes configured agents through standard HTTP endpoints. It does not create a listener and is safe for concurrent requests.
type Option ¶
type Option func(*Handler)
Option configures Handler. Options are applied once by New.
func WithAssetResolver ¶
func WithAssetResolver(resolver chat.AssetResolver) Option
WithAssetResolver enables resolution of application-owned media references.
func WithErrorLog ¶
WithErrorLog lets an application observe operational failures without exposing raw backend or prompt data to clients. The hook is not called for ordinary client validation errors.
func WithLimits ¶
WithLimits sets request, media, and output size limits for the handler.
func WithMCP ¶
func WithMCP() Option
WithMCP enables the optional MCP endpoint at the exact path /mcp (over stateless Streamable HTTP). It takes no arguments: the exposed tools come from Catalog.List, filtered to entries whose Info.Tool is nonempty. A nil catalog yields an empty tool catalog, never implicit enumeration.
The transport is constructed after all options are applied, so option ordering does not matter.
func WithSpeaker ¶
WithSpeaker enables POST /audio/speech.
func WithStore ¶
WithStore enables continuation loading and response lifecycle acceptance. Merely supplying a Store does not change retention defaults; see WithStoreDefault. Applications without persistence omit this option.
func WithStoreDefault ¶
WithStoreDefault sets the content-retention policy when the request omits store. The zero option default is false (current behavior). Explicit store:true or store:false always overrides this default. Effective retention (Retain) requires a configured Store.
func WithTranscriber ¶
func WithTranscriber(transcriber audio.Transcriber) Option
WithTranscriber enables POST /audio/transcriptions.
type Store ¶
type Store interface {
Load(context.Context, string) ([]chat.Item, error)
Accept(context.Context, *chat.TurnRequest) (chat.Acceptance, error)
}
Store is the optional application integration for continuation and response lifecycle. Configure it with WithStore.
Load authorizes access and returns the ordered history that should precede the current turn for previous_response_id. A Store that does not support continuation may return an appropriate error.
Accept reserves new work, rejects conflicts, or returns an existing response for replay. Acceptance.Finish remains the per-request completion callback: it captures reserved application state and persists the terminal result. Implementations may share underlying persistence; llmux does not require coordination maps between Load and Accept.
Ordering for a retained request:
- Validate request, resolve store policy, load continuation via Load.
- Accept — reserve identity, reject conflicts, or return Replay. Capture request-local resources on Acceptance.Finish.
- Agent.Run (skipped on Replay). RunTimeout > 0 detaches client cancel and bounds execution; llmux owns that context and cancels it on exit.
- Finish exactly once for accepted executions, with the execution context. That context may already be cancelled. Finish owns any detached, bounded cleanup work (for example context.WithTimeout(context.WithoutCancel(ctx), timeout)). Not called for Accept errors, completed Replays, or when Finish is nil. Treat the Response as read-only: nested data is shared with the response encoded after Finish returns. Call Response.Clone() before retaining or modifying it.
- Advertise success only after Finish succeeds.
Activity: set Acceptance.Activity and emit Activity(name, json). Keep application-specific fields outside standard envelopes.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
|
|
|
lifecycle
command
|
|
|
lifecycle-full
command
|
|
|
mcp
command
|
|
|
multimodal
command
|
|
|
internal
|
|