@meetstream/cli 0.2.0 → 0.6.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/CHANGELOG.md +29 -0
- package/README.md +171 -37
- package/bin/meetstream.js +6 -3
- package/package.json +4 -3
- package/src/api.js +236 -14
- package/src/commands/bot.js +88 -21
- package/src/commands/listen.js +23 -8
- package/src/commands/logins.js +292 -0
- package/src/commands/misc.js +96 -10
- package/src/commands/transcript.js +2 -1
- package/src/output.js +35 -2
- package/src/secrets.js +61 -0
- package/src/telemetry.js +1 -1
package/src/api.js
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
|
-
// MeetStream API client
|
|
1
|
+
// MeetStream API client - mirrors the live OpenAPI spec (https://docs.meetstream.ai/openapi.json)
|
|
2
2
|
// Auth: `Authorization: Token <key>` · Base: https://api.meetstream.ai/api/v1
|
|
3
3
|
import { BASE_URL } from './config.js';
|
|
4
4
|
|
|
5
5
|
export class ApiError extends Error {
|
|
6
|
-
constructor(message, { status, body, path } = {}) {
|
|
6
|
+
constructor(message, { status, body, path, retryAfter } = {}) {
|
|
7
7
|
super(message);
|
|
8
8
|
this.name = 'ApiError';
|
|
9
9
|
this.status = status;
|
|
10
10
|
this.body = body;
|
|
11
11
|
this.path = path;
|
|
12
|
+
// Seconds from the Retry-After header (429 rate limit, 409 while an
|
|
13
|
+
// idempotent create is still saving). undefined when the API sent none.
|
|
14
|
+
this.retryAfter = retryAfter;
|
|
12
15
|
}
|
|
13
16
|
}
|
|
14
17
|
|
|
18
|
+
/** Error text from a response body: message, then detail, then error, then a bare string. */
|
|
19
|
+
export function errorDetail(data) {
|
|
20
|
+
if (typeof data === 'object' && data !== null) {
|
|
21
|
+
return data.message || data.detail || data.error || JSON.stringify(data);
|
|
22
|
+
}
|
|
23
|
+
return String(data).slice(0, 300);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function retryAfterSeconds(res) {
|
|
27
|
+
const v = res.headers?.get?.('retry-after');
|
|
28
|
+
if (v == null || String(v).trim() === '') return undefined;
|
|
29
|
+
const n = Number(v);
|
|
30
|
+
if (Number.isFinite(n)) return Math.max(0, Math.ceil(n));
|
|
31
|
+
const when = Date.parse(v); // HTTP-date form
|
|
32
|
+
return Number.isNaN(when) ? undefined : Math.max(0, Math.ceil((when - Date.now()) / 1000));
|
|
33
|
+
}
|
|
34
|
+
|
|
15
35
|
export class MeetStreamClient {
|
|
16
36
|
constructor(apiKey, { baseUrl = BASE_URL, fetchImpl = fetch } = {}) {
|
|
17
37
|
this.apiKey = apiKey;
|
|
@@ -37,13 +57,12 @@ export class MeetStreamClient {
|
|
|
37
57
|
const text = await res.text();
|
|
38
58
|
let data;
|
|
39
59
|
try { data = text ? JSON.parse(text) : null; } catch { data = text; }
|
|
40
|
-
// 507 = idempotent replay of an existing bot
|
|
60
|
+
// 507 = idempotent replay of an existing bot - a success, not an error.
|
|
41
61
|
if (!res.ok && res.status !== 507) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
status: res.status, body: data, path,
|
|
62
|
+
const retryAfter = retryAfterSeconds(res);
|
|
63
|
+
const suffix = retryAfter !== undefined ? ` (retry after ${retryAfter} s)` : '';
|
|
64
|
+
throw new ApiError(`${method} ${path} → HTTP ${res.status}: ${errorDetail(data)}${suffix}`, {
|
|
65
|
+
status: res.status, body: data, path, retryAfter,
|
|
47
66
|
});
|
|
48
67
|
}
|
|
49
68
|
return { status: res.status, data };
|
|
@@ -57,14 +76,26 @@ export class MeetStreamClient {
|
|
|
57
76
|
listBots() { return this.request('GET', '/bots'); }
|
|
58
77
|
botStatus(botId) { return this.request('GET', `/bots/${botId}/status`); }
|
|
59
78
|
botDetail(botId) { return this.request('GET', `/bots/${botId}/detail`); }
|
|
60
|
-
botSummary(botId) { return this.request('GET', `/bots/${botId}/summary`); }
|
|
61
79
|
botAudio(botId) { return this.request('GET', `/bots/${botId}/get_audio`); }
|
|
62
80
|
botVideo(botId) { return this.request('GET', `/bots/${botId}/get_video`); }
|
|
63
81
|
recordingStreams(botId) { return this.request('GET', `/bots/${botId}/get_recording_streams`); }
|
|
64
82
|
audioStreams(botId) { return this.request('GET', `/bots/${botId}/get_audio_streams`); }
|
|
65
83
|
speakerTimeline(botId) { return this.request('GET', `/bots/${botId}/get_speaker_timeline`); }
|
|
84
|
+
/**
|
|
85
|
+
* A large speaker timeline comes back as { bot_id, speaker_timeline_url, size_bytes, truncated }
|
|
86
|
+
* instead of the timeline itself. This downloads the file from that pre-signed URL (valid 1 hour).
|
|
87
|
+
* The URL needs no API key, so no Authorization header is sent to it.
|
|
88
|
+
*/
|
|
89
|
+
async downloadSpeakerTimeline(url) {
|
|
90
|
+
const res = await this.fetch(url, { method: 'GET' });
|
|
91
|
+
const text = await res.text();
|
|
92
|
+
if (!res.ok) {
|
|
93
|
+
throw new ApiError(`GET speaker_timeline_url → HTTP ${res.status}: ${String(text).slice(0, 300)}`, { status: res.status, path: 'speaker_timeline_url' });
|
|
94
|
+
}
|
|
95
|
+
try { return JSON.parse(text); } catch { return text; }
|
|
96
|
+
}
|
|
66
97
|
chats(botId) { return this.request('GET', `/bots/${botId}/get_chats`); }
|
|
67
|
-
screenshots(botId) { return this.request('GET', `/bots/${botId}/
|
|
98
|
+
screenshots(botId) { return this.request('GET', `/bots/${botId}/screenshots`); }
|
|
68
99
|
participants(botId) { return this.request('GET', `/bots/${botId}/get_participants`); }
|
|
69
100
|
removeBot(botId) { return this.request('GET', `/bots/${botId}/remove_bot`); } // GET, not DELETE
|
|
70
101
|
deleteBotData(botId) { return this.request('DELETE', `/bots/${botId}/delete`); }
|
|
@@ -77,6 +108,13 @@ export class MeetStreamClient {
|
|
|
77
108
|
});
|
|
78
109
|
}
|
|
79
110
|
|
|
111
|
+
/** In-meeting command, e.g. raise_hand / lower_hand. The bot must be in the meeting. */
|
|
112
|
+
sendCommand(botId, command) {
|
|
113
|
+
return this.request('POST', `/bots/${botId}/send_command`, { body: { command } });
|
|
114
|
+
}
|
|
115
|
+
raiseHand(botId) { return this.sendCommand(botId, 'raise_hand'); }
|
|
116
|
+
lowerHand(botId) { return this.sendCommand(botId, 'lower_hand'); }
|
|
117
|
+
|
|
80
118
|
// ── Transcription ─────────────────────────────────────────────────────
|
|
81
119
|
transcriptions(botId) { return this.request('GET', `/bots/${botId}/transcriptions`); }
|
|
82
120
|
transcribe(botId, provider, callbackUrl) {
|
|
@@ -89,7 +127,7 @@ export class MeetStreamClient {
|
|
|
89
127
|
}
|
|
90
128
|
|
|
91
129
|
/**
|
|
92
|
-
* Resolve a bot's transcript_id. transcript_id is NOT delivered in webhooks
|
|
130
|
+
* Resolve a bot's transcript_id. transcript_id is NOT delivered in webhooks -
|
|
93
131
|
* canonical sources: GET /bots/{id}/detail (bot_details.transcript_id),
|
|
94
132
|
* the create_bot response, or GET /bots/{id}/transcriptions.
|
|
95
133
|
*/
|
|
@@ -120,7 +158,8 @@ export class MeetStreamClient {
|
|
|
120
158
|
return { transcript_id: tid, transcript: segments };
|
|
121
159
|
}
|
|
122
160
|
} catch (e) {
|
|
123
|
-
|
|
161
|
+
// 422 = the transcript failed: final, never poll it.
|
|
162
|
+
if (!wait || e.status === 422 || (e.status && e.status !== 404 && e.status !== 400)) throw e;
|
|
124
163
|
}
|
|
125
164
|
}
|
|
126
165
|
if (!wait || Date.now() > deadline) {
|
|
@@ -131,6 +170,10 @@ export class MeetStreamClient {
|
|
|
131
170
|
}
|
|
132
171
|
}
|
|
133
172
|
|
|
173
|
+
// ── Billing ───────────────────────────────────────────────────────────
|
|
174
|
+
/** Prepaid balance, read only. 404 while the endpoint is not on for the account. */
|
|
175
|
+
balance() { return this.request('GET', '/billing/balance'); }
|
|
176
|
+
|
|
134
177
|
// ── Calendar ──────────────────────────────────────────────────────────
|
|
135
178
|
connectCalendar({ clientId, clientSecret, refreshToken }) {
|
|
136
179
|
return this.request('POST', '/calendar/create_calendar', {
|
|
@@ -142,7 +185,7 @@ export class MeetStreamClient {
|
|
|
142
185
|
body: { google_client_id: clientId, google_client_secret: clientSecret, google_refresh_token: refreshToken },
|
|
143
186
|
});
|
|
144
187
|
}
|
|
145
|
-
listCalendars() { return this.request('GET', '/calendar'); }
|
|
188
|
+
listCalendars() { return this.request('GET', '/calendar/calendars'); }
|
|
146
189
|
calendarEvents() { return this.request('GET', '/calendar/events'); }
|
|
147
190
|
scheduleEvent(eventId) { return this.request('POST', `/calendar/schedule/${eventId}`); }
|
|
148
191
|
unscheduleEvent(eventId) { return this.request('DELETE', `/calendar/schedule/${eventId}`); }
|
|
@@ -162,9 +205,144 @@ export class MeetStreamClient {
|
|
|
162
205
|
|
|
163
206
|
// ── MIA (conversational agents) ───────────────────────────────────────
|
|
164
207
|
miaList() { return this.request('GET', '/mia'); }
|
|
208
|
+
miaGet(agentConfigId) { return this.request('GET', '/mia', { query: { agent_config_id: agentConfigId } }); }
|
|
165
209
|
miaCreate(config) { return this.request('POST', '/mia', { body: config }); }
|
|
210
|
+
/** PUT replaces each block you send; the body must carry agent_config_id. */
|
|
166
211
|
miaUpdate(config) { return this.request('PUT', '/mia', { body: config }); }
|
|
212
|
+
/** Test the connection to a local agent bridge (model.provider "local_agent"). */
|
|
213
|
+
miaCheckLocalAgent(agentConfigId) {
|
|
214
|
+
return this.request('GET', '/mia', { query: { agent_config_id: agentConfigId, check: 'local_agent' } });
|
|
215
|
+
}
|
|
167
216
|
miaDelete(agentConfigId) { return this.request('DELETE', '/mia', { query: { agent_config_id: agentConfigId } }); }
|
|
217
|
+
|
|
218
|
+
// ── Signed-in bots: Microsoft Teams logins ────────────────────────────
|
|
219
|
+
// Passwords are write-only: sent in the request body, never returned, never logged.
|
|
220
|
+
teamsDomainsList() { return this.request('GET', '/teams-login-domains'); }
|
|
221
|
+
teamsDomainGet(domain) { return this.request('GET', `/teams-login-domains/${enc(domain)}`); }
|
|
222
|
+
teamsDomainCreate({ domain, name } = {}) {
|
|
223
|
+
// login_mode "if_required" is not supported for Teams yet; always use "always".
|
|
224
|
+
return this.request('POST', '/teams-login-domains', {
|
|
225
|
+
body: { domain, ...(name ? { name } : {}), login_mode: 'always' },
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
teamsDomainUpdate(domain, { name } = {}) {
|
|
229
|
+
return this.request('PATCH', `/teams-login-domains/${enc(domain)}`, { body: { ...(name ? { name } : {}) } });
|
|
230
|
+
}
|
|
231
|
+
teamsDomainDelete(domain) { return this.request('DELETE', `/teams-login-domains/${enc(domain)}`); }
|
|
232
|
+
teamsLoginsList(domain) { return this.request('GET', '/teams-logins', { query: { domain } }); }
|
|
233
|
+
teamsLoginGet(loginId) { return this.request('GET', `/teams-logins/${enc(loginId)}`); }
|
|
234
|
+
teamsLoginCreate({ domain, email, password, isActive } = {}) {
|
|
235
|
+
return this.request('POST', '/teams-logins', {
|
|
236
|
+
body: { domain, email, password, ...(isActive !== undefined ? { is_active: Boolean(isActive) } : {}) },
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
teamsLoginUpdate(loginId, { password, isActive } = {}) {
|
|
240
|
+
const body = {};
|
|
241
|
+
if (password !== undefined) body.password = password; // a new password also reactivates the account
|
|
242
|
+
if (isActive !== undefined) body.is_active = Boolean(isActive);
|
|
243
|
+
return this.request('PATCH', `/teams-logins/${enc(loginId)}`, { body });
|
|
244
|
+
}
|
|
245
|
+
teamsLoginDelete(loginId) { return this.request('DELETE', `/teams-logins/${enc(loginId)}`); }
|
|
246
|
+
|
|
247
|
+
// ── Signed-in bots: Google Meet logins ────────────────────────────────
|
|
248
|
+
// Google domains are keyed by sso_workspace_domain; logins authenticate with an
|
|
249
|
+
// SSO private key + certificate (PEM), not a password. There is no GET-by-id for
|
|
250
|
+
// a Google login, and PATCH/DELETE on a login need the domain.
|
|
251
|
+
googleDomainsList() { return this.request('GET', '/google-login-domains'); }
|
|
252
|
+
googleDomainGet(domain) { return this.request('GET', `/google-login-domains/${enc(domain)}`); }
|
|
253
|
+
googleDomainCreate({ domain, name, loginMode = 'always' } = {}) {
|
|
254
|
+
return this.request('POST', '/google-login-domains', {
|
|
255
|
+
body: { sso_workspace_domain: domain, ...(name ? { name } : {}), login_mode: loginMode },
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
googleDomainUpdate(domain, { name, loginMode } = {}) {
|
|
259
|
+
return this.request('PATCH', `/google-login-domains/${enc(domain)}`, {
|
|
260
|
+
body: { ...(name ? { name } : {}), ...(loginMode ? { login_mode: loginMode } : {}) },
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
googleDomainDelete(domain) { return this.request('DELETE', `/google-login-domains/${enc(domain)}`); }
|
|
264
|
+
googleLoginsList(domain) { return this.request('GET', '/google-logins', { query: { domain } }); }
|
|
265
|
+
googleLoginCreate({ domain, email, privateKeyPem, certPem, isActive } = {}) {
|
|
266
|
+
return this.request('POST', '/google-logins', {
|
|
267
|
+
body: {
|
|
268
|
+
domain, email, sso_private_key_pem: privateKeyPem, sso_cert_pem: certPem,
|
|
269
|
+
...(isActive !== undefined ? { is_active: Boolean(isActive) } : {}),
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
googleLoginUpdate(loginId, { domain, isActive, privateKeyPem, certPem } = {}) {
|
|
274
|
+
const body = { domain };
|
|
275
|
+
if (isActive !== undefined) body.is_active = Boolean(isActive);
|
|
276
|
+
if (privateKeyPem !== undefined) body.sso_private_key_pem = privateKeyPem;
|
|
277
|
+
if (certPem !== undefined) body.sso_cert_pem = certPem;
|
|
278
|
+
return this.request('PATCH', `/google-logins/${enc(loginId)}`, { body });
|
|
279
|
+
}
|
|
280
|
+
googleLoginDelete(loginId, domain) {
|
|
281
|
+
return this.request('DELETE', `/google-logins/${enc(loginId)}`, { query: { domain } });
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const enc = (s) => encodeURIComponent(String(s));
|
|
286
|
+
|
|
287
|
+
// recording_config.video_layout values. The *_default layouts are Google Meet and Teams only (the API returns 400 on Zoom).
|
|
288
|
+
const VIDEO_LAYOUTS = ['speaker_view', 'grid_view', 'speaker_view_default', 'grid_view_default'];
|
|
289
|
+
const STORAGE_ID_RE = /^[A-Za-z0-9_-]{1,80}$/;
|
|
290
|
+
|
|
291
|
+
const TEAMS_HOSTS = ['teams.microsoft.com', 'teams.live.com', 'teams.cloud.microsoft'];
|
|
292
|
+
const GOOGLE_HOSTS = ['meet.google.com'];
|
|
293
|
+
|
|
294
|
+
function linkHost(link) {
|
|
295
|
+
try { return new URL(String(link)).hostname.toLowerCase(); } catch { return ''; }
|
|
296
|
+
}
|
|
297
|
+
const hostIn = (host, list) => list.some((h) => host === h || host.endsWith(`.${h}`));
|
|
298
|
+
|
|
299
|
+
function usageError(message) {
|
|
300
|
+
return Object.assign(new Error(message), { exitCode: 2 });
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Validate the signed-in bot flags and build the `google_meet` / `teams` block.
|
|
305
|
+
* Returns { key, block } or null when no signed-in flag is set. Throws (exitCode 2) on misuse.
|
|
306
|
+
*/
|
|
307
|
+
export function buildSignedInBlock(opts = {}) {
|
|
308
|
+
const { googleLoginDomain, teamsLoginDomain, signInEmail, strictEmail } = opts;
|
|
309
|
+
if (googleLoginDomain && teamsLoginDomain) {
|
|
310
|
+
throw usageError('Use either --google-login-domain or --teams-login-domain, not both (one meeting, one platform).');
|
|
311
|
+
}
|
|
312
|
+
const domain = googleLoginDomain || teamsLoginDomain;
|
|
313
|
+
if (!domain) {
|
|
314
|
+
if (signInEmail) throw usageError('--sign-in-email needs --google-login-domain or --teams-login-domain.');
|
|
315
|
+
if (strictEmail === false) throw usageError('--no-strict-email only applies together with --sign-in-email and a login domain flag.');
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
if (strictEmail === false && !signInEmail) {
|
|
319
|
+
throw usageError('--no-strict-email only applies together with --sign-in-email.');
|
|
320
|
+
}
|
|
321
|
+
const isTeams = Boolean(teamsLoginDomain);
|
|
322
|
+
const block = { login_required: true, [isTeams ? 'teams_login_domain' : 'google_login_domain']: domain };
|
|
323
|
+
if (signInEmail) {
|
|
324
|
+
block.sign_in_email = signInEmail;
|
|
325
|
+
block.strict_email = strictEmail !== false; // API default is true; false = fall back to any free account
|
|
326
|
+
}
|
|
327
|
+
return { key: isTeams ? 'teams' : 'google_meet', block };
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** Non-fatal warnings for signed-in bot flags (printed to stderr; the request is still sent). */
|
|
331
|
+
export function signedInWarnings(opts = {}) {
|
|
332
|
+
const warnings = [];
|
|
333
|
+
const host = linkHost(opts.meetingLink);
|
|
334
|
+
if (opts.teamsLoginDomain) {
|
|
335
|
+
if (!hostIn(host, TEAMS_HOSTS)) {
|
|
336
|
+
warnings.push(`--teams-login-domain is set but the meeting link host is "${host || opts.meetingLink}", not a Microsoft Teams host (teams.microsoft.com / teams.live.com). Sending anyway.`);
|
|
337
|
+
} else if (hostIn(host, ['teams.live.com'])) {
|
|
338
|
+
warnings.push('teams.live.com is personal Teams: signed-in bots only work with Microsoft 365 work/school Teams meetings.');
|
|
339
|
+
}
|
|
340
|
+
warnings.push('Signed-in Teams bots show the Microsoft account\'s own display name and picture; --name and --image-url are not applied.');
|
|
341
|
+
}
|
|
342
|
+
if (opts.googleLoginDomain && !hostIn(host, GOOGLE_HOSTS)) {
|
|
343
|
+
warnings.push(`--google-login-domain is set but the meeting link host is "${host || opts.meetingLink}", not meet.google.com. Sending anyway.`);
|
|
344
|
+
}
|
|
345
|
+
return warnings;
|
|
168
346
|
}
|
|
169
347
|
|
|
170
348
|
/** Build a create_bot payload from CLI-ish options, applying safe defaults. */
|
|
@@ -179,9 +357,49 @@ export function buildCreateBotPayload(opts) {
|
|
|
179
357
|
if (opts.callback) payload.callback_url = opts.callback;
|
|
180
358
|
if (opts.joinAt) payload.join_at = opts.joinAt;
|
|
181
359
|
if (opts.agentConfigId) payload.agent_config_id = opts.agentConfigId;
|
|
360
|
+
if (opts.agentConfigParams && Object.keys(opts.agentConfigParams).length) payload.agent_config_params = opts.agentConfigParams;
|
|
182
361
|
if (opts.separateAudio) payload.audio_separate_streams = true;
|
|
362
|
+
// Per-participant video is opt-in only: never set implicitly.
|
|
183
363
|
if (opts.separateVideo) payload.video_separate_streams = true;
|
|
184
|
-
|
|
364
|
+
|
|
365
|
+
// Audio only unless --video; with --video, speaker view unless --video-layout grid_view
|
|
366
|
+
// (the REST API defaults to grid_view, so the layout is always sent explicitly).
|
|
367
|
+
// video_layout applies to mixed video only, so audio-only bots never carry it.
|
|
368
|
+
if (payload.video_required) {
|
|
369
|
+
const layout = String(opts.videoLayout || 'speaker_view').toLowerCase();
|
|
370
|
+
if (!VIDEO_LAYOUTS.includes(layout)) {
|
|
371
|
+
throw usageError('--video-layout must be speaker_view or grid_view (Google Meet and Teams also accept speaker_view_default or grid_view_default).');
|
|
372
|
+
}
|
|
373
|
+
payload.recording_config = { ...(payload.recording_config || {}), video_layout: layout };
|
|
374
|
+
} else if (opts.videoLayout) {
|
|
375
|
+
throw usageError('--video-layout needs --video (an audio-only bot records no mixed video).');
|
|
376
|
+
}
|
|
377
|
+
if (opts.zoomObf) {
|
|
378
|
+
throw new Error('--zoom-obf was removed: the API rejects use_zoom_obf. Use --zoom-obf-url <https-url> or --zoom-zak-url <https-url>.');
|
|
379
|
+
}
|
|
380
|
+
// Authenticated Zoom joins: each URL is an HTTPS endpoint on the caller's server that returns a fresh token.
|
|
381
|
+
// Both need the account's own Zoom app, so they cannot go with --no-zoom-use-own-app.
|
|
382
|
+
if (opts.zoomUseOwnApp === false && (opts.zoomZakUrl || opts.zoomObfUrl)) {
|
|
383
|
+
throw usageError('--zoom-zak-url and --zoom-obf-url need your own Zoom app; they cannot be used with --no-zoom-use-own-app.');
|
|
384
|
+
}
|
|
385
|
+
if (opts.zoomZakUrl || opts.zoomObfUrl) {
|
|
386
|
+
payload.zoom = {};
|
|
387
|
+
if (opts.zoomZakUrl) payload.zoom.zak_url = opts.zoomZakUrl;
|
|
388
|
+
if (opts.zoomObfUrl) payload.zoom.obf_url = opts.zoomObfUrl;
|
|
389
|
+
}
|
|
390
|
+
// Zoom join choice. Omitted = automatic: no setup, or the account's own Zoom app when it has one.
|
|
391
|
+
if (typeof opts.zoomUseOwnApp === 'boolean') {
|
|
392
|
+
payload.zoom = { ...(payload.zoom || {}), use_own_app: opts.zoomUseOwnApp };
|
|
393
|
+
}
|
|
394
|
+
if (opts.storageId !== undefined) {
|
|
395
|
+
if (!STORAGE_ID_RE.test(String(opts.storageId))) {
|
|
396
|
+
throw usageError('--storage-id must be 1-80 letters, numbers, underscores or hyphens.');
|
|
397
|
+
}
|
|
398
|
+
payload.storage_id = String(opts.storageId);
|
|
399
|
+
}
|
|
400
|
+
// Signed-in bots: Google Meet (google_meet) or Microsoft Teams (teams) accounts registered via `meetstream logins`.
|
|
401
|
+
const signedIn = buildSignedInBlock(opts);
|
|
402
|
+
if (signedIn) payload[signedIn.key] = signedIn.block;
|
|
185
403
|
if (opts.liveTranscriptWebhook) payload.live_transcription_required = { webhook_url: opts.liveTranscriptWebhook };
|
|
186
404
|
if (opts.liveAudioWs) payload.live_audio_required = { websocket_url: opts.liveAudioWs };
|
|
187
405
|
if (opts.liveVideoWs) payload.live_video_required = { websocket_url: opts.liveVideoWs };
|
|
@@ -199,6 +417,9 @@ export function buildCreateBotPayload(opts) {
|
|
|
199
417
|
else if (p === 'meeting_captions') provider.meeting_captions = {};
|
|
200
418
|
else if (p === 'deepgram_streaming') provider.deepgram_streaming = { model: 'nova-3', language: opts.language || 'en' };
|
|
201
419
|
else if (p === 'assemblyai_streaming') provider.assemblyai_streaming = {};
|
|
420
|
+
// Smallest AI needs the account's Smallest AI key saved in the MeetStream dashboard.
|
|
421
|
+
else if (p === 'smallest') provider.smallest = { model: 'pulse', language: opts.language || 'en', diarize: true };
|
|
422
|
+
else if (p === 'smallest_streaming') provider.smallest_streaming = { model: 'pulse', language: opts.language || 'en' };
|
|
202
423
|
else provider[p] = {};
|
|
203
424
|
payload.recording_config = {
|
|
204
425
|
...(payload.recording_config || {}),
|
|
@@ -222,3 +443,4 @@ export function buildCreateBotPayload(opts) {
|
|
|
222
443
|
};
|
|
223
444
|
return payload;
|
|
224
445
|
}
|
|
446
|
+
|
package/src/commands/bot.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { buildCreateBotPayload } from '../api.js';
|
|
2
|
-
import { printJson, ok, kv, bold, dim, cyan, transcriptToText, handleError } from '../output.js';
|
|
1
|
+
import { buildCreateBotPayload, signedInWarnings } from '../api.js';
|
|
2
|
+
import { printJson, ok, kv, bold, dim, cyan, transcriptToText, handleError, warnErr } from '../output.js';
|
|
3
3
|
|
|
4
|
-
function parseAttrs(list = []) {
|
|
4
|
+
function parseAttrs(list = [], flag = '--attr') {
|
|
5
5
|
const out = {};
|
|
6
6
|
for (const item of list) {
|
|
7
7
|
const i = item.indexOf('=');
|
|
8
|
-
if (i === -1) throw Object.assign(new Error(
|
|
8
|
+
if (i === -1) throw Object.assign(new Error(`${flag} expects key=value, got "${item}"`), { exitCode: 2 });
|
|
9
9
|
out[item.slice(0, i)] = item.slice(i + 1); // values kept as strings (API expects strings)
|
|
10
10
|
}
|
|
11
11
|
return out;
|
|
@@ -16,24 +16,36 @@ export function registerBotCommands(program, getClient) {
|
|
|
16
16
|
|
|
17
17
|
bot
|
|
18
18
|
.command('create')
|
|
19
|
-
.description('Send a bot to a meeting (or schedule with --join-at)')
|
|
19
|
+
.description('Send a bot to a meeting (or schedule with --join-at). Zoom needs no setup: the API key and the link are enough')
|
|
20
20
|
.argument('<meeting-link>', 'Zoom / Google Meet / Teams meeting URL')
|
|
21
21
|
.option('-n, --name <name>', 'bot display name', 'MeetStream Bot')
|
|
22
|
-
.option('--video', 'record video (default: audio only)')
|
|
23
|
-
.option('-
|
|
22
|
+
.option('--video', 'record video as well as audio (default: audio only)')
|
|
23
|
+
.option('--video-layout <layout>', 'with --video: speaker_view (default) or grid_view; Google Meet and Teams also accept speaker_view_default, grid_view_default')
|
|
24
|
+
.option('-t, --transcript <provider>', 'deepgram | assemblyai | sarvam | meetstream | jigsawstack | smallest | meeting_captions | deepgram_streaming | assemblyai_streaming | smallest_streaming (smallest* need your Smallest AI key saved in the dashboard)')
|
|
24
25
|
.option('-l, --language <lang>', 'transcription language (provider-specific format)')
|
|
25
26
|
.option('-c, --callback <url>', 'HTTPS webhook for lifecycle events')
|
|
26
27
|
.option('--join-at <iso8601>', 'schedule a future join, e.g. 2026-07-02T15:00:00Z')
|
|
27
28
|
.option('--bot-message <msg>', 'chat message posted when the bot joins')
|
|
28
29
|
.option('--image-url <url>', 'PUBLIC image URL for the bot avatar')
|
|
29
|
-
.option('--retention-hours <n>', 'data retention window (
|
|
30
|
+
.option('--retention-hours <n>', 'data retention window in hours (API default 720, i.e. 30 days)')
|
|
30
31
|
.option('--separate-audio', 'capture per-participant audio streams')
|
|
31
|
-
.option('--separate-video', 'capture per-participant video streams')
|
|
32
|
-
.option('--zoom-
|
|
33
|
-
.option('--
|
|
32
|
+
.option('--separate-video', 'capture per-participant video streams (opt-in; off unless you pass this)')
|
|
33
|
+
.option('--zoom-zak-url <url>', 'Zoom: HTTPS endpoint on your server returning a ZAK token (join as a signed-in user)')
|
|
34
|
+
.option('--zoom-obf-url <url>', 'Zoom: HTTPS endpoint on your server returning an OBF token (join on behalf of a user in the meeting)')
|
|
35
|
+
.option('--zoom-obf', 'removed: use --zoom-obf-url')
|
|
36
|
+
.option('--zoom-use-own-app', 'Zoom: always join with your own Zoom app (default: automatic, no setup unless the account has its own Zoom app)')
|
|
37
|
+
.option('--no-zoom-use-own-app', 'Zoom: always join with no setup (cannot be combined with --zoom-zak-url / --zoom-obf-url)')
|
|
38
|
+
.option('--storage-id <id>', 'save the recording to this storage destination of your workspace (default: the workspace default)')
|
|
39
|
+
.option('--google-login-domain <domain>', 'Google Meet: join signed in with an account from this registered Workspace domain (see: meetstream logins google)')
|
|
40
|
+
.option('--teams-login-domain <domain>', 'Teams: join signed in with an account from this registered Microsoft 365 domain (see: meetstream logins teams)')
|
|
41
|
+
.option('--sign-in-email <email>', 'signed-in bots: pin one registered account (needs a login domain flag)')
|
|
42
|
+
.option('--no-strict-email', 'with --sign-in-email: fall back to any free account in the domain instead of failing')
|
|
43
|
+
.option('--agent-config <id>', 'attach a voice agent (Agents API): the agent_config_id from "meetstream mia create". Nothing else is needed')
|
|
44
|
+
.option('--agent-config-id <id>', 'same as --agent-config')
|
|
45
|
+
.option('--agent-param <key=value...>', 'agent_config_params: values for {{variable}} placeholders in the agent prompt')
|
|
34
46
|
.option('--live-transcript-webhook <url>', 'webhook URL for live transcript chunks')
|
|
35
47
|
.option('--live-audio-ws <wss>', 'WebSocket URL for live audio out')
|
|
36
|
-
.option('--live-video-ws <wss>', '
|
|
48
|
+
.option('--live-video-ws <wss>', 'reserved: the API accepts live_video_required.websocket_url but does not deliver live video yet')
|
|
37
49
|
.option('--socket-ws <wss>', 'two-way bot-control WebSocket (socket_connection_url)')
|
|
38
50
|
.option('--attr <key=value...>', 'custom_attributes entries (echoed back in webhooks)')
|
|
39
51
|
.option('--idempotency-key <uuid>', 'safe-retry key (retry returns HTTP 507 with the original bot)')
|
|
@@ -43,11 +55,11 @@ export function registerBotCommands(program, getClient) {
|
|
|
43
55
|
.option('--json', 'JSON output')
|
|
44
56
|
.action(async (meetingLink, opts) => {
|
|
45
57
|
try {
|
|
46
|
-
const client = getClient();
|
|
47
58
|
const payload = buildCreateBotPayload({
|
|
48
59
|
meetingLink,
|
|
49
60
|
name: opts.name,
|
|
50
61
|
video: opts.video,
|
|
62
|
+
videoLayout: opts.videoLayout,
|
|
51
63
|
transcript: opts.transcript,
|
|
52
64
|
language: opts.language,
|
|
53
65
|
callback: opts.callback,
|
|
@@ -58,7 +70,16 @@ export function registerBotCommands(program, getClient) {
|
|
|
58
70
|
separateAudio: opts.separateAudio,
|
|
59
71
|
separateVideo: opts.separateVideo,
|
|
60
72
|
zoomObf: opts.zoomObf,
|
|
61
|
-
|
|
73
|
+
zoomZakUrl: opts.zoomZakUrl,
|
|
74
|
+
zoomObfUrl: opts.zoomObfUrl,
|
|
75
|
+
zoomUseOwnApp: opts.zoomUseOwnApp,
|
|
76
|
+
storageId: opts.storageId,
|
|
77
|
+
googleLoginDomain: opts.googleLoginDomain,
|
|
78
|
+
teamsLoginDomain: opts.teamsLoginDomain,
|
|
79
|
+
signInEmail: opts.signInEmail,
|
|
80
|
+
strictEmail: opts.strictEmail,
|
|
81
|
+
agentConfigId: opts.agentConfig || opts.agentConfigId,
|
|
82
|
+
agentConfigParams: parseAttrs(opts.agentParam, '--agent-param'),
|
|
62
83
|
liveTranscriptWebhook: opts.liveTranscriptWebhook,
|
|
63
84
|
liveAudioWs: opts.liveAudioWs,
|
|
64
85
|
liveVideoWs: opts.liveVideoWs,
|
|
@@ -68,9 +89,13 @@ export function registerBotCommands(program, getClient) {
|
|
|
68
89
|
waitingRoomTimeout: opts.waitingRoomTimeout,
|
|
69
90
|
maxRecordingSeconds: opts.maxRecordingSeconds,
|
|
70
91
|
});
|
|
71
|
-
|
|
92
|
+
if (payload.agent_config_id && (opts.socketWs || opts.liveAudioWs)) {
|
|
93
|
+
warnErr('A voice agent needs only --agent-config. --socket-ws / --live-audio-ws are for your own bridge and are the usual cause of a silent agent.');
|
|
94
|
+
}
|
|
95
|
+
for (const w of signedInWarnings({ meetingLink, googleLoginDomain: opts.googleLoginDomain, teamsLoginDomain: opts.teamsLoginDomain })) warnErr(w);
|
|
96
|
+
const { status, data } = await getClient().createBot(payload, { idempotencyKey: opts.idempotencyKey });
|
|
72
97
|
if (opts.json) return printJson(data);
|
|
73
|
-
ok(status === 507 ? 'Idempotent replay
|
|
98
|
+
ok(status === 507 ? 'Idempotent replay - existing bot returned (no new bot created)' : 'Bot created');
|
|
74
99
|
kv({ bot_id: bold(data.bot_id), transcript_id: data.transcript_id || dim('(pending)'), status: data.status, meeting: data.meeting_url });
|
|
75
100
|
console.log(dim(`\n Next: meetstream bot status ${data.bot_id} --watch`));
|
|
76
101
|
if (payload.recording_config?.transcript) console.log(dim(` meetstream transcript ${data.bot_id} --wait`));
|
|
@@ -120,12 +145,10 @@ export function registerBotCommands(program, getClient) {
|
|
|
120
145
|
|
|
121
146
|
const simpleGets = [
|
|
122
147
|
['detail', 'botDetail', 'Full session metadata (incl. transcript_id + caption_file)'],
|
|
123
|
-
['
|
|
124
|
-
['
|
|
125
|
-
['video', 'botVideo', 'Recorded video URL (presigned S3, valid 10min)'],
|
|
148
|
+
['audio', 'botAudio', 'Recorded audio download link (valid 1 hour)'],
|
|
149
|
+
['video', 'botVideo', 'Recorded video download link (valid 1 hour)'],
|
|
126
150
|
['streams', 'recordingStreams', 'Per-participant video streams (needs --separate-video at create)'],
|
|
127
151
|
['audio-streams', 'audioStreams', 'Per-participant audio streams (needs --separate-audio at create)'],
|
|
128
|
-
['timeline', 'speakerTimeline', 'Speaker timeline (who spoke when)'],
|
|
129
152
|
['chats', 'chats', 'In-meeting chat messages'],
|
|
130
153
|
['screenshots', 'screenshots', 'Screenshots captured during the meeting'],
|
|
131
154
|
['participants', 'participants', 'Participant list'],
|
|
@@ -139,7 +162,51 @@ export function registerBotCommands(program, getClient) {
|
|
|
139
162
|
.action(async (botId, opts) => {
|
|
140
163
|
try {
|
|
141
164
|
const { data } = await getClient()[method](botId);
|
|
142
|
-
printJson(data); // structured data
|
|
165
|
+
printJson(data); // structured data - JSON is the honest default
|
|
166
|
+
} catch (e) { handleError(e, opts); }
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
bot
|
|
171
|
+
.command('timeline')
|
|
172
|
+
.description('Speaker timeline (who spoke when). A very large timeline comes back as a download link; --download fetches it')
|
|
173
|
+
.argument('<bot-id>')
|
|
174
|
+
.option('--download', 'when the API returns speaker_timeline_url, download the file and print the timeline')
|
|
175
|
+
.option('--json', 'JSON output')
|
|
176
|
+
.action(async (botId, opts) => {
|
|
177
|
+
try {
|
|
178
|
+
const client = getClient();
|
|
179
|
+
const { data } = await client.speakerTimeline(botId);
|
|
180
|
+
const url = data && typeof data === 'object' && !Array.isArray(data) ? data.speaker_timeline_url : undefined;
|
|
181
|
+
if (url && opts.download) return printJson(await client.downloadSpeakerTimeline(url));
|
|
182
|
+
if (url) warnErr(`The timeline is ${data.size_bytes ?? 'too many'} bytes, so the API returned a download link (valid 1 hour). Run again with --download to fetch it.`);
|
|
183
|
+
printJson(data);
|
|
184
|
+
} catch (e) { handleError(e, opts); }
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
bot
|
|
188
|
+
.command('summary')
|
|
189
|
+
.description('Removed: the API has no summary endpoint. Use: meetstream transcript <bot-id>')
|
|
190
|
+
.argument('<bot-id>')
|
|
191
|
+
.option('--json', 'JSON output')
|
|
192
|
+
.action((botId, opts) => {
|
|
193
|
+
const err = new Error(`MeetStream has no meeting summary endpoint. Fetch the transcript and summarize it: meetstream transcript ${botId}`);
|
|
194
|
+
err.exitCode = 2;
|
|
195
|
+
handleError(err, opts);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
for (const [name, method, label] of [['raise-hand', 'raiseHand', 'raised'], ['lower-hand', 'lowerHand', 'lowered']]) {
|
|
199
|
+
bot
|
|
200
|
+
.command(name)
|
|
201
|
+
.description(`${label === 'raised' ? 'Raise' : 'Lower'} the bot's hand in the live meeting (Google Meet, Zoom, Teams; the bot must be in the meeting)`)
|
|
202
|
+
.argument('<bot-id>')
|
|
203
|
+
.option('--json', 'JSON output')
|
|
204
|
+
.action(async (botId, opts) => {
|
|
205
|
+
try {
|
|
206
|
+
const { data } = await getClient()[method](botId);
|
|
207
|
+
if (opts.json) return printJson(data);
|
|
208
|
+
ok(`Hand ${label}`);
|
|
209
|
+
kv({ hand_raised: String(data?.hand_raised ?? '(not reported)') });
|
|
143
210
|
} catch (e) { handleError(e, opts); }
|
|
144
211
|
});
|
|
145
212
|
}
|
package/src/commands/listen.js
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
// `meetstream listen`
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// `meetstream listen` - local webhook receiver for MeetStream lifecycle events.
|
|
2
|
+
// Verified against 4,139 captured webhooks: every delivery carries `event`, most
|
|
3
|
+
// also carry `bot_event`. Terminals are two-layer: every ending arrives once as
|
|
4
|
+
// event "bot.stopped" and bot_event says why (bot.stopped | bot.kicked |
|
|
5
|
+
// bot.notallowed | bot.denied | bot.failed). bot.done is the final event.
|
|
6
|
+
// Branch on bot_event: a kick and a clean exit both report bot_status "Stopped".
|
|
5
7
|
import { createServer } from 'node:http';
|
|
6
8
|
import { bold, dim, green, yellow, red, cyan } from '../output.js';
|
|
7
9
|
|
|
8
10
|
const TERMINAL = new Set(['bot.stopped', 'bot.done']);
|
|
9
11
|
const FAILY = /denied|notallowed|failed|error/i;
|
|
12
|
+
const ABNORMAL_STOP = new Set(['bot.kicked', 'bot.notallowed', 'bot.denied', 'bot.failed']);
|
|
13
|
+
|
|
14
|
+
function stopReason(payload) {
|
|
15
|
+
if (payload?.bot_event) return payload.bot_event;
|
|
16
|
+
const st = String(payload?.bot_status || '').toLowerCase();
|
|
17
|
+
if (st === 'notallowed') return 'bot.notallowed';
|
|
18
|
+
if (st === 'denied') return 'bot.denied';
|
|
19
|
+
if (st === 'error' || st === 'failed') return 'bot.failed';
|
|
20
|
+
return 'bot.stopped';
|
|
21
|
+
}
|
|
10
22
|
|
|
11
23
|
function colorFor(event, payload) {
|
|
12
|
-
if (event === 'transcription.failed'
|
|
24
|
+
if (event === 'transcription.failed') return red;
|
|
25
|
+
if (event === 'bot.stopped' && ABNORMAL_STOP.has(stopReason(payload))) return red;
|
|
26
|
+
if (FAILY.test(payload?.bot_status || '')) return red;
|
|
13
27
|
if (TERMINAL.has(event)) return yellow;
|
|
14
28
|
if (/\.processed$|manifest\.completed/.test(event)) return green;
|
|
15
29
|
return cyan;
|
|
@@ -42,6 +56,7 @@ export function registerListenCommand(program) {
|
|
|
42
56
|
const bits = [
|
|
43
57
|
dim(time),
|
|
44
58
|
paint(bold(event)),
|
|
59
|
+
payload.bot_event && payload.bot_event !== event ? paint(`(${payload.bot_event})`) : '',
|
|
45
60
|
payload.bot_status ? `status=${payload.bot_status}` : '',
|
|
46
61
|
payload.status_code !== undefined ? `code=${payload.status_code}` : '',
|
|
47
62
|
payload.bot_id ? dim(String(payload.bot_id).slice(0, 8)) : '',
|
|
@@ -51,8 +66,8 @@ export function registerListenCommand(program) {
|
|
|
51
66
|
if (event === 'transcription.processed' && payload.bot_id) {
|
|
52
67
|
console.log(dim(` → meetstream transcript ${payload.bot_id}`));
|
|
53
68
|
}
|
|
54
|
-
if (event === 'bot.stopped' &&
|
|
55
|
-
console.log(red(` bot ended abnormally (bot_status=${payload.bot_status})`));
|
|
69
|
+
if (event === 'bot.stopped' && ABNORMAL_STOP.has(stopReason(payload))) {
|
|
70
|
+
console.log(red(` bot ended abnormally (${stopReason(payload)}, bot_status=${payload.bot_status})`));
|
|
56
71
|
}
|
|
57
72
|
}
|
|
58
73
|
|
|
@@ -66,7 +81,7 @@ export function registerListenCommand(program) {
|
|
|
66
81
|
console.log(`${green('▶')} listening on ${bold(`http://localhost:${port}${opts.path === '/webhook' ? '/webhook' : opts.path}`)}`);
|
|
67
82
|
console.log(dim(' expose it: ngrok http ' + port));
|
|
68
83
|
console.log(dim(' then create a bot with: --callback https://<your-ngrok>.ngrok.io/webhook'));
|
|
69
|
-
console.log(dim('
|
|
84
|
+
console.log(dim(' terminals arrive as bot.stopped; the reason is in bot_event · Ctrl-C to stop\n'));
|
|
70
85
|
});
|
|
71
86
|
});
|
|
72
87
|
}
|