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

Function runSessionTaskFailCommand

internal/cli/task.go:1785–1828  ·  view source on GitHub ↗
(
	cmd *cobra.Command,
	deps commandDeps,
	runIDs []string,
	flags taskFailCommandFlags,
)

Source from the content-addressed store, hash-verified

1783}
1784
1785func runSessionTaskFailCommand(
1786 cmd *cobra.Command,
1787 deps commandDeps,
1788 runIDs []string,
1789 flags taskFailCommandFlags,
1790) error {
1791 if cmd.Flags().Changed("reason") {
1792 return errors.New(
1793 "cli: choose either --error for session-bound failure or --reason for force failure",
1794 )
1795 }
1796 if len(runIDs) != 1 {
1797 return errors.New("cli: --error supports exactly one run id")
1798 }
1799 request := AgentTaskFailRequest{Error: strings.TrimSpace(flags.errorMessage)}
1800 if request.Error == "" {
1801 return errors.New("cli: --error is required")
1802 }
1803 if cmd.Flags().Changed("metadata") {
1804 metadata, err := parseAgentTaskJSONFlag("metadata", flags.metadataRaw)
1805 if err != nil {
1806 return err
1807 }
1808 request.Metadata = metadata
1809 }
1810 client, err := clientFromDeps(deps)
1811 if err != nil {
1812 return err
1813 }
1814 credentials, err := requireAgentCommandIdentity(
1815 cmd.Context(),
1816 deps,
1817 client,
1818 agentActionCLI("task.fail"),
1819 )
1820 if err != nil {
1821 return err
1822 }
1823 record, err := client.AgentTaskFail(cmd.Context(), runIDs[0], request, credentials)
1824 if err != nil {
1825 return err
1826 }
1827 return writeCommandOutput(cmd, agentTaskLeaseBundle(record))
1828}
1829
1830func runForceTaskFailCommand(
1831 cmd *cobra.Command,

Callers 1

runTaskFailCommandFunction · 0.85

Calls 7

parseAgentTaskJSONFlagFunction · 0.85
clientFromDepsFunction · 0.85
agentActionCLIFunction · 0.85
writeCommandOutputFunction · 0.85
agentTaskLeaseBundleFunction · 0.85
AgentTaskFailMethod · 0.65

Tested by

no test coverage detected