agent-window 1.2.0 → 1.2.3

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/cli.js CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * AgentBridge - Command Line Interface
4
+ * AgentWindow - Command Line Interface
5
5
  *
6
- * Bridge AI coding agents to chat platforms
6
+ * A window to interact with AI agents through chat interfaces
7
7
  *
8
8
  * Usage:
9
- * agent-bridge setup - Interactive setup wizard
10
- * agent-bridge start - Start the bridge
11
- * agent-bridge stop - Stop the bridge
12
- * agent-bridge restart - Restart the bridge
13
- * agent-bridge status - Check status
14
- * agent-bridge logs - View logs
15
- * agent-bridge update - Update to latest version
16
- * agent-bridge config - Show config location
9
+ * agent-window setup - Interactive setup wizard
10
+ * agent-window start - Start the service
11
+ * agent-window stop - Stop the service
12
+ * agent-window restart - Restart the service
13
+ * agent-window status - Check status
14
+ * agent-window logs - View logs
15
+ * agent-window update - Update to latest version
16
+ * agent-window config - Show config location
17
17
  */
18
18
 
19
19
  import { spawn, execSync } from 'child_process';
@@ -27,7 +27,7 @@ const PROJECT_ROOT = join(__dirname, '..');
27
27
  const CONFIG_DIR = join(PROJECT_ROOT, 'config');
28
28
  const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
29
29
  const CONFIG_EXAMPLE = join(CONFIG_DIR, 'config.example.json');
30
- const PM2_NAME = 'agent-bridge';
30
+ const PM2_NAME = 'agent-window';
31
31
 
32
32
  // Colors for terminal output
33
33
  const colors = {
@@ -182,7 +182,7 @@ async function verifyDiscordToken(token) {
182
182
  function testDockerMount(testPath) {
183
183
  log('\n🔍 Testing Docker file sharing...', colors.cyan);
184
184
  try {
185
- const testContainer = 'agent-bridge-mount-test';
185
+ const testContainer = 'agent-window-mount-test';
186
186
  // Remove any old test container
187
187
  execSync(`docker rm -f ${testContainer} 2>/dev/null`, { stdio: 'ignore' });
188
188
 
@@ -203,7 +203,7 @@ function testDockerMount(testPath) {
203
203
  log(`3. Add: ${testPath}`);
204
204
  log('4. Click "Apply & Restart"');
205
205
  log('\nAlternative: Install to user directory instead of global:');
206
- log(' mkdir -p ~/agent-bridge && cd ~/agent-bridge && npm install cyrus-agent-bridge\n');
206
+ log(' mkdir -p ~/agent-window && cd ~/agent-window && npm install agent-window\n');
207
207
  return false;
208
208
  }
209
209
  }
@@ -305,7 +305,7 @@ async function setup() {
305
305
  const discordValid = await verifyDiscordToken(config.BOT_TOKEN);
306
306
  if (!discordValid) {
307
307
  logError('\n❌ Setup failed: Discord configuration invalid');
308
- logInfo('Fix the issues above and run: agent-bridge setup');
308
+ logInfo('Fix the issues above and run: agent-window setup');
309
309
  process.exit(1);
310
310
  }
311
311
  }
@@ -319,7 +319,7 @@ async function setup() {
319
319
  const mountOk = testDockerMount(PROJECT_ROOT);
320
320
  if (!mountOk) {
321
321
  logError('\n❌ Setup failed: Docker file sharing not configured');
322
- logInfo('Fix the issues above and run: agent-bridge setup');
322
+ logInfo('Fix the issues above and run: agent-window setup');
323
323
  process.exit(1);
324
324
  }
325
325
 
@@ -359,13 +359,13 @@ async function setup() {
359
359
 
360
360
  log('\n✨ Setup complete!\n', colors.green + colors.bright);
361
361
  log('Start the bridge with:', colors.cyan);
362
- log(' agent-bridge start\n');
362
+ log(' agent-window start\n');
363
363
  }
364
364
 
365
365
  // Start
366
366
  function start() {
367
367
  if (!existsSync(CONFIG_FILE)) {
368
- logError('Configuration not found. Run "agent-bridge setup" first.');
368
+ logError('Configuration not found. Run "agent-window setup" first.');
369
369
  process.exit(1);
370
370
  }
371
371
 
@@ -376,7 +376,7 @@ function start() {
376
376
  stdio: 'inherit'
377
377
  });
378
378
  logSuccess('AgentBridge started');
379
- log('\nView logs: agent-bridge logs', colors.dim);
379
+ log('\nView logs: agent-window logs', colors.dim);
380
380
  } catch (e) {
381
381
  logError('Failed to start: ' + e.message);
382
382
  }
@@ -464,7 +464,7 @@ async function update() {
464
464
  logSuccess('Update complete');
465
465
  } else {
466
466
  log('Updating via npm...', colors.cyan);
467
- execSync('npm update -g agent-bridge', { stdio: 'inherit' });
467
+ execSync('npm update -g agent-window', { stdio: 'inherit' });
468
468
  logSuccess('Update complete. Please restart.');
469
469
  }
470
470
  } catch (e) {
@@ -481,7 +481,7 @@ function showConfig() {
481
481
  if (existsSync(CONFIG_FILE)) {
482
482
  logSuccess('Config exists');
483
483
  } else {
484
- logWarning('Config not found. Run "agent-bridge setup"');
484
+ logWarning('Config not found. Run "agent-window setup"');
485
485
  }
486
486
  }
487
487
 
@@ -496,20 +496,20 @@ async function initBotsDir() {
496
496
  const botsDir = await prompt('Bots directory (press Enter for default): ') || defaultBotsDir;
497
497
 
498
498
  // Create directory structure
499
- const botTypesDir = join(botsDir, 'agent-bridge@latest');
499
+ const botTypesDir = join(botsDir, 'agent-window@latest');
500
500
  try {
501
501
  execSync(`mkdir -p "${botTypesDir}"`, { stdio: 'inherit' });
502
502
  } catch {
503
503
  // Directory already exists or was created
504
504
  }
505
505
 
506
- // Create symlink to global agent-bridge
507
- const globalAgentBridge = '/opt/homebrew/lib/node_modules/agent-bridge';
508
- if (existsSync(globalAgentBridge)) {
509
- const linkPath = join(botsDir, 'agent-bridge');
506
+ // Create symlink to global agent-window
507
+ const globalAgentWindow = '/opt/homebrew/lib/node_modules/agent-window';
508
+ if (existsSync(globalAgentWindow)) {
509
+ const linkPath = join(botsDir, 'agent-window');
510
510
  try {
511
- execSync(`ln -sf "${globalAgentBridge}" "${linkPath}"`, { stdio: 'inherit' });
512
- logSuccess('Linked to global agent-bridge installation');
511
+ execSync(`ln -sf "${globalAgentWindow}" "${linkPath}"`, { stdio: 'inherit' });
512
+ logSuccess('Linked to global agent-window installation');
513
513
  } catch {
514
514
  logWarning('Could not create symlink (may already exist)');
515
515
  }
@@ -519,12 +519,12 @@ async function initBotsDir() {
519
519
  const ecosystemFile = join(botsDir, 'ecosystem.config.cjs');
520
520
  if (!existsSync(ecosystemFile)) {
521
521
  const ecosystemTemplate = `/**
522
- * AgentBridge - Multi-Bot Management
522
+ * AgentWindow - Multi-Bot Management
523
523
  *
524
- * Add new bots with: agent-bridge add-bot <name>
524
+ * Add new bots with: agent-window add-bot <name>
525
525
  */
526
526
 
527
- const AGENT_BRIDGE = '${globalAgentBridge}';
527
+ const AGENT_WINDOW = '${globalAgentWindow}';
528
528
  const BOTS_DIR = '${botsDir}';
529
529
 
530
530
  module.exports = {
@@ -551,7 +551,7 @@ module.exports = {
551
551
  log('\n✨ Multi-bot directory initialized!\n', colors.green + colors.bright);
552
552
  log('Next steps:', colors.cyan);
553
553
  log(` cd ${botsDir}`);
554
- log(' agent-bridge add-bot <name> # Add a new bot');
554
+ log(' agent-window add-bot <name> # Add a new bot');
555
555
  log(' pm2 start ecosystem.config.cjs # Start all bots\n');
556
556
  }
557
557
 
@@ -559,8 +559,8 @@ module.exports = {
559
559
  async function addBot() {
560
560
  const botName = process.argv[3];
561
561
  if (!botName) {
562
- logError('Usage: agent-bridge add-bot <name>');
563
- logInfo('Example: agent-bridge add-bot myproject');
562
+ logError('Usage: agent-window add-bot <name>');
563
+ logInfo('Example: agent-window add-bot myproject');
564
564
  process.exit(1);
565
565
  }
566
566
 
@@ -570,7 +570,7 @@ async function addBot() {
570
570
 
571
571
  if (!botsDir || !existsSync(join(botsDir, 'ecosystem.config.cjs'))) {
572
572
  logError('Bots directory not initialized.');
573
- logInfo('Run: agent-bridge init');
573
+ logInfo('Run: agent-window init');
574
574
  process.exit(1);
575
575
  }
576
576
 
@@ -631,8 +631,8 @@ async function addBot() {
631
631
  const newApp = `,
632
632
  {
633
633
  name: 'bot-` + botName + `',
634
- script: process.env.GLOBAL_AGENT_BRIDGE || '/opt/homebrew/lib/node_modules/agent-bridge/src/bot.js',
635
- cwd: process.env.GLOBAL_AGENT_BRIDGE ? process.env.GLOBAL_AGENT_BRIDGE : '/opt/homebrew/lib/node_modules/agent-bridge',
634
+ script: process.env.GLOBAL_AGENT_WINDOW || '/opt/homebrew/lib/node_modules/agent-window/src/bot.js',
635
+ cwd: process.env.GLOBAL_AGENT_WINDOW ? process.env.GLOBAL_AGENT_WINDOW : '/opt/homebrew/lib/node_modules/agent-window',
636
636
  env: {
637
637
  CONFIG_PATH: '` + botsDir + '/' + botName + `/config.json'
638
638
  },
@@ -704,13 +704,13 @@ async function ui() {
704
704
  function showHelp() {
705
705
  showBanner();
706
706
  log(`${colors.cyan}Usage:${colors.reset}
707
- agent-bridge <command>
707
+ agent-window <command>
708
708
 
709
709
  ${colors.cyan}Single-Bot Commands:${colors.reset}
710
710
  setup Interactive setup wizard
711
- start Start the bridge
712
- stop Stop the bridge
713
- restart Restart the bridge
711
+ start Start the service
712
+ stop Stop the service
713
+ restart Restart the service
714
714
  status Show status
715
715
  logs View logs (live)
716
716
  update Update to latest version
@@ -727,14 +727,14 @@ ${colors.cyan}General:${colors.reset}
727
727
  help Show this help
728
728
 
729
729
  ${colors.cyan}Examples:${colors.reset}
730
- agent-bridge setup ${colors.dim}# First time setup${colors.reset}
731
- agent-bridge init ${colors.dim}# Initialize ~/bots directory${colors.reset}
732
- agent-bridge add-bot myproject ${colors.dim}# Add a new bot${colors.reset}
733
- agent-bridge ui ${colors.dim}# Launch web UI${colors.reset}
730
+ agent-window setup ${colors.dim}# First time setup${colors.reset}
731
+ agent-window init ${colors.dim}# Initialize ~/bots directory${colors.reset}
732
+ agent-window add-bot myproject ${colors.dim}# Add a new bot${colors.reset}
733
+ agent-window ui ${colors.dim}# Launch web UI${colors.reset}
734
734
  pm2 start ~/bots/ecosystem.config.cjs ${colors.dim}# Start all bots${colors.reset}
735
735
 
736
736
  ${colors.cyan}Documentation:${colors.reset}
737
- https://github.com/YOUR_USERNAME/AgentBridge
737
+ https://github.com/Observer-GGboy/AgentWindow
738
738
  `);
739
739
  }
740
740
 
@@ -0,0 +1,12 @@
1
+ {
2
+ "BOT_TOKEN": "MTQ2MjczODE4MDc4NzY2Njk3Nw.GZYfmO.z1yzHmhHZbbg0sy-oJDDyNxSpedsXVI1BpifOY",
3
+ "CLAUDE_CODE_OAUTH_TOKEN": "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",
4
+ "PROJECT_DIR": "/Users/cyrus/Documents/project/cognitive-prototype/interactive-prototype-cognitiveOS",
5
+ "ALLOWED_CHANNELS": "1462723721188868096",
6
+ "_comment_workspace": "工作空间配置(v1.0.9+ 新标准)",
7
+ "workspace": {
8
+ "containerName": "claude-sandbox",
9
+ "dockerImage": "claude-sandbox:latest",
10
+ "portMappings": []
11
+ }
12
+ }
@@ -1,4 +1,4 @@
1
- # AgentBridge - Docker Compose
1
+ # AgentWindow - Docker Compose
2
2
  #
3
3
  # Usage:
4
4
  # docker-compose up -d # Start in background
@@ -8,11 +8,11 @@
8
8
  version: '3.8'
9
9
 
10
10
  services:
11
- agent-bridge:
11
+ agent-window:
12
12
  build:
13
13
  context: .
14
14
  dockerfile: Dockerfile
15
- container_name: agent-bridge
15
+ container_name: agent-window
16
16
  restart: unless-stopped
17
17
  volumes:
18
18
  - ./config/config.json:/app/config/config.json:ro
@@ -24,8 +24,8 @@ services:
24
24
  environment:
25
25
  - NODE_ENV=production
26
26
  networks:
27
- - agent-bridge-network
27
+ - agent-window-network
28
28
 
29
29
  networks:
30
- agent-bridge-network:
30
+ agent-window-network:
31
31
  driver: bridge
@@ -1,14 +1,14 @@
1
1
  /**
2
- * PM2 Ecosystem Configuration for AgentBridge
2
+ * PM2 Ecosystem Configuration for AgentWindow
3
3
  *
4
4
  * Start: pm2 start ecosystem.config.cjs
5
- * Stop: pm2 stop agent-bridge
6
- * Logs: pm2 logs agent-bridge
5
+ * Stop: pm2 stop agent-window
6
+ * Logs: pm2 logs agent-window
7
7
  */
8
8
 
9
9
  module.exports = {
10
10
  apps: [{
11
- name: 'agent-bridge',
11
+ name: 'agent-window',
12
12
  script: 'src/bot.js',
13
13
  watch: false,
14
14
  autorestart: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-window",
3
- "version": "1.2.0",
3
+ "version": "1.2.3",
4
4
  "description": "A window to interact with AI agents through chat interfaces. Simplified interaction, powerful backend capabilities.",
5
5
  "type": "module",
6
6
  "main": "src/bot.js",
@@ -0,0 +1,136 @@
1
+ #!/bin/bash
2
+
3
+ echo "=== AgentWindow 实例类型显示问题 - 最终验证测试 ==="
4
+ echo ""
5
+
6
+ # 颜色定义
7
+ GREEN='\033[0;32m'
8
+ RED='\033[0;31m'
9
+ YELLOW='\033[1;33m'
10
+ NC='\033[0m' # No Color
11
+
12
+ # 测试计数
13
+ TOTAL=0
14
+ PASSED=0
15
+ FAILED=0
16
+
17
+ # 测试函数
18
+ test_case() {
19
+ local name="$1"
20
+ local command="$2"
21
+ local expected="$3"
22
+
23
+ TOTAL=$((TOTAL + 1))
24
+ echo -n "测试 $TOTAL: $name ... "
25
+
26
+ result=$(eval "$command" 2>/dev/null)
27
+
28
+ if echo "$result" | grep -q "$expected"; then
29
+ echo -e "${GREEN}✓ 通过${NC}"
30
+ PASSED=$((PASSED + 1))
31
+ return 0
32
+ else
33
+ echo -e "${RED}✗ 失败${NC}"
34
+ echo " 期望: $expected"
35
+ echo " 实际: $result"
36
+ FAILED=$((FAILED + 1))
37
+ return 1
38
+ fi
39
+ }
40
+
41
+ echo "1. 测试实例类型检测"
42
+ echo "-------------------"
43
+
44
+ test_case \
45
+ "agentbridge 实例类型" \
46
+ "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"agentbridge\") | .instanceType'" \
47
+ "bmad-plugin"
48
+
49
+ test_case \
50
+ "cognitive 实例类型" \
51
+ "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"cognitive\") | .instanceType'" \
52
+ "bmad-plugin"
53
+
54
+ test_case \
55
+ "corp 实例类型" \
56
+ "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"corp\") | .instanceType'" \
57
+ "bmad-plugin"
58
+
59
+ echo ""
60
+ echo "2. 测试实例数据完整性"
61
+ echo "---------------------"
62
+
63
+ test_case \
64
+ "agentbridge 有 projectPath" \
65
+ "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"agentbridge\") | .projectPath'" \
66
+ "cognitive-prototype"
67
+
68
+ test_case \
69
+ "cognitive 有 projectPath" \
70
+ "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"cognitive\") | .projectPath'" \
71
+ "cognitive-prototype"
72
+
73
+ test_case \
74
+ "corp 有 projectPath" \
75
+ "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"corp\") | .projectPath'" \
76
+ "corp-office"
77
+
78
+ echo ""
79
+ echo "3. 测试 API 响应结构"
80
+ echo "-------------------"
81
+
82
+ test_case \
83
+ "API 返回 instanceType 字段" \
84
+ "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[0] | keys[]' | grep instanceType" \
85
+ "instanceType"
86
+
87
+ test_case \
88
+ "API 返回 botName 字段" \
89
+ "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[0] | keys[]' | grep botName" \
90
+ "botName"
91
+
92
+ test_case \
93
+ "API 返回 configPath 字段" \
94
+ "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[0] | keys[]' | grep configPath" \
95
+ "configPath"
96
+
97
+ echo ""
98
+ echo "4. 验证 instances.json 文件"
99
+ echo "-------------------------"
100
+
101
+ test_case \
102
+ "instances.json 存在" \
103
+ "test -f ~/.agent-window/instances.json && echo 'exists'" \
104
+ "exists"
105
+
106
+ test_case \
107
+ "instances.json 包含 3 个实例" \
108
+ "cat ~/.agent-window/instances.json | jq '.instances | length'" \
109
+ "3"
110
+
111
+ test_case \
112
+ "所有实例都有 instanceType" \
113
+ "cat ~/.agent-window/instances.json | jq -r '.instances[].instanceType' | sort -u" \
114
+ "bmad-plugin"
115
+
116
+ echo ""
117
+ echo "=== 测试总结 ==="
118
+ echo "----------------"
119
+ echo "总测试数: $TOTAL"
120
+ echo -e "通过: ${GREEN}$PASSED${NC}"
121
+ echo -e "失败: ${RED}$FAILED${NC}"
122
+
123
+ if [ $FAILED -eq 0 ]; then
124
+ echo ""
125
+ echo -e "${GREEN}✓ 所有测试通过!实例类型显示问题已完全修复。${NC}"
126
+ echo ""
127
+ echo "前端预期显示:"
128
+ echo " - agentbridge: BMAD 插件 (绿色)"
129
+ echo " - cognitive: BMAD 插件 (绿色)"
130
+ echo " - corp: BMAD 插件 (绿色)"
131
+ exit 0
132
+ else
133
+ echo ""
134
+ echo -e "${RED}✗ 有 $FAILED 个测试失败,请检查修复。${NC}"
135
+ exit 1
136
+ fi