@meetstream/cli 0.1.0
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/LICENSE +21 -0
- package/README.md +80 -0
- package/bin/meetstream.js +38 -0
- package/package.json +41 -0
- package/src/api.js +224 -0
- package/src/commands/bot.js +211 -0
- package/src/commands/listen.js +72 -0
- package/src/commands/misc.js +101 -0
- package/src/commands/transcript.js +64 -0
- package/src/config.js +39 -0
- package/src/output.js +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MeetStream.ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# MeetStream CLI
|
|
2
|
+
|
|
3
|
+
**The MeetStream meeting-bot API from your terminal.** Create bots that join Zoom, Google Meet, and Microsoft Teams meetings; record, transcribe, and interact — without writing a line of code.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g @meetstream/cli # or: npx @meetstream/cli ...
|
|
7
|
+
meetstream auth set-key ms_XXXX # key from https://app.meetstream.ai/api-keys
|
|
8
|
+
meetstream bot create "https://meet.google.com/abc-defg-hij" -t deepgram
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 60-second tour
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# 1. Point a local webhook receiver at the world (great for dev)
|
|
17
|
+
meetstream listen --port 3333 # then: ngrok http 3333
|
|
18
|
+
|
|
19
|
+
# 2. Send a bot to a meeting with post-call transcription
|
|
20
|
+
meetstream bot create "https://zoom.us/j/123456789" \
|
|
21
|
+
--name "Notetaker" -t deepgram -c https://<ngrok>.ngrok.io/webhook
|
|
22
|
+
|
|
23
|
+
# 3. Watch it join
|
|
24
|
+
meetstream bot status <bot_id> --watch
|
|
25
|
+
|
|
26
|
+
# 4. Grab the transcript the moment it's ready
|
|
27
|
+
meetstream transcript <bot_id> --wait
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Commands
|
|
31
|
+
|
|
32
|
+
| Command | What it does |
|
|
33
|
+
|---------|--------------|
|
|
34
|
+
| `auth set-key <key>` / `auth status` | Store + validate your API key (`MEETSTREAM_API_KEY` env wins) |
|
|
35
|
+
| `bot create <link>` | Send/schedule a bot — transcription provider, callbacks, live streams, MIA agent, per-participant streams, idempotency |
|
|
36
|
+
| `bot list` / `status --watch` / `detail` | Inspect bots |
|
|
37
|
+
| `bot summary <id>` | MeetStream's built-in AI meeting summary |
|
|
38
|
+
| `bot audio/video/streams/audio-streams <id>` | Presigned media URLs (incl. per-participant) |
|
|
39
|
+
| `bot participants/chats/screenshots/timeline <id>` | Meeting data |
|
|
40
|
+
| `bot send-message <id> <msg>` / `send-image <id> <url>` | Interact with a live meeting |
|
|
41
|
+
| `bot remove <id>` / `bot delete <id> --yes` | Leave meeting / permanently delete data |
|
|
42
|
+
| `transcript <bot_id> [--wait] [--json] [--raw]` | Fetch transcript — resolves `transcript_id` for you |
|
|
43
|
+
| `transcriptions <bot_id>` / `transcribe <bot_id> -p assemblyai` | List runs / re-transcribe with another provider |
|
|
44
|
+
| `calendar connect/events/schedule/auto-join on` | Google Calendar auto-join |
|
|
45
|
+
| `mia list/create/delete` | Conversational AI agents (MIA) |
|
|
46
|
+
| `listen [--forward url]` | Local webhook receiver with pretty, colorized lifecycle output |
|
|
47
|
+
|
|
48
|
+
Every command supports `--json` for scripting.
|
|
49
|
+
|
|
50
|
+
## The webhook model (what `listen` shows you)
|
|
51
|
+
|
|
52
|
+
Events arrive under the **`event`** key with `bot_id`, `bot_status`, `message`, `status_code` (200/500), `custom_attributes`:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
bot.joining → bot.in_waiting_room → bot.inmeeting → bot.recording → bot.leaving → bot.stopped
|
|
56
|
+
→ manifest.completed → audio.processed → transcription.processed → video.processed → bot.done
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`bot.stopped` fires **once** — `bot_status` says why (`Stopped` · `NotAllowed` lobby-timeout · `Denied` host-denied · `Error`). Streaming-only transcription providers end at `audio.processed` (no `bot.done`). `transcript_id` is **not** in webhooks — `meetstream transcript <bot_id>` resolves it via `/detail`.
|
|
60
|
+
|
|
61
|
+
## Configuration
|
|
62
|
+
|
|
63
|
+
| Source | Notes |
|
|
64
|
+
|--------|-------|
|
|
65
|
+
| `MEETSTREAM_API_KEY` | wins over the config file |
|
|
66
|
+
| `~/.meetstream/config.json` | written by `auth set-key` (0600) |
|
|
67
|
+
| `MEETSTREAM_API_URL` | override the base URL (default `https://api.meetstream.ai/api/v1`) |
|
|
68
|
+
|
|
69
|
+
## Development
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm install
|
|
73
|
+
npm test # node --test, fully mocked (no network)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
Docs: [docs.meetstream.ai](https://docs.meetstream.ai) · OpenAPI: [openapi.json](https://docs.meetstream.ai/openapi.json) · MCP server for agents: [meetstream-ai/meetstream-mcp](https://github.com/meetstream-ai/meetstream-mcp)
|
|
79
|
+
|
|
80
|
+
MIT © MeetStream.ai
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// MeetStream CLI — https://github.com/meetstream-ai/meetstream-cli
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { MeetStreamClient } from '../src/api.js';
|
|
6
|
+
import { resolveApiKey } from '../src/config.js';
|
|
7
|
+
import { fail } from '../src/output.js';
|
|
8
|
+
import { registerBotCommands } from '../src/commands/bot.js';
|
|
9
|
+
import { registerTranscriptCommands } from '../src/commands/transcript.js';
|
|
10
|
+
import { registerAuthCommands, registerCalendarCommands, registerMiaCommands } from '../src/commands/misc.js';
|
|
11
|
+
import { registerListenCommand } from '../src/commands/listen.js';
|
|
12
|
+
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
const { version } = require('../package.json');
|
|
15
|
+
|
|
16
|
+
const program = new Command();
|
|
17
|
+
program
|
|
18
|
+
.name('meetstream')
|
|
19
|
+
.description('MeetStream — meeting bot API from your terminal (Zoom, Google Meet, Teams)\nDocs: https://docs.meetstream.ai · Keys: https://app.meetstream.ai/api-keys')
|
|
20
|
+
.version(version);
|
|
21
|
+
|
|
22
|
+
let client;
|
|
23
|
+
function getClient() {
|
|
24
|
+
if (!client) client = new MeetStreamClient(resolveApiKey());
|
|
25
|
+
return client;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
registerAuthCommands(program, getClient);
|
|
29
|
+
registerBotCommands(program, getClient);
|
|
30
|
+
registerTranscriptCommands(program, getClient);
|
|
31
|
+
registerCalendarCommands(program, getClient);
|
|
32
|
+
registerMiaCommands(program, getClient);
|
|
33
|
+
registerListenCommand(program);
|
|
34
|
+
|
|
35
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
36
|
+
fail(err.message);
|
|
37
|
+
process.exit(err.exitCode || 1);
|
|
38
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@meetstream/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official MeetStream CLI — create meeting bots, fetch transcripts, and stream webhook events from your terminal. Zoom, Google Meet, Microsoft Teams.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"meetstream": "bin/meetstream.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"src",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "node --test"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18.17"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"commander": "^15.0.0"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"meetstream",
|
|
26
|
+
"meeting-bot",
|
|
27
|
+
"transcription",
|
|
28
|
+
"zoom",
|
|
29
|
+
"google-meet",
|
|
30
|
+
"microsoft-teams",
|
|
31
|
+
"cli",
|
|
32
|
+
"meeting-intelligence"
|
|
33
|
+
],
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/meetstream-ai/meetstream-cli.git"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://docs.meetstream.ai",
|
|
39
|
+
"author": "MeetStream.ai <hello@meetstream.ai>",
|
|
40
|
+
"license": "MIT"
|
|
41
|
+
}
|
package/src/api.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// MeetStream API client — mirrors the live OpenAPI spec (https://docs.meetstream.ai/openapi.json)
|
|
2
|
+
// Auth: `Authorization: Token <key>` · Base: https://api.meetstream.ai/api/v1
|
|
3
|
+
import { BASE_URL } from './config.js';
|
|
4
|
+
|
|
5
|
+
export class ApiError extends Error {
|
|
6
|
+
constructor(message, { status, body, path } = {}) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'ApiError';
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.body = body;
|
|
11
|
+
this.path = path;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class MeetStreamClient {
|
|
16
|
+
constructor(apiKey, { baseUrl = BASE_URL, fetchImpl = fetch } = {}) {
|
|
17
|
+
this.apiKey = apiKey;
|
|
18
|
+
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
19
|
+
this.fetch = fetchImpl;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async request(method, path, { body, headers = {}, query } = {}) {
|
|
23
|
+
let url = `${this.baseUrl}${path}`;
|
|
24
|
+
if (query) {
|
|
25
|
+
const qs = new URLSearchParams(query).toString();
|
|
26
|
+
if (qs) url += `?${qs}`;
|
|
27
|
+
}
|
|
28
|
+
const res = await this.fetch(url, {
|
|
29
|
+
method,
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: `Token ${this.apiKey}`,
|
|
32
|
+
'Content-Type': 'application/json',
|
|
33
|
+
...headers,
|
|
34
|
+
},
|
|
35
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
36
|
+
});
|
|
37
|
+
const text = await res.text();
|
|
38
|
+
let data;
|
|
39
|
+
try { data = text ? JSON.parse(text) : null; } catch { data = text; }
|
|
40
|
+
// 507 = idempotent replay of an existing bot — a success, not an error.
|
|
41
|
+
if (!res.ok && res.status !== 507) {
|
|
42
|
+
const detail = typeof data === 'object' && data !== null
|
|
43
|
+
? (data.detail || data.message || data.error || JSON.stringify(data))
|
|
44
|
+
: String(data).slice(0, 300);
|
|
45
|
+
throw new ApiError(`${method} ${path} → HTTP ${res.status}: ${detail}`, {
|
|
46
|
+
status: res.status, body: data, path,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return { status: res.status, data };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ── Bots ──────────────────────────────────────────────────────────────
|
|
53
|
+
createBot(payload, { idempotencyKey } = {}) {
|
|
54
|
+
const headers = idempotencyKey ? { 'Idempotency-Key': idempotencyKey } : {};
|
|
55
|
+
return this.request('POST', '/bots/create_bot', { body: payload, headers });
|
|
56
|
+
}
|
|
57
|
+
listBots() { return this.request('GET', '/bots'); }
|
|
58
|
+
botStatus(botId) { return this.request('GET', `/bots/${botId}/status`); }
|
|
59
|
+
botDetail(botId) { return this.request('GET', `/bots/${botId}/detail`); }
|
|
60
|
+
botSummary(botId) { return this.request('GET', `/bots/${botId}/summary`); }
|
|
61
|
+
botAudio(botId) { return this.request('GET', `/bots/${botId}/get_audio`); }
|
|
62
|
+
botVideo(botId) { return this.request('GET', `/bots/${botId}/get_video`); }
|
|
63
|
+
recordingStreams(botId) { return this.request('GET', `/bots/${botId}/get_recording_streams`); }
|
|
64
|
+
audioStreams(botId) { return this.request('GET', `/bots/${botId}/get_audio_streams`); }
|
|
65
|
+
speakerTimeline(botId) { return this.request('GET', `/bots/${botId}/get_speaker_timeline`); }
|
|
66
|
+
chats(botId) { return this.request('GET', `/bots/${botId}/get_chats`); }
|
|
67
|
+
screenshots(botId) { return this.request('GET', `/bots/${botId}/get_screenshots`); }
|
|
68
|
+
participants(botId) { return this.request('GET', `/bots/${botId}/get_participants`); }
|
|
69
|
+
removeBot(botId) { return this.request('GET', `/bots/${botId}/remove_bot`); } // GET, not DELETE
|
|
70
|
+
deleteBotData(botId) { return this.request('DELETE', `/bots/${botId}/delete`); }
|
|
71
|
+
sendMessage(botId, message, metadata) {
|
|
72
|
+
return this.request('POST', `/bots/${botId}/send_message`, { body: { message, ...(metadata ? { metadata } : {}) } });
|
|
73
|
+
}
|
|
74
|
+
sendImage(botId, imgUrl, displayDuration, metadata) {
|
|
75
|
+
return this.request('POST', `/bots/${botId}/send_image`, {
|
|
76
|
+
body: { img_url: imgUrl, ...(displayDuration ? { display_duration: displayDuration } : {}), ...(metadata ? { metadata } : {}) },
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ── Transcription ─────────────────────────────────────────────────────
|
|
81
|
+
transcriptions(botId) { return this.request('GET', `/bots/${botId}/transcriptions`); }
|
|
82
|
+
transcribe(botId, provider, callbackUrl) {
|
|
83
|
+
return this.request('POST', `/bots/${botId}/transcribe`, {
|
|
84
|
+
body: { provider, ...(callbackUrl ? { callback_url: callbackUrl } : {}) },
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
getTranscriptById(transcriptId, { raw = false } = {}) {
|
|
88
|
+
return this.request('GET', `/transcript/${transcriptId}/get_transcript`, { query: { raw: String(raw) } });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Resolve a bot's transcript_id. transcript_id is NOT delivered in webhooks —
|
|
93
|
+
* canonical sources: GET /bots/{id}/detail (bot_details.transcript_id),
|
|
94
|
+
* the create_bot response, or GET /bots/{id}/transcriptions.
|
|
95
|
+
*/
|
|
96
|
+
async resolveTranscriptId(botId) {
|
|
97
|
+
try {
|
|
98
|
+
const { data } = await this.botDetail(botId);
|
|
99
|
+
const tid = data?.bot_details?.transcript_id || data?.transcript_id;
|
|
100
|
+
if (tid) return tid;
|
|
101
|
+
} catch { /* fall through to /transcriptions */ }
|
|
102
|
+
const { data } = await this.transcriptions(botId);
|
|
103
|
+
const items = data?.transcriptions || [];
|
|
104
|
+
const done = items.find((t) => /success|completed/i.test(t.status || '')) || items[0];
|
|
105
|
+
return done?.transcript_id || null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Fetch a bot's transcript, optionally polling until it is ready. */
|
|
109
|
+
async getTranscript(botId, { raw = false, wait = false, timeoutMs = 600_000, intervalMs = 5000 } = {}) {
|
|
110
|
+
const deadline = Date.now() + timeoutMs;
|
|
111
|
+
// one immediate attempt, then poll if wait=true
|
|
112
|
+
for (;;) {
|
|
113
|
+
const tid = await this.resolveTranscriptId(botId);
|
|
114
|
+
if (tid) {
|
|
115
|
+
try {
|
|
116
|
+
const { data } = await this.getTranscriptById(tid, { raw });
|
|
117
|
+
// Live API may wrap segments in a `message` key: { message: [ {speaker, transcript, ...} ] }
|
|
118
|
+
const segments = Array.isArray(data) ? data : (Array.isArray(data?.message) ? data.message : data);
|
|
119
|
+
if (segments && (Array.isArray(segments) ? segments.length : true)) {
|
|
120
|
+
return { transcript_id: tid, transcript: segments };
|
|
121
|
+
}
|
|
122
|
+
} catch (e) {
|
|
123
|
+
if (!wait || (e.status && e.status !== 404 && e.status !== 400)) throw e;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (!wait || Date.now() > deadline) {
|
|
127
|
+
if (!wait) return { transcript_id: tid, transcript: null };
|
|
128
|
+
throw new ApiError(`Timed out after ${Math.round(timeoutMs / 1000)}s waiting for transcript of bot ${botId}`, { path: `/bots/${botId}` });
|
|
129
|
+
}
|
|
130
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ── Calendar ──────────────────────────────────────────────────────────
|
|
135
|
+
connectCalendar({ clientId, clientSecret, refreshToken }) {
|
|
136
|
+
return this.request('POST', '/calendar/create_calendar', {
|
|
137
|
+
body: { google_client_id: clientId, google_client_secret: clientSecret, google_refresh_token: refreshToken },
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
disconnectCalendar({ clientId, clientSecret, refreshToken }) {
|
|
141
|
+
return this.request('POST', '/calendar/disconnect', {
|
|
142
|
+
body: { google_client_id: clientId, google_client_secret: clientSecret, google_refresh_token: refreshToken },
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
listCalendars() { return this.request('GET', '/calendar'); }
|
|
146
|
+
calendarEvents() { return this.request('GET', '/calendar/events'); }
|
|
147
|
+
scheduleEvent(eventId) { return this.request('POST', `/calendar/schedule/${eventId}`); }
|
|
148
|
+
unscheduleEvent(eventId) { return this.request('DELETE', `/calendar/schedule/${eventId}`); }
|
|
149
|
+
toggleRecurrence(eventId, enabled) {
|
|
150
|
+
return this.request('POST', '/calendar/toggle-recurrence', { body: { event_id: eventId, recurring_enabled: enabled } });
|
|
151
|
+
}
|
|
152
|
+
autoScheduleEnable(defaultBotConfig) {
|
|
153
|
+
return this.request('POST', '/calendar/auto-schedule/enable', { body: { default_bot_config: defaultBotConfig } });
|
|
154
|
+
}
|
|
155
|
+
autoScheduleDisable(defaultBotConfig) {
|
|
156
|
+
return this.request('POST', '/calendar/auto-schedule/disable', { body: { default_bot_config: defaultBotConfig || {} } });
|
|
157
|
+
}
|
|
158
|
+
rescheduleBot(botId, joinTime) {
|
|
159
|
+
return this.request('PATCH', `/calendar/scheduled_bots/${botId}`, { body: { scheduled_join_time: joinTime } });
|
|
160
|
+
}
|
|
161
|
+
deleteScheduledBot(botId) { return this.request('DELETE', `/calendar/scheduled_bots/${botId}`); }
|
|
162
|
+
|
|
163
|
+
// ── MIA (conversational agents) ───────────────────────────────────────
|
|
164
|
+
miaList() { return this.request('GET', '/mia'); }
|
|
165
|
+
miaCreate(config) { return this.request('POST', '/mia', { body: config }); }
|
|
166
|
+
miaUpdate(config) { return this.request('PUT', '/mia', { body: config }); }
|
|
167
|
+
miaDelete(agentConfigId) { return this.request('DELETE', '/mia', { query: { agent_config_id: agentConfigId } }); }
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Build a create_bot payload from CLI-ish options, applying safe defaults. */
|
|
171
|
+
export function buildCreateBotPayload(opts) {
|
|
172
|
+
const payload = {
|
|
173
|
+
meeting_link: opts.meetingLink,
|
|
174
|
+
bot_name: opts.name || 'MeetStream Bot',
|
|
175
|
+
video_required: Boolean(opts.video),
|
|
176
|
+
};
|
|
177
|
+
if (opts.botMessage) payload.bot_message = opts.botMessage;
|
|
178
|
+
if (opts.imageUrl) payload.bot_image_url = opts.imageUrl; // must be a PUBLIC url
|
|
179
|
+
if (opts.callback) payload.callback_url = opts.callback;
|
|
180
|
+
if (opts.joinAt) payload.join_at = opts.joinAt;
|
|
181
|
+
if (opts.agentConfigId) payload.agent_config_id = opts.agentConfigId;
|
|
182
|
+
if (opts.separateAudio) payload.audio_separate_streams = true;
|
|
183
|
+
if (opts.separateVideo) payload.video_separate_streams = true;
|
|
184
|
+
if (opts.zoomObf) payload.zoom = { use_zoom_obf: true };
|
|
185
|
+
if (opts.liveTranscriptWebhook) payload.live_transcription_required = { webhook_url: opts.liveTranscriptWebhook };
|
|
186
|
+
if (opts.liveAudioWs) payload.live_audio_required = { websocket_url: opts.liveAudioWs };
|
|
187
|
+
if (opts.liveVideoWs) payload.live_video_required = { websocket_url: opts.liveVideoWs };
|
|
188
|
+
if (opts.socketWs) payload.socket_connection_url = { websocket_url: opts.socketWs };
|
|
189
|
+
if (opts.attrs && Object.keys(opts.attrs).length) payload.custom_attributes = opts.attrs;
|
|
190
|
+
|
|
191
|
+
if (opts.transcript) {
|
|
192
|
+
const provider = {};
|
|
193
|
+
const p = opts.transcript;
|
|
194
|
+
if (p === 'deepgram') provider.deepgram = { model: 'nova-3', language: opts.language || 'en', diarize: true };
|
|
195
|
+
else if (p === 'assemblyai') provider.assemblyai = { speech_models: ['best'], language_code: opts.language || 'en_us', speaker_labels: true };
|
|
196
|
+
else if (p === 'sarvam') provider.sarvam = { model: 'saarika:v2', language_code: opts.language || 'en-IN', mode: 'batch', with_diarization: true };
|
|
197
|
+
else if (p === 'meetstream') provider.meetstream = { language: opts.language || 'auto', translate: false };
|
|
198
|
+
else if (p === 'jigsawstack') provider.jigsawstack = { language: opts.language || 'auto', translate: false, by_speaker: true };
|
|
199
|
+
else if (p === 'meeting_captions') provider.meeting_captions = {};
|
|
200
|
+
else if (p === 'deepgram_streaming') provider.deepgram_streaming = { model: 'nova-3', language: opts.language || 'en' };
|
|
201
|
+
else if (p === 'assemblyai_streaming') provider.assemblyai_streaming = {};
|
|
202
|
+
else provider[p] = {};
|
|
203
|
+
payload.recording_config = {
|
|
204
|
+
...(payload.recording_config || {}),
|
|
205
|
+
transcript: { provider },
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
if (opts.retentionHours) {
|
|
209
|
+
payload.recording_config = {
|
|
210
|
+
...(payload.recording_config || {}),
|
|
211
|
+
retention: { type: 'timed', hours: Number(opts.retentionHours) },
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Sensible timeouts so bots never sit in empty meetings.
|
|
216
|
+
// recording_permission_denied_timeout: Zoom-only, MINIMUM 60 (lower → HTTP 400).
|
|
217
|
+
payload.automatic_leave = {
|
|
218
|
+
waiting_room_timeout: Number(opts.waitingRoomTimeout ?? 300),
|
|
219
|
+
everyone_left_timeout: Number(opts.everyoneLeftTimeout ?? 60),
|
|
220
|
+
in_call_recording_timeout: Number(opts.maxRecordingSeconds ?? 14400),
|
|
221
|
+
recording_permission_denied_timeout: Math.max(60, Number(opts.permissionDeniedTimeout ?? 60)),
|
|
222
|
+
};
|
|
223
|
+
return payload;
|
|
224
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { buildCreateBotPayload } from '../api.js';
|
|
2
|
+
import { printJson, ok, kv, bold, dim, cyan, transcriptToText, handleError } from '../output.js';
|
|
3
|
+
|
|
4
|
+
function parseAttrs(list = []) {
|
|
5
|
+
const out = {};
|
|
6
|
+
for (const item of list) {
|
|
7
|
+
const i = item.indexOf('=');
|
|
8
|
+
if (i === -1) throw Object.assign(new Error(`--attr expects key=value, got "${item}"`), { exitCode: 2 });
|
|
9
|
+
out[item.slice(0, i)] = item.slice(i + 1); // values kept as strings (API expects strings)
|
|
10
|
+
}
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function registerBotCommands(program, getClient) {
|
|
15
|
+
const bot = program.command('bot').description('Create and manage meeting bots');
|
|
16
|
+
|
|
17
|
+
bot
|
|
18
|
+
.command('create')
|
|
19
|
+
.description('Send a bot to a meeting (or schedule with --join-at)')
|
|
20
|
+
.argument('<meeting-link>', 'Zoom / Google Meet / Teams meeting URL')
|
|
21
|
+
.option('-n, --name <name>', 'bot display name', 'MeetStream Bot')
|
|
22
|
+
.option('--video', 'record video (default: audio only)')
|
|
23
|
+
.option('-t, --transcript <provider>', 'deepgram | assemblyai | sarvam | meetstream | jigsawstack | meeting_captions | deepgram_streaming | assemblyai_streaming')
|
|
24
|
+
.option('-l, --language <lang>', 'transcription language (provider-specific format)')
|
|
25
|
+
.option('-c, --callback <url>', 'HTTPS webhook for lifecycle events')
|
|
26
|
+
.option('--join-at <iso8601>', 'schedule a future join, e.g. 2026-07-02T15:00:00Z')
|
|
27
|
+
.option('--bot-message <msg>', 'chat message posted when the bot joins')
|
|
28
|
+
.option('--image-url <url>', 'PUBLIC image URL for the bot avatar')
|
|
29
|
+
.option('--retention-hours <n>', 'data retention window (default: API default 24h)')
|
|
30
|
+
.option('--separate-audio', 'capture per-participant audio streams')
|
|
31
|
+
.option('--separate-video', 'capture per-participant video streams')
|
|
32
|
+
.option('--zoom-obf', 'use Zoom On-Behalf-Of')
|
|
33
|
+
.option('--agent-config-id <id>', 'attach a MIA conversational agent')
|
|
34
|
+
.option('--live-transcript-webhook <url>', 'webhook URL for live transcript chunks')
|
|
35
|
+
.option('--live-audio-ws <wss>', 'WebSocket URL for live audio out')
|
|
36
|
+
.option('--live-video-ws <wss>', 'WebSocket URL for live video out')
|
|
37
|
+
.option('--socket-ws <wss>', 'two-way bot-control WebSocket (socket_connection_url)')
|
|
38
|
+
.option('--attr <key=value...>', 'custom_attributes entries (echoed back in webhooks)')
|
|
39
|
+
.option('--idempotency-key <uuid>', 'safe-retry key (retry returns HTTP 507 with the original bot)')
|
|
40
|
+
.option('--everyone-left-timeout <sec>', 'leave after everyone else leaves', '60')
|
|
41
|
+
.option('--waiting-room-timeout <sec>', 'max seconds in waiting room', '300')
|
|
42
|
+
.option('--max-recording-seconds <sec>', 'max in-call recording seconds', '14400')
|
|
43
|
+
.option('--json', 'JSON output')
|
|
44
|
+
.action(async (meetingLink, opts) => {
|
|
45
|
+
try {
|
|
46
|
+
const client = getClient();
|
|
47
|
+
const payload = buildCreateBotPayload({
|
|
48
|
+
meetingLink,
|
|
49
|
+
name: opts.name,
|
|
50
|
+
video: opts.video,
|
|
51
|
+
transcript: opts.transcript,
|
|
52
|
+
language: opts.language,
|
|
53
|
+
callback: opts.callback,
|
|
54
|
+
joinAt: opts.joinAt,
|
|
55
|
+
botMessage: opts.botMessage,
|
|
56
|
+
imageUrl: opts.imageUrl,
|
|
57
|
+
retentionHours: opts.retentionHours,
|
|
58
|
+
separateAudio: opts.separateAudio,
|
|
59
|
+
separateVideo: opts.separateVideo,
|
|
60
|
+
zoomObf: opts.zoomObf,
|
|
61
|
+
agentConfigId: opts.agentConfigId,
|
|
62
|
+
liveTranscriptWebhook: opts.liveTranscriptWebhook,
|
|
63
|
+
liveAudioWs: opts.liveAudioWs,
|
|
64
|
+
liveVideoWs: opts.liveVideoWs,
|
|
65
|
+
socketWs: opts.socketWs,
|
|
66
|
+
attrs: parseAttrs(opts.attr),
|
|
67
|
+
everyoneLeftTimeout: opts.everyoneLeftTimeout,
|
|
68
|
+
waitingRoomTimeout: opts.waitingRoomTimeout,
|
|
69
|
+
maxRecordingSeconds: opts.maxRecordingSeconds,
|
|
70
|
+
});
|
|
71
|
+
const { status, data } = await client.createBot(payload, { idempotencyKey: opts.idempotencyKey });
|
|
72
|
+
if (opts.json) return printJson(data);
|
|
73
|
+
ok(status === 507 ? 'Idempotent replay — existing bot returned (no new bot created)' : 'Bot created');
|
|
74
|
+
kv({ bot_id: bold(data.bot_id), transcript_id: data.transcript_id || dim('(pending)'), status: data.status, meeting: data.meeting_url });
|
|
75
|
+
console.log(dim(`\n Next: meetstream bot status ${data.bot_id} --watch`));
|
|
76
|
+
if (payload.recording_config?.transcript) console.log(dim(` meetstream transcript ${data.bot_id} --wait`));
|
|
77
|
+
} catch (e) { handleError(e, opts); }
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
bot
|
|
81
|
+
.command('list')
|
|
82
|
+
.description('List all bots on the account')
|
|
83
|
+
.option('--json', 'JSON output')
|
|
84
|
+
.action(async (opts) => {
|
|
85
|
+
try {
|
|
86
|
+
const { data } = await getClient().listBots();
|
|
87
|
+
if (opts.json) return printJson(data);
|
|
88
|
+
const bots = data?.bots || [];
|
|
89
|
+
if (!bots.length) return console.log(dim('No bots yet. Create one: meetstream bot create <meeting-link>'));
|
|
90
|
+
for (const b of bots) {
|
|
91
|
+
const id = b.BotID || b.bot_id || b.id;
|
|
92
|
+
const st = b.Status || b.status || '';
|
|
93
|
+
const name = b.BotUsername || b.bot_name || '';
|
|
94
|
+
const plat = b.Platform || '';
|
|
95
|
+
console.log(`${cyan(id)} ${String(st).padEnd(12)} ${name} ${dim(plat)}`);
|
|
96
|
+
}
|
|
97
|
+
if (data?.hasNextPage) console.log(dim(`… more pages (nextCursor: ${data.nextCursor})`));
|
|
98
|
+
} catch (e) { handleError(e, opts); }
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
bot
|
|
102
|
+
.command('status')
|
|
103
|
+
.description('Bot status (Joining → InWaitingRoom → InMeeting → Recording → Stopped)')
|
|
104
|
+
.argument('<bot-id>')
|
|
105
|
+
.option('-w, --watch', 'poll every 5s until a terminal status')
|
|
106
|
+
.option('--json', 'JSON output')
|
|
107
|
+
.action(async (botId, opts) => {
|
|
108
|
+
try {
|
|
109
|
+
const client = getClient();
|
|
110
|
+
for (;;) {
|
|
111
|
+
const { data } = await client.botStatus(botId);
|
|
112
|
+
if (opts.json && !opts.watch) return printJson(data);
|
|
113
|
+
const st = data.status || JSON.stringify(data);
|
|
114
|
+
console.log(`${new Date().toTimeString().slice(0, 8)} ${bold(st)}`);
|
|
115
|
+
if (!opts.watch || /stopped|done|error|failed|notallowed|denied/i.test(String(st))) break;
|
|
116
|
+
await new Promise((r) => setTimeout(r, 5000));
|
|
117
|
+
}
|
|
118
|
+
} catch (e) { handleError(e, opts); }
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const simpleGets = [
|
|
122
|
+
['detail', 'botDetail', 'Full session metadata (incl. transcript_id + caption_file)'],
|
|
123
|
+
['summary', 'botSummary', "MeetStream's built-in AI meeting summary"],
|
|
124
|
+
['audio', 'botAudio', 'Recorded audio URL (presigned S3, valid 1h)'],
|
|
125
|
+
['video', 'botVideo', 'Recorded video URL (presigned S3, valid 10min)'],
|
|
126
|
+
['streams', 'recordingStreams', 'Per-participant video streams (needs --separate-video at create)'],
|
|
127
|
+
['audio-streams', 'audioStreams', 'Per-participant audio streams (needs --separate-audio at create)'],
|
|
128
|
+
['timeline', 'speakerTimeline', 'Speaker timeline (who spoke when)'],
|
|
129
|
+
['chats', 'chats', 'In-meeting chat messages'],
|
|
130
|
+
['screenshots', 'screenshots', 'Screenshots captured during the meeting'],
|
|
131
|
+
['participants', 'participants', 'Participant list'],
|
|
132
|
+
];
|
|
133
|
+
for (const [name, method, desc] of simpleGets) {
|
|
134
|
+
bot
|
|
135
|
+
.command(name)
|
|
136
|
+
.description(desc)
|
|
137
|
+
.argument('<bot-id>')
|
|
138
|
+
.option('--json', 'JSON output')
|
|
139
|
+
.action(async (botId, opts) => {
|
|
140
|
+
try {
|
|
141
|
+
const { data } = await getClient()[method](botId);
|
|
142
|
+
printJson(data); // structured data — JSON is the honest default
|
|
143
|
+
} catch (e) { handleError(e, opts); }
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
bot
|
|
148
|
+
.command('remove')
|
|
149
|
+
.description('Remove the bot from an active meeting (data is kept)')
|
|
150
|
+
.argument('<bot-id>')
|
|
151
|
+
.option('--json', 'JSON output')
|
|
152
|
+
.action(async (botId, opts) => {
|
|
153
|
+
try {
|
|
154
|
+
const { data } = await getClient().removeBot(botId);
|
|
155
|
+
if (opts.json) return printJson(data);
|
|
156
|
+
ok(`Bot ${botId} removed from meeting`);
|
|
157
|
+
} catch (e) { handleError(e, opts); }
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
bot
|
|
161
|
+
.command('delete')
|
|
162
|
+
.description('PERMANENTLY delete a bot\'s audio, video, and transcripts')
|
|
163
|
+
.argument('<bot-id>')
|
|
164
|
+
.option('--yes', 'skip confirmation')
|
|
165
|
+
.option('--json', 'JSON output')
|
|
166
|
+
.action(async (botId, opts) => {
|
|
167
|
+
try {
|
|
168
|
+
if (!opts.yes) {
|
|
169
|
+
const err = new Error('Refusing to delete without --yes (this permanently removes all media + transcripts)');
|
|
170
|
+
err.exitCode = 2;
|
|
171
|
+
throw err;
|
|
172
|
+
}
|
|
173
|
+
const { data } = await getClient().deleteBotData(botId);
|
|
174
|
+
if (opts.json) return printJson(data);
|
|
175
|
+
ok(`Bot ${botId} data deleted (a data_deletion webhook will fire)`);
|
|
176
|
+
} catch (e) { handleError(e, opts); }
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
bot
|
|
180
|
+
.command('send-message')
|
|
181
|
+
.description('Post a chat message into the live meeting')
|
|
182
|
+
.argument('<bot-id>')
|
|
183
|
+
.argument('<message...>')
|
|
184
|
+
.option('--json', 'JSON output')
|
|
185
|
+
.action(async (botId, messageWords, opts) => {
|
|
186
|
+
try {
|
|
187
|
+
const { data } = await getClient().sendMessage(botId, messageWords.join(' '));
|
|
188
|
+
if (opts.json) return printJson(data);
|
|
189
|
+
ok('Message sent');
|
|
190
|
+
} catch (e) { handleError(e, opts); }
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
bot
|
|
194
|
+
.command('send-image')
|
|
195
|
+
.description('Show an image/GIF as the bot\'s video frame (public URL)')
|
|
196
|
+
.argument('<bot-id>')
|
|
197
|
+
.argument('<img-url>')
|
|
198
|
+
.option('-d, --duration <seconds>', 'display duration')
|
|
199
|
+
.option('--json', 'JSON output')
|
|
200
|
+
.action(async (botId, imgUrl, opts) => {
|
|
201
|
+
try {
|
|
202
|
+
const { data } = await getClient().sendImage(botId, imgUrl, opts.duration ? Number(opts.duration) : undefined);
|
|
203
|
+
if (opts.json) return printJson(data);
|
|
204
|
+
ok('Image sent');
|
|
205
|
+
} catch (e) { handleError(e, opts); }
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
return bot;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export { transcriptToText };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// `meetstream listen` — local webhook receiver for MeetStream lifecycle events.
|
|
2
|
+
// Ground truth (live-verified): the envelope key is `event` (NOT bot_event).
|
|
3
|
+
// Two-layer model: bot.stopped fires once; bot_status says why
|
|
4
|
+
// (Stopped | NotAllowed lobby-timeout | Denied host-denied | Error crash).
|
|
5
|
+
import { createServer } from 'node:http';
|
|
6
|
+
import { bold, dim, green, yellow, red, cyan } from '../output.js';
|
|
7
|
+
|
|
8
|
+
const TERMINAL = new Set(['bot.stopped', 'bot.done']);
|
|
9
|
+
const FAILY = /denied|notallowed|failed|error/i;
|
|
10
|
+
|
|
11
|
+
function colorFor(event, payload) {
|
|
12
|
+
if (event === 'transcription.failed' || FAILY.test(payload?.bot_status || '')) return red;
|
|
13
|
+
if (TERMINAL.has(event)) return yellow;
|
|
14
|
+
if (/\.processed$|manifest\.completed/.test(event)) return green;
|
|
15
|
+
return cyan;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function registerListenCommand(program) {
|
|
19
|
+
program
|
|
20
|
+
.command('listen')
|
|
21
|
+
.description('Run a local webhook receiver and pretty-print MeetStream events (use ngrok to expose it)')
|
|
22
|
+
.option('-p, --port <port>', 'port to listen on', '3333')
|
|
23
|
+
.option('--path <path>', 'webhook path', '/webhook')
|
|
24
|
+
.option('--forward <url>', 'also relay each event to another URL')
|
|
25
|
+
.option('--json', 'print raw JSON lines instead of pretty output')
|
|
26
|
+
.action(async (opts) => {
|
|
27
|
+
const port = Number(opts.port);
|
|
28
|
+
const server = createServer(async (req, res) => {
|
|
29
|
+
if (req.method !== 'POST') { res.writeHead(200).end('meetstream listen'); return; }
|
|
30
|
+
let raw = '';
|
|
31
|
+
for await (const chunk of req) raw += chunk;
|
|
32
|
+
res.writeHead(200, { 'Content-Type': 'application/json' }).end('{"status":"ok"}'); // respond fast, process after
|
|
33
|
+
let payload;
|
|
34
|
+
try { payload = JSON.parse(raw); } catch { payload = { raw }; }
|
|
35
|
+
|
|
36
|
+
if (opts.json) {
|
|
37
|
+
console.log(JSON.stringify(payload));
|
|
38
|
+
} else {
|
|
39
|
+
const event = payload.event || '(no event field)';
|
|
40
|
+
const paint = colorFor(event, payload);
|
|
41
|
+
const time = new Date().toTimeString().slice(0, 8);
|
|
42
|
+
const bits = [
|
|
43
|
+
dim(time),
|
|
44
|
+
paint(bold(event)),
|
|
45
|
+
payload.bot_status ? `status=${payload.bot_status}` : '',
|
|
46
|
+
payload.status_code !== undefined ? `code=${payload.status_code}` : '',
|
|
47
|
+
payload.bot_id ? dim(String(payload.bot_id).slice(0, 8)) : '',
|
|
48
|
+
].filter(Boolean);
|
|
49
|
+
console.log(bits.join(' '));
|
|
50
|
+
if (payload.message) console.log(dim(` ${payload.message}`));
|
|
51
|
+
if (event === 'transcription.processed' && payload.bot_id) {
|
|
52
|
+
console.log(dim(` → meetstream transcript ${payload.bot_id}`));
|
|
53
|
+
}
|
|
54
|
+
if (event === 'bot.stopped' && FAILY.test(payload.bot_status || '')) {
|
|
55
|
+
console.log(red(` bot ended abnormally (bot_status=${payload.bot_status})`));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (opts.forward) {
|
|
60
|
+
fetch(opts.forward, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: raw })
|
|
61
|
+
.catch((e) => console.error(dim(` forward failed: ${e.message}`)));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
server.listen(port, () => {
|
|
66
|
+
console.log(`${green('▶')} listening on ${bold(`http://localhost:${port}${opts.path === '/webhook' ? '/webhook' : opts.path}`)}`);
|
|
67
|
+
console.log(dim(' expose it: ngrok http ' + port));
|
|
68
|
+
console.log(dim(' then create a bot with: --callback https://<your-ngrok>.ngrok.io/webhook'));
|
|
69
|
+
console.log(dim(' events arrive under the `event` key · Ctrl-C to stop\n'));
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { printJson, ok, kv, dim, handleError } from '../output.js';
|
|
3
|
+
import { saveConfig, resolveApiKey, CONFIG_PATH, BASE_URL } from '../config.js';
|
|
4
|
+
|
|
5
|
+
export function registerAuthCommands(program, getClient) {
|
|
6
|
+
const auth = program.command('auth').description('Manage your API key');
|
|
7
|
+
|
|
8
|
+
auth
|
|
9
|
+
.command('set-key')
|
|
10
|
+
.description(`Store your API key in ${CONFIG_PATH}`)
|
|
11
|
+
.argument('<api-key>')
|
|
12
|
+
.action((key) => {
|
|
13
|
+
const path = saveConfig({ api_key: key });
|
|
14
|
+
ok(`API key saved to ${path} (env MEETSTREAM_API_KEY still takes precedence)`);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
auth
|
|
18
|
+
.command('status')
|
|
19
|
+
.description('Validate the configured key against the live API')
|
|
20
|
+
.action(async (opts) => {
|
|
21
|
+
try {
|
|
22
|
+
const key = resolveApiKey();
|
|
23
|
+
const { data } = await getClient().listBots();
|
|
24
|
+
ok('API key is valid');
|
|
25
|
+
kv({ key: key.slice(0, 6) + '…' + key.slice(-4), base_url: BASE_URL, bots_on_account: (data?.bots || []).length + (data?.hasNextPage ? '+' : '') });
|
|
26
|
+
} catch (e) { handleError(e, opts); }
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function registerCalendarCommands(program, getClient) {
|
|
31
|
+
const cal = program.command('calendar').description('Google Calendar auto-join');
|
|
32
|
+
|
|
33
|
+
cal
|
|
34
|
+
.command('connect')
|
|
35
|
+
.description('Connect a Google Calendar (OAuth refresh-token flow)')
|
|
36
|
+
.requiredOption('--client-id <id>', 'Google OAuth client id')
|
|
37
|
+
.requiredOption('--client-secret <secret>', 'Google OAuth client secret')
|
|
38
|
+
.requiredOption('--refresh-token <token>', 'Google OAuth refresh token')
|
|
39
|
+
.action(async (opts) => {
|
|
40
|
+
try {
|
|
41
|
+
const { data } = await getClient().connectCalendar({ clientId: opts.clientId, clientSecret: opts.clientSecret, refreshToken: opts.refreshToken });
|
|
42
|
+
ok('Calendar connected'); printJson(data);
|
|
43
|
+
} catch (e) { handleError(e, opts); }
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
cal.command('list').description('List connected calendars').action(async (opts) => {
|
|
47
|
+
try { printJson((await getClient().listCalendars()).data); } catch (e) { handleError(e, opts); }
|
|
48
|
+
});
|
|
49
|
+
cal.command('events').description('Fetch/sync upcoming events').action(async (opts) => {
|
|
50
|
+
try { printJson((await getClient().calendarEvents()).data); } catch (e) { handleError(e, opts); }
|
|
51
|
+
});
|
|
52
|
+
cal.command('schedule').description('Schedule a bot for a calendar event').argument('<event-id>').action(async (id, opts) => {
|
|
53
|
+
try { printJson((await getClient().scheduleEvent(id)).data); } catch (e) { handleError(e, opts); }
|
|
54
|
+
});
|
|
55
|
+
cal.command('unschedule').description('Remove the scheduled bot for an event').argument('<event-id>').action(async (id, opts) => {
|
|
56
|
+
try { printJson((await getClient().unscheduleEvent(id)).data); } catch (e) { handleError(e, opts); }
|
|
57
|
+
});
|
|
58
|
+
cal
|
|
59
|
+
.command('auto-join')
|
|
60
|
+
.description('Enable/disable auto-join for every calendar meeting')
|
|
61
|
+
.argument('<on|off>')
|
|
62
|
+
.option('-n, --name <bot-name>', 'default bot name', 'Notetaker')
|
|
63
|
+
.option('--video', 'record video')
|
|
64
|
+
.action(async (mode, opts) => {
|
|
65
|
+
try {
|
|
66
|
+
const cfg = { bot_name: opts.name, audio_required: true, video_required: Boolean(opts.video), automatic_leave: { everyone_left_timeout: 60 } };
|
|
67
|
+
const { data } = mode === 'on'
|
|
68
|
+
? await getClient().autoScheduleEnable(cfg)
|
|
69
|
+
: await getClient().autoScheduleDisable(cfg);
|
|
70
|
+
ok(`Auto-join ${mode === 'on' ? 'enabled' : 'disabled'}`); printJson(data);
|
|
71
|
+
} catch (e) { handleError(e, opts); }
|
|
72
|
+
});
|
|
73
|
+
cal.command('reschedule').description('Change a scheduled bot\'s join time').argument('<bot-id>').argument('<iso8601>').action(async (botId, when, opts) => {
|
|
74
|
+
try { printJson((await getClient().rescheduleBot(botId, when)).data); } catch (e) { handleError(e, opts); }
|
|
75
|
+
});
|
|
76
|
+
cal.command('cancel').description('Delete a scheduled (not yet joined) bot').argument('<bot-id>').action(async (botId, opts) => {
|
|
77
|
+
try { printJson((await getClient().deleteScheduledBot(botId)).data); } catch (e) { handleError(e, opts); }
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function registerMiaCommands(program, getClient) {
|
|
82
|
+
const mia = program.command('mia').description('MIA conversational AI agents');
|
|
83
|
+
mia.command('list').description('List agent configs').action(async (opts) => {
|
|
84
|
+
try { printJson((await getClient().miaList()).data); } catch (e) { handleError(e, opts); }
|
|
85
|
+
});
|
|
86
|
+
mia
|
|
87
|
+
.command('create')
|
|
88
|
+
.description('Create an agent config from a JSON file (agent_name, mode, model, voice, transcriber, …)')
|
|
89
|
+
.requiredOption('-f, --file <path>', 'JSON config file')
|
|
90
|
+
.action(async (opts) => {
|
|
91
|
+
try {
|
|
92
|
+
const cfg = JSON.parse(readFileSync(opts.file, 'utf8'));
|
|
93
|
+
const { data } = await getClient().miaCreate(cfg);
|
|
94
|
+
ok('Agent config created'); printJson(data);
|
|
95
|
+
console.log(dim('Attach it to a bot: meetstream bot create <link> --agent-config-id <id> --socket-ws <wss> --live-audio-ws <wss>'));
|
|
96
|
+
} catch (e) { handleError(e, opts); }
|
|
97
|
+
});
|
|
98
|
+
mia.command('delete').description('Delete an agent config').argument('<agent-config-id>').action(async (id, opts) => {
|
|
99
|
+
try { printJson((await getClient().miaDelete(id)).data); ok('Deleted'); } catch (e) { handleError(e, opts); }
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { printJson, dim, ok, transcriptToText, handleError } from '../output.js';
|
|
2
|
+
|
|
3
|
+
export function registerTranscriptCommands(program, getClient) {
|
|
4
|
+
program
|
|
5
|
+
.command('transcript')
|
|
6
|
+
.description('Fetch a bot\'s transcript (resolves transcript_id for you; --wait polls until ready)')
|
|
7
|
+
.argument('<bot-id>')
|
|
8
|
+
.option('-w, --wait', 'poll until the transcript is ready')
|
|
9
|
+
.option('--timeout <seconds>', 'max wait time with --wait', '600')
|
|
10
|
+
.option('--raw', 'raw provider output instead of processed segments')
|
|
11
|
+
.option('--json', 'JSON segments (default is readable "Speaker: text" lines)')
|
|
12
|
+
.action(async (botId, opts) => {
|
|
13
|
+
try {
|
|
14
|
+
const { transcript_id, transcript } = await getClient().getTranscript(botId, {
|
|
15
|
+
raw: Boolean(opts.raw),
|
|
16
|
+
wait: Boolean(opts.wait),
|
|
17
|
+
timeoutMs: Number(opts.timeout) * 1000,
|
|
18
|
+
});
|
|
19
|
+
if (transcript == null) {
|
|
20
|
+
console.log(dim(`Transcript not ready yet (transcript_id: ${transcript_id ?? 'unresolved'}).`));
|
|
21
|
+
console.log(dim(`Try: meetstream transcript ${botId} --wait`));
|
|
22
|
+
process.exit(3);
|
|
23
|
+
}
|
|
24
|
+
if (opts.json || opts.raw) return printJson(transcript);
|
|
25
|
+
process.stdout.write(transcriptToText(transcript) + '\n');
|
|
26
|
+
} catch (e) { handleError(e, opts); }
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
program
|
|
30
|
+
.command('transcriptions')
|
|
31
|
+
.description('List all transcription runs for a bot (ids, status, download URLs)')
|
|
32
|
+
.argument('<bot-id>')
|
|
33
|
+
.action(async (botId, opts) => {
|
|
34
|
+
try {
|
|
35
|
+
const { data } = await getClient().transcriptions(botId);
|
|
36
|
+
printJson(data);
|
|
37
|
+
} catch (e) { handleError(e, opts); }
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
program
|
|
41
|
+
.command('transcribe')
|
|
42
|
+
.description('Run (or re-run) transcription on a bot\'s recorded audio')
|
|
43
|
+
.argument('<bot-id>')
|
|
44
|
+
.option('-p, --provider <name>', 'deepgram | assemblyai | sarvam | meetstream | jigsawstack', 'deepgram')
|
|
45
|
+
.option('-l, --language <lang>', 'language (provider-specific format)')
|
|
46
|
+
.option('-c, --callback <url>', 'webhook to notify when done')
|
|
47
|
+
.option('--json', 'JSON output')
|
|
48
|
+
.action(async (botId, opts) => {
|
|
49
|
+
try {
|
|
50
|
+
const p = opts.provider;
|
|
51
|
+
const provider = {};
|
|
52
|
+
if (p === 'deepgram') provider.deepgram = { model: 'nova-3', language: opts.language || 'en' };
|
|
53
|
+
else if (p === 'assemblyai') provider.assemblyai = { speech_models: ['best'], language_code: opts.language || 'en_us' };
|
|
54
|
+
else if (p === 'sarvam') provider.sarvam = { model: 'saarika:v2', language_code: opts.language || 'en-IN', mode: 'batch' };
|
|
55
|
+
else if (p === 'meetstream') provider.meetstream = { language: opts.language || 'auto', translate: false };
|
|
56
|
+
else if (p === 'jigsawstack') provider.jigsawstack = { language: opts.language || 'auto', translate: false };
|
|
57
|
+
else provider[p] = {};
|
|
58
|
+
const { data } = await getClient().transcribe(botId, provider, opts.callback);
|
|
59
|
+
if (opts.json) return printJson(data);
|
|
60
|
+
ok('Transcription started');
|
|
61
|
+
printJson(data);
|
|
62
|
+
} catch (e) { handleError(e, opts); }
|
|
63
|
+
});
|
|
64
|
+
}
|
package/src/config.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Config resolution: MEETSTREAM_API_KEY env var wins, else ~/.meetstream/config.json
|
|
2
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
|
|
6
|
+
const CONFIG_DIR = join(homedir(), '.meetstream');
|
|
7
|
+
const CONFIG_PATH = join(CONFIG_DIR, 'config.json');
|
|
8
|
+
|
|
9
|
+
export const BASE_URL = process.env.MEETSTREAM_API_URL || 'https://api.meetstream.ai/api/v1';
|
|
10
|
+
|
|
11
|
+
export function loadConfig() {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(readFileSync(CONFIG_PATH, 'utf8'));
|
|
14
|
+
} catch {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function saveConfig(patch) {
|
|
20
|
+
const cfg = { ...loadConfig(), ...patch };
|
|
21
|
+
if (!existsSync(CONFIG_DIR)) mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
22
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(cfg, null, 2) + '\n', { mode: 0o600 });
|
|
23
|
+
return CONFIG_PATH;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function resolveApiKey({ required = true } = {}) {
|
|
27
|
+
const key = process.env.MEETSTREAM_API_KEY || loadConfig().api_key;
|
|
28
|
+
if (!key && required) {
|
|
29
|
+
const err = new Error(
|
|
30
|
+
'No API key found. Set MEETSTREAM_API_KEY or run: meetstream auth set-key <key>\n' +
|
|
31
|
+
'Create a key at https://app.meetstream.ai/api-keys'
|
|
32
|
+
);
|
|
33
|
+
err.exitCode = 2;
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
return key;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { CONFIG_PATH };
|
package/src/output.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Terminal output helpers — zero-dependency colors + consistent JSON mode.
|
|
2
|
+
const tty = process.stdout.isTTY;
|
|
3
|
+
const c = (code) => (s) => (tty ? `\x1b[${code}m${s}\x1b[0m` : String(s));
|
|
4
|
+
export const bold = c('1');
|
|
5
|
+
export const dim = c('2');
|
|
6
|
+
export const green = c('32');
|
|
7
|
+
export const yellow = c('33');
|
|
8
|
+
export const red = c('31');
|
|
9
|
+
export const cyan = c('36');
|
|
10
|
+
|
|
11
|
+
export function printJson(obj) {
|
|
12
|
+
process.stdout.write(JSON.stringify(obj, null, 2) + '\n');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function ok(msg) { console.log(green('✓ ') + msg); }
|
|
16
|
+
export function warn(msg) { console.log(yellow('⚠ ') + msg); }
|
|
17
|
+
export function fail(msg) { console.error(red('✗ ') + msg); }
|
|
18
|
+
|
|
19
|
+
export function kv(pairs) {
|
|
20
|
+
const width = Math.max(...Object.keys(pairs).map((k) => k.length));
|
|
21
|
+
for (const [k, v] of Object.entries(pairs)) {
|
|
22
|
+
if (v === undefined || v === null || v === '') continue;
|
|
23
|
+
console.log(` ${dim(k.padEnd(width))} ${v}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Render transcript segments (speaker + transcript fields) as readable text. */
|
|
28
|
+
export function transcriptToText(segments) {
|
|
29
|
+
if (!Array.isArray(segments)) return typeof segments === 'string' ? segments : JSON.stringify(segments, null, 2);
|
|
30
|
+
return segments
|
|
31
|
+
.map((s) => `${s.speaker ?? 'Unknown'}: ${s.transcript ?? ''}`.trim())
|
|
32
|
+
.filter(Boolean)
|
|
33
|
+
.join('\n');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function handleError(err, { json = false } = {}) {
|
|
37
|
+
if (json) {
|
|
38
|
+
printJson({ error: err.message, status: err.status, body: err.body });
|
|
39
|
+
} else {
|
|
40
|
+
fail(err.message);
|
|
41
|
+
if (err.status === 401) console.error(dim(' Check your API key: https://app.meetstream.ai/api-keys'));
|
|
42
|
+
}
|
|
43
|
+
process.exit(err.exitCode || 1);
|
|
44
|
+
}
|