Documentation
¶
Index ¶
- Constants
- Variables
- func IsNotFound(err error) bool
- type Bucket
- type PostgresRepository
- func (r *PostgresRepository) BucketRuns(ctx context.Context, agentID string, since time.Time) ([]Bucket, error)
- func (r *PostgresRepository) GetByAgentRunID(ctx context.Context, agentID, runID string) (*Run, error)
- func (r *PostgresRepository) InsertRun(ctx context.Context, run *Run) error
- func (r *PostgresRepository) ListRuns(ctx context.Context, agentID string, since time.Time, limit int) ([]*Run, error)
- func (r *PostgresRepository) Stats(ctx context.Context, agentID string, since time.Time) (*Stats, error)
- type Repository
- type Run
- type RunInput
- type Service
- type Stats
- type ToolCall
- type ToolCallInput
Constants ¶
View Source
const EdgeTypeAgentLookup = "AGENT_LOOKUP"
EdgeTypeAgentLookup is the lineage type emitted for tool-call observations where the agent touched a catalogued asset.
Variables ¶
View Source
var ( ErrAgentNotFound = errors.New("agent not found") ErrRunNotFound = errors.New("agent run not found") )
Functions ¶
func IsNotFound ¶
IsNotFound returns true if err is one of the package's not-found sentinels. Useful for handlers that translate to 404.
Types ¶
type Bucket ¶
type Bucket struct {
Hour time.Time `json:"hour"`
Success int `json:"success"`
Error int `json:"error"`
}
Bucket is an hour-aligned aggregate of runs by status.
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
func (*PostgresRepository) BucketRuns ¶
func (*PostgresRepository) GetByAgentRunID ¶
func (*PostgresRepository) InsertRun ¶
func (r *PostgresRepository) InsertRun(ctx context.Context, run *Run) error
type Repository ¶
type Repository interface {
InsertRun(ctx context.Context, r *Run) error
GetByAgentRunID(ctx context.Context, agentID, runID string) (*Run, error)
ListRuns(ctx context.Context, agentID string, since time.Time, limit int) ([]*Run, error)
BucketRuns(ctx context.Context, agentID string, since time.Time) ([]Bucket, error)
Stats(ctx context.Context, agentID string, since time.Time) (*Stats, error)
}
func NewPostgresRepository ¶
func NewPostgresRepository(db *pgxpool.Pool) Repository
type Run ¶
type Run struct {
ID string `json:"id"`
AgentID string `json:"agent_id"`
RunID string `json:"run_id"`
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at,omitempty"`
DurationMs *int `json:"duration_ms,omitempty"`
Status string `json:"status"`
Model string `json:"model,omitempty"`
TokensIn int `json:"tokens_in"`
TokensOut int `json:"tokens_out"`
Error string `json:"error,omitempty"`
CreatedAt time.Time `json:"created_at"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}
Run is a single agent invocation as recorded by the SDK.
type RunInput ¶
type RunInput struct {
AgentMRN string `json:"agent_mrn"`
RunID string `json:"run_id"`
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at,omitempty"`
Status string `json:"status"`
Model string `json:"model,omitempty"`
TokensIn int `json:"tokens_in"`
TokensOut int `json:"tokens_out"`
Error string `json:"error,omitempty"`
ToolCalls []ToolCallInput `json:"tool_calls,omitempty"`
// ObservedAssets are MRNs the agent touched at runtime that aren't already
// surfaced through ToolCalls' target_mrn — typically extracted from tool
// outputs (e.g. catalog-traversal tools that return MRNs). The server
// emits an AGENT_LOOKUP observed edge for each.
ObservedAssets []string `json:"observed_assets,omitempty"`
}
RunInput is what the SDK posts when an agent run completes.
type Service ¶
type Service interface {
RecordRun(ctx context.Context, input RunInput) (*Run, error)
ListRuns(ctx context.Context, assetID string, period time.Duration, limit int) ([]*Run, error)
BucketRuns(ctx context.Context, assetID string, period time.Duration) ([]Bucket, error)
Stats(ctx context.Context, assetID string, period time.Duration) (*Stats, error)
}
func NewService ¶
type Stats ¶
type Stats struct {
RunCount int `json:"run_count"`
SuccessRate float64 `json:"success_rate"`
MedianLatency int `json:"median_latency_ms"`
P95Latency int `json:"p95_latency_ms"`
TokensIn int `json:"tokens_in"`
TokensOut int `json:"tokens_out"`
}
Stats summarises agent activity over a window.
type ToolCall ¶
type ToolCall struct {
Ordinal int `json:"ordinal"`
ToolName string `json:"tool_name"`
TargetMRN string `json:"target_mrn,omitempty"`
StartedAt time.Time `json:"started_at"`
DurationMs *int `json:"duration_ms,omitempty"`
Status string `json:"status"`
}
ToolCall is a single tool invocation inside a Run.
Click to show internal directories.
Click to hide internal directories.