debug-session.mjs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { createOpencodeClient } from '@opencode-ai/sdk';
  2. import { SessionReader } from './dist/collector/session-reader.js';
  3. import { TimelineBuilder } from './dist/collector/timeline-builder.js';
  4. const client = createOpencodeClient({
  5. baseUrl: 'http://localhost:3721'
  6. });
  7. const sessionId = 'ses_54285cf4effeB8lTpo4r5v3swc';
  8. const reader = new SessionReader(client);
  9. const builder = new TimelineBuilder(reader);
  10. console.log('Building timeline...\n');
  11. const timeline = await builder.buildTimeline(sessionId);
  12. console.log(`Timeline events: ${timeline.length}\n`);
  13. // Show event types
  14. const eventTypes = {};
  15. timeline.forEach(e => {
  16. eventTypes[e.type] = (eventTypes[e.type] || 0) + 1;
  17. });
  18. console.log('Event types:');
  19. Object.entries(eventTypes).forEach(([type, count]) => {
  20. console.log(` ${type}: ${count}`);
  21. });
  22. // Show tool calls
  23. const toolCalls = timeline.filter(e => e.type === 'tool_call');
  24. console.log(`\nTool calls: ${toolCalls.length}`);
  25. toolCalls.forEach((tc, i) => {
  26. console.log(` ${i + 1}. ${tc.data.tool} - ${tc.data.state}`);
  27. });