Documentation
¶
Index ¶
- type AdminWorkspaceInfo
- type AgentInfo
- type AgentRegistrationCode
- type DB
- func (db *DB) AddWorkspaceMember(workspaceID, userID, role string) error
- func (db *DB) AddWorkspaceVolume(id, workspaceID, pvcName, mountPath string) error
- func (db *DB) ConsumeAgentRegistrationCode(code string) (*AgentRegistrationCode, error)
- func (db *DB) CountSandboxesByWorkspace(workspaceID string) (int, error)
- func (db *DB) CountUsers() (int, error)
- func (db *DB) CountWorkspacesOwnedByUser(userID string) (int, error)
- func (db *DB) CreateAgentRegistrationCode(code, userID, workspaceID string, expiresAt time.Time) error
- func (db *DB) CreateLocalSandbox(...) error
- func (db *DB) CreateOIDCIdentity(provider, subject, userID string, email *string) error
- func (db *DB) CreateSandbox(...) error
- func (db *DB) CreateToken(token, userID string, expiresAt time.Time) error
- func (db *DB) CreateUser(id, email, passwordHash string) error
- func (db *DB) CreateUserWithEmail(id string, passwordHash *string, email string) error
- func (db *DB) CreateWeixinBinding(sandboxID, botID, userID string) error
- func (db *DB) CreateWorkspace(id, name string) error
- func (db *DB) DeleteExpiredTokens() error
- func (db *DB) DeleteModelserverConnection(workspaceID string) error
- func (db *DB) DeleteSandbox(id string) error
- func (db *DB) DeleteUserQuota(userID string) error
- func (db *DB) DeleteWorkspace(id string) error
- func (db *DB) DeleteWorkspaceLLMConfig(workspaceID string) error
- func (db *DB) DeleteWorkspaceQuota(workspaceID string) error
- func (db *DB) GetAgentInfo(sandboxID string) (*AgentInfo, error)
- func (db *DB) GetAllWorkspaceNamespaces() ([]string, error)
- func (db *DB) GetBindingsWithBotToken() ([]*WeixinBinding, error)
- func (db *DB) GetBotCredentials(sandboxID, botID string) (botToken, baseURL string, err error)
- func (db *DB) GetContextToken(sandboxID, botID, userID string) (string, error)
- func (db *DB) GetModelserverConnection(workspaceID string) (*ModelserverConnection, error)
- func (db *DB) GetOIDCIdentity(provider, subject string) (*OIDCIdentity, error)
- func (db *DB) GetPasswordHash(userID string) (*string, error)
- func (db *DB) GetSandbox(id string) (*Sandbox, error)
- func (db *DB) GetSandboxByBotID(botID string) (string, error)
- func (db *DB) GetSandboxByProxyToken(proxyToken string) (*Sandbox, error)
- func (db *DB) GetSandboxByShortID(shortID string) (*Sandbox, error)
- func (db *DB) GetSandboxByTunnelToken(sandboxID, tunnelToken string) (*Sandbox, error)
- func (db *DB) GetSystemSetting(key string) (string, error)
- func (db *DB) GetUserByEmail(email string) (*User, error)
- func (db *DB) GetUserByID(id string) (*User, error)
- func (db *DB) GetUserQuota(userID string) (*UserQuota, error)
- func (db *DB) GetWorkspace(id string) (*Workspace, error)
- func (db *DB) GetWorkspaceLLMConfig(workspaceID string) (*WorkspaceLLMConfig, error)
- func (db *DB) GetWorkspaceMember(workspaceID, userID string) (*WorkspaceMember, error)
- func (db *DB) GetWorkspaceMemberRole(workspaceID, userID string) (string, error)
- func (db *DB) GetWorkspaceQuota(workspaceID string) (*WorkspaceQuota, error)
- func (db *DB) HasModelserverConnection(workspaceID string) (bool, error)
- func (db *DB) IsWorkspaceMember(workspaceID, userID string) (bool, error)
- func (db *DB) ListAllActiveSandboxNames() ([]string, error)
- func (db *DB) ListAllSandboxes() ([]*Sandbox, error)
- func (db *DB) ListAllUsers() ([]*User, error)
- func (db *DB) ListAllWorkspaces() ([]*Workspace, error)
- func (db *DB) ListAllWorkspacesAdmin() ([]*AdminWorkspaceInfo, error)
- func (db *DB) ListIdleSandboxes(defaultTimeoutSeconds int) ([]*Sandbox, error)
- func (db *DB) ListSandboxesByWorkspace(workspaceID string) ([]*Sandbox, error)
- func (db *DB) ListWeixinBindings(sandboxID string) ([]*WeixinBinding, error)
- func (db *DB) ListWorkspaceMembers(workspaceID string) ([]*WorkspaceMember, error)
- func (db *DB) ListWorkspaceVolumes(workspaceID string) ([]WorkspaceVolume, error)
- func (db *DB) ListWorkspacesByUser(userID string) ([]*Workspace, error)
- func (db *DB) ListWorkspacesWithoutNamespace() ([]*Workspace, error)
- func (db *DB) RemoveWorkspaceMember(workspaceID, userID string) error
- func (db *DB) SaveBotCredentials(sandboxID, botID, botToken, baseURL string) error
- func (db *DB) SetModelserverConnection(c *ModelserverConnection) error
- func (db *DB) SetPasswordHash(userID, hash string) error
- func (db *DB) SetSystemSetting(key, value string) error
- func (db *DB) SetUserQuota(userID string, maxWorkspaces *int) error
- func (db *DB) SetWorkspaceLLMConfig(workspaceID, baseURL, apiKey string, models []LLMModel) error
- func (db *DB) SetWorkspaceNamespace(id, namespace string) error
- func (db *DB) SetWorkspaceQuota(workspaceID string, maxSandboxes *int, maxSandboxCPU *int, ...) error
- func (db *DB) SumWorkspaceSandboxResources(workspaceID string) (cpuMillis int64, memBytes int64, err error)
- func (db *DB) UpdateGetUpdatesBuf(sandboxID, botID, buf string) error
- func (db *DB) UpdateModelserverTokens(workspaceID, accessToken, refreshToken string, expiresAt time.Time) error
- func (db *DB) UpdateOIDCIdentityEmail(provider, subject, email string) error
- func (db *DB) UpdateSandboxActivity(id string) error
- func (db *DB) UpdateSandboxHeartbeat(id string) error
- func (db *DB) UpdateSandboxName(id, name string) error
- func (db *DB) UpdateSandboxNanoclawBridgeSecret(id, secret string) error
- func (db *DB) UpdateSandboxPodIP(id, podIP string) error
- func (db *DB) UpdateSandboxSandboxName(id, sandboxName string) error
- func (db *DB) UpdateSandboxStatus(id, status string) error
- func (db *DB) UpdateUserEmail(userID, email string) error
- func (db *DB) UpdateUserName(userID, name string) error
- func (db *DB) UpdateUserPicture(userID, picture string) error
- func (db *DB) UpdateUserRole(userID, role string) error
- func (db *DB) UpdateWorkspaceMemberRole(workspaceID, userID, role string) error
- func (db *DB) UpdateWorkspaceName(id, name string) error
- func (db *DB) UpsertAgentInfo(info *AgentInfo) error
- func (db *DB) UpsertContextToken(sandboxID, botID, userID, contextToken string) error
- func (db *DB) ValidateToken(token string) (string, error)
- type LLMModel
- type ModelserverConnection
- type OIDCIdentity
- type Sandbox
- type User
- type UserQuota
- type WeixinBinding
- type Workspace
- type WorkspaceLLMConfig
- type WorkspaceMember
- type WorkspaceQuota
- type WorkspaceVolume
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminWorkspaceInfo ¶ added in v0.18.3
type AdminWorkspaceInfo struct {
Workspace
OwnerID *string
OwnerEmail *string
OwnerName *string
OwnerPicture *string
SandboxCount int
}
AdminWorkspaceInfo holds enriched workspace data for the admin panel.
type AgentInfo ¶ added in v0.16.0
type AgentInfo struct {
SandboxID string `json:"sandbox_id"`
Hostname string `json:"hostname"`
OS string `json:"os"`
Platform string `json:"platform"`
PlatformVersion string `json:"platform_version"`
KernelArch string `json:"kernel_arch"`
CPUModelName string `json:"cpu_model_name"`
CPUCountLogical int `json:"cpu_count_logical"`
MemoryTotal int64 `json:"memory_total"`
DiskTotal int64 `json:"disk_total"`
DiskFree int64 `json:"disk_free"`
AgentVersion string `json:"agent_version"`
OpencodeVersion string `json:"opencode_version"`
Workdir string `json:"workdir"`
HostInfo json.RawMessage `json:"host_info"`
CPUInfo json.RawMessage `json:"cpu_info"`
MemoryInfo json.RawMessage `json:"memory_info"`
DiskInfo json.RawMessage `json:"disk_info"`
UpdatedAt time.Time `json:"updated_at"`
}
AgentInfo holds system information reported by a local agent.
type AgentRegistrationCode ¶
type DB ¶
DB wraps a *sql.DB with migration support.
func (*DB) AddWorkspaceMember ¶
func (*DB) AddWorkspaceVolume ¶ added in v0.9.0
func (*DB) ConsumeAgentRegistrationCode ¶
func (db *DB) ConsumeAgentRegistrationCode(code string) (*AgentRegistrationCode, error)
ConsumeAgentRegistrationCode atomically validates and marks a code as used. Returns the code record if valid, nil if not found/expired/used.
func (*DB) CountSandboxesByWorkspace ¶ added in v0.7.0
func (*DB) CountUsers ¶ added in v0.6.1
func (*DB) CountWorkspacesOwnedByUser ¶ added in v0.7.0
func (*DB) CreateAgentRegistrationCode ¶
func (db *DB) CreateAgentRegistrationCode(code, userID, workspaceID string, expiresAt time.Time) error
CreateAgentRegistrationCode inserts a new one-time registration code.
func (*DB) CreateLocalSandbox ¶
func (db *DB) CreateLocalSandbox(id, workspaceID, name, sandboxType, opencodeToken, proxyToken, tunnelToken, shortID string) error
CreateLocalSandbox inserts a local agent sandbox with is_local=true.
func (*DB) CreateOIDCIdentity ¶
func (*DB) CreateSandbox ¶
func (*DB) CreateUser ¶
func (*DB) CreateUserWithEmail ¶
func (*DB) CreateWeixinBinding ¶ added in v0.22.0
CreateWeixinBinding inserts a new binding record after a successful QR login.
func (*DB) CreateWorkspace ¶
func (*DB) DeleteExpiredTokens ¶
func (*DB) DeleteModelserverConnection ¶ added in v0.22.0
func (*DB) DeleteSandbox ¶
func (*DB) DeleteUserQuota ¶ added in v0.7.0
func (*DB) DeleteWorkspace ¶
func (*DB) DeleteWorkspaceLLMConfig ¶ added in v0.22.0
func (*DB) DeleteWorkspaceQuota ¶ added in v0.9.0
func (*DB) GetAgentInfo ¶ added in v0.16.0
GetAgentInfo returns agent info for a sandbox, or nil,nil if not found.
func (*DB) GetAllWorkspaceNamespaces ¶
func (*DB) GetBindingsWithBotToken ¶ added in v0.26.0
func (db *DB) GetBindingsWithBotToken() ([]*WeixinBinding, error)
GetBindingsWithBotToken returns all nanoclaw bindings that have a bot_token set, for starting long-poll goroutines. Only returns bindings for running nanoclaw sandboxes.
func (*DB) GetBotCredentials ¶ added in v0.26.0
GetBotCredentials returns the bot_token and ilink_base_url for a specific binding. Used by the outbound bridge endpoint to send messages via iLink.
func (*DB) GetContextToken ¶ added in v0.26.0
GetContextToken retrieves the cached context_token for a user.
func (*DB) GetModelserverConnection ¶ added in v0.22.0
func (db *DB) GetModelserverConnection(workspaceID string) (*ModelserverConnection, error)
func (*DB) GetOIDCIdentity ¶
func (db *DB) GetOIDCIdentity(provider, subject string) (*OIDCIdentity, error)
func (*DB) GetPasswordHash ¶ added in v0.9.0
GetPasswordHash returns the bcrypt hash for the given user, or nil if no credential exists.
func (*DB) GetSandboxByBotID ¶ added in v0.26.0
GetSandboxByBotID returns the sandbox_id for a given WeChat bot_id. Used for routing inbound iLink messages to the correct NanoClaw sandbox.
func (*DB) GetSandboxByProxyToken ¶
func (*DB) GetSandboxByShortID ¶
func (*DB) GetSandboxByTunnelToken ¶
GetSandboxByTunnelToken finds a local sandbox by its tunnel token.
func (*DB) GetSystemSetting ¶ added in v0.7.0
func (*DB) GetUserQuota ¶ added in v0.7.0
func (*DB) GetWorkspaceLLMConfig ¶ added in v0.22.0
func (db *DB) GetWorkspaceLLMConfig(workspaceID string) (*WorkspaceLLMConfig, error)
func (*DB) GetWorkspaceMember ¶
func (db *DB) GetWorkspaceMember(workspaceID, userID string) (*WorkspaceMember, error)
func (*DB) GetWorkspaceMemberRole ¶
func (*DB) GetWorkspaceQuota ¶ added in v0.9.0
func (db *DB) GetWorkspaceQuota(workspaceID string) (*WorkspaceQuota, error)
func (*DB) HasModelserverConnection ¶ added in v0.22.0
func (*DB) IsWorkspaceMember ¶
func (*DB) ListAllActiveSandboxNames ¶
func (*DB) ListAllSandboxes ¶ added in v0.6.1
func (*DB) ListAllUsers ¶ added in v0.6.1
func (*DB) ListAllWorkspaces ¶ added in v0.6.1
func (*DB) ListAllWorkspacesAdmin ¶ added in v0.18.3
func (db *DB) ListAllWorkspacesAdmin() ([]*AdminWorkspaceInfo, error)
func (*DB) ListIdleSandboxes ¶
func (*DB) ListSandboxesByWorkspace ¶
func (*DB) ListWeixinBindings ¶ added in v0.22.0
func (db *DB) ListWeixinBindings(sandboxID string) ([]*WeixinBinding, error)
ListWeixinBindings returns all binding records for a sandbox, most recent first.
func (*DB) ListWorkspaceMembers ¶
func (db *DB) ListWorkspaceMembers(workspaceID string) ([]*WorkspaceMember, error)
func (*DB) ListWorkspaceVolumes ¶ added in v0.9.0
func (db *DB) ListWorkspaceVolumes(workspaceID string) ([]WorkspaceVolume, error)
func (*DB) ListWorkspacesByUser ¶
func (*DB) ListWorkspacesWithoutNamespace ¶
func (*DB) RemoveWorkspaceMember ¶
func (*DB) SaveBotCredentials ¶ added in v0.26.0
SaveBotCredentials stores iLink bot credentials for bridge-mode messaging. Used by nanoclaw sandboxes where agentserver holds the credentials.
func (*DB) SetModelserverConnection ¶ added in v0.22.0
func (db *DB) SetModelserverConnection(c *ModelserverConnection) error
func (*DB) SetPasswordHash ¶ added in v0.9.0
SetPasswordHash upserts a password hash for the given user.
func (*DB) SetSystemSetting ¶ added in v0.7.0
func (*DB) SetUserQuota ¶ added in v0.7.0
func (*DB) SetWorkspaceLLMConfig ¶ added in v0.22.0
func (*DB) SetWorkspaceNamespace ¶
func (*DB) SetWorkspaceQuota ¶ added in v0.9.0
func (*DB) SumWorkspaceSandboxResources ¶ added in v0.7.0
func (db *DB) SumWorkspaceSandboxResources(workspaceID string) (cpuMillis int64, memBytes int64, err error)
SumWorkspaceSandboxResources returns the total CPU (millicores) and memory (bytes) allocated by non-offline sandboxes in a workspace.
func (*DB) UpdateGetUpdatesBuf ¶ added in v0.26.0
UpdateGetUpdatesBuf persists the long-poll cursor for a binding.
func (*DB) UpdateModelserverTokens ¶ added in v0.22.0
func (*DB) UpdateOIDCIdentityEmail ¶ added in v0.9.0
func (*DB) UpdateSandboxActivity ¶
func (*DB) UpdateSandboxHeartbeat ¶
UpdateSandboxHeartbeat updates the last_heartbeat_at timestamp.
func (*DB) UpdateSandboxName ¶ added in v0.16.0
func (*DB) UpdateSandboxNanoclawBridgeSecret ¶ added in v0.26.0
UpdateSandboxNanoclawBridgeSecret stores the bridge secret for a nanoclaw sandbox.
func (*DB) UpdateSandboxPodIP ¶
func (*DB) UpdateSandboxSandboxName ¶
func (*DB) UpdateSandboxStatus ¶
func (*DB) UpdateUserEmail ¶
func (*DB) UpdateUserName ¶ added in v0.9.0
func (*DB) UpdateUserPicture ¶ added in v0.9.0
func (*DB) UpdateUserRole ¶ added in v0.6.1
func (*DB) UpdateWorkspaceMemberRole ¶
func (*DB) UpdateWorkspaceName ¶ added in v0.16.0
func (*DB) UpsertAgentInfo ¶ added in v0.16.0
UpsertAgentInfo inserts or updates agent info for a sandbox.
func (*DB) UpsertContextToken ¶ added in v0.26.0
UpsertContextToken stores or updates the context_token for a user conversation.
type ModelserverConnection ¶ added in v0.22.0
type ModelserverConnection struct {
WorkspaceID string `json:"workspace_id"`
ProjectID string `json:"project_id"`
ProjectName string `json:"project_name"`
UserID string `json:"user_id"`
AccessToken string `json:"-"`
RefreshToken string `json:"-"`
TokenExpiresAt time.Time `json:"token_expires_at"`
Models []LLMModel `json:"models"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type OIDCIdentity ¶
type Sandbox ¶
type Sandbox struct {
ID string
WorkspaceID string
Name string
Type string
Status string
IsLocal bool
ShortID sql.NullString
SandboxName sql.NullString
PodIP sql.NullString
ProxyToken sql.NullString
OpencodeToken sql.NullString
OpenclawToken sql.NullString
TunnelToken sql.NullString
NanoclawBridgeSecret sql.NullString
LastActivityAt sql.NullTime
CreatedAt time.Time
PausedAt sql.NullTime
LastHeartbeatAt sql.NullTime
CPU *int
Memory *int64
IdleTimeout *int
}
type WeixinBinding ¶ added in v0.22.0
type WeixinBinding struct {
ID int
SandboxID string
BotID string
UserID string
BoundAt time.Time
BotToken string
ILinkBaseURL string
GetUpdatesBuf string
}
WeixinBinding records a WeChat QR scan binding for a sandbox.