@sschepis/robodev 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "robodev-test",
3
+ "version": "1.0.0",
4
+ "description": "Test for robodev library",
5
+ "type": "module",
6
+ "main": "test.js",
7
+ "dependencies": {
8
+ "@sschepis/robodev": "^1.0.0"
9
+ }
10
+ }
@@ -0,0 +1,116 @@
1
+ import { AiMan } from '@sschepis/robodev';
2
+
3
+ // Mock Status Adapter
4
+ class MockStatusAdapter {
5
+ constructor() {
6
+ this.logs = [];
7
+ this.events = [];
8
+ }
9
+
10
+ log(level, message, metadata = {}) {
11
+ console.log(`[MockStatus] LOG: ${level} - ${message}`);
12
+ this.logs.push({ level, message, metadata });
13
+ }
14
+
15
+ onProgress(progress, status) {
16
+ console.log(`[MockStatus] PROGRESS: ${progress}% - ${status}`);
17
+ this.events.push({ type: 'progress', progress, status });
18
+ }
19
+
20
+ onToolStart(toolName, args) {
21
+ console.log(`[MockStatus] TOOL START: ${toolName}`);
22
+ this.events.push({ type: 'toolStart', toolName, args });
23
+ }
24
+
25
+ onToolEnd(toolName, result) {
26
+ console.log(`[MockStatus] TOOL END: ${toolName}`);
27
+ this.events.push({ type: 'toolEnd', toolName, result });
28
+ }
29
+ }
30
+
31
+ // Mock LLM Adapter
32
+ class MockLLMAdapter {
33
+ constructor() {
34
+ this.calls = [];
35
+ }
36
+
37
+ async generateContent(requestBody) {
38
+ console.log(`[MockLLM] generateContent called with model: ${requestBody.model}`);
39
+ this.calls.push(requestBody);
40
+
41
+ // Return a simple OpenAI-compatible response
42
+ return {
43
+ choices: [
44
+ {
45
+ message: {
46
+ role: 'assistant',
47
+ content: 'This is a mock response from the custom LLM adapter.'
48
+ },
49
+ finish_reason: 'stop'
50
+ }
51
+ ],
52
+ usage: {
53
+ total_tokens: 100
54
+ }
55
+ };
56
+ }
57
+
58
+ async generateContentStream(requestBody) {
59
+ console.log(`[MockLLM] generateContentStream called`);
60
+ // For this test, we might not trigger streaming, but good to have
61
+ return this.generateContent(requestBody);
62
+ }
63
+ }
64
+
65
+ async function main() {
66
+ console.log('Initializing AiMan with custom adapters...');
67
+
68
+ const mockStatus = new MockStatusAdapter();
69
+ const mockLLM = new MockLLMAdapter();
70
+
71
+ try {
72
+ const ai = new AiMan({
73
+ llmAdapter: mockLLM,
74
+ statusAdapter: mockStatus
75
+ });
76
+
77
+ console.log('AiMan initialized.');
78
+
79
+ console.log('Executing task: "Test custom adapters"');
80
+ const result = await ai.execute('Test custom adapters');
81
+
82
+ console.log('\n--- Test Results ---');
83
+ console.log('Result:', result);
84
+
85
+ // Verifications
86
+ if (result.includes('mock response')) {
87
+ console.log('SUCCESS: Custom LLM Adapter was used.');
88
+ } else {
89
+ console.error('FAILURE: Custom LLM Adapter was NOT used.');
90
+ process.exit(1);
91
+ }
92
+
93
+ if (mockStatus.logs.length > 0) {
94
+ console.log('SUCCESS: Custom Status Adapter received logs.');
95
+ } else {
96
+ console.error('FAILURE: Custom Status Adapter did NOT receive logs.');
97
+ process.exit(1);
98
+ }
99
+
100
+ // Check specifically for execution start/end logs if possible,
101
+ // though internal implementation might vary.
102
+ // AiMan.execute calls statusAdapter.onToolStart('ai_man_execute', ...)
103
+ const executeStart = mockStatus.events.find(e => e.type === 'toolStart' && e.toolName === 'ai_man_execute');
104
+ if (executeStart) {
105
+ console.log('SUCCESS: Status Adapter received ai_man_execute start event.');
106
+ } else {
107
+ console.warn('WARNING: Status Adapter did NOT receive ai_man_execute start event (implementation might have changed).');
108
+ }
109
+
110
+ } catch (error) {
111
+ console.error('Test failed with error:', error);
112
+ process.exit(1);
113
+ }
114
+ }
115
+
116
+ main();