agent

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package agent defines stable, provider-neutral AgentSlot domain values.

It intentionally contains no storage, model, tool, UI, or runtime implementation. Contract packages may depend on these values without creating a dependency cycle through the fixed AgentRuntime layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCode

func IsCode(err error, code ErrorCode) bool

IsCode reports whether err carries the requested domain reason.

func IsKind

func IsKind(err error, kind ErrorKind) bool

IsKind reports whether err carries the requested public reaction category.

func NewCodedError

func NewCodedError(kind ErrorKind, code ErrorCode, op, message string, cause error) error

NewCodedError creates a classified error with a stable domain reason.

func NewError

func NewError(kind ErrorKind, op, message string, cause error) error

NewError creates a classified boundary error. Empty kinds are normalized to internal instead of creating an unclassifiable public error.

Types

type ActorIdentity

type ActorIdentity struct {
	Kind ActorKind
	ID   string
}

ActorIdentity records who caused a durable fact without carrying secrets.

func (ActorIdentity) Valid

func (a ActorIdentity) Valid() bool

type ActorKind

type ActorKind string

ActorKind is the finite origin vocabulary attached to durable Session facts. Authentication remains the GatewayChannel's responsibility; this value contains no credential or authorization decision.

const (
	ActorLocalUser  ActorKind = "local_user"
	ActorRemoteUser ActorKind = "remote_user"
	ActorService    ActorKind = "service"
	ActorAgent      ActorKind = "agent"
)

func (ActorKind) Valid

func (k ActorKind) Valid() bool

type Agent

type Agent struct {
	ID AgentID
}

Agent identifies one configured capability set.

type AgentID

type AgentID string

The identity types are deliberately distinct even though they use the same wire representation. This prevents accidentally passing a SessionID where a RunID is required.

func (AgentID) Valid

func (id AgentID) Valid() bool

type AttemptID

type AttemptID string

The identity types are deliberately distinct even though they use the same wire representation. This prevents accidentally passing a SessionID where a RunID is required.

func (AttemptID) Valid

func (id AttemptID) Valid() bool

type ClassifiedError

type ClassifiedError struct {
	Kind    ErrorKind
	Code    ErrorCode
	Op      string
	Message string
	Cause   error
}

ClassifiedError carries a safe operation-level message and an optional implementation cause for logs and errors.Is. Callers should branch on Kind, not on provider or database error strings.

func (*ClassifiedError) Error

func (e *ClassifiedError) Error() string

func (*ClassifiedError) Unwrap

func (e *ClassifiedError) Unwrap() error

type ClientMessageID added in v0.0.3

type ClientMessageID string

ClientMessageID is an optional caller-generated correlation identity for reconciling an optimistic submission with the Runtime-assigned MessageID. It is not a substitute for the durable MessageID.

func (ClientMessageID) Valid added in v0.0.3

func (id ClientMessageID) Valid() bool

type ErrorCode

type ErrorCode string

ErrorCode is the stable domain reason inside a broad reaction category.

const (
	CodeRevisionConflict                  ErrorCode = "revision_conflict"
	CodeQueueItemClaimed                  ErrorCode = "queue_item_claimed"
	CodeNoActiveRun                       ErrorCode = "no_active_run"
	CodeNoPendingWork                     ErrorCode = "no_pending_work"
	CodeRuntimeClosed                     ErrorCode = "runtime_closed"
	CodeCanceled                          ErrorCode = "canceled"
	CodeSessionUnrecoverable              ErrorCode = "session_unrecoverable"
	CodeApplicationNotStarted             ErrorCode = "application_not_started"
	CodeSessionNotOpen                    ErrorCode = "session_not_open"
	CodeSessionAlreadyOpen                ErrorCode = "session_already_open"
	CodeRuntimeUnavailable                ErrorCode = "runtime_unavailable"
	CodeCommandNotFound                   ErrorCode = "command_not_found"
	CodeSessionNotFound                   ErrorCode = "session_not_found"
	CodeSessionAlreadyExists              ErrorCode = "session_already_exists"
	CodeActiveRun                         ErrorCode = "active_run"
	CodeQueueItemNotFound                 ErrorCode = "queue_item_not_found"
	CodeQueueItemAlreadyExists            ErrorCode = "queue_item_already_exists"
	CodeJournalInvariant                  ErrorCode = "journal_invariant"
	CodeHistoryInvariant                  ErrorCode = "history_invariant"
	CodeContextLimitExceeded              ErrorCode = "context_limit_exceeded"
	CodeModelNotSupported                 ErrorCode = "model_not_supported"
	CodeCompatibilityConfirmationRequired ErrorCode = "compatibility_confirmation_required"
	CodeModelExecutionFailed              ErrorCode = "model_execution_failed"
	CodeModelStreamInvalid                ErrorCode = "model_stream_invalid"
	CodeContextPreparationFailed          ErrorCode = "context_preparation_failed"
	CodeLoopFailed                        ErrorCode = "loop_failed"
	CodeLoopProtocolViolation             ErrorCode = "loop_protocol_violation"
	CodeToolExecutionFailed               ErrorCode = "tool_execution_failed"
	CodeRunTokenBudgetExceeded            ErrorCode = "run_token_budget_exceeded"
	CodeRunWaiting                        ErrorCode = "run_waiting"
	CodeSessionOperationFailed            ErrorCode = "session_operation_failed"
	CodeRuntimeFailed                     ErrorCode = "runtime_failed"
	CodeRuntimeInterrupted                ErrorCode = "runtime_interrupted"
)

func CodeOf

func CodeOf(err error) ErrorCode

CodeOf returns the stable domain reason, or an empty code for an unclassified implementation error.

type ErrorKind

type ErrorKind string

ErrorKind is the provider-neutral classification used at component boundaries. It describes how a caller may react, not an implementation's private diagnostic.

const (
	ErrorInvalidInput ErrorKind = "invalid_input"
	ErrorConflict     ErrorKind = "conflict"
	ErrorNotFound     ErrorKind = "not_found"
	ErrorUnauthorized ErrorKind = "unauthorized"
	ErrorForbidden    ErrorKind = "forbidden"
	ErrorCanceled     ErrorKind = "canceled"
	ErrorDeadline     ErrorKind = "deadline_exceeded"
	ErrorUnavailable  ErrorKind = "unavailable"
	ErrorInternal     ErrorKind = "internal"
)

func KindOf

func KindOf(err error) ErrorKind

KindOf returns the public reaction category of err. Unknown implementation errors are intentionally treated as internal failures.

func (ErrorKind) Valid added in v0.1.10

func (k ErrorKind) Valid() bool

Valid reports whether the kind belongs to the portable error vocabulary.

type FactID

type FactID string

The identity types are deliberately distinct even though they use the same wire representation. This prevents accidentally passing a SessionID where a RunID is required.

func (FactID) Valid

func (id FactID) Valid() bool

type Message

type Message struct {
	ID                MessageID
	ClientMessageID   ClientMessageID
	SessionID         SessionID
	RunID             RunID
	StepID            StepID
	Role              Role
	Parts             []MessagePart
	ModelContinuation *ModelContinuation
	CreatedAt         time.Time
}

Message is a durable message fact. Provider-neutral content stays in Parts; an optional opaque continuation preserves provider protocol state without pretending that state is user-visible message content.

func (Message) Valid

func (m Message) Valid() bool

Valid reports whether a durable message has stable identity and a known role. A contained assistant message may be content-empty only so it can own tool calls; SessionStore must require those calls in the same transaction.

type MessageID

type MessageID string

The identity types are deliberately distinct even though they use the same wire representation. This prevents accidentally passing a SessionID where a RunID is required.

func (MessageID) Valid

func (id MessageID) Valid() bool

type MessageInput

type MessageInput struct {
	Parts []MessagePart
}

MessageInput is unpersisted inbound content. It deliberately has no MessageID, SessionID, RunID, StepID, role, or timestamp: only the fixed Runtime may allocate durable identity and containment during commit.

func (MessageInput) Valid

func (m MessageInput) Valid() bool

Valid reports whether every inbound content part is provider-neutral and the input is non-empty.

type MessagePart

type MessagePart struct {
	Kind         MessagePartKind
	Text         string
	AttachmentID string
	MediaType    string
	Name         string
}

MessagePart is one text fragment or durable attachment reference. Provider adapters project these facts into their own wire blocks.

func (MessagePart) Valid

func (p MessagePart) Valid() bool

Valid reports whether a message part has exactly the payload required by its kind.

type MessagePartKind

type MessagePartKind string

MessagePartKind is the finite provider-neutral content vocabulary. Binary data is never embedded in History; attachment parts carry stable references.

const (
	PartText       MessagePartKind = "text"
	PartAttachment MessagePartKind = "attachment"
)

type ModelContinuation added in v0.0.5

type ModelContinuation struct {
	ProviderKey string
	ModelID     string
	State       json.RawMessage
}

ModelContinuation is provider-owned protocol state that must survive an interrupted model turn unchanged. Runtime and Context may copy and persist it, but must never inspect, render, edit, or send it to a different selected model. State contains one syntactically valid JSON value defined by the ModelExecutor implementation.

func (ModelContinuation) Valid added in v0.0.5

func (c ModelContinuation) Valid() bool

type Revision

type Revision uint64

Revision is the monotonically increasing version of a durable aggregate.

func (Revision) Next

func (r Revision) Next() Revision

Next returns the next revision without mutating the receiver.

type Role

type Role string

Role is the stable semantic role of a persisted message.

const (
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleTool      Role = "tool"
)

func (Role) Valid

func (r Role) Valid() bool

Valid reports whether role is a persisted History role.

type Run

type Run struct {
	ID        RunID
	SessionID SessionID
}

Run identifies one execution inside one Session.

type RunID

type RunID string

The identity types are deliberately distinct even though they use the same wire representation. This prevents accidentally passing a SessionID where a RunID is required.

func (RunID) Valid

func (id RunID) Valid() bool

type Session

type Session struct {
	ID              SessionID
	AgentID         AgentID
	WorkspaceID     WorkspaceID
	ParentSessionID SessionID
	ParentRevision  Revision
	Revision        Revision
}

Session identifies one isolated conversation and execution aggregate.

type SessionID

type SessionID string

The identity types are deliberately distinct even though they use the same wire representation. This prevents accidentally passing a SessionID where a RunID is required.

func (SessionID) Valid

func (id SessionID) Valid() bool

type Step

type Step struct {
	ID    StepID
	RunID RunID
}

Step identifies one model call or tool batch inside one Run. The concrete step kind vocabulary is intentionally kept small until execution contracts are introduced in a later round.

type StepID

type StepID string

The identity types are deliberately distinct even though they use the same wire representation. This prevents accidentally passing a SessionID where a RunID is required.

func (StepID) Valid

func (id StepID) Valid() bool

type ToolCall

type ToolCall struct {
	ID ToolCallID
	// CorrelationID is the model protocol's call/result correlation token. It
	// is content supplied by ModelExecutor, not the durable ToolCall identity.
	CorrelationID string
	MessageID     MessageID
	SessionID     SessionID
	RunID         RunID
	StepID        StepID
	Name          string
	Arguments     json.RawMessage
}

ToolCall is the durable identity, arguments, and containment record for one model-requested tool invocation.

func (ToolCall) Valid

func (c ToolCall) Valid() bool

Valid reports whether a tool call has stable containment, a tool name, and syntactically valid JSON arguments. Schema validation remains the fixed dispatcher's responsibility.

type ToolCallID

type ToolCallID string

The identity types are deliberately distinct even though they use the same wire representation. This prevents accidentally passing a SessionID where a RunID is required.

func (ToolCallID) Valid

func (id ToolCallID) Valid() bool

type Workspace

type Workspace struct {
	ID      WorkspaceID
	AgentID AgentID
}

Workspace identifies a product-owned scope under one Agent.

type WorkspaceID

type WorkspaceID string

The identity types are deliberately distinct even though they use the same wire representation. This prevents accidentally passing a SessionID where a RunID is required.

func (WorkspaceID) Valid

func (id WorkspaceID) Valid() bool

Jump to

Keyboard shortcuts

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