sam-coder-cli 1.0.39 ā 1.0.41
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.
- package/bin/ai-team.js +16 -1
- package/bin/multiplayer-client.js +3 -4
- package/package.json +1 -1
package/bin/ai-team.js
CHANGED
|
@@ -5,6 +5,9 @@ const readline = require('readline');
|
|
|
5
5
|
const chalk = require('chalk');
|
|
6
6
|
const { v4: uuidv4 } = require('uuid');
|
|
7
7
|
|
|
8
|
+
// Flag to track if MultiplayerClient is being required to prevent infinite loops
|
|
9
|
+
let isRequiringMultiplayerClient = false;
|
|
10
|
+
|
|
8
11
|
// Lazy load dependencies to avoid circular dependencies
|
|
9
12
|
function getCallOpenRouter() {
|
|
10
13
|
if (!callOpenRouter) {
|
|
@@ -14,8 +17,17 @@ function getCallOpenRouter() {
|
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
function getMultiplayerClient() {
|
|
20
|
+
if (!MultiplayerClient && !isRequiringMultiplayerClient) {
|
|
21
|
+
try {
|
|
22
|
+
isRequiringMultiplayerClient = true;
|
|
23
|
+
const mc = require('./multiplayer-client');
|
|
24
|
+
MultiplayerClient = mc.MultiplayerClient;
|
|
25
|
+
} finally {
|
|
26
|
+
isRequiringMultiplayerClient = false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
17
29
|
if (!MultiplayerClient) {
|
|
18
|
-
|
|
30
|
+
throw new Error('Failed to load MultiplayerClient');
|
|
19
31
|
}
|
|
20
32
|
return MultiplayerClient;
|
|
21
33
|
}
|
|
@@ -39,6 +51,7 @@ Respond in markdown format with clear sections for each part of your response.`;
|
|
|
39
51
|
|
|
40
52
|
class AITeam {
|
|
41
53
|
constructor(options = {}) {
|
|
54
|
+
const MultiplayerClient = getMultiplayerClient();
|
|
42
55
|
this.client = new MultiplayerClient({
|
|
43
56
|
name: options.name || `Agent-${uuidv4().substr(0, 4)}`,
|
|
44
57
|
role: options.role || 'DEVELOPER',
|
|
@@ -141,6 +154,7 @@ class AITeam {
|
|
|
141
154
|
this.conversation.push({ role: 'user', content: input });
|
|
142
155
|
|
|
143
156
|
// Get AI response
|
|
157
|
+
const callOpenRouter = getCallOpenRouter();
|
|
144
158
|
const response = await callOpenRouter(this.conversation, this.client.model);
|
|
145
159
|
const aiMessage = response.choices[0].message;
|
|
146
160
|
|
|
@@ -187,6 +201,7 @@ class AITeam {
|
|
|
187
201
|
console.log(chalk.blue(`\nš Task received: ${task.description}`));
|
|
188
202
|
|
|
189
203
|
// Process the task using the AGI-CLI's tool calling system
|
|
204
|
+
const callOpenRouter = getCallOpenRouter();
|
|
190
205
|
const response = await callOpenRouter([
|
|
191
206
|
{ role: 'system', content: `You are an AI assistant working on a task: ${task.description}` },
|
|
192
207
|
{ role: 'user', content: 'Please complete this task step by step.' }
|
|
@@ -891,7 +891,6 @@ class MultiplayerClient extends EventEmitter {
|
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
893
|
|
|
894
|
-
module.exports
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
};
|
|
894
|
+
// Export MultiplayerClient and MultiplayerServer as direct properties of module.exports
|
|
895
|
+
module.exports.MultiplayerClient = MultiplayerClient;
|
|
896
|
+
module.exports.MultiplayerServer = MultiplayerServer;
|