runtimeapi

package
v0.0.0-...-804b954 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package runtimeapi exposes the public, Temporal-free HTTP boundary of Agent Runtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(config Config) (http.Handler, error)

NewHandler constructs the versioned public HTTP API without starting a listener.

Types

type Authenticator

type Authenticator interface {
	Authenticate(context.Context, string) (Identity, error)
}

Authenticator turns one bearer credential into a bounded caller identity.

type Clock

type Clock = clock.Clock

Clock supplies the request-duration clock when observability is enabled.

type Config

type Config struct {
	Runtime         Runtime
	Authenticator   Authenticator
	RequestIDs      agentruntime.RequestIDSource
	MaxRequestBytes int64
	Observability   Observability
}

Config declares every dependency and finite request bound used by the API.

type CorrelationEnvelope

type CorrelationEnvelope struct {
	// contains filtered or unexported fields
}

CorrelationEnvelope is a validated, finite observability-only projection of runtime IDs. Its fields are private so an injected composition provider cannot accidentally bypass validation.

func NewCorrelationEnvelope

func NewCorrelationEnvelope(values CorrelationValues) (CorrelationEnvelope, error)

NewCorrelationEnvelope rejects an unsafe or oversized correlation value. Empty fields are omitted, which lets a caller provide only the references it knows without inventing cross-resource relationships.

func (CorrelationEnvelope) Values

func (envelope CorrelationEnvelope) Values() CorrelationValues

Values returns a value copy suitable for an observability exporter. It must never be used to populate application responses, public events, or metrics.

type CorrelationValues

type CorrelationValues struct {
	AgentID         string
	AgentRevisionID string
	SessionID       string
	TurnID          string
	InvocationID    string
	ToolCallID      string
	ToolExecutionID string
	ApprovalID      string
	SandboxID       string
	ProcessID       string
	OperationID     string
}

CorrelationValues is the finite set of runtime references that may be sent to an operator's trace or log sink. Values are deliberately references, not names, content, credentials, paths, provider handles, or arbitrary labels.

The fields are not metric dimensions. In particular, implementations must not turn this envelope into a high-cardinality metric label set.

type HMACIdentityCorrelator

type HMACIdentityCorrelator struct {
	// contains filtered or unexported fields
}

HMACIdentityCorrelator derives stable, keyed, bounded identity correlations.

func NewHMACIdentityCorrelator

func NewHMACIdentityCorrelator(key []byte) (*HMACIdentityCorrelator, error)

NewHMACIdentityCorrelator constructs an identity correlator from an explicit secret key.

func (*HMACIdentityCorrelator) Correlate

func (correlator *HMACIdentityCorrelator) Correlate(identity Identity) IdentityCorrelation

Correlate returns tenant and principal references that cannot be reversed without the configured key.

type Identity

type Identity struct {
	Tenant    string
	Principal string
	Admin     bool
}

Identity is the authenticated tenant and principal boundary for one request.

type IdentityCorrelation

type IdentityCorrelation struct {
	Tenant    string
	Principal string
}

IdentityCorrelation contains non-reversible operator correlation references.

type IdentityCorrelator

type IdentityCorrelator interface {
	Correlate(Identity) IdentityCorrelation
}

IdentityCorrelator derives safe operator correlations without returning a raw identity.

type Observability

type Observability struct {
	Clock              Clock
	Observer           RequestObserver
	IdentityCorrelator IdentityCorrelator
	// CorrelationProvider may add validated durable runtime references after a
	// request completes. It is intentionally optional: route-derived safe IDs
	// remain useful without coupling the HTTP role to a runtime implementation.
	CorrelationProvider RequestCorrelationProvider
}

Observability declares every dependency required to observe public HTTP requests. Its zero value deliberately disables observations for the local memory-unsafe role.

type RequestCorrelationProvider

type RequestCorrelationProvider interface {
	CorrelateRequest(context.Context, RequestObservation) CorrelationEnvelope
}

RequestCorrelationProvider is the explicit seam through which a trusted runtime composition can add durable IDs that are not present in the public HTTP route (for example an invocation, tool execution, sandbox, or process). It receives the already-redacted observation: never the request body, credentials, raw identity, URL, or provider/backend details.

type RequestObservation

type RequestObservation struct {
	RequestID            agentruntime.RequestID
	Operation            string
	Status               int
	Outcome              RequestOutcome
	FailureCode          agentruntime.FailureCode
	StartedAt            time.Time
	Duration             time.Duration
	TenantCorrelation    string
	PrincipalCorrelation string
	Correlation          CorrelationEnvelope
}

RequestObservation contains the bounded, application-safe outcome of one HTTP request.

type RequestObserver

type RequestObserver interface {
	ObserveRequest(context.Context, RequestObservation)
}

RequestObserver receives exactly one completed request observation.

type RequestOutcome

type RequestOutcome string

RequestOutcome classifies one bounded HTTP completion without exposing request data.

const (
	// RequestOutcomeSucceeded reports a completed non-error HTTP request.
	RequestOutcomeSucceeded RequestOutcome = "succeeded"
	// RequestOutcomeFailed reports a completed HTTP request with a safe failure status.
	RequestOutcomeFailed RequestOutcome = "failed"
	// RequestOutcomeCancelled reports a request whose caller context ended before completion.
	RequestOutcomeCancelled RequestOutcome = "cancelled"
)

type Runtime

type Runtime interface {
	CreateAgent(context.Context, Identity, agentruntime.CreateAgentRequest) (agentruntime.AgentSpecification, error)
	ReviseAgent(context.Context, Identity, agentruntime.ReviseAgentRequest) (agentruntime.AgentSpecification, error)
	GetAgentRevision(context.Context, Identity, agentruntime.AgentID, agentruntime.AgentRevisionID) (agentruntime.AgentSpecification, error)
	CreatePolicy(context.Context, Identity, agentruntime.CreatePolicyRequest) (agentruntime.Policy, error)
	RevisePolicy(context.Context, Identity, agentruntime.RevisePolicyRequest) (agentruntime.Policy, error)
	GetPolicy(context.Context, Identity, string, uint64) (agentruntime.Policy, error)
	ReadArtifact(context.Context, Identity, agentruntime.ArtifactID) (agentruntime.ArtifactDownload, error)
	ListSessionArtifacts(context.Context, Identity, agentruntime.SessionID) (agentruntime.ArtifactPage, error)
	InspectApproval(context.Context, Identity, agentruntime.ApprovalID) (agentruntime.Approval, error)
	ListApprovals(context.Context, Identity) (agentruntime.ApprovalPage, error)
	DecideApproval(context.Context, Identity, agentruntime.DecideApprovalRequest) (agentruntime.Approval, error)
	IdempotencyStatus(context.Context, Identity, string) (agentruntime.IdempotencyStatus, error)
	CreateSession(context.Context, Identity, agentruntime.CreateSessionRequest) (agentruntime.Session, error)
	SendInput(context.Context, Identity, agentruntime.SendInputRequest) (agentruntime.SendInputResult, error)
	InspectSession(context.Context, Identity, agentruntime.SessionID) (agentruntime.SessionView, error)
	InspectTurn(context.Context, Identity, agentruntime.SessionID, agentruntime.TurnID) (agentruntime.Turn, error)
	Events(context.Context, Identity, agentruntime.SessionID, agentruntime.Cursor, int) (agentruntime.EventPage, error)
	CancelTurn(context.Context, Identity, agentruntime.CancelTurnRequest) (agentruntime.Turn, error)
	CloseSession(context.Context, Identity, agentruntime.CloseSessionRequest) (agentruntime.Session, error)
	CancelSession(context.Context, Identity, agentruntime.CancelSessionRequest) (agentruntime.Session, error)
}

Runtime owns the internal application operations used by the public HTTP routes.

func NewKernelRuntime

func NewKernelRuntime(service *kernel.Kernel) (Runtime, error)

NewKernelRuntime adapts the deterministic memory-mode kernel to the internal Runtime seam.

type StateRuntime

type StateRuntime struct {
	// contains filtered or unexported fields
}

StateRuntime is the application seam that will route every public operation through content staging, compiler, planner, and state persistence.

func NewStateRuntime

func NewStateRuntime(config StateRuntimeConfig) (*StateRuntime, error)

NewStateRuntime validates the non-fallback durable runtime composition.

func (*StateRuntime) CancelSession

func (runtime *StateRuntime) CancelSession(ctx context.Context, identity Identity, request agentruntime.CancelSessionRequest) (agentruntime.Session, error)

CancelSession durably marks a drained open or closing Session cancelled.

func (*StateRuntime) CancelTurn

func (runtime *StateRuntime) CancelTurn(ctx context.Context, identity Identity, request agentruntime.CancelTurnRequest) (agentruntime.Turn, error)

CancelTurn atomically records a caller-authorized terminal cancellation.

func (*StateRuntime) CloseSession

func (runtime *StateRuntime) CloseSession(ctx context.Context, identity Identity, request agentruntime.CloseSessionRequest) (agentruntime.Session, error)

CloseSession durably rejects future Input while allowing accepted work to drain.

func (*StateRuntime) CreateAgent

CreateAgent stages the immutable specification body before atomically registering its metadata revision.

func (*StateRuntime) CreatePolicy

func (runtime *StateRuntime) CreatePolicy(ctx context.Context, identity Identity, request agentruntime.CreatePolicyRequest) (agentruntime.Policy, error)

CreatePolicy creates the first immutable revision of a named tenant policy.

func (*StateRuntime) CreateSession

func (runtime *StateRuntime) CreateSession(ctx context.Context, identity Identity, request agentruntime.CreateSessionRequest) (agentruntime.Session, error)

CreateSession pins a principal-owned Session to one existing immutable revision.

func (*StateRuntime) DecideApproval

func (runtime *StateRuntime) DecideApproval(ctx context.Context, identity Identity, request agentruntime.DecideApprovalRequest) (agentruntime.Approval, error)

DecideApproval atomically records one owner decision. A successful approval creates an internal bounded grant; the public result never carries it.

func (*StateRuntime) Events

func (runtime *StateRuntime) Events(ctx context.Context, identity Identity, sessionID agentruntime.SessionID, after agentruntime.Cursor, limit int) (agentruntime.EventPage, error)

Events reads a bounded cursor-resumable page of principal-scoped Product events.

func (*StateRuntime) GetAgentRevision

func (runtime *StateRuntime) GetAgentRevision(ctx context.Context, identity Identity, agentID agentruntime.AgentID, revisionID agentruntime.AgentRevisionID) (agentruntime.AgentSpecification, error)

GetAgentRevision reads one immutable Agent revision through the state-authorized content reader.

func (*StateRuntime) GetPolicy

func (runtime *StateRuntime) GetPolicy(ctx context.Context, identity Identity, name string, revision uint64) (agentruntime.Policy, error)

GetPolicy reads one immutable policy revision through the administrator surface.

func (*StateRuntime) IdempotencyStatus

func (runtime *StateRuntime) IdempotencyStatus(ctx context.Context, identity Identity, key string) (agentruntime.IdempotencyStatus, error)

IdempotencyStatus safely returns a retained receipt for the caller's exact durable scope. It is an observation only: no command is compiled or replayed.

func (*StateRuntime) InspectApproval

func (runtime *StateRuntime) InspectApproval(ctx context.Context, identity Identity, approvalID agentruntime.ApprovalID) (agentruntime.Approval, error)

InspectApproval returns the caller-owned projection of one approval without exposing the tool action, policy digest, or capability metadata.

func (*StateRuntime) InspectSession

func (runtime *StateRuntime) InspectSession(ctx context.Context, identity Identity, sessionID agentruntime.SessionID) (agentruntime.SessionView, error)

InspectSession returns the bounded principal-scoped public projection.

func (*StateRuntime) InspectToolCalls

func (runtime *StateRuntime) InspectToolCalls(ctx context.Context, identity Identity, sessionID agentruntime.SessionID, turnID agentruntime.TurnID) (agentruntime.ToolCallPage, error)

InspectToolCalls returns bounded safe projections for one principal-owned Turn.

func (*StateRuntime) InspectTurn

func (runtime *StateRuntime) InspectTurn(ctx context.Context, identity Identity, sessionID agentruntime.SessionID, turnID agentruntime.TurnID) (agentruntime.Turn, error)

InspectTurn returns one exact principal-owned Turn.

func (*StateRuntime) ListApprovals

func (runtime *StateRuntime) ListApprovals(ctx context.Context, identity Identity) (agentruntime.ApprovalPage, error)

ListApprovals returns the bounded owner-scoped Approval inbox in durable creation order. It exposes no policy, descriptor, or capability material.

func (*StateRuntime) ListSessionArtifacts

func (runtime *StateRuntime) ListSessionArtifacts(ctx context.Context, identity Identity, sessionID agentruntime.SessionID) (agentruntime.ArtifactPage, error)

ListSessionArtifacts returns the bounded immutable Artifact index for one owner-authorized Session. It never exposes a storage locator or Artifact bytes, and a caller must still pass exact authorization when reading one.

func (*StateRuntime) OpenArtifact

func (runtime *StateRuntime) OpenArtifact(ctx context.Context, identity Identity, artifactID agentruntime.ArtifactID) (runtimecontent.ArtifactStream, error)

OpenArtifact opens an authorized bounded Artifact transfer without exposing a storage locator. The existing ReadArtifact method remains for compatibility.

func (*StateRuntime) ReadArtifact

func (runtime *StateRuntime) ReadArtifact(ctx context.Context, identity Identity, artifactID agentruntime.ArtifactID) (agentruntime.ArtifactDownload, error)

ReadArtifact returns one principal-authorized immutable artifact through the state-authorized runtime-content reader. Blob storage is never addressed by a public ID alone.

func (*StateRuntime) ReviseAgent

ReviseAgent stages a replacement immutable body and records the next revision under optimistic concurrency.

func (*StateRuntime) RevisePolicy

func (runtime *StateRuntime) RevisePolicy(ctx context.Context, identity Identity, request agentruntime.RevisePolicyRequest) (agentruntime.Policy, error)

RevisePolicy creates the next immutable revision of a named tenant policy.

func (*StateRuntime) SendInput

func (runtime *StateRuntime) SendInput(ctx context.Context, identity Identity, request agentruntime.SendInputRequest) (agentruntime.SendInputResult, error)

SendInput stages its immutable envelope and atomically admits one Input and Turn.

type StateRuntimeConfig

type StateRuntimeConfig struct {
	Content  *runtimecontent.Store
	Compiler *runtimestate.Compiler
	Planner  *runtimestate.RuntimeStatePlanner
	Store    runtimestate.RuntimeStateStore
	// ModelProfiles is the explicit allow-list for public Agent specifications.
	ModelProfiles []string
}

StateRuntimeConfig supplies the complete metadata/content authority required by the state-backed public runtime.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL