Skip to content
This repository was archived by the owner on Apr 14, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions cmd/dalcli-leader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {
Short: fmt.Sprintf("Dal CLI for leader dal (%s)", dalName),
}

root.AddCommand(wakeCmd(), sleepCmd(), psCmd(), statusCmd(), logsCmd(), syncCmd(), assignCmd(dalName), postCmd())
root.AddCommand(wakeCmd(), sleepCmd(), psCmd(), statusCmd(), logsCmd(), syncCmd(), assignCmd(dalName), postCmd(), issueWorkflowCmd())

if err := root.Execute(); err != nil {
os.Exit(1)
Expand Down Expand Up @@ -54,7 +54,7 @@ func wakeCmd() *cobra.Command {
return nil
},
}
cmd.Flags().StringVar(&issueID, "issue", "", "Issue ID for branch creation (e.g. 489)")
cmd.Flags().StringVar(&issueID, "issue", "", "Issue ID for branch creation (creates issue-N/dal branch)")
return cmd
}

Expand Down Expand Up @@ -223,6 +223,35 @@ func postCmd() *cobra.Command {
return cmd
}

func issueWorkflowCmd() *cobra.Command {
var member string
cmd := &cobra.Command{
Use: "issue-workflow <issue-id> <task>",
Short: "Start full issue workflow: wake member → assign task → track → notify",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := daemon.NewClient()
if err != nil {
return err
}
issueID := args[0]
task := args[1]
if member == "" {
member = "dev"
}
result, err := client.StartIssueWorkflow(issueID, member, task, "")
if err != nil {
return err
}
fmt.Printf("issue-workflow: started %s (issue=#%s, member=%s)\n", result.WorkflowID, issueID, member)
fmt.Printf("status: %s\n", result.Status)
return nil
},
}
cmd.Flags().StringVar(&member, "member", "dev", "Member dal to assign")
return cmd
}

func assignCmd(dalName string) *cobra.Command {
return &cobra.Command{
Use: "assign <dal> <task>",
Expand Down
77 changes: 77 additions & 0 deletions internal/daemon/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,3 +541,80 @@ func (c *Client) TaskList() ([]TaskResult, error) {
json.NewDecoder(resp.Body).Decode(&results)
return results, nil
}

// IssueWorkflowResult holds the response from an issue workflow request.
type IssueWorkflowResult struct {
WorkflowID string `json:"workflow_id"`
Status string `json:"status"`
IssueID string `json:"issue_id"`
Error string `json:"error,omitempty"`
}

// IssueWorkflowStatus holds the full status of an issue workflow.
type IssueWorkflowStatus struct {
ID string `json:"id"`
IssueID string `json:"issue_id"`
Member string `json:"member"`
Task string `json:"task"`
Status string `json:"status"`
Phase string `json:"phase"`
TaskID string `json:"task_id,omitempty"`
PRUrl string `json:"pr_url,omitempty"`
Error string `json:"error,omitempty"`
StartedAt string `json:"started_at"`
DoneAt string `json:"done_at,omitempty"`
}

// StartIssueWorkflow kicks off the full issue workflow orchestration.
func (c *Client) StartIssueWorkflow(issueID, member, task, callbackPane string) (*IssueWorkflowResult, error) {
body := fmt.Sprintf(`{"issue_id":%q,"member":%q,"task":%q,"callback_pane":%q}`,
issueID, member, task, callbackPane)
req, err := http.NewRequest(http.MethodPost, c.baseURL+"/api/issue-workflow", strings.NewReader(body))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
if c.apiToken != "" {
req.Header.Set("Authorization", "Bearer "+c.apiToken)
}
resp, err := c.http.Do(req)
if err != nil {
return nil, fmt.Errorf("daemon unreachable: %w", err)
}
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
if resp.StatusCode >= 400 {
return nil, fmt.Errorf("issue workflow failed: %s", strings.TrimSpace(string(b)))
}
var result IssueWorkflowResult
json.Unmarshal(b, &result)
return &result, nil
}

// GetIssueWorkflow returns the status of an issue workflow.
func (c *Client) GetIssueWorkflow(id string) (*IssueWorkflowStatus, error) {
resp, err := c.http.Get(c.baseURL + "/api/issue-workflow/" + id)
if err != nil {
return nil, fmt.Errorf("daemon unreachable: %w", err)
}
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
if resp.StatusCode >= 400 {
return nil, fmt.Errorf("workflow not found: %s", strings.TrimSpace(string(b)))
}
var result IssueWorkflowStatus
json.Unmarshal(b, &result)
return &result, nil
}

// ListIssueWorkflows returns all issue workflows.
func (c *Client) ListIssueWorkflows() ([]IssueWorkflowStatus, error) {
resp, err := c.http.Get(c.baseURL + "/api/issue-workflows")
if err != nil {
return nil, fmt.Errorf("daemon unreachable: %w", err)
}
defer resp.Body.Close()
var results []IssueWorkflowStatus
json.NewDecoder(resp.Body).Decode(&results)
return results, nil
}
21 changes: 14 additions & 7 deletions internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ type Daemon struct {
claims *claimStore
tasks *taskStore
feedback *feedbackStore
costs *costStore
issues *issueStore
registry *Registry
startTime time.Time
costs *costStore
issues *issueStore
issueWorkflows *issueWorkflowStore
registry *Registry
startTime time.Time
}

// Container tracks a running dal Docker container.
Expand Down Expand Up @@ -88,9 +89,10 @@ func New(addr, localdalRoot, serviceRepo, bridgeURL, dalbridgeURL, bridgeConf, g
claims: newClaimStoreWithFile(filepath.Join(dataDir(serviceRepo), "claims.json")),
tasks: newTaskStoreWithFile(filepath.Join(dataDir(serviceRepo), "tasks.json")),
feedback: newFeedbackStoreWithFile(filepath.Join(dataDir(serviceRepo), "feedback.json")),
costs: newCostStoreWithFile(filepath.Join(dataDir(serviceRepo), "costs.json"), orchestrationLogDir(serviceRepo)),
issues: newIssueStore(filepath.Join(dataDir(serviceRepo), "issues_seen.json")),
registry: newRegistry(serviceRepo),
costs: newCostStoreWithFile(filepath.Join(dataDir(serviceRepo), "costs.json"), orchestrationLogDir(serviceRepo)),
issues: newIssueStore(filepath.Join(dataDir(serviceRepo), "issues_seen.json")),
issueWorkflows: newIssueWorkflowStore(),
registry: newRegistry(serviceRepo),
credSyncLast: newCredentialSyncMap(),
startTime: time.Now(),
}
Expand Down Expand Up @@ -241,6 +243,11 @@ func (d *Daemon) Run(ctx context.Context) error {
mux.HandleFunc("GET /api/provider-status", d.handleProviderStatus)
mux.HandleFunc("POST /api/provider-trip", d.handleProviderTrip)

// Issue workflow — full orchestration endpoints
mux.HandleFunc("POST /api/issue-workflow", d.requireAuth(d.handleIssueWorkflow))
mux.HandleFunc("GET /api/issue-workflow/{id}", d.handleIssueWorkflowStatus)
mux.HandleFunc("GET /api/issue-workflows", d.handleIssueWorkflowList)

mux.HandleFunc("GET /.well-known/agent-card.json", d.handleAgentCard)
mux.HandleFunc("POST /rpc", d.requireAuth(d.handleA2ARPC))

Expand Down
Loading
Loading