sam-coder-cli 1.0.19 → 1.0.21
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/multiplayer-client.js +33 -6
- package/bin/multiplayer-mode.js +4 -1
- package/package.json +1 -1
|
@@ -651,12 +651,39 @@ class MultiplayerClient extends EventEmitter {
|
|
|
651
651
|
return client ? (client.name || client.clientInfo?.name || 'Unknown') : 'Unknown';
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
654
|
+
createSession() {
|
|
655
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
656
|
+
throw new Error('Not connected to server');
|
|
657
|
+
}
|
|
658
|
+
this.sessionId = uuidv4();
|
|
659
|
+
this.isHost = true;
|
|
660
|
+
this.send({
|
|
661
|
+
type: 'create_session',
|
|
662
|
+
sessionId: this.sessionId,
|
|
663
|
+
clientInfo: {
|
|
664
|
+
name: this.name,
|
|
665
|
+
role: this.role,
|
|
666
|
+
model: this.model
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
return this.sessionId;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
joinSession(sessionId) {
|
|
673
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
674
|
+
throw new Error('Not connected to server');
|
|
675
|
+
}
|
|
676
|
+
this.sessionId = sessionId;
|
|
677
|
+
this.isHost = false;
|
|
678
|
+
this.send({
|
|
679
|
+
type: 'join_session',
|
|
680
|
+
sessionId: this.sessionId,
|
|
681
|
+
clientInfo: {
|
|
682
|
+
name: this.name,
|
|
683
|
+
role: this.role,
|
|
684
|
+
model: this.model
|
|
685
|
+
}
|
|
686
|
+
});
|
|
660
687
|
}
|
|
661
688
|
}
|
|
662
689
|
|
package/bin/multiplayer-mode.js
CHANGED
|
@@ -2,6 +2,7 @@ const MultiplayerClient = require('./multiplayer-client');
|
|
|
2
2
|
const readline = require('readline');
|
|
3
3
|
const chalk = require('chalk');
|
|
4
4
|
const { v4: uuidv4 } = require('uuid');
|
|
5
|
+
const ui = require('./ui');
|
|
5
6
|
|
|
6
7
|
class MultiplayerMode {
|
|
7
8
|
constructor(options = {}) {
|
|
@@ -40,6 +41,7 @@ class MultiplayerMode {
|
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
this.client.on('session_joined', (data) => {
|
|
44
|
+
ui.showHeader();
|
|
43
45
|
console.log(chalk.green(`\nJoined session: ${data.sessionId}`));
|
|
44
46
|
console.log(chalk.blue(`You are: ${this.client.agentName}`));
|
|
45
47
|
console.log(chalk.blue(`Model: ${this.client.model}`));
|
|
@@ -87,7 +89,8 @@ class MultiplayerMode {
|
|
|
87
89
|
|
|
88
90
|
async start() {
|
|
89
91
|
console.clear();
|
|
90
|
-
|
|
92
|
+
ui.showHeader();
|
|
93
|
+
console.log(chalk.blue.bold('=== Multiplayer Mode ==='));
|
|
91
94
|
|
|
92
95
|
// Set agent name
|
|
93
96
|
this.client.name = await this.askQuestion('Enter your name (or press Enter for a random one): ') ||
|