handlers

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtifactHandler

type ArtifactHandler struct {
	// contains filtered or unexported fields
}

ArtifactHandler serves cross-session shared artifact endpoints.

func NewArtifactHandler

func NewArtifactHandler(h *Hub) *ArtifactHandler

func (*ArtifactHandler) Delete

func (ah *ArtifactHandler) Delete(c *gin.Context)

DELETE /api/v1/artifacts/:id

func (*ArtifactHandler) Download

func (ah *ArtifactHandler) Download(c *gin.Context)

GET /api/v1/artifacts/:id/download Streams the artifact file. Non-master callers may only download artifacts they created.

func (*ArtifactHandler) List

func (ah *ArtifactHandler) List(c *gin.Context)

GET /api/v1/artifacts Lists shared artifacts. Non-master callers see only their own artifacts.

func (*ArtifactHandler) Promote

func (ah *ArtifactHandler) Promote(c *gin.Context)

POST /api/v1/sessions/:id/artifacts Promotes a file from the session workspace to the shared artifact registry. Body: {"path":"/workspace/output.csv","name":"output.csv"} (name is optional)

type AuditHandler

type AuditHandler struct {
	// contains filtered or unexported fields
}

func NewAuditHandler

func NewAuditHandler(h *Hub) *AuditHandler

func (*AuditHandler) List

func (ah *AuditHandler) List(c *gin.Context)

GET /api/v1/audit

type CollabHandler added in v0.3.0

type CollabHandler struct {
	// contains filtered or unexported fields
}

CollabHandler handles collaboration-related HTTP requests

func NewCollabHandler added in v0.3.0

func NewCollabHandler(manager *collab.Manager, hub *collab.Hub, baseHub *Hub) *CollabHandler

NewCollabHandler creates a new collaboration handler

func (*CollabHandler) AddGraphEdge added in v0.3.2

func (h *CollabHandler) AddGraphEdge(c *gin.Context)

AddGraphEdge adds or updates a directed swarm edge. POST /api/v1/sessions/:id/graph/edges

func (*CollabHandler) EnableCollaboration added in v0.3.0

func (h *CollabHandler) EnableCollaboration(c *gin.Context)

EnableCollaboration enables collaboration for a session POST /api/v1/sessions/:id/enable-collaboration

func (*CollabHandler) GetActiveAgents added in v0.3.0

func (h *CollabHandler) GetActiveAgents(c *gin.Context)

GetActiveAgents returns all active agents for a session GET /api/v1/sessions/:id/agents

func (*CollabHandler) GetAgentGraph added in v0.3.2

func (h *CollabHandler) GetAgentGraph(c *gin.Context)

GetAgentGraph returns active agents plus swarm topology edges. GET /api/v1/sessions/:id/graph

func (*CollabHandler) GetMessages added in v0.3.0

func (h *CollabHandler) GetMessages(c *gin.Context)

GetMessages returns recent messages for a session GET /api/v1/sessions/:id/messages?limit=100

func (*CollabHandler) RemoveGraphEdge added in v0.3.2

func (h *CollabHandler) RemoveGraphEdge(c *gin.Context)

RemoveGraphEdge deletes a swarm edge. DELETE /api/v1/sessions/:id/graph/edges/:edge_id

func (*CollabHandler) SendMessage added in v0.3.0

func (h *CollabHandler) SendMessage(c *gin.Context)

SendMessage sends a message to agents in a session POST /api/v1/sessions/:id/messages

func (*CollabHandler) WebSocket added in v0.3.0

func (h *CollabHandler) WebSocket(c *gin.Context)

WebSocket handles WebSocket connections for collaborative sessions GET /api/v1/sessions/:id/ws?agent_id=agent_a&agent_name=Architect

type CostHandler added in v0.3.0

type CostHandler struct {
	// contains filtered or unexported fields
}

func NewCostHandler added in v0.3.0

func NewCostHandler(h *Hub, tracker *cost.Tracker) *CostHandler

func (*CostHandler) GetAlerts added in v0.3.0

func (ch *CostHandler) GetAlerts(c *gin.Context)

GET /api/v1/costs/alerts

func (*CostHandler) GetCostBreakdown added in v0.3.0

func (ch *CostHandler) GetCostBreakdown(c *gin.Context)

GET /api/v1/costs/breakdown?period=YYYY-MM

func (*CostHandler) GetOrgCosts added in v0.3.0

func (ch *CostHandler) GetOrgCosts(c *gin.Context)

GET /api/v1/orgs/:id/costs?month=YYYY-MM

func (*CostHandler) GetRates added in v0.3.0

func (ch *CostHandler) GetRates(c *gin.Context)

GET /api/v1/costs/rates

func (*CostHandler) GetSessionCosts added in v0.3.0

func (ch *CostHandler) GetSessionCosts(c *gin.Context)

GET /api/v1/sessions/:id/costs

func (*CostHandler) ResolveAlert added in v0.3.0

func (ch *CostHandler) ResolveAlert(c *gin.Context)

POST /api/v1/costs/alerts/:id/resolve

func (*CostHandler) SetBudget added in v0.3.0

func (ch *CostHandler) SetBudget(c *gin.Context)

POST /api/v1/orgs/:id/budget

type DockerHandler

type DockerHandler struct {
	// contains filtered or unexported fields
}

DockerHandler serves Docker image and container-management endpoints. All routes are restricted to the master API key except the per-session stats/logs endpoints which use the standard session-access check.

func NewDockerHandler

func NewDockerHandler(h *Hub) *DockerHandler

func (*DockerHandler) ListImages

func (dh *DockerHandler) ListImages(c *gin.Context)

GET /api/v1/docker/images Returns the list of Docker images locally available on the host.

func (*DockerHandler) PullImage

func (dh *DockerHandler) PullImage(c *gin.Context)

POST /api/v1/docker/images/pull Body: {"image":"python:3.12-slim"} Pulls a Docker image from the registry and blocks until complete.

func (*DockerHandler) SessionLogs

func (dh *DockerHandler) SessionLogs(c *gin.Context)

GET /api/v1/sessions/:id/logs?tail=100 Streams the last N lines of stdout+stderr from the session's container.

func (*DockerHandler) SessionStats

func (dh *DockerHandler) SessionStats(c *gin.Context)

GET /api/v1/sessions/:id/stats Returns a one-shot CPU/memory/network snapshot for the session's container.

type FileHandler

type FileHandler struct {
	// contains filtered or unexported fields
}

func NewFileHandler

func NewFileHandler(h *Hub) *FileHandler

func (*FileHandler) Delete

func (fh *FileHandler) Delete(c *gin.Context)

DELETE /api/v1/sessions/:id/files/*path

func (*FileHandler) Download

func (fh *FileHandler) Download(c *gin.Context)

GET /api/v1/sessions/:id/files/*path

func (*FileHandler) List

func (fh *FileHandler) List(c *gin.Context)

GET /api/v1/sessions/:id/files

func (*FileHandler) Upload

func (fh *FileHandler) Upload(c *gin.Context)

POST /api/v1/sessions/:id/files

func (*FileHandler) WorkspaceZip

func (fh *FileHandler) WorkspaceZip(c *gin.Context)

GET /api/v1/sessions/:id/workspace.zip Streams the entire workspace as a ZIP archive. Symlink escape protection is applied: symlinks whose real target lies outside the workspace are skipped.

type HealthHandler

type HealthHandler struct {
	// contains filtered or unexported fields
}

func NewHealthHandler

func NewHealthHandler(h *Hub) *HealthHandler

func (*HealthHandler) Health

func (hh *HealthHandler) Health(c *gin.Context)

GET /health Returns a structured health object covering each major dependency. Responds 200 when all required checks pass, 503 when the DB is unreachable. Docker failures are reported but do not change the status code (the API can still serve non-run requests without a live Docker daemon).

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

Hub holds shared dependencies that all handlers need.

func NewHub

func NewHub(
	db *sqlx.DB,
	docker *dockerpkg.Client,
	ws *workspace.Manager,
	runner *runner.Runner,
	audit *audit.Logger,
	cfg *config.Config,
	pol policy.Hook,
	queue jobqueue.Queue,
	sec secrets.Provider,
	pool *warmpool.Pool,
	artStore artifacts.Store,
) *Hub

func (*Hub) Policy

func (h *Hub) Policy() policy.Hook

Policy exposes the active policy hook (for the policy handler).

func (*Hub) PolicyFile

func (h *Hub) PolicyFile() string

PolicyFile returns the configured OPA policy file path (empty = AllowAll).

type KeyHandler

type KeyHandler struct {
	// contains filtered or unexported fields
}

func NewKeyHandler

func NewKeyHandler(h *Hub) *KeyHandler

func (*KeyHandler) Create

func (kh *KeyHandler) Create(c *gin.Context)

POST /api/v1/keys

func (*KeyHandler) List

func (kh *KeyHandler) List(c *gin.Context)

GET /api/v1/keys

func (*KeyHandler) Revoke

func (kh *KeyHandler) Revoke(c *gin.Context)

DELETE /api/v1/keys/:id

type MissionHandler added in v0.3.2

type MissionHandler struct {
	// contains filtered or unexported fields
}

func NewMissionHandler added in v0.3.2

func NewMissionHandler(manager *missions.Manager, hub *Hub) *MissionHandler

func (*MissionHandler) AttributeRunCosts added in v0.3.2

func (h *MissionHandler) AttributeRunCosts(c *gin.Context)

AttributeRunCosts POST /api/v1/missions/:id/runs/:run_id/attribute-costs

func (*MissionHandler) Create added in v0.3.2

func (h *MissionHandler) Create(c *gin.Context)

func (*MissionHandler) Delete added in v0.3.2

func (h *MissionHandler) Delete(c *gin.Context)

func (*MissionHandler) Get added in v0.3.2

func (h *MissionHandler) Get(c *gin.Context)

func (*MissionHandler) GetBySlug added in v0.3.2

func (h *MissionHandler) GetBySlug(c *gin.Context)

func (*MissionHandler) GetMissionCosts added in v0.3.2

func (h *MissionHandler) GetMissionCosts(c *gin.Context)

GetMissionCosts GET /api/v1/missions/:id/costs

func (*MissionHandler) GetRun added in v0.3.2

func (h *MissionHandler) GetRun(c *gin.Context)

GetRun GET /api/v1/missions/:id/runs/:run_id

func (*MissionHandler) GetRunCosts added in v0.3.2

func (h *MissionHandler) GetRunCosts(c *gin.Context)

GetRunCosts GET /api/v1/missions/:id/runs/:run_id/costs

func (*MissionHandler) List added in v0.3.2

func (h *MissionHandler) List(c *gin.Context)

func (*MissionHandler) ListRuns added in v0.3.2

func (h *MissionHandler) ListRuns(c *gin.Context)

func (*MissionHandler) RecordRun added in v0.3.2

func (h *MissionHandler) RecordRun(c *gin.Context)

RecordRun attaches a mission execution record to a session (does not execute steps server-side yet).

func (*MissionHandler) Update added in v0.3.2

func (h *MissionHandler) Update(c *gin.Context)

func (*MissionHandler) UpdateRun added in v0.3.2

func (h *MissionHandler) UpdateRun(c *gin.Context)

UpdateRun PATCH /api/v1/missions/:id/runs/:run_id

type NLPolicyHandler added in v0.3.0

type NLPolicyHandler struct {
	// contains filtered or unexported fields
}

func NewNLPolicyHandler added in v0.3.0

func NewNLPolicyHandler(h *Hub) *NLPolicyHandler

func (*NLPolicyHandler) CompilePolicy added in v0.3.0

func (ph *NLPolicyHandler) CompilePolicy(c *gin.Context)

POST /api/v1/policies/compile Parse and compile policy to all formats

func (*NLPolicyHandler) FromTemplate added in v0.3.0

func (ph *NLPolicyHandler) FromTemplate(c *gin.Context)

POST /api/v1/policies/from-template/:name Generate policy from template

func (*NLPolicyHandler) GetTemplate added in v0.3.0

func (ph *NLPolicyHandler) GetTemplate(c *gin.Context)

GET /api/v1/policies/templates/:name Get specific policy template

func (*NLPolicyHandler) ListTemplates added in v0.3.0

func (ph *NLPolicyHandler) ListTemplates(c *gin.Context)

GET /api/v1/policies/templates List available policy templates

func (*NLPolicyHandler) ParsePolicy added in v0.3.0

func (ph *NLPolicyHandler) ParsePolicy(c *gin.Context)

POST /api/v1/policies/parse Parse natural language policy to structured JSON

func (*NLPolicyHandler) ValidatePolicy added in v0.3.0

func (ph *NLPolicyHandler) ValidatePolicy(c *gin.Context)

POST /api/v1/policies/validate Validate natural language policy

type OrgHandler

type OrgHandler struct {
	// contains filtered or unexported fields
}

OrgHandler serves /api/v1/orgs and /api/v1/orgs/:id/members.

func NewOrgHandler

func NewOrgHandler(h *Hub) *OrgHandler

func (*OrgHandler) AddMember

func (oh *OrgHandler) AddMember(c *gin.Context)

POST /api/v1/orgs/:id/members (master key or org admin)

func (*OrgHandler) Create

func (oh *OrgHandler) Create(c *gin.Context)

POST /api/v1/orgs (master key only)

func (*OrgHandler) Delete

func (oh *OrgHandler) Delete(c *gin.Context)

DELETE /api/v1/orgs/:id (master key only)

func (*OrgHandler) Get

func (oh *OrgHandler) Get(c *gin.Context)

GET /api/v1/orgs/:id (master key or any org member)

func (*OrgHandler) List

func (oh *OrgHandler) List(c *gin.Context)

GET /api/v1/orgs (master key only)

func (*OrgHandler) ListMembers

func (oh *OrgHandler) ListMembers(c *gin.Context)

GET /api/v1/orgs/:id/members (master key or any org member)

func (*OrgHandler) ListMine added in v0.3.2

func (oh *OrgHandler) ListMine(c *gin.Context)

GET /api/v1/me/orgs — organizations visible to the authenticated actor. Master key sees every org (role=admin). Other keys see memberships only.

func (*OrgHandler) ListSessions

func (oh *OrgHandler) ListSessions(c *gin.Context)

GET /api/v1/orgs/:id/sessions (org member — respects role visibility)

func (*OrgHandler) RemoveMember

func (oh *OrgHandler) RemoveMember(c *gin.Context)

DELETE /api/v1/orgs/:id/members/:principal (master key or org admin)

type PolicyHandler

type PolicyHandler struct {
	// contains filtered or unexported fields
}

func NewPolicyHandler

func NewPolicyHandler(h *Hub) *PolicyHandler

func (*PolicyHandler) Eval

func (ph *PolicyHandler) Eval(c *gin.Context)

POST /api/v1/policy/eval — dry-run: evaluate a command or file access against the currently loaded policy without actually executing anything.

func (*PolicyHandler) Get

func (ph *PolicyHandler) Get(c *gin.Context)

GET /api/v1/policy

type ReplayHandler added in v0.3.1

type ReplayHandler struct {
	// contains filtered or unexported fields
}

func NewReplayHandler added in v0.3.1

func NewReplayHandler(h *Hub, mgr *replay.Manager) *ReplayHandler

func (*ReplayHandler) CreateCheckpoint added in v0.3.1

func (rh *ReplayHandler) CreateCheckpoint(c *gin.Context)

POST /api/v1/sessions/:id/checkpoints

func (*ReplayHandler) DeleteCheckpoint added in v0.3.1

func (rh *ReplayHandler) DeleteCheckpoint(c *gin.Context)

DELETE /api/v1/sessions/:id/checkpoints/:checkpoint_id

func (*ReplayHandler) ForkCheckpoint added in v0.3.1

func (rh *ReplayHandler) ForkCheckpoint(c *gin.Context)

POST /api/v1/checkpoints/:checkpoint_id/fork

func (*ReplayHandler) GetCheckpoint added in v0.3.1

func (rh *ReplayHandler) GetCheckpoint(c *gin.Context)

GET /api/v1/sessions/:id/checkpoints/:checkpoint_id

func (*ReplayHandler) ListCheckpoints added in v0.3.1

func (rh *ReplayHandler) ListCheckpoints(c *gin.Context)

GET /api/v1/sessions/:id/checkpoints

func (*ReplayHandler) RestoreCheckpoint added in v0.3.1

func (rh *ReplayHandler) RestoreCheckpoint(c *gin.Context)

POST /api/v1/sessions/:id/checkpoints/:checkpoint_id/restore

type RunHandler

type RunHandler struct {
	// contains filtered or unexported fields
}

func NewRunHandler

func NewRunHandler(h *Hub) *RunHandler

func (*RunHandler) Async

func (rh *RunHandler) Async(c *gin.Context)

POST /api/v1/sessions/:id/run/async Non-blocking variant: creates the run record immediately (status=pending), returns 202 with the run_id, and executes the command in a background worker. Optional "callback_url" field in the request body receives an HTTP POST with the completed Run when finished.

func (*RunHandler) Execute

func (rh *RunHandler) Execute(c *gin.Context)

POST /api/v1/sessions/:id/run

func (*RunHandler) Get

func (rh *RunHandler) Get(c *gin.Context)

GET /api/v1/runs/:id

func (*RunHandler) ListBySession

func (rh *RunHandler) ListBySession(c *gin.Context)

GET /api/v1/sessions/:id/runs

func (*RunHandler) Stream

func (rh *RunHandler) Stream(c *gin.Context)

POST /api/v1/sessions/:id/run/stream Same request body as Execute, but responds with text/event-stream (SSE). Events:

data: {"type":"stdout","data":"..."}\n\n
data: {"type":"stderr","data":"..."}\n\n
data: {"type":"done","run_id":"...","exit_code":0,"status":"completed","duration_ms":123}\n\n

type SessionHandler

type SessionHandler struct {
	// contains filtered or unexported fields
}

func NewSessionHandler

func NewSessionHandler(h *Hub) *SessionHandler

func (*SessionHandler) Create

func (sh *SessionHandler) Create(c *gin.Context)

POST /api/v1/sessions

func (*SessionHandler) Delete

func (sh *SessionHandler) Delete(c *gin.Context)

DELETE /api/v1/sessions/:id

func (*SessionHandler) Get

func (sh *SessionHandler) Get(c *gin.Context)

GET /api/v1/sessions/:id

func (*SessionHandler) List

func (sh *SessionHandler) List(c *gin.Context)

GET /api/v1/sessions Returns the caller's own sessions plus sessions in any org they belong to. Master key sees all sessions. Supports optional ?label=key:value filter.

func (*SessionHandler) UpdateLabels

func (sh *SessionHandler) UpdateLabels(c *gin.Context)

PATCH /api/v1/sessions/:id/labels Replaces the session's entire label set. Pass {} to clear all labels.

type SnapshotHandler

type SnapshotHandler struct {
	// contains filtered or unexported fields
}

SnapshotHandler serves snapshot endpoints under /sessions/:id/snapshots and the /snapshots/:id singleton routes.

func NewSnapshotHandler

func NewSnapshotHandler(h *Hub) *SnapshotHandler

func (*SnapshotHandler) Create

func (sh *SnapshotHandler) Create(c *gin.Context)

POST /api/v1/sessions/:id/snapshots Body: {"name":"my-snapshot"} Creates a gzip-compressed tar archive of the session workspace and records it in the database. The archive path is never exposed to callers.

func (*SnapshotHandler) Delete

func (sh *SnapshotHandler) Delete(c *gin.Context)

DELETE /api/v1/snapshots/:id

func (*SnapshotHandler) Download

func (sh *SnapshotHandler) Download(c *gin.Context)

GET /api/v1/snapshots/:id/download Streams the snapshot archive as application/gzip.

func (*SnapshotHandler) List

func (sh *SnapshotHandler) List(c *gin.Context)

GET /api/v1/sessions/:id/snapshots

type TemplateHandler added in v0.3.0

type TemplateHandler struct {
	// contains filtered or unexported fields
}

TemplateHandler handles template-related HTTP requests

func NewTemplateHandler added in v0.3.0

func NewTemplateHandler(manager *templates.Manager, hub *Hub) *TemplateHandler

NewTemplateHandler creates a new template handler

func (*TemplateHandler) CreateSessionFromTemplate added in v0.3.0

func (h *TemplateHandler) CreateSessionFromTemplate(c *gin.Context)

CreateSessionFromTemplate creates a new session from a template POST /api/v1/templates/:id/use

func (*TemplateHandler) CreateTemplate added in v0.3.0

func (h *TemplateHandler) CreateTemplate(c *gin.Context)

CreateTemplate creates a new custom template POST /api/v1/templates

func (*TemplateHandler) DeleteTemplate added in v0.3.0

func (h *TemplateHandler) DeleteTemplate(c *gin.Context)

DeleteTemplate deletes a template DELETE /api/v1/templates/:id

func (*TemplateHandler) GetTemplate added in v0.3.0

func (h *TemplateHandler) GetTemplate(c *gin.Context)

GetTemplate returns a single template GET /api/v1/templates/:id

func (*TemplateHandler) GetTemplateBySlug added in v0.3.0

func (h *TemplateHandler) GetTemplateBySlug(c *gin.Context)

GetTemplateBySlug returns a template by slug GET /api/v1/templates/slug/:slug

func (*TemplateHandler) ListTemplates added in v0.3.0

func (h *TemplateHandler) ListTemplates(c *gin.Context)

ListTemplates returns all templates with optional filtering GET /api/v1/templates

func (*TemplateHandler) UpdateTemplate added in v0.3.0

func (h *TemplateHandler) UpdateTemplate(c *gin.Context)

UpdateTemplate updates a template PUT /api/v1/templates/:id

type VerifyHandler added in v0.3.2

type VerifyHandler struct {
	// contains filtered or unexported fields
}

VerifyHandler evaluates and optionally persists post-run checkpoints.

func NewVerifyHandler added in v0.3.2

func NewVerifyHandler(h *Hub, store *verify.Store) *VerifyHandler

NewVerifyHandler creates a VerifyHandler.

func (*VerifyHandler) Controls added in v0.3.2

func (vh *VerifyHandler) Controls(c *gin.Context)

Controls POST /api/v1/verify/controls Runs the frozen positive/negative control suite against the in-process evaluator (no Docker / session required). Certifies that verify discriminates known-good from known-bad observations — FaultWright-style evaluator check.

func (*VerifyHandler) Evaluate added in v0.3.2

func (vh *VerifyHandler) Evaluate(c *gin.Context)

Evaluate POST /api/v1/verify

func (*VerifyHandler) Evidence added in v0.3.4

func (vh *VerifyHandler) Evidence(c *gin.Context)

Evidence POST /api/v1/verify/evidence Seals a digests-and-optional-HMAC verification export (checkpoint and/or controls).

func (*VerifyHandler) GetEvidence added in v0.3.4

func (vh *VerifyHandler) GetEvidence(c *gin.Context)

GetEvidence GET /api/v1/verifications/:id/evidence Exports a sealed evidence record for a persisted verification (ACL via session).

func (*VerifyHandler) ListBySession added in v0.3.2

func (vh *VerifyHandler) ListBySession(c *gin.Context)

ListBySession GET /api/v1/sessions/:id/verifications

Jump to

Keyboard shortcuts

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