diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-01-28 22:19:28 -1000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-01-28 22:19:28 -1000 |
| commit | 05b1930e04ac222d73ffb2f45c1b1febb69f893d (patch) | |
| tree | bc451d72b5265ff044c4655ed90685c601688b6d /internal/models | |
| parent | 058ff7d699f088edb851336928dd3eea2934cc07 (diff) | |
Add Agent Context API for external agent integration
Phase 1: Authentication and read-only context
- POST /agent/auth/request - request access with name + agent_id
- GET /agent/auth/poll - poll for approval status
- POST /agent/auth/approve|deny - user approval (browser auth required)
- GET /agent/context - 7-day timeline context (agent session required)
Phase 1.5: Browser-only agent endpoints (HTML pages)
- GET /agent/web/request - request page with token
- GET /agent/web/status - status page with polling
- GET /agent/web/context - context page with timeline data
WebSocket notifications:
- GET /ws/notifications - push agent requests to browsers
- Approval modal with trust indicators and countdown timer
Database:
- agents table for registered agent tracking
- agent_sessions table for pending/active sessions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/models')
| -rw-r--r-- | internal/models/types.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/internal/models/types.go b/internal/models/types.go index 4bf8462..5214bf8 100644 --- a/internal/models/types.go +++ b/internal/models/types.go @@ -146,3 +146,54 @@ type DashboardData struct { LastUpdated time.Time `json:"last_updated"` Errors []string `json:"errors,omitempty"` } + +// Agent represents a registered external agent +type Agent struct { + ID int64 `json:"id"` + Name string `json:"name"` + AgentID string `json:"agent_id"` // UUID from agent + CreatedAt time.Time `json:"created_at"` + LastSeen *time.Time `json:"last_seen,omitempty"` + Trusted bool `json:"trusted"` +} + +// AgentSession represents a pending request or active session +type AgentSession struct { + ID int64 `json:"id"` + RequestToken string `json:"request_token"` + AgentName string `json:"agent_name"` + AgentID string `json:"agent_id"` + Status string `json:"status"` // pending, approved, denied, expired + CreatedAt time.Time `json:"created_at"` + ExpiresAt time.Time `json:"expires_at"` + SessionToken string `json:"session_token,omitempty"` + SessionExpiresAt *time.Time `json:"session_expires_at,omitempty"` +} + +// AgentAuthRequest is the request body for agent auth +type AgentAuthRequest struct { + Name string `json:"name"` + AgentID string `json:"agent_id"` +} + +// AgentAuthResponse is the response for auth request +type AgentAuthResponse struct { + RequestToken string `json:"request_token"` + Status string `json:"status"` +} + +// AgentPollResponse is the response for poll endpoint +type AgentPollResponse struct { + Status string `json:"status"` + SessionToken string `json:"session_token,omitempty"` + ExpiresAt *time.Time `json:"expires_at,omitempty"` +} + +// AgentTrustLevel indicates the trust state of an agent +type AgentTrustLevel string + +const ( + AgentTrustNew AgentTrustLevel = "new" + AgentTrustRecognized AgentTrustLevel = "recognized" + AgentTrustSuspicious AgentTrustLevel = "suspicious" +) |
