import json
import sys

data = []
with open('/tmp/deeplake-wiki-e8e131b0-7425-4b85-bd9d-2731c23ee475-1781739525184/session.jsonl') as f:
    for i, line in enumerate(f):
        if i >= 2210:  # start from line 2211
            try:
                data.append(json.loads(line))
            except:
                pass

# Print summary of what happened
print("=== SESSION CONTINUATION SUMMARY ===")
print(f"Total new events: {len(data)}")
print(f"Date range: {data[0]['timestamp']} to {data[-1]['timestamp']}")

# Group by type
events = {}
for item in data:
    event_type = item.get('hook_event_name', 'unknown')
    events[event_type] = events.get(event_type, 0) + 1

print("\nEvent types:")
for k, v in sorted(events.items()):
    print(f"  {k}: {v}")

# Show agent IDs
agents = set()
for item in data:
    if 'agent_id' in item:
        agents.add(item['agent_id'])

print(f"\nAgents involved: {agents}")

# Show key subagent stops
print("\nKey subagent stops:")
for item in data:
    if item.get('hook_event_name') == 'SubagentStop':
        print(f"  {item['timestamp']}: {item.get('content', '')}")

# Show last few bash commands
print("\nLast bash operations:")
for item in data[-20:]:
    if item.get('tool_name') == 'Bash':
        inp = item.get('tool_input')
        if inp and isinstance(inp, str):
            try:
                inp_obj = json.loads(inp)
                desc = inp_obj.get('description', '')
                if desc:
                    print(f"  {item['timestamp']}: {desc}")
            except:
                pass
