@metatell/bot-cli 0.0.5 → 0.0.7
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/README.md +112 -34
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +19 -13
- package/dist/commands/connect.js +31 -86
- package/dist/commands/inspect.js +51 -108
- package/dist/commands/interactive.js +105 -185
- package/dist/index.js +3 -9
- package/dist/types.js +1 -2
- package/dist/utils/commands.d.ts.map +1 -1
- package/dist/utils/commands.js +216 -347
- package/dist/utils/url.js +13 -17
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -1,63 +1,141 @@
|
|
|
1
|
-
# @metatell/cli
|
|
1
|
+
# @metatell/bot-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MetaTell Bot 開発とテスト用の CLI ツール。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 必要要件
|
|
6
|
+
|
|
7
|
+
- Node.js 20 以上(推奨: 22+)
|
|
8
|
+
|
|
9
|
+
## インストール
|
|
6
10
|
|
|
7
11
|
```bash
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
# グローバルインストール
|
|
13
|
+
npm install -g @metatell/bot-cli
|
|
14
|
+
|
|
15
|
+
# または npx で実行
|
|
16
|
+
npx @metatell/bot-cli <command>
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
# または開発依存として
|
|
19
|
+
npm install --save-dev @metatell/bot-cli
|
|
20
|
+
```
|
|
12
21
|
|
|
13
|
-
|
|
22
|
+
## 使い方
|
|
14
23
|
|
|
15
24
|
```bash
|
|
16
|
-
#
|
|
25
|
+
# インタラクティブモード(デフォルト)
|
|
17
26
|
metatell-cli https://metatell.app/ROOM_ID
|
|
18
27
|
|
|
19
|
-
#
|
|
28
|
+
# 認証トークン付き
|
|
20
29
|
metatell-cli https://metatell.app/ROOM_ID -t "your-auth-token"
|
|
30
|
+
|
|
31
|
+
# カスタムボット名
|
|
32
|
+
metatell-cli https://metatell.app/ROOM_ID -n "MyBot"
|
|
33
|
+
|
|
34
|
+
# デバッグログ有効
|
|
35
|
+
metatell-cli https://metatell.app/ROOM_ID -d
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## コマンド
|
|
39
|
+
|
|
40
|
+
### インタラクティブモード
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
metatell-cli https://metatell.app/ROOM_ID [options]
|
|
44
|
+
# または
|
|
45
|
+
metatell-cli interactive https://metatell.app/ROOM_ID [options]
|
|
21
46
|
```
|
|
22
47
|
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
48
|
+
**利用可能なコマンド:**
|
|
49
|
+
- `/say <message>` — チャットメッセージ送信
|
|
50
|
+
- `/move <x> <y> <z>` — アバター移動
|
|
51
|
+
- `/look <x> <y> <z>` または `/look @<username>` — 指定座標/ユーザーを見る
|
|
52
|
+
- `/nearby [radius]` — 近傍ユーザーを表示(既定 10m)
|
|
53
|
+
- `/users` — ルーム内の全ユーザーを表示
|
|
54
|
+
- `/status` — 接続状態を表示
|
|
55
|
+
- `/info` — ボット情報を表示
|
|
56
|
+
- `/avatar <id>` — アバターを変更
|
|
57
|
+
- `/assets` — 利用可能なアバター一覧
|
|
58
|
+
- `/anime <name>` または `/animation <name>` — アニメーション再生
|
|
59
|
+
- `/animations` — 利用可能なアニメーション一覧
|
|
60
|
+
- `/stop` — アニメーション停止(アイドルに戻す)
|
|
61
|
+
- `quit` / `exit` — 終了
|
|
62
|
+
|
|
63
|
+
### 接続テストコマンド
|
|
27
64
|
|
|
28
|
-
|
|
65
|
+
```bash
|
|
66
|
+
metatell-cli connect https://metatell.app/ROOM_ID [options]
|
|
67
|
+
```
|
|
29
68
|
|
|
30
|
-
|
|
69
|
+
### ルーム検査コマンド
|
|
31
70
|
|
|
32
71
|
```bash
|
|
33
|
-
|
|
34
|
-
metatell-cli connect https://metatell.app/ROOM_ID
|
|
72
|
+
metatell-cli inspect https://metatell.app/ROOM_ID [options]
|
|
35
73
|
```
|
|
36
74
|
|
|
37
|
-
|
|
75
|
+
## オプション
|
|
76
|
+
|
|
77
|
+
| オプション | エイリアス | 説明 | デフォルト |
|
|
78
|
+
|--------|-------|-------------|---------|
|
|
79
|
+
| `--token` | `-t` | 認証トークン(任意) | `METATELL_TOKEN` 環境変数 |
|
|
80
|
+
| `--name` | `-n` | ボット表示名 | "MetatellCLI" |
|
|
81
|
+
| `--debug` | `-d` | デバッグログ有効 | false |
|
|
82
|
+
|
|
83
|
+
## 環境変数
|
|
38
84
|
|
|
39
|
-
|
|
85
|
+
- `METATELL_TOKEN` — デフォルト認証トークン(任意)
|
|
86
|
+
|
|
87
|
+
## 開発
|
|
88
|
+
|
|
89
|
+
### ローカル開発環境のセットアップ
|
|
90
|
+
|
|
91
|
+
CLIをローカルで開発・テストする場合の手順:
|
|
40
92
|
|
|
41
93
|
```bash
|
|
42
|
-
#
|
|
43
|
-
|
|
94
|
+
# 1. リポジトリをクローン
|
|
95
|
+
git clone https://github.com/urth-inc/metatell-ai-bot.git
|
|
96
|
+
cd metatell-ai-bot
|
|
97
|
+
|
|
98
|
+
# 2. 依存関係をインストール
|
|
99
|
+
npm install
|
|
100
|
+
|
|
101
|
+
# 3. CLIパッケージへ移動
|
|
102
|
+
cd packages/cli
|
|
103
|
+
|
|
104
|
+
# 4. ビルド
|
|
105
|
+
npm run build
|
|
106
|
+
|
|
107
|
+
# 5. ローカルにリンク(グローバルコマンドとして登録)
|
|
108
|
+
npm link
|
|
109
|
+
|
|
110
|
+
# 6. 動作確認
|
|
111
|
+
metatell-cli --version
|
|
112
|
+
metatell-cli --help
|
|
44
113
|
```
|
|
45
114
|
|
|
46
|
-
###
|
|
115
|
+
### 開発時の便利なコマンド
|
|
47
116
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
117
|
+
```bash
|
|
118
|
+
# TypeScriptをウォッチモードでコンパイル
|
|
119
|
+
npm run dev
|
|
120
|
+
|
|
121
|
+
# ビルド
|
|
122
|
+
npm run build
|
|
123
|
+
|
|
124
|
+
# 型チェック
|
|
125
|
+
npm run typecheck
|
|
126
|
+
|
|
127
|
+
# テスト実行(ルートディレクトリから)
|
|
128
|
+
cd ../.. && npm test packages/cli/src/cli.spec.ts
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### アンリンク(クリーンアップ)
|
|
51
132
|
|
|
52
|
-
|
|
133
|
+
開発が終了したら、グローバルリンクを削除:
|
|
53
134
|
|
|
54
|
-
|
|
135
|
+
```bash
|
|
136
|
+
npm unlink -g @metatell/bot-cli
|
|
137
|
+
```
|
|
55
138
|
|
|
56
|
-
##
|
|
139
|
+
## License
|
|
57
140
|
|
|
58
|
-
|
|
59
|
-
- Room state inspection
|
|
60
|
-
- Interactive command-line interface
|
|
61
|
-
- User presence monitoring
|
|
62
|
-
- Message activity tracking
|
|
63
|
-
- Clean implementation using SDK facade API
|
|
141
|
+
MIT
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;GAEG"}
|
package/dist/cli.js
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
2
|
/**
|
|
4
3
|
* Metatell CLI - Interactive tool for bot development and testing
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { dirname, join } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
import { connectCommand } from './commands/connect.js';
|
|
10
|
+
import { inspectCommand } from './commands/inspect.js';
|
|
11
|
+
import { startInteractiveMode } from './commands/interactive.js';
|
|
12
|
+
// パッケージのバージョンを動的に取得
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
16
|
+
const version = packageJson.version;
|
|
17
|
+
const program = new Command();
|
|
12
18
|
program
|
|
13
19
|
.name('metatell-cli')
|
|
14
20
|
.description('CLI tool for Metatell bot development and testing')
|
|
15
|
-
.version(
|
|
21
|
+
.version(version);
|
|
16
22
|
// Connect command - Simple connection test
|
|
17
23
|
program
|
|
18
24
|
.command('connect <url>')
|
|
19
25
|
.description('Connect to a Metatell room and show basic info')
|
|
20
26
|
.option('-t, --token <token>', 'Authentication token')
|
|
21
27
|
.option('-d, --debug', 'Enable debug logging')
|
|
22
|
-
.action(
|
|
28
|
+
.action(connectCommand);
|
|
23
29
|
// Inspect command - Room inspection
|
|
24
30
|
program
|
|
25
31
|
.command('inspect <url>')
|
|
26
32
|
.description('Inspect room state and user presence')
|
|
27
33
|
.option('-t, --token <token>', 'Authentication token')
|
|
28
|
-
.action(
|
|
34
|
+
.action(inspectCommand);
|
|
29
35
|
// Interactive mode (default)
|
|
30
36
|
program
|
|
31
37
|
.command('interactive <url>')
|
|
@@ -34,14 +40,14 @@ program
|
|
|
34
40
|
.option('-t, --token <token>', 'Authentication token')
|
|
35
41
|
.option('-n, --name <name>', 'Bot display name', 'MetatellCLI')
|
|
36
42
|
.option('-d, --debug', 'Enable debug logging')
|
|
37
|
-
.action(
|
|
43
|
+
.action(startInteractiveMode);
|
|
38
44
|
// Default to interactive mode
|
|
39
45
|
program
|
|
40
46
|
.arguments('<url>')
|
|
41
47
|
.option('-t, --token <token>', 'Authentication token')
|
|
42
48
|
.option('-n, --name <name>', 'Bot display name', 'MetatellCLI')
|
|
43
49
|
.option('-d, --debug', 'Enable debug logging')
|
|
44
|
-
.action(
|
|
45
|
-
|
|
50
|
+
.action((url, options) => {
|
|
51
|
+
startInteractiveMode(url, options);
|
|
46
52
|
});
|
|
47
53
|
program.parse();
|
package/dist/commands/connect.js
CHANGED
|
@@ -1,91 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Simple connection test command
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
28
|
-
default:
|
|
29
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
30
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
31
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
32
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
33
|
-
if (t[2]) _.ops.pop();
|
|
34
|
-
_.trys.pop(); continue;
|
|
35
|
-
}
|
|
36
|
-
op = body.call(thisArg, _);
|
|
37
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
38
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.connectCommand = connectCommand;
|
|
43
|
-
var bot_sdk_1 = require("@metatell/bot-sdk");
|
|
44
|
-
var url_js_1 = require("../utils/url.js");
|
|
45
|
-
function connectCommand(url, options) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
-
var _a, serverUrl, roomId, client, users, error_1;
|
|
48
|
-
return __generator(this, function (_b) {
|
|
49
|
-
switch (_b.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
console.log('Connecting to:', url);
|
|
52
|
-
_b.label = 1;
|
|
53
|
-
case 1:
|
|
54
|
-
_b.trys.push([1, 4, , 5]);
|
|
55
|
-
_a = (0, url_js_1.parseUrl)(url), serverUrl = _a.serverUrl, roomId = _a.roomId;
|
|
56
|
-
client = (0, bot_sdk_1.createMetatellClient)({
|
|
57
|
-
serverUrl: serverUrl,
|
|
58
|
-
roomId: roomId,
|
|
59
|
-
token: options.token || process.env.METATELL_TOKEN || '',
|
|
60
|
-
username: 'MetatellCLI',
|
|
61
|
-
debug: options.debug,
|
|
62
|
-
});
|
|
63
|
-
return [4 /*yield*/, client.connect()];
|
|
64
|
-
case 2:
|
|
65
|
-
_b.sent();
|
|
66
|
-
console.log('✓ Connected successfully!');
|
|
67
|
-
console.log('Session ID:', client.getSessionId());
|
|
68
|
-
console.log('Status:', client.getStatus());
|
|
69
|
-
users = client.getUsers();
|
|
70
|
-
console.log("\nUsers in room: ".concat(users.length));
|
|
71
|
-
users.forEach(function (user) {
|
|
72
|
-
console.log("- ".concat(user.name || 'Anonymous', " (").concat(user.id, ")").concat(user.isBot ? ' [Bot]' : ''));
|
|
73
|
-
});
|
|
74
|
-
// Clean disconnect
|
|
75
|
-
return [4 /*yield*/, client.disconnect()];
|
|
76
|
-
case 3:
|
|
77
|
-
// Clean disconnect
|
|
78
|
-
_b.sent();
|
|
79
|
-
console.log('\n✓ Disconnected successfully');
|
|
80
|
-
process.exit(0);
|
|
81
|
-
return [3 /*break*/, 5];
|
|
82
|
-
case 4:
|
|
83
|
-
error_1 = _b.sent();
|
|
84
|
-
console.error('Connection failed:', error_1);
|
|
85
|
-
process.exit(1);
|
|
86
|
-
return [3 /*break*/, 5];
|
|
87
|
-
case 5: return [2 /*return*/];
|
|
88
|
-
}
|
|
4
|
+
import { createMetatellClient } from '@metatell/bot-sdk';
|
|
5
|
+
import { parseUrl } from '../utils/url.js';
|
|
6
|
+
export async function connectCommand(url, options) {
|
|
7
|
+
console.log('Connecting to:', url);
|
|
8
|
+
try {
|
|
9
|
+
const { serverUrl, roomId } = parseUrl(url);
|
|
10
|
+
const client = createMetatellClient({
|
|
11
|
+
serverUrl,
|
|
12
|
+
roomId,
|
|
13
|
+
token: options.token || process.env.METATELL_TOKEN || '',
|
|
14
|
+
username: 'MetatellCLI',
|
|
15
|
+
debug: options.debug,
|
|
16
|
+
});
|
|
17
|
+
await client.connect();
|
|
18
|
+
console.log('✓ Connected successfully!');
|
|
19
|
+
console.log('Session ID:', client.getSessionId());
|
|
20
|
+
console.log('Status:', client.getStatus());
|
|
21
|
+
// Show presence info
|
|
22
|
+
const users = client.getUsers();
|
|
23
|
+
console.log(`\nUsers in room: ${users.length}`);
|
|
24
|
+
users.forEach((user) => {
|
|
25
|
+
console.log(`- ${user.name || 'Anonymous'} (${user.id})${user.isBot ? ' [Bot]' : ''}`);
|
|
89
26
|
});
|
|
90
|
-
|
|
27
|
+
// Clean disconnect
|
|
28
|
+
await client.disconnect();
|
|
29
|
+
console.log('\n✓ Disconnected successfully');
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error('Connection failed:', error);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
91
36
|
}
|
package/dist/commands/inspect.js
CHANGED
|
@@ -1,113 +1,56 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Room inspection command
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
18
|
-
function step(op) {
|
|
19
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
20
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
21
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
22
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
23
|
-
switch (op[0]) {
|
|
24
|
-
case 0: case 1: t = op; break;
|
|
25
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
26
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
27
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
28
|
-
default:
|
|
29
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
30
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
31
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
32
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
33
|
-
if (t[2]) _.ops.pop();
|
|
34
|
-
_.trys.pop(); continue;
|
|
35
|
-
}
|
|
36
|
-
op = body.call(thisArg, _);
|
|
37
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
38
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.inspectCommand = inspectCommand;
|
|
43
|
-
var bot_sdk_1 = require("@metatell/bot-sdk");
|
|
44
|
-
var url_js_1 = require("../utils/url.js");
|
|
45
|
-
function inspectCommand(url, options) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
-
var _a, serverUrl, roomId, client, users, humans, bots, messageCount_1, joinCount_1, leaveCount_1, error_1;
|
|
48
|
-
return __generator(this, function (_b) {
|
|
49
|
-
switch (_b.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
console.log('Inspecting room:', url);
|
|
52
|
-
_b.label = 1;
|
|
53
|
-
case 1:
|
|
54
|
-
_b.trys.push([1, 5, , 6]);
|
|
55
|
-
_a = (0, url_js_1.parseUrl)(url), serverUrl = _a.serverUrl, roomId = _a.roomId;
|
|
56
|
-
client = (0, bot_sdk_1.createMetatellClient)({
|
|
57
|
-
serverUrl: serverUrl,
|
|
58
|
-
roomId: roomId,
|
|
59
|
-
token: options.token || process.env.METATELL_TOKEN || '',
|
|
60
|
-
username: 'MetatellInspector',
|
|
61
|
-
debug: false, // Keep quiet for inspection
|
|
62
|
-
});
|
|
63
|
-
return [4 /*yield*/, client.connect()];
|
|
64
|
-
case 2:
|
|
65
|
-
_b.sent();
|
|
66
|
-
console.log('\n=== Room Information ===');
|
|
67
|
-
console.log('Room ID:', roomId);
|
|
68
|
-
console.log('Server:', serverUrl);
|
|
69
|
-
console.log('Session:', client.getSessionId());
|
|
70
|
-
users = client.getUsers();
|
|
71
|
-
console.log('\n=== User Presence ===');
|
|
72
|
-
console.log("Total users: ".concat(users.length));
|
|
73
|
-
humans = users.filter(function (u) { return !u.isBot; });
|
|
74
|
-
bots = users.filter(function (u) { return u.isBot; });
|
|
75
|
-
console.log("Humans: ".concat(humans.length));
|
|
76
|
-
console.log("Bots: ".concat(bots.length));
|
|
77
|
-
if (users.length > 0) {
|
|
78
|
-
console.log('\nDetailed list:');
|
|
79
|
-
users.forEach(function (user) {
|
|
80
|
-
var type = user.isBot ? '[Bot]' : '[Human]';
|
|
81
|
-
console.log(" ".concat(type, " ").concat(user.name || 'Anonymous', " (").concat(user.id, ")"));
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
// Listen for a few seconds to detect activity
|
|
85
|
-
console.log('\n=== Monitoring Activity (5 seconds) ===');
|
|
86
|
-
messageCount_1 = 0;
|
|
87
|
-
joinCount_1 = 0;
|
|
88
|
-
leaveCount_1 = 0;
|
|
89
|
-
client.on('message', function () { return messageCount_1++; });
|
|
90
|
-
client.on('user-join', function () { return joinCount_1++; });
|
|
91
|
-
client.on('user-leave', function () { return leaveCount_1++; });
|
|
92
|
-
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 5000); })];
|
|
93
|
-
case 3:
|
|
94
|
-
_b.sent();
|
|
95
|
-
console.log("Messages: ".concat(messageCount_1));
|
|
96
|
-
console.log("Users joined: ".concat(joinCount_1));
|
|
97
|
-
console.log("Users left: ".concat(leaveCount_1));
|
|
98
|
-
return [4 /*yield*/, client.disconnect()];
|
|
99
|
-
case 4:
|
|
100
|
-
_b.sent();
|
|
101
|
-
console.log('\n✓ Inspection complete');
|
|
102
|
-
process.exit(0);
|
|
103
|
-
return [3 /*break*/, 6];
|
|
104
|
-
case 5:
|
|
105
|
-
error_1 = _b.sent();
|
|
106
|
-
console.error('Inspection failed:', error_1);
|
|
107
|
-
process.exit(1);
|
|
108
|
-
return [3 /*break*/, 6];
|
|
109
|
-
case 6: return [2 /*return*/];
|
|
110
|
-
}
|
|
4
|
+
import { createMetatellClient } from '@metatell/bot-sdk';
|
|
5
|
+
import { parseUrl } from '../utils/url.js';
|
|
6
|
+
export async function inspectCommand(url, options) {
|
|
7
|
+
console.log('Inspecting room:', url);
|
|
8
|
+
try {
|
|
9
|
+
const { serverUrl, roomId } = parseUrl(url);
|
|
10
|
+
const client = createMetatellClient({
|
|
11
|
+
serverUrl,
|
|
12
|
+
roomId,
|
|
13
|
+
token: options.token || process.env.METATELL_TOKEN || '',
|
|
14
|
+
username: 'MetatellInspector',
|
|
15
|
+
debug: false, // Keep quiet for inspection
|
|
111
16
|
});
|
|
112
|
-
|
|
17
|
+
await client.connect();
|
|
18
|
+
console.log('\n=== Room Information ===');
|
|
19
|
+
console.log('Room ID:', roomId);
|
|
20
|
+
console.log('Server:', serverUrl);
|
|
21
|
+
console.log('Session:', client.getSessionId());
|
|
22
|
+
const users = client.getUsers();
|
|
23
|
+
console.log('\n=== User Presence ===');
|
|
24
|
+
console.log(`Total users: ${users.length}`);
|
|
25
|
+
const humans = users.filter((u) => !u.isBot);
|
|
26
|
+
const bots = users.filter((u) => u.isBot);
|
|
27
|
+
console.log(`Humans: ${humans.length}`);
|
|
28
|
+
console.log(`Bots: ${bots.length}`);
|
|
29
|
+
if (users.length > 0) {
|
|
30
|
+
console.log('\nDetailed list:');
|
|
31
|
+
users.forEach((user) => {
|
|
32
|
+
const type = user.isBot ? '[Bot]' : '[Human]';
|
|
33
|
+
console.log(` ${type} ${user.name || 'Anonymous'} (${user.id})`);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Listen for a few seconds to detect activity
|
|
37
|
+
console.log('\n=== Monitoring Activity (5 seconds) ===');
|
|
38
|
+
let messageCount = 0;
|
|
39
|
+
let joinCount = 0;
|
|
40
|
+
let leaveCount = 0;
|
|
41
|
+
client.on('message', () => messageCount++);
|
|
42
|
+
client.on('user-join', () => joinCount++);
|
|
43
|
+
client.on('user-leave', () => leaveCount++);
|
|
44
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
45
|
+
console.log(`Messages: ${messageCount}`);
|
|
46
|
+
console.log(`Users joined: ${joinCount}`);
|
|
47
|
+
console.log(`Users left: ${leaveCount}`);
|
|
48
|
+
await client.disconnect();
|
|
49
|
+
console.log('\n✓ Inspection complete');
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error('Inspection failed:', error);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
113
56
|
}
|