feat: init sproutclaw-web — Go+Gin backend + React frontend
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
263
backend/internal/models/types.go
Normal file
263
backend/internal/models/types.go
Normal file
@@ -0,0 +1,263 @@
|
||||
package models
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// ── RPC ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
type RPCCommand struct {
|
||||
Type string `json:"type"`
|
||||
ID string `json:"id,omitempty"`
|
||||
// prompt fields
|
||||
Text string `json:"text,omitempty"`
|
||||
Images []ChatImage `json:"images,omitempty"`
|
||||
// model / thinking fields
|
||||
Provider string `json:"provider,omitempty"`
|
||||
ModelID string `json:"modelId,omitempty"`
|
||||
Budget *int `json:"budget,omitempty"`
|
||||
// session fields
|
||||
Path string `json:"path,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
// streaming behaviour
|
||||
StreamingBehavior string `json:"streamingBehavior,omitempty"`
|
||||
// slash dispatch passthrough
|
||||
Args string `json:"args,omitempty"`
|
||||
// extension ui
|
||||
Response json.RawMessage `json:"response,omitempty"`
|
||||
}
|
||||
|
||||
type RPCResponse struct {
|
||||
Type string `json:"type"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Result json.RawMessage `json:"result,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// Raw event line forwarded to SSE clients as-is
|
||||
type RPCEvent struct {
|
||||
Type string `json:"type"`
|
||||
Raw json.RawMessage `json:"-"`
|
||||
}
|
||||
|
||||
// ── Chat ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
type ChatImage struct {
|
||||
MediaType string `json:"mediaType"`
|
||||
Data string `json:"data"` // base64
|
||||
}
|
||||
|
||||
type ChatRequest struct {
|
||||
Message string `json:"message"`
|
||||
Images []ChatImage `json:"images,omitempty"`
|
||||
StreamingBehavior string `json:"streamingBehavior,omitempty"`
|
||||
}
|
||||
|
||||
type SteerRequest struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type BashRequest struct {
|
||||
Command string `json:"command"`
|
||||
}
|
||||
|
||||
type MessagesRequest struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
// ── Sessions ─────────────────────────────────────────────────────────────────
|
||||
|
||||
type SessionSummary struct {
|
||||
Path string `json:"path"`
|
||||
Name string `json:"name,omitempty"`
|
||||
FirstMessage string `json:"firstMessage,omitempty"`
|
||||
MessageCount int `json:"messageCount,omitempty"`
|
||||
Modified string `json:"modified,omitempty"`
|
||||
Created string `json:"created,omitempty"`
|
||||
Pinned bool `json:"pinned,omitempty"`
|
||||
}
|
||||
|
||||
type SessionsResponse struct {
|
||||
Sessions []SessionSummary `json:"sessions"`
|
||||
}
|
||||
|
||||
type SessionStateResponse struct {
|
||||
IsStreaming bool `json:"isStreaming"`
|
||||
SessionFile string `json:"sessionFile,omitempty"`
|
||||
}
|
||||
|
||||
type LoadSessionRequest struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
type ActivateSessionRequest struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
type DeleteSessionRequest struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
type PinSessionRequest struct {
|
||||
Path string `json:"path"`
|
||||
Pinned bool `json:"pinned"`
|
||||
}
|
||||
|
||||
type NameSessionRequest struct {
|
||||
Path string `json:"path"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type HistoryRequest struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
// ── Models ───────────────────────────────────────────────────────────────────
|
||||
|
||||
type ModelEntry struct {
|
||||
Provider string `json:"provider"`
|
||||
ModelID string `json:"modelId"`
|
||||
DisplayName string `json:"displayName,omitempty"`
|
||||
IsDefault bool `json:"isDefault,omitempty"`
|
||||
}
|
||||
|
||||
type ModelsResponse struct {
|
||||
Models []ModelEntry `json:"models"`
|
||||
Current *ModelEntry `json:"current,omitempty"`
|
||||
}
|
||||
|
||||
type SetModelRequest struct {
|
||||
Provider string `json:"provider"`
|
||||
ModelID string `json:"modelId"`
|
||||
}
|
||||
|
||||
type SetThinkingRequest struct {
|
||||
Budget *int `json:"budget"` // nil = disable
|
||||
}
|
||||
|
||||
// ── Commands ─────────────────────────────────────────────────────────────────
|
||||
|
||||
type SlashCommand struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Source string `json:"source"` // builtin | extension | skill | prompt
|
||||
}
|
||||
|
||||
type CommandsResponse struct {
|
||||
Commands []SlashCommand `json:"commands"`
|
||||
}
|
||||
|
||||
// ── WebUI Config ──────────────────────────────────────────────────────────────
|
||||
|
||||
type AvatarsResponse struct {
|
||||
UserAvatar string `json:"userAvatar,omitempty"`
|
||||
AssistantAvatar string `json:"assistantAvatar,omitempty"`
|
||||
}
|
||||
|
||||
type WebuiConfigResponse struct {
|
||||
Key string `json:"key,omitempty"`
|
||||
Value string `json:"value,omitempty"`
|
||||
// batch response
|
||||
Entries map[string]string `json:"entries,omitempty"`
|
||||
}
|
||||
|
||||
type WebuiConfigSetRequest struct {
|
||||
Key string `json:"key,omitempty"`
|
||||
Value string `json:"value,omitempty"`
|
||||
// batch
|
||||
Entries map[string]string `json:"entries,omitempty"`
|
||||
}
|
||||
|
||||
type WebuiConfigDeleteRequest struct {
|
||||
Key string `json:"key"`
|
||||
}
|
||||
|
||||
// ── Settings ──────────────────────────────────────────────────────────────────
|
||||
|
||||
type SkillInfo struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
type ExtensionInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Source string `json:"source"` // local | npm
|
||||
Commands []string `json:"commands,omitempty"`
|
||||
}
|
||||
|
||||
type MCPTool struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Disabled bool `json:"disabled"`
|
||||
}
|
||||
|
||||
type MCPServer struct {
|
||||
Name string `json:"name"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Tools []MCPTool `json:"tools,omitempty"`
|
||||
}
|
||||
|
||||
type SettingsResponse struct {
|
||||
Skills []SkillInfo `json:"skills"`
|
||||
Extensions []ExtensionInfo `json:"extensions"`
|
||||
MCPServers []MCPServer `json:"mcpServers"`
|
||||
SystemPrompt string `json:"systemPrompt,omitempty"`
|
||||
ModelsConfig string `json:"modelsConfig,omitempty"`
|
||||
}
|
||||
|
||||
type ToggleRequest struct {
|
||||
ID string `json:"id"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
type MCPServerToggleRequest struct {
|
||||
Server string `json:"server"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
type MCPToolToggleRequest struct {
|
||||
Server string `json:"server"`
|
||||
Tool string `json:"tool"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
type SystemPromptRequest struct {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type ModelsConfigRequest struct {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type AvatarsSetRequest struct {
|
||||
UserAvatar string `json:"userAvatar,omitempty"`
|
||||
AssistantAvatar string `json:"assistantAvatar,omitempty"`
|
||||
}
|
||||
|
||||
type EnvironmentResponse struct {
|
||||
Platform string `json:"platform"`
|
||||
Arch string `json:"arch"`
|
||||
Hostname string `json:"hostname"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// ── Extension UI ──────────────────────────────────────────────────────────────
|
||||
|
||||
type ExtensionUIResponseRequest struct {
|
||||
ID string `json:"id"`
|
||||
Response json.RawMessage `json:"response"`
|
||||
}
|
||||
|
||||
// ── Generic ───────────────────────────────────────────────────────────────────
|
||||
|
||||
type OKResponse struct {
|
||||
OK bool `json:"ok"`
|
||||
}
|
||||
|
||||
type ErrorResponse struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
Reference in New Issue
Block a user