Documentation
¶
Overview ¶
Package agentenkit is a durable runtime for AI agent runs, as a library.
It does not own your prompts, models, or tools; goai does. It owns the lifecycle of a run: that a run outlives the request that started it, survives a worker dying mid-step, can be stopped, parked for a human, resumed exactly where it stopped, nested, metered, and watched by several people at once.
This is the Go port of the TypeScript agentenkit package, file for file:
ports/ the four ports you implement, the admin store, every DTO core/ the behaviors (engine, loop, HITL, subagents, follow, admin reads) adapters/ memory, inline, sqlite, postgres, redis, qstash, upstash admin/ memory, sqlite, postgres operational stores
This root package re-exports the public surface, the way index.ts does, and holds SetupAgentCore (runtime.ts). Adapters are imported from their own packages so a program only compiles the drivers it uses.
Index ¶
- Constants
- Variables
- func Ptr[T any](v T) *T
- func WithSandbox[T any](ctx context.Context, fn func(ThreadSandbox) (T, error)) (T, error)
- type AdminAPI
- func (a *AdminAPI) GetRun(ctx context.Context, runID string) (*RunDetail, error)
- func (a *AdminAPI) GetThread(ctx context.Context, threadID string) (*ThreadDetail, error)
- func (a *AdminAPI) ListRuns(ctx context.Context, filter RunFilter) ([]RunRecord, error)
- func (a *AdminAPI) ListRunsByThread(ctx context.Context, threadID string) ([]RunRecord, error)
- func (a *AdminAPI) ListSteps(ctx context.Context, runID string) ([]StepRecord, error)
- func (a *AdminAPI) ListThreads(ctx context.Context, filter AdminThreadFilter) ([]ThreadSummary, error)
- func (a *AdminAPI) Overview(ctx context.Context, since *time.Time) (AdminOverview, error)
- func (a *AdminAPI) Stats(ctx context.Context, r StatsRange) (RunStats, error)
- type AdminOverview
- type AdminStore
- type AdminThread
- type AdminThreadFilter
- type AdminThreadStore
- type AgentConfig
- type AgentCore
- func (c *AgentCore) AdminStore() AdminStore
- func (c *AgentCore) BuiltinTools(names []string, opts BuiltinToolOptions) ([]Tool, error)
- func (c *AgentCore) Close() error
- func (c *AgentCore) Config() AgentConfig
- func (c *AgentCore) CreateGenerateTextAgent(spec GenerateTextAgentSpec) *AgentHandle
- func (c *AgentCore) CreateStreamTextAgent(spec StreamTextAgentSpec) *AgentHandle
- func (c *AgentCore) DeleteThread(ctx context.Context, threadID string, state AgentRunState) (DeleteThreadResult, error)
- func (c *AgentCore) GetAgent(name string) *AgentHandle
- func (c *AgentCore) GetThreadSnapshot(ctx context.Context, threadID string, state AgentRunState) (*ThreadSnapshot, error)
- func (c *AgentCore) GetThreadUsage(ctx context.Context, threadID string, state AgentRunState) (*ThreadUsage, error)
- func (c *AgentCore) ListThreads(ctx context.Context, state AgentRunState) ([]ThreadDTO, error)
- func (c *AgentCore) Ports(state AgentRunState) RuntimePorts
- func (c *AgentCore) PruneEvents(ctx context.Context, opts core.PruneOptions) (core.PruneReport, error)
- func (c *AgentCore) ReclaimStuckRuns(ctx context.Context, olderThan time.Duration) (ReclaimReport, error)
- func (c *AgentCore) ResolveModel(modelName string) (ResolvedModel, error)
- type AgentEvent
- type AgentHandle
- type AgentKind
- type AgentRunState
- type Approval
- type ApprovalRule
- type Attachment
- type BashOptions
- type BillingCheck
- type BillingStage
- type BoundStorage
- type BuiltinToolDefinition
- type BuiltinToolOptions
- type BuiltinToolPorts
- type CodeExecutionOptions
- type CommandResult
- type ContentPart
- type ContextUsage
- type Cost
- type CreateSandboxOptions
- type DeleteThreadResult
- type EnqueueOptions
- type EventBus
- type EventPublisher
- type EventStore
- type EventStream
- type EventsAPI
- func (e *EventsAPI) Follow(ctx context.Context, threadID string, opts FollowStateOptions) (*core.FrameStream, error)
- func (e *EventsAPI) FollowRecord(ctx context.Context, threadID string, opts FollowStateOptions) (*EventStream, error)
- func (e *EventsAPI) PublishEvent(ctx context.Context, threadID, typ string, payload any, ...) (AgentEvent, error)
- func (e *EventsAPI) SSE(ctx context.Context, threadID string, opts SSEStateOptions) (*core.FollowSSE, error)
- func (e *EventsAPI) Since(ctx context.Context, threadID string, sinceSeq int64, state AgentRunState) ([]AgentEvent, error)
- func (e *EventsAPI) Subscribe(ctx context.Context, threadID string, handler func(AgentEvent)) (func() error, error)
- type ExecuteFunc
- type ExecuteInput
- type ExecuteOutcome
- type ExecutionState
- type FetchOptions
- type FetchedPage
- type Fetcher
- type FileEntry
- type FinalizeInput
- type FollowFrame
- type FollowOptions
- type FollowSSE
- type FollowStateOptions
- type FrameStream
- type GenerateTextAgentSpec
- type HITLAPI
- type HandleJobResult
- type HitlCtx
- type HitlFrame
- type HitlResponse
- type JobKind
- type Kv
- type LoopInput
- type LoopOutcome
- type MessageDTO
- type MessageRole
- type MessageScope
- type MessageStore
- type NestedDescriptor
- type NewAdminThread
- type NewMessage
- type NewRunRecord
- type NewStepRecord
- type NewUsage
- type ParkInput
- type ParkRequest
- type PendingHitl
- type Percentiles
- type Policy
- type PrepareStepFunc
- type Pricer
- type PricerFunc
- type ProviderOptions
- type PruneOptions
- type PruneReport
- type PublishOptions
- type PublishStateOptions
- type Queue
- type QueueStats
- type QueuedJob
- type ReclaimReport
- type RegisteredAgent
- type ResolvedModel
- type RespondInput
- type RespondResult
- type ResumeInfo
- type RunBudget
- type RunCommandOptions
- type RunDetail
- type RunFilter
- type RunFinishInfo
- type RunInput
- type RunJob
- type RunLedger
- type RunPatch
- type RunRecord
- type RunResult
- type RunStats
- type RunStore
- type RunStreams
- type RuntimeOptions
- type RuntimePorts
- type SSEOptions
- type SSEStateOptions
- type SSEStream
- type Sandbox
- type SandboxFileSystem
- type SandboxInfo
- type SandboxMetadata
- type SandboxNetwork
- type SandboxProvider
- type SandboxResources
- type Search
- type SearchHit
- type SearchOptions
- type SearchRecency
- type Semaphore
- type SetOptions
- type SettleFunc
- type SnapshotStream
- type StatsRange
- type StepCall
- type StepRecord
- type StepResult
- type StepStore
- type StepToolCall
- type StopOptions
- type StopResult
- type Storage
- type StorageContext
- type StreamEnd
- type StreamEvent
- type StreamItem
- type StreamMeta
- type StreamTextAgentSpec
- type StreamsAPI
- type SubagentCtx
- type SubagentProfile
- type SubagentsConfig
- type SystemFunc
- type TextEditorOptions
- type ThreadCursor
- type ThreadDTO
- type ThreadDetail
- type ThreadInit
- type ThreadSandbox
- type ThreadSnapshot
- type ThreadStart
- type ThreadStore
- type ThreadSummary
- type ThreadUsage
- type TokenAttribution
- type Tool
- type ToolContext
- type ToolRun
- type UsageFilter
- type UsageKind
- type UsageLine
- type UsageOutcome
- type UsageStore
- type UsageTotals
- type WebFetchOptions
- type WebSearchOptions
- type WorkerAPI
Constants ¶
const ( KindStep = ports.KindStep KindCompaction = ports.KindCompaction KindTool = ports.KindTool UsageFinished = ports.UsageFinished UsageAborted = ports.UsageAborted UsageErrored = ports.UsageErrored StateIdle = ports.StateIdle StateQueued = ports.StateQueued StateRunning = ports.StateRunning StateWaitingForInput = ports.StateWaitingForInput StateCancelled = ports.StateCancelled StateCompleted = ports.StateCompleted StateFailed = ports.StateFailed RoleUser = ports.RoleUser RoleAssistant = ports.RoleAssistant RoleSystem = ports.RoleSystem RoleTool = ports.RoleTool KindStreamText = ports.KindStreamText KindGenerateText = ports.KindGenerateText JobDispatch = ports.JobDispatch JobRetry = ports.JobRetry JobRedrive = ports.JobRedrive JobResume = ports.JobResume JobExpiry = ports.JobExpiry JobReclaim = ports.JobReclaim PriorityLow = ports.PriorityLow BillingAtDispatch = ports.BillingAtDispatch BillingAtPickup = ports.BillingAtPickup RefusedActiveRun = ports.RefusedActiveRun RefusedQueueFull = ports.RefusedQueueFull RefusedBilling = ports.RefusedBilling )
const ( OutcomeExecuted = core.OutcomeExecuted OutcomeLockConflict = core.OutcomeLockConflict OutcomeStale = core.OutcomeStale OutcomeLockLost = core.OutcomeLockLost // SettleClaimTTL is how long a settle claim holds (§5.6). SettleClaimTTL = core.SettleClaimTTL HITLParked = core.HITLParked ReasonApproval = core.ReasonApproval HITLTTL = core.HITLTTL ContextTokenCeiling = core.ContextTokenCeiling ContextSummaryType = core.ContextSummaryType DefaultModel = core.DefaultModel )
Variables ¶
var ( ErrQueueFull = ports.ErrQueueFull ErrPayloadTooLarge = ports.ErrPayloadTooLarge ErrDuplicateJob = ports.ErrDuplicateJob ErrUnsupported = ports.ErrUnsupported )
Errors a queue answers with, so a host can tell them apart.
var ( // MainAgent scopes a message listing to the main agent's stream. MainAgent = ports.MainAgent // AgentScope scopes a message listing to one nested run's stream. AgentScope = ports.AgentScope // DefaultConfig returns the shipped defaults. DefaultConfig = ports.DefaultConfig // ResolveConfig validates a config. ResolveConfig = ports.ResolveConfig // WrapTool lifts a plain goai tool into the platform's Tool. WrapTool = ports.WrapTool // WrapTools lifts several goai tools. WrapTools = ports.WrapTools // BindStorage attaches a run's context to every storage method once. BindStorage = ports.BindStorage // MergeProviderOptions is a shallow per-provider merge. MergeProviderOptions = ports.MergeProviderOptions )
var ( Execute = core.Execute ExecuteStep = core.ExecuteStep ExecuteWithPolicy = core.ExecuteWithPolicy Finalize = core.Finalize RunLoop = core.RunLoop IsParked = core.IsParked MarkRequiresConfirmation = core.MarkRequiresConfirmation RequireConfirmation = core.RequireConfirmation FollowEvents = core.FollowEvents ToSSEStream = core.ToSSEStream SSEFrame = core.SSEFrame ParseCursor = core.ParseCursor FormatCursor = core.FormatCursor SSEHeaders = core.SSEHeaders ContextWithRunID = core.ContextWithRunID RunIDFromContext = core.RunIDFromContext ClaimRun = core.ClaimRun ClaimRunAs = core.ClaimRunAs UserContent = core.UserContent CurrentRunID = core.CurrentRunID RunIDKey = core.RunIDKey RedriveKey = core.RedriveKey AttemptsKey = core.AttemptsKey IsActive = core.IsActive StateKey = core.StateKey SeqKey = core.SeqKey RunLockKey = core.RunLockKey ParseLockValue = core.ParseLockValue NewID = core.NewID CountTokens = core.CountTokens AttributeTokens = core.AttributeTokens Respond = core.Respond ParkForApproval = core.ParkForApproval ParkForInput = core.ParkForInput AsParkRequest = core.AsParkRequest LoadPendingHitl = core.LoadPendingHitl LoadOpenHitls = core.LoadOpenHitls WithHitl = core.WithHitl HitlKey = core.HitlKey ReclaimIfOrphaned = core.ReclaimIfOrphaned ContextBudget = core.ContextBudget ContextUsageOf = core.ContextUsage CompactContext = core.CompactContext NewSemaphore = core.NewSemaphore RunNestedAgent = core.RunNestedAgent SpawnSubagentTool = core.SpawnSubagentTool Run = core.Run Stop = core.Stop StopRun = core.StopRun DeleteThread = core.DeleteThread RunStateFromContext = core.RunStateFromContext ContextWithRunState = core.ContextWithRunState WithRunState = core.WithRunState MarkPromptCaching = core.MarkPromptCaching SystemCacheMessage = core.SystemCacheMessage ChunkPayload = core.ChunkPayload ContentFromMessage = core.ContentFromMessage MessageFromDTO = core.MessageFromDTO MessagesFromDTOs = core.MessagesFromDTOs RepairDanglingToolCalls = core.RepairDanglingToolCalls ParseContent = core.ParseContent TextContent = core.TextContent PartsContent = core.PartsContent Publish = core.Publish PublishNotice = core.PublishNotice PublishEvent = core.PublishEvent WithPublishEvent = core.WithPublishEvent ToolContextFrom = core.ToolContextFrom ToolRunFromContext = core.ToolRunFromContext SandboxFor = core.SandboxFor IsPermanentError = core.IsPermanentError BuiltinToolNames = core.BuiltinToolNames DecodeEntities = core.DecodeEntities HTMLToText = core.HTMLToText ApprovalFromContext = core.ApprovalFromContext PublisherFromContext = core.PublisherFromContext ReservedEventTypes = core.ReservedEventTypes SetThreadState = core.SetThreadState Summarise = core.Summarise )
var ( ErrSandboxGone = ports.ErrSandboxGone ErrSandboxFileNotFound = ports.ErrSandboxFileNotFound ErrSandboxUnsupported = ports.ErrSandboxUnsupported )
The sandbox errors, for errors.Is.
var ( AskAlways = core.AskAlways AskNever = core.AskNever )
AskAlways and AskNever are the two fixed approval rules for the sandbox tools.
var ErrUnknownAgent = errors.New("agentenkit: no agent registered for this job")
ErrUnknownAgent is a job for an agent this process has not registered, with no default handle to fall back on. It is an error rather than a quiet refusal: the queue keeps the job and retries it, so a process that registers its agents a moment after it starts consuming heals on its own, and one that never does leaves a dead row and a log line, not silence.
Functions ¶
func WithSandbox ¶ added in v0.5.0
WithSandbox runs fn on the thread's sandbox, from inside a tool. When the sandbox turns out to be gone part way (it ended on its own), a fresh one is made and fn runs once more, told Lost.
Types ¶
type AdminAPI ¶
type AdminAPI struct {
// contains filtered or unexported fields
}
AdminAPI reads operational history (§2.9). Everything here comes from the platform's OWN store; it never reads the caller's database.
func (*AdminAPI) ListRunsByThread ¶
ListRunsByThread: every run on a thread, newest first.
func (*AdminAPI) ListThreads ¶
func (a *AdminAPI) ListThreads(ctx context.Context, filter AdminThreadFilter) ([]ThreadSummary, error)
ListThreads: threads with their runs rolled up.
type AdminThreadFilter ¶
type AdminThreadFilter = ports.AdminThreadFilter
Ports: the interfaces users implement.
type AdminThreadStore ¶
type AdminThreadStore = ports.AdminThreadStore
Ports: the interfaces users implement.
type AgentCore ¶
type AgentCore struct {
// HITL answers approvals and heals orphans (§2.5).
HITL *HITLAPI
// Events replays and tails a thread (§2.2).
Events *EventsAPI
// Admin reads operational history (§2.9).
Admin *AdminAPI
// Worker is the queue dispatch side (§2.8).
Worker *WorkerAPI
// Streams reads run streams by id.
Streams *StreamsAPI
// contains filtered or unexported fields
}
AgentCore is the bound platform: ports plus behaviors (§3.3).
func SetupAgentCore ¶
func SetupAgentCore(ctx context.Context, opts RuntimeOptions) (*AgentCore, error)
SetupAgentCore binds the ports to the core behaviors (§3.3). This is the package's public entry point: the only place where anything is wired.
Operational history is the platform's own (§2.9). Nothing configured means SQLite on disk, opened here, eagerly: a store that cannot be opened is a startup error you see immediately, rather than a surprise on the first run.
func (*AgentCore) AdminStore ¶
func (c *AgentCore) AdminStore() AdminStore
AdminStore is the operational store in use.
func (*AgentCore) BuiltinTools ¶ added in v0.5.0
func (c *AgentCore) BuiltinTools(names []string, opts BuiltinToolOptions) ([]Tool, error)
BuiltinTools returns the built-in tools, ready to put in an agent's Tools: one name and one input shape in every runtime, so any model that can call tools can use them. An error when a tool's adapter was not given in RuntimeOptions.Tools.
tools, err := rt.BuiltinTools([]string{"web_search", "web_fetch"}, agentenkit.BuiltinToolOptions{})
func (*AgentCore) CreateGenerateTextAgent ¶
func (c *AgentCore) CreateGenerateTextAgent(spec GenerateTextAgentSpec) *AgentHandle
CreateGenerateTextAgent registers a generate-text handle under spec.Name.
func (*AgentCore) CreateStreamTextAgent ¶
func (c *AgentCore) CreateStreamTextAgent(spec StreamTextAgentSpec) *AgentHandle
CreateStreamTextAgent registers a stream-text handle under spec.Name (§4).
func (*AgentCore) DeleteThread ¶
func (c *AgentCore) DeleteThread(ctx context.Context, threadID string, state AgentRunState) (DeleteThreadResult, error)
DeleteThread deletes a thread and everything that follows it (§3.2). Refused while a run is active; Stop first.
func (*AgentCore) GetAgent ¶
func (c *AgentCore) GetAgent(name string) *AgentHandle
GetAgent resolves a registered handle by name, or nil.
func (*AgentCore) GetThreadSnapshot ¶
func (c *AgentCore) GetThreadSnapshot(ctx context.Context, threadID string, state AgentRunState) (*ThreadSnapshot, error)
GetThreadSnapshot is one call for UIs: thread + messages + runs + the unfinished run's record entries + its run stream. Nil when the thread is gone.
func (*AgentCore) GetThreadUsage ¶
func (c *AgentCore) GetThreadUsage(ctx context.Context, threadID string, state AgentRunState) (*ThreadUsage, error)
GetThreadUsage is tokens spent so far and the §2.6 context load. Nil when the thread is gone.
func (*AgentCore) ListThreads ¶
ListThreads lists threads most recent first. Takes the run state (§2.10) so a tenant-scoped Storage can filter; a read has no dispatch ticket.
func (*AgentCore) Ports ¶
func (c *AgentCore) Ports(state AgentRunState) RuntimePorts
Ports returns the ports bundle for reads on behalf of no particular run, or for a run when state is given.
func (*AgentCore) PruneEvents ¶ added in v0.4.0
func (c *AgentCore) PruneEvents(ctx context.Context, opts core.PruneOptions) (core.PruneReport, error)
PruneEvents deletes the stream-only rows (chunks, step markers, state changes…) releases before run streams left in the event table, a batch at a time. Nothing reads them any more; an app's own types are kept. Run it when it suits you, after upgrading: DryRun counts first.
func (*AgentCore) ReclaimStuckRuns ¶ added in v0.3.0
func (c *AgentCore) ReclaimStuckRuns(ctx context.Context, olderThan time.Duration) (ReclaimReport, error)
ReclaimStuckRuns is the backstop for a run that nothing is working on (§2.5, §2.8): a QUEUED or RUNNING record older than olderThan whose lock nobody holds and whose job the queue no longer has is re-dispatched, and an ended record older than olderThan whose settle never ran is settled. Call it from a periodic job. It pages through every such run, not only the first page. A record with no recorded state (RecordPayloads off) is read with an empty state, so a tenant-scoped storage sees no tenant.
func (*AgentCore) ResolveModel ¶
func (c *AgentCore) ResolveModel(modelName string) (ResolvedModel, error)
ResolveModel resolves a registry key to the identity and provider instance used by execution, compaction and usage attribution.
type AgentRunState ¶
type AgentRunState = ports.AgentRunState
Ports: the interfaces users implement.
type ApprovalRule ¶ added in v0.5.0
type ApprovalRule = core.ApprovalRule
Core: behaviors, all ports-only.
type BashOptions ¶ added in v0.5.0
type BashOptions = core.BashOptions
Core: behaviors, all ports-only.
type BillingStage ¶ added in v0.3.0
type BillingStage = ports.BillingStage
Types: the DTOs that cross the ports.
type BuiltinToolDefinition ¶ added in v0.5.0
type BuiltinToolDefinition = core.BuiltinToolDefinition
Core: behaviors, all ports-only.
type BuiltinToolOptions ¶ added in v0.5.0
type BuiltinToolOptions = core.BuiltinToolOptions
Core: behaviors, all ports-only.
type BuiltinToolPorts ¶ added in v0.5.0
type BuiltinToolPorts = ports.BuiltinToolPorts
Types: the DTOs that cross the ports.
type CodeExecutionOptions ¶ added in v0.5.0
type CodeExecutionOptions = core.CodeExecutionOptions
Core: behaviors, all ports-only.
type CommandResult ¶ added in v0.5.0
type CommandResult = ports.CommandResult
Types: the DTOs that cross the ports.
type CreateSandboxOptions ¶ added in v0.5.0
type CreateSandboxOptions = ports.CreateSandboxOptions
Types: the DTOs that cross the ports.
type DeleteThreadResult ¶
type DeleteThreadResult = ports.DeleteThreadResult
Ports: the interfaces users implement.
type EnqueueOptions ¶
type EnqueueOptions = ports.EnqueueOptions
Ports: the interfaces users implement.
type EventsAPI ¶
type EventsAPI struct {
// contains filtered or unexported fields
}
EventsAPI replays and tails a thread (§2.2).
func (*EventsAPI) Follow ¶
func (e *EventsAPI) Follow(ctx context.Context, threadID string, opts FollowStateOptions) (*core.FrameStream, error)
Follow is a thread live, as one sequence of frames (§2.2): its record entries and notices, and its run streams — the stream the cursor names read on from its offset, the next segment's from its RUN_STARTED, and one SNAPSHOT frame when the stream the client was reading is gone. Cancel ctx, or the follow outlives the client.
func (*EventsAPI) FollowRecord ¶ added in v0.4.0
func (e *EventsAPI) FollowRecord(ctx context.Context, threadID string, opts FollowStateOptions) (*EventStream, error)
FollowRecord is the thread record and its notices alone, as before run streams: no stream frames.
func (*EventsAPI) PublishEvent ¶
func (e *EventsAPI) PublishEvent(ctx context.Context, threadID, typ string, payload any, opts PublishStateOptions) (AgentEvent, error)
PublishEvent publishes an event of your own on a thread, from anywhere on the server: a webhook, a cron job, a route. Tools get the same thing bound to their thread through ToolContext.PublishEvent. Live only by default; Durable also keeps it in the thread record. Platform event types are refused.
func (*EventsAPI) SSE ¶
func (e *EventsAPI) SSE(ctx context.Context, threadID string, opts SSEStateOptions) (*core.FollowSSE, error)
SSE is Follow, encoded as Server-Sent Events: each frame that moves the cursor carries it as its id:. Serve it with ServeHTTP or WriteTo.
func (*EventsAPI) Since ¶
func (e *EventsAPI) Since(ctx context.Context, threadID string, sinceSeq int64, state AgentRunState) ([]AgentEvent, error)
Since is the raw replay: every event after the cursor.
func (*EventsAPI) Subscribe ¶
func (e *EventsAPI) Subscribe(ctx context.Context, threadID string, handler func(AgentEvent)) (func() error, error)
Subscribe is the raw tail. Returns an unsubscribe function. A bus that reads storage itself (the Postgres bus, after a reconnect) takes the run state from ctx: wrap it with ContextWithRunState on scoped storage.
type ExecutionState ¶
type ExecutionState = ports.ExecutionState
Types: the DTOs that cross the ports.
type FetchOptions ¶ added in v0.5.0
type FetchOptions = ports.FetchOptions
Types: the DTOs that cross the ports.
type FetchedPage ¶ added in v0.5.0
type FetchedPage = ports.FetchedPage
Types: the DTOs that cross the ports.
type FollowFrame ¶ added in v0.4.0
type FollowFrame = core.FollowFrame
Core: behaviors, all ports-only.
type FollowStateOptions ¶
type FollowStateOptions struct {
// Since is a bare record seq, as older clients send; used when Cursor
// is empty.
FollowOptions
// Cursor is where the client is: the SSE id it last saw
// (Last-Event-ID), "<seq> <streamId> <offset>".
Cursor string
// LastMessageID is the last message the client has, so a SNAPSHOT
// carries only newer ones.
LastMessageID string
State AgentRunState
}
FollowStateOptions says where a follow starts, with the run state.
type FrameStream ¶ added in v0.4.0
type FrameStream = core.FrameStream
Core: behaviors, all ports-only.
type GenerateTextAgentSpec ¶
type GenerateTextAgentSpec = ports.GenerateTextAgentSpec
Ports: the interfaces users implement.
type HITLAPI ¶
type HITLAPI struct {
// contains filtered or unexported fields
}
HITLAPI answers approvals (§2.5).
func (*HITLAPI) ReclaimIfOrphaned ¶
func (h *HITLAPI) ReclaimIfOrphaned(ctx context.Context, threadID string, state AgentRunState) (bool, error)
ReclaimIfOrphaned re-dispatches a thread whose approvals all expired.
func (*HITLAPI) Respond ¶
func (h *HITLAPI) Respond(ctx context.Context, input RespondInput) (RespondResult, error)
Respond records an answer and resumes the run through the queue. Scoped like the run it resumes (§2.10). An orphaned wait is healed first; if reclamation claims the thread, the response is rejected as late.
type HandleJobResult ¶
type HandleJobResult struct {
Accepted bool `json:"accepted"`
Reason string `json:"reason,omitempty"`
}
HandleJobResult says whether a job was accepted.
type NestedDescriptor ¶
type NestedDescriptor = ports.NestedDescriptor
Types: the DTOs that cross the ports.
type NewAdminThread ¶
type NewAdminThread = ports.NewAdminThread
Ports: the interfaces users implement.
type NewStepRecord ¶
type NewStepRecord = ports.NewStepRecord
Ports: the interfaces users implement.
type ParkRequest ¶ added in v0.2.1
type ParkRequest = core.ParkRequest
Core: behaviors, all ports-only.
type PrepareStepFunc ¶
type PrepareStepFunc = ports.PrepareStepFunc
Ports: the interfaces users implement.
type ProviderOptions ¶
type ProviderOptions = ports.ProviderOptions
Types: the DTOs that cross the ports.
type PruneOptions ¶ added in v0.4.0
type PruneOptions = core.PruneOptions
Core: behaviors, all ports-only.
type PruneReport ¶ added in v0.4.0
type PruneReport = core.PruneReport
Core: behaviors, all ports-only.
type PublishStateOptions ¶
type PublishStateOptions struct {
PublishOptions
State AgentRunState
}
PublishStateOptions carries the run state alongside the publish options.
type QueueStats ¶ added in v0.3.0
type QueueStats = ports.QueueStats
Ports: the interfaces users implement.
type ReclaimReport ¶ added in v0.3.0
type ReclaimReport struct {
// Checked is how many open run records the sweep looked at.
Checked int `json:"checked"`
// Redispatched is how many runs went back on the queue or were moved
// to their record's end state.
Redispatched int `json:"redispatched"`
// Settled is how many ended runs had their settle run late.
Settled int `json:"settled"`
// Errors is how many runs the sweep could not act on.
Errors int `json:"errors"`
}
ReclaimReport is what a stuck-run sweep did.
type RespondResult ¶
type RespondResult = ports.RespondResult
Ports: the interfaces users implement.
type RunCommandOptions ¶ added in v0.5.0
type RunCommandOptions = ports.RunCommandOptions
Types: the DTOs that cross the ports.
type RunFinishInfo ¶
type RunFinishInfo = ports.RunFinishInfo
Ports: the interfaces users implement.
type RunStreams ¶ added in v0.4.0
type RunStreams = ports.RunStreams
Ports: the interfaces users implement.
type RuntimeOptions ¶
type RuntimeOptions = ports.RuntimeOptions
Ports: the interfaces users implement.
type SSEStateOptions ¶
type SSEStateOptions struct {
FollowStateOptions
// RetryMs is emitted once, up front: how long a browser waits before
// reconnecting. Zero omits it.
RetryMs int
// WireFormat is "agentenkit" (the default) or "ag-ui" to send AG-UI
// events instead of our frames (opt-in).
WireFormat string
}
SSEStateOptions is FollowStateOptions with the SSE retry hint and wire format.
type SandboxFileSystem ¶ added in v0.5.0
type SandboxFileSystem = ports.SandboxFileSystem
Types: the DTOs that cross the ports.
type SandboxInfo ¶ added in v0.5.0
type SandboxInfo = ports.SandboxInfo
Types: the DTOs that cross the ports.
type SandboxMetadata ¶ added in v0.5.0
type SandboxMetadata = ports.SandboxMetadata
Types: the DTOs that cross the ports.
type SandboxNetwork ¶ added in v0.5.0
type SandboxNetwork = ports.SandboxNetwork
Types: the DTOs that cross the ports.
type SandboxProvider ¶ added in v0.5.0
type SandboxProvider = ports.SandboxProvider
Types: the DTOs that cross the ports.
type SandboxResources ¶ added in v0.5.0
type SandboxResources = ports.SandboxResources
Types: the DTOs that cross the ports.
type SearchOptions ¶ added in v0.5.0
type SearchOptions = ports.SearchOptions
Types: the DTOs that cross the ports.
type SearchRecency ¶ added in v0.5.0
type SearchRecency = ports.SearchRecency
Types: the DTOs that cross the ports.
type SnapshotStream ¶ added in v0.4.0
type SnapshotStream = ports.SnapshotStream
Ports: the interfaces users implement.
type StopOptions ¶ added in v0.2.3
type StopOptions = core.StopOptions
Core: behaviors, all ports-only.
type StorageContext ¶
type StorageContext = ports.StorageContext
Ports: the interfaces users implement.
type StreamEvent ¶ added in v0.4.0
type StreamEvent = ports.StreamEvent
Ports: the interfaces users implement.
type StreamItem ¶ added in v0.4.0
type StreamItem = ports.StreamItem
Ports: the interfaces users implement.
type StreamMeta ¶ added in v0.4.0
type StreamMeta = ports.StreamMeta
Ports: the interfaces users implement.
type StreamTextAgentSpec ¶
type StreamTextAgentSpec = ports.StreamTextAgentSpec
Ports: the interfaces users implement.
type StreamsAPI ¶ added in v0.4.0
type StreamsAPI struct {
// contains filtered or unexported fields
}
StreamsAPI reads run streams by id, for a caller that only cares about one run.
func (*StreamsAPI) Read ¶ added in v0.4.0
func (s *StreamsAPI) Read(ctx context.Context, streamID, after string) iter.Seq2[ports.StreamItem, error]
Read yields a run stream's items after `after`, live until it closes. It yields ErrStreamGone once the stream is past its grace window.
func (*StreamsAPI) Snapshot ¶ added in v0.4.0
func (s *StreamsAPI) Snapshot(ctx context.Context, streamID, after string) (*ports.StreamSnapshot, error)
Snapshot is a run stream as it stands now; nil when it is gone.
type SubagentProfile ¶
type SubagentProfile = ports.SubagentProfile
Ports: the interfaces users implement.
type SubagentsConfig ¶
type SubagentsConfig = ports.SubagentsConfig
Ports: the interfaces users implement.
type TextEditorOptions ¶ added in v0.5.0
type TextEditorOptions = core.TextEditorOptions
Core: behaviors, all ports-only.
type ThreadCursor ¶ added in v0.4.0
type ThreadCursor = core.ThreadCursor
Core: behaviors, all ports-only.
type ThreadSandbox ¶ added in v0.5.0
type ThreadSandbox = core.ThreadSandbox
Core: behaviors, all ports-only.
type ThreadSnapshot ¶
type ThreadSnapshot = ports.ThreadSnapshot
Ports: the interfaces users implement.
type TokenAttribution ¶
type TokenAttribution = core.TokenAttribution
Core: behaviors, all ports-only.
type WebFetchOptions ¶ added in v0.5.0
type WebFetchOptions = core.WebFetchOptions
Core: behaviors, all ports-only.
type WebSearchOptions ¶ added in v0.5.0
type WebSearchOptions = core.WebSearchOptions
Core: behaviors, all ports-only.
type WorkerAPI ¶
type WorkerAPI struct {
// contains filtered or unexported fields
}
WorkerAPI is the queue dispatch side of the platform (§2.8).
func (*WorkerAPI) HandleDeadJob ¶ added in v0.3.0
HandleDeadJob is what a queue calls when it gives up on a job (§2.8): the run behind it is failed with the reason, so its thread does not read QUEUED or RUNNING for ever and its spend is settled. A job whose run has already moved on (a newer run, a stop, a finished run) is left alone.
Directories
¶
| Path | Synopsis |
|---|---|
|
adapters
|
|
|
brave
Package brave is web search on the Brave Search API: its own index of the web, $5 per 1,000 searches with $5 free each month (checked 2026-09-26).
|
Package brave is web search on the Brave Search API: its own index of the web, $5 per 1,000 searches with $5 free each month (checked 2026-09-26). |
|
docker
Package docker runs sandboxes as Docker containers on the machine the docker CLI talks to: for self-hosting.
|
Package docker runs sandboxes as Docker containers on the machine the docker CLI talks to: for self-hosting. |
|
e2b
Package e2b runs sandboxes on E2B: each is a small VM that starts in under a second.
|
Package e2b runs sandboxes on E2B: each is a small VM that starts in under a second. |
|
inline
Package inline holds an in-process queue that actually dispatches (§2.8).
|
Package inline holds an in-process queue that actually dispatches (§2.8). |
|
internal/redisstreams
Package redisstreams is RunStreams over Redis Streams, shared by the Redis and Upstash adapters.
|
Package redisstreams is RunStreams over Redis Streams, shared by the Redis and Upstash adapters. |
|
internal/sandboxsh
Package sandboxsh holds what the sandbox adapters share.
|
Package sandboxsh holds what the sandbox adapters share. |
|
internal/sqlstreams
Package sqlstreams is RunStreams over two SQL tables, shared by the SQLite and Postgres adapters.
|
Package sqlstreams is RunStreams over two SQL tables, shared by the SQLite and Postgres adapters. |
|
internal/websearch
Package websearch holds what the search adapters share: the domain lists.
|
Package websearch holds what the search adapters share: the domain lists. |
|
jina
Package jina is web search and page reading through Jina AI (checked 2026-09-26): s.jina.ai for search, about $0.50 per 1,000 searches ($0.05 per million tokens, at least 10,000 a search, 100 requests a minute), and r.jina.ai for pages built with JavaScript, PDFs and sites that block plain fetches, about $0.25–$0.50 per 1,000 pages.
|
Package jina is web search and page reading through Jina AI (checked 2026-09-26): s.jina.ai for search, about $0.50 per 1,000 searches ($0.05 per million tokens, at least 10,000 a search, 100 requests a minute), and r.jina.ai for pages built with JavaScript, PDFs and sites that block plain fetches, about $0.25–$0.50 per 1,000 pages. |
|
localsandbox
Package localsandbox is a sandbox that is only a folder on this machine: for development, where you want the sandbox tools without Docker or an account.
|
Package localsandbox is a sandbox that is only a folder on this machine: for development, where you want the sandbox tools without Docker or an account. |
|
memory
Package memory holds the in-memory adapters: a full implementation used by the test suite, and a template for custom adapters.
|
Package memory holds the in-memory adapters: a full implementation used by the test suite, and a template for custom adapters. |
|
pagereader
Package pagereader is our own page reader for the web_fetch built-in tool: it fetches the page itself and turns it into markdown, with no service in between and nothing to pay.
|
Package pagereader is our own page reader for the web_fetch built-in tool: it fetches the page itself and turns it into markdown, with no service in between and nothing to pay. |
|
postgres
Package postgres holds a complete Storage over Postgres (§3.2): the production storage adapter, the Go stand-in for the TypeScript package's PrismaStorage.
|
Package postgres holds a complete Storage over Postgres (§3.2): the production storage adapter, the Go stand-in for the TypeScript package's PrismaStorage. |
|
postgres/pgxlisten
Package pgxlisten is the postgres bus's Listener over pgx v5: one dedicated connection that LISTENs and hands every notification over.
|
Package pgxlisten is the postgres bus's Listener over pgx v5: one dedicated connection that LISTENs and hands every notification over. |
|
qstash
Package qstash holds the reference Queue adapter over Upstash QStash HTTP queues, talking to the REST API directly.
|
Package qstash holds the reference Queue adapter over Upstash QStash HTTP queues, talking to the REST API directly. |
|
redis
Package redis holds the reference Kv and EventBus adapters over Redis (github.com/redis/go-redis/v9).
|
Package redis holds the reference Kv and EventBus adapters over Redis (github.com/redis/go-redis/v9). |
|
sqlite
Package sqlite holds a complete Storage over SQLite (§3.2): every table the platform needs, created on construction.
|
Package sqlite holds a complete Storage over SQLite (§3.2): every table the platform needs, created on construction. |
|
upstash
Package upstash holds the reference Kv and EventBus adapters over the Upstash Redis REST API.
|
Package upstash holds the reference Kv and EventBus adapters over the Upstash Redis REST API. |
|
Package admin picks the operational store SetupAgentCore uses when none is configured (§2.9).
|
Package admin picks the operational store SetupAgentCore uses when none is configured (§2.9). |
|
memory
Package memory holds operational history in memory: tests, and a template.
|
Package memory holds operational history in memory: tests, and a template. |
|
migrate
Package migrate applies the platform's OWN schema to the admin store (§2.9), from numbered .sql files.
|
Package migrate applies the platform's OWN schema to the admin store (§2.9), from numbered .sql files. |
|
postgres
Package postgres holds operational history in Postgres (§2.9): the production store, reached through AGENTIC_KIT_ADMIN_DATABASE_URL.
|
Package postgres holds operational history in Postgres (§2.9): the production store, reached through AGENTIC_KIT_ADMIN_DATABASE_URL. |
|
sqlite
Package sqlite holds operational history in SQLite (§2.9): the development store.
|
Package sqlite holds operational history in SQLite (§2.9): the development store. |
|
Package core holds the platform's behaviors.
|
Package core holds the platform's behaviors. |
|
Package ports holds the contract between the platform and the code around it: the four ports a caller implements (Storage, EventBus, Queue, Kv), the platform's own AdminStore, and every DTO that crosses those boundaries.
|
Package ports holds the contract between the platform and the code around it: the four ports a caller implements (Storage, EventBus, Queue, Kv), the platform's own AdminStore, and every DTO that crosses those boundaries. |
|
Package pricing holds the pricers that ship with the platform (§4).
|
Package pricing holds the pricers that ship with the platform (§4). |