# agent/vogon: reuse one parser for the sessionInfoRaw hooks

`ff99145`→[main](/content/gh/entireio/cli/commits/main/index.html)·
  
Soph·2w ago·1 file·+19 added/-33 removed

Same fold as the other agents: SessionStart/Stop/SessionEnd shared the
payload shape and differed only in event type.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

## Sessions

65cfea8234e1View transcript

## Changes

1

- cmd/entire/cli/agent/vogon
  
  - Mhooks.go+19/-33

```
func (v *Agent) ParseHookEvent(_ context.Context, hookName string, stdin io.Reader) (*agent.Event, error) {
	switch hookName {
	case HookNameSessionStart:
		raw, err := agent.ReadAndParseHookInput[sessionInfoRaw](stdin)
		if err != nil {
			return nil, err
		}
		return &agent.Event{
			Type:       agent.SessionStart,
			SessionID:  raw.SessionID,
			SessionRef: raw.TranscriptPath,
			Model:      raw.Model,
			Timestamp:  time.Now(),
		}, nil
		return parseSessionInfoEvent(stdin, agent.SessionStart)

case HookNameUserPromptSubmit:
		raw, err := agent.ReadAndParseHookInput[userPromptSubmitRaw](stdin)

case HookNameStop:
		raw, err := agent.ReadAndParseHookInput[sessionInfoRaw](stdin)
		if err != nil {
			return nil, err
		}
		return &agent.Event{
			Type:       agent.TurnEnd,
			SessionID:  raw.SessionID,
			SessionRef: raw.TranscriptPath,
			Model:      raw.Model,
			Timestamp:  time.Now(),
		}, nil
		return parseSessionInfoEvent(stdin, agent.TurnEnd)

case HookNameSessionEnd:
		raw, err := agent.ReadAndParseHookInput[sessionInfoRaw](stdin)
		if err != nil {
			return nil, err
		}
		return &agent.Event{
			Type:       agent.SessionEnd,
			SessionID:  raw.SessionID,
			SessionRef: raw.TranscriptPath,
			Model:      raw.Model,
			Timestamp:  time.Now(),
		}, nil
		return parseSessionInfoEvent(stdin, agent.SessionEnd)

default:
		return nil, nil //nolint:nilnil // Unknown hooks have no lifecycle action
	}
}

// parseSessionInfoEvent parses the hooks whose payload is sessionInfoRaw —
// SessionStart, Stop, and SessionEnd differ only in the resulting event type.
func parseSessionInfoEvent(stdin io.Reader, eventType agent.EventType) (*agent.Event, error) {
	raw, err := agent.ReadAndParseHookInput[sessionInfoRaw](stdin)
	if err != nil {
		return nil, err
	}
	return &agent.Event{
		Type:       eventType,
		SessionID:  raw.SessionID,
		SessionRef: raw.TranscriptPath,
		Model:      raw.Model,
		Timestamp:  time.Now(),
	}, nil
}

// InstallHooks is a no-op — the vogon binary fires hooks directly.
func (v *Agent) InstallHooks(_ context.Context, _ bool, _ bool) (int, error) {
	return 0, nil
}
```
