Skill and extension picker for Paperclip agents; session notes and cleanup plan
This commit is contained in:
@@ -499,3 +499,60 @@ func (c *Client) DashboardSummary() (Dashboard, error) {
|
||||
err := c.do("GET", "/api/companies/"+c.Company+"/dashboard", nil, &out)
|
||||
return out, err
|
||||
}
|
||||
|
||||
// AgentSkills is what an agent may use: the desired list and what is installed.
|
||||
type AgentSkills struct {
|
||||
DesiredSkills []string `json:"desiredSkills"`
|
||||
Entries []struct {
|
||||
Key string `json:"key"`
|
||||
RuntimeName string `json:"runtimeName"`
|
||||
State string `json:"state"`
|
||||
} `json:"entries"`
|
||||
}
|
||||
|
||||
func (c *Client) AgentSkills(agentID string) (AgentSkills, error) {
|
||||
var out AgentSkills
|
||||
err := c.do("GET", "/api/agents/"+agentID+"/skills", nil, &out)
|
||||
return out, err
|
||||
}
|
||||
|
||||
// SyncSkills sets an agent's skills. mode is add, remove or replace.
|
||||
func (c *Client) SyncSkills(agentID, mode string, keys []string) error {
|
||||
if !c.UsingUserKey() {
|
||||
return errors.New("refusing to write with the agent key: set PAPERCLIP_BOARD_KEY")
|
||||
}
|
||||
return c.do("POST", "/api/agents/"+agentID+"/skills/sync",
|
||||
map[string]any{"mode": mode, "desiredSkills": keys}, nil)
|
||||
}
|
||||
|
||||
// CompanySkill is one skill Paperclip knows about for this company.
|
||||
type CompanySkill struct {
|
||||
Key string `json:"key"`
|
||||
Slug string `json:"slug"`
|
||||
Name string `json:"name"`
|
||||
SourceType string `json:"sourceType"`
|
||||
}
|
||||
|
||||
func (c *Client) CompanySkills() ([]CompanySkill, error) {
|
||||
var out []CompanySkill
|
||||
err := c.do("GET", "/api/companies/"+c.Company+"/skills", nil, &out)
|
||||
return out, err
|
||||
}
|
||||
|
||||
// ImportSkill adds a skill that lives in the company's managed folder.
|
||||
func (c *Client) ImportSkill(source string) (string, error) {
|
||||
if !c.UsingUserKey() {
|
||||
return "", errors.New("refusing to write with the agent key: set PAPERCLIP_BOARD_KEY")
|
||||
}
|
||||
var out struct {
|
||||
Imported []CompanySkill `json:"imported"`
|
||||
}
|
||||
if err := c.do("POST", "/api/companies/"+c.Company+"/skills/import",
|
||||
map[string]string{"source": source}, &out); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(out.Imported) > 0 {
|
||||
return out.Imported[0].Key, nil
|
||||
}
|
||||
return "", fmt.Errorf("import returned no skill")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user