sam-coder-cli 1.0.41 → 1.0.43

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/agi-cli.js CHANGED
@@ -3,6 +3,8 @@
3
3
  const ui = require('./ui.js');
4
4
  const readline = require('readline');
5
5
  const path = require('path');
6
+ // Import MultiplayerMode at the top level to avoid reference errors
7
+ let MultiplayerMode;
6
8
  const os = require('os');
7
9
  const fs = require('fs').promises;
8
10
  const { exec } = require('child_process');
@@ -782,15 +784,24 @@ async function start() {
782
784
 
783
785
  ui.showHeader();
784
786
 
785
- // Check for multiplayer mode flag
787
+ // Multiplayer mode via CLI flag
786
788
  if (process.argv.includes('--multiplayer')) {
787
- const multiplayerMode = new MultiplayerMode({
788
- rl,
789
- model: MODEL,
790
- serverUrl: process.env.MP_SERVER_URL || 'ws://localhost:8080'
791
- });
792
- await multiplayerMode.start();
793
- return;
789
+ // Lazy load MultiplayerMode to avoid circular dependencies
790
+ if (!MultiplayerMode) {
791
+ MultiplayerMode = require('./multiplayer-mode');
792
+ }
793
+ try {
794
+ const multiplayerMode = new MultiplayerMode({
795
+ rl,
796
+ model: MODEL,
797
+ serverUrl: process.env.MP_SERVER_URL || 'ws://localhost:8080'
798
+ });
799
+ await multiplayerMode.start();
800
+ return;
801
+ } catch (error) {
802
+ console.error('Failed to start multiplayer mode:', error);
803
+ process.exit(1);
804
+ }
794
805
  }
795
806
 
796
807
  // Standard single-agent mode
@@ -801,7 +812,10 @@ async function start() {
801
812
 
802
813
  const mode = await askForMode(rl, true);
803
814
  if (mode === 'multiplayer') {
804
- const MultiplayerMode = require('./multiplayer-mode');
815
+ // Lazy load MultiplayerMode to avoid circular dependencies
816
+ if (!MultiplayerMode) {
817
+ MultiplayerMode = require('./multiplayer-mode');
818
+ }
805
819
  try {
806
820
  const multiplayerMode = new MultiplayerMode({
807
821
  rl,
package/bin/ai-team.js CHANGED
@@ -124,13 +124,19 @@ class AITeam {
124
124
 
125
125
  if (actualSessionId) {
126
126
  console.log(`Joining session ${actualSessionId}...`);
127
- await this.client.joinSession(actualSessionId);
127
+ await this.client.joinSession(actualSessionId, false); // Don't create if not exists
128
128
  } else {
129
+ // Create a new session - this user will be the host
129
130
  console.log('Creating new session...');
130
131
  const newSessionId = await this.client.createSession();
132
+ this.client.isHost = true; // Ensure this client is marked as host
131
133
  console.log(chalk.green(`✅ Created new session: ${newSessionId}`));
134
+ console.log(chalk.yellow('You are the host of this session.'));
132
135
  console.log('Share this ID with others to collaborate!');
133
136
  console.log(chalk.yellow(`To join this session, use: ${serverId || 'localhost:8080'}:${newSessionId}`));
137
+
138
+ // Notify the user they are the host
139
+ console.log('\nAs the host, you can now enter a project prompt (e.g., "create a calculator"):');
134
140
  }
135
141
  } catch (error) {
136
142
  console.error(chalk.red('Failed to connect to server:'), error.message);
@@ -419,6 +419,11 @@ class MultiplayerClient extends EventEmitter {
419
419
  this.clients = message.clients || [];
420
420
  this.workHistory = message.workHistory || [];
421
421
 
422
+ // Update host status if this client is the host
423
+ if (message.isHost !== undefined) {
424
+ this.isHost = message.isHost;
425
+ }
426
+
422
427
  // Process any pending tasks
423
428
  if (message.pendingTasks && message.pendingTasks.length > 0) {
424
429
  message.pendingTasks.forEach(task => {
@@ -426,7 +431,11 @@ class MultiplayerClient extends EventEmitter {
426
431
  });
427
432
  }
428
433
 
429
- this.emit('session_joined', message);
434
+ // Emit session_joined with host status
435
+ this.emit('session_joined', {
436
+ ...message,
437
+ isHost: this.isHost
438
+ });
430
439
  }
431
440
 
432
441
  handleClientUpdated(data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sam-coder-cli",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "description": "SAM-CODER: An animated command-line AI assistant with agency capabilities.",
5
5
  "main": "bin/agi-cli.js",
6
6
  "bin": {