MCPcopy Create free account
hub / github.com/compozy/agh / newTaskNextCommand

Function newTaskNextCommand

internal/cli/task.go:1570–1637  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

1568}
1569
1570func newTaskNextCommand(deps commandDeps) *cobra.Command {
1571 var (
1572 workspaceID string
1573 requiredCapabilities []string
1574 priorityMin int
1575 leaseSeconds int64
1576 wait bool
1577 idempotencyKey string
1578 )
1579
1580 cmd := &cobra.Command{
1581 Use: taskNextKey,
1582 Short: "Claim the next task run for the current agent session",
1583 Args: cobra.NoArgs,
1584 Example: ` # Claim the next available run for this session
1585 agh task next
1586
1587 # Wait until matching work is claimable and request a five-minute lease
1588 agh task next --wait --lease-seconds 300 -o json
1589
1590 # Filter by required caller capability
1591 agh task next --capability go.test --priority-min 10`,
1592 RunE: func(cmd *cobra.Command, _ []string) error {
1593 if err := validateAgentTaskLeaseSeconds(leaseSeconds); err != nil {
1594 return err
1595 }
1596 if priorityMin < 0 {
1597 return fmt.Errorf("cli: --priority-min must be zero or positive: %d", priorityMin)
1598 }
1599 request := AgentTaskClaimNextRequest{
1600 WorkspaceID: strings.TrimSpace(workspaceID),
1601 RequiredCapabilities: trimAgentTaskCapabilities(requiredCapabilities),
1602 PriorityMin: priorityMin,
1603 LeaseSeconds: leaseSeconds,
1604 Wait: wait,
1605 IdempotencyKey: strings.TrimSpace(idempotencyKey),
1606 }
1607
1608 client, err := clientFromDeps(deps)
1609 if err != nil {
1610 return err
1611 }
1612 credentials, err := requireAgentCommandIdentity(
1613 cmd.Context(),
1614 deps,
1615 client,
1616 agentActionCLI("task.next"),
1617 )
1618 if err != nil {
1619 return err
1620 }
1621 record, err := client.AgentTaskClaimNext(cmd.Context(), request, credentials)
1622 if err != nil {
1623 return err
1624 }
1625 return writeCommandOutput(cmd, agentTaskNextBundle(record))
1626 },
1627 }

Callers 1

newTaskCommandFunction · 0.85

Calls 8

clientFromDepsFunction · 0.85
agentActionCLIFunction · 0.85
writeCommandOutputFunction · 0.85
agentTaskNextBundleFunction · 0.85
AgentTaskClaimNextMethod · 0.65

Tested by

no test coverage detected