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

Function newTaskBlockCommand

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

Source from the content-addressed store, hash-verified

1425}
1426
1427func newTaskBlockCommand(deps commandDeps) *cobra.Command {
1428 input := taskBlockInput{}
1429 cmd := &cobra.Command{
1430 Use: "block <id>",
1431 Short: "Block a task with a typed reason",
1432 Args: exactOneNonBlankArg(),
1433 RunE: func(cmd *cobra.Command, args []string) error {
1434 request, err := buildTaskBlockRequest(cmd, input, cliNow(deps.now))
1435 if err != nil {
1436 return err
1437 }
1438 if request.RunID != "" && !input.AsAgent {
1439 return errors.New("cli: --run-id requires --as-agent so the active lease can be resolved")
1440 }
1441 client, err := clientFromDeps(deps)
1442 if err != nil {
1443 return err
1444 }
1445 var block TaskBlockRecord
1446 if input.AsAgent {
1447 credentials, credErr := requireAgentCommandIdentity(
1448 cmd.Context(),
1449 deps,
1450 client,
1451 agentActionCLI("task.block"),
1452 )
1453 if credErr != nil {
1454 return credErr
1455 }
1456 block, err = client.BlockTaskAsAgent(cmd.Context(), args[0], request, credentials)
1457 } else {
1458 block, err = client.BlockTask(cmd.Context(), args[0], request)
1459 }
1460 if err != nil {
1461 return err
1462 }
1463 return writeCommandOutput(cmd, taskBlockBundle(block))
1464 },
1465 }
1466 cmd.Flags().StringVar(&input.KindRaw, taskKindKey, "", "Block kind: needs_input, capability, or transient")
1467 cmd.Flags().StringVar(&input.Reason, taskReasonKey, "", "Block reason")
1468 cmd.Flags().StringVar(&input.DetailsRaw, "details", "", "Optional block details JSON")
1469 cmd.Flags().StringVar(&input.ExpiresIn, "expires-in", "", "Optional transient block duration")
1470 cmd.Flags().StringVar(&input.RunID, "run-id", "", "Active run ID to park when blocking")
1471 cmd.Flags().BoolVar(&input.AsAgent, "as-agent", false, "Block using the current AGH-managed agent session identity")
1472 mustMarkFlagRequired(cmd, taskKindKey)
1473 mustMarkFlagRequired(cmd, taskReasonKey)
1474 return cmd
1475}
1476
1477func newTaskUnblockCommand(deps commandDeps) *cobra.Command {
1478 var blockID string

Callers 1

newTaskCommandFunction · 0.85

Calls 11

exactOneNonBlankArgFunction · 0.85
buildTaskBlockRequestFunction · 0.85
cliNowFunction · 0.85
clientFromDepsFunction · 0.85
agentActionCLIFunction · 0.85
writeCommandOutputFunction · 0.85
taskBlockBundleFunction · 0.85
mustMarkFlagRequiredFunction · 0.85
BlockTaskAsAgentMethod · 0.65
BlockTaskMethod · 0.65

Tested by

no test coverage detected