Documentation
¶
Overview ¶
Package agentflow provides a small public facade for embedding the scenario-driven agent runtime in other Go projects.
Applications that need low-level extension points can import pkg/core, pkg/llm, pkg/memory, and pkg/runstate directly. Applications that only need to load a YAML scenario and run it should use this package.
Index ¶
- Constants
- func BuildProductionHTTPHandler(cfg ProductionConfig, fw *Framework, queue asyncpkg.Queue) (http.Handler, error)
- func DemoWorkDir(scenarioFile string) (string, error)
- func IsLoopbackAddr(addr string) bool
- func LoadScenario(data []byte) (core.Scenario, error)
- func LoadScenarioFile(path string) (core.Scenario, error)
- func NewAPIKeyMiddleware(config APIKeyMiddlewareConfig) (func(http.Handler) http.Handler, error)
- func NewAnthropicGateway(profiles []llm.Profile, client *http.Client) llm.Gateway
- func NewAsyncRunHTTPHandler(config AsyncRunHTTPHandlerConfig) (http.Handler, error)
- func NewAuthorizationMiddleware(config AuthorizationMiddlewareConfig) (func(http.Handler) http.Handler, error)
- func NewEventFanoutSink(sinks ...core.EventSink) core.EventSink
- func NewEventHub() *observability.EventHub
- func NewEventStoreSink(store observability.EventStore, publishers ...observability.EventPublisher) core.EventSink
- func NewFileAuditSink(path string) (audit.Sink, error)
- func NewFileBlobStore(dir string) (runstate.BlobStore, error)
- func NewFileKnowledgeLoader(config FileKnowledgeLoaderConfig) (knowledge.Loader, error)
- func NewFileMemoryRepository(dir string) (memory.Repository, error)
- func NewFileRunStateRepository(dir string) (runstate.Repository, error)
- func NewFilesystemToolExecutor(config FilesystemToolConfig) (core.ToolExecutor, error)
- func NewFrameworkJobHandler(config FrameworkRunJobHandlerConfig) (asyncpkg.Handler, error)
- func NewFrameworkRunJobHandler(config FrameworkRunJobHandlerConfig) (asyncpkg.Handler, error)
- func NewGitToolExecutor(config GitToolConfig) (core.ToolExecutor, error)
- func NewHTTPKnowledgeLoader(config HTTPKnowledgeLoaderConfig) (knowledge.Loader, error)
- func NewHTTPToolExecutor(config HTTPToolConfig) (core.ToolExecutor, error)
- func NewHumanHTTPHandler(config HumanHTTPHandlerConfig) http.Handler
- func NewInMemoryAuditSink(limit int) audit.Sink
- func NewInMemoryBlobStore() runstate.BlobStore
- func NewInMemoryEventStore() observability.EventStore
- func NewInMemoryJobQueue() asyncpkg.Queue
- func NewInMemoryRunStateRepository() runstate.Repository
- func NewJWTAuthenticator(config JWTAuthenticatorConfig) (security.BearerAuthenticator, error)
- func NewJWTMiddleware(config JWTMiddlewareConfig) (func(http.Handler) http.Handler, error)
- func NewKnowledgeIndexer(config KnowledgeIndexerConfig) (*knowledge.Indexer, error)
- func NewLLMReranker(gateway llm.Gateway, profile string) knowledge.Reranker
- func NewLLMRouter(routes map[string]llm.Gateway) llm.Gateway
- func NewLocalGateway(profiles []llm.Profile, client *http.Client) llm.Gateway
- func NewMCPHTTPClient(endpoint string, client *http.Client) (mcp.Client, error)
- func NewMCPToolExecutor(client mcp.Client, tool string) (core.ToolExecutor, error)
- func NewMockLLMGateway(scenario core.Scenario) llm.Gateway
- func NewNoopAuditSink() audit.Sink
- func NewOIDCJWTAuthenticator(config OIDCJWTAuthenticatorConfig) (security.BearerAuthenticator, error)
- func NewObservabilityEventSink(recorder observability.Recorder, tracer observability.Tracer, ...) core.EventSink
- func NewObservabilityHTTPHandler(config ObservabilityHTTPHandlerConfig) (http.Handler, error)
- func NewOpenAICompatibleEmbedder(profiles []llm.Profile, client *http.Client) llm.Embedder
- func NewOpenAICompatibleGateway(profiles []llm.Profile, client *http.Client) llm.Gateway
- func NewPostgresEventStore(ctx context.Context, config PostgresEventStoreConfig) (observability.EventStore, error)
- func NewPostgresJobQueue(db *sql.DB, tableName ...string) (asyncpkg.Queue, error)
- func NewPostgresRunStateRepository(db *sql.DB, tableName ...string) (runstate.Repository, error)
- func NewPostgresVectorStore(config PostgresVectorStoreConfig) (knowledge.VectorStore, error)
- func NewProductionHTTPHandler(config ProductionHTTPHandlerConfig) (http.Handler, error)
- func NewProductionQueue(cfg ProductionConfig, db **sql.DB) (asyncpkg.Queue, error)
- func NewProductionWorker(cfg ProductionConfig, queue asyncpkg.Queue, fw *Framework) (*asyncpkg.Worker, error)
- func NewRedisLocker(config RedisLockerConfig) (coordination.Locker, error)
- func NewRedisRunStateRepository(config RedisRunStateRepositoryConfig) (runstate.Repository, error)
- func NewRetrieverTool(config RetrieverToolConfig) (core.ToolExecutor, error)
- func NewS3BlobStore(config S3BlobStoreConfig) (runstate.BlobStore, error)
- func NewSQLToolExecutor(config SQLToolConfig) (core.ToolExecutor, error)
- func NewScoreReranker() knowledge.Reranker
- func NewSlogAuditSink(logger *stdslog.Logger) audit.Sink
- func NewSlogEventSink(logger *stdslog.Logger) core.EventSink
- func NewStaticAPIKeyAuthenticator(keys map[string]identity.Principal) (security.APIKeyAuthenticator, error)
- func NewTicketToolExecutor(config TicketToolConfig) (core.ToolExecutor, error)
- func NewVerboseSlogEventSink(logger *stdslog.Logger) core.EventSink
- func NewWebhookHTTPHandler(config WebhookHTTPHandlerConfig) (http.Handler, error)
- func PrometheusMetricsHandler(recorder *PrometheusRecorder) http.Handler
- func ScenarioJSONSchema() []byte
- func ValidateScenario(scenario core.Scenario) error
- func ValidateWiring(scenario core.Scenario, opts ...Option) error
- func ValidateWiringWithOptions(scenario core.Scenario, wiring WiringOptions, opts ...Option) error
- type APIKeyMiddlewareConfig
- type AsyncRunHTTPHandlerConfig
- type AuthorizationMiddlewareConfig
- type DemoConfig
- type DevelopmentConfig
- type EventRouter
- type FileKnowledgeLoaderConfig
- type FilesystemToolConfig
- type Framework
- func (f *Framework) BlobStore() runstate.BlobStore
- func (f *Framework) Catalog() catalog.Catalog
- func (f *Framework) Close(ctx context.Context) error
- func (f *Framework) HandleEvent(ctx context.Context, event IncomingEvent) (RunResult, error)
- func (f *Framework) PurgeExpired(ctx context.Context, maxAge time.Duration) (int, error)
- func (f *Framework) PurgeOrphanBlobs(ctx context.Context) (int, error)
- func (f *Framework) PurgeRuns(ctx context.Context, filter runstate.ListFilter) (int, error)
- func (f *Framework) PurgeWithPolicy(ctx context.Context, policy RetentionPolicy) (int, error)
- func (f *Framework) ResolveEvent(event IncomingEvent) (RunRequest, error)
- func (f *Framework) Resume(ctx context.Context, token string, decision core.Decision, ...) error
- func (f *Framework) ResumeAndContinue(ctx context.Context, token string, decision core.Decision, ...) (RunResult, error)
- func (f *Framework) Run(ctx context.Context, req RunRequest) (RunResult, error)
- func (f *Framework) RunStateRepository() runstate.Repository
- func (f *Framework) RunStructured(ctx context.Context, req RunRequest) (RunResult, error)
- func (f *Framework) Scenario() core.Scenario
- func (f *Framework) Stream(ctx context.Context, req RunRequest) (<-chan llm.ChatChunk, error)
- type FrameworkRunJobHandlerConfig
- type GitToolConfig
- type HTTPKnowledgeLoaderConfig
- type HTTPToolConfig
- type HumanHTTPHandlerConfig
- type IncomingEvent
- type JWTAlgorithm
- type JWTAuthenticatorConfig
- type JWTKey
- type JWTMiddlewareConfig
- type KnowledgeIndexerConfig
- type KnowledgeRegistry
- type LLMProviderRouter
- type MCPRegistry
- type MCPStdioClient
- type MCPStdioClientConfig
- type OIDCJWTAuthenticatorConfig
- type ObservabilityHTTPHandlerConfig
- type OpenAICompatibleProvider
- type Option
- func DemoOptions(scenario core.Scenario, config DemoConfig) ([]Option, error)
- func DevelopmentOptions(scenario core.Scenario, config DevelopmentConfig) ([]Option, error)
- func KnowledgeWiringOptions(scenario core.Scenario, registry KnowledgeRegistry) ([]Option, error)
- func MCPWiringOptions(ctx context.Context, scenario core.Scenario, registry MCPRegistry) ([]Option, error)
- func ProductionOptions(cfg ProductionConfig, scenario core.Scenario, workDir string) ([]Option, error)
- func WireMCPTools(ctx context.Context, scenario core.Scenario, registry MCPRegistry) ([]Option, error)
- func WithAuditSink(sink audit.Sink) Option
- func WithBlobStore(store runstate.BlobStore) Option
- func WithCloser(fn func(context.Context) error) Option
- func WithDatabase(db *sql.DB) Option
- func WithEventSink(sink core.EventSink) Option
- func WithHITLTokenSecret(secret []byte, tokenWriter io.Writer) Option
- func WithHITLTokenTTL(ttl time.Duration) Option
- func WithHumanGate(gate core.HumanGate) Option
- func WithLLMGateway(gateway llm.Gateway) Option
- func WithLogger(logger log.Logger) Option
- func WithMemoryRepository(name string, repo memory.Repository) Option
- func WithOutputRedactor(redactor governance.OutputRedactor) Option
- func WithRecorder(recorder observability.Recorder) Option
- func WithRequireLLM() Option
- func WithRunStateRepository(repo runstate.Repository) Option
- func WithSecurityPolicy(policy security.Policy) Option
- func WithToolExecutor(name string, executor core.ToolExecutor) Option
- func WithToolGovernancePolicy(policy governance.ToolPolicy) Option
- func WithToolResolver(resolver core.ToolResolver) Option
- func WithTracer(tracer observability.Tracer) Option
- type Plan
- type PostgresEventStoreConfig
- type PostgresVectorStoreConfig
- type ProductionConfig
- type ProductionHTTPHandlerConfig
- type PrometheusRecorder
- type RedisLockerConfig
- type RedisRunStateRepositoryConfig
- type RetentionPolicy
- type RetrieverToolConfig
- type RunRequest
- type RunResult
- type S3BlobStoreConfig
- type SQLToolConfig
- type Ticket
- type TicketStore
- type TicketToolConfig
- type ToolResolver
- type ToolResolverFunc
- type WebhookHTTPHandlerConfig
- type WiringOptions
Examples ¶
Constants ¶
const SchemaVersion = "2020-12"
SchemaVersion is the JSON Schema draft used by ScenarioJSONSchema.
const Version = "0.1.0"
Version is the library release version exposed to embedders.
Variables ¶
This section is empty.
Functions ¶
func BuildProductionHTTPHandler ¶ added in v0.1.4
func BuildProductionHTTPHandler(cfg ProductionConfig, fw *Framework, queue asyncpkg.Queue) (http.Handler, error)
BuildProductionHTTPHandler builds the production HTTP API handler from env-style config.
func DemoWorkDir ¶ added in v0.1.3
DemoWorkDir returns the directory containing a scenario file, or the current working directory when the path is empty.
func IsLoopbackAddr ¶ added in v0.1.4
IsLoopbackAddr reports whether an HTTP listen address is loopback-only.
func LoadScenario ¶
LoadScenario loads and validates a scenario YAML document.
func LoadScenarioFile ¶
LoadScenarioFile loads and validates a scenario YAML file.
func NewAPIKeyMiddleware ¶
func NewAnthropicGateway ¶
NewAnthropicGateway creates a gateway for Anthropic Messages APIs.
func NewAsyncRunHTTPHandler ¶
func NewAsyncRunHTTPHandler(config AsyncRunHTTPHandlerConfig) (http.Handler, error)
func NewEventHub ¶
func NewEventHub() *observability.EventHub
func NewEventStoreSink ¶
func NewEventStoreSink(store observability.EventStore, publishers ...observability.EventPublisher) core.EventSink
func NewFileBlobStore ¶
NewFileBlobStore creates a file-backed blob store.
func NewFileKnowledgeLoader ¶
func NewFileKnowledgeLoader(config FileKnowledgeLoaderConfig) (knowledge.Loader, error)
NewFileKnowledgeLoader creates a filesystem document loader for knowledge ingestion.
func NewFileMemoryRepository ¶
func NewFileMemoryRepository(dir string) (memory.Repository, error)
NewFileMemoryRepository creates a JSON-file-backed memory repository.
func NewFileRunStateRepository ¶
func NewFileRunStateRepository(dir string) (runstate.Repository, error)
NewFileRunStateRepository creates a JSON-file-backed run-state repository.
func NewFilesystemToolExecutor ¶
func NewFilesystemToolExecutor(config FilesystemToolConfig) (core.ToolExecutor, error)
NewFilesystemToolExecutor creates a governed filesystem read tool executor.
func NewFrameworkJobHandler ¶ added in v0.1.2
func NewFrameworkJobHandler(config FrameworkRunJobHandlerConfig) (asyncpkg.Handler, error)
NewFrameworkJobHandler executes framework run, event, and resume.continue jobs.
func NewFrameworkRunJobHandler ¶
func NewFrameworkRunJobHandler(config FrameworkRunJobHandlerConfig) (asyncpkg.Handler, error)
NewFrameworkRunJobHandler is an alias for NewFrameworkJobHandler.
func NewGitToolExecutor ¶ added in v0.1.2
func NewGitToolExecutor(config GitToolConfig) (core.ToolExecutor, error)
NewGitToolExecutor creates a read-only git tool executor.
func NewHTTPKnowledgeLoader ¶
func NewHTTPKnowledgeLoader(config HTTPKnowledgeLoaderConfig) (knowledge.Loader, error)
NewHTTPKnowledgeLoader creates an HTTP document loader for knowledge ingestion.
func NewHTTPToolExecutor ¶
func NewHTTPToolExecutor(config HTTPToolConfig) (core.ToolExecutor, error)
NewHTTPToolExecutor creates a governed HTTP client tool executor.
func NewHumanHTTPHandler ¶ added in v0.1.2
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.
func NewInMemoryAuditSink ¶
func NewInMemoryBlobStore ¶
NewInMemoryBlobStore creates the default in-memory blob store used by New.
func NewInMemoryEventStore ¶
func NewInMemoryEventStore() observability.EventStore
func NewInMemoryJobQueue ¶
func NewInMemoryRunStateRepository ¶
func NewInMemoryRunStateRepository() runstate.Repository
NewInMemoryRunStateRepository creates the default in-memory run-state repository used by New.
func NewJWTAuthenticator ¶
func NewJWTAuthenticator(config JWTAuthenticatorConfig) (security.BearerAuthenticator, error)
func NewJWTMiddleware ¶
func NewKnowledgeIndexer ¶
func NewKnowledgeIndexer(config KnowledgeIndexerConfig) (*knowledge.Indexer, error)
NewKnowledgeIndexer creates a document chunking, embedding, and vector upsert pipeline.
func NewLLMReranker ¶ added in v0.1.5
NewLLMReranker creates an LLM reranker for retrieval tools.
func NewLLMRouter ¶
NewLLMRouter routes profile names to provider-specific gateways.
func NewLocalGateway ¶
NewLocalGateway creates a gateway for local OpenAI-compatible model servers.
func NewMCPHTTPClient ¶
NewMCPHTTPClient creates an MCP JSON-RPC client over HTTP.
func NewMCPToolExecutor ¶
NewMCPToolExecutor adapts one MCP server tool into an AgentFlow tool executor.
func NewMockLLMGateway ¶ added in v0.1.4
NewMockLLMGateway creates a fallback mock gateway suitable for local development.
func NewNoopAuditSink ¶
func NewOIDCJWTAuthenticator ¶
func NewOIDCJWTAuthenticator(config OIDCJWTAuthenticatorConfig) (security.BearerAuthenticator, error)
NewOIDCJWTAuthenticator creates a bearer authenticator that discovers and refreshes RSA verification keys from OIDC Discovery/JWKS endpoints.
func NewObservabilityEventSink ¶
func NewObservabilityEventSink(recorder observability.Recorder, tracer observability.Tracer, next core.EventSink) core.EventSink
func NewObservabilityHTTPHandler ¶
func NewObservabilityHTTPHandler(config ObservabilityHTTPHandlerConfig) (http.Handler, error)
func NewOpenAICompatibleEmbedder ¶
NewOpenAICompatibleEmbedder creates an embedder for OpenAI-compatible embedding APIs.
func NewOpenAICompatibleGateway ¶
NewOpenAICompatibleGateway creates a gateway for OpenAI-compatible chat APIs.
func NewPostgresEventStore ¶
func NewPostgresEventStore(ctx context.Context, config PostgresEventStoreConfig) (observability.EventStore, error)
func NewPostgresJobQueue ¶
func NewPostgresRunStateRepository ¶
NewPostgresRunStateRepository creates a PostgreSQL-compatible run-state repository using a caller-provided *sql.DB. Applications must import and register their preferred PostgreSQL database/sql driver.
func NewPostgresVectorStore ¶
func NewPostgresVectorStore(config PostgresVectorStoreConfig) (knowledge.VectorStore, error)
NewPostgresVectorStore creates a pgvector-compatible knowledge vector store.
func NewProductionHTTPHandler ¶
func NewProductionHTTPHandler(config ProductionHTTPHandlerConfig) (http.Handler, error)
func NewProductionQueue ¶ added in v0.1.4
NewProductionQueue creates a job queue from ProductionConfig.
func NewProductionWorker ¶ added in v0.1.4
func NewProductionWorker(cfg ProductionConfig, queue asyncpkg.Queue, fw *Framework) (*asyncpkg.Worker, error)
NewProductionWorker creates an async worker for production job processing.
func NewRedisLocker ¶
func NewRedisLocker(config RedisLockerConfig) (coordination.Locker, error)
NewRedisLocker creates a Redis-backed lease manager for distributed worker and workflow coordination.
func NewRedisRunStateRepository ¶
func NewRedisRunStateRepository(config RedisRunStateRepositoryConfig) (runstate.Repository, error)
NewRedisRunStateRepository creates a Redis-backed run-state repository with compare-and-swap version checks for distributed workers.
func NewRetrieverTool ¶
func NewRetrieverTool(config RetrieverToolConfig) (core.ToolExecutor, error)
NewRetrieverTool creates a semantic retrieval tool backed by an embedder and vector store.
func NewS3BlobStore ¶
func NewS3BlobStore(config S3BlobStoreConfig) (runstate.BlobStore, error)
NewS3BlobStore creates an S3-compatible blob store for large runtime and workflow outputs. It uses path-style object URLs, AWS Signature Version 4, and supports providers whose S3-compatible PUT/GET behavior has been tested.
func NewSQLToolExecutor ¶
func NewSQLToolExecutor(config SQLToolConfig) (core.ToolExecutor, error)
NewSQLToolExecutor creates a governed read-only SQL query tool executor.
func NewScoreReranker ¶ added in v0.1.5
NewScoreReranker creates a lexical score reranker for retrieval tools.
func NewTicketToolExecutor ¶ added in v0.1.2
func NewTicketToolExecutor(config TicketToolConfig) (core.ToolExecutor, error)
NewTicketToolExecutor creates a ticket store backed tool executor.
func NewVerboseSlogEventSink ¶ added in v0.1.6
NewVerboseSlogEventSink logs runtime events with redacted-safe payload details to stderr-friendly sinks.
func NewWebhookHTTPHandler ¶ added in v0.1.2
func NewWebhookHTTPHandler(config WebhookHTTPHandlerConfig) (http.Handler, error)
NewWebhookHTTPHandler serves POST / requests that accept IncomingEvent JSON payloads.
func PrometheusMetricsHandler ¶ added in v0.1.4
func PrometheusMetricsHandler(recorder *PrometheusRecorder) http.Handler
PrometheusMetricsHandler returns an http.Handler that serves recorder metrics.
func ScenarioJSONSchema ¶ added in v0.1.4
func ScenarioJSONSchema() []byte
ScenarioJSONSchema returns a copy of the AgentFlow scenario JSON Schema.
func ValidateScenario ¶
ValidateScenario validates a scenario built programmatically.
func ValidateWiring ¶ added in v0.1.4
ValidateWiring checks that a scenario's declared dependencies are covered by the provided options before constructing a Framework.
func ValidateWiringWithOptions ¶ added in v0.1.4
func ValidateWiringWithOptions(scenario core.Scenario, wiring WiringOptions, opts ...Option) error
ValidateWiringWithOptions validates wiring using explicit wiring rules.
Types ¶
type APIKeyMiddlewareConfig ¶
type APIKeyMiddlewareConfig struct {
Authenticator security.APIKeyAuthenticator
HeaderName string
}
type DemoConfig ¶ added in v0.1.3
type DemoConfig struct {
// WorkDir is used as the default git allowlist root and relative repo path base.
WorkDir string
// GitRoots overrides git allowlist roots; WorkDir is used when empty.
GitRoots []string
}
DemoConfig controls local demo wiring for scenarios loaded from YAML.
type DevelopmentConfig ¶ added in v0.1.4
type DevelopmentConfig = DemoConfig
DevelopmentConfig controls local development wiring for scenarios loaded from YAML.
type EventRouter ¶ added in v0.1.2
type EventRouter = eventrouter.Router
EventRouter maps external events to run requests for a scenario.
func NewEventRouter ¶ added in v0.1.2
func NewEventRouter(scenario core.Scenario) *EventRouter
NewEventRouter creates a router from scenario trigger definitions.
type FilesystemToolConfig ¶
type Framework ¶
type Framework struct {
// contains filtered or unexported fields
}
Framework is an embeddable runtime wrapper for one scenario.
func New ¶
New creates a Framework for a validated scenario. By default it wires in-memory run-state and blob stores and a no-op event sink. Production applications should provide persistent repositories through options.
func NewFromFile ¶
NewFromFile loads a scenario YAML file and creates a Framework.
Example ¶
package main
import (
"context"
"encoding/json"
agentflow "github.com/aijustin/agentflow-go"
)
func main() {
fw, err := agentflow.NewFromFile("examples/autonomous.yaml")
if err != nil {
panic(err)
}
result, err := fw.Run(context.Background(), agentflow.RunRequest{
RunID: "example-run",
Prompt: "hello",
})
if err != nil {
panic(err)
}
out, _ := json.Marshal(result.Status)
println(string(out))
}
Output:
func NewProduction ¶ added in v0.1.4
func NewProduction(cfg ProductionConfig, tokenWriter io.Writer) (*Framework, error)
NewProduction constructs a Framework from ProductionConfig.
func (*Framework) Close ¶ added in v0.1.4
Close releases resources registered through WithCloser or WithDatabase.
func (*Framework) HandleEvent ¶ added in v0.1.2
HandleEvent resolves an incoming event and executes the scenario.
func (*Framework) PurgeExpired ¶ added in v0.1.4
PurgeExpired deletes terminal run snapshots whose UpdatedAt is before now-maxAge. Snapshots without UpdatedAt are skipped.
func (*Framework) PurgeOrphanBlobs ¶ added in v0.1.4
PurgeOrphanBlobs deletes blob objects that are no longer referenced by any run snapshot for the current scenario (and tenant, when a principal is present).
func (*Framework) PurgeWithPolicy ¶ added in v0.1.4
PurgeWithPolicy deletes run snapshots using a retention policy.
func (*Framework) ResolveEvent ¶ added in v0.1.2
func (f *Framework) ResolveEvent(event IncomingEvent) (RunRequest, error)
ResolveEvent resolves an incoming event without executing it.
func (*Framework) Resume ¶
func (f *Framework) Resume(ctx context.Context, token string, decision core.Decision, amendment json.RawMessage) error
Resume resumes a paused run through the configured human gate.
func (*Framework) ResumeAndContinue ¶ added in v0.1.2
func (f *Framework) ResumeAndContinue(ctx context.Context, token string, decision core.Decision, amendment json.RawMessage) (RunResult, error)
ResumeAndContinue resumes a paused run and continues execution until the next pause point or completion.
func (*Framework) RunStateRepository ¶
func (f *Framework) RunStateRepository() runstate.Repository
RunStateRepository returns the repository backing run-state snapshots.
func (*Framework) RunStructured ¶
RunStructured executes an agent using its configured output_schema and a gateway that implements llm.StructuredOutputter.
type FrameworkRunJobHandlerConfig ¶
type FrameworkRunJobHandlerConfig struct {
Framework *Framework
}
type GitToolConfig ¶ added in v0.1.2
type GitToolConfig struct {
AllowedRoots []string
}
type HTTPToolConfig ¶
type HumanHTTPHandlerConfig ¶ added in v0.1.2
type IncomingEvent ¶ added in v0.1.2
type IncomingEvent = eventrouter.Event
IncomingEvent is an external trigger delivered through webhooks or CLI.
type JWTAlgorithm ¶
type JWTAlgorithm string
const ( JWTAlgorithmHS256 JWTAlgorithm = "HS256" JWTAlgorithmRS256 JWTAlgorithm = "RS256" )
type JWTAuthenticatorConfig ¶
type JWTKey ¶
type JWTKey struct {
ID string
Algorithm JWTAlgorithm
HMACSecret []byte
RSAPublicKeyPEM []byte
}
type JWTMiddlewareConfig ¶
type JWTMiddlewareConfig struct {
Authenticator security.BearerAuthenticator
}
type KnowledgeIndexerConfig ¶
type KnowledgeRegistry ¶ added in v0.1.5
type KnowledgeRegistry struct {
Embedder llm.Embedder
Store knowledge.VectorStore
Reranker knowledge.Reranker
}
KnowledgeRegistry wires scenario knowledge collections to retriever executors.
type LLMProviderRouter ¶
func NewLLMProviderRouter ¶
func NewLLMProviderRouter(routes map[string]llm.Gateway) LLMProviderRouter
NewLLMProviderRouter routes chat/tool/structured/streaming and embedding calls by profile name when the selected route supports the requested capability.
type MCPRegistry ¶ added in v0.1.5
MCPRegistry supplies MCP clients for scenario server declarations.
type MCPStdioClient ¶
func NewMCPStdioClient ¶
func NewMCPStdioClient(ctx context.Context, config MCPStdioClientConfig) (MCPStdioClient, error)
NewMCPStdioClient creates an MCP JSON-RPC client over a child process stdio transport.
type MCPStdioClientConfig ¶
type OIDCJWTAuthenticatorConfig ¶
type OIDCJWTAuthenticatorConfig struct {
Issuer string
Audience string
DiscoveryURL string
JWKSURL string
HTTPClient *http.Client
RefreshInterval time.Duration
Now func() time.Time
Leeway time.Duration
PrincipalType identity.PrincipalType
TenantClaim string
WorkspaceClaim string
ProjectClaim string
RolesClaim string
}
type ObservabilityHTTPHandlerConfig ¶
type ObservabilityHTTPHandlerConfig struct {
Store observability.EventStore
Hub *observability.EventHub
AuthMiddleware func(http.Handler) http.Handler
}
type OpenAICompatibleProvider ¶
func NewOpenAICompatibleProvider ¶
func NewOpenAICompatibleProvider(profiles []llm.Profile, client *http.Client) OpenAICompatibleProvider
NewOpenAICompatibleProvider creates a gateway/embedder for OpenAI-compatible APIs.
type Option ¶
type Option func(*options) error
Option customizes Framework construction.
func DemoOptions ¶ added in v0.1.3
func DemoOptions(scenario core.Scenario, config DemoConfig) ([]Option, error)
DemoOptions registers mock LLM gateways and built-in demo tool executors declared in a scenario. Production services should register real executors explicitly.
func DevelopmentOptions ¶ added in v0.1.4
func DevelopmentOptions(scenario core.Scenario, config DevelopmentConfig) ([]Option, error)
DevelopmentOptions registers mock LLM gateways and built-in development tool executors declared in a scenario. Use for tests and local prototyping; wire real executors in production via explicit options or ProductionOptions.
func KnowledgeWiringOptions ¶ added in v0.1.5
func KnowledgeWiringOptions(scenario core.Scenario, registry KnowledgeRegistry) ([]Option, error)
KnowledgeWiringOptions returns Framework options that bind scenario knowledge collections.
func MCPWiringOptions ¶ added in v0.1.5
func MCPWiringOptions(ctx context.Context, scenario core.Scenario, registry MCPRegistry) ([]Option, error)
MCPWiringOptions returns Framework options that wire mcp.tool declarations to MCP servers.
func ProductionOptions ¶ added in v0.1.4
func ProductionOptions(cfg ProductionConfig, scenario core.Scenario, workDir string) ([]Option, error)
ProductionOptions returns Framework options for a production-style deployment.
func WireMCPTools ¶ added in v0.1.5
func WireMCPTools(ctx context.Context, scenario core.Scenario, registry MCPRegistry) ([]Option, error)
WireMCPTools binds scenario MCP servers to mcp.tool executors.
func WithAuditSink ¶
WithAuditSink wires an audit sink used for compliance-oriented events.
func WithBlobStore ¶
WithBlobStore wires storage for large step outputs.
func WithCloser ¶ added in v0.1.4
WithCloser registers a function invoked by Framework.Close in LIFO order.
func WithDatabase ¶ added in v0.1.4
WithDatabase registers a database handle for automatic close on Framework.Close.
func WithEventSink ¶
WithEventSink wires observability event output.
func WithHITLTokenSecret ¶
WithHITLTokenSecret wires the built-in HMAC-token human gate using the same RunStateRepository as the framework. tokenWriter can be nil.
func WithHITLTokenTTL ¶
WithHITLTokenTTL sets the lifetime for tokens emitted by WithHITLTokenSecret.
func WithHumanGate ¶
WithHumanGate wires a custom human-in-the-loop gate.
func WithLLMGateway ¶
WithLLMGateway wires a provider-neutral LLM gateway.
func WithLogger ¶ added in v0.1.1
WithLogger wires a structured logger that receives warning and error messages from the runtime. If not provided, messages are silently discarded.
func WithMemoryRepository ¶
func WithMemoryRepository(name string, repo memory.Repository) Option
WithMemoryRepository wires a memory backend by scenario memory name.
func WithOutputRedactor ¶
func WithOutputRedactor(redactor governance.OutputRedactor) Option
WithOutputRedactor wires an output redactor that scrubs sensitive fields from step outputs before they are persisted or returned to callers.
func WithRecorder ¶ added in v0.1.1
func WithRecorder(recorder observability.Recorder) Option
WithRecorder wires a metrics recorder. If not provided, metrics are discarded via observability.NoopRecorder.
func WithRequireLLM ¶ added in v0.1.4
func WithRequireLLM() Option
WithRequireLLM makes New fail when no LLM gateway is wired.
func WithRunStateRepository ¶
func WithRunStateRepository(repo runstate.Repository) Option
WithRunStateRepository wires run-state persistence used for pause/resume.
func WithSecurityPolicy ¶
WithSecurityPolicy wires an authorization policy used by runtime execution.
func WithToolExecutor ¶
func WithToolExecutor(name string, executor core.ToolExecutor) Option
WithToolExecutor registers an executable tool implementation by scenario tool name. Agent tool policies still come from the scenario YAML.
func WithToolGovernancePolicy ¶
func WithToolGovernancePolicy(policy governance.ToolPolicy) Option
WithToolGovernancePolicy wires a per-invocation tool governance policy. The policy is evaluated before every tool execution and can deny calls based on side-effect level, call budget, or custom logic.
func WithToolResolver ¶
func WithToolResolver(resolver core.ToolResolver) Option
WithToolResolver wires a resolver that creates or retrieves tool executors only when a declared tool is invoked. Explicit WithToolExecutor registrations take precedence over the resolver.
func WithTracer ¶ added in v0.1.1
func WithTracer(tracer observability.Tracer) Option
WithTracer wires a distributed-tracing provider. If not provided, tracing is a no-op via observability.NoopTracer.
type Plan ¶
type Plan struct {
Scenario core.Scenario
LLMs map[string]llm.Profile
Memory map[string]memory.Namespace
}
Plan is a resolved scenario plan that library users can inspect before creating a Framework.
type ProductionConfig ¶ added in v0.1.4
type ProductionConfig struct {
ScenarioFile string
StateDir string
TokenSecret string
TokenTTL time.Duration
HTTPAddr string
QueueKind string
PostgresDSN string
APIKey string
TenantID string
PrincipalID string
AuditFile string
Version string
WorkerID string
Concurrency int
LeaseTTL time.Duration
RenewInterval time.Duration
JobTimeout time.Duration
PollInterval time.Duration
}
ProductionConfig holds production wiring settings for library embedders.
func LoadProductionConfigFromEnv ¶ added in v0.1.4
func LoadProductionConfigFromEnv() (ProductionConfig, error)
LoadProductionConfigFromEnv loads ProductionConfig from standard AGENT_* env vars.
type ProductionHTTPHandlerConfig ¶
type ProductionHTTPHandlerConfig struct {
Queue asyncpkg.Queue
Policy security.Policy
Audit audit.Sink
AuthMiddleware func(http.Handler) 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 *Framework
}
type PrometheusRecorder ¶ added in v0.1.4
type PrometheusRecorder = promrecorder.Recorder
PrometheusRecorder exposes in-process Prometheus text metrics for agentflow runtime signals.
func NewPrometheusRecorder ¶ added in v0.1.4
func NewPrometheusRecorder() *PrometheusRecorder
NewPrometheusRecorder creates a Prometheus-compatible observability recorder.
type RedisLockerConfig ¶
type RetentionPolicy ¶ added in v0.1.4
type RetentionPolicy struct {
MaxAge time.Duration
Status runstate.RunStatus
ScenarioName string
Limit int
}
RetentionPolicy controls run-state cleanup.
type RetrieverToolConfig ¶
type RunRequest ¶
type RunRequest = appexec.RunRequest
RunRequest is the input passed to Framework.Run.
type S3BlobStoreConfig ¶
type SQLToolConfig ¶
type Ticket ¶ added in v0.1.2
type Ticket = toolticket.Ticket
Ticket is a support ticket record manipulated by the ticket tool.
type TicketStore ¶ added in v0.1.2
type TicketStore = toolticket.Store
TicketStore persists ticket records for the ticket tool executor.
func NewMemoryTicketStore ¶ added in v0.1.2
func NewMemoryTicketStore(seed map[string]Ticket) TicketStore
NewMemoryTicketStore creates an in-memory ticket store for tests and demos.
type TicketToolConfig ¶ added in v0.1.2
type TicketToolConfig struct {
Store toolticket.Store
}
type ToolResolver ¶
type ToolResolver = core.ToolResolver
type ToolResolverFunc ¶
type ToolResolverFunc = core.ToolResolverFunc
type WebhookHTTPHandlerConfig ¶ added in v0.1.2
type WiringOptions ¶ added in v0.1.4
WiringOptions controls ValidateWiring and optional New-time checks.
Source Files
¶
- api.go
- async.go
- audit.go
- blob_gc.go
- coordination.go
- demo.go
- development.go
- eventrouter.go
- framework.go
- framework_continue.go
- framework_event.go
- framework_hydrate.go
- knowledge.go
- knowledge_wiring.go
- lifecycle.go
- mcp.go
- mcp_wiring.go
- observability.go
- production.go
- providers.go
- retention.go
- schema.go
- security.go
- storage.go
- tools.go
- version.go
- wiring.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
agent-http
command
|
|
|
agent-server
command
|
|
|
agent-worker
command
|
|
|
agentctl
command
|
|
|
examples
|
|
|
go/hitl-resume
command
|
|
|
go/http-worker
command
|
|
|
go/minimal
command
|
|
|
go/postgres
command
|
|
|
internal
|
|
|
pkg
|
|
|
testutil
Package testutil provides helpers for testing applications built on agentflow.
|
Package testutil provides helpers for testing applications built on agentflow. |
|
Package schemas embeds machine-readable configuration schemas for AgentFlow.
|
Package schemas embeds machine-readable configuration schemas for AgentFlow. |