Documentation: - Add ARCHITECTURE.md with comprehensive system review - Add GETTING_STARTED.md for new users - Add DOCUMENTATION_CLEANUP.md tracking cleanup changes - Add SCRIPTS_ORGANIZATION.md documenting script reorganization - Remove outdated docs (TESTING_CONFIDENCE.md, TEST_REVIEW.md, SESSION_STORAGE_FIX.md) - Update README files with current information Script Organization: - Move 12 scripts from framework root to organized directories: - scripts/debug/ (4 files): Session debugging tools - scripts/test/ (6 files): Test execution scripts - scripts/utils/ (2 files): Utility scripts - Add comprehensive scripts/README.md with usage examples Test Infrastructure: - Add 5 new context loading tests for openagent - Add result-saver.ts for test result persistence - Add interactive results dashboard (index.html) - Add error-handling.test.ts for framework testing - Add result-saver.test.ts with comprehensive unit tests Evaluator Improvements: - Enhance context-loading-evaluator with better detection - Update run-sdk-tests.ts with improved result handling Agent Configuration: - Add .opencode/agent/AGENT.md for agent definition Test Utilities: - Add test-agent-manual.mjs for manual testing - Update test_tmp/README.md with usage guidelines This commit consolidates multiple improvements: - Better organization (scripts, docs) - Improved testing infrastructure - Comprehensive documentation - Cleaner codebase structure
131 lines
4 KiB
TypeScript
131 lines
4 KiB
TypeScript
#!/usr/bin/env npx tsx
|
|
/**
|
|
* Direct test: Ask agent to run ls and check if it actually executes
|
|
*/
|
|
|
|
import { createOpencodeClient } from '@opencode-ai/sdk';
|
|
|
|
const baseUrl = process.argv[2] || 'http://127.0.0.1:3000';
|
|
const agentToUse = process.argv[3] || 'opencoder';
|
|
|
|
async function test() {
|
|
console.log(`Connecting to ${baseUrl}...`);
|
|
console.log(`Using agent: ${agentToUse}`);
|
|
const client = createOpencodeClient({ baseUrl });
|
|
|
|
// Create a new session
|
|
console.log('\n1. Creating session...');
|
|
const sessionResp = await client.session.create({
|
|
body: { title: 'Direct Tool Test' }
|
|
});
|
|
const sessionId = sessionResp.data?.id;
|
|
console.log(` Session: ${sessionId}`);
|
|
|
|
if (!sessionId) {
|
|
console.log('Failed to create session');
|
|
return;
|
|
}
|
|
|
|
// Send a simple prompt using the correct API
|
|
console.log('\n2. Sending prompt: "Run ls in the current directory"');
|
|
console.log(' (prompt() should block until complete)');
|
|
|
|
const startTime = Date.now();
|
|
try {
|
|
const response = await client.session.prompt({
|
|
path: { id: sessionId },
|
|
body: {
|
|
parts: [{ type: 'text', text: 'Run ls in the current directory' }],
|
|
agent: agentToUse,
|
|
model: {
|
|
providerID: 'anthropic',
|
|
modelID: 'claude-sonnet-4-5'
|
|
}
|
|
}
|
|
});
|
|
const elapsed = Date.now() - startTime;
|
|
console.log(` Prompt completed in ${elapsed}ms`);
|
|
console.log(` Response has data: ${!!response.data}`);
|
|
|
|
// Check response directly
|
|
if (response.data) {
|
|
console.log(` Response info role: ${response.data.info?.role}`);
|
|
console.log(` Response parts: ${response.data.parts?.length || 0}`);
|
|
|
|
for (const part of response.data.parts || []) {
|
|
console.log(` - Part type: ${part.type}`);
|
|
if (part.type === 'tool') {
|
|
console.log(` Tool: ${part.tool}, Status: ${part.state?.status}`);
|
|
}
|
|
}
|
|
}
|
|
} catch (error) {
|
|
const elapsed = Date.now() - startTime;
|
|
console.log(` Error after ${elapsed}ms:`, (error as Error).message);
|
|
}
|
|
|
|
// No artificial wait - prompt() should have blocked until complete
|
|
console.log('\n3. Checking messages...');
|
|
|
|
// Get messages
|
|
console.log('\n4. Checking response...');
|
|
const messagesResp = await client.session.messages({ path: { id: sessionId } });
|
|
const messages = messagesResp.data || [];
|
|
|
|
console.log(` Total messages: ${messages.length}`);
|
|
|
|
// Check for tool usage
|
|
let toolCount = 0;
|
|
let bashOutput = '';
|
|
|
|
for (const msg of messages) {
|
|
if (msg.info?.role === 'assistant') {
|
|
for (const part of msg.parts || []) {
|
|
if (part.type === 'tool') {
|
|
toolCount++;
|
|
console.log(`\n TOOL FOUND: ${part.tool}`);
|
|
console.log(` Status: ${part.state?.status || part.status}`);
|
|
|
|
if (part.tool === 'bash') {
|
|
console.log(` Command: ${part.state?.input?.command || part.input?.command}`);
|
|
bashOutput = part.state?.output || part.output || '';
|
|
if (bashOutput) {
|
|
console.log(` Output preview: ${String(bashOutput).substring(0, 500)}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log('\n=== RESULT ===');
|
|
if (toolCount > 0) {
|
|
console.log(`✅ Agent used ${toolCount} tool(s)`);
|
|
if (bashOutput) {
|
|
console.log('✅ Got bash output - tools are working!');
|
|
}
|
|
} else {
|
|
console.log('❌ Agent did NOT use any tools');
|
|
console.log('\nAgent response (text only):');
|
|
for (const msg of messages) {
|
|
if (msg.info?.role === 'assistant') {
|
|
for (const part of msg.parts || []) {
|
|
if (part.type === 'text') {
|
|
console.log(part.text?.substring(0, 1000));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Cleanup
|
|
console.log('\n5. Cleaning up...');
|
|
try {
|
|
await client.session.delete({ path: { id: sessionId } });
|
|
console.log(' Session deleted');
|
|
} catch {
|
|
console.log(' Could not delete session');
|
|
}
|
|
}
|
|
|
|
test().catch(console.error);
|