import json,pathlib,sys
# Keep native protocol evidence, omit configuration values and private workspace metadata.
root=pathlib.Path(sys.argv[1]);thread=sys.argv[2];cutoff=sys.argv[3]
for f in root.glob('events.*.log'):
 for line in f.read_text().splitlines():
  if 'NTIVE: ' not in line or line[1:25]<cutoff:continue
  try:d=json.loads(line.split('NTIVE: ',1)[1]);ev=d['event'];p=ev['payload']
  except (ValueError,KeyError):continue
  params=p.get('params',{});method=p.get('method')
  if thread not in f.name:continue
  if method in ['thread/resume','thread/start'] and ev.get('direction')=='outgoing':
   cfg=params.get('config',{});print(json.dumps({'time':line[1:25],'method':method,'mcpConfigKeys':[k for k in cfg if k.startswith('mcp_servers.')],'excludeTurns':params.get('excludeTurns')}))
  if method=='item/completed':
   item=params.get('item',{})
   if item.get('type')=='agentMessage':print(json.dumps({'time':line[1:25],'assistant':item.get('text')}))
