@metatell/bot-realtime 0.0.4 → 0.0.6

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.
Files changed (2) hide show
  1. package/README.md +112 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # @metatell/bot-realtime
2
+
3
+ MetaTell Botのリアルタイム通信レイヤー。LiveKitを使用したWebRTC通信とテスト用モックアダプターを提供します。
4
+
5
+ ## 必要要件
6
+
7
+ - Node.js 20 以上(推奨: 22+)
8
+ - TypeScript 5.0+
9
+
10
+ ## インストール
11
+
12
+ ```bash
13
+ npm install @metatell/bot-realtime
14
+ # または
15
+ pnpm add @metatell/bot-realtime
16
+ # または
17
+ yarn add @metatell/bot-realtime
18
+ ```
19
+
20
+ ## 使い方
21
+
22
+ ```typescript
23
+ import { LiveKitAdapter } from '@metatell/bot-realtime';
24
+
25
+ // アダプター作成
26
+ const adapter = new LiveKitAdapter();
27
+
28
+ // イベントリスナー
29
+ adapter.on((event) => {
30
+ switch (event.type) {
31
+ case 'state':
32
+ console.log('接続状態:', event.state);
33
+ break;
34
+ case 'data':
35
+ console.log('データ受信:', event.topic, event.payload);
36
+ break;
37
+ case 'participant-joined':
38
+ console.log('ユーザー参加:', event.identity);
39
+ break;
40
+ }
41
+ });
42
+
43
+ // 接続
44
+ await adapter.connect({
45
+ url: 'wss://livekit.example.com',
46
+ tokenProvider: async () => getAccessToken(),
47
+ topics: ['control', 'events', 'transcript'],
48
+ audioPublish: {
49
+ sampleRate: 48000,
50
+ channels: 1
51
+ }
52
+ });
53
+
54
+ // データ送信
55
+ await adapter.send('control', JSON.stringify({ action: 'spawn' }));
56
+
57
+ // 音声配信
58
+ await adapter.startAudioPublisher();
59
+ await adapter.pushPcmFrame(pcmData);
60
+ ```
61
+
62
+ ## 主な機能
63
+
64
+ ### LiveKitアダプター
65
+
66
+ 本番環境用のLiveKit WebRTCアダプター。
67
+
68
+ ```typescript
69
+ const options = {
70
+ url: 'wss://your-livekit-server.com',
71
+ tokenProvider: async () => {
72
+ // トークン取得ロジック
73
+ return token;
74
+ },
75
+ topics: ['control', 'events', 'transcript', 'audio'],
76
+ audioPublish: {
77
+ sampleRate: 48000, // 48kHz, 24kHz, または 16kHz
78
+ channels: 1, // モノラルまたはステレオ
79
+ }
80
+ };
81
+ ```
82
+
83
+ ### モックアダプター
84
+
85
+ テストと開発用のモックアダプター。
86
+
87
+ ```typescript
88
+ import { MockAdapter } from '@metatell/bot-realtime';
89
+
90
+ const mock = new MockAdapter();
91
+
92
+ // モック動作の設定
93
+ mock.simulateConnection();
94
+ mock.simulateParticipant('user-123', 'Alice');
95
+ mock.simulateData('events', { type: 'test' });
96
+ ```
97
+
98
+ ## イベント
99
+
100
+ ```typescript
101
+ type RealtimeEvent =
102
+ | { type: 'state'; state: ConnectionState }
103
+ | { type: 'data'; topic: string; payload: Uint8Array; from?: string }
104
+ | { type: 'participant-joined'; identity: string; sid: string }
105
+ | { type: 'participant-left'; identity: string; sid: string }
106
+ | { type: 'warning'; code: string; message: string }
107
+ | { type: 'error'; code: string; message: string; cause?: unknown }
108
+ ```
109
+
110
+ ## License
111
+
112
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metatell/bot-realtime",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
24
  "@livekit/rtc-node": "^0.13.18",
25
- "@metatell/bot-sdk": "0.0.4"
25
+ "@metatell/bot-sdk": "0.0.6"
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",