mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: chat desktop backend (#23005)
Implement the backend for the desktop feature for agents. - Adds a new `/api/experimental/chats/$id/desktop` endpoint to coderd which exposes a VNC stream from a [portabledesktop](https://github.com/coder/portabledesktop) process running inside the workspace - Adds a new `spawn_computer_use_agent` tool to chatd, which spawns a subagent that has access to the `computer` tool which lets it interact with the `portabledesktop` process running inside the workspace - Adds the plumbing to make the above possible There's a follow up frontend PR here: https://github.com/coder/coder/pull/23006
This commit is contained in:
@@ -1174,6 +1174,61 @@ func AllChatMessageVisibilityValues() []ChatMessageVisibility {
|
||||
}
|
||||
}
|
||||
|
||||
type ChatMode string
|
||||
|
||||
const (
|
||||
ChatModeComputerUse ChatMode = "computer_use"
|
||||
)
|
||||
|
||||
func (e *ChatMode) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = ChatMode(s)
|
||||
case string:
|
||||
*e = ChatMode(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for ChatMode: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullChatMode struct {
|
||||
ChatMode ChatMode `json:"chat_mode"`
|
||||
Valid bool `json:"valid"` // Valid is true if ChatMode is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullChatMode) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.ChatMode, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.ChatMode.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullChatMode) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.ChatMode), nil
|
||||
}
|
||||
|
||||
func (e ChatMode) Valid() bool {
|
||||
switch e {
|
||||
case ChatModeComputerUse:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func AllChatModeValues() []ChatMode {
|
||||
return []ChatMode{
|
||||
ChatModeComputerUse,
|
||||
}
|
||||
}
|
||||
|
||||
type ChatStatus string
|
||||
|
||||
const (
|
||||
@@ -3972,6 +4027,7 @@ type Chat struct {
|
||||
LastModelConfigID uuid.UUID `db:"last_model_config_id" json:"last_model_config_id"`
|
||||
Archived bool `db:"archived" json:"archived"`
|
||||
LastError sql.NullString `db:"last_error" json:"last_error"`
|
||||
Mode NullChatMode `db:"mode" json:"mode"`
|
||||
}
|
||||
|
||||
type ChatDiffStatus struct {
|
||||
|
||||
Reference in New Issue
Block a user