Let the lead configure the iPhone Action button
This commit is contained in:
@@ -51,6 +51,23 @@ func (m *Manager) SetReviewWorkflow(ctx context.Context, projectID, name, actor
|
||||
return m.store.SetReviewWorkflow(ctx, projectID, name, actor)
|
||||
}
|
||||
|
||||
func (m *Manager) SetQuickRun(ctx context.Context, login string, q api.QuickRun) (api.User, error) {
|
||||
if (q.ProjectId == "") != (q.Workflow == "") {
|
||||
return api.User{}, fmt.Errorf("%w: project_id and workflow are set together", ErrInvalid)
|
||||
}
|
||||
if q.ProjectId != "" {
|
||||
_, err := m.store.GetProject(ctx, q.ProjectId)
|
||||
if err != nil {
|
||||
return api.User{}, fmt.Errorf("project %s: %w", q.ProjectId, err)
|
||||
}
|
||||
_, err = m.store.GetWorkflow(ctx, q.Workflow)
|
||||
if err != nil {
|
||||
return api.User{}, fmt.Errorf("workflow %q: %w", q.Workflow, err)
|
||||
}
|
||||
}
|
||||
return m.store.UpdateQuickRun(ctx, login, q)
|
||||
}
|
||||
|
||||
func reviewProblem(def api.WorkflowDefinition) error {
|
||||
for _, s := range workflow.Stages(def) {
|
||||
if s.Agents != nil {
|
||||
@@ -918,6 +935,29 @@ func (m *Manager) workflowTools(tool func(name, description, schema string, run
|
||||
return fmt.Sprintf("Project %s is audited with workflow %q.", p.Name, p.AuditWorkflow), nil
|
||||
}),
|
||||
|
||||
tool("set_action_button",
|
||||
"Set the workflow the human's iPhone Action button starts, and the project it runs in: pressing the button opens byre for a prompt and starts that workflow with it as the brief. "+
|
||||
"Empty project_id and workflow turn it off. Only when the human asks.",
|
||||
`{"type": "object", "properties": {
|
||||
"project_id": {"type": "string"},
|
||||
"workflow": {"type": "string"}
|
||||
}, "required": ["project_id", "workflow"]}`,
|
||||
func(ctx context.Context, user api.User, raw json.RawMessage) (string, error) {
|
||||
q := api.QuickRun{}
|
||||
err := json.Unmarshal(raw, &q)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
u, err := m.SetQuickRun(ctx, user.Login, q)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if u.QuickRun.Workflow == "" {
|
||||
return "The Action button starts no workflow now.", nil
|
||||
}
|
||||
return fmt.Sprintf("The Action button starts workflow %q in project %s.", u.QuickRun.Workflow, u.QuickRun.ProjectId), nil
|
||||
}),
|
||||
|
||||
tool("delete_workflow",
|
||||
"Delete a workflow from the server. Tasks that froze it keep their copy. Only when the human asks.",
|
||||
`{"type": "object", "properties": {"name": {"type": "string"}}, "required": ["name"]}`,
|
||||
|
||||
Reference in New Issue
Block a user