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

Function newSessionEventsCommand

internal/cli/session.go:590–639  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

588}
589
590func newSessionEventsCommand(deps commandDeps) *cobra.Command {
591 var (
592 eventType string
593 last int
594 sinceRaw string
595 follow bool
596 )
597
598 cmd := &cobra.Command{
599 Use: "events <id>",
600 Short: "Read session events",
601 Example: ` # Read the latest stored events
602 agh session events sess_1234 --last 20
603
604 # Follow new events until interrupted
605 agh session events sess_1234 --follow`,
606 Args: exactOneNonBlankArg(),
607 RunE: func(cmd *cobra.Command, args []string) error {
608 client, err := clientFromDeps(deps)
609 if err != nil {
610 return err
611 }
612
613 since, err := parseSinceFlag(sinceRaw, deps.now)
614 if err != nil {
615 return err
616 }
617 query := SessionEventQuery{
618 Type: eventType,
619 Last: last,
620 Since: since,
621 }
622
623 if follow {
624 return streamSessionEvents(cmd, client, args[0], query)
625 }
626
627 events, err := client.SessionEvents(cmd.Context(), args[0], query)
628 if err != nil {
629 return err
630 }
631 return writeSessionEventsOutput(cmd, events)
632 },
633 }
634 cmd.Flags().StringVar(&eventType, extensionTypeKey, "", "Filter by event type")
635 cmd.Flags().IntVar(&last, "last", 0, "Show only the most recent N events")
636 cmd.Flags().StringVar(&sinceRaw, "since", "", "Show events since an RFC3339 timestamp or relative duration")
637 cmd.Flags().BoolVar(&follow, "follow", false, "Stream new events over SSE")
638 return cmd
639}
640
641func streamPromptEventsJSONL(cmd *cobra.Command, client DaemonClient, id string, message string) error {
642 return client.StreamPromptSession(cmd.Context(), id, message, func(event SSEEvent) error {

Callers 1

newSessionCommandFunction · 0.85

Calls 6

exactOneNonBlankArgFunction · 0.85
clientFromDepsFunction · 0.85
parseSinceFlagFunction · 0.85
streamSessionEventsFunction · 0.85
writeSessionEventsOutputFunction · 0.85
SessionEventsMethod · 0.65

Tested by

no test coverage detected