OpenWriterControle/evals/framework/inspect-session.mjs
darrenhinde 8eb4b31ef4 feat(evals): add opencoder test suite and fix expected violation handling
- Create separate test folder for opencoder agent with 4 tests
- Update openagent tests to use multi-turn prompts for approval workflow
- Fix test runner to properly handle expectedViolations with shouldViolate: true
- Add mustUseAnyOf behavior expectation for flexible tool matching
- Add unit tests for timeline-builder and context-loading-evaluator
- Update documentation to reflect agent-specific test structure
- Remove outdated AGENT_DETECTION_STATUS.md

Opencoder tests: 4/4 passing
Key insight: openagent uses text-based approval, opencoder uses tool permissions only
2025-11-26 01:52:18 +00:00

76 lines
2.3 KiB
JavaScript

/**
* Inspect the most recent session to see what events were captured
*/
import { SessionReader } from './dist/collector/session-reader.js';
import path from 'path';
import os from 'os';
const sessionStoragePath = path.join(os.homedir(), '.local', 'share', 'opencode');
const reader = new SessionReader(undefined, sessionStoragePath);
// Get session ID from command line or use most recent
const sessionId = process.argv[2];
let mostRecent;
if (sessionId) {
console.log(`Looking for session: ${sessionId}`);
mostRecent = await reader.getSessionInfo(sessionId);
if (!mostRecent) {
console.log('Session not found!');
process.exit(1);
}
} else {
// Get the most recent session
const sessions = await reader.listSessions();
mostRecent = sessions[0];
}
console.log('='.repeat(70));
console.log('Most Recent Session Analysis');
console.log('='.repeat(70));
console.log('');
console.log('Session Info:');
console.log(' ID:', mostRecent.id);
console.log(' Title:', mostRecent.title);
console.log(' Agent:', mostRecent.agent || 'N/A');
console.log(' Directory:', mostRecent.directory);
console.log(' Created:', new Date(mostRecent.time.created).toISOString());
console.log('');
// Get messages
const messages = await reader.getMessages(mostRecent.id);
console.log(`Messages: ${messages.length}`);
console.log('');
for (let i = 0; i < messages.length; i++) {
const msg = messages[i];
console.log('-'.repeat(70));
console.log(`Message ${i + 1}:`);
console.log(' ID:', msg.id);
console.log(' Role:', msg.role);
console.log(' Agent:', msg.agent || 'N/A');
console.log(' Model:', msg.model?.modelID || 'N/A');
console.log(' Created:', new Date(msg.time.created).toISOString());
const parts = await reader.getParts(mostRecent.id, msg.id);
console.log(` Parts: ${parts.length}`);
console.log('');
for (let j = 0; j < parts.length; j++) {
const part = parts[j];
console.log(` Part ${j + 1}:`);
console.log(` Type: ${part.type}`);
if (part.type === 'text') {
const text = part.text || '';
console.log(` Text: ${text.substring(0, 200)}${text.length > 200 ? '...' : ''}`);
} else if (part.type === 'tool') {
console.log(` Tool: ${part.tool}`);
console.log(` Input: ${JSON.stringify(part.input).substring(0, 100)}...`);
}
console.log('');
}
}
console.log('='.repeat(70));