Documentation
¶
Overview ¶
Package axi is the entry point for axi-go — a domain-driven execution kernel for semantic actions. It provides a fluent, descriptive SDK for registering plugins and executing actions with built-in safety controls.
Example:
kernel := axi.New().
WithLogger(logger).
WithBudget(axi.Budget{MaxInvocations: 100})
if err := kernel.RegisterPlugin(myPlugin); err != nil {
return err
}
result, err := kernel.Execute(ctx, axi.Invocation{
Action: "greet",
Input: map[string]any{"name": "world"},
})
axi-go is a library you embed, not a service you run. There is no HTTP API. Delivery mechanisms (HTTP, gRPC, CLI, MCP) are the caller's choice; build your own adapter around this kernel.
Example ¶
Demonstrate the example from the package doc works.
package main
import (
"context"
"strings"
"github.com/felixgeelhaar/axi-go"
"github.com/felixgeelhaar/axi-go/domain"
)
func main() {
kernel := axi.New()
kernel.RegisterActionExecutor("exec.greet", &greetDocExecutor{})
_ = kernel.RegisterPlugin(&docPlugin{})
result, _ := kernel.Execute(context.Background(), axi.Invocation{
Action: "greet",
Input: map[string]any{"name": "world"},
})
data, _ := result.Result.Data.(map[string]any)
_ = strings.Contains(data["message"].(string), "world")
}
type docPlugin struct{}
func (p *docPlugin) Contribute() (*domain.PluginContribution, error) {
action, _ := domain.NewActionDefinition("greet", "",
domain.EmptyContract(), domain.EmptyContract(), nil,
domain.EffectProfile{}, domain.IdempotencyProfile{})
_ = action.BindExecutor("exec.greet")
return domain.NewPluginContribution("doc.plugin",
[]*domain.ActionDefinition{action}, nil)
}
type greetDocExecutor struct{}
func (e *greetDocExecutor) Execute(_ context.Context, input any, _ domain.CapabilityInvoker) (domain.ExecutionResult, []domain.EvidenceRecord, error) {
m := input.(map[string]any)
return domain.ExecutionResult{Data: map[string]any{"message": "Hello, " + m["name"].(string)}}, nil, nil
}
Output:
Index ¶
- type Budget
- type Invocation
- type Kernel
- func (k *Kernel) Approve(ctx context.Context, sessionID string) (*Result, error)
- func (k *Kernel) DeregisterPlugin(id string) error
- func (k *Kernel) Execute(ctx context.Context, inv Invocation) (*Result, error)
- func (k *Kernel) ExecuteAsync(ctx context.Context, inv Invocation) (*Result, error)
- func (k *Kernel) GetAction(name string) (*domain.ActionDefinition, error)
- func (k *Kernel) GetSession(sessionID string) (*domain.ExecutionSession, error)
- func (k *Kernel) ListActions() []*domain.ActionDefinition
- func (k *Kernel) ListCapabilities() []*domain.CapabilityDefinition
- func (k *Kernel) RegisterActionExecutor(ref string, executor domain.ActionExecutor)
- func (k *Kernel) RegisterBundle(bundle *domain.PluginBundle) error
- func (k *Kernel) RegisterCapabilityExecutor(ref string, executor domain.CapabilityExecutor)
- func (k *Kernel) RegisterPlugin(plugin domain.Plugin) error
- func (k *Kernel) RegisterPluginWithConfig(plugin domain.Plugin, config domain.PluginConfig) error
- func (k *Kernel) Reject(sessionID, reason string) (*Result, error)
- func (k *Kernel) WithBudget(budget Budget) *Kernel
- func (k *Kernel) WithIDGenerator(gen application.IDGenerator) *Kernel
- func (k *Kernel) WithLogger(logger domain.Logger) *Kernel
- func (k *Kernel) WithRateLimiter(rl domain.RateLimiter) *Kernel
- func (k *Kernel) WithTimeout(d time.Duration) *Kernel
- type Result
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Budget ¶
type Budget = domain.ExecutionBudget
Budget is an alias for domain.ExecutionBudget for ergonomic SDK usage.
type Invocation ¶
Invocation is the input to Execute — an action name plus its input data.
type Kernel ¶
type Kernel struct {
// contains filtered or unexported fields
}
Kernel is the fluent entry point for axi-go. Build it with New(), configure it with With* methods, register plugins, then Execute actions.
A Kernel is NOT safe to configure concurrently. Call With* before the first Execute. Execute itself is safe for concurrent use.
func New ¶
func New() *Kernel
New creates a Kernel with default in-memory adapters. Further configuration is done via chainable With* methods.
func (*Kernel) Approve ¶
Approve approves a session in AwaitingApproval state and resumes execution.
func (*Kernel) DeregisterPlugin ¶
DeregisterPlugin removes a plugin and all its contributed actions/capabilities.
func (*Kernel) Execute ¶
Execute runs an action synchronously and returns the full result. If the action has effect_level "write-external", execution pauses at AwaitingApproval and the caller must Approve() or Reject() before completion.
func (*Kernel) ExecuteAsync ¶
ExecuteAsync submits an action for background execution and returns immediately. Poll via GetSession(sessionID) to check status.
func (*Kernel) GetAction ¶
func (k *Kernel) GetAction(name string) (*domain.ActionDefinition, error)
GetAction returns an action definition by name.
func (*Kernel) GetSession ¶
func (k *Kernel) GetSession(sessionID string) (*domain.ExecutionSession, error)
GetSession returns the current state of an execution session by ID.
func (*Kernel) ListActions ¶
func (k *Kernel) ListActions() []*domain.ActionDefinition
ListActions returns all registered actions.
func (*Kernel) ListCapabilities ¶
func (k *Kernel) ListCapabilities() []*domain.CapabilityDefinition
ListCapabilities returns all registered capabilities.
func (*Kernel) RegisterActionExecutor ¶
func (k *Kernel) RegisterActionExecutor(ref string, executor domain.ActionExecutor)
RegisterActionExecutor wires an executor ref to an implementation. Use this when registering actions without a PluginBundle.
func (*Kernel) RegisterBundle ¶
func (k *Kernel) RegisterBundle(bundle *domain.PluginBundle) error
RegisterBundle atomically registers a plugin contribution along with its executor implementations. Preferred over RegisterPlugin when you want to validate executor refs match implementations before registration.
func (*Kernel) RegisterCapabilityExecutor ¶
func (k *Kernel) RegisterCapabilityExecutor(ref string, executor domain.CapabilityExecutor)
RegisterCapabilityExecutor wires a capability executor ref to an implementation.
func (*Kernel) RegisterPlugin ¶
RegisterPlugin registers a Plugin by calling Contribute() and activating it. If the plugin implements domain.LifecyclePlugin, Init() is called first.
func (*Kernel) RegisterPluginWithConfig ¶
RegisterPluginWithConfig registers a LifecyclePlugin with configuration.
func (*Kernel) WithBudget ¶
WithBudget sets the default execution budget (max duration, max invocations). Returns the kernel for chaining.
func (*Kernel) WithIDGenerator ¶
func (k *Kernel) WithIDGenerator(gen application.IDGenerator) *Kernel
WithIDGenerator overrides the default session ID generator.
func (*Kernel) WithLogger ¶
WithLogger sets a structured logger for the kernel. Returns the kernel for chaining.
func (*Kernel) WithRateLimiter ¶
func (k *Kernel) WithRateLimiter(rl domain.RateLimiter) *Kernel
WithRateLimiter sets a rate limiter checked before each execution. Returns the kernel for chaining.
type Result ¶
type Result = application.ExecuteActionOutput
Result is the output of Execute — session state, result data, evidence.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package application contains the use cases for axi-go.
|
Package application contains the use cases for axi-go. |
|
Package domain defines the core domain model for axi-go, a domain-driven execution kernel for semantic actions.
|
Package domain defines the core domain model for axi-go, a domain-driven execution kernel for semantic actions. |
|
Package main demonstrates axi-go embedded in a Go program.
|
Package main demonstrates axi-go embedded in a Go program. |
|
Package inmemory provides in-memory implementations of all repository ports.
|
Package inmemory provides in-memory implementations of all repository ports. |
|
Package jsonstore provides file-based JSON persistence adapters for all axi-go repository interfaces.
|
Package jsonstore provides file-based JSON persistence adapters for all axi-go repository interfaces. |