Documentation
¶
Index ¶
- func Adapt(legacy tools.Tool, toolCtx tools.ToolContext) agent.Tool
- type ArtifactBaseline
- type AttachmentIngestor
- type EventContext
- type Finalization
- type Finalizer
- type Journal
- type JournalFactory
- type JournalSnapshot
- type NodeHandler
- type PlanPublishError
- type PlanPublisher
- type PlanPublisherConfig
- type PreparedRun
- type Preparer
- func NewPreparer(builder *agentruncontext.ContextBuilder) Preparer
- func NewPreparerWithPorts(builder *agentruncontext.ContextBuilder, wm WorkspaceManager, ...) Preparer
- func NewPreparerWithSessionStore(builder *agentruncontext.ContextBuilder, wm WorkspaceManager, ...) Preparer
- func NewPreparerWithTools(builder *agentruncontext.ContextBuilder, wm WorkspaceManager, ...) Preparer
- type ProviderSessionBinding
- type ProviderSessionKey
- type ProviderSessionStore
- type RunEventDraft
- type RunEventPublisher
- type Service
- type ToolProvider
- type WorkspaceManager
- type WorkspacePreparation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArtifactBaseline ¶
type ArtifactBaseline struct {
Ref string
}
ArtifactBaseline captures artifact state before execution.
type AttachmentIngestor ¶
type AttachmentIngestor interface {
IngestAttachments(ctx context.Context, req *agentrundomain.RunRequest)
}
AttachmentIngestor downloads and commits user attachments into the workspace. It is best-effort: failures are logged but do not block the run.
func NewAttachmentIngestor ¶
func NewAttachmentIngestor() AttachmentIngestor
NewAttachmentIngestor creates a new AttachmentIngestor.
type EventContext ¶
type EventContext struct {
OrgID uint
WorkerID uint
SessionID string
AssistantID string
TraceID string
RequestID string
TaskID string
RunID string
ParentID string
ReplyToMessageIDs []string
}
EventContext carries immutable routing and tracing values for one business run.
type Finalization ¶
type Finalization struct {
Result *agentrundomain.RunResult
Events []messaging.RunEventBody
}
Finalization holds the final business result and events emitted before terminal.
type Finalizer ¶
type Finalizer interface {
FinalizeRequired(
ctx context.Context,
run *PreparedRun,
runtimeResult *agent.ExecutionResult,
snapshot JournalSnapshot,
) (*Finalization, error)
PostRunBestEffort(
ctx context.Context,
run *PreparedRun,
result *agentrundomain.RunResult,
snapshot JournalSnapshot,
)
}
Finalizer performs required business finalization and best-effort post-run work.
type Journal ¶
type Journal interface {
Record(ctx context.Context, event RunEventDraft) error
Snapshot() JournalSnapshot
}
Journal records, sequences, archives, and publishes events for one business run.
func NewJournal ¶
func NewJournal( req *agentrundomain.RunRequest, eventContext EventContext, publisher RunEventPublisher, ) Journal
NewJournal creates a Journal bound to a request and an explicit publisher.
type JournalFactory ¶
type JournalFactory interface {
New(
req *agentrundomain.RunRequest,
eventContext EventContext,
publisher RunEventPublisher,
) Journal
}
JournalFactory creates a Journal bound to a run and downstream observer.
func NewJournalFactory ¶
func NewJournalFactory() JournalFactory
NewJournalFactory creates the default JournalFactory.
type JournalSnapshot ¶
type JournalSnapshot struct {
ToolCalls []agentrundomain.ToolCallRecord
Usage *agentrundomain.Usage
MessageCount int
ToolFailures int
ToolNames []string
Events []messaging.RunEventRecord
}
JournalSnapshot is the immutable activity summary used by finalization.
type NodeHandler ¶
type NodeHandler struct {
// contains filtered or unexported fields
}
NodeHandler owns the Worker-side interpretation of runtime NodeEvents.
func NewNodeHandler ¶
func NewNodeHandler( journal Journal, planPublisher PlanPublisher, sessionStore ProviderSessionStore, provider string, sessionKey string, assistantID string, ) *NodeHandler
NewNodeHandler creates the business handler used as the Runtime observer.
func (*NodeHandler) Observe ¶
Observe handles internal nodes and maps externally visible nodes to RunEventBody.
func (*NodeHandler) PlanError ¶
func (h *NodeHandler) PlanError() error
PlanError returns a plan publication error captured during runtime observation.
type PlanPublishError ¶
PlanPublishError is a business-stage error during plan publishing. AgentRun records it after Runtime execution returns so it is not mistaken for a Runtime adapter failure.
func (*PlanPublishError) Error ¶
func (e *PlanPublishError) Error() string
func (*PlanPublishError) Unwrap ¶
func (e *PlanPublishError) Unwrap() error
type PlanPublisher ¶
type PlanPublisher interface {
Publish(ctx context.Context, event agent.NodeEvent) (*messaging.RunEventBody, error)
}
PlanPublisher processes plan.ready events emitted by the runtime. It reads the plan file, uploads it, and returns a plan.published event. Upload failures return PlanPublishError; AgentRun classifies those failures as business plan_publish errors instead of Runtime execution errors.
func NewPlanPublisher ¶
func NewPlanPublisher(cfg PlanPublisherConfig) PlanPublisher
NewPlanPublisher creates a PlanPublisher with injected dependencies.
type PlanPublisherConfig ¶
type PlanPublisherConfig struct {
ServerAddr string
OrgID uint
AuthToken string
HTTPClient *http.Client
}
PlanPublisherConfig holds injected dependencies for plan publishing.
type PreparedRun ¶
type PreparedRun struct {
Request *agentrundomain.RunRequest
Execution agent.ExecutionRequest
Workspace WorkspacePreparation
Baseline ArtifactBaseline
}
PreparedRun holds the immutable original request and the fully-built execution context. Request is the caller's original snapshot — it is never modified during preparation.
type Preparer ¶
type Preparer interface {
Prepare(ctx context.Context, req *agentrundomain.RunRequest) (*PreparedRun, error)
}
Preparer converts a business run request into an immutable prepared run.
func NewPreparer ¶
func NewPreparer(builder *agentruncontext.ContextBuilder) Preparer
NewPreparer creates a new RunPreparer.
func NewPreparerWithPorts ¶
func NewPreparerWithPorts( builder *agentruncontext.ContextBuilder, wm WorkspaceManager, ai AttachmentIngestor, modelStore *modelrouter.ModelStore, ) Preparer
NewPreparerWithPorts creates a RunPreparer with injected workspace and attachment ports.
func NewPreparerWithSessionStore ¶
func NewPreparerWithSessionStore( builder *agentruncontext.ContextBuilder, wm WorkspaceManager, ai AttachmentIngestor, modelStore *modelrouter.ModelStore, toolProvider ToolProvider, sessionStore ProviderSessionStore, ) Preparer
NewPreparerWithSessionStore creates a RunPreparer with ProviderSessionStore for resume support.
func NewPreparerWithTools ¶
func NewPreparerWithTools( builder *agentruncontext.ContextBuilder, wm WorkspaceManager, ai AttachmentIngestor, modelStore *modelrouter.ModelStore, toolProvider ToolProvider, ) Preparer
NewPreparerWithTools creates a RunPreparer with all external dependencies injected.
type ProviderSessionBinding ¶
type ProviderSessionBinding struct {
InternalSessionID string
Provider string
ProviderSessionID string
WorkDir string
AssistantID string
Status string
LastError string
}
ProviderSessionBinding maps a SingerOS session to a provider native session.
type ProviderSessionKey ¶
type ProviderSessionKey struct {
InternalSessionID string
Provider string
WorkDir string
AssistantID string
}
ProviderSessionKey identifies a provider session binding.
type ProviderSessionStore ¶
type ProviderSessionStore interface {
GetProviderSession(ctx context.Context, key ProviderSessionKey) (*ProviderSessionBinding, error)
UpsertProviderSession(ctx context.Context, binding *ProviderSessionBinding) error
MarkProviderSessionFailed(ctx context.Context, key ProviderSessionKey, reason string) error
}
ProviderSessionStore persists provider session bindings for external CLI resume. Implementations are provided by the Worker host layer (e.g. SQLite).
type RunEventDraft ¶
type RunEventDraft struct {
OccurredAt time.Time
Body messaging.RunEventBody
}
RunEventDraft is an unsequenced business event produced inside AgentRun.
type RunEventPublisher ¶
type RunEventPublisher interface {
PublishRunEvent(ctx context.Context, event messaging.RunEvent) error
}
RunEventPublisher publishes a fully constructed Worker/Server business event.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the single business entry point for an Agent Run.
func NewService ¶
func NewService( preparer Preparer, executor *agent.Executor, finalizer Finalizer, journal JournalFactory, planPublisher PlanPublisher, ) *Service
NewService creates a new AgentRun Service.
func NewServiceWithSessionStore ¶
func NewServiceWithSessionStore( preparer Preparer, executor *agent.Executor, finalizer Finalizer, journal JournalFactory, planPublisher PlanPublisher, sessionStore ProviderSessionStore, ) *Service
NewServiceWithSessionStore creates a new Service with ProviderSessionStore for resume support.
func (*Service) Run ¶
func (s *Service) Run( ctx context.Context, req *agentrundomain.RunRequest, eventContext EventContext, publisher RunEventPublisher, ) (*agentrundomain.RunResult, error)
Run executes one business agent run. It:
- Validates the request
- Emits run.started
- Calls Preparer to build ExecutionRequest
- Calls agent.Executor for the runtime lifecycle
- Calls Finalizer for required post-run tasks
- Emits artifact events
- Emits exactly one terminal event
- Runs best-effort post-run tasks
type ToolProvider ¶
type ToolProvider interface {
ToolsFor(
req *agentrundomain.RunRequest,
workspace WorkspacePreparation,
) ([]agent.Tool, error)
}
ToolProvider resolves business tools into the neutral execution contract.
func NewToolProvider ¶
func NewToolProvider(registry *tools.Registry) ToolProvider
NewToolProvider adapts the application tool registry at the AgentRun business boundary.
type WorkspaceManager ¶
type WorkspaceManager interface {
PrepareWorkspace(
ctx context.Context,
req agentworkspace.TaskWorkspaceRequest,
) (WorkspacePreparation, error)
}
WorkspaceManager prepares task workspaces (clone/populate repo).
func NewWorkspaceManager ¶
func NewWorkspaceManager(env, giteaEndpoint, giteaOwner, giteaAccessToken string) WorkspaceManager
NewWorkspaceManager creates a WorkspaceManager backed by the given Gitea config.