debug-claude-session.mjs 1.2 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_542667051ffe5nQvZ31DzUo6Ux';
  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 tool calls
  14. const toolCalls = timeline.filter(e => e.type === 'tool_call');
  15. console.log(`Tool calls: ${toolCalls.length}`);
  16. toolCalls.forEach((tc, i) => {
  17. console.log(` ${i + 1}. ${tc.data.tool} - ${tc.data.state?.status || 'unknown'}`);
  18. if (tc.data.state?.input) {
  19. console.log(` Input:`, JSON.stringify(tc.data.state.input).substring(0, 100));
  20. }
  21. });
  22. // Show text parts
  23. const textParts = timeline.filter(e => e.type === 'text');
  24. console.log(`\nText parts: ${textParts.length}`);
  25. textParts.forEach((tp, i) => {
  26. const text = tp.data.text || '';
  27. console.log(` ${i + 1}. ${text.substring(0, 100)}...`);
  28. });