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

Function newSessionWaitCommand

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

Source from the content-addressed store, hash-verified

436}
437
438func newSessionWaitCommand(deps commandDeps) *cobra.Command {
439 return &cobra.Command{
440 Use: "wait <id>",
441 Short: "Block until a session stops",
442 Example: ` # Block until a session emits its stopped event
443 agh session wait sess_1234`,
444 Args: exactOneNonBlankArg(),
445 RunE: func(cmd *cobra.Command, args []string) error {
446 client, err := clientFromDeps(deps)
447 if err != nil {
448 return err
449 }
450
451 info, err := client.GetSession(cmd.Context(), args[0])
452 if err != nil {
453 return err
454 }
455 if info.State != session.StateStopped {
456 err = client.StreamSessionEvents(
457 cmd.Context(),
458 args[0],
459 SessionEventQuery{},
460 "",
461 func(event SSEEvent) error {
462 if event.Event == session.EventTypeSessionStopped {
463 return errStopSSE
464 }
465 return nil
466 },
467 )
468 if err != nil && !errors.Is(err, errStopSSE) {
469 return err
470 }
471 info, err = client.GetSession(cmd.Context(), args[0])
472 if err != nil {
473 return err
474 }
475 }
476
477 return writeCommandOutput(cmd, sessionBundle(info, deps.now))
478 },
479 }
480}
481
482func newSessionPromptCommand(deps commandDeps) *cobra.Command {
483 var (

Callers 1

newSessionCommandFunction · 0.85

Calls 7

exactOneNonBlankArgFunction · 0.85
clientFromDepsFunction · 0.85
writeCommandOutputFunction · 0.85
sessionBundleFunction · 0.85
GetSessionMethod · 0.65
StreamSessionEventsMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected