(deps commandDeps)
| 591 | } |
| 592 | |
| 593 | func newAgentHeartbeatStatusCommand(deps commandDeps) *cobra.Command { |
| 594 | var ( |
| 595 | sessionID string |
| 596 | includeHealth bool |
| 597 | includeEvents bool |
| 598 | ) |
| 599 | cmd := &cobra.Command{ |
| 600 | Use: "status <agent>", |
| 601 | Short: "Read Heartbeat policy status and wake eligibility", |
| 602 | Example: " agh agent heartbeat status coder --session sess_123 --workspace checkout-api --json", |
| 603 | Args: exactOneNonBlankArg(), |
| 604 | RunE: func(cmd *cobra.Command, args []string) error { |
| 605 | client, err := clientFromDeps(deps) |
| 606 | if err != nil { |
| 607 | return err |
| 608 | } |
| 609 | workspace, err := commandWorkspaceFlag(cmd) |
| 610 | if err != nil { |
| 611 | return err |
| 612 | } |
| 613 | session := strings.TrimSpace(sessionID) |
| 614 | record, err := client.GetAgentHeartbeatStatus(cmd.Context(), args[0], AgentHeartbeatStatusRequest{ |
| 615 | WorkspaceID: workspace, |
| 616 | AgentName: args[0], |
| 617 | SessionID: session, |
| 618 | IncludeSessionHealth: includeHealth || session != "", |
| 619 | IncludeRecentWakeEvents: includeEvents, |
| 620 | }) |
| 621 | if err != nil { |
| 622 | return err |
| 623 | } |
| 624 | return writeCommandOutput(cmd, agentHeartbeatStatusBundle(record)) |
| 625 | }, |
| 626 | } |
| 627 | addWorkspaceFlag(cmd) |
| 628 | cmd.Flags().StringVar(&sessionID, sessionSessionKey, "", "Session id for wake state and health") |
| 629 | cmd.Flags().BoolVar( |
| 630 | &includeHealth, |
| 631 | "include-session-health", |
| 632 | false, |
| 633 | "Include session health when a session id is supplied", |
| 634 | ) |
| 635 | cmd.Flags().BoolVar(&includeEvents, "include-wake-events", false, "Include recent wake audit rows") |
| 636 | return cmd |
| 637 | } |
| 638 | |
| 639 | func newAgentHeartbeatWakeCommand(deps commandDeps) *cobra.Command { |
| 640 | var ( |
no test coverage detected