Documentation
¶
Overview ¶
Package httpx hosts the HTTP adapter constructors for the agentflow root facade (checkpoint, retention, studio, webhook/human-gate, async jobs, production composition, and the observability dashboard) plus the scenario wiring helpers whose signatures reference root-facade types such as agentflow.Framework and agentflow.Option. Everything here may import the root package; constructors that do not need it live in pkg/adapters.
Index ¶
- func KnowledgeWiringOptions(scenario core.Scenario, registry KnowledgeRegistry) ([]agentflow.Option, error)
- func MCPWiringOptions(ctx context.Context, scenario core.Scenario, registry MCPRegistry) ([]agentflow.Option, error)
- func NewAsyncRunHTTPHandler(config AsyncRunHTTPHandlerConfig) (http.Handler, error)
- func NewCheckpointHTTPHandler(config CheckpointHTTPHandlerConfig) (http.Handler, error)
- func NewHumanHTTPHandler(config HumanHTTPHandlerConfig) http.Handler
- func NewObservabilityHTTPHandler(config ObservabilityHTTPHandlerConfig) (http.Handler, error)
- func NewProductionHTTPHandler(config ProductionHTTPHandlerConfig) (http.Handler, error)
- func NewRetentionHTTPHandler(config RetentionHTTPHandlerConfig) (http.Handler, error)
- func NewStudioHTTPHandler(config StudioHTTPHandlerConfig) (http.Handler, error)
- func NewWebhookHTTPHandler(config WebhookHTTPHandlerConfig) (http.Handler, error)
- func WireMCPTools(ctx context.Context, scenario core.Scenario, registry MCPRegistry) ([]agentflow.Option, error)
- type AsyncRunHTTPHandlerConfig
- type CheckpointHTTPHandlerConfig
- type HumanHTTPHandlerConfig
- type KnowledgeRegistry
- type MCPRegistry
- type ObservabilityHTTPHandlerConfig
- type ProductionHTTPHandlerConfig
- type RetentionHTTPHandlerConfig
- type StudioHTTPHandlerConfig
- type WebhookHTTPHandlerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KnowledgeWiringOptions ¶
func KnowledgeWiringOptions(scenario core.Scenario, registry KnowledgeRegistry) ([]agentflow.Option, error)
KnowledgeWiringOptions returns Framework options that bind scenario knowledge collections.
func MCPWiringOptions ¶
func MCPWiringOptions(ctx context.Context, scenario core.Scenario, registry MCPRegistry) ([]agentflow.Option, error)
MCPWiringOptions returns Framework options that wire mcp.tool declarations to MCP servers.
func NewAsyncRunHTTPHandler ¶
func NewAsyncRunHTTPHandler(config AsyncRunHTTPHandlerConfig) (http.Handler, error)
func NewCheckpointHTTPHandler ¶
func NewCheckpointHTTPHandler(config CheckpointHTTPHandlerConfig) (http.Handler, error)
NewCheckpointHTTPHandler serves production checkpoint routes:
- GET /v1/runs/{run_id}/steps
- POST /v1/runs/{run_id}/resume-from-step
- GET /v1/runs/{run_id}/checkpoints
- GET /v1/runs/{run_id}/checkpoints/{version}
- POST /v1/runs/{run_id}/resume-from-checkpoint
- POST /v1/runs/{run_id}/fork
Every route requires CheckpointHTTPHandlerConfig.Policy (or an explicit InsecureAllowNoAuth opt-out).
func NewHumanHTTPHandler ¶
func NewHumanHTTPHandler(config HumanHTTPHandlerConfig) http.Handler
NewHumanHTTPHandler serves human gate resume requests. When the request sets continue=true, the handler calls ResumeAndContinue instead of Resume. It panics when config.Framework is nil: a nil framework would panic later at request time inside the adapter, so failing fast at construction surfaces the wiring mistake where it is made.
func NewObservabilityHTTPHandler ¶
func NewObservabilityHTTPHandler(config ObservabilityHTTPHandlerConfig) (http.Handler, error)
func NewProductionHTTPHandler ¶
func NewProductionHTTPHandler(config ProductionHTTPHandlerConfig) (http.Handler, error)
func NewRetentionHTTPHandler ¶
func NewRetentionHTTPHandler(config RetentionHTTPHandlerConfig) (http.Handler, error)
NewRetentionHTTPHandler serves admin retention routes:
- POST /v1/admin/retention/purge-runs
- POST /v1/admin/retention/purge-expired
- POST /v1/admin/retention/purge-policy
- POST /v1/admin/retention/purge-blobs
func NewStudioHTTPHandler ¶
func NewStudioHTTPHandler(config StudioHTTPHandlerConfig) (http.Handler, error)
NewStudioHTTPHandler serves production Studio routes:
- POST /v1/studio/validate
- POST /v1/studio/codegen
- POST /v1/studio/yaml
- POST /v1/studio/import-yaml
- POST /v1/studio/run
- POST /v1/studio/save (when StudioSavePath is set)
- POST /v1/studio/compose
- GET /v1/studio/parts
The run/save/compose routes require StudioHTTPHandlerConfig.Policy (or an explicit InsecureAllowNoAuth opt-out).
func NewWebhookHTTPHandler ¶
func NewWebhookHTTPHandler(config WebhookHTTPHandlerConfig) (http.Handler, error)
NewWebhookHTTPHandler serves POST / requests that accept IncomingEvent JSON payloads.
func WireMCPTools ¶
func WireMCPTools(ctx context.Context, scenario core.Scenario, registry MCPRegistry) ([]agentflow.Option, error)
WireMCPTools binds scenario MCP servers to mcp.tool executors.
Types ¶
type AsyncRunHTTPHandlerConfig ¶
type AsyncRunHTTPHandlerConfig struct {
Queue asyncpkg.Queue
RunState runstate.Repository
Policy security.Policy
Audit audit.Sink
IDGenerator func() string
Now func() time.Time
MaxBodyBytes int64
// InsecureAllowNoAuth explicitly opens the async endpoints when Policy is
// nil. It is intended only for loopback development and tests.
InsecureAllowNoAuth bool
}
type CheckpointHTTPHandlerConfig ¶
type CheckpointHTTPHandlerConfig struct {
Framework *agentflow.Framework
MaxBodyBytes int64
// Policy authorizes requests: reads as run.read, writes (resume-from-step,
// resume-from-checkpoint, fork) as hitl.resume / run.submit, with the
// caller's tenant bound to the resource. When Policy is nil every endpoint
// defaults to 403 auth_required because reads expose run data and writes
// can mint fresh execution.
Policy security.Policy
// Audit receives policy-denied records when configured.
Audit audit.Sink
// InsecureAllowNoAuth disables the default-deny protection when Policy is
// nil. Only set it behind an authenticating
// reverse proxy or in tests.
InsecureAllowNoAuth bool
}
type HumanHTTPHandlerConfig ¶
type KnowledgeRegistry ¶
type KnowledgeRegistry struct {
Embedder llm.Embedder
Store knowledge.VectorStore
Reranker knowledge.Reranker
}
KnowledgeRegistry wires scenario knowledge collections to retriever executors.
type MCPRegistry ¶
MCPRegistry supplies MCP clients for scenario server declarations.
type ObservabilityHTTPHandlerConfig ¶
type ObservabilityHTTPHandlerConfig struct {
Store observability.EventStore
Hub *observability.EventHub
AuthMiddleware func(http.Handler) http.Handler
// Framework enables Studio graph export, step listing, and resume-from-step.
Framework *agentflow.Framework
// StudioSavePath enables POST /observability/api/studio/save for the configured scenario file.
StudioSavePath string
// TraceExploreURL is an optional trace UI link template, e.g. https://jaeger.example.com/trace/{trace_id}.
TraceExploreURL string
// InsecureAllowNoAuth disables the default-deny guard on the dashboard
// and every API endpoint when AuthMiddleware is nil. Only set it behind
// an authenticating reverse proxy or in local tests and demos.
InsecureAllowNoAuth bool
// Logger receives the one-time construction warning emitted when
// AuthMiddleware is nil; nil discards it.
Logger log.Logger
}
type ProductionHTTPHandlerConfig ¶
type ProductionHTTPHandlerConfig struct {
Queue asyncpkg.Queue
Policy security.Policy
Audit audit.Sink
AuthMiddleware func(http.Handler) http.Handler
// MetricsHandler is mounted outside AuthMiddleware for infrastructure
// scrapers. Bind it to an internal listener/network or wrap it before use.
MetricsHandler http.Handler
IDGenerator func() string
Now func() time.Time
MaxBodyBytes int64
Version string
// Framework enables sync /v1/events and /v1/hitl/resume when set.
Framework *agentflow.Framework
// StudioSavePath enables POST /v1/studio/save for the configured scenario file.
StudioSavePath string
// VerifyWebhookSignature validates the raw /v1/events request body before
// event decoding, in addition to the shared AuthMiddleware.
VerifyWebhookSignature func(r *http.Request, body []byte) error
// InsecureAllowNoAuth explicitly opens production routes without
// AuthMiddleware and Policy. Only use it for loopback development/tests.
InsecureAllowNoAuth bool
}
type RetentionHTTPHandlerConfig ¶
type RetentionHTTPHandlerConfig struct {
Framework *agentflow.Framework
Policy security.Policy
Audit audit.Sink
MaxBodyBytes int64
// InsecureAllowNoAuth disables the default-deny guard on the purge
// endpoints when Policy is nil. Only set it behind an authenticating
// reverse proxy or in tests.
InsecureAllowNoAuth bool
}
type StudioHTTPHandlerConfig ¶
type StudioHTTPHandlerConfig struct {
Framework *agentflow.Framework
StudioSavePath string
MaxBodyBytes int64
// Policy authorizes the mutating endpoints: studio run as run.submit and
// studio save as admin.configure. When Policy is nil those endpoints
// default-deny with 403 auth_required — studio run executes agents and
// studio save rewrites the scenario file, so mounting them open was a
// privilege-escalation hole. The pure-transform endpoints
// (validate/codegen/yaml/import-yaml) stay open.
Policy security.Policy
// Audit receives policy-denied records when configured.
Audit audit.Sink
// InsecureAllowNoAuth disables the default-deny protection on the
// mutating endpoints when Policy is nil. Only set it behind an
// authenticating reverse proxy or in tests.
InsecureAllowNoAuth bool
}
type WebhookHTTPHandlerConfig ¶
type WebhookHTTPHandlerConfig struct {
Framework *agentflow.Framework
MaxBodyBytes int64
// VerifySignature, when set, validates the raw webhook body before the
// event is decoded (e.g. an HMAC signature from the event source); a
// non-nil error rejects the request with 401. Webhooks are
// unauthenticated ingress — production deployments should set this or
// wrap the handler in an authenticating middleware.
VerifySignature func(r *http.Request, body []byte) error
}