Overview
Concrete tool for creating and persisting conversations and messages provided by the internal/database package.
Description
CreateConversation inserts a new conversation row with an optional title, project binding, role name, and agent mode. CreateConversationWithWebshell additionally binds a webshell connection ID. A Conversation has Messages with roles (assistant/user/tool), content, reasoning content, MCP execution IDs, and process details. GetMessages retrieves the message history. The record_vulnerability MCP tool persists vulnerability rows via db.SaveVulnerability.
Usage
- Deployment step 6 (evidence review): conversations and messages are persisted here.
- Multi-agent engagement: each run's messages are saved for replay and attack-chain generation.
Code Reference
Source Location
- Repository: CyberStrikeAI
- File: internal/database/conversation.go
- Lines: Conversation L20-32, Message L34-45, CreateConversation L48-50, CreateConversationWithWebshell L53+
Signature
type Conversation struct {
ID, Title, ProjectID, RoleName, AgentMode string
Pinned bool
CreatedAt, UpdatedAt time.Time
Messages []Message
}
type Message struct {
ID, ConversationID, Role, Content, ReasoningContent string
MCPExecutionIDs []string
ProcessDetails []map[string]interface{}
CreatedAt, UpdatedAt time.Time
}
func (db *DB) CreateConversation(title string, meta ConversationCreateMeta) (*Conversation, error)
func (db *DB) CreateConversationWithWebshell(webshellConnectionID, title string, meta ConversationCreateMeta) (*Conversation, error)
func (db *DB) GetMessages(conversationID string) ([]Message, error)
func (db *DB) SaveVulnerability(v *Vulnerability) error
Import
import "cyberstrike-ai/internal/database"
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| title |
string |
No |
Conversation title
|
| meta.ProjectID |
string |
No |
Project binding
|
| meta.RoleName |
string |
No |
Role config name
|
| meta.AgentMode |
string |
No |
plan-execute|supervisor|single
|
Outputs
| Name |
Type |
Description
|
| returns |
*Conversation, error |
Persisted conversation with UUID
|
Usage Examples
Create a Project-Bound Conversation
conv, err := db.CreateConversation("SQLi engagement", database.ConversationCreateMeta{
ProjectID: "proj-1",
RoleName: "渗透测试",
AgentMode: "deep",
})
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.