(deps commandDeps)
| 43 | ) |
| 44 | |
| 45 | func newMeCommand(deps commandDeps) *cobra.Command { |
| 46 | cmd := &cobra.Command{ |
| 47 | Use: "me", |
| 48 | Short: "Inspect the current AGH-managed agent session", |
| 49 | Example: ` # Show the current managed session identity |
| 50 | agh me |
| 51 | |
| 52 | # Print machine-readable caller state |
| 53 | agh me -o json`, |
| 54 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 55 | client, err := clientFromDeps(deps) |
| 56 | if err != nil { |
| 57 | return err |
| 58 | } |
| 59 | credentials, err := requireAgentCommandIdentity(cmd.Context(), deps, client, agentActionCLI("me")) |
| 60 | if err != nil { |
| 61 | return err |
| 62 | } |
| 63 | record, err := client.AgentMe(cmd.Context(), credentials) |
| 64 | if err != nil { |
| 65 | return err |
| 66 | } |
| 67 | return writeCommandOutput(cmd, agentMeBundle(record)) |
| 68 | }, |
| 69 | } |
| 70 | cmd.AddCommand(newMeContextCommand(deps)) |
| 71 | return cmd |
| 72 | } |
| 73 | |
| 74 | func newMeContextCommand(deps commandDeps) *cobra.Command { |
| 75 | return &cobra.Command{ |
no test coverage detected