agentruntime

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 63 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToolMemoryRead   = "memory.read"
	ToolMemoryWrite  = "memory.write"
	ToolMemorySearch = "memory.search"
	ToolMemoryList   = "memory.list"
	ToolMemoryIngest = "memory.ingest"
)
View Source
const (
	ToolOrlojTaskCreate = "orloj.task.create"
	ToolOrlojTaskList   = "orloj.task.list"
)
View Source
const (
	AuthorizeVerdictAllow            = "allow"
	AuthorizeVerdictDeny             = "deny"
	AuthorizeVerdictApprovalRequired = "approval_required"
)
View Source
const (
	ToolContractVersionV1 = "v1"
	ToolOperationInvoke   = "invoke"
)
View Source
const (
	ToolExecutionStatusOK     = "ok"
	ToolExecutionStatusError  = ToolStatusError
	ToolExecutionStatusDenied = ToolStatusDenied
)
View Source
const (
	ToolStatusError  = "error"
	ToolStatusDenied = "denied"
)
View Source
const (
	ToolCodeInvalidInput         = "invalid_input"
	ToolCodeUnsupportedTool      = "unsupported_tool"
	ToolCodeRuntimePolicyInvalid = "runtime_policy_invalid"
	ToolCodeIsolationUnavailable = "isolation_unavailable"
	ToolCodePermissionDenied     = "permission_denied"
	ToolCodeSecretResolution     = "secret_resolution_failed"
	ToolCodeTimeout              = "timeout"
	ToolCodeCanceled             = "canceled"
	ToolCodeExecutionFailed      = "execution_failed"
	ToolCodeAuthExpired          = "auth_expired"
	ToolCodeAuthInvalid          = "auth_invalid"
	ToolCodeAuthForbidden        = "auth_forbidden"
	ToolCodeApprovalPending      = "approval_pending"
	ToolCodeApprovalDenied       = "approval_denied"
	ToolCodeApprovalTimeout      = "approval_timeout"
)
View Source
const (
	ToolReasonInvalidInput           = "tool_invalid_input"
	ToolReasonToolUnsupported        = "tool_unsupported"
	ToolReasonRuntimePolicyInvalid   = "tool_runtime_policy_invalid"
	ToolReasonIsolationUnavailable   = "tool_isolation_unavailable"
	ToolReasonPermissionDenied       = "tool_permission_denied"
	ToolReasonSecretResolution       = "tool_secret_resolution_failed"
	ToolReasonExecutionTimeout       = "tool_execution_timeout"
	ToolReasonExecutionCanceled      = "tool_execution_canceled"
	ToolReasonBackendFailure         = "tool_backend_failure"
	ToolReasonAuthExpired            = "tool_auth_expired"
	ToolReasonAuthInvalid            = "tool_auth_invalid"
	ToolReasonAuthForbidden          = "tool_auth_forbidden"
	ToolReasonApprovalPending        = "tool_approval_pending"
	ToolReasonApprovalDenied         = "tool_approval_denied"
	ToolReasonApprovalTimeout        = "tool_approval_timeout"
	ToolReasonAgentContractViolation = "agent_contract_violation"
)
View Source
const DefaultMaxToolOutputBytes = 16 * 1024 * 1024

DefaultMaxToolOutputBytes is the default cap for tool stdout/stderr capture. 16 MiB is generous for legitimate tool output while preventing OOM from runaway processes.

View Source
const WASMToolModuleContractVersionV1 = "v1"

Variables

View Source
var (
	ErrUnsupportedTool          = errors.New("unsupported tool")
	ErrToolIsolationUnavailable = errors.New("tool isolation runtime unavailable")
	ErrInvalidToolRuntimePolicy = errors.New("invalid tool runtime policy")
	ErrToolPermissionDenied     = errors.New("tool permission denied")
	ErrToolApprovalRequired     = errors.New("tool approval required")
)
View Source
var ErrModelGatewayConfiguration = errors.New("model gateway configuration error")
View Source
var ErrOutputLimitExceeded = fmt.Errorf("tool output exceeded maximum allowed size")

ErrOutputLimitExceeded is returned when a tool's stdout or stderr exceeds the configured maximum.

View Source
var ErrToolSecretNotFound = errors.New("tool secret not found")
View Source
var ErrToolSecretResolution = errors.New("tool secret resolution failed")

Functions

func AdaptTaskInputViaContextAdapter added in v0.12.0

func AdaptTaskInputViaContextAdapter(
	ctx context.Context,
	namespace string,
	adapterStoreKey string,
	lookup ContextAdapterGetter,
	deps ContextAdapterDeps,
	raw map[string]string,
) (map[string]string, error)

AdaptTaskInputViaContextAdapter runs the ContextAdapter tool chain on raw task input maps.

func AgentHasOrlojTools added in v0.6.0

func AgentHasOrlojTools(agent resources.Agent) bool

AgentHasOrlojTools returns true if any of the agent's allowed_tools are orloj tools.

func AgentTokenBudget added in v0.12.0

func AgentTokenBudget(policies []resources.AgentPolicy, agentName string) int

AgentTokenBudget returns the smallest positive MaxTokensPerRun across policies that apply to the named agent, or 0 when no budget is configured. Policies with target_agents only match the listed agents; policies without target_agents apply to all agents.

func BuiltinMemoryToolNames

func BuiltinMemoryToolNames() []string

BuiltinMemoryToolNames returns the sorted list of built-in memory tool names.

func BuiltinOrlojToolNames added in v0.6.0

func BuiltinOrlojToolNames() []string

BuiltinOrlojToolNames returns the sorted list of built-in orloj tool names.

func CanRunAsJob added in v0.16.0

func CanRunAsJob(agent resources.Agent, tools []resources.Tool, mcpServers map[string]resources.McpServer) bool

CanRunAsJob checks whether an agent can run as a K8s Job. Agents with Docker-dependent tools (container isolation or stdio MCP with image) cannot run as Jobs and fall back to in-process execution.

func ConfigureA2ARuntime added in v0.17.0

func ConfigureA2ARuntime(rt ToolRuntime, a2aRT ToolRuntime, namespace string)

ConfigureA2ARuntime builds and attaches a runtime for type=a2a tools. The runtime is scoped to the governed runtime's registry and the provided namespace.

func ConfigureCliRuntime added in v0.5.0

func ConfigureCliRuntime(rt ToolRuntime, secrets SecretResolver, runner CLICommandRunner, config CLIToolRuntimeConfig, namespace string)

ConfigureCliRuntime builds and attaches a CLI runtime for direct (non-containerized) CLI tool execution. The runtime is scoped to the governed runtime's registry and the provided namespace.

func ConfigureExternalRuntime added in v0.6.0

func ConfigureExternalRuntime(rt ToolRuntime, secrets SecretResolver, namespace string)

ConfigureExternalRuntime builds and attaches a runtime for type=external tools. The runtime is scoped to the governed runtime's registry and the provided namespace.

func ConfigureGRPCRuntime added in v0.6.0

func ConfigureGRPCRuntime(rt ToolRuntime, secrets SecretResolver, namespace string)

ConfigureGRPCRuntime builds and attaches a runtime for type=grpc tools. The runtime is scoped to the governed runtime's registry and the provided namespace.

func ConfigureHttpRuntime added in v0.9.0

func ConfigureHttpRuntime(rt ToolRuntime, secrets SecretResolver, namespace string)

ConfigureHttpRuntime replaces the HTTP base runtime with one that has a secret resolver, enabling HTTP tools with auth.secretRef to resolve their credentials. Must be called after BuildGovernedToolRuntimeForAgent* when the caller has a secret resolver available (e.g. a store-backed resolver in the worker).

func ConfigureKubernetesRuntime added in v0.16.0

func ConfigureKubernetesRuntime(rt ToolRuntime, k8sRT ToolRuntime, namespace string)

ConfigureKubernetesRuntime builds and attaches a runtime for isolation_mode=kubernetes tools. The runtime is scoped to the governed runtime's registry and the provided namespace.

func ConfigureMcpRuntime

func ConfigureMcpRuntime(rt ToolRuntime, sessionManager *McpSessionManager, mcpServerStore McpServerLookup, namespace string)

ConfigureMcpRuntime builds and attaches an MCP runtime using the given session manager and server store. The runtime is scoped to the governed runtime's registry and the provided namespace.

func ConfigureWasmRuntime added in v0.11.0

func ConfigureWasmRuntime(rt ToolRuntime, wasmRT ToolRuntime, namespace string)

ConfigureWasmRuntime builds and attaches a WASM runtime for type=wasm tools. The runtime is scoped to the governed runtime's registry and the provided namespace.

func ConfigureWebhookCallbackRuntime added in v0.6.0

func ConfigureWebhookCallbackRuntime(rt ToolRuntime, secrets SecretResolver, namespace string)

ConfigureWebhookCallbackRuntime builds and attaches a runtime for type=webhook-callback tools. The runtime is scoped to the governed runtime's registry and the provided namespace.

func DefaultSafeHTTPClient added in v0.8.0

func DefaultSafeHTTPClient(allowPrivate bool) *http.Client

DefaultSafeHTTPClient returns a shared *http.Client whose transport enforces SSRF policy at dial time. Prefer this over constructing a fresh client when the default 30-second timeout is acceptable.

func EncodeReviewRequestPayload added in v0.10.0

func EncodeReviewRequestPayload(payload ReviewRequestPayload) string

func EnforcePoliciesForAgent added in v0.6.0

func EnforcePoliciesForAgent(agent resources.Agent, effectiveModel string, policies []resources.AgentPolicy) error

EnforcePoliciesForAgent checks that the agent's effective model and declared tools comply with all matched AgentPolicy resources. Returns an error on the first violation. This must be called in both synchronous and message-driven execution paths before the agent runs.

func ExecutionToAgentJobResult added in v0.16.0

func ExecutionToAgentJobResult(r AgentExecutionResult, execErr error) *resources.AgentJobResult

ExecutionToAgentJobResult converts an AgentExecutionResult into an AgentJobResult for storage by the agent pod.

func IsApprovalRequiredError

func IsApprovalRequiredError(err error) bool

func IsBuiltinMemoryTool

func IsBuiltinMemoryTool(name string) bool

IsBuiltinMemoryTool returns true if the tool name is a built-in memory tool.

func IsBuiltinOrlojTool added in v0.6.0

func IsBuiltinOrlojTool(name string) bool

IsBuiltinOrlojTool returns true if the tool name is a built-in orloj tool.

func IsToolDeniedError

func IsToolDeniedError(err error) bool

func IsWASMToolModuleContractError

func IsWASMToolModuleContractError(err error) bool

func MatchedPolicies added in v0.6.0

func MatchedPolicies(task resources.Task, system resources.AgentSystem, all []resources.AgentPolicy) []resources.AgentPolicy

MatchedPolicies returns the subset of policies that apply to the given task/system combination, respecting apply_mode (global vs scoped).

func MinimumChildDepth added in v0.6.0

func MinimumChildDepth(policies []resources.AgentPolicy) int

MinimumChildDepth returns the smallest positive MaxChildDepth across the given policies, or 0 when no limit is configured.

func MinimumChildTasks added in v0.6.0

func MinimumChildTasks(policies []resources.AgentPolicy) int

MinimumChildTasks returns the smallest positive MaxChildTasks across the given policies, or 0 when no limit is configured.

func MinimumTokenBudget added in v0.6.0

func MinimumTokenBudget(policies []resources.AgentPolicy) int

MinimumTokenBudget returns the smallest positive MaxTokensPerRun across system-wide policies (those without target_agents), or 0 when no budget is configured. Policies with target_agents are per-agent budgets and are handled by AgentTokenBudget instead.

func NewToolDeniedError

func NewToolDeniedError(message string, details map[string]string, cause error) error

func NewToolError

func NewToolError(
	status string,
	code string,
	reason string,
	retryable bool,
	message string,
	cause error,
	details map[string]string,
) error

func ParseInputFromApprovalError added in v0.13.0

func ParseInputFromApprovalError(err error) string

ParseInputFromApprovalError extracts the tool input from a structured ToolApprovalRequiredError in the error chain. Returns empty string if not found.

func ParseToolFromApprovalError added in v0.6.0

func ParseToolFromApprovalError(err error) string

ParseToolFromApprovalError extracts the tool name from an approval-required error chain by looking for "tool=..." in the error message.

func RedactSensitive

func RedactSensitive(s string) string

RedactSensitive replaces known sensitive patterns (auth headers, API keys, tokens) in s with a redacted placeholder. This is applied as defense-in-depth before including process output (stderr, error messages) in logs or traces.

func RegisterModelProvider

func RegisterModelProvider(plugin ModelProviderPlugin) error

RegisterModelProvider registers a plugin globally for model gateway and router usage.

func RegisterToolIsolationBackend

func RegisterToolIsolationBackend(mode string, factory ToolIsolationBackendFactory) error

func ResumeMessageFromAgentMessage added in v0.10.0

func ResumeMessageFromAgentMessage(msg AgentMessage) resources.TaskApprovalResumeMessage

func RetryAfter

func RetryAfter(delay time.Duration, cause error) error

RetryAfter builds a handler error that asks the bus to requeue this delivery after delay.

func SafeDialer added in v0.8.0

func SafeDialer(allowPrivate bool) *net.Dialer

SafeDialer returns a *net.Dialer whose Control hook enforces SSRF policy against the actual IP the runtime is about to connect to. This closes the hostname-bypass gap in ValidateEndpointURL and defends against DNS rebinding: even if a hostname resolves to a public IP during validation and a private IP at dial time, the dial is aborted.

Pass allowPrivate=true to permit connections to RFC 1918 / ULA / CGNAT addresses (e.g. self-hosted Ollama, vLLM, LM Studio, internal services). Loopback, link-local, cloud metadata, and unspecified addresses are always blocked regardless of allowPrivate.

func SafeHTTPClient added in v0.8.0

func SafeHTTPClient(allowPrivate bool, timeout time.Duration) *http.Client

SafeHTTPClient returns an *http.Client whose transport dials through SafeDialer, enforcing SSRF policy on every outbound connection. Pass timeout<=0 to use the default 30-second timeout.

func SafeModelGatewayHTTPClient added in v0.14.0

func SafeModelGatewayHTTPClient(allowPrivate bool, timeout time.Duration) *http.Client

SafeModelGatewayHTTPClient returns a safe HTTP client for trusted model endpoints. With allowPrivate=true it permits loopback and private model servers, but still blocks cloud metadata, link-local, and unspecified addresses.

func TaskApprovalResourceName added in v0.10.0

func TaskApprovalResourceName(taskKey, checkpointID string, cycle int) string

TaskApprovalResourceName returns a deterministic resource name for a TaskApproval keyed by (taskKey, checkpointID, cycle).

func ToolApprovalResourceName added in v0.6.0

func ToolApprovalResourceName(taskKey, messageID string) string

ToolApprovalResourceName returns the deterministic resource name for a ToolApproval keyed by (taskKey, messageID).

func ToolApprovalScopedStoreKey

func ToolApprovalScopedStoreKey(taskKey, messageID string) string

ToolApprovalScopedStoreKey returns the same lookup key used for ToolApproval resources created by pauseTaskForToolApproval (namespace/name).

func ToolErrorMeta

func ToolErrorMeta(err error) (code string, reason string, retryable bool, ok bool)

func ValidateEndpointURL

func ValidateEndpointURL(rawURL string, allowPrivate bool) error

ValidateEndpointURL checks that a URL is safe for outbound requests from tool and MCP runtimes. It blocks dangerous URL schemes and, when the host is a literal IP address, rejects loopback, link-local, cloud metadata, and (optionally) private addresses.

When the host is a hostname (not a literal IP), scheme validation still applies but IP-level checks are deferred to the dial layer installed by SafeHTTPClient / SafeDialer. Callers that build an *http.Client with SafeHTTPClient get dial-time enforcement automatically; callers that do not (e.g. code that predates SafeHTTPClient) MUST call SafeHTTPClient rather than relying on ValidateEndpointURL alone for SSRF protection.

Pass allowPrivate=true to skip the private/internal address checks (e.g. for development or explicitly trusted internal services).

Types

type AgentExecutionResult

type AgentExecutionResult struct {
	Agent           string
	Model           string
	Steps           int
	ToolCalls       int
	MemoryWrites    int
	EstimatedTokens int
	TokensUsed      int
	TokenSource     string
	Duration        time.Duration
	Output          string
	LastEvent       string
	Events          []string
	StepEvents      []AgentStepEvent
}

AgentExecutionResult captures task-time execution details for one agent.

func AgentJobResultToExecution added in v0.16.0

func AgentJobResultToExecution(r *resources.AgentJobResult, agentName string) AgentExecutionResult

AgentJobResultToExecution converts an AgentJobResult from a K8s Job back into an AgentExecutionResult for use by the controller/consumer.

type AgentJobStore added in v0.16.0

type AgentJobStore interface {
	Get(ctx context.Context, name string) (resources.Task, bool, error)
	SetAgentJobInput(ctx context.Context, name string, input map[string]string, agent, messageID string) error
	SetAgentJobResult(ctx context.Context, name string, result *resources.AgentJobResult) error
	GetAgentJobResult(ctx context.Context, name string) (*resources.AgentJobResult, error)
	ClearAgentJobFields(ctx context.Context, name string) error
}

AgentJobStore is the minimal interface for orchestrator↔pod communication via Postgres. Implemented by store.TaskStore.

type AgentMessage

type AgentMessage struct {
	MessageID      string `json:"message_id,omitempty"`
	IdempotencyKey string `json:"idempotency_key,omitempty"`
	TaskID         string `json:"task_id,omitempty"`
	Attempt        int    `json:"attempt,omitempty"`
	System         string `json:"system,omitempty"`
	Namespace      string `json:"namespace,omitempty"`
	FromAgent      string `json:"from_agent,omitempty"`
	ToAgent        string `json:"to_agent,omitempty"`
	BranchID       string `json:"branch_id,omitempty"`
	ParentBranchID string `json:"parent_branch_id,omitempty"`
	Type           string `json:"type,omitempty"`
	Payload        string `json:"payload,omitempty"`
	Timestamp      string `json:"timestamp,omitempty"`
	TraceID        string `json:"trace_id,omitempty"`
	ParentID       string `json:"parent_id,omitempty"`
	DelegateOf     string `json:"delegate_of,omitempty"`
}

AgentMessage is the runtime envelope exchanged between agents.

func AgentMessageFromResumeMessage added in v0.10.0

func AgentMessageFromResumeMessage(msg resources.TaskApprovalResumeMessage) AgentMessage

type AgentMessageBus

type AgentMessageBus interface {
	Publish(context.Context, AgentMessage) (AgentMessage, error)
	Consume(context.Context, AgentMessageSubscription, AgentMessageHandler) error
	Close() error
}

AgentMessageBus is the runtime data-plane contract for agent messaging.

type AgentMessageConsumerManager

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

AgentMessageConsumerManager watches agents and consumes runtime inbox messages per agent.

func (*AgentMessageConsumerManager) Start

type AgentMessageConsumerOptions

type AgentMessageConsumerOptions struct {
	WorkerID            string
	Namespace           string
	RefreshEvery        time.Duration
	DedupeWindow        time.Duration
	ConsumerDelay       time.Duration
	LeaseExtendDuration time.Duration
	Executor            *TaskExecutor
	Tools               ToolResourceLookup
	Roles               AgentRoleLookup
	ToolPermissions     ToolPermissionLookup
	IsolatedToolRuntime ToolRuntime
	WasmToolRuntime     ToolRuntime
	CliToolConfig       CLIToolRuntimeConfig
	SecretResolver      SecretResolver
	McpSessionManager   *McpSessionManager
	McpServerStore      McpServerLookup
	Extensions          Extensions
	Memories            MemoryResourceLookup
	MemoryBackends      *PersistentMemoryBackendRegistry
	ModelEndpoints      resources.ModelEndpointLookup
	ToolApprovals       ToolApprovalUpserter
	TaskApprovals       TaskApprovalUpserter
	Policies            AgentPolicyLookup
	ContextAdapters     ContextAdapterGetter
	KubernetesToolRT    ToolRuntime
	A2AToolRuntime      ToolRuntime
	AgentK8sRuntime     *KubernetesAgentRuntime
	OnStepEvent         func(taskName, namespace string, evt AgentStepEvent)
	DebugLogger         *log.Logger
}

AgentMessageConsumerOptions configures inbox consumers in a worker.

type AgentMessageDelivery

type AgentMessageDelivery interface {
	Message() AgentMessage
	Ack(context.Context) error
	Nack(context.Context, bool) error
	NackWithDelay(context.Context, time.Duration) error
	ExtendLease(context.Context, time.Duration) error
}

AgentMessageDelivery represents one delivery instance with ack semantics.

type AgentMessageHandler

type AgentMessageHandler func(context.Context, AgentMessageDelivery) error

AgentMessageHandler processes one message delivery.

type AgentMessageSubscription

type AgentMessageSubscription struct {
	Namespace string
	Agent     string
	Durable   string
}

AgentMessageSubscription identifies a consumer input stream.

type AgentPolicyLookup added in v0.6.0

type AgentPolicyLookup interface {
	List(ctx context.Context) ([]resources.AgentPolicy, error)
}

AgentPolicyLookup lists AgentPolicy resources for policy enforcement.

type AgentRegistry

type AgentRegistry interface {
	List(ctx context.Context) ([]resources.Agent, error)
	Get(ctx context.Context, name string) (resources.Agent, bool, error)
}

AgentRegistry lists and resolves declared agents for message consumer subscriptions/execution.

type AgentRoleLookup

type AgentRoleLookup interface {
	Get(ctx context.Context, name string) (resources.AgentRole, bool, error)
}

type AgentStepEvent

type AgentStepEvent struct {
	Timestamp           string
	Type                string
	Step                int
	Tool                string
	Message             string
	ErrorCode           string
	ErrorReason         string
	Retryable           *bool
	ToolContractVersion string
	ToolRequestID       string
	ToolAttempt         int
	LatencyMS           int64
	Tokens              int
	InputTokens         int
	OutputTokens        int
	UsageSource         string
	ToolAuthProfile     string
	ToolAuthSecretRef   string
}

AgentStepEvent is one structured runtime event emitted during agent execution.

type AgentSystemRegistry

type AgentSystemRegistry interface {
	Get(ctx context.Context, name string) (resources.AgentSystem, bool, error)
}

AgentSystemRegistry resolves AgentSystem resources for next-hop routing.

type AgentToolAuthorizer

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

func NewAgentToolAuthorizer

func NewAgentToolAuthorizer(
	ctx context.Context,
	namespace string,
	agent resources.Agent,
	roleLookup AgentRoleLookup,
	permissionLookup ToolPermissionLookup,
) *AgentToolAuthorizer

func (*AgentToolAuthorizer) Authorize

func (a *AgentToolAuthorizer) Authorize(tool string, spec resources.ToolSpec) (*AuthorizeResult, error)

type AgentWorker

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

AgentWorker runs the core execution loop for one agent.

func NewAgentWorker

func NewAgentWorker(agent resources.Agent, toolRuntime ToolRuntime, memory MemoryStore, onEvent func(string)) *AgentWorker

func NewAgentWorkerWithInterval

func NewAgentWorkerWithInterval(agent resources.Agent, toolRuntime ToolRuntime, memory MemoryStore, onEvent func(string), stepEvery time.Duration) *AgentWorker

func NewAgentWorkerWithIntervalAndGateway

func NewAgentWorkerWithIntervalAndGateway(
	agent resources.Agent,
	toolRuntime ToolRuntime,
	memory MemoryStore,
	modelGateway ModelGateway,
	onEvent func(string),
	stepEvery time.Duration,
) *AgentWorker

func NewAgentWorkerWithIntervalAndGatewayAndInput

func NewAgentWorkerWithIntervalAndGatewayAndInput(
	agent resources.Agent,
	toolRuntime ToolRuntime,
	memory MemoryStore,
	modelGateway ModelGateway,
	input map[string]string,
	onEvent func(string),
	stepEvery time.Duration,
) *AgentWorker

func (*AgentWorker) Run

func (w *AgentWorker) Run(ctx context.Context)

func (*AgentWorker) SetToolSchemas

func (w *AgentWorker) SetToolSchemas(schemas map[string]ToolSchemaInfo)

SetToolSchemas attaches per-tool description and JSON Schema metadata. Model gateways use these to provide rich tool definitions to the LLM instead of the generic {input: string} fallback.

type AnthropicModelGateway

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

AnthropicModelGateway calls the Anthropic Messages API.

func (*AnthropicModelGateway) Complete

type AnthropicModelGatewayConfig

type AnthropicModelGatewayConfig struct {
	APIKey           string
	BaseURL          string
	DefaultModel     string
	AnthropicVersion string
	MaxTokens        int
	Timeout          time.Duration
	HTTPClient       *http.Client
}

AnthropicModelGatewayConfig defines Anthropic Messages API settings.

func DefaultAnthropicModelGatewayConfig

func DefaultAnthropicModelGatewayConfig() AnthropicModelGatewayConfig

DefaultAnthropicModelGatewayConfig returns Anthropic gateway defaults.

type AuditEvent

type AuditEvent struct {
	Timestamp    string            `json:"timestamp"`
	Component    string            `json:"component,omitempty"`
	Action       string            `json:"action"`
	Outcome      string            `json:"outcome"`
	Namespace    string            `json:"namespace,omitempty"`
	ResourceKind string            `json:"resource_kind,omitempty"`
	ResourceName string            `json:"resource_name,omitempty"`
	Principal    string            `json:"principal,omitempty"`
	Message      string            `json:"message,omitempty"`
	Metadata     map[string]string `json:"metadata,omitempty"`
}

AuditEvent captures one normalized audit event for optional external audit sinks.

type AuditSink

type AuditSink interface {
	RecordAudit(ctx context.Context, event AuditEvent)
}

AuditSink receives audit events. Implementations should be non-blocking and resilient.

type AuthInjector

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

AuthInjector centralizes auth resolution for all tool runtime backends. It resolves Tool.spec.auth into concrete headers/env based on the auth profile.

func NewAuthInjector

func NewAuthInjector(secrets SecretResolver, tokenCache *OAuth2TokenCache) *AuthInjector

func (*AuthInjector) EvictOAuth2Token

func (a *AuthInjector) EvictOAuth2Token(tokenURL, clientID string)

EvictOAuth2Token removes a cached OAuth2 token, used on 401 responses.

func (*AuthInjector) Resolve

func (a *AuthInjector) Resolve(ctx context.Context, toolName string, auth resources.ToolAuth) (AuthResult, error)

Resolve produces an AuthResult for the given tool auth config. Returns an empty AuthResult (no error) when no auth is configured.

type AuthResult

type AuthResult struct {
	Headers map[string]string
	EnvVars map[string]string
	Profile string
}

AuthResult holds resolved authentication artifacts for tool backends. Headers are used by HTTP-based backends; EnvVars are used by the container backend.

type AuthorizeResult

type AuthorizeResult struct {
	Verdict string
	Reason  string
	Details map[string]string
}

type AzureOpenAIModelGateway

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

AzureOpenAIModelGateway calls Azure OpenAI chat completions API.

func (*AzureOpenAIModelGateway) Complete

type AzureOpenAIModelGatewayConfig

type AzureOpenAIModelGatewayConfig struct {
	APIKey            string
	BaseURL           string
	DefaultDeployment string
	APIVersion        string
	Timeout           time.Duration
	HTTPClient        *http.Client
}

AzureOpenAIModelGatewayConfig defines Azure OpenAI chat completion settings.

func DefaultAzureOpenAIModelGatewayConfig

func DefaultAzureOpenAIModelGatewayConfig() AzureOpenAIModelGatewayConfig

DefaultAzureOpenAIModelGatewayConfig returns Azure OpenAI gateway defaults.

type BedrockModelGateway added in v0.10.0

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

BedrockModelGateway calls the AWS Bedrock Converse API.

func NewBedrockModelGateway added in v0.10.0

func NewBedrockModelGateway(cfg BedrockModelGatewayConfig) (*BedrockModelGateway, error)

NewBedrockModelGateway builds a Bedrock gateway from the given config.

func (*BedrockModelGateway) Complete added in v0.10.0

type BedrockModelGatewayConfig added in v0.10.0

type BedrockModelGatewayConfig struct {
	Region          string
	AccessKeyID     string
	SecretAccessKey string
	SessionToken    string
	Profile         string
	BaseURL         string
	DefaultModel    string
	MaxTokens       int
	Timeout         time.Duration
}

BedrockModelGatewayConfig defines AWS Bedrock Converse API settings.

func DefaultBedrockModelGatewayConfig added in v0.10.0

func DefaultBedrockModelGatewayConfig() BedrockModelGatewayConfig

DefaultBedrockModelGatewayConfig returns Bedrock gateway defaults.

type BoundedWriter added in v0.12.0

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

BoundedWriter wraps a bytes.Buffer and stops accepting writes once the configured maximum is reached. It is safe for concurrent use.

func NewBoundedWriter added in v0.12.0

func NewBoundedWriter(max int) *BoundedWriter

NewBoundedWriter returns a writer that accepts at most max bytes.

func (*BoundedWriter) Exceeded added in v0.12.0

func (w *BoundedWriter) Exceeded() bool

Exceeded reports whether the cap was hit.

func (*BoundedWriter) String added in v0.12.0

func (w *BoundedWriter) String() string

String returns the captured output.

func (*BoundedWriter) Write added in v0.12.0

func (w *BoundedWriter) Write(p []byte) (int, error)

Write implements io.Writer. Once the cap is reached, further bytes are silently discarded and Exceeded() returns true.

type CLICommandRunner added in v0.5.0

type CLICommandRunner interface {
	Run(ctx context.Context, command string, args []string, stdin string, env []string, dir string) (stdout string, stderr string, exitCode int, err error)
}

CLICommandRunner abstracts process execution for testability.

type CLIToolRuntime added in v0.5.0

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

CLIToolRuntime executes CLI tools directly on the worker host.

func NewCLIToolRuntime added in v0.5.0

func NewCLIToolRuntime(registry ToolCapabilityRegistry, secrets SecretResolver, runner CLICommandRunner, config CLIToolRuntimeConfig) *CLIToolRuntime

func (*CLIToolRuntime) Call added in v0.5.0

func (r *CLIToolRuntime) Call(ctx context.Context, tool string, input string) (string, error)

func (*CLIToolRuntime) WithNamespace added in v0.5.0

func (r *CLIToolRuntime) WithNamespace(namespace string) ToolRuntime

func (*CLIToolRuntime) WithRegistry added in v0.5.0

func (r *CLIToolRuntime) WithRegistry(registry ToolCapabilityRegistry) ToolRuntime

type CLIToolRuntimeConfig added in v0.5.0

type CLIToolRuntimeConfig struct {
	AllowedCommands []string
	MaxArgvLength   int
}

CLIToolRuntimeConfig holds optional policy for direct CLI execution.

func DefaultCLIToolRuntimeConfig added in v0.5.0

func DefaultCLIToolRuntimeConfig() CLIToolRuntimeConfig

type Capability

type Capability struct {
	ID          string `json:"id"`
	Enabled     bool   `json:"enabled"`
	Description string `json:"description,omitempty"`
	Source      string `json:"source,omitempty"`
}

Capability describes one discoverable feature exposed by the current runtime.

type CapabilityProvider

type CapabilityProvider interface {
	Capabilities(ctx context.Context) CapabilitySnapshot
}

CapabilityProvider returns deployment capabilities for API/UI/CLI feature discovery.

type CapabilitySnapshot

type CapabilitySnapshot struct {
	GeneratedAt  string       `json:"generated_at"`
	Capabilities []Capability `json:"capabilities"`
}

CapabilitySnapshot returns the effective capability set for this deployment.

type ChainSecretResolver

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

func NewChainSecretResolver

func NewChainSecretResolver(resolvers ...SecretResolver) *ChainSecretResolver

func (*ChainSecretResolver) Resolve

func (r *ChainSecretResolver) Resolve(ctx context.Context, secretRef string) (string, error)

func (*ChainSecretResolver) WithNamespace

func (r *ChainSecretResolver) WithNamespace(namespace string) SecretResolver

type ChatMessage

type ChatMessage struct {
	Role       string // "system", "user", "assistant", "tool"
	Content    string
	ToolCallID string         // role="tool": the ID of the tool call this result answers
	ToolCalls  []ChatToolCall // role="assistant": tool calls the model made this turn
	IsError    bool           // role="tool": true when this tool result represents a failure
}

ChatMessage represents one message in a multi-turn conversation.

type ChatToolCall

type ChatToolCall struct {
	ID           string
	Name         string
	Input        string
	ProviderName string
}

ChatToolCall captures one tool invocation from an assistant message.

type Chunk

type Chunk struct {
	Index  int    `json:"index"`
	Text   string `json:"text"`
	Offset int    `json:"offset"`
}

Chunk represents one segment of a chunked document.

func ChunkText

func ChunkText(text string, chunkSize, overlap int) []Chunk

ChunkText splits text into overlapping windows of chunkSize characters. overlap controls how many characters from the end of the previous chunk are repeated at the start of the next. Zero or negative values are replaced with sensible defaults (1000 / 200).

type ContainerCommandRunner

type ContainerCommandRunner interface {
	Run(ctx context.Context, binary string, args []string, stdin string, env map[string]string) (stdout string, stderr string, err error)
}

ContainerCommandRunner executes container runtime commands.

type ContainerToolRuntime

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

ContainerToolRuntime executes tools inside a containerized sandbox.

func NewContainerToolRuntimeWithRunnerAndSecrets

func NewContainerToolRuntimeWithRunnerAndSecrets(
	registry ToolCapabilityRegistry,
	config ContainerToolRuntimeConfig,
	runner ContainerCommandRunner,
	secrets SecretResolver,
) *ContainerToolRuntime

func (*ContainerToolRuntime) Call

func (r *ContainerToolRuntime) Call(ctx context.Context, tool string, input string) (string, error)

func (*ContainerToolRuntime) WithNamespace

func (r *ContainerToolRuntime) WithNamespace(namespace string) ToolRuntime

func (*ContainerToolRuntime) WithRegistry

func (r *ContainerToolRuntime) WithRegistry(registry ToolCapabilityRegistry) ToolRuntime

type ContainerToolRuntimeConfig

type ContainerToolRuntimeConfig struct {
	RuntimeBinary string
	Image         string
	Network       string
	Memory        string
	CPUs          string
	PidsLimit     int
	User          string
	Shell         string
}

ContainerToolRuntimeConfig defines isolated tool execution in a locked-down container.

func DefaultContainerToolRuntimeConfig

func DefaultContainerToolRuntimeConfig() ContainerToolRuntimeConfig

func SandboxedContainerDefaults

func SandboxedContainerDefaults() ContainerToolRuntimeConfig

SandboxedContainerDefaults returns secure-by-default container settings for tools running in sandboxed isolation mode. These enforce:

  • network=none (no network access)
  • memory=128m (128 MB ceiling)
  • cpus=0.50 (half a core)
  • pids_limit=64 (process limit)
  • user=65532:65532 (non-root nobody user)

These defaults match DefaultContainerToolRuntimeConfig but are preserved as an explicit contract so callers can distinguish between default and sandboxed modes.

type ContextAdapterDeps added in v0.12.0

type ContextAdapterDeps struct {
	Tools          ToolResourceLookup
	Isolated       ToolRuntime
	Wasm           ToolRuntime
	SecretResolver SecretResolver
	Cli            CLIToolRuntimeConfig
	McpMgr         *McpSessionManager
	McpStore       McpServerLookup
}

ContextAdapterDeps supplies tool runtime machinery shared with TaskController and the message consumer.

type ContextAdapterGetter added in v0.12.0

type ContextAdapterGetter interface {
	Get(ctx context.Context, key string) (resources.ContextAdapter, bool, error)
}

ContextAdapterGetter resolves ContextAdapter resources by store key (namespace-qualified).

type ContextAdapterHook added in v0.12.0

type ContextAdapterHook interface {
	AdaptContext(ctx context.Context, input map[string]string) (map[string]string, error)
}

ContextAdapterHook transforms task input before any agent sees it. Implementations must be safe to call concurrently.

type EmbeddingProvider

type EmbeddingProvider interface {
	Embed(ctx context.Context, texts []string) ([][]float32, error)
	Dimensions() int
}

EmbeddingProvider generates vector embeddings from text. Implementations are used by vector-database memory backends (e.g. pgvector) to embed values on write and queries on search.

type EnvSecretResolver

type EnvSecretResolver struct {
	Prefix string
}

EnvSecretResolver resolves secret refs from worker environment variables.

func NewEnvSecretResolver

func NewEnvSecretResolver(prefix string) *EnvSecretResolver

func (*EnvSecretResolver) Resolve

func (r *EnvSecretResolver) Resolve(_ context.Context, secretRef string) (string, error)

func (*EnvSecretResolver) WithNamespace

func (r *EnvSecretResolver) WithNamespace(_ string) SecretResolver

type EvalScoreResult added in v0.15.0

type EvalScoreResult struct {
	Score     *float64
	Pass      *bool
	Reasoning string
	Error     string
}

EvalScoreResult holds the outcome of scoring a single sample.

type EvalScorer added in v0.15.0

type EvalScorer struct {
	Gateway ModelGateway
}

EvalScorer runs the scoring pipeline for eval samples.

func (*EvalScorer) Score added in v0.15.0

Score evaluates a single sample's output using the given scoring configuration. The output string is the agent system's response from task.status.output.

type ExecutionEngine

type ExecutionEngine interface {
	Execute(ctx context.Context, agent resources.Agent, input map[string]string) (AgentExecutionResult, error)
}

ExecutionEngine orchestrates one agent execution loop.

type Extensions

type Extensions struct {
	Metering     MeteringSink
	Audit        AuditSink
	Capabilities CapabilityProvider
}

Extensions groups optional runtime hooks for add-on integrations.

func DefaultExtensions

func DefaultExtensions() Extensions

DefaultExtensions returns OSS-safe defaults for all extension hooks.

func NormalizeExtensions

func NormalizeExtensions(ext Extensions) Extensions

NormalizeExtensions applies safe defaults so callers can omit all optional hooks.

type ExternalToolRuntime

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

ExternalToolRuntime delegates tool execution to an external HTTP service. Tools with spec.type=external have their ToolExecutionRequest forwarded to spec.endpoint and the ToolExecutionResponse parsed from the reply.

func NewExternalToolRuntime

func NewExternalToolRuntime(registry ToolCapabilityRegistry, secrets SecretResolver, client HTTPDoer) *ExternalToolRuntime

func (*ExternalToolRuntime) Call

func (r *ExternalToolRuntime) Call(ctx context.Context, tool string, input string) (string, error)

func (*ExternalToolRuntime) SetAllowPrivateEndpoints added in v0.8.0

func (r *ExternalToolRuntime) SetAllowPrivateEndpoints(allow bool)

SetAllowPrivateEndpoints permits external tool delegation to private / internal IP ranges. Loopback, link-local, cloud metadata, and unspecified addresses remain blocked.

func (*ExternalToolRuntime) WithNamespace

func (r *ExternalToolRuntime) WithNamespace(namespace string) ToolRuntime

func (*ExternalToolRuntime) WithRegistry

func (r *ExternalToolRuntime) WithRegistry(registry ToolCapabilityRegistry) ToolRuntime

type GRPCDialer

type GRPCDialer interface {
	DialContext(ctx context.Context, target string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
}

GRPCDialer abstracts gRPC connection establishment for testing.

type GRPCToolRuntime

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

GRPCToolRuntime executes tools via a unary gRPC call to an external service. The service must implement orloj.tool.v1.ToolService/Execute accepting ToolExecutionRequest and returning ToolExecutionResponse as JSON payloads.

func NewGRPCToolRuntime

func NewGRPCToolRuntime(registry ToolCapabilityRegistry, secrets SecretResolver, dialer GRPCDialer) *GRPCToolRuntime

func (*GRPCToolRuntime) Call

func (r *GRPCToolRuntime) Call(ctx context.Context, tool string, input string) (string, error)

func (*GRPCToolRuntime) SetAllowInsecure

func (r *GRPCToolRuntime) SetAllowInsecure(allow bool)

SetAllowInsecure enables plaintext gRPC connections. This should only be used in development or when the transport is otherwise secured (e.g. service mesh with mTLS). Callers must explicitly opt in.

func (*GRPCToolRuntime) WithNamespace

func (r *GRPCToolRuntime) WithNamespace(namespace string) ToolRuntime

func (*GRPCToolRuntime) WithRegistry

func (r *GRPCToolRuntime) WithRegistry(registry ToolCapabilityRegistry) ToolRuntime

type GovernedToolApprovalContext

type GovernedToolApprovalContext struct {
	Getter    func(key string) (resources.ToolApproval, bool, error)
	TaskKey   string
	MessageID string
}

GovernedToolApprovalContext optionally lets the governed tool runtime treat an existing Approved ToolApproval (same key as pauseTaskForToolApproval) as a grant to invoke the tool, so resuming a message after approval does not loop on approval_required for every fresh agent worker run.

type GovernedToolRuntime

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

GovernedToolRuntime enforces per-tool policy (timeout/retry/isolation) using Tool CRD runtime metadata.

func NewGovernedToolRuntime

func NewGovernedToolRuntime(
	baseRuntime ToolRuntime,
	isolatedRuntime ToolRuntime,
	registry ToolCapabilityRegistry,
	strict bool,
) *GovernedToolRuntime

func NewGovernedToolRuntimeWithAuthorizer

func NewGovernedToolRuntimeWithAuthorizer(
	baseRuntime ToolRuntime,
	isolatedRuntime ToolRuntime,
	registry ToolCapabilityRegistry,
	authorizer ToolCallAuthorizer,
	strict bool,
) *GovernedToolRuntime

func (*GovernedToolRuntime) Call

func (r *GovernedToolRuntime) Call(ctx context.Context, tool string, input string) (string, error)

func (*GovernedToolRuntime) ResolveToolSchemas

func (r *GovernedToolRuntime) ResolveToolSchemas(toolNames []string) map[string]ToolSchemaInfo

ResolveToolSchemas returns description and input schema metadata for the given tool names, sourced from the underlying ToolCapabilityRegistry.

func (*GovernedToolRuntime) SetMcpRuntime

func (r *GovernedToolRuntime) SetMcpRuntime(mcpRuntime ToolRuntime)

SetMcpRuntime configures the MCP tool runtime used for type=mcp tools.

func (*GovernedToolRuntime) SetWasmRuntime added in v0.11.0

func (r *GovernedToolRuntime) SetWasmRuntime(wasmRuntime ToolRuntime)

SetWasmRuntime configures the embedded WASM tool runtime used for type=wasm tools.

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPDoer abstracts HTTP request execution for testing.

type HTTPMemoryBackend

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

HTTPMemoryBackend implements PersistentMemoryBackend by delegating to an external HTTP service that speaks the Orloj memory provider contract. See docs/pages/concepts/memory.md for the contract specification.

func NewHTTPMemoryBackend

func NewHTTPMemoryBackend(endpoint, authToken string) *HTTPMemoryBackend

func (*HTTPMemoryBackend) Get

func (b *HTTPMemoryBackend) Get(ctx context.Context, key string) (string, bool, error)

func (*HTTPMemoryBackend) List

func (b *HTTPMemoryBackend) List(ctx context.Context, prefix string) ([]MemorySearchResult, error)

func (*HTTPMemoryBackend) Ping

func (b *HTTPMemoryBackend) Ping(ctx context.Context) error

func (*HTTPMemoryBackend) Put

func (b *HTTPMemoryBackend) Put(ctx context.Context, key, value string) error

func (*HTTPMemoryBackend) Search

func (b *HTTPMemoryBackend) Search(ctx context.Context, query string, topK int) ([]MemorySearchResult, error)

type HTTPToolClient

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

HTTPToolClient executes tools via HTTP POST against Tool.spec.endpoint. It replaces MockToolClient as the base runtime for isolation_mode=none.

func NewHTTPToolClient

func NewHTTPToolClient(registry ToolCapabilityRegistry, secrets SecretResolver, client HTTPDoer) *HTTPToolClient

func NewHTTPToolClientWithAuth

func NewHTTPToolClientWithAuth(registry ToolCapabilityRegistry, injector *AuthInjector, client HTTPDoer) *HTTPToolClient

func (*HTTPToolClient) Call

func (r *HTTPToolClient) Call(ctx context.Context, tool string, input string) (string, error)

func (*HTTPToolClient) SetAllowPrivateEndpoints

func (r *HTTPToolClient) SetAllowPrivateEndpoints(allow bool)

SetAllowPrivateEndpoints permits HTTP tool calls to private/internal IP ranges (RFC 1918). Loopback and cloud metadata addresses are always blocked. When the runtime is using its internally-built safe HTTP client, this swaps the client for one whose dial-time policy matches, so call-time validation and dial-time enforcement stay consistent.

func (*HTTPToolClient) WithNamespace

func (r *HTTPToolClient) WithNamespace(namespace string) ToolRuntime

func (*HTTPToolClient) WithRegistry

func (r *HTTPToolClient) WithRegistry(registry ToolCapabilityRegistry) ToolRuntime

type InMemoryBackend

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

InMemoryBackend is a PersistentMemoryBackend backed by an in-process map. Useful for testing and single-instance deployments.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

func (*InMemoryBackend) Get

func (b *InMemoryBackend) Get(_ context.Context, key string) (string, bool, error)

func (*InMemoryBackend) List

func (*InMemoryBackend) Ping

func (b *InMemoryBackend) Ping(_ context.Context) error

func (*InMemoryBackend) Put

func (b *InMemoryBackend) Put(_ context.Context, key, value string) error

func (*InMemoryBackend) Search

func (b *InMemoryBackend) Search(_ context.Context, query string, topK int) ([]MemorySearchResult, error)

type KubernetesAgentConfig added in v0.16.0

type KubernetesAgentConfig struct {
	Namespace      string
	ServiceAccount string
	Image          string
	JobTTLSeconds  int32
	DefaultMemory  string
	DefaultCPU     string
	EnvConfigMap   string
	EnvSecretName  string
}

KubernetesAgentConfig holds operator-level defaults for agent K8s execution.

type KubernetesAgentRuntime added in v0.16.0

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

KubernetesAgentRuntime executes agents as ephemeral Kubernetes Jobs.

func NewKubernetesAgentRuntime added in v0.16.0

func NewKubernetesAgentRuntime(
	client KubernetesJobClient,
	config KubernetesAgentConfig,
	store AgentJobStore,
	logger *log.Logger,
) *KubernetesAgentRuntime

func (*KubernetesAgentRuntime) ExecuteAgent added in v0.16.0

func (r *KubernetesAgentRuntime) ExecuteAgent(
	ctx context.Context,
	task resources.Task,
	agent resources.Agent,
	input map[string]string,
	attempt int,
	messageID string,
) (*resources.AgentJobResult, error)

ExecuteAgent runs an agent as a K8s Job and returns the result.

type KubernetesJobClient added in v0.16.0

type KubernetesJobClient interface {
	CreateJob(ctx context.Context, namespace string, job *batchv1.Job) (*batchv1.Job, error)
	WatchJob(ctx context.Context, namespace, name string) (watch.Interface, error)
	GetJob(ctx context.Context, namespace, name string) (*batchv1.Job, error)
	GetPodLogs(ctx context.Context, namespace, podName string) (string, error)
	ListPods(ctx context.Context, namespace, jobName string) ([]corev1.Pod, error)
	DeleteJob(ctx context.Context, namespace, name string) error
}

KubernetesJobClient abstracts the Kubernetes API calls for testing.

func NewDefaultKubernetesJobClient added in v0.16.0

func NewDefaultKubernetesJobClient(clientset kubernetes.Interface) KubernetesJobClient

NewDefaultKubernetesJobClient wraps a kubernetes.Interface as a KubernetesJobClient.

type KubernetesSecretClient added in v0.16.0

type KubernetesSecretClient interface {
	GetSecret(ctx context.Context, namespace, name string) (map[string][]byte, error)
}

KubernetesSecretClient abstracts Kubernetes Secret API calls for testing.

type KubernetesSecretResolver added in v0.16.0

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

KubernetesSecretResolver resolves secretRef values from Kubernetes Secrets.

func NewKubernetesSecretResolver added in v0.16.0

func NewKubernetesSecretResolver(clientset kubernetes.Interface, defaultKey string) *KubernetesSecretResolver

func NewKubernetesSecretResolverWithClient added in v0.16.0

func NewKubernetesSecretResolverWithClient(client KubernetesSecretClient, defaultKey string) *KubernetesSecretResolver

func (*KubernetesSecretResolver) Resolve added in v0.16.0

func (r *KubernetesSecretResolver) Resolve(ctx context.Context, secretRef string) (string, error)

func (*KubernetesSecretResolver) WithNamespace added in v0.16.0

func (r *KubernetesSecretResolver) WithNamespace(namespace string) SecretResolver

type KubernetesToolConfig added in v0.16.0

type KubernetesToolConfig struct {
	Namespace      string
	ServiceAccount string
	DefaultImage   string
	JobTTLSeconds  int32
}

KubernetesToolConfig holds operator-level defaults for the K8s tool runtime.

type KubernetesToolRuntime added in v0.16.0

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

KubernetesToolRuntime executes tools as ephemeral Kubernetes Jobs.

func NewKubernetesToolRuntime added in v0.16.0

func NewKubernetesToolRuntime(
	clientset kubernetes.Interface,
	config KubernetesToolConfig,
	secrets SecretResolver,
) *KubernetesToolRuntime

func NewKubernetesToolRuntimeWithClient added in v0.16.0

func NewKubernetesToolRuntimeWithClient(
	client KubernetesJobClient,
	config KubernetesToolConfig,
	secrets SecretResolver,
) *KubernetesToolRuntime

func (*KubernetesToolRuntime) Call added in v0.16.0

func (r *KubernetesToolRuntime) Call(ctx context.Context, tool string, input string) (string, error)

func (*KubernetesToolRuntime) WithNamespace added in v0.16.0

func (r *KubernetesToolRuntime) WithNamespace(namespace string) ToolRuntime

func (*KubernetesToolRuntime) WithRegistry added in v0.16.0

func (r *KubernetesToolRuntime) WithRegistry(registry ToolCapabilityRegistry) ToolRuntime

type MCPToolRuntime

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

MCPToolRuntime executes tool calls against MCP servers. It resolves the mcp_server_ref from the tool's ToolSpec, retrieves the session from the McpSessionManager, and delegates to tools/call.

func NewMCPToolRuntime

func NewMCPToolRuntime(
	registry ToolCapabilityRegistry,
	sessionManager *McpSessionManager,
	mcpServerStore McpServerLookup,
) *MCPToolRuntime

func (*MCPToolRuntime) Call

func (r *MCPToolRuntime) Call(ctx context.Context, tool string, input string) (string, error)

func (*MCPToolRuntime) WithNamespace

func (r *MCPToolRuntime) WithNamespace(namespace string) ToolRuntime

func (*MCPToolRuntime) WithRegistry

func (r *MCPToolRuntime) WithRegistry(registry ToolCapabilityRegistry) ToolRuntime

type Manager

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

Manager tracks and reconciles running workers.

func NewManager

func NewManager(logger *log.Logger) *Manager

func (*Manager) EnsureRunning

func (m *Manager) EnsureRunning(agent resources.Agent)

func (*Manager) IsRunning

func (m *Manager) IsRunning(name string) bool

func (*Manager) Logs

func (m *Manager) Logs(name string) []string

func (*Manager) RunningAgents

func (m *Manager) RunningAgents() []string

func (*Manager) Stop

func (m *Manager) Stop(name string)

type McpCapabilities

type McpCapabilities struct {
	Tools *McpToolCapability `json:"tools,omitempty"`
}

type McpContent

type McpContent struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

McpContent is one content block in a tool result.

type McpInitResult

type McpInitResult struct {
	ProtocolVersion string          `json:"protocolVersion"`
	ServerInfo      McpServerInfo   `json:"serverInfo"`
	Capabilities    McpCapabilities `json:"capabilities"`
}

McpInitResult captures the server's response to the initialize handshake.

type McpServerInfo

type McpServerInfo struct {
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
}

type McpServerLookup

type McpServerLookup interface {
	Get(ctx context.Context, name string) (resources.McpServer, bool, error)
}

McpServerLookup resolves McpServer resources by scoped name.

type McpSession

type McpSession struct {
	Transport  McpTransport
	InitResult *McpInitResult
	ServerName string
	// contains filtered or unexported fields
}

McpSession wraps one active connection to an MCP server.

type McpSessionManager

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

McpSessionManager maintains one session per McpServer, handling connection pooling, initialization, idle eviction, and graceful shutdown.

func NewMcpSessionManager

func NewMcpSessionManager(secretResolver SecretResolver) *McpSessionManager

func (*McpSessionManager) Close

func (m *McpSessionManager) Close()

Close shuts down all active sessions.

func (*McpSessionManager) GetOrCreate

func (m *McpSessionManager) GetOrCreate(ctx context.Context, server resources.McpServer) (*McpSession, error)

GetOrCreate returns an existing session or creates a new one for the given McpServer spec. Sessions are keyed by namespace/name. If the server's generation has changed since the cached session was created, the old session is torn down and a fresh one is built.

func (*McpSessionManager) Remove

func (m *McpSessionManager) Remove(server resources.McpServer)

Remove closes and removes the session for the given server.

func (*McpSessionManager) SetAllowedCommands

func (m *McpSessionManager) SetAllowedCommands(cmds []string)

SetAllowedCommands restricts the binaries that stdio MCP transports may execute. An empty list means "no restriction" (backwards-compatible). When set, only the basename (or full path) of spec.command must appear in the list for the transport to start.

func (*McpSessionManager) SetContainerConfig added in v0.7.0

func (m *McpSessionManager) SetContainerConfig(cfg ContainerToolRuntimeConfig)

SetContainerConfig sets the container runtime configuration used when McpServer resources specify spec.image for containerised stdio transport.

func (*McpSessionManager) StartReaper added in v0.7.0

func (m *McpSessionManager) StartReaper(ctx context.Context, interval time.Duration)

StartReaper runs a background goroutine that periodically evicts sessions whose idle time exceeds their configured idle_timeout. Sessions with idleTimeout == 0 are never evicted. The goroutine exits when ctx is done.

type McpToolCapability

type McpToolCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

type McpToolDefinition

type McpToolDefinition struct {
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	InputSchema map[string]any `json:"inputSchema,omitempty"`
}

McpToolDefinition describes one tool exposed by an MCP server via tools/list.

type McpToolResult

type McpToolResult struct {
	Content []McpContent `json:"content"`
	IsError bool         `json:"isError,omitempty"`
}

McpToolResult captures the response from a tools/call invocation.

func (*McpToolResult) McpTextResult

func (r *McpToolResult) McpTextResult() string

McpTextResult returns the concatenated text content of a tool result.

type McpTransport

type McpTransport interface {
	Initialize(ctx context.Context) (*McpInitResult, error)
	ListTools(ctx context.Context) ([]McpToolDefinition, error)
	CallTool(ctx context.Context, name string, arguments map[string]any) (*McpToolResult, error)
	Close() error
}

McpTransport abstracts the MCP JSON-RPC 2.0 communication layer. Implementations handle stdio (child process) and Streamable HTTP transports.

type MemoryAgentMessageBus

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

MemoryAgentMessageBus is an in-process runtime message bus for local dev/test.

func NewMemoryAgentMessageBus

func NewMemoryAgentMessageBus(subjectPrefix string, historyMax int, dedupeWindow time.Duration) *MemoryAgentMessageBus

func (*MemoryAgentMessageBus) Close

func (b *MemoryAgentMessageBus) Close() error

func (*MemoryAgentMessageBus) Consume

func (*MemoryAgentMessageBus) Publish

type MemoryManager

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

MemoryManager stores short-lived runtime memory for an agent worker.

func NewMemoryManager

func NewMemoryManager() *MemoryManager

func (*MemoryManager) Get

func (m *MemoryManager) Get(key string) (string, bool)

func (*MemoryManager) Put

func (m *MemoryManager) Put(key, value string)

func (*MemoryManager) Snapshot

func (m *MemoryManager) Snapshot() map[string]string

type MemoryProviderConfig

type MemoryProviderConfig struct {
	Type           string
	Provider       string
	EmbeddingModel string
	Endpoint       string
	AuthToken      string
	Options        map[string]string
	Embedder       EmbeddingProvider
}

MemoryProviderConfig holds the fields from a Memory CRD spec that a provider factory needs to construct a backend.

type MemoryProviderFactory

type MemoryProviderFactory func(cfg MemoryProviderConfig) (PersistentMemoryBackend, error)

MemoryProviderFactory creates a PersistentMemoryBackend from CRD config. Implementations should validate their own config and return a descriptive error if required fields are missing.

type MemoryProviderRegistry

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

MemoryProviderRegistry is a global registry of provider factories keyed by provider name (e.g. "pgvector", "qdrant", "weaviate"). Thread-safe.

func DefaultMemoryProviderRegistry

func DefaultMemoryProviderRegistry() *MemoryProviderRegistry

DefaultMemoryProviderRegistry returns the global provider registry. Use this to register custom vector database providers at startup.

func (*MemoryProviderRegistry) Create

Create looks up the factory for the given provider name and calls it. An empty provider name falls back to "in-memory".

func (*MemoryProviderRegistry) Providers

func (r *MemoryProviderRegistry) Providers() []string

Providers returns the sorted list of registered provider names.

func (*MemoryProviderRegistry) Register

func (r *MemoryProviderRegistry) Register(name string, factory MemoryProviderFactory)

Register adds a provider factory under the given name. Names are case-insensitive and trimmed. Registering the same name twice replaces the previous factory.

type MemoryResourceLookup

type MemoryResourceLookup interface {
	Get(ctx context.Context, name string) (resources.Memory, bool, error)
}

MemoryResourceLookup resolves Memory CRDs by name.

type MemorySearchResult

type MemorySearchResult struct {
	Key   string  `json:"key"`
	Value string  `json:"value"`
	Score float64 `json:"score,omitempty"`
}

MemorySearchResult is one entry returned by search or list.

type MemoryStore

type MemoryStore interface {
	Put(key, value string)
	Get(key string) (string, bool)
	Snapshot() map[string]string
}

MemoryStore stores short-lived agent working memory.

type MemoryToolRuntime

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

MemoryToolRuntime wraps a ToolRuntime and intercepts built-in memory tool calls. When a persistent backend is set, it takes priority over the ephemeral shared store.

func NewMemoryToolRuntime

func NewMemoryToolRuntime(delegate ToolRuntime, memory *SharedMemoryStore) *MemoryToolRuntime

func (*MemoryToolRuntime) Call

func (r *MemoryToolRuntime) Call(ctx context.Context, tool string, input string) (string, error)

func (*MemoryToolRuntime) WithPersistentBackend

func (r *MemoryToolRuntime) WithPersistentBackend(backend PersistentMemoryBackend) *MemoryToolRuntime

WithPersistentBackend returns a copy that delegates to the persistent backend.

type MeteringEvent

type MeteringEvent struct {
	Timestamp       string            `json:"timestamp"`
	Component       string            `json:"component,omitempty"`
	Type            string            `json:"type"`
	Namespace       string            `json:"namespace,omitempty"`
	Task            string            `json:"task,omitempty"`
	System          string            `json:"system,omitempty"`
	Agent           string            `json:"agent,omitempty"`
	Worker          string            `json:"worker,omitempty"`
	Attempt         int               `json:"attempt,omitempty"`
	MessageID       string            `json:"message_id,omitempty"`
	Status          string            `json:"status,omitempty"`
	TokensUsed      int               `json:"tokens_used,omitempty"`
	TokensEstimated int               `json:"tokens_estimated,omitempty"`
	ToolCalls       int               `json:"tool_calls,omitempty"`
	Metadata        map[string]string `json:"metadata,omitempty"`
}

MeteringEvent captures one normalized usage event for optional billing/usage sinks.

type MeteringSink

type MeteringSink interface {
	RecordMetering(ctx context.Context, event MeteringEvent)
}

MeteringSink receives metering events. Implementations should be non-blocking and resilient.

type MockModelGateway

type MockModelGateway struct{}

MockModelGateway is an in-process placeholder model adapter.

func (*MockModelGateway) Complete

type MockToolClient

type MockToolClient struct{}

MockToolClient is an in-process placeholder for external tool systems.

func (*MockToolClient) Call

func (m *MockToolClient) Call(_ context.Context, tool string, input string) (string, error)

type ModelEndpointLookup

type ModelEndpointLookup interface {
	Get(ctx context.Context, name string) (resources.ModelEndpoint, bool, error)
}

ModelEndpointLookup resolves namespaced ModelEndpoint resources.

type ModelGateway

type ModelGateway interface {
	Complete(ctx context.Context, req ModelRequest) (ModelResponse, error)
}

ModelGateway abstracts model-provider calls for agent execution.

func NewModelGatewayFromConfig

func NewModelGatewayFromConfig(cfg ModelGatewayConfig) (ModelGateway, error)

NewModelGatewayFromConfig returns a provider-backed model gateway.

type ModelGatewayConfig

type ModelGatewayConfig struct {
	Provider     string
	APIKey       string
	BaseURL      string
	DefaultModel string
	Options      map[string]string
	Timeout      time.Duration
	HTTPClient   *http.Client
	// AllowPrivate permits outbound gateway requests to trusted local/private
	// model endpoints, including loopback, RFC 1918 / ULA, and CGNAT
	// addresses. Only honored when HTTPClient is nil (otherwise the caller is
	// responsible for the supplied client's egress policy).
	AllowPrivate bool
}

ModelGatewayConfig configures a runtime model gateway provider.

func DefaultModelGatewayConfig

func DefaultModelGatewayConfig() ModelGatewayConfig

DefaultModelGatewayConfig returns conservative defaults that preserve existing behavior.

type ModelGatewayError

type ModelGatewayError struct {
	StatusCode int
	Provider   string
	Message    string
}

ModelGatewayError is returned by model gateways when the upstream provider returns an HTTP error. Callers can inspect StatusCode to distinguish transient failures (5xx, 429) from permanent ones (4xx).

func IsModelGatewayError

func IsModelGatewayError(err error) (gatewayErr *ModelGatewayError, retryable bool)

IsModelGatewayError returns the underlying *ModelGatewayError if err wraps one, along with a flag indicating whether the caller should retry.

func (*ModelGatewayError) Error

func (e *ModelGatewayError) Error() string

type ModelProviderPlugin

type ModelProviderPlugin interface {
	Name() string
	Aliases() []string
	RequiresAPIKey() bool
	BuildGateway(cfg ModelGatewayConfig) (ModelGateway, error)
}

ModelProviderPlugin builds model gateways for a provider family.

type ModelProviderRegistry

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

ModelProviderRegistry stores model provider plugins by name and alias.

func DefaultModelProviderRegistry

func DefaultModelProviderRegistry() *ModelProviderRegistry

func NewModelProviderRegistry

func NewModelProviderRegistry() *ModelProviderRegistry

func (*ModelProviderRegistry) Lookup

func (r *ModelProviderRegistry) Lookup(provider string) (ModelProviderPlugin, bool)

func (*ModelProviderRegistry) Register

func (r *ModelProviderRegistry) Register(plugin ModelProviderPlugin) error

type ModelRequest

type ModelRequest struct {
	Model             string
	ModelRef          string
	FallbackModelRefs []string
	Namespace         string
	Agent             string
	Prompt            string
	Step              int
	Tools             []string
	ToolSchemas       map[string]ToolSchemaInfo
	Context           map[string]string
	Messages          []ChatMessage
	OutputSchema      map[string]any
}

ModelRequest defines one model inference request for an agent step.

type ModelResponse

type ModelResponse struct {
	Content   string
	Done      bool
	ToolCalls []ModelToolCall
	Usage     ModelUsage
}

ModelResponse captures model output used by the runtime loop.

type ModelRouter

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

ModelRouter routes model requests to ModelEndpoint-backed gateways by ModelRequest.ModelRef.

func NewModelRouter

func NewModelRouter(cfg ModelRouterConfig) *ModelRouter

func (*ModelRouter) Complete

func (r *ModelRouter) Complete(ctx context.Context, req ModelRequest) (ModelResponse, error)

type ModelRouterConfig

type ModelRouterConfig struct {
	Endpoints       ModelEndpointLookup
	Secrets         SecretResourceLookup
	SecretEnvPrefix string
}

ModelRouterConfig configures model routing via ModelEndpoint resources.

type ModelToolCall

type ModelToolCall struct {
	ID           string
	Name         string
	Input        string
	ProviderName string
}

ModelToolCall is one model-selected tool invocation request.

type ModelUsage

type ModelUsage struct {
	InputTokens  int
	OutputTokens int
	TotalTokens  int
	Source       string
}

ModelUsage captures provider-reported or estimated token usage for one model call.

type ModuleSource added in v0.11.0

type ModuleSource int

ModuleSource classifies a module reference string.

const (
	ModuleSourceLocal ModuleSource = iota
	ModuleSourceHTTPS
	ModuleSourceOCI
)

func ClassifyModuleRef added in v0.11.0

func ClassifyModuleRef(ref string) ModuleSource

ClassifyModuleRef determines the source type of a module reference.

type NATSJetStreamAgentMessageBus

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

NATSJetStreamAgentMessageBus is a durable runtime message bus backed by JetStream.

func NewNATSJetStreamAgentMessageBus

func NewNATSJetStreamAgentMessageBus(url string, subjectPrefix string, streamName string, logger *log.Logger) (*NATSJetStreamAgentMessageBus, error)

func (*NATSJetStreamAgentMessageBus) Close

func (*NATSJetStreamAgentMessageBus) Consume

func (*NATSJetStreamAgentMessageBus) Publish

type OAuth2TokenCache

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

OAuth2TokenCache caches access tokens obtained via the client_credentials grant. Tokens are keyed by tokenURL+clientID and evicted on expiry or explicit eviction.

func NewOAuth2TokenCache

func NewOAuth2TokenCache(client HTTPDoer) *OAuth2TokenCache

func (*OAuth2TokenCache) Evict

func (c *OAuth2TokenCache) Evict(tokenURL, clientID string)

Evict removes a cached token, forcing a fresh exchange on next GetToken.

func (*OAuth2TokenCache) GetToken

func (c *OAuth2TokenCache) GetToken(ctx context.Context, tokenURL, clientID, clientSecret, scope string) (string, error)

GetToken returns a cached access token if valid, or performs a fresh exchange.

type OCIArtifactPuller added in v0.11.0

type OCIArtifactPuller interface {
	Pull(ctx context.Context, ref string, destPath string, auth *OCIAuth) error
}

OCIArtifactPuller abstracts OCI artifact pulls so callers can inject a real oras-go implementation or a test double.

type OCIAuth added in v0.11.0

type OCIAuth struct {
	Username string
	Password string
}

OCIAuth carries credentials for authenticating to a private OCI registry.

type OllamaModelGateway

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

OllamaModelGateway calls Ollama's /api/chat endpoint.

func NewOllamaModelGateway

func NewOllamaModelGateway(cfg OllamaModelGatewayConfig) (*OllamaModelGateway, error)

func (*OllamaModelGateway) Complete

type OllamaModelGatewayConfig

type OllamaModelGatewayConfig struct {
	BaseURL      string
	DefaultModel string
	Timeout      time.Duration
	HTTPClient   *http.Client
}

OllamaModelGatewayConfig defines Ollama chat settings.

func DefaultOllamaModelGatewayConfig

func DefaultOllamaModelGatewayConfig() OllamaModelGatewayConfig

DefaultOllamaModelGatewayConfig returns Ollama gateway defaults.

type OpenAIEmbeddingProvider

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

OpenAIEmbeddingProvider calls an OpenAI-compatible /embeddings endpoint. Works with OpenAI, Azure OpenAI, Ollama, and any compatible API.

func NewOpenAIEmbeddingProvider

func NewOpenAIEmbeddingProvider(baseURL, apiKey, model string) *OpenAIEmbeddingProvider

func (*OpenAIEmbeddingProvider) Dimensions

func (p *OpenAIEmbeddingProvider) Dimensions() int

func (*OpenAIEmbeddingProvider) Embed

func (p *OpenAIEmbeddingProvider) Embed(ctx context.Context, texts []string) ([][]float32, error)

type OpenAIModelGateway

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

OpenAIModelGateway calls an OpenAI-compatible Chat Completions endpoint.

func NewOpenAIModelGateway

func NewOpenAIModelGateway(cfg OpenAIModelGatewayConfig) (*OpenAIModelGateway, error)

func (*OpenAIModelGateway) Complete

type OpenAIModelGatewayConfig

type OpenAIModelGatewayConfig struct {
	APIKey        string
	RequireAPIKey bool
	BaseURL       string
	DefaultModel  string
	Timeout       time.Duration
	HTTPClient    *http.Client
}

OpenAIModelGatewayConfig defines OpenAI-compatible model gateway settings.

func DefaultOpenAIModelGatewayConfig

func DefaultOpenAIModelGatewayConfig() OpenAIModelGatewayConfig

DefaultOpenAIModelGatewayConfig returns OpenAI gateway defaults.

type OrlojTaskStore added in v0.6.0

type OrlojTaskStore interface {
	Get(ctx context.Context, name string) (resources.Task, bool, error)
	Upsert(ctx context.Context, item resources.Task) (resources.Task, error)
	ListPaged(ctx context.Context, limit, offset int, namespace string) ([]resources.Task, error)
}

OrlojTaskStore is the subset of store.TaskStore used by OrlojToolRuntime.

type OrlojToolConfig added in v0.6.0

type OrlojToolConfig struct {
	ParentNamespace string
	ParentTaskName  string
	CurrentDepth    int
	MaxDepth        int
	MaxChildren     int
}

OrlojToolConfig holds policy-derived limits for the orloj tool runtime.

type OrlojToolRuntime added in v0.6.0

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

OrlojToolRuntime wraps a ToolRuntime and intercepts built-in orloj tool calls.

func NewOrlojToolRuntime added in v0.6.0

func NewOrlojToolRuntime(delegate ToolRuntime, taskStore OrlojTaskStore, config OrlojToolConfig) *OrlojToolRuntime

func (*OrlojToolRuntime) Call added in v0.6.0

func (r *OrlojToolRuntime) Call(ctx context.Context, tool string, input string) (string, error)

type PersistentMemoryBackend

type PersistentMemoryBackend interface {
	Put(ctx context.Context, key, value string) error
	Get(ctx context.Context, key string) (string, bool, error)
	Search(ctx context.Context, query string, topK int) ([]MemorySearchResult, error)
	List(ctx context.Context, prefix string) ([]MemorySearchResult, error)
	Ping(ctx context.Context) error
}

PersistentMemoryBackend defines the interface for durable memory stores that persist across task runs. Implementations are selected based on the Memory CRD's spec.type and spec.provider fields.

func NewPersistentMemoryBackendFromConfig

func NewPersistentMemoryBackendFromConfig(memType, provider, embeddingModel string) (PersistentMemoryBackend, error)

NewPersistentMemoryBackendFromConfig creates a backend using the global provider registry. This is the primary entry point used by the controller.

type PersistentMemoryBackendRegistry

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

PersistentMemoryBackendRegistry manages named persistent backends keyed by Memory CRD name.

func NewPersistentMemoryBackendRegistry

func NewPersistentMemoryBackendRegistry() *PersistentMemoryBackendRegistry

func (*PersistentMemoryBackendRegistry) Get

func (*PersistentMemoryBackendRegistry) Register

type PgvectorBackend

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

PgvectorBackend implements PersistentMemoryBackend using PostgreSQL with the pgvector extension. Entries are stored with their vector embeddings, enabling cosine-similarity search.

func NewPgvectorBackend

func NewPgvectorBackend(dsn string, embedder EmbeddingProvider, opts PgvectorOptions) (*PgvectorBackend, error)

NewPgvectorBackend connects to the database, detects the embedding dimension (if not overridden), installs the vector extension, and creates the table with an HNSW index.

func (*PgvectorBackend) Get

func (b *PgvectorBackend) Get(ctx context.Context, key string) (string, bool, error)

func (*PgvectorBackend) List

func (b *PgvectorBackend) List(ctx context.Context, prefix string) ([]MemorySearchResult, error)

func (*PgvectorBackend) Ping

func (b *PgvectorBackend) Ping(ctx context.Context) error

func (*PgvectorBackend) Put

func (b *PgvectorBackend) Put(ctx context.Context, key, value string) error

func (*PgvectorBackend) Search

func (b *PgvectorBackend) Search(ctx context.Context, queryText string, topK int) ([]MemorySearchResult, error)

type PgvectorOptions

type PgvectorOptions struct {
	Table     string // table name, default "orloj_memory"
	Dimension int    // vector dimension override; auto-detected when 0
}

PgvectorOptions configures optional behaviour of the pgvector backend.

type ReActExecutionEngine

type ReActExecutionEngine struct {
	OnStepEvent func(AgentStepEvent)
	// contains filtered or unexported fields
}

ReActExecutionEngine is the default runtime engine: model call + optional tool actions in bounded steps.

func NewReActExecutionEngine

func NewReActExecutionEngine(
	toolRuntime ToolRuntime,
	modelGateway ModelGateway,
	newMemoryStore func() MemoryStore,
	stepEvery time.Duration,
) *ReActExecutionEngine

func (*ReActExecutionEngine) Execute

type RegistryAuthResolver added in v0.10.2

type RegistryAuthResolver func(ctx context.Context, resolver SecretResolver, secretRef string) (*registryCredentials, error)

RegistryAuthResolver is an optional hook for resolving image pull secrets into temporary Docker config directories. When nil, the manager resolves secrets using its own secretResolver.

type RetryRequestError

type RetryRequestError struct {
	Delay time.Duration
	Err   error
}

RetryRequestError instructs the message bus consumer to requeue after a delay.

func (*RetryRequestError) Error

func (e *RetryRequestError) Error() string

func (*RetryRequestError) Unwrap

func (e *RetryRequestError) Unwrap() error

type ReviewRequestPayload added in v0.10.0

type ReviewRequestPayload struct {
	Content        string `json:"content,omitempty"`
	Feedback       string `json:"feedback,omitempty"`
	PreviousOutput string `json:"previous_output,omitempty"`
	CheckpointID   string `json:"checkpoint_id,omitempty"`
	Cycle          int    `json:"cycle,omitempty"`
	RequestedBy    string `json:"requested_by,omitempty"`
	Supersedes     string `json:"supersedes,omitempty"`
}

func DecodeReviewRequestPayload added in v0.10.0

func DecodeReviewRequestPayload(raw string) (ReviewRequestPayload, bool)

type SecretResolver

type SecretResolver interface {
	Resolve(ctx context.Context, secretRef string) (string, error)
}

SecretResolver resolves tool auth secret references.

type SecretResourceLookup

type SecretResourceLookup interface {
	Get(ctx context.Context, name string) (resources.Secret, bool, error)
}

type SharedMemoryStore

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

SharedMemoryStore is a thread-safe key-value store shared across agents in a task.

func NewSharedMemoryStore

func NewSharedMemoryStore() *SharedMemoryStore

func (*SharedMemoryStore) Get

func (s *SharedMemoryStore) Get(key string) (string, bool)

func (*SharedMemoryStore) List

func (s *SharedMemoryStore) List(prefix string) []memoryEntry

func (*SharedMemoryStore) Put

func (s *SharedMemoryStore) Put(key, value string)

func (*SharedMemoryStore) Search

func (s *SharedMemoryStore) Search(query string, topK int) []memoryEntry

func (*SharedMemoryStore) Snapshot

func (s *SharedMemoryStore) Snapshot() map[string]string

type StaticToolCapabilityRegistry

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

StaticToolCapabilityRegistry stores tool policies in-memory for runtime checks.

func NewStaticToolCapabilityRegistry

func NewStaticToolCapabilityRegistry(specs map[string]resources.ToolSpec) *StaticToolCapabilityRegistry

func NewToolCapabilityRegistryFromTools

func NewToolCapabilityRegistryFromTools(tools []resources.Tool) *StaticToolCapabilityRegistry

func (*StaticToolCapabilityRegistry) Resolve

type StdioMcpTransport

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

StdioMcpTransport communicates with an MCP server via a child process's stdin/stdout using newline-delimited JSON-RPC 2.0 messages.

func NewStdioMcpTransport

func NewStdioMcpTransport(cfg StdioMcpTransportConfig) *StdioMcpTransport

func (*StdioMcpTransport) CallTool

func (t *StdioMcpTransport) CallTool(ctx context.Context, name string, arguments map[string]any) (*McpToolResult, error)

func (*StdioMcpTransport) Close

func (t *StdioMcpTransport) Close() error

func (*StdioMcpTransport) Initialize

func (t *StdioMcpTransport) Initialize(ctx context.Context) (*McpInitResult, error)

func (*StdioMcpTransport) ListTools

func (t *StdioMcpTransport) ListTools(ctx context.Context) ([]McpToolDefinition, error)

type StdioMcpTransportConfig

type StdioMcpTransportConfig struct {
	Command string
	Args    []string
	Env     []string
	OnClose func() // optional callback invoked after the process is killed
}

StdioMcpTransportConfig configures the child process to spawn.

type StoreSecretResolver

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

func NewStoreSecretResolver

func NewStoreSecretResolver(lookup SecretResourceLookup, defaultKey string) *StoreSecretResolver

func (*StoreSecretResolver) Resolve

func (r *StoreSecretResolver) Resolve(ctx context.Context, secretRef string) (string, error)

func (*StoreSecretResolver) WithNamespace

func (r *StoreSecretResolver) WithNamespace(namespace string) SecretResolver

type StreamableHTTPMcpTransport

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

StreamableHTTPMcpTransport communicates with an MCP server over HTTP using the Streamable HTTP transport (JSON-RPC 2.0 over POST).

func (*StreamableHTTPMcpTransport) CallTool

func (t *StreamableHTTPMcpTransport) CallTool(ctx context.Context, name string, arguments map[string]any) (*McpToolResult, error)

func (*StreamableHTTPMcpTransport) Close

func (t *StreamableHTTPMcpTransport) Close() error

func (*StreamableHTTPMcpTransport) Initialize

func (*StreamableHTTPMcpTransport) ListTools

type StreamableHTTPMcpTransportConfig

type StreamableHTTPMcpTransportConfig struct {
	Endpoint     string
	Headers      map[string]string
	Client       HTTPDoer
	AllowPrivate bool // permit connections to private/internal IPs
}

StreamableHTTPMcpTransportConfig configures the HTTP transport.

type TaskApprovalUpserter added in v0.10.0

type TaskApprovalUpserter interface {
	Upsert(ctx context.Context, item resources.TaskApproval) (resources.TaskApproval, error)
	Get(ctx context.Context, key string) (resources.TaskApproval, bool, error)
}

type TaskExecutor

type TaskExecutor struct {
	OnStepEvent func(AgentStepEvent)
	// contains filtered or unexported fields
}

TaskExecutor runs agents on-demand for Task execution.

func NewTaskExecutor

func NewTaskExecutor(logger *log.Logger) *TaskExecutor

func NewTaskExecutorWithRuntime

func NewTaskExecutorWithRuntime(
	logger *log.Logger,
	toolRuntime ToolRuntime,
	modelGateway ModelGateway,
	newMemoryStore func() MemoryStore,
) *TaskExecutor

func (*TaskExecutor) ExecuteAgent

func (e *TaskExecutor) ExecuteAgent(ctx context.Context, agent resources.Agent, input map[string]string) (AgentExecutionResult, error)

func (*TaskExecutor) ExecuteAgentWithRuntime

func (e *TaskExecutor) ExecuteAgentWithRuntime(
	ctx context.Context,
	agent resources.Agent,
	input map[string]string,
	override ToolRuntime,
) (AgentExecutionResult, error)

type TaskStateStore

type TaskStateStore interface {
	Get(ctx context.Context, name string) (resources.Task, bool, error)
	Upsert(ctx context.Context, item resources.Task) (resources.Task, error)
	AppendLog(ctx context.Context, name, message string) error
}

TaskStateStore stores task status updates produced by message consumers.

type ToolApprovalRequiredError added in v0.13.0

type ToolApprovalRequiredError struct {
	Tool   string
	Input  string
	Reason string
}

ToolApprovalRequiredError is a structured error carrying the tool name, input arguments, and policy reason when approval is required.

func (*ToolApprovalRequiredError) Error added in v0.13.0

func (e *ToolApprovalRequiredError) Error() string

func (*ToolApprovalRequiredError) Unwrap added in v0.13.0

func (e *ToolApprovalRequiredError) Unwrap() error

type ToolApprovalUpserter

type ToolApprovalUpserter interface {
	Upsert(ctx context.Context, item resources.ToolApproval) (resources.ToolApproval, error)
	Get(ctx context.Context, key string) (resources.ToolApproval, bool, error)
}

ToolApprovalUpserter persists ToolApproval resources when a governed tool requires approval.

type ToolBackedContextAdapter added in v0.12.0

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

ToolBackedContextAdapter runs a sanitization Tool against raw task input.

func NewToolBackedContextAdapter added in v0.12.0

func NewToolBackedContextAdapter(
	spec resources.ContextAdapterSpec,
	toolRuntime ToolRuntime,
) *ToolBackedContextAdapter

NewToolBackedContextAdapter builds a hook backed by ToolRuntime.Call(spec.ToolRef, JSON payload).

func (*ToolBackedContextAdapter) AdaptContext added in v0.12.0

func (c *ToolBackedContextAdapter) AdaptContext(ctx context.Context, input map[string]string) (map[string]string, error)

AdaptContext JSON-encodes input, calls the tool, and decodes the JSON output.

type ToolCallAuthorizer

type ToolCallAuthorizer interface {
	Authorize(tool string, spec resources.ToolSpec) (*AuthorizeResult, error)
}

func NewAuthorizerWithApprovedToolGrant

func NewAuthorizerWithApprovedToolGrant(inner ToolCallAuthorizer, getter func(key string) (resources.ToolApproval, bool, error), taskKey, messageID string) ToolCallAuthorizer

NewAuthorizerWithApprovedToolGrant wraps inner (typically AgentToolAuthorizer). When inner requires approval, it allows the call if the ToolApproval row for (taskKey, messageID) is Approved and its spec.tool matches the requested tool.

type ToolCapabilityRegistry

type ToolCapabilityRegistry interface {
	Resolve(tool string) (resources.ToolSpec, bool)
}

ToolCapabilityRegistry resolves runtime policy/capability metadata for tools.

type ToolClient

type ToolClient = ToolRuntime

ToolClient is kept as a compatibility alias.

type ToolContractExecutor

type ToolContractExecutor interface {
	Execute(ctx context.Context, req ToolExecutionRequest) (ToolExecutionResponse, error)
}

ToolContractExecutor executes tools against the v1 tool request/response contract.

func NewToolContractExecutor

func NewToolContractExecutor(runtime ToolRuntime) ToolContractExecutor

type ToolError

type ToolError struct {
	Status    string
	Code      string
	Reason    string
	Retryable bool
	Message   string
	Details   map[string]string
	Cause     error
}

ToolError is the canonical runtime tool error envelope. It is serialized into deterministic message text so controllers/UI can parse stable fields.

func AsToolError

func AsToolError(err error) (*ToolError, bool)

func (*ToolError) Error

func (e *ToolError) Error() string

func (*ToolError) Unwrap

func (e *ToolError) Unwrap() error

type ToolExecutionAuth

type ToolExecutionAuth struct {
	Profile   string   `json:"profile,omitempty"`
	SecretRef string   `json:"secret_ref,omitempty"`
	Scopes    []string `json:"scopes,omitempty"`
}

type ToolExecutionFailure

type ToolExecutionFailure struct {
	Code      string            `json:"code,omitempty"`
	Reason    string            `json:"reason,omitempty"`
	Retryable bool              `json:"retryable"`
	Message   string            `json:"message,omitempty"`
	Details   map[string]string `json:"details,omitempty"`
}

type ToolExecutionOutput

type ToolExecutionOutput struct {
	Result string `json:"result,omitempty"`
}

type ToolExecutionRequest

type ToolExecutionRequest struct {
	ToolContractVersion string                    `json:"tool_contract_version,omitempty"`
	RequestID           string                    `json:"request_id,omitempty"`
	TaskID              string                    `json:"task_id,omitempty"`
	Namespace           string                    `json:"namespace,omitempty"`
	Agent               string                    `json:"agent,omitempty"`
	Tool                ToolExecutionRequestTool  `json:"tool,omitempty"`
	Input               map[string]string         `json:"input,omitempty"`
	InputRaw            string                    `json:"input_raw,omitempty"`
	Runtime             ToolExecutionRuntime      `json:"runtime,omitempty"`
	Auth                ToolExecutionAuth         `json:"auth,omitempty"`
	Trace               ToolExecutionTraceContext `json:"trace,omitempty"`
	Attempt             int                       `json:"attempt,omitempty"`
}

ToolExecutionRequest is the strict runtime contract envelope for one tool call.

func NormalizeToolExecutionRequest

func NormalizeToolExecutionRequest(req ToolExecutionRequest) (ToolExecutionRequest, error)

func (ToolExecutionRequest) EncodedInput

func (r ToolExecutionRequest) EncodedInput() (string, error)

type ToolExecutionRequestTool

type ToolExecutionRequestTool struct {
	Name         string   `json:"name,omitempty"`
	Operation    string   `json:"operation,omitempty"`
	Capabilities []string `json:"capabilities,omitempty"`
	RiskLevel    string   `json:"risk_level,omitempty"`
}

type ToolExecutionResponse

type ToolExecutionResponse struct {
	ToolContractVersion string                    `json:"tool_contract_version,omitempty"`
	RequestID           string                    `json:"request_id,omitempty"`
	Status              string                    `json:"status,omitempty"`
	Output              ToolExecutionOutput       `json:"output,omitempty"`
	Usage               ToolExecutionUsage        `json:"usage,omitempty"`
	Trace               ToolExecutionTraceContext `json:"trace,omitempty"`
	Error               *ToolExecutionFailure     `json:"error,omitempty"`
}

func (ToolExecutionResponse) ToError

func (r ToolExecutionResponse) ToError() error

type ToolExecutionRuntime

type ToolExecutionRuntime struct {
	Mode         string `json:"mode,omitempty"`
	TimeoutMS    int    `json:"timeout_ms,omitempty"`
	MaxAttempts  int    `json:"max_attempts,omitempty"`
	Backoff      string `json:"backoff,omitempty"`
	MaxBackoffMS int    `json:"max_backoff_ms,omitempty"`
	Jitter       bool   `json:"jitter,omitempty"`
}

type ToolExecutionTraceContext

type ToolExecutionTraceContext struct {
	TraceID string `json:"trace_id,omitempty"`
	SpanID  string `json:"span_id,omitempty"`
}

type ToolExecutionUsage

type ToolExecutionUsage struct {
	DurationMS int64 `json:"duration_ms,omitempty"`
	Attempt    int   `json:"attempt,omitempty"`
}

type ToolIsolationBackendFactory

type ToolIsolationBackendFactory func(options ToolIsolationBackendOptions) (ToolRuntime, error)

type ToolIsolationBackendOptions

type ToolIsolationBackendOptions struct {
	Mode                string
	ContainerConfig     ContainerToolRuntimeConfig
	SecretResolver      SecretResolver
	WASMConfig          WASMToolRuntimeConfig
	WASMExecutorFactory WASMToolExecutorFactory
	McpSessionManager   *McpSessionManager
	McpServerStore      McpServerLookup
	KubernetesConfig    KubernetesToolConfig
}

type ToolIsolationBackendRegistry

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

ToolIsolationBackendRegistry resolves isolated runtime backends by mode. New backends can be registered without editing core switch logic.

func DefaultToolIsolationBackendRegistry

func DefaultToolIsolationBackendRegistry() *ToolIsolationBackendRegistry

func NewToolIsolationBackendRegistry

func NewToolIsolationBackendRegistry() *ToolIsolationBackendRegistry

func (*ToolIsolationBackendRegistry) Build

func (*ToolIsolationBackendRegistry) Modes

func (r *ToolIsolationBackendRegistry) Modes() []string

func (*ToolIsolationBackendRegistry) Register

type ToolPermissionLookup

type ToolPermissionLookup interface {
	List(ctx context.Context) ([]resources.ToolPermission, error)
}

type ToolResourceLookup

type ToolResourceLookup interface {
	Get(ctx context.Context, name string) (resources.Tool, bool, error)
}

ToolResourceLookup resolves Tool CRDs by name (optionally namespace scoped).

type ToolRuntime

type ToolRuntime interface {
	Call(ctx context.Context, tool string, input string) (string, error)
}

ToolRuntime executes external tool calls for agents.

func BuildGovernedToolRuntimeForAgent

func BuildGovernedToolRuntimeForAgent(
	ctx context.Context,
	baseRuntime ToolRuntime,
	isolatedRuntime ToolRuntime,
	lookup ToolResourceLookup,
	namespace string,
	toolNames []string,
) ToolRuntime

BuildGovernedToolRuntimeForAgent resolves tool policies for one agent in a namespace. Missing registry entries are treated as unsupported at call time when strict mode is enabled.

func BuildGovernedToolRuntimeForAgentWithGovernance

func BuildGovernedToolRuntimeForAgentWithGovernance(
	ctx context.Context,
	baseRuntime ToolRuntime,
	isolatedRuntime ToolRuntime,
	toolLookup ToolResourceLookup,
	roleLookup AgentRoleLookup,
	permissionLookup ToolPermissionLookup,
	namespace string,
	agent resources.Agent,
	approvalCtx *GovernedToolApprovalContext,
) ToolRuntime

func BuildSanitizerToolRuntime added in v0.12.0

func BuildSanitizerToolRuntime(
	ctx context.Context,
	namespace string,
	toolRef string,
	tools ToolResourceLookup,
	isolated ToolRuntime,
	wasmRT ToolRuntime,
	secretResolver SecretResolver,
	cliConfig CLIToolRuntimeConfig,
	mcpMgr *McpSessionManager,
	mcpStore McpServerLookup,
) (ToolRuntime, error)

BuildSanitizerToolRuntime constructs a governed tool runtime wired like agent execution, scoped to exactly one Tool name (used for ContextAdapter sanitization tools).

func BuildToolIsolationRuntime

func BuildToolIsolationRuntime(options ToolIsolationBackendOptions) (ToolRuntime, error)

type ToolSchemaInfo

type ToolSchemaInfo struct {
	Description string
	InputSchema map[string]any
}

ToolSchemaInfo carries optional description and JSON Schema for a tool. When present, model gateways use these instead of the generic fallback.

type ToolSchemaResolver

type ToolSchemaResolver interface {
	ResolveToolSchemas(toolNames []string) map[string]ToolSchemaInfo
}

ToolSchemaResolver resolves rich tool schemas for model gateway formatting. Implementations that wrap tool registries (e.g. GovernedToolRuntime) can provide per-tool descriptions and JSON Schemas to the LLM.

type UnsupportedIsolatedToolRuntime

type UnsupportedIsolatedToolRuntime struct{}

UnsupportedIsolatedToolRuntime fails closed when isolation is required but no sandbox executor is wired.

func (*UnsupportedIsolatedToolRuntime) Call

type WASMModuleResolver added in v0.11.0

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

WASMModuleResolver resolves a module reference (local path, HTTPS URL, or OCI artifact reference) to a local filesystem path. Remote modules are cached on disk keyed by SHA-256 of the reference string.

func NewWASMModuleResolver added in v0.11.0

func NewWASMModuleResolver(cfg WASMModuleResolverConfig) (*WASMModuleResolver, error)

NewWASMModuleResolver creates a resolver that can fetch WASM modules from local paths, HTTPS URLs, or OCI registries.

func (*WASMModuleResolver) Resolve added in v0.11.0

func (r *WASMModuleResolver) Resolve(ctx context.Context, moduleRef string, imagePullSecret string) (string, error)

Resolve returns a local filesystem path for the given module reference. For local paths it returns as-is; for HTTPS URLs and OCI refs it fetches and caches the module on disk.

func (*WASMModuleResolver) SourceLabel added in v0.11.0

func (r *WASMModuleResolver) SourceLabel(moduleRef string) string

SourceLabel returns a label suitable for metrics/logging.

type WASMModuleResolverConfig added in v0.11.0

type WASMModuleResolverConfig struct {
	CacheDir       string
	AllowPrivate   bool
	SecretResolver SecretResolver
	OCIPuller      OCIArtifactPuller
}

WASMModuleResolverConfig holds configuration for the module resolver.

type WASMToolExecuteRequest

type WASMToolExecuteRequest struct {
	Namespace       string
	Tool            string
	Input           string
	Capabilities    []string
	RiskLevel       string
	Runtime         WASMToolRuntimeConfig
	AuthProfile     string
	AuthHeaders     map[string]string
	ImagePullSecret string
}

WASMToolExecuteRequest is the portable execution envelope used by wasm executors.

type WASMToolExecuteResponse

type WASMToolExecuteResponse struct {
	Output string
}

type WASMToolExecutor

type WASMToolExecutor interface {
	Execute(ctx context.Context, req WASMToolExecuteRequest) (WASMToolExecuteResponse, error)
}

WASMToolExecutor is a pluggable wasm execution adapter.

type WASMToolExecutorFactory

type WASMToolExecutorFactory interface {
	Build(ctx context.Context, cfg WASMToolRuntimeConfig) (WASMToolExecutor, error)
}

WASMToolExecutorFactory creates wasm executors from runtime config.

type WASMToolModuleReqAuth

type WASMToolModuleReqAuth struct {
	Profile string            `json:"profile,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
}

type WASMToolModuleReqRuntime

type WASMToolModuleReqRuntime struct {
	Entrypoint     string `json:"entrypoint,omitempty"`
	MaxMemoryBytes int64  `json:"max_memory_bytes,omitempty"`
	Fuel           uint64 `json:"fuel,omitempty"`
	EnableWASI     bool   `json:"enable_wasi"`
}

type WASMToolModuleRequest

type WASMToolModuleRequest struct {
	ContractVersion string                   `json:"contract_version,omitempty"`
	Namespace       string                   `json:"namespace,omitempty"`
	Tool            string                   `json:"tool,omitempty"`
	Input           string                   `json:"input,omitempty"`
	Capabilities    []string                 `json:"capabilities,omitempty"`
	RiskLevel       string                   `json:"risk_level,omitempty"`
	Runtime         WASMToolModuleReqRuntime `json:"runtime,omitempty"`
	Auth            WASMToolModuleReqAuth    `json:"auth,omitempty"`
}

type WASMToolModuleResponse

type WASMToolModuleResponse struct {
	ContractVersion string                `json:"contract_version,omitempty"`
	Status          string                `json:"status,omitempty"`
	Output          string                `json:"output,omitempty"`
	Error           *ToolExecutionFailure `json:"error,omitempty"`
}

func DecodeWASMToolModuleResponse

func DecodeWASMToolModuleResponse(raw string) (WASMToolModuleResponse, error)

type WASMToolRuntime

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

WASMToolRuntime is a scaffold runtime for wasm-backed tool execution.

func NewWASMToolRuntime

func NewWASMToolRuntime(registry ToolCapabilityRegistry, executor WASMToolExecutor) *WASMToolRuntime

func NewWASMToolRuntimeWithFactory

func NewWASMToolRuntimeWithFactory(
	registry ToolCapabilityRegistry,
	factory WASMToolExecutorFactory,
	config WASMToolRuntimeConfig,
) *WASMToolRuntime

func (*WASMToolRuntime) Call

func (r *WASMToolRuntime) Call(ctx context.Context, tool string, input string) (string, error)

func (*WASMToolRuntime) WithConfig

func (r *WASMToolRuntime) WithConfig(config WASMToolRuntimeConfig) *WASMToolRuntime

func (*WASMToolRuntime) WithNamespace

func (r *WASMToolRuntime) WithNamespace(namespace string) ToolRuntime

func (*WASMToolRuntime) WithRegistry

func (r *WASMToolRuntime) WithRegistry(registry ToolCapabilityRegistry) ToolRuntime

type WASMToolRuntimeConfig

type WASMToolRuntimeConfig struct {
	ModulePath     string
	Entrypoint     string
	MaxMemoryBytes int64
	Fuel           uint64
	EnableWASI     bool
}

func DefaultWASMToolRuntimeConfig

func DefaultWASMToolRuntimeConfig() WASMToolRuntimeConfig

type WazeroExecutor added in v0.11.0

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

WazeroExecutor runs WASM tool modules in-process using the wazero runtime. Compiled modules are cached by module reference to avoid redundant compilation.

func NewWazeroExecutor added in v0.11.0

func NewWazeroExecutor(engine wazero.Runtime) *WazeroExecutor

NewWazeroExecutor wraps an existing wazero.Runtime with a compilation cache.

func (*WazeroExecutor) Close added in v0.11.0

func (e *WazeroExecutor) Close(ctx context.Context) error

Close releases all cached compiled modules and the underlying engine.

func (*WazeroExecutor) Execute added in v0.11.0

Execute runs a WASM tool module and returns its output via the stdin/stdout JSON contract.

func (*WazeroExecutor) SetModuleResolver added in v0.11.0

func (e *WazeroExecutor) SetModuleResolver(resolver *WASMModuleResolver)

SetModuleResolver attaches a module resolver for remote (HTTPS/OCI) modules.

type WazeroExecutorFactory added in v0.11.0

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

WazeroExecutorFactory builds WazeroExecutor instances backed by a shared wazero.Runtime engine.

func NewWazeroExecutorFactory added in v0.11.0

func NewWazeroExecutorFactory(engine wazero.Runtime) *WazeroExecutorFactory

NewWazeroExecutorFactory creates a factory that produces executors sharing a single wazero.Runtime.

func NewWazeroExecutorFactoryWithResolver added in v0.11.0

func NewWazeroExecutorFactoryWithResolver(engine wazero.Runtime, resolver *WASMModuleResolver) *WazeroExecutorFactory

NewWazeroExecutorFactoryWithResolver creates a factory with an attached module resolver for remote (HTTPS/OCI) WASM modules.

func (*WazeroExecutorFactory) Build added in v0.11.0

Build returns the shared WazeroExecutor (module path is per-request, not per-build).

type WebhookCallbackToolRuntime

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

WebhookCallbackToolRuntime implements an async tool pattern: fire a ToolExecutionRequest to the tool endpoint, then poll a callback URL (or the same endpoint with the request ID) until a ToolExecutionResponse arrives or the context times out.

Flow:

  1. POST ToolExecutionRequest to Tool.spec.endpoint
  2. Receive 202 Accepted (or 200 with immediate result)
  3. If 202: poll GET {endpoint}/{request_id} until status != "pending"

func NewWebhookCallbackToolRuntime

func NewWebhookCallbackToolRuntime(registry ToolCapabilityRegistry, secrets SecretResolver, client HTTPDoer, pollInterval time.Duration) *WebhookCallbackToolRuntime

func (*WebhookCallbackToolRuntime) Call

func (r *WebhookCallbackToolRuntime) Call(ctx context.Context, tool string, input string) (string, error)

func (*WebhookCallbackToolRuntime) DeliverCallback

func (r *WebhookCallbackToolRuntime) DeliverCallback(requestID string, resp ToolExecutionResponse) bool

DeliverCallback allows external code to push an async response for a pending request.

func (*WebhookCallbackToolRuntime) SetAllowPrivateEndpoints added in v0.8.0

func (r *WebhookCallbackToolRuntime) SetAllowPrivateEndpoints(allow bool)

SetAllowPrivateEndpoints permits webhook callbacks and polling against private / internal IP ranges. Loopback, link-local, cloud metadata, and unspecified addresses remain blocked.

func (*WebhookCallbackToolRuntime) WithNamespace

func (r *WebhookCallbackToolRuntime) WithNamespace(namespace string) ToolRuntime

func (*WebhookCallbackToolRuntime) WithRegistry

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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