inspect-real-session.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Inspect a real session to understand the data structure
  3. */
  4. const {
  5. createConfig,
  6. SessionReader,
  7. TimelineBuilder,
  8. MessageParser
  9. } = require('./dist');
  10. async function main() {
  11. const config = createConfig({
  12. projectPath: '/Users/darrenhinde/Documents/GitHub/opencode-agents'
  13. });
  14. const sessionReader = new SessionReader(config.projectPath, config.sessionStoragePath);
  15. const timelineBuilder = new TimelineBuilder(sessionReader);
  16. const sessions = sessionReader.listSessions();
  17. // Find session with execution tools
  18. for (const session of sessions.slice(0, 20)) {
  19. const timeline = timelineBuilder.buildTimeline(session.id);
  20. const execTools = timeline.filter(e =>
  21. e.type === 'tool_call' &&
  22. ['bash', 'write', 'edit', 'task'].includes(e.data?.tool)
  23. );
  24. if (execTools.length > 0) {
  25. console.log('Found session with execution tools:');
  26. console.log(`Session ID: ${session.id}`);
  27. console.log(`Title: ${session.title.substring(0, 60)}...`);
  28. console.log(`\nTimeline (${timeline.length} events):\n`);
  29. timeline.slice(0, 10).forEach((event, idx) => {
  30. console.log(`${idx + 1}. [${event.type}] @ ${event.timestamp}`);
  31. if (event.type === 'text') {
  32. console.log(` Text: ${(event.data?.text || '').substring(0, 80)}...`);
  33. } else if (event.type === 'tool_call') {
  34. console.log(` Tool: ${event.data?.tool}`);
  35. console.log(` Input: ${JSON.stringify(event.data?.input || {}).substring(0, 80)}...`);
  36. }
  37. });
  38. console.log('\n\nFull timeline structure (first event):');
  39. console.log(JSON.stringify(timeline[0], null, 2));
  40. break;
  41. }
  42. }
  43. }
  44. main().catch(console.error);