forked from Enderfga/claw-orchestrator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-integration.ts
More file actions
66 lines (51 loc) · 2.45 KB
/
test-integration.ts
File metadata and controls
66 lines (51 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env tsx
/**
* Integration test — runs all core operations in a single process
* (simulates Plugin in-process usage)
*/
import { SessionManager } from './src/session-manager.js';
const manager = new SessionManager({ claudeBin: 'claude' });
async function test() {
console.log('=== openclaw-claude-code v2.0 Integration Test ===\n');
// 1. File operations (no session needed)
console.log('--- Test: agents-list ---');
const agents = manager.listAgents('/tmp/test-project');
console.log(` Found ${agents.length} agent(s):`, agents.map(a => a.name));
console.log('--- Test: skills-list ---');
const skills = manager.listSkills('/tmp/test-project');
console.log(` Found ${skills.length} skill(s):`, skills.map(s => s.name));
console.log('--- Test: rules-list ---');
const rules = manager.listRules('/tmp/test-project');
console.log(` Found ${rules.length} rule(s):`, rules.map(r => r.name));
// 2. Session lifecycle
console.log('\n--- Test: session-start ---');
const info = await manager.startSession({
name: 'integration-test',
cwd: process.env.HOME!,
});
console.log(` Session started: ${info.name}, Claude ID: ${info.claudeSessionId || 'pending'}`);
console.log('\n--- Test: session-list ---');
const sessions = manager.listSessions();
console.log(` Active sessions: ${sessions.length}`, sessions.map(s => s.name));
console.log('\n--- Test: session-send ---');
const result = await manager.sendMessage('integration-test', 'just reply with one word: hello');
console.log(` Response: "${result.output.trim()}"`);
console.log('\n--- Test: session-status ---');
const status = manager.getStatus('integration-test');
console.log(` Turns: ${status.stats.turns}, Tokens: ${status.stats.tokensIn}in/${status.stats.tokensOut}out, Cost: $${status.stats.costUsd}`);
console.log('\n--- Test: session-grep ---');
const matches = await manager.grepSession('integration-test', 'hello');
console.log(` Grep matches: ${matches.length}`);
console.log('\n--- Test: session-stop ---');
await manager.stopSession('integration-test');
console.log(' Session stopped.');
console.log('\n--- Test: session-list (after stop) ---');
const remaining = manager.listSessions();
console.log(` Active sessions: ${remaining.length}`);
console.log('\n=== All tests passed ===');
await manager.shutdown();
}
test().catch(err => {
console.error('TEST FAILED:', err);
manager.shutdown().then(() => process.exit(1));
});