Documentation
¶
Index ¶
- Constants
- func ServeSSE(w http.ResponseWriter, r *http.Request, hub *Hub, id string, ...)
- func ValidateMode(mode string) (string, error)
- func ValidateTarget(raw string) (string, error)
- type AgentInfo
- type AgentPool
- func (p *AgentPool) CancelPTY(agentID, terminalID string)
- func (p *AgentPool) CancelTask(agentID, taskID string)
- func (p *AgentPool) CloseTerminal(agentID, terminalID string)
- func (p *AgentPool) Count() int
- func (p *AgentPool) DispatchChat(agentID, taskID, prompt string) (<-chan taskResult, error)
- func (p *AgentPool) DispatchChatSession(agentID, taskID, sessionID, prompt string) (<-chan taskResult, error)
- func (p *AgentPool) DispatchCommand(agentID, taskID, command string) (<-chan taskResult, error)
- func (p *AgentPool) HandleTerminalWS(agentID string, w http.ResponseWriter, r *http.Request)
- func (p *AgentPool) HandleWS(w http.ResponseWriter, r *http.Request)
- func (p *AgentPool) List() []AgentInfo
- func (p *AgentPool) Pick() *remoteAgent
- func (p *AgentPool) PickChat() *remoteAgent
- func (p *AgentPool) SendAgentMessage(agentID string, msg WSMessage) error
- func (p *AgentPool) SetRecordStore(rs RecordStore)
- func (p *AgentPool) SetSessionLookup(sl SessionLookup)
- type BroadcastCallback
- type ChatEvent
- type ChatMessage
- type ChatSession
- type ConfigStatus
- type ConfigStore
- type CreateSessionRequest
- type Handler
- type Hub
- type HubEvent
- type RecordStore
- type SQLiteStore
- func (s *SQLiteStore) AddMessage(ctx context.Context, msg *ChatMessage) error
- func (s *SQLiteStore) Close() error
- func (s *SQLiteStore) Create(ctx context.Context, job *ScanJob) error
- func (s *SQLiteStore) CreateSession(ctx context.Context, session *ChatSession) error
- func (s *SQLiteStore) Delete(ctx context.Context, id string) error
- func (s *SQLiteStore) DeleteSession(ctx context.Context, id string) error
- func (s *SQLiteStore) Get(ctx context.Context, id string) (*ScanJob, error)
- func (s *SQLiteStore) GetSession(ctx context.Context, id string) (*ChatSession, error)
- func (s *SQLiteStore) InsertRecord(ctx context.Context, rec *output.Record) error
- func (s *SQLiteStore) InsertRecords(ctx context.Context, recs []*output.Record) error
- func (s *SQLiteStore) LinkScanToSession(ctx context.Context, sessionID, scanID string) error
- func (s *SQLiteStore) List(ctx context.Context, limit int) ([]*ScanJob, error)
- func (s *SQLiteStore) ListMessages(ctx context.Context, sessionID string, limit int) ([]*ChatMessage, error)
- func (s *SQLiteStore) ListSessions(ctx context.Context, limit int) ([]*ChatSession, error)
- func (s *SQLiteStore) SessionScanIDs(ctx context.Context, sessionID string) ([]string, error)
- func (s *SQLiteStore) Update(ctx context.Context, job *ScanJob) error
- func (s *SQLiteStore) UpdateSession(ctx context.Context, session *ChatSession) error
- type ScanJob
- type ScanRequest
- type ScanStatus
- type SendMessageRequest
- type Service
- func (s *Service) BroadcastChatEvent(sessionID string, event ChatEvent)
- func (s *Service) CancelScan(id string) error
- func (s *Service) CancelSession(ctx context.Context, sessionID string) error
- func (s *Service) Close()
- func (s *Service) CreateSession(ctx context.Context, agentID, title string) (*ChatSession, error)
- func (s *Service) DeleteSession(ctx context.Context, id string) error
- func (s *Service) GetConfigStatus(ctx context.Context) (ConfigStatus, error)
- func (s *Service) GetDistributeConfig(ctx context.Context) (webproto.DistributeConfig, error)
- func (s *Service) GetMessages(ctx context.Context, sessionID string) ([]*ChatMessage, error)
- func (s *Service) GetReport(ctx context.Context, id string) (string, error)
- func (s *Service) GetScan(ctx context.Context, id string) (*ScanJob, error)
- func (s *Service) GetSession(ctx context.Context, id string) (*ChatSession, error)
- func (s *Service) HandleFileUpload(ctx context.Context, sessionID, filename string, data []byte) (*webproto.FileUploadResult, error)
- func (s *Service) HandleUserMessage(ctx context.Context, sessionID, content string) (*ChatMessage, error)
- func (s *Service) Hub() *Hub
- func (s *Service) ListScans(ctx context.Context) ([]*ScanJob, error)
- func (s *Service) ListSessions(ctx context.Context) ([]*ChatSession, error)
- func (s *Service) SaveConfig(ctx context.Context, cfg webproto.DistributeConfig) (ConfigStatus, error)
- func (s *Service) SetAgentPool(pool *AgentPool)
- func (s *Service) Status() ServiceStatus
- func (s *Service) SubmitScan(ctx context.Context, target, mode string, verify, sniper, deep bool) (*ScanJob, error)
- func (s *Service) TaskSession(taskID string) (string, bool)
- type ServiceConfig
- type ServiceStatus
- type SessionLookup
- type Store
- type WSMessage
Constants ¶
const ( SessionActive = "active" SessionArchived = "archived" )
const ( ChatEventMessage = "message" ChatEventMessageStart = "message_start" ChatEventMessageDelta = "message_delta" ChatEventMessageEnd = "message_end" ChatEventToolCall = "tool_call" ChatEventToolResult = "tool_result" ChatEventThinking = "thinking" ChatEventScanStarted = "scan_started" ChatEventScanProgress = "scan_progress" ChatEventScanComplete = "scan_complete" ChatEventScanError = "scan_error" ChatEventAgentJoined = "agent_joined" ChatEventError = "error" )
Variables ¶
This section is empty.
Functions ¶
func ValidateMode ¶
func ValidateTarget ¶
Types ¶
type AgentInfo ¶
type AgentInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Commands []string `json:"commands,omitempty"`
Busy bool `json:"busy"`
ConnectAt time.Time `json:"connected_at"`
Identity webproto.AgentIdentity `json:"identity,omitempty"`
Stats webproto.AgentStats `json:"stats,omitempty"`
}
AgentInfo is the public view of a connected agent.
type AgentPool ¶
type AgentPool struct {
// contains filtered or unexported fields
}
AgentPool manages connected remote aiscan agents via WebSocket.
func NewAgentPool ¶
func (*AgentPool) CancelTask ¶
func (*AgentPool) CloseTerminal ¶
func (*AgentPool) DispatchChat ¶ added in v0.2.8
DispatchChat sends a natural-language prompt to an LLM-capable agent.
func (*AgentPool) DispatchChatSession ¶ added in v0.2.8
func (p *AgentPool) DispatchChatSession(agentID, taskID, sessionID, prompt string) (<-chan taskResult, error)
DispatchChatSession sends chat input to an agent and scopes the remote agent-side conversation state to the web chat session.
func (*AgentPool) DispatchCommand ¶
DispatchCommand sends a command to an agent and returns a channel for the result.
func (*AgentPool) HandleTerminalWS ¶
HandleTerminalWS bridges one browser terminal WebSocket to one remote agent. The browser sends pty.* messages; the pool assigns a stream_id and relays matching agent responses back.
func (*AgentPool) HandleWS ¶
func (p *AgentPool) HandleWS(w http.ResponseWriter, r *http.Request)
HandleWS upgrades to WebSocket and manages the agent lifecycle. This single endpoint replaces register + stream + output + complete.
func (*AgentPool) Pick ¶
func (p *AgentPool) Pick() *remoteAgent
Pick selects an idle agent, or any agent if none idle.
func (*AgentPool) PickChat ¶ added in v0.2.8
func (p *AgentPool) PickChat() *remoteAgent
PickChat selects an idle LLM-capable agent, or any LLM-capable agent if all are busy.
func (*AgentPool) SendAgentMessage ¶
func (*AgentPool) SetRecordStore ¶ added in v0.2.8
func (p *AgentPool) SetRecordStore(rs RecordStore)
func (*AgentPool) SetSessionLookup ¶ added in v0.2.8
func (p *AgentPool) SetSessionLookup(sl SessionLookup)
type BroadcastCallback ¶
type ChatEvent ¶ added in v0.2.8
type ChatEvent struct {
Type string `json:"type"`
SessionID string `json:"session_id"`
MessageID string `json:"message_id,omitempty"`
Role string `json:"role,omitempty"`
AgentID string `json:"agent_id,omitempty"`
AgentName string `json:"agent_name,omitempty"`
Turn int `json:"turn,omitempty"`
Content string `json:"content,omitempty"`
Delta string `json:"delta,omitempty"`
ToolName string `json:"tool_name,omitempty"`
ToolArgs string `json:"tool_args,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
ScanID string `json:"scan_id,omitempty"`
Result *output.Result `json:"result,omitempty"`
Data string `json:"data,omitempty"`
Error string `json:"error,omitempty"`
Transient bool `json:"-"`
}
type ChatMessage ¶ added in v0.2.8
type ChatMessage struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
Role string `json:"role"`
AgentID string `json:"agent_id,omitempty"`
AgentName string `json:"agent_name,omitempty"`
Content string `json:"content"`
Metadata json.RawMessage `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type ChatSession ¶ added in v0.2.8
type ChatSession struct {
ID string `json:"id"`
AgentID string `json:"agent_id"`
AgentName string `json:"agent_name,omitempty"`
Title string `json:"title"`
Status string `json:"status"`
ScanIDs []string `json:"scan_ids,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type ConfigStatus ¶ added in v0.2.8
type ConfigStatus struct {
ConfigPath string `json:"config_path,omitempty"`
ConfigLoaded bool `json:"config_loaded"`
LLM struct {
Provider string `json:"provider"`
BaseURL string `json:"base_url"`
APIKeyConfigured bool `json:"api_key_configured"`
Model string `json:"model"`
Proxy string `json:"proxy"`
} `json:"llm"`
Cyberhub struct {
URL string `json:"url"`
KeyConfigured bool `json:"key_configured"`
Mode string `json:"mode"`
Proxy string `json:"proxy"`
} `json:"cyberhub"`
Recon struct {
FofaEmail string `json:"fofa_email"`
FofaKeyConfigured bool `json:"fofa_key_configured"`
HunterTokenConfigured bool `json:"hunter_token_configured"`
HunterAPIKeyConfigured bool `json:"hunter_api_key_configured"`
Proxy string `json:"proxy"`
Limit *int `json:"limit,omitempty"`
} `json:"recon"`
Scan struct {
Verify string `json:"verify"`
VerifyTimeout int `json:"verify_timeout"`
} `json:"scan"`
Search struct {
TavilyKeysConfigured bool `json:"tavily_keys_configured"`
} `json:"search"`
IOA struct {
URL string `json:"url"`
TokenConfigured bool `json:"token_configured"`
NodeName string `json:"node_name"`
Space string `json:"space"`
} `json:"ioa"`
Agent struct {
Tools []string `json:"tools,omitempty"`
Timeout int `json:"timeout"`
SaveSession bool `json:"save_session"`
} `json:"agent"`
}
ConfigStatus is the response for GET /api/config — secrets masked, *_configured booleans indicate whether a secret is set.
func ConfigStatusFromDistribute ¶ added in v0.2.8
func ConfigStatusFromDistribute(d *webproto.DistributeConfig, path string, loaded bool) ConfigStatus
ConfigStatusFromDistribute builds a masked ConfigStatus from raw config.
type ConfigStore ¶ added in v0.2.8
type CreateSessionRequest ¶ added in v0.2.8
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
func (*Hub) OnBroadcast ¶
func (h *Hub) OnBroadcast(cb BroadcastCallback)
type HubEvent ¶
type HubEvent struct {
Type string
Data json.RawMessage
}
HubEvent is the unit broadcast through the SSE hub. Type is the SSE event name, Data is pre-serialized JSON written directly to the stream.
type RecordStore ¶ added in v0.2.8
type RecordStore interface {
InsertRecord(ctx context.Context, rec *output.Record) error
InsertRecords(ctx context.Context, recs []*output.Record) error
}
RecordStore is the subset of Store needed for record persistence.
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
func NewSQLiteStore ¶
func NewSQLiteStore(dbPath string) (*SQLiteStore, error)
func (*SQLiteStore) AddMessage ¶ added in v0.2.8
func (s *SQLiteStore) AddMessage(ctx context.Context, msg *ChatMessage) error
func (*SQLiteStore) Close ¶
func (s *SQLiteStore) Close() error
func (*SQLiteStore) CreateSession ¶ added in v0.2.8
func (s *SQLiteStore) CreateSession(ctx context.Context, session *ChatSession) error
func (*SQLiteStore) DeleteSession ¶ added in v0.2.8
func (s *SQLiteStore) DeleteSession(ctx context.Context, id string) error
func (*SQLiteStore) GetSession ¶ added in v0.2.8
func (s *SQLiteStore) GetSession(ctx context.Context, id string) (*ChatSession, error)
func (*SQLiteStore) InsertRecord ¶ added in v0.2.8
func (*SQLiteStore) InsertRecords ¶ added in v0.2.8
func (*SQLiteStore) LinkScanToSession ¶ added in v0.2.8
func (s *SQLiteStore) LinkScanToSession(ctx context.Context, sessionID, scanID string) error
func (*SQLiteStore) ListMessages ¶ added in v0.2.8
func (s *SQLiteStore) ListMessages(ctx context.Context, sessionID string, limit int) ([]*ChatMessage, error)
func (*SQLiteStore) ListSessions ¶ added in v0.2.8
func (s *SQLiteStore) ListSessions(ctx context.Context, limit int) ([]*ChatSession, error)
func (*SQLiteStore) SessionScanIDs ¶ added in v0.2.8
func (*SQLiteStore) UpdateSession ¶ added in v0.2.8
func (s *SQLiteStore) UpdateSession(ctx context.Context, session *ChatSession) error
type ScanJob ¶
type ScanJob struct {
ID string `json:"id"`
Target string `json:"target"`
Mode string `json:"mode"`
Verify bool `json:"verify,omitempty"`
Sniper bool `json:"sniper,omitempty"`
AI bool `json:"ai,omitempty"`
Deep bool `json:"deep,omitempty"`
Status ScanStatus `json:"status"`
Progress string `json:"progress,omitempty"`
Report string `json:"report,omitempty"`
Result *output.Result `json:"result,omitempty"`
Error string `json:"error,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type ScanRequest ¶
type ScanRequest struct {
Target string `json:"target"`
Mode string `json:"mode"`
Verify bool `json:"verify,omitempty"`
Sniper bool `json:"sniper,omitempty"`
AI bool `json:"ai,omitempty"`
Deep bool `json:"deep,omitempty"`
}
func (ScanRequest) AnalysisOptions ¶
func (r ScanRequest) AnalysisOptions() (verify, sniper, deep bool)
type ScanStatus ¶
type ScanStatus string
const ( StatusQueued ScanStatus = "queued" StatusRunning ScanStatus = "running" StatusCompleted ScanStatus = "completed" StatusFailed ScanStatus = "failed" StatusCanceled ScanStatus = "canceled" )
type SendMessageRequest ¶ added in v0.2.8
type SendMessageRequest struct {
Content string `json:"content"`
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(cfg ServiceConfig) *Service
func (*Service) BroadcastChatEvent ¶ added in v0.2.8
func (*Service) CancelScan ¶
func (*Service) CancelSession ¶ added in v0.2.8
func (*Service) CreateSession ¶ added in v0.2.8
func (*Service) DeleteSession ¶ added in v0.2.8
func (*Service) GetConfigStatus ¶ added in v0.2.8
func (s *Service) GetConfigStatus(ctx context.Context) (ConfigStatus, error)
func (*Service) GetDistributeConfig ¶ added in v0.2.8
func (*Service) GetMessages ¶ added in v0.2.8
func (*Service) GetSession ¶ added in v0.2.8
func (*Service) HandleFileUpload ¶ added in v0.2.8
func (*Service) HandleUserMessage ¶ added in v0.2.8
func (*Service) ListSessions ¶ added in v0.2.8
func (s *Service) ListSessions(ctx context.Context) ([]*ChatSession, error)
func (*Service) SaveConfig ¶ added in v0.2.8
func (s *Service) SaveConfig(ctx context.Context, cfg webproto.DistributeConfig) (ConfigStatus, error)
func (*Service) SetAgentPool ¶
func (*Service) Status ¶
func (s *Service) Status() ServiceStatus
func (*Service) SubmitScan ¶
type ServiceConfig ¶
type ServiceStatus ¶
type ServiceStatus struct {
LLMAvailable bool `json:"llm_available"`
LLMProvider string `json:"llm_provider,omitempty"`
LLMModel string `json:"llm_model,omitempty"`
LLMAPIKeyConfigured bool `json:"llm_api_key_configured,omitempty"`
ConfigPath string `json:"config_path,omitempty"`
ConfigLoaded bool `json:"config_loaded"`
Agents int `json:"agents"`
}
type SessionLookup ¶ added in v0.2.8
type SessionLookup interface {
TaskSession(taskID string) (sessionID string, ok bool)
BroadcastChatEvent(sessionID string, event ChatEvent)
}
SessionLookup resolves a task ID to its owning chat session.
type Store ¶
type Store interface {
// Scan CRUD
Create(ctx context.Context, job *ScanJob) error
Get(ctx context.Context, id string) (*ScanJob, error)
List(ctx context.Context, limit int) ([]*ScanJob, error)
Update(ctx context.Context, job *ScanJob) error
Delete(ctx context.Context, id string) error
// Chat sessions
CreateSession(ctx context.Context, session *ChatSession) error
GetSession(ctx context.Context, id string) (*ChatSession, error)
ListSessions(ctx context.Context, limit int) ([]*ChatSession, error)
UpdateSession(ctx context.Context, session *ChatSession) error
DeleteSession(ctx context.Context, id string) error
// Chat messages
AddMessage(ctx context.Context, msg *ChatMessage) error
ListMessages(ctx context.Context, sessionID string, limit int) ([]*ChatMessage, error)
// Session-scan association
LinkScanToSession(ctx context.Context, sessionID, scanID string) error
SessionScanIDs(ctx context.Context, sessionID string) ([]string, error)
// Records
InsertRecord(ctx context.Context, rec *output.Record) error
InsertRecords(ctx context.Context, recs []*output.Record) error
}