Documentation
¶
Overview ¶
Package agent defines the provider-neutral Agent Runtime Interface used by native SDKs and framework adapters. It intentionally depends only on the Go standard library so third-party Agents do not import Kernel implementation packages.
Index ¶
- Constants
- Variables
- func ValidateBaseURL(baseURL string) error
- type CapabilityGrant
- type Checkpoint
- type CheckpointResponse
- type Client
- func (c *Client) Checkpoint(ctx context.Context, executionID string) (CheckpointResponse, error)
- func (c *Client) Events(ctx context.Context, executionID string, after int64) (EventList, error)
- func (c *Client) Health(ctx context.Context) (HealthResponse, error)
- func (c *Client) Restore(ctx context.Context, request RestoreRequest) (RestoreResponse, error)
- func (c *Client) Result(ctx context.Context, executionID string) (Result, bool, error)
- func (c *Client) Start(ctx context.Context, request StartRequest) (StartResponse, error)
- func (c *Client) Stop(ctx context.Context, executionID string) (StopResponse, error)
- func (c *Client) StreamEvents(ctx context.Context, executionID string, after int64, ...) (Result, error)
- func (c *Client) WaitResult(ctx context.Context, executionID string, interval time.Duration) (Result, error)
- type Emitter
- type Event
- type EventList
- type HTTPError
- type HealthResponse
- type Host
- type HostOptions
- type RestoreRequest
- type RestoreResponse
- type Result
- type Runtime
- type StartRequest
- type StartResponse
- type StopResponse
Constants ¶
const ( ProtocolVersion = "fenced.runtime.interface/v1" LegacyProtocolVersion = "fenced.runtime.interface/v1alpha1" StatusAccepted = "ACCEPTED" StatusRunning = "RUNNING" StatusSucceeded = "SUCCEEDED" StatusFailed = "FAILED" StatusCancelled = "CANCELLED" )
Variables ¶
var ( ErrExecutionNotFound = errors.New("agent execution not found") ErrExecutionConflict = errors.New("agent execution id conflicts with another request") ErrCapacityExhausted = errors.New("agent runtime capacity exhausted") )
var ErrStreamingUnsupported = errors.New("runtime interface does not support event streaming")
ErrStreamingUnsupported reports a runtime that implements only the frozen v1 polling endpoints. Callers fall back to Events/Result polling.
Functions ¶
func ValidateBaseURL ¶
ValidateBaseURL checks one Runtime Interface endpoint against the wire contract every client and binding loader shares: an absolute http(s) URL with a host and no userinfo, query, fragment, or path components. It is the single validator so configuration fails fast at load time instead of at the first request.
Types ¶
type CapabilityGrant ¶
type CapabilityGrant struct {
Tools []string `json:"tools"`
Models []string `json:"models"`
Memory []string `json:"memory"`
MemorySensitivities []string `json:"memorySensitivities,omitempty"`
Secrets []string `json:"secrets"`
SpawnTasks bool `json:"spawnTasks,omitempty"`
ChildAgents []string `json:"childAgents,omitempty"`
// Peers lists the AgentVersion references this agent may send IPC messages
// to. An absent or empty list denies every peer.
Peers []string `json:"peers,omitempty"`
}
CapabilityGrant contains symbolic grants already admitted by the Kernel. Adapters use these identifiers to select a Gateway; they are never network endpoints, credentials, or raw secret values.
type Checkpoint ¶
type Checkpoint struct {
SchemaVersion string `json:"schemaVersion"`
State json.RawMessage `json:"state"`
CreatedAt time.Time `json:"createdAt"`
}
type CheckpointResponse ¶
type CheckpointResponse struct {
ExecutionID string `json:"executionId"`
Checkpoint Checkpoint `json:"checkpoint"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewLegacyClient ¶
NewLegacyClient creates an explicit N-1 client for the deprecated alpha endpoint. New integrations must use NewClient, which negotiates stable v1.
func (*Client) Checkpoint ¶
func (*Client) Restore ¶
func (c *Client) Restore(ctx context.Context, request RestoreRequest) (RestoreResponse, error)
func (*Client) Start ¶
func (c *Client) Start(ctx context.Context, request StartRequest) (StartResponse, error)
func (*Client) StreamEvents ¶
func (c *Client) StreamEvents(ctx context.Context, executionID string, after int64, onEvent func(Event) error) (Result, error)
StreamEvents consumes one execution's event stream over a single long-lived connection. Events after the cursor are delivered to onEvent; the terminal frame carries the final Result so no separate Result poll is needed. The connection lifetime is bound to ctx.
type Emitter ¶
type Emitter func(eventType string, payload json.RawMessage) error
Emitter appends a bounded execution event. Payload must be valid JSON.
type HealthResponse ¶
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host exposes one Runtime through the stable HTTP+JSON Runtime Interface. It supplies idempotent start, bounded event history, cancellation, logical checkpoint/restore, and terminal result semantics for every adapter.
type HostOptions ¶
type HostOptions struct {
Adapter string
MaxConcurrent int
EventLimit int
ExecutionLimit int
ExecutionTimeout time.Duration
Now func() time.Time
TerminationGrace time.Duration
// ForceTerminate must kill the isolated execution boundary (subprocess,
// container or microVM) after cooperative cancellation fails. Production
// adapters should configure it; embedded dev adapters may leave it nil.
ForceTerminate func(executionID string) error
}
type RestoreRequest ¶
type RestoreRequest struct {
ExecutionID string `json:"executionId"`
Checkpoint Checkpoint `json:"checkpoint"`
}
type RestoreResponse ¶
type Runtime ¶
type Runtime interface {
Run(ctx context.Context, request StartRequest, emit Emitter) (json.RawMessage, error)
Checkpoint(ctx context.Context, executionID string) (Checkpoint, error)
Restore(ctx context.Context, request RestoreRequest) error
}
Runtime is implemented by Native SDKs and framework adapters. Run owns one execution until a terminal output or error. Stop is represented by context cancellation. Checkpoint and Restore must use versioned logical state.
type StartRequest ¶
type StartRequest struct {
ExecutionID string `json:"executionId"`
AgentVersionRef string `json:"agentVersionRef"`
Goal string `json:"goal"`
Input json.RawMessage `json:"input"`
Capabilities CapabilityGrant `json:"capabilities"`
}