(deps commandDeps)
| 1685 | } |
| 1686 | |
| 1687 | func newTaskCompleteCommand(deps commandDeps) *cobra.Command { |
| 1688 | var resultRaw string |
| 1689 | |
| 1690 | cmd := &cobra.Command{ |
| 1691 | Use: "complete <run-id>", |
| 1692 | Short: "Complete a claimed task run for the current agent session", |
| 1693 | Args: cobra.ExactArgs(1), |
| 1694 | Example: ` # Complete a claimed run |
| 1695 | agh task complete run-123 |
| 1696 | |
| 1697 | # Complete with structured result data |
| 1698 | agh task complete run-123 --result '{"summary":"tests passed"}'`, |
| 1699 | RunE: func(cmd *cobra.Command, args []string) error { |
| 1700 | runID, err := requiredAgentTaskRunID(args[0]) |
| 1701 | if err != nil { |
| 1702 | return err |
| 1703 | } |
| 1704 | request := AgentTaskCompleteRequest{} |
| 1705 | if cmd.Flags().Changed("result") { |
| 1706 | request.Result, err = parseAgentTaskJSONFlag("result", resultRaw) |
| 1707 | if err != nil { |
| 1708 | return err |
| 1709 | } |
| 1710 | } |
| 1711 | |
| 1712 | client, err := clientFromDeps(deps) |
| 1713 | if err != nil { |
| 1714 | return err |
| 1715 | } |
| 1716 | credentials, err := requireAgentCommandIdentity( |
| 1717 | cmd.Context(), |
| 1718 | deps, |
| 1719 | client, |
| 1720 | agentActionCLI("task.complete"), |
| 1721 | ) |
| 1722 | if err != nil { |
| 1723 | return err |
| 1724 | } |
| 1725 | record, err := client.AgentTaskComplete(cmd.Context(), runID, request, credentials) |
| 1726 | if err != nil { |
| 1727 | return err |
| 1728 | } |
| 1729 | return writeCommandOutput(cmd, agentTaskLeaseBundle(record)) |
| 1730 | }, |
| 1731 | } |
| 1732 | cmd.Flags().StringVar(&resultRaw, "result", "", "Optional result JSON") |
| 1733 | return cmd |
| 1734 | } |
| 1735 | |
| 1736 | func newTaskFailCommand(deps commandDeps) *cobra.Command { |
| 1737 | flags := taskFailCommandFlags{} |
no test coverage detected