Documentation
¶
Overview ¶
Package server implements the local web API server, WebSocket, and embedded frontend.
Index ¶
- Variables
- type ArchiveService
- type AssertionDetail
- type AttemptSummary
- type BatchDetail
- type BatchListEntry
- type BatchRunSummary
- type DisplayOutput
- type ErrorClassDetail
- type ExpectFailureDetail
- type ExtractionDetail
- type HeaderEntry
- type ImportResponse
- type LLMCallDetail
- type LLMMessageDetail
- type OASPayloadDetail
- type OASValidationDetail
- type OASValidationErrorDetail
- type OutputConsumer
- type RenameRequest
- type RenameResponse
- type RequestDetail
- type ResolutionDetail
- type ResponseBodyErrorDetail
- type ResponseDetail
- type RunDetail
- type RunListEntry
- type SelectionDetail
- type Server
- type ServerOptions
- type SkeletonDetail
- type StepDetail
- type StepSummary
- type TraceDetail
- type TraceListEntry
- type TraceService
- type ValidationDetail
- type VisualizerHit
Constants ¶
This section is empty.
Variables ¶
var ( ErrRunNotFound = errors.New("run not found") ErrStepNotFound = errors.New("step not found") ErrBatchNotFound = errors.New("batch not found") )
Sentinel errors for service methods.
var ErrStaticMode = errors.New("operation not available in static viewing mode")
ErrStaticMode is returned when a mutating operation is attempted in static mode.
var ErrTraceNotFound = errors.New("trace not found")
ErrTraceNotFound indicates the requested trace does not exist.
Functions ¶
This section is empty.
Types ¶
type ArchiveService ¶
type ArchiveService interface {
ListRuns(limit int, savedOnly bool) ([]RunListEntry, error)
LatestRef() (id string, refType string, err error)
GetRun(id string) (*RunDetail, error)
GetAttempt(runID string, attemptNum int) (*RunDetail, error)
GetStep(runID, stepID string) (*StepDetail, error)
GetAttemptStep(runID string, attemptNum int, stepID string) (*StepDetail, error)
ListBatches(limit int, savedOnly bool) ([]BatchListEntry, error)
GetBatch(id string) (*BatchDetail, error)
ExportRun(id string, w io.Writer) (string, error)
ExportBatch(id string, w io.Writer) (string, error)
ImportArchive(data io.ReaderAt, size int64, filename string) (ref string, archiveType string, err error)
RenameRun(currentRef, newName string) (string, error)
UnnameRun(currentRef string) (string, error)
RenameBatch(currentRef, newName string) (string, error)
UnnameBatch(currentRef string) (string, error)
}
ArchiveService provides read access to run archives for the web API.
func NewArchiveService ¶
func NewArchiveService(archiveDir string) ArchiveService
NewArchiveService creates an ArchiveService that reads from the given directory.
func NewArchiveServiceFromBatch ¶
func NewArchiveServiceFromBatch(id string, b *archive.BatchArchive, runs map[string]*archive.Archive, attempts map[string]map[int]*archive.Archive) ArchiveService
NewArchiveServiceFromBatch creates an ArchiveService pre-loaded with a batch archive and its member runs. No disk access is performed.
func NewArchiveServiceFromRun ¶
func NewArchiveServiceFromRun(id string, a *archive.Archive, attempts map[int]*archive.Archive) ArchiveService
NewArchiveServiceFromRun creates an ArchiveService pre-loaded with a single run archive and its attempts. No disk access is performed.
type AssertionDetail ¶
type AssertionDetail struct {
Type string `json:"type"`
Passed bool `json:"passed"`
Skipped bool `json:"skipped,omitempty"`
Message string `json:"message"`
Path string `json:"path,omitempty"`
Expr string `json:"expr,omitempty"`
Raw bool `json:"raw,omitempty"`
}
AssertionDetail captures the result of a single assertion.
type AttemptSummary ¶
type AttemptSummary struct {
Attempt int `json:"attempt"`
Outcome string `json:"outcome"`
Error string `json:"error,omitempty"`
FileName string `json:"fileName"`
}
AttemptSummary captures the outcome of a single retry attempt.
type BatchDetail ¶
type BatchDetail struct {
BatchID string `json:"batchId"`
Timestamp time.Time `json:"timestamp"`
Outcome string `json:"outcome"`
TotalRuns int `json:"totalRuns"`
PassedRuns int `json:"passedRuns"`
FailedRuns int `json:"failedRuns"`
ErrorRuns int `json:"errorRuns"`
SkippedRuns int `json:"skippedRuns,omitempty"`
TotalDurationMs int64 `json:"totalDurationMs"`
DurationDisplay string `json:"durationDisplay"`
Source string `json:"source,omitempty"`
ToolVersion string `json:"toolVersion,omitempty"`
Runs []BatchRunSummary `json:"runs"`
Name string `json:"name,omitempty"`
Layers []string `json:"layers,omitempty"`
LayerGroups [][]string `json:"layerGroups,omitempty"`
Issues map[string]int `json:"issues,omitempty"`
}
BatchDetail is the full overview of a batch run.
type BatchListEntry ¶
type BatchListEntry struct {
BatchID string `json:"batchId"`
Timestamp time.Time `json:"timestamp"`
Outcome string `json:"outcome"`
TotalRuns int `json:"totalRuns"`
PassedRuns int `json:"passedRuns"`
FailedRuns int `json:"failedRuns"`
ErrorRuns int `json:"errorRuns"`
TotalDurationMs int64 `json:"totalDurationMs"`
Source string `json:"source,omitempty"`
ToolVersion string `json:"toolVersion,omitempty"`
Name string `json:"name,omitempty"`
Layers []string `json:"layers,omitempty"`
Issues map[string]int `json:"issues,omitempty"`
}
BatchListEntry is a summary of a batch run for list display.
type BatchRunSummary ¶
type BatchRunSummary struct {
PlanName string `json:"planName"`
RunID string `json:"runId"`
Outcome string `json:"outcome"`
StepCount int `json:"stepCount"`
PassedCount int `json:"passedCount"`
FailedCount int `json:"failedCount"`
DurationMs int64 `json:"durationMs"`
Error string `json:"error,omitempty"`
Attempts int `json:"attempts,omitempty"`
Layers []string `json:"layers,omitempty"`
Permutation string `json:"permutation,omitempty"`
Skipped bool `json:"skipped,omitempty"`
DuplicateOf string `json:"duplicateOf,omitempty"`
Issues map[string]int `json:"issues,omitempty"`
}
BatchRunSummary is a compact view of a single run within a batch.
type DisplayOutput ¶
type DisplayOutput struct {
Label string `json:"label"`
Name string `json:"name"`
Value any `json:"value,omitempty"`
}
DisplayOutput surfaces a labeled output value for quick display.
type ErrorClassDetail ¶
type ErrorClassDetail struct {
Category string `json:"category"`
Detail string `json:"detail"`
Action string `json:"action"`
RetryAttempt int `json:"retryAttempt"`
}
ErrorClassDetail captures the error classification for a failed step.
type ExpectFailureDetail ¶
type ExpectFailureDetail struct {
Expected []int `json:"expected"`
Actual int `json:"actual"`
Passed bool `json:"passed"`
}
ExpectFailureDetail captures the outcome of a negative assertion.
type ExtractionDetail ¶
type ExtractionDetail struct {
Name string `json:"name"`
Value any `json:"value,omitempty"`
Consumers []OutputConsumer `json:"consumers,omitempty"`
}
ExtractionDetail captures a single output value and which downstream steps consumed it.
type HeaderEntry ¶
HeaderEntry is a single HTTP header name-value pair.
type ImportResponse ¶
type ImportResponse struct {
Ref string `json:"ref"`
Name string `json:"name"`
Type string `json:"type"` // "run" or "batch"
}
ImportResponse is the JSON response from the import endpoint.
type LLMCallDetail ¶
type LLMCallDetail struct {
Messages []LLMMessageDetail `json:"messages"`
Model string `json:"model"`
Response string `json:"response"`
InputTokens int `json:"inputTokens"`
OutputTokens int `json:"outputTokens"`
DurationMs int64 `json:"durationMs"`
FinishReason string `json:"finishReason,omitempty"`
Error string `json:"error,omitempty"`
}
LLMCallDetail captures details of a single LLM API call.
type LLMMessageDetail ¶
LLMMessageDetail captures a single prompt message sent to the LLM.
type OASPayloadDetail ¶ added in v0.0.3
type OASPayloadDetail struct {
Valid bool `json:"valid"`
ErrorCount int `json:"errorCount"`
Errors []OASValidationErrorDetail `json:"errors,omitempty"`
CompilationWarnings []string `json:"compilationWarnings,omitempty"`
}
OASPayloadDetail captures validation for one direction (request or response).
type OASValidationDetail ¶ added in v0.0.3
type OASValidationDetail struct {
OperationID string `json:"operationId,omitempty"`
Request *OASPayloadDetail `json:"request,omitempty"`
Response *OASPayloadDetail `json:"response,omitempty"`
Skipped bool `json:"skipped,omitempty"`
SkipReason string `json:"skipReason,omitempty"`
}
OASValidationDetail captures runtime OAS schema validation for a step.
type OASValidationErrorDetail ¶ added in v0.0.3
OASValidationErrorDetail captures a single OAS validation error.
type OutputConsumer ¶
type OutputConsumer struct {
StepID string `json:"stepId"`
InputName string `json:"inputName"`
Via string `json:"via"` // "resolution" or "selection"
}
OutputConsumer identifies a downstream step that consumed an extracted output.
type RenameRequest ¶
type RenameRequest struct {
Name string `json:"name"`
}
RenameRequest is the JSON body for rename endpoints.
type RenameResponse ¶
RenameResponse is the JSON response from rename/unname endpoints.
type RequestDetail ¶
type RequestDetail struct {
Method string `json:"method"`
URL string `json:"url"`
OriginalURL string `json:"originalUrl,omitempty"`
Headers []HeaderEntry `json:"headers,omitempty"`
Body json.RawMessage `json:"body,omitempty"`
}
RequestDetail captures the outbound HTTP request.
type ResolutionDetail ¶
type ResolutionDetail struct {
InputName string `json:"inputName"`
Source string `json:"source"`
RawValue any `json:"rawValue,omitempty"`
FinalValue any `json:"finalValue,omitempty"`
FromStep string `json:"fromStep,omitempty"`
FromOutput string `json:"fromOutput,omitempty"`
FromInput string `json:"fromInput,omitempty"`
Expression string `json:"expression,omitempty"`
Constraint string `json:"constraint,omitempty"`
ConstraintOK *bool `json:"constraintOk,omitempty"`
PoolIndex int `json:"poolIndex,omitempty"`
PoolSize int `json:"poolSize,omitempty"`
Tried []any `json:"tried,omitempty"`
}
ResolutionDetail captures how a single input was resolved.
type ResponseBodyErrorDetail ¶
type ResponseBodyErrorDetail struct {
RulePath string `json:"rulePath"`
Rule string `json:"rule"`
Message string `json:"message,omitempty"`
Code string `json:"code,omitempty"`
Category string `json:"category,omitempty"`
}
ResponseBodyErrorDetail captures an error detected in a 2xx response body.
type ResponseDetail ¶
type ResponseDetail struct {
Status int `json:"status"`
Headers []HeaderEntry `json:"headers,omitempty"`
Body json.RawMessage `json:"body,omitempty"`
}
ResponseDetail captures the HTTP response.
type RunDetail ¶
type RunDetail struct {
RunID string `json:"runId"`
Timestamp time.Time `json:"timestamp"`
Outcome string `json:"outcome"`
Error string `json:"error,omitempty"`
DurationMs int64 `json:"durationMs"`
DurationDisplay string `json:"durationDisplay"`
StepCount int `json:"stepCount"`
PassedCount int `json:"passedCount"`
FailedCount int `json:"failedCount"`
PlanName string `json:"planName,omitempty"`
Environment string `json:"environment,omitempty"`
GraphVersion string `json:"graphVersion,omitempty"`
ToolVersion string `json:"toolVersion,omitempty"`
BatchID string `json:"batchId,omitempty"`
Steps []StepSummary `json:"steps"`
Cleanup []StepSummary `json:"cleanup,omitempty"`
Attempt int `json:"attempt,omitempty"`
TotalAttempts int `json:"totalAttempts,omitempty"`
Attempts []AttemptSummary `json:"attempts,omitempty"`
Name string `json:"name,omitempty"`
Layers []string `json:"layers,omitempty"`
}
RunDetail is the full overview of a single run.
type RunListEntry ¶
type RunListEntry struct {
RunID string `json:"runId"`
Timestamp time.Time `json:"timestamp"`
Outcome string `json:"outcome"`
StepCount int `json:"stepCount"`
PassedCount int `json:"passedCount"`
FailedCount int `json:"failedCount"`
DurationMs int64 `json:"durationMs"`
PlanName string `json:"planName,omitempty"`
BatchID string `json:"batchId,omitempty"`
Attempt int `json:"attempt,omitempty"`
TotalAttempts int `json:"totalAttempts,omitempty"`
Name string `json:"name,omitempty"`
Layers []string `json:"layers,omitempty"`
Issues map[string]int `json:"issues,omitempty"`
}
RunListEntry is a summary of a single run for list display.
type SelectionDetail ¶
type SelectionDetail struct {
InputName string `json:"inputName"`
SourceStep string `json:"sourceStep,omitempty"`
SourceNode string `json:"sourceNode"`
SourceField string `json:"sourceField"`
SourceSize int `json:"sourceSize"`
FilterExpr string `json:"filterExpr,omitempty"`
FilteredSize int `json:"filteredSize"`
Strategy string `json:"strategy"`
SelectedIndex int `json:"selectedIndex"`
SelectionName string `json:"selectionName,omitempty"`
}
SelectionDetail captures how an array selection was resolved.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the AAT web API server.
func NewServer ¶
func NewServer(opts ServerOptions) *Server
NewServer creates a Server with the given options. Port defaults to 9119 if not set.
func NewServerWithService ¶
func NewServerWithService(opts ServerOptions, svc ArchiveService) *Server
NewServerWithService creates a Server with a pre-built ArchiveService. This is used for static/in-memory archive viewing where no disk access is needed.
func (*Server) Addr ¶
Addr returns the actual listening address. Only valid after ListenAndServe has started.
func (*Server) ListenAndServe ¶
ListenAndServe starts serving HTTP requests. It blocks until the server is shut down, at which point it returns http.ErrServerClosed.
type ServerOptions ¶
type ServerOptions struct {
Port int
ArchiveDir string
TracesDir string
VisualizerDir string
DevMode bool
ViteURL string // Vite dev server URL for dev proxy (default http://localhost:5173)
}
ServerOptions configures the web server.
type SkeletonDetail ¶
type SkeletonDetail struct {
PlanYAML string `json:"planYaml"`
UnfedInputs []string `json:"unfedInputs,omitempty"`
DurationMs int64 `json:"durationMs"`
}
SkeletonDetail captures the skeleton plan construction step.
type StepDetail ¶
type StepDetail struct {
StepID string `json:"stepId"`
Node string `json:"node"`
Status int `json:"status,omitempty"`
DurationMs int64 `json:"durationMs"`
DurationDisplay string `json:"durationDisplay"`
Passed bool `json:"passed"`
AssertionCount int `json:"assertionCount"`
AssertionPassedCount int `json:"assertionPassedCount"`
DisplayOutputs []DisplayOutput `json:"displayOutputs,omitempty"`
Error string `json:"error,omitempty"`
IsCleanup bool `json:"isCleanup,omitempty"`
HasSelections bool `json:"hasSelections,omitempty"`
HasResolutions bool `json:"hasResolutions,omitempty"`
RetryCount int `json:"retryCount,omitempty"`
StartTime time.Time `json:"startTime,omitempty"`
Inputs map[string]any `json:"inputs,omitempty"`
Outputs map[string]any `json:"outputs,omitempty"`
Request *RequestDetail `json:"request,omitempty"`
Response *ResponseDetail `json:"response,omitempty"`
Validation *ValidationDetail `json:"validation,omitempty"`
Selections []SelectionDetail `json:"selections,omitempty"`
Resolutions []ResolutionDetail `json:"resolutions,omitempty"`
ErrorClassification *ErrorClassDetail `json:"errorClassification,omitempty"`
ExpectFailure *ExpectFailureDetail `json:"expectFailure,omitempty"`
ResponseBodyError *ResponseBodyErrorDetail `json:"responseBodyError,omitempty"`
OASValidation *OASValidationDetail `json:"oasValidation,omitempty"`
TransformScript string `json:"transformScript,omitempty"`
Extractions []ExtractionDetail `json:"extractions,omitempty"`
PlanStepYAML string `json:"planStepYaml,omitempty"`
InstantiatedStepYAML string `json:"instantiatedStepYaml,omitempty"`
PrevStepID string `json:"prevStepId,omitempty"`
NextStepID string `json:"nextStepId,omitempty"`
Visualizers []VisualizerHit `json:"visualizers,omitempty"`
}
StepDetail is the full audit view of a single step.
type StepSummary ¶
type StepSummary struct {
StepID string `json:"stepId"`
Node string `json:"node"`
Status int `json:"status,omitempty"`
DurationMs int64 `json:"durationMs"`
DurationDisplay string `json:"durationDisplay"`
Passed bool `json:"passed"`
AssertionCount int `json:"assertionCount"`
AssertionPassedCount int `json:"assertionPassedCount"`
DisplayOutputs []DisplayOutput `json:"displayOutputs,omitempty"`
Error string `json:"error,omitempty"`
IsCleanup bool `json:"isCleanup,omitempty"`
HasSelections bool `json:"hasSelections,omitempty"`
HasResolutions bool `json:"hasResolutions,omitempty"`
HasTransform bool `json:"hasTransform,omitempty"`
HasOASValidation bool `json:"hasOasValidation,omitempty"`
OASErrorCount int `json:"oasErrorCount,omitempty"`
OASReqErrorCount int `json:"oasReqErrorCount,omitempty"`
OASRespErrorCount int `json:"oasRespErrorCount,omitempty"`
OASWarningCount int `json:"oasWarningCount,omitempty"`
RetryCount int `json:"retryCount,omitempty"`
OffsetMs int64 `json:"offsetMs,omitempty"`
}
StepSummary is a compact view of a step for timeline display.
type TraceDetail ¶
type TraceDetail struct {
TraceID string `json:"traceId"`
Timestamp time.Time `json:"timestamp"`
Prompt string `json:"prompt"`
SelectionCall *LLMCallDetail `json:"selectionCall"`
SelectionRetryCall *LLMCallDetail `json:"selectionRetryCall,omitempty"`
WorkflowSelection any `json:"workflowSelection,omitempty"`
Skeleton *SkeletonDetail `json:"skeleton,omitempty"`
PlanCall *LLMCallDetail `json:"planCall"`
TargetedResponse any `json:"targetedResponse,omitempty"`
MergedPlanYAML string `json:"mergedPlanYaml,omitempty"`
FinalPlanYAML string `json:"finalPlanYaml,omitempty"`
ValidationErr string `json:"validationErr,omitempty"`
RetryCall *LLMCallDetail `json:"retryCall,omitempty"`
RetryValidationErr string `json:"retryValidationErr,omitempty"`
TotalDurationMs int64 `json:"totalDurationMs"`
Error string `json:"error,omitempty"`
// Wrong-plan escape fields.
WrongPlanSignal any `json:"wrongPlanSignal,omitempty"`
WrongPlanCall *LLMCallDetail `json:"wrongPlanCall,omitempty"`
ReselectionCall *LLMCallDetail `json:"reselectionCall,omitempty"`
// Workflow metadata.
WorkflowName string `json:"workflowName,omitempty"`
TemplatePath string `json:"templatePath,omitempty"`
RecipeYAML string `json:"recipeYaml,omitempty"`
}
TraceDetail is the full view of a plan trace for the trace detail page.
type TraceListEntry ¶
type TraceListEntry struct {
TraceID string `json:"traceId"`
Timestamp time.Time `json:"timestamp"`
Prompt string `json:"prompt"`
WorkflowName string `json:"workflowName,omitempty"`
TotalDurationMs int64 `json:"totalDurationMs"`
HasError bool `json:"hasError"`
LLMCallCount int `json:"llmCallCount"`
}
TraceListEntry is a summary of a single plan trace for list display.
type TraceService ¶
type TraceService struct {
// contains filtered or unexported fields
}
TraceService provides read access to plan traces for the web API.
func NewTraceService ¶
func NewTraceService(tracesDir string) *TraceService
NewTraceService creates a TraceService that reads from the given directory.
func (*TraceService) GetTrace ¶
func (s *TraceService) GetTrace(id string) (*TraceDetail, error)
GetTrace loads a full trace detail by trace ID.
func (*TraceService) ListTraces ¶
func (s *TraceService) ListTraces(limit int) ([]TraceListEntry, error)
ListTraces scans the traces directory for trace directories, reads each trace, and returns summaries sorted newest-first. limit=0 means no limit. Unreadable traces are skipped silently.
type ValidationDetail ¶
type ValidationDetail struct {
Passed bool `json:"passed"`
Results []AssertionDetail `json:"results,omitempty"`
}
ValidationDetail captures the outcome of mechanical assertions.
type VisualizerHit ¶ added in v0.0.3
VisualizerHit is returned by matchVisualizers to identify which visualizers apply to a given step response.