@speakai/mcp-server 1.42.2 → 1.43.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/README.md +2 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +617 -84
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -407,6 +407,7 @@ SPEAK_API_KEY=your-key npx @speakai/mcp-server
|
|
|
407
407
|
| `SPEAK_API_KEY` | Yes | -- | Your Speak AI API key |
|
|
408
408
|
| `SPEAK_ACCESS_TOKEN` | No | Auto-managed | JWT access token (auto-fetched and refreshed) |
|
|
409
409
|
| `SPEAK_BASE_URL` | No | `https://api.speakai.co` | API base URL |
|
|
410
|
+
| `SPEAK_MCP_CARDS` | No | -- | Set to `true` to show the file list card for list_media and search_media in chat apps that support MCP Apps |
|
|
410
411
|
|
|
411
412
|
### MCP Tools
|
|
412
413
|
|
|
@@ -456,7 +457,7 @@ SPEAK_API_KEY=your-key npx @speakai/mcp-server
|
|
|
456
457
|
| `export_chat_answer` | Export a conversation or answer |
|
|
457
458
|
| `get_analysis_quote` | Check if a file can be analysed as audio/video and what it costs |
|
|
458
459
|
|
|
459
|
-
`ask_ai_chat`, `retry_ai_chat` and `get_analysis_quote` register only with `aiChat: true`. The stdio server
|
|
460
|
+
`ask_ai_chat`, `retry_ai_chat` and `get_analysis_quote` register only with `aiChat: true` or `aiChatAnswerOnly: true`. The stdio server uses `aiChat`, where Speak's assistant can call other tools. The hosted endpoint uses `aiChatAnswerOnly`: for AI-assistant connections the assistant answers only from the person's recordings and does not take actions in other apps.
|
|
460
461
|
|
|
461
462
|
The automation tools, `build_automation`, `provision_inbound_webhook`, `get_inbound_webhook` and `get_webhook_attempts` register only with `automations: true`, and `get_voice_test_run` and `apply_voice_test_recommendation` only with `voiceTestRunDetails: true`. The stdio server includes them; the hosted endpoint does not, because automation steps can run actions in connected third-party apps. On the hosted endpoint, set up automations in the Speak AI web app.
|
|
462
463
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,12 +6,30 @@ export interface RegisterOptions {
|
|
|
6
6
|
localFileAccess?: boolean;
|
|
7
7
|
/** Register the voice test-run tools (start, pause, resume, cancel, results). Defaults to true; pass false to leave them off. */
|
|
8
8
|
voiceTestRuns?: boolean;
|
|
9
|
-
/** Register ask_ai_chat, retry_ai_chat and get_analysis_quote. Speak's assistant behind them can call other tools
|
|
9
|
+
/** Register ask_ai_chat, retry_ai_chat and get_analysis_quote. Speak's assistant behind them can call other tools. */
|
|
10
10
|
aiChat?: boolean;
|
|
11
|
+
/** Register the same AI Chat tools with answer-only descriptions. For the hosted server: Speak runs chat from AI-assistant connections with read tools over the person's recordings only, and no actions in other apps. */
|
|
12
|
+
aiChatAnswerOnly?: boolean;
|
|
11
13
|
/** Register the automation tools, build_automation and the inbound-webhook tools. Automation steps can run actions in connected third-party apps, so the hosted server leaves this off. */
|
|
12
14
|
automations?: boolean;
|
|
13
15
|
/** Register get_voice_test_run and apply_voice_test_recommendation. The hosted server leaves this off. */
|
|
14
16
|
voiceTestRunDetails?: boolean;
|
|
17
|
+
/** Register the file list card (MCP Apps resource ui://speak/media-list) and show it for list_media and search_media. Off by default. */
|
|
18
|
+
cards?: boolean;
|
|
19
|
+
/** Receives one usage event per tool call. Events never carry tool arguments, results or user text. Off when not set. */
|
|
20
|
+
onToolCall?: (event: ToolCallEvent) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** One tool call. `refusal` and `status` are set only when `ok` is false and the API gave them. */
|
|
24
|
+
export interface ToolCallEvent {
|
|
25
|
+
event: "mcp.tool.call";
|
|
26
|
+
tool: string;
|
|
27
|
+
ok: boolean;
|
|
28
|
+
/** The API's refusal reason, such as running out of credits. */
|
|
29
|
+
refusal?: string;
|
|
30
|
+
/** HTTP status of the failing API call. */
|
|
31
|
+
status?: number;
|
|
32
|
+
durationMs: number;
|
|
15
33
|
}
|
|
16
34
|
|
|
17
35
|
export declare function registerAllTools(
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,7 @@ __export(client_exports, {
|
|
|
41
41
|
getApiRefusal: () => getApiRefusal,
|
|
42
42
|
instrumentSpeakClient: () => instrumentSpeakClient,
|
|
43
43
|
isFailedBody: () => isFailedBody,
|
|
44
|
+
noteToolFailure: () => noteToolFailure,
|
|
44
45
|
runToolCall: () => runToolCall,
|
|
45
46
|
speakClient: () => speakClient
|
|
46
47
|
});
|
|
@@ -70,6 +71,12 @@ function formatRefusal(refusal) {
|
|
|
70
71
|
return typeof refusal.checkoutUrl === "string" && refusal.checkoutUrl ? `${lead}
|
|
71
72
|
Continue here: ${refusal.checkoutUrl}` : lead;
|
|
72
73
|
}
|
|
74
|
+
function noteToolFailure(value, refusal = getApiRefusal(value)) {
|
|
75
|
+
const context = toolCallContext.getStore();
|
|
76
|
+
if (!context) return;
|
|
77
|
+
if (refusal) context.refusal = refusal;
|
|
78
|
+
if (import_axios.default.isAxiosError(value) && value.response) context.status = value.response.status;
|
|
79
|
+
}
|
|
73
80
|
function instrumentSpeakClient(client) {
|
|
74
81
|
if (!client?.interceptors || instrumentedClients.has(client)) return client;
|
|
75
82
|
instrumentedClients.add(client);
|
|
@@ -78,22 +85,17 @@ function instrumentSpeakClient(client) {
|
|
|
78
85
|
if (toolName) config.headers.set(TOOL_NAME_HEADER, toolName);
|
|
79
86
|
return config;
|
|
80
87
|
});
|
|
81
|
-
const keepRefusal = (value) => {
|
|
82
|
-
const context = toolCallContext.getStore();
|
|
83
|
-
const refusal = getApiRefusal(value);
|
|
84
|
-
if (context && refusal) context.refusal = refusal;
|
|
85
|
-
};
|
|
86
88
|
client.interceptors.response.use(
|
|
87
89
|
(response) => {
|
|
88
90
|
if (!isFailedBody(response.data)) return response;
|
|
89
|
-
|
|
91
|
+
noteToolFailure(response.data);
|
|
90
92
|
const message = getApiRefusal(response.data) ? formatRefusal(response.data) : String(response.data.message ?? "The API reported that the request failed.");
|
|
91
93
|
return Promise.reject(
|
|
92
94
|
new import_axios.default.AxiosError(message, "ERR_BAD_RESPONSE", response.config, response.request, response)
|
|
93
95
|
);
|
|
94
96
|
},
|
|
95
97
|
(error) => {
|
|
96
|
-
|
|
98
|
+
noteToolFailure(error);
|
|
97
99
|
return Promise.reject(error);
|
|
98
100
|
}
|
|
99
101
|
);
|
|
@@ -274,6 +276,7 @@ var init_client = __esm({
|
|
|
274
276
|
|
|
275
277
|
// src/tools/_helpers.ts
|
|
276
278
|
function refusalResult(refusal) {
|
|
279
|
+
noteToolFailure(refusal, refusal);
|
|
277
280
|
return {
|
|
278
281
|
content: [{ type: "text", text: formatRefusal(refusal) }],
|
|
279
282
|
structuredContent: { data: refusal },
|
|
@@ -297,6 +300,7 @@ function ok(data) {
|
|
|
297
300
|
};
|
|
298
301
|
}
|
|
299
302
|
function err(error) {
|
|
303
|
+
noteToolFailure(error);
|
|
300
304
|
const refusal = getApiRefusal(error);
|
|
301
305
|
if (refusal) return refusalResult(refusal);
|
|
302
306
|
return {
|
|
@@ -304,7 +308,7 @@ function err(error) {
|
|
|
304
308
|
isError: true
|
|
305
309
|
};
|
|
306
310
|
}
|
|
307
|
-
function registerSpeakTool(server, name, description, inputSchema, annotations, handler) {
|
|
311
|
+
function registerSpeakTool(server, name, description, inputSchema, annotations, handler, toolMeta) {
|
|
308
312
|
const registerTool = server.registerTool.bind(server);
|
|
309
313
|
return registerTool(
|
|
310
314
|
name,
|
|
@@ -313,40 +317,69 @@ function registerSpeakTool(server, name, description, inputSchema, annotations,
|
|
|
313
317
|
description,
|
|
314
318
|
inputSchema,
|
|
315
319
|
outputSchema: passthroughOutputSchema,
|
|
316
|
-
annotations
|
|
320
|
+
annotations,
|
|
321
|
+
...toolMeta ? { _meta: toolMeta } : {}
|
|
317
322
|
},
|
|
318
323
|
async (args2, extra) => runToolCall(name, async (context) => {
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
return refusalResult(context.refusal);
|
|
322
|
-
}
|
|
323
|
-
if (result.isError || result.structuredContent) {
|
|
324
|
-
return result;
|
|
325
|
-
}
|
|
326
|
-
const textContent = result.content?.find(
|
|
327
|
-
(item) => item.type === "text"
|
|
328
|
-
);
|
|
329
|
-
if (!textContent) {
|
|
330
|
-
return { ...result, structuredContent: { data: null } };
|
|
331
|
-
}
|
|
332
|
-
let data;
|
|
324
|
+
const startedAt = performance.now();
|
|
325
|
+
let result;
|
|
333
326
|
try {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
327
|
+
result = normalizeToolResult(await handler(args2, extra), context);
|
|
328
|
+
return result;
|
|
329
|
+
} finally {
|
|
330
|
+
reportToolCall(server, name, startedAt, result, context);
|
|
337
331
|
}
|
|
338
|
-
const refusal = getApiRefusal(data);
|
|
339
|
-
if (refusal) return refusalResult(refusal);
|
|
340
|
-
return { ...result, structuredContent: { data } };
|
|
341
332
|
})
|
|
342
333
|
);
|
|
343
334
|
}
|
|
344
|
-
|
|
335
|
+
function normalizeToolResult(result, context) {
|
|
336
|
+
if (result.isError && context.refusal) {
|
|
337
|
+
return refusalResult(context.refusal);
|
|
338
|
+
}
|
|
339
|
+
if (result.isError || result.structuredContent) {
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
const textContent = result.content?.find(
|
|
343
|
+
(item) => item.type === "text"
|
|
344
|
+
);
|
|
345
|
+
if (!textContent) {
|
|
346
|
+
return { ...result, structuredContent: { data: null } };
|
|
347
|
+
}
|
|
348
|
+
let data;
|
|
349
|
+
try {
|
|
350
|
+
data = JSON.parse(textContent.text);
|
|
351
|
+
} catch {
|
|
352
|
+
return { ...result, structuredContent: { data: textContent.text } };
|
|
353
|
+
}
|
|
354
|
+
const refusal = getApiRefusal(data);
|
|
355
|
+
if (refusal) return refusalResult(refusal);
|
|
356
|
+
return { ...result, structuredContent: { data } };
|
|
357
|
+
}
|
|
358
|
+
function setToolCallListener(server, listener) {
|
|
359
|
+
toolCallListeners.set(server, listener);
|
|
360
|
+
}
|
|
361
|
+
function reportToolCall(server, tool, startedAt, result, context) {
|
|
362
|
+
const listener = toolCallListeners.get(server);
|
|
363
|
+
if (!listener) return;
|
|
364
|
+
const ok2 = result !== void 0 && !result.isError;
|
|
365
|
+
const event = { event: "mcp.tool.call", tool, ok: ok2, durationMs: Math.round(performance.now() - startedAt) };
|
|
366
|
+
if (!ok2 && context.refusal) {
|
|
367
|
+
event.refusal = typeof context.refusal.reason === "string" ? context.refusal.reason : "declined";
|
|
368
|
+
}
|
|
369
|
+
if (!ok2 && context.status !== void 0) event.status = context.status;
|
|
370
|
+
try {
|
|
371
|
+
listener(event);
|
|
372
|
+
} catch {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
var import_zod, toolCallListeners, passthroughOutputSchema, fieldIdSchema, SHARED_DASHBOARD_CACHE_NOTE;
|
|
345
377
|
var init_helpers = __esm({
|
|
346
378
|
"src/tools/_helpers.ts"() {
|
|
347
379
|
"use strict";
|
|
348
380
|
import_zod = require("zod");
|
|
349
381
|
init_client();
|
|
382
|
+
toolCallListeners = /* @__PURE__ */ new WeakMap();
|
|
350
383
|
passthroughOutputSchema = {
|
|
351
384
|
data: import_zod.z.unknown().describe("Response payload from the Speak AI API")
|
|
352
385
|
};
|
|
@@ -357,6 +390,88 @@ var init_helpers = __esm({
|
|
|
357
390
|
}
|
|
358
391
|
});
|
|
359
392
|
|
|
393
|
+
// src/ui/media-list/card-data.ts
|
|
394
|
+
function isRecord2(value) {
|
|
395
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
396
|
+
}
|
|
397
|
+
function nonEmptyString(value) {
|
|
398
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
399
|
+
}
|
|
400
|
+
function durationSecondsOf(value) {
|
|
401
|
+
if (!isRecord2(value)) return void 0;
|
|
402
|
+
const seconds = value.inSecond;
|
|
403
|
+
return typeof seconds === "number" && Number.isFinite(seconds) && seconds >= 0 ? seconds : void 0;
|
|
404
|
+
}
|
|
405
|
+
function firstMatchLine(sentences) {
|
|
406
|
+
if (!Array.isArray(sentences)) return void 0;
|
|
407
|
+
const text = isRecord2(sentences[0]) ? nonEmptyString(sentences[0].text) : void 0;
|
|
408
|
+
if (!text) return void 0;
|
|
409
|
+
const line = text.replace(/\s+/g, " ").trim();
|
|
410
|
+
return line.length > MATCH_LINE_MAX_CHARS ? `${line.slice(0, MATCH_LINE_MAX_CHARS - 1)}\u2026` : line;
|
|
411
|
+
}
|
|
412
|
+
function toCardItem(raw, withMatchLine) {
|
|
413
|
+
if (!isRecord2(raw)) return void 0;
|
|
414
|
+
const mediaId = nonEmptyString(raw.mediaId);
|
|
415
|
+
const name = nonEmptyString(raw.name);
|
|
416
|
+
if (!mediaId || !name) return void 0;
|
|
417
|
+
const item = { mediaId, name };
|
|
418
|
+
const createdAt = nonEmptyString(raw.createdAt);
|
|
419
|
+
if (createdAt) item.createdAt = createdAt;
|
|
420
|
+
const durationSeconds = durationSecondsOf(raw.duration);
|
|
421
|
+
if (durationSeconds !== void 0) item.durationSeconds = durationSeconds;
|
|
422
|
+
const mediaType = nonEmptyString(raw.mediaType);
|
|
423
|
+
if (mediaType) item.mediaType = mediaType;
|
|
424
|
+
const state = nonEmptyString(raw.state);
|
|
425
|
+
if (state) item.state = state;
|
|
426
|
+
if (withMatchLine) {
|
|
427
|
+
const matchLine = firstMatchLine(raw.sentences);
|
|
428
|
+
if (matchLine) item.matchLine = matchLine;
|
|
429
|
+
}
|
|
430
|
+
return item;
|
|
431
|
+
}
|
|
432
|
+
function toCard(source, rows, total, query) {
|
|
433
|
+
if (!Array.isArray(rows)) return void 0;
|
|
434
|
+
const items = [];
|
|
435
|
+
for (const row of rows) {
|
|
436
|
+
if (items.length === MEDIA_LIST_CARD_MAX_ROWS) break;
|
|
437
|
+
const item = toCardItem(row, source === "search_media");
|
|
438
|
+
if (item) items.push(item);
|
|
439
|
+
}
|
|
440
|
+
if (!items.length) return void 0;
|
|
441
|
+
const card = { source, total: Math.max(total, items.length), items };
|
|
442
|
+
if (query) card.query = query;
|
|
443
|
+
return card;
|
|
444
|
+
}
|
|
445
|
+
function buildListMediaCard(body) {
|
|
446
|
+
const data = isRecord2(body) && isRecord2(body.data) ? body.data : void 0;
|
|
447
|
+
if (!data) return void 0;
|
|
448
|
+
const total = typeof data.totalCount === "number" ? data.totalCount : 0;
|
|
449
|
+
return toCard("list_media", data.mediaList, total);
|
|
450
|
+
}
|
|
451
|
+
function buildSearchMediaCard(body, query) {
|
|
452
|
+
const data = isRecord2(body) && isRecord2(body.data) ? body.data : void 0;
|
|
453
|
+
if (!data || !Array.isArray(data.media)) return void 0;
|
|
454
|
+
return toCard("search_media", data.media, data.media.length, query);
|
|
455
|
+
}
|
|
456
|
+
function mediaListCardResultMeta(card) {
|
|
457
|
+
return card ? { [MEDIA_LIST_CARD_META_KEY]: card } : void 0;
|
|
458
|
+
}
|
|
459
|
+
var MEDIA_LIST_CARD_URI, MCP_APP_MIME_TYPE, MEDIA_LIST_CARD_META_KEY, MEDIA_LIST_CARD_MAX_ROWS, MATCH_LINE_MAX_CHARS, mediaListCardToolMeta;
|
|
460
|
+
var init_card_data = __esm({
|
|
461
|
+
"src/ui/media-list/card-data.ts"() {
|
|
462
|
+
"use strict";
|
|
463
|
+
MEDIA_LIST_CARD_URI = "ui://speak/media-list";
|
|
464
|
+
MCP_APP_MIME_TYPE = "text/html;profile=mcp-app";
|
|
465
|
+
MEDIA_LIST_CARD_META_KEY = "co.speakai/mediaList";
|
|
466
|
+
MEDIA_LIST_CARD_MAX_ROWS = 3;
|
|
467
|
+
MATCH_LINE_MAX_CHARS = 160;
|
|
468
|
+
mediaListCardToolMeta = {
|
|
469
|
+
ui: { resourceUri: MEDIA_LIST_CARD_URI },
|
|
470
|
+
"ui/resourceUri": MEDIA_LIST_CARD_URI
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
|
|
360
475
|
// node_modules/@speakai/shared/dist/enums/activities.js
|
|
361
476
|
var ActivityType;
|
|
362
477
|
var init_activities = __esm({
|
|
@@ -4886,6 +5001,36 @@ function getMimeType(filePath) {
|
|
|
4886
5001
|
function detectMediaType(filePath) {
|
|
4887
5002
|
return isVideoFile(filePath) ? "video" : "audio";
|
|
4888
5003
|
}
|
|
5004
|
+
function apiErrorText(error, helpByStatus) {
|
|
5005
|
+
const status = import_axios2.default.isAxiosError(error) ? error.response?.status : void 0;
|
|
5006
|
+
const help = status === void 0 ? void 0 : helpByStatus[status];
|
|
5007
|
+
return `Error: ${formatAxiosError(error)}${help ? `
|
|
5008
|
+
|
|
5009
|
+
${help}` : ""}`;
|
|
5010
|
+
}
|
|
5011
|
+
function defaultUploadName(source, name, now = /* @__PURE__ */ new Date()) {
|
|
5012
|
+
const given = name?.trim();
|
|
5013
|
+
if (given) return given;
|
|
5014
|
+
const fileName = fileNameFromSource(source);
|
|
5015
|
+
if (fileName) return fileName;
|
|
5016
|
+
return `Upload ${now.toISOString().slice(0, 16).replace("T", " ")} UTC`;
|
|
5017
|
+
}
|
|
5018
|
+
function fileNameFromSource(source) {
|
|
5019
|
+
if (!/^https?:\/\//i.test(source.trim())) return path.basename(source.trim()) || void 0;
|
|
5020
|
+
let lastSegment;
|
|
5021
|
+
try {
|
|
5022
|
+
lastSegment = new URL(source.trim()).pathname.split("/").filter(Boolean).pop();
|
|
5023
|
+
} catch {
|
|
5024
|
+
return void 0;
|
|
5025
|
+
}
|
|
5026
|
+
if (!lastSegment) return void 0;
|
|
5027
|
+
let fileName = lastSegment.trim();
|
|
5028
|
+
try {
|
|
5029
|
+
fileName = decodeURIComponent(lastSegment).trim();
|
|
5030
|
+
} catch {
|
|
5031
|
+
}
|
|
5032
|
+
return fileName && path.extname(fileName) ? fileName : void 0;
|
|
5033
|
+
}
|
|
4889
5034
|
function detectImageMimeType(bytes) {
|
|
4890
5035
|
const ascii = (start, end) => String.fromCharCode(...bytes.subarray(start, end));
|
|
4891
5036
|
if (bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255) return "image/jpeg";
|
|
@@ -4893,11 +5038,13 @@ function detectImageMimeType(bytes) {
|
|
|
4893
5038
|
if (bytes.length >= 12 && ascii(0, 4) === "RIFF" && ascii(8, 12) === "WEBP") return "image/webp";
|
|
4894
5039
|
return null;
|
|
4895
5040
|
}
|
|
4896
|
-
var path, VIDEO_EXTENSIONS, MIME_TYPES, SUPPORTED_URL_SOURCES, UNSUPPORTED_URL_SOURCES;
|
|
5041
|
+
var path, import_axios2, VIDEO_EXTENSIONS, MIME_TYPES, SUPPORTED_URL_SOURCES, UNSUPPORTED_URL_SOURCES, URL_UPLOAD_HELP, MEDIA_NOT_FOUND_HELP;
|
|
4897
5042
|
var init_media_utils = __esm({
|
|
4898
5043
|
"src/media-utils.ts"() {
|
|
4899
5044
|
"use strict";
|
|
4900
5045
|
path = __toESM(require("path"));
|
|
5046
|
+
import_axios2 = __toESM(require("axios"));
|
|
5047
|
+
init_client();
|
|
4901
5048
|
VIDEO_EXTENSIONS = [".mp4", ".mov", ".avi", ".mkv", ".webm", ".wmv"];
|
|
4902
5049
|
MIME_TYPES = {
|
|
4903
5050
|
".mp3": "audio/mpeg",
|
|
@@ -4912,6 +5059,8 @@ var init_media_utils = __esm({
|
|
|
4912
5059
|
};
|
|
4913
5060
|
SUPPORTED_URL_SOURCES = "YouTube, TikTok, Instagram, X/Twitter, Facebook, Reddit, SoundCloud, Twitch, Dailymotion, Streamable, Snapchat, Pinterest, Tumblr, Bilibili, VK, OK.ru and Rutube";
|
|
4914
5061
|
UNSUPPORTED_URL_SOURCES = "Vimeo and Loom page links are not supported.";
|
|
5062
|
+
URL_UPLOAD_HELP = `If the message above is about the link, show it to the user and ask for a different link instead of retrying the same one. A link works when it opens without signing in and is either a direct link to an audio or video file (such as .mp3, .m4a, .wav or .mp4) or a public page link from ${SUPPORTED_URL_SOURCES}. ${UNSUPPORTED_URL_SOURCES} Private or sign-in-only links, photo-only posts and links to web pages without media cannot be imported.`;
|
|
5063
|
+
MEDIA_NOT_FOUND_HELP = "No media with this mediaId exists in the signed-in Speak account. It may have been deleted, belong to a different Speak account, or not be a mediaId at all (a media name, a database _id or an id from another tool). Call search_media or list_media to find the right mediaId, then try again.";
|
|
4915
5064
|
}
|
|
4916
5065
|
});
|
|
4917
5066
|
|
|
@@ -4923,12 +5072,12 @@ __export(media_exports, {
|
|
|
4923
5072
|
register: () => register,
|
|
4924
5073
|
toNameFilter: () => toNameFilter
|
|
4925
5074
|
});
|
|
4926
|
-
function register(server, client) {
|
|
5075
|
+
function register(server, client, options = {}) {
|
|
4927
5076
|
const api = client ?? speakClient;
|
|
4928
5077
|
registerSpeakTool(
|
|
4929
5078
|
server,
|
|
4930
5079
|
"get_signed_upload_url",
|
|
4931
|
-
"Get a pre-signed
|
|
5080
|
+
"Get a pre-signed URL for sending a file's bytes straight to Speak AI storage. Use it only when you can make an HTTP PUT request with the file's bytes yourself, for example from a terminal on the user's computer. If you cannot send that request, do not call this tool: ask the user for a public link to the file and use upload_and_analyze, or ask them to upload it in the Speak AI app. After the PUT succeeds, call upload_media with the returned URL. Where upload_local_file is available it does all of these steps for you.",
|
|
4932
5081
|
{
|
|
4933
5082
|
filename: import_zod2.z.string().min(1).describe('Original filename including extension, e.g. "interview.mp4". The extension decides audio vs video and the storage path, so it must match the real file \u2014 a video named ".mp3" is stored as audio and can never be analysed as video.'),
|
|
4934
5083
|
mediaType: import_zod2.z.enum([MediaType.AUDIO, MediaType.VIDEO]).optional().describe('Type of media: "audio" or "video". It decides the storage path, so it has to match the real file. Send it whenever the user has told you which they want, or when the filename extension does not reflect the real container. Omit it to derive the type from the extension, which is the only evidence available here because the bytes do not exist yet.'),
|
|
@@ -4966,7 +5115,7 @@ function register(server, client) {
|
|
|
4966
5115
|
"upload_media",
|
|
4967
5116
|
`Import an audio or video file into Speak AI from a URL and start transcription. Accepts a direct public file URL, a URL returned by get_signed_upload_url, or a page link from a supported platform, which the server resolves to the underlying media. Supported page links: ${SUPPORTED_URL_SOURCES}. ${UNSUPPORTED_URL_SOURCES} Creates a media item. The request fails if the file exceeds the plan's size limit or its duration cannot be read. Returns mediaId and state right away while processing continues in the background. Use get_media_status until state is 'processed', then get_transcript and get_media_insights.`,
|
|
4968
5117
|
{
|
|
4969
|
-
name: import_zod2.z.string().
|
|
5118
|
+
name: import_zod2.z.string().optional().describe('Display name for the media. Defaults to the file name in the URL, or "Upload" with the date and time when the URL has none.'),
|
|
4970
5119
|
url: import_zod2.z.string().describe("Direct public media file URL, a URL returned by get_signed_upload_url, or a page link from a platform listed in this tool's description. Page links are resolved server-side, so pass the URL the user gave you as-is."),
|
|
4971
5120
|
mediaType: import_zod2.z.enum([MediaType.AUDIO, MediaType.VIDEO]).optional().describe('Type of media: "audio" or "video". Send it whenever the user has told you which they want \u2014 if they called it an audio file, or asked for audio only, pass "audio"; if they called it a video, pass "video". Otherwise omit it and the server decides: it inspects the actual file for a direct URL, and picks the best track the platform offers for a page link. Do not guess from the URL, because sending a value stops the server inspecting the file, and a video imported as "audio" can never be analysed as video afterwards.'),
|
|
4972
5121
|
description: import_zod2.z.string().optional().describe("Description of the media file"),
|
|
@@ -4990,7 +5139,7 @@ function register(server, client) {
|
|
|
4990
5139
|
},
|
|
4991
5140
|
async (body) => {
|
|
4992
5141
|
try {
|
|
4993
|
-
const result = await api.post("/v1/media/upload", body);
|
|
5142
|
+
const result = await api.post("/v1/media/upload", { ...body, name: defaultUploadName(body.url, body.name) });
|
|
4994
5143
|
return {
|
|
4995
5144
|
content: [
|
|
4996
5145
|
{ type: "text", text: JSON.stringify(result.data, null, 2) }
|
|
@@ -4998,7 +5147,7 @@ function register(server, client) {
|
|
|
4998
5147
|
};
|
|
4999
5148
|
} catch (err2) {
|
|
5000
5149
|
return {
|
|
5001
|
-
content: [{ type: "text", text:
|
|
5150
|
+
content: [{ type: "text", text: apiErrorText(err2, { 400: URL_UPLOAD_HELP }) }],
|
|
5002
5151
|
isError: true
|
|
5003
5152
|
};
|
|
5004
5153
|
}
|
|
@@ -5052,8 +5201,10 @@ function register(server, client) {
|
|
|
5052
5201
|
}
|
|
5053
5202
|
queryParams.pageSize = params.pageSize ?? LIST_MEDIA_DEFAULT_PAGE_SIZE;
|
|
5054
5203
|
const result = await api.get("/v1/media", { params: queryParams });
|
|
5204
|
+
const cardMeta = options.cards ? mediaListCardResultMeta(buildListMediaCard(result.data)) : void 0;
|
|
5055
5205
|
return {
|
|
5056
|
-
content: [{ type: "text", text: JSON.stringify(result.data) }]
|
|
5206
|
+
content: [{ type: "text", text: JSON.stringify(result.data) }],
|
|
5207
|
+
...cardMeta ? { _meta: cardMeta } : {}
|
|
5057
5208
|
};
|
|
5058
5209
|
} catch (err2) {
|
|
5059
5210
|
return {
|
|
@@ -5061,14 +5212,15 @@ function register(server, client) {
|
|
|
5061
5212
|
isError: true
|
|
5062
5213
|
};
|
|
5063
5214
|
}
|
|
5064
|
-
}
|
|
5215
|
+
},
|
|
5216
|
+
options.cards ? mediaListCardToolMeta : void 0
|
|
5065
5217
|
);
|
|
5066
5218
|
registerSpeakTool(
|
|
5067
5219
|
server,
|
|
5068
5220
|
"get_media_insights",
|
|
5069
5221
|
"Retrieve AI-generated insights for a processed media file \u2014 topics, sentiment, keywords, action items, summaries, and more. The media must be in 'processed' state (check with get_media_status first). For a video, data.thumbnail has the thumbnail: url, source (auto or custom), pending while a requested frame is being made, and error if that frame failed.",
|
|
5070
5222
|
{
|
|
5071
|
-
mediaId: import_zod2.z.string().min(1).describe(
|
|
5223
|
+
mediaId: import_zod2.z.string().min(1).describe(MEDIA_ID_DESCRIPTION)
|
|
5072
5224
|
},
|
|
5073
5225
|
{
|
|
5074
5226
|
title: "Get Media Insights",
|
|
@@ -5087,7 +5239,7 @@ function register(server, client) {
|
|
|
5087
5239
|
};
|
|
5088
5240
|
} catch (err2) {
|
|
5089
5241
|
return {
|
|
5090
|
-
content: [{ type: "text", text:
|
|
5242
|
+
content: [{ type: "text", text: apiErrorText(err2, { 404: MEDIA_NOT_FOUND_HELP }) }],
|
|
5091
5243
|
isError: true
|
|
5092
5244
|
};
|
|
5093
5245
|
}
|
|
@@ -5098,7 +5250,7 @@ function register(server, client) {
|
|
|
5098
5250
|
"get_transcript",
|
|
5099
5251
|
"Retrieve the full transcript for a media file with speaker labels and timestamps. Works on processed media and also returns the partial, in-progress transcript while a meeting bot is still recording (LIVE_TRANSCRIPT state). To fetch only the new sentences added since your previous call during a live meeting, use get_live_meeting_transcript instead. Use update_transcript_speakers to rename speaker labels after reviewing. For subtitle-formatted output, use get_captions instead.",
|
|
5100
5252
|
{
|
|
5101
|
-
mediaId: import_zod2.z.string().min(1).describe(
|
|
5253
|
+
mediaId: import_zod2.z.string().min(1).describe(MEDIA_ID_DESCRIPTION)
|
|
5102
5254
|
},
|
|
5103
5255
|
{
|
|
5104
5256
|
title: "Get Transcript",
|
|
@@ -5117,7 +5269,7 @@ function register(server, client) {
|
|
|
5117
5269
|
};
|
|
5118
5270
|
} catch (err2) {
|
|
5119
5271
|
return {
|
|
5120
|
-
content: [{ type: "text", text:
|
|
5272
|
+
content: [{ type: "text", text: apiErrorText(err2, { 404: MEDIA_NOT_FOUND_HELP }) }],
|
|
5121
5273
|
isError: true
|
|
5122
5274
|
};
|
|
5123
5275
|
}
|
|
@@ -5207,7 +5359,7 @@ function register(server, client) {
|
|
|
5207
5359
|
"get_media_status",
|
|
5208
5360
|
"Check the processing status of a media file. States: pending \u2192 transcribing \u2192 analyzing \u2192 processed (or failed). Poll this after upload_media until state is 'processed', then use get_transcript and get_media_insights to retrieve results. For a video, data.thumbnail has the thumbnail: url, source (auto or custom), pending while a requested frame is being made, and error if that frame failed.",
|
|
5209
5361
|
{
|
|
5210
|
-
mediaId: import_zod2.z.string().min(1).describe(
|
|
5362
|
+
mediaId: import_zod2.z.string().min(1).describe(MEDIA_ID_DESCRIPTION)
|
|
5211
5363
|
},
|
|
5212
5364
|
{
|
|
5213
5365
|
title: "Get Media Status",
|
|
@@ -5226,7 +5378,7 @@ function register(server, client) {
|
|
|
5226
5378
|
};
|
|
5227
5379
|
} catch (err2) {
|
|
5228
5380
|
return {
|
|
5229
|
-
content: [{ type: "text", text:
|
|
5381
|
+
content: [{ type: "text", text: apiErrorText(err2, { 404: MEDIA_NOT_FOUND_HELP }) }],
|
|
5230
5382
|
isError: true
|
|
5231
5383
|
};
|
|
5232
5384
|
}
|
|
@@ -5599,12 +5751,13 @@ function register(server, client) {
|
|
|
5599
5751
|
}
|
|
5600
5752
|
);
|
|
5601
5753
|
}
|
|
5602
|
-
var import_zod2, LIST_MEDIA_DEFAULT_PAGE_SIZE, LIST_MEDIA_MAX_PAGE_SIZE, THUMBNAIL_MAX_BYTES, THUMBNAIL_POLL_TIMEOUT_MS, THUMBNAIL_POLL_INTERVAL_MS, THUMBNAIL_FILE_EXTENSIONS, toNameFilter;
|
|
5754
|
+
var import_zod2, LIST_MEDIA_DEFAULT_PAGE_SIZE, LIST_MEDIA_MAX_PAGE_SIZE, THUMBNAIL_MAX_BYTES, THUMBNAIL_POLL_TIMEOUT_MS, THUMBNAIL_POLL_INTERVAL_MS, THUMBNAIL_FILE_EXTENSIONS, MEDIA_ID_DESCRIPTION, toNameFilter;
|
|
5603
5755
|
var init_media3 = __esm({
|
|
5604
5756
|
"src/tools/media.ts"() {
|
|
5605
5757
|
"use strict";
|
|
5606
5758
|
import_zod2 = require("zod");
|
|
5607
5759
|
init_helpers();
|
|
5760
|
+
init_card_data();
|
|
5608
5761
|
init_client();
|
|
5609
5762
|
init_dist();
|
|
5610
5763
|
init_media_utils();
|
|
@@ -5618,6 +5771,7 @@ var init_media3 = __esm({
|
|
|
5618
5771
|
"image/png": "png",
|
|
5619
5772
|
"image/webp": "webp"
|
|
5620
5773
|
};
|
|
5774
|
+
MEDIA_ID_DESCRIPTION = "The mediaId (12 characters) from list_media, search_media or an upload result. Not the media name and not a database _id.";
|
|
5621
5775
|
toNameFilter = (text) => /^name:/i.test(text) ? text : `name:${text}`;
|
|
5622
5776
|
}
|
|
5623
5777
|
});
|
|
@@ -6879,6 +7033,7 @@ __export(prompt_exports, {
|
|
|
6879
7033
|
});
|
|
6880
7034
|
function register7(server, client, options = {}) {
|
|
6881
7035
|
const api = client ?? speakClient;
|
|
7036
|
+
const answerOnly = Boolean(options.aiChatAnswerOnly);
|
|
6882
7037
|
const askAiChatDescription = [
|
|
6883
7038
|
"Ask an AI-powered question about your media using Speak AI's AI Chat.",
|
|
6884
7039
|
"Supports querying a single file, multiple files, entire folders, or your whole account.",
|
|
@@ -6887,10 +7042,8 @@ function register7(server, client, options = {}) {
|
|
|
6887
7042
|
"To continue a conversation, pass the promptId from a previous response.",
|
|
6888
7043
|
"Returns a promptId \u2014 save it to continue the conversation with follow-up questions.",
|
|
6889
7044
|
"Set analysisMediaId + analysisInput to have the model listen to the audio or watch the video instead of",
|
|
6890
|
-
"reading the transcript alone
|
|
6891
|
-
"
|
|
6892
|
-
"Each question is charged to the account's chat usage.",
|
|
6893
|
-
"The assistant can also call other Speak AI tools and actions in the user's connected third-party apps (for example, sending a message), so a prompt can change data or send content outside this chat."
|
|
7045
|
+
"reading the transcript alone; call get_analysis_quote first to check the file can be analysed that way.",
|
|
7046
|
+
answerOnly ? "The assistant answers only from the person's Speak recordings: it can search them and chart what it finds, and it does not take actions in other apps." : "The assistant can also call other Speak AI tools and actions in the user's connected third-party apps (for example, sending a message), so a prompt can change data or send content outside this chat."
|
|
6894
7047
|
].join(" ");
|
|
6895
7048
|
const askAiChatInputSchema = {
|
|
6896
7049
|
prompt: import_zod8.z.string().min(1).describe("The question or prompt to ask about the media"),
|
|
@@ -6908,15 +7061,15 @@ function register7(server, client, options = {}) {
|
|
|
6908
7061
|
fieldId: import_zod8.z.string().optional().describe("Scope the prompt to a single custom field"),
|
|
6909
7062
|
fieldIds: import_zod8.z.array(import_zod8.z.string()).max(10).optional().describe("Scope the prompt to multiple custom fields (max 10)"),
|
|
6910
7063
|
filters: import_zod8.z.record(import_zod8.z.unknown()).optional().describe("Advanced filter object to scope which media the prompt runs over"),
|
|
6911
|
-
analysisMediaId: import_zod8.z.string().optional().describe("Media to analyse as audio/video rather than transcript. Must also appear in mediaIds, and must be sent together with analysisInput.
|
|
6912
|
-
analysisInput: import_zod8.z.enum(["audio", "video"]).optional().describe("'audio' lets the model hear tone, pacing and delivery; 'video' also lets it see what is on screen. Omit for transcript-only, which is the default
|
|
7064
|
+
analysisMediaId: import_zod8.z.string().optional().describe("Media to analyse as audio/video rather than transcript. Must also appear in mediaIds, and must be sent together with analysisInput."),
|
|
7065
|
+
analysisInput: import_zod8.z.enum(["audio", "video"]).optional().describe("'audio' lets the model hear tone, pacing and delivery; 'video' also lets it see what is on screen. Omit for transcript-only, which is the default. 'transcript' is not a valid value here \u2014 omitting the field IS transcript-only.")
|
|
6913
7066
|
};
|
|
6914
7067
|
const askAiChatAnnotations = {
|
|
6915
7068
|
title: "Ask AI Chat",
|
|
6916
7069
|
readOnlyHint: false,
|
|
6917
|
-
destructiveHint:
|
|
7070
|
+
destructiveHint: !answerOnly,
|
|
6918
7071
|
idempotentHint: false,
|
|
6919
|
-
openWorldHint:
|
|
7072
|
+
openWorldHint: !answerOnly
|
|
6920
7073
|
};
|
|
6921
7074
|
const ANALYSIS_TIMEOUT_MS = 6 * 60 * 1e3;
|
|
6922
7075
|
const refuse = (message) => ({
|
|
@@ -6974,7 +7127,8 @@ function register7(server, client, options = {}) {
|
|
|
6974
7127
|
};
|
|
6975
7128
|
}
|
|
6976
7129
|
};
|
|
6977
|
-
|
|
7130
|
+
const aiChat = options.aiChat || answerOnly;
|
|
7131
|
+
if (aiChat) registerSpeakTool(
|
|
6978
7132
|
server,
|
|
6979
7133
|
"ask_ai_chat",
|
|
6980
7134
|
askAiChatDescription,
|
|
@@ -6982,16 +7136,16 @@ function register7(server, client, options = {}) {
|
|
|
6982
7136
|
askAiChatAnnotations,
|
|
6983
7137
|
askAiChatHandler
|
|
6984
7138
|
);
|
|
6985
|
-
if (
|
|
7139
|
+
if (aiChat) registerSpeakTool(
|
|
6986
7140
|
server,
|
|
6987
7141
|
"get_analysis_quote",
|
|
6988
|
-
"Check whether a media file can be analysed as audio or video
|
|
7142
|
+
"Check whether a media file can be analysed as audio or video before running ask_ai_chat with analysisInput. Returns whether the file is eligible and, when it is not, a plain-English reason. An unavailable file is a normal result here, not an error. This is the only check that accounts for both the account's opt-in and the server-wide switch, so call it before an audio or video run.",
|
|
6989
7143
|
{
|
|
6990
|
-
mediaId: import_zod8.z.string().min(1).describe("Media file to
|
|
7144
|
+
mediaId: import_zod8.z.string().min(1).describe("Media file to check"),
|
|
6991
7145
|
analysisInput: import_zod8.z.enum(["audio", "video"]).describe(
|
|
6992
|
-
"Which pass to
|
|
7146
|
+
"Which pass to check: 'audio' (tone, pacing, delivery) or 'video' (also on-screen visuals, gestures, slides). Required."
|
|
6993
7147
|
),
|
|
6994
|
-
modelId: import_zod8.z.string().optional().describe("Optional model id to
|
|
7148
|
+
modelId: import_zod8.z.string().optional().describe("Optional model id to check against. Omit for the workspace default.")
|
|
6995
7149
|
},
|
|
6996
7150
|
{
|
|
6997
7151
|
title: "Get Analysis Quote",
|
|
@@ -7014,10 +7168,10 @@ function register7(server, client, options = {}) {
|
|
|
7014
7168
|
}
|
|
7015
7169
|
}
|
|
7016
7170
|
);
|
|
7017
|
-
if (
|
|
7171
|
+
if (aiChat) registerSpeakTool(
|
|
7018
7172
|
server,
|
|
7019
7173
|
"retry_ai_chat",
|
|
7020
|
-
"Retry a failed or incomplete AI Chat response. Use when a previous ask_ai_chat call returned an error or incomplete answer. The turn runs again with its original settings
|
|
7174
|
+
"Retry a failed or incomplete AI Chat response. Use when a previous ask_ai_chat call returned an error or incomplete answer. The turn runs again with its original settings and replaces the earlier answer for that message. " + (answerOnly ? "Like ask_ai_chat, the assistant answers only from the person's Speak recordings and does not take actions in other apps." : "Like ask_ai_chat, the assistant can call other Speak AI tools and actions in connected third-party apps."),
|
|
7021
7175
|
{
|
|
7022
7176
|
promptId: import_zod8.z.string().min(1).describe("ID of the conversation containing the failed message"),
|
|
7023
7177
|
messageId: import_zod8.z.string().min(1).describe("ID of the specific message to retry")
|
|
@@ -7027,7 +7181,7 @@ function register7(server, client, options = {}) {
|
|
|
7027
7181
|
readOnlyHint: false,
|
|
7028
7182
|
destructiveHint: true,
|
|
7029
7183
|
idempotentHint: false,
|
|
7030
|
-
openWorldHint:
|
|
7184
|
+
openWorldHint: !answerOnly
|
|
7031
7185
|
},
|
|
7032
7186
|
async (body) => {
|
|
7033
7187
|
try {
|
|
@@ -9884,7 +10038,7 @@ function withDefaultSearchDateRange(params) {
|
|
|
9884
10038
|
endDate: params.endDate ?? now.toISOString()
|
|
9885
10039
|
};
|
|
9886
10040
|
}
|
|
9887
|
-
function register14(server, client) {
|
|
10041
|
+
function register14(server, client, options = {}) {
|
|
9888
10042
|
const api = client ?? speakClient;
|
|
9889
10043
|
registerSpeakTool(
|
|
9890
10044
|
server,
|
|
@@ -9919,8 +10073,10 @@ function register14(server, client) {
|
|
|
9919
10073
|
async (params) => {
|
|
9920
10074
|
try {
|
|
9921
10075
|
const result = await api.post("/v1/analytics/search", withDefaultSearchDateRange(params));
|
|
10076
|
+
const cardMeta = options.cards ? mediaListCardResultMeta(buildSearchMediaCard(result.data, params.query)) : void 0;
|
|
9922
10077
|
return {
|
|
9923
|
-
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
|
|
10078
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
10079
|
+
...cardMeta ? { _meta: cardMeta } : {}
|
|
9924
10080
|
};
|
|
9925
10081
|
} catch (err2) {
|
|
9926
10082
|
return {
|
|
@@ -9928,7 +10084,8 @@ function register14(server, client) {
|
|
|
9928
10084
|
isError: true
|
|
9929
10085
|
};
|
|
9930
10086
|
}
|
|
9931
|
-
}
|
|
10087
|
+
},
|
|
10088
|
+
options.cards ? mediaListCardToolMeta : void 0
|
|
9932
10089
|
);
|
|
9933
10090
|
}
|
|
9934
10091
|
var import_zod16;
|
|
@@ -9937,6 +10094,7 @@ var init_analytics2 = __esm({
|
|
|
9937
10094
|
"use strict";
|
|
9938
10095
|
import_zod16 = require("zod");
|
|
9939
10096
|
init_helpers();
|
|
10097
|
+
init_card_data();
|
|
9940
10098
|
init_client();
|
|
9941
10099
|
init_dist();
|
|
9942
10100
|
}
|
|
@@ -10485,7 +10643,7 @@ Likely cause: this server rejects filter rules on webhook payload fields (${data
|
|
|
10485
10643
|
// A plain literal, not a template: the docs generator drops a tool's whole parameter
|
|
10486
10644
|
// table when a description interpolates a value it cannot resolve statically.
|
|
10487
10645
|
url: import_zod18.z.string().describe("Direct/public media file URL, or a shareable social/video page link \u2014 page links are resolved to the underlying media server-side. See this tool's description for the platforms accepted. Pass the URL the user gave you as-is; do not try to convert it to a file URL first."),
|
|
10488
|
-
name: import_zod18.z.string().optional().describe(
|
|
10646
|
+
name: import_zod18.z.string().optional().describe('Display name for the media. Defaults to the file name in the URL, or "Upload" with the date and time when the URL has none.'),
|
|
10489
10647
|
mediaType: import_zod18.z.enum([MediaType.AUDIO, MediaType.VIDEO]).optional().describe('Type of media: "audio" or "video". Send it whenever the user has told you which they want \u2014 if they called it an audio file, or asked for audio only, pass "audio"; if they called it a video, pass "video". Otherwise omit it and the server decides: it inspects the actual file for a direct URL, and picks the best track the platform offers for a page link. Do not guess from the URL, because sending a value stops the server inspecting the file, and a video imported as "audio" can never be analysed as video afterwards.'),
|
|
10490
10648
|
sourceLanguage: import_zod18.z.string().optional().describe("BCP-47 language code (e.g., 'en-US', 'he-IL')"),
|
|
10491
10649
|
folderId: import_zod18.z.string().optional().describe("Folder ID to place the media in"),
|
|
@@ -10501,7 +10659,7 @@ Likely cause: this server rejects filter rules on webhook payload fields (${data
|
|
|
10501
10659
|
async (params) => {
|
|
10502
10660
|
try {
|
|
10503
10661
|
const uploadBody = {
|
|
10504
|
-
name: params.
|
|
10662
|
+
name: defaultUploadName(params.url, params.name),
|
|
10505
10663
|
url: params.url
|
|
10506
10664
|
};
|
|
10507
10665
|
if (params.mediaType) uploadBody.mediaType = params.mediaType;
|
|
@@ -10535,7 +10693,7 @@ ${JSON.stringify(uploadRes.data, null, 2)}` }],
|
|
|
10535
10693
|
};
|
|
10536
10694
|
} catch (err2) {
|
|
10537
10695
|
return {
|
|
10538
|
-
content: [{ type: "text", text:
|
|
10696
|
+
content: [{ type: "text", text: apiErrorText(err2, { 400: URL_UPLOAD_HELP }) }],
|
|
10539
10697
|
isError: true
|
|
10540
10698
|
};
|
|
10541
10699
|
}
|
|
@@ -10577,7 +10735,7 @@ ${JSON.stringify(uploadRes.data, null, 2)}` }],
|
|
|
10577
10735
|
const workerCount = Math.min(params.concurrency ?? MAX_BATCH_CONCURRENCY, urls.length);
|
|
10578
10736
|
const send = (url) => api.post("/v1/media/upload", {
|
|
10579
10737
|
...shared,
|
|
10580
|
-
name: url
|
|
10738
|
+
name: defaultUploadName(url),
|
|
10581
10739
|
url
|
|
10582
10740
|
});
|
|
10583
10741
|
const worker = async () => {
|
|
@@ -10624,8 +10782,8 @@ ${JSON.stringify(uploadRes.data, null, 2)}` }],
|
|
|
10624
10782
|
] : uploaded.length ? [
|
|
10625
10783
|
`1. Poll get_media_status for each of the ${uploaded.length} mediaId values every 10-30 seconds, or call list_media on the folder to see them together.`,
|
|
10626
10784
|
`2. When one reads "processed", call get_media_insights and get_transcript for it.`,
|
|
10627
|
-
failed.length ? `3. ${failed.length} URL(s) did not upload \u2014 report the reasons above rather than silently retrying
|
|
10628
|
-
] : [
|
|
10785
|
+
failed.length ? `3. ${failed.length} URL(s) did not upload \u2014 report the reasons above rather than silently retrying. ${URL_UPLOAD_HELP}` : `3. Nothing failed in this batch.`
|
|
10786
|
+
] : [`No uploads were accepted. Report the errors above to the user. ${URL_UPLOAD_HELP}`]
|
|
10629
10787
|
};
|
|
10630
10788
|
return {
|
|
10631
10789
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
@@ -10683,8 +10841,8 @@ ${JSON.stringify(signedRes.data, null, 2)}` }],
|
|
|
10683
10841
|
};
|
|
10684
10842
|
}
|
|
10685
10843
|
const fileBuffer = fs.readFileSync(filePath);
|
|
10686
|
-
const
|
|
10687
|
-
await
|
|
10844
|
+
const axios4 = (await import("axios")).default;
|
|
10845
|
+
await axios4.put(uploadUrl, fileBuffer, {
|
|
10688
10846
|
headers: {
|
|
10689
10847
|
"Content-Type": mimeType
|
|
10690
10848
|
},
|
|
@@ -10692,7 +10850,7 @@ ${JSON.stringify(signedRes.data, null, 2)}` }],
|
|
|
10692
10850
|
maxContentLength: Infinity
|
|
10693
10851
|
});
|
|
10694
10852
|
const createBody = {
|
|
10695
|
-
name: params.name
|
|
10853
|
+
name: defaultUploadName(filename, params.name),
|
|
10696
10854
|
url: uploadUrl.split("?")[0],
|
|
10697
10855
|
// S3 URL without query params; server re-signs via CloudFront
|
|
10698
10856
|
mediaType
|
|
@@ -13064,7 +13222,7 @@ function register23(server, client) {
|
|
|
13064
13222
|
const result = await api.get("/v1/subscription/billing-status");
|
|
13065
13223
|
return ok(result.data);
|
|
13066
13224
|
} catch (error) {
|
|
13067
|
-
if (
|
|
13225
|
+
if (import_axios3.default.isAxiosError(error) && error.response?.status === 404) {
|
|
13068
13226
|
return {
|
|
13069
13227
|
content: [
|
|
13070
13228
|
{
|
|
@@ -13080,16 +13238,387 @@ function register23(server, client) {
|
|
|
13080
13238
|
}
|
|
13081
13239
|
);
|
|
13082
13240
|
}
|
|
13083
|
-
var
|
|
13241
|
+
var import_axios3;
|
|
13084
13242
|
var init_billing3 = __esm({
|
|
13085
13243
|
"src/tools/billing.ts"() {
|
|
13086
13244
|
"use strict";
|
|
13087
|
-
|
|
13245
|
+
import_axios3 = __toESM(require("axios"));
|
|
13088
13246
|
init_helpers();
|
|
13089
13247
|
init_client();
|
|
13090
13248
|
}
|
|
13091
13249
|
});
|
|
13092
13250
|
|
|
13251
|
+
// src/ui/media-list/view.ts
|
|
13252
|
+
var SPEAK_WEB_APP_URL, CARD_DATA_TIMEOUT_MS, LIVE_BUTTON_PAUSE_MS, MCP_APPS_PROTOCOL_VERSION, VIEW_STYLE, VIEW_SCRIPT, MEDIA_LIST_CARD_HTML;
|
|
13253
|
+
var init_view = __esm({
|
|
13254
|
+
"src/ui/media-list/view.ts"() {
|
|
13255
|
+
"use strict";
|
|
13256
|
+
init_card_data();
|
|
13257
|
+
SPEAK_WEB_APP_URL = "https://app.speakai.co";
|
|
13258
|
+
CARD_DATA_TIMEOUT_MS = 45e3;
|
|
13259
|
+
LIVE_BUTTON_PAUSE_MS = 8e3;
|
|
13260
|
+
MCP_APPS_PROTOCOL_VERSION = "2026-01-26";
|
|
13261
|
+
VIEW_STYLE = `
|
|
13262
|
+
:root{color-scheme:light;
|
|
13263
|
+
--fb-bg:#ffffff;--fb-fg:#1f2328;--fb-muted:#59636e;--fb-line:#d8dee4;--fb-soft:#eef0f2;--fb-bad:#b42318}
|
|
13264
|
+
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){color-scheme:dark;
|
|
13265
|
+
--fb-bg:#26282c;--fb-fg:#ececec;--fb-muted:#a8adb3;--fb-line:#3a3d42;--fb-soft:#34363a;--fb-bad:#f97066}}
|
|
13266
|
+
:root[data-theme="dark"]{color-scheme:dark;
|
|
13267
|
+
--fb-bg:#26282c;--fb-fg:#ececec;--fb-muted:#a8adb3;--fb-line:#3a3d42;--fb-soft:#34363a;--fb-bad:#f97066}
|
|
13268
|
+
:root{
|
|
13269
|
+
--c-bg:var(--color-background-primary,var(--fb-bg));
|
|
13270
|
+
--c-fg:var(--color-text-primary,var(--fb-fg));
|
|
13271
|
+
--c-muted:var(--color-text-secondary,var(--fb-muted));
|
|
13272
|
+
--c-line:var(--color-border-tertiary,var(--fb-line));
|
|
13273
|
+
--c-soft:var(--color-background-secondary,var(--fb-soft));
|
|
13274
|
+
--c-bad:var(--color-text-danger,var(--fb-bad));
|
|
13275
|
+
--c-ring:var(--color-ring-primary,var(--c-fg));
|
|
13276
|
+
--c-radius:var(--border-radius-xl,12px);
|
|
13277
|
+
--c-radius-btn:var(--border-radius-md,8px);
|
|
13278
|
+
--c-font:var(--font-sans,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif);
|
|
13279
|
+
--c-semibold:var(--font-weight-semibold,600)}
|
|
13280
|
+
*{box-sizing:border-box}
|
|
13281
|
+
html,body{margin:0;padding:0;background:transparent}
|
|
13282
|
+
body{font-family:var(--c-font);color:var(--c-fg);font-size:12px;line-height:1.45;-webkit-text-size-adjust:100%}
|
|
13283
|
+
[hidden]{display:none!important}
|
|
13284
|
+
.card{border:1px solid var(--c-line);border-radius:var(--c-radius);background:var(--c-bg);padding:2px 12px 6px;min-width:0}
|
|
13285
|
+
.head{font-size:12px;font-weight:var(--c-semibold);color:var(--c-muted);padding:8px 0 6px;margin:0;overflow-wrap:anywhere}
|
|
13286
|
+
.list{list-style:none;margin:0;padding:0}
|
|
13287
|
+
.row{display:flex;align-items:center;justify-content:space-between;gap:10px;border-top:1px solid var(--c-line);padding:6px 0;min-height:44px;min-width:0}
|
|
13288
|
+
.txt{position:relative;min-width:0;flex:1 1 auto}
|
|
13289
|
+
.t{font-size:14px;font-weight:var(--c-semibold);color:var(--c-fg);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere;text-decoration:underline;text-decoration-color:var(--c-line);text-underline-offset:3px;border-radius:4px}
|
|
13290
|
+
.t:hover{text-decoration-color:currentColor}
|
|
13291
|
+
.meta,.match{display:block;font-size:12px;color:var(--c-muted)}
|
|
13292
|
+
.match{color:var(--c-fg)}
|
|
13293
|
+
.st{color:var(--c-fg);font-weight:var(--c-semibold)}
|
|
13294
|
+
.st.bad{color:var(--c-bad)}
|
|
13295
|
+
.match{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
13296
|
+
.btn{flex:0 0 auto;font:inherit;font-size:12px;font-weight:var(--c-semibold);color:var(--c-fg);background:transparent;border:1px solid var(--c-line);border-radius:var(--c-radius-btn);padding:0 10px;min-height:32px;display:inline-flex;align-items:center;white-space:nowrap;cursor:pointer}
|
|
13297
|
+
.btn:hover{background:var(--c-soft)}
|
|
13298
|
+
.btn[aria-disabled="true"]{opacity:.45;cursor:default;background:transparent}
|
|
13299
|
+
.t:focus-visible,.btn:focus-visible{outline:2px solid var(--c-ring);outline-offset:2px}
|
|
13300
|
+
.t:focus:not(:focus-visible),.btn:focus:not(:focus-visible){outline:none}
|
|
13301
|
+
.foot{font-size:12px;color:var(--c-muted);border-top:1px solid var(--c-line);padding-top:6px;margin:0}
|
|
13302
|
+
.sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
|
|
13303
|
+
.touch .btn{min-height:44px;padding:0 12px}
|
|
13304
|
+
.touch .txt{min-height:44px;display:flex;flex-direction:column;justify-content:center}
|
|
13305
|
+
.touch .t::after{content:"";position:absolute;inset:0}
|
|
13306
|
+
.sk{display:block;background:var(--c-soft);border-radius:4px;height:12px}
|
|
13307
|
+
.sk.h{width:60px;margin:8px 0 6px}
|
|
13308
|
+
.sk.t{height:14px;width:60%;margin-bottom:6px}
|
|
13309
|
+
.sk.m{width:35%}
|
|
13310
|
+
.sk.b{width:110px;height:32px;border-radius:var(--c-radius-btn);flex:0 0 auto}
|
|
13311
|
+
.touch .sk.b{height:44px}
|
|
13312
|
+
@media (max-width:359px){.row{flex-direction:column;align-items:flex-start;gap:4px}.txt{width:100%}}
|
|
13313
|
+
`;
|
|
13314
|
+
VIEW_SCRIPT = `
|
|
13315
|
+
(function(){
|
|
13316
|
+
var META_KEY=${JSON.stringify(MEDIA_LIST_CARD_META_KEY)};
|
|
13317
|
+
var MAX_ROWS=${MEDIA_LIST_CARD_MAX_ROWS};
|
|
13318
|
+
var WEB_APP_URL=${JSON.stringify(SPEAK_WEB_APP_URL)};
|
|
13319
|
+
var DATA_TIMEOUT_MS=${CARD_DATA_TIMEOUT_MS};
|
|
13320
|
+
var LIVE_PAUSE_MS=${LIVE_BUTTON_PAUSE_MS};
|
|
13321
|
+
var PROTOCOL_VERSION=${JSON.stringify(MCP_APPS_PROTOCOL_VERSION)};
|
|
13322
|
+
var READY_STATES={processed:1,complete:1};
|
|
13323
|
+
var NOT_STARTED_STATES={notUploaded:1,pendingPayment:1};
|
|
13324
|
+
|
|
13325
|
+
var root=document.getElementById("card");
|
|
13326
|
+
var hostCaps={};
|
|
13327
|
+
var locale=document.documentElement.lang||navigator.language||"en-GB";
|
|
13328
|
+
var timeZone;
|
|
13329
|
+
var nextId=1;
|
|
13330
|
+
var pending={};
|
|
13331
|
+
var settled=false;
|
|
13332
|
+
var dataTimer;
|
|
13333
|
+
|
|
13334
|
+
function post(msg){window.parent.postMessage(msg,"*");}
|
|
13335
|
+
function request(method,params){
|
|
13336
|
+
var id=nextId++;
|
|
13337
|
+
post({jsonrpc:"2.0",id:id,method:method,params:params});
|
|
13338
|
+
return new Promise(function(resolve,reject){
|
|
13339
|
+
pending[id]={resolve:resolve,reject:reject};
|
|
13340
|
+
setTimeout(function(){if(pending[id]){delete pending[id];reject(new Error("timeout"));}},15000);
|
|
13341
|
+
});
|
|
13342
|
+
}
|
|
13343
|
+
function notify(method,params){post({jsonrpc:"2.0",method:method,params:params||{}});}
|
|
13344
|
+
|
|
13345
|
+
var lastHeight=-1;
|
|
13346
|
+
function reportSize(){
|
|
13347
|
+
var h=root.hidden?0:Math.ceil(document.documentElement.getBoundingClientRect().height);
|
|
13348
|
+
if(h===lastHeight)return;
|
|
13349
|
+
lastHeight=h;
|
|
13350
|
+
notify("ui/notifications/size-changed",{height:h});
|
|
13351
|
+
}
|
|
13352
|
+
|
|
13353
|
+
function applyContext(ctx){
|
|
13354
|
+
if(!ctx)return;
|
|
13355
|
+
var docEl=document.documentElement;
|
|
13356
|
+
if(ctx.theme)docEl.setAttribute("data-theme",ctx.theme==="dark"?"dark":"light");
|
|
13357
|
+
var vars=ctx.styles&&ctx.styles.variables;
|
|
13358
|
+
if(vars){for(var k in vars){if(vars[k])docEl.style.setProperty(k,vars[k]);}}
|
|
13359
|
+
if(ctx.locale)locale=ctx.locale;
|
|
13360
|
+
if(ctx.timeZone)timeZone=ctx.timeZone;
|
|
13361
|
+
var touch=(ctx.deviceCapabilities&&ctx.deviceCapabilities.touch)||ctx.platform==="mobile";
|
|
13362
|
+
if(touch||(window.matchMedia&&window.matchMedia("(pointer: coarse)").matches))docEl.classList.add("touch");
|
|
13363
|
+
var inset=ctx.safeAreaInsets;
|
|
13364
|
+
if(inset){document.body.style.padding=[inset.top,inset.right,inset.bottom,inset.left].map(function(n){return (n||0)+"px";}).join(" ");}
|
|
13365
|
+
}
|
|
13366
|
+
|
|
13367
|
+
function el(tag,cls,text){var n=document.createElement(tag);if(cls)n.className=cls;if(text!=null)n.textContent=text;return n;}
|
|
13368
|
+
|
|
13369
|
+
function formatDate(iso){
|
|
13370
|
+
if(!iso)return "";
|
|
13371
|
+
var d=new Date(iso);
|
|
13372
|
+
if(isNaN(d.getTime()))return "";
|
|
13373
|
+
try{return new Intl.DateTimeFormat(locale,{day:"numeric",month:"short",year:"numeric",timeZone:timeZone}).format(d);}
|
|
13374
|
+
catch(e){return d.toISOString().slice(0,10);}
|
|
13375
|
+
}
|
|
13376
|
+
function formatLength(s){
|
|
13377
|
+
if(typeof s!=="number")return "";
|
|
13378
|
+
if(s<60)return "Under 1 min";
|
|
13379
|
+
if(s<3600)return Math.floor(s/60)+" min";
|
|
13380
|
+
var m=Math.floor((s%3600)/60);
|
|
13381
|
+
return Math.floor(s/3600)+" h "+(m<10?"0":"")+m+" min";
|
|
13382
|
+
}
|
|
13383
|
+
function statusOf(item){
|
|
13384
|
+
var s=item.state;
|
|
13385
|
+
if(!s||READY_STATES[s])return null;
|
|
13386
|
+
if(s==="failed")return {text:"Could not process",bad:true,button:false};
|
|
13387
|
+
if(s==="liveTranscript")return {text:"Recording now",button:true,live:true};
|
|
13388
|
+
if(NOT_STARTED_STATES[s])return {text:"Not processed yet",button:false};
|
|
13389
|
+
return {text:"Processing",button:false};
|
|
13390
|
+
}
|
|
13391
|
+
function plural(n,one,many){return n+" "+(n===1?one:many);}
|
|
13392
|
+
function headerText(card){
|
|
13393
|
+
if(card.source==="search_media"&&card.query){
|
|
13394
|
+
return plural(card.total,"file matches","files match")+" \\u201c"+card.query+"\\u201d";
|
|
13395
|
+
}
|
|
13396
|
+
return plural(card.total,"file","files");
|
|
13397
|
+
}
|
|
13398
|
+
|
|
13399
|
+
function openLink(url){
|
|
13400
|
+
if(hostCaps.openLinks){
|
|
13401
|
+
return request("ui/open-link",{url:url}).then(function(r){if(r&&r.isError)throw new Error("refused");});
|
|
13402
|
+
}
|
|
13403
|
+
return Promise.reject(new Error("no open-link"));
|
|
13404
|
+
}
|
|
13405
|
+
|
|
13406
|
+
function askForText(item,btn,status){
|
|
13407
|
+
if(btn.getAttribute("aria-disabled")==="true")return;
|
|
13408
|
+
btn.setAttribute("aria-disabled","true");
|
|
13409
|
+
var isText=item.mediaType==="text";
|
|
13410
|
+
var live=status&&status.live;
|
|
13411
|
+
var visible=isText?"Show the text of "+item.name:(live?"Show the transcript so far of "+item.name:"Show the transcript of "+item.name);
|
|
13412
|
+
var context="The person picked the Speak file \\""+item.name+"\\" (mediaId "+item.mediaId+") in the file list card. Use get_transcript with mediaId "+item.mediaId+" for it; do not search again.";
|
|
13413
|
+
var withContext=hostCaps.updateModelContext
|
|
13414
|
+
?request("ui/update-model-context",{content:[{type:"text",text:context}],structuredContent:{mediaId:item.mediaId,name:item.name}}).catch(function(){})
|
|
13415
|
+
:Promise.resolve();
|
|
13416
|
+
withContext.then(function(){
|
|
13417
|
+
return request("ui/message",{role:"user",content:[{type:"text",text:visible}]});
|
|
13418
|
+
}).then(function(r){
|
|
13419
|
+
if(r&&r.isError)throw new Error("refused");
|
|
13420
|
+
if(live)setTimeout(function(){btn.removeAttribute("aria-disabled");},LIVE_PAUSE_MS);
|
|
13421
|
+
}).catch(function(){btn.removeAttribute("aria-disabled");});
|
|
13422
|
+
}
|
|
13423
|
+
|
|
13424
|
+
function renderRow(item,isSearch){
|
|
13425
|
+
var status=statusOf(item);
|
|
13426
|
+
var li=el("li","row");
|
|
13427
|
+
var txt=el("div","txt");
|
|
13428
|
+
var url=WEB_APP_URL+"/media/"+encodeURIComponent(item.mediaId);
|
|
13429
|
+
var a=el("a","t");
|
|
13430
|
+
a.href=url;a.target="_blank";a.rel="noopener noreferrer";a.title=item.name;
|
|
13431
|
+
a.appendChild(document.createTextNode(item.name));
|
|
13432
|
+
a.appendChild(el("span","sr",", opens in Speak in a new tab"));
|
|
13433
|
+
a.addEventListener("click",function(ev){
|
|
13434
|
+
if(!hostCaps.openLinks)return;
|
|
13435
|
+
ev.preventDefault();
|
|
13436
|
+
openLink(url).catch(function(){window.open(url,"_blank","noopener");});
|
|
13437
|
+
});
|
|
13438
|
+
txt.appendChild(a);
|
|
13439
|
+
|
|
13440
|
+
var meta=el("span","meta");
|
|
13441
|
+
var parts=[];
|
|
13442
|
+
if(!status&&item.mediaType!=="text"){var len=formatLength(item.durationSeconds);if(len)parts.push(len);}
|
|
13443
|
+
var date=formatDate(item.createdAt);
|
|
13444
|
+
if(date)parts.push(date);
|
|
13445
|
+
meta.textContent=parts.join(" \\u00b7 ");
|
|
13446
|
+
if(status){
|
|
13447
|
+
if(parts.length)meta.appendChild(document.createTextNode(" \\u00b7 "));
|
|
13448
|
+
meta.appendChild(el("span","st"+(status.bad?" bad":""),status.text));
|
|
13449
|
+
}
|
|
13450
|
+
txt.appendChild(meta);
|
|
13451
|
+
|
|
13452
|
+
if(isSearch){
|
|
13453
|
+
txt.appendChild(el("span","match",item.matchLine?"\\u201c"+item.matchLine+"\\u201d":"Matched the file name or details"));
|
|
13454
|
+
}
|
|
13455
|
+
li.appendChild(txt);
|
|
13456
|
+
|
|
13457
|
+
if(!status||status.button){
|
|
13458
|
+
var isText=item.mediaType==="text";
|
|
13459
|
+
var label=isText?"Show text":"Show transcript";
|
|
13460
|
+
var btn=el("button","btn",label);
|
|
13461
|
+
btn.type="button";
|
|
13462
|
+
btn.setAttribute("aria-label",(isText?"Show text of ":"Show transcript of ")+item.name);
|
|
13463
|
+
btn.addEventListener("click",function(){askForText(item,btn,status);});
|
|
13464
|
+
li.appendChild(btn);
|
|
13465
|
+
}
|
|
13466
|
+
return li;
|
|
13467
|
+
}
|
|
13468
|
+
|
|
13469
|
+
function render(card){
|
|
13470
|
+
settled=true;
|
|
13471
|
+
clearTimeout(dataTimer);
|
|
13472
|
+
root.textContent="";
|
|
13473
|
+
root.removeAttribute("aria-busy");
|
|
13474
|
+
if(!card||!Array.isArray(card.items)||!card.items.length){hide();return;}
|
|
13475
|
+
var isSearch=card.source==="search_media";
|
|
13476
|
+
var items=card.items.slice(0,MAX_ROWS);
|
|
13477
|
+
var head=el("h2","head",headerText(card));
|
|
13478
|
+
head.id="card-head";
|
|
13479
|
+
root.appendChild(head);
|
|
13480
|
+
var ul=el("ul","list");
|
|
13481
|
+
ul.setAttribute("aria-labelledby","card-head");
|
|
13482
|
+
items.forEach(function(item){ul.appendChild(renderRow(item,isSearch));});
|
|
13483
|
+
root.appendChild(ul);
|
|
13484
|
+
if(card.total>items.length){
|
|
13485
|
+
root.appendChild(el("p","foot","Showing "+items.length+" of "+card.total+". "+(card.total-items.length)+" more in Speak."));
|
|
13486
|
+
}
|
|
13487
|
+
root.hidden=false;
|
|
13488
|
+
reportSize();
|
|
13489
|
+
}
|
|
13490
|
+
|
|
13491
|
+
function renderSkeleton(rows){
|
|
13492
|
+
if(settled)return;
|
|
13493
|
+
root.textContent="";
|
|
13494
|
+
root.setAttribute("aria-busy","true");
|
|
13495
|
+
root.appendChild(el("span","sk h"));
|
|
13496
|
+
var ul=el("ul","list");
|
|
13497
|
+
ul.setAttribute("aria-hidden","true");
|
|
13498
|
+
for(var i=0;i<rows;i++){
|
|
13499
|
+
var li=el("li","row");
|
|
13500
|
+
var txt=el("div","txt");
|
|
13501
|
+
txt.appendChild(el("span","sk t"));
|
|
13502
|
+
txt.appendChild(el("span","sk m"));
|
|
13503
|
+
li.appendChild(txt);
|
|
13504
|
+
li.appendChild(el("span","sk b"));
|
|
13505
|
+
ul.appendChild(li);
|
|
13506
|
+
}
|
|
13507
|
+
root.appendChild(ul);
|
|
13508
|
+
root.hidden=false;
|
|
13509
|
+
reportSize();
|
|
13510
|
+
}
|
|
13511
|
+
|
|
13512
|
+
function hide(){
|
|
13513
|
+
settled=true;
|
|
13514
|
+
clearTimeout(dataTimer);
|
|
13515
|
+
root.hidden=true;
|
|
13516
|
+
root.textContent="";
|
|
13517
|
+
reportSize();
|
|
13518
|
+
}
|
|
13519
|
+
|
|
13520
|
+
function skeletonRows(args){
|
|
13521
|
+
var size=args&&typeof args.pageSize==="number"?args.pageSize:MAX_ROWS;
|
|
13522
|
+
return Math.max(1,Math.min(MAX_ROWS,size));
|
|
13523
|
+
}
|
|
13524
|
+
|
|
13525
|
+
function onNotification(method,params){
|
|
13526
|
+
if(method==="ui/notifications/tool-input"){renderSkeleton(skeletonRows(params&¶ms.arguments));}
|
|
13527
|
+
else if(method==="ui/notifications/tool-result"){
|
|
13528
|
+
if(!params||params.isError){hide();return;}
|
|
13529
|
+
render(params._meta&¶ms._meta[META_KEY]);
|
|
13530
|
+
}
|
|
13531
|
+
else if(method==="ui/notifications/tool-cancelled"){hide();}
|
|
13532
|
+
else if(method==="ui/notifications/host-context-changed"){applyContext(params);reportSize();}
|
|
13533
|
+
}
|
|
13534
|
+
|
|
13535
|
+
window.addEventListener("message",function(ev){
|
|
13536
|
+
if(ev.source!==window.parent)return;
|
|
13537
|
+
var msg=ev.data;
|
|
13538
|
+
if(!msg||msg.jsonrpc!=="2.0")return;
|
|
13539
|
+
if(msg.method){
|
|
13540
|
+
if(msg.id!=null){post({jsonrpc:"2.0",id:msg.id,result:{}});return;}
|
|
13541
|
+
onNotification(msg.method,msg.params);
|
|
13542
|
+
return;
|
|
13543
|
+
}
|
|
13544
|
+
if(msg.id!=null&&pending[msg.id]){
|
|
13545
|
+
var p=pending[msg.id];delete pending[msg.id];
|
|
13546
|
+
if(msg.error)p.reject(msg.error);else p.resolve(msg.result);
|
|
13547
|
+
}
|
|
13548
|
+
});
|
|
13549
|
+
|
|
13550
|
+
if(window.ResizeObserver){new ResizeObserver(reportSize).observe(document.documentElement);}
|
|
13551
|
+
|
|
13552
|
+
renderSkeleton(MAX_ROWS);
|
|
13553
|
+
dataTimer=setTimeout(function(){if(!settled)hide();},DATA_TIMEOUT_MS);
|
|
13554
|
+
|
|
13555
|
+
request("ui/initialize",{
|
|
13556
|
+
appInfo:{name:"speakai-file-list",version:"1.0.0"},
|
|
13557
|
+
appCapabilities:{availableDisplayModes:["inline"]},
|
|
13558
|
+
protocolVersion:PROTOCOL_VERSION
|
|
13559
|
+
}).then(function(result){
|
|
13560
|
+
hostCaps=(result&&result.hostCapabilities)||{};
|
|
13561
|
+
applyContext(result&&result.hostContext);
|
|
13562
|
+
notify("ui/notifications/initialized",{});
|
|
13563
|
+
reportSize();
|
|
13564
|
+
}).catch(function(){});
|
|
13565
|
+
})();
|
|
13566
|
+
`;
|
|
13567
|
+
MEDIA_LIST_CARD_HTML = `<!doctype html>
|
|
13568
|
+
<html lang="en">
|
|
13569
|
+
<head>
|
|
13570
|
+
<meta charset="utf-8">
|
|
13571
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
13572
|
+
<title>Speak files</title>
|
|
13573
|
+
<style>${VIEW_STYLE}</style>
|
|
13574
|
+
</head>
|
|
13575
|
+
<body>
|
|
13576
|
+
<main id="card" class="card" hidden></main>
|
|
13577
|
+
<script>${VIEW_SCRIPT}</script>
|
|
13578
|
+
</body>
|
|
13579
|
+
</html>
|
|
13580
|
+
`;
|
|
13581
|
+
}
|
|
13582
|
+
});
|
|
13583
|
+
|
|
13584
|
+
// src/ui/media-list/index.ts
|
|
13585
|
+
function registerMediaListCard(server) {
|
|
13586
|
+
server.registerResource(
|
|
13587
|
+
"speakai-file-list-card",
|
|
13588
|
+
MEDIA_LIST_CARD_URI,
|
|
13589
|
+
{
|
|
13590
|
+
title: "Speak file list card",
|
|
13591
|
+
description: "Shows up to 3 Speak files from list_media or search_media in the chat.",
|
|
13592
|
+
mimeType: MCP_APP_MIME_TYPE,
|
|
13593
|
+
_meta: MEDIA_LIST_CARD_RESOURCE_META
|
|
13594
|
+
},
|
|
13595
|
+
async () => ({
|
|
13596
|
+
contents: [
|
|
13597
|
+
{
|
|
13598
|
+
uri: MEDIA_LIST_CARD_URI,
|
|
13599
|
+
mimeType: MCP_APP_MIME_TYPE,
|
|
13600
|
+
text: MEDIA_LIST_CARD_HTML,
|
|
13601
|
+
_meta: MEDIA_LIST_CARD_RESOURCE_META
|
|
13602
|
+
}
|
|
13603
|
+
]
|
|
13604
|
+
})
|
|
13605
|
+
);
|
|
13606
|
+
}
|
|
13607
|
+
var MEDIA_LIST_CARD_RESOURCE_META;
|
|
13608
|
+
var init_media_list = __esm({
|
|
13609
|
+
"src/ui/media-list/index.ts"() {
|
|
13610
|
+
"use strict";
|
|
13611
|
+
init_card_data();
|
|
13612
|
+
init_view();
|
|
13613
|
+
MEDIA_LIST_CARD_RESOURCE_META = {
|
|
13614
|
+
ui: {
|
|
13615
|
+
csp: { connectDomains: [], resourceDomains: [] },
|
|
13616
|
+
prefersBorder: false
|
|
13617
|
+
}
|
|
13618
|
+
};
|
|
13619
|
+
}
|
|
13620
|
+
});
|
|
13621
|
+
|
|
13093
13622
|
// src/tools/index.ts
|
|
13094
13623
|
var tools_exports = {};
|
|
13095
13624
|
__export(tools_exports, {
|
|
@@ -13097,9 +13626,11 @@ __export(tools_exports, {
|
|
|
13097
13626
|
});
|
|
13098
13627
|
function registerAllTools(server, client, options = {}) {
|
|
13099
13628
|
if (client) instrumentSpeakClient(client);
|
|
13629
|
+
if (options.onToolCall) setToolCallListener(server, options.onToolCall);
|
|
13100
13630
|
for (const mod of modules) {
|
|
13101
13631
|
mod.register(server, client, options);
|
|
13102
13632
|
}
|
|
13633
|
+
if (options.cards) registerMediaListCard(server);
|
|
13103
13634
|
}
|
|
13104
13635
|
var modules;
|
|
13105
13636
|
var init_tools = __esm({
|
|
@@ -13129,6 +13660,8 @@ var init_tools = __esm({
|
|
|
13129
13660
|
init_voice_intelligence();
|
|
13130
13661
|
init_billing3();
|
|
13131
13662
|
init_client();
|
|
13663
|
+
init_media_list();
|
|
13664
|
+
init_helpers();
|
|
13132
13665
|
modules = [
|
|
13133
13666
|
media_exports,
|
|
13134
13667
|
text_exports,
|
|
@@ -13794,9 +14327,9 @@ function createCli() {
|
|
|
13794
14327
|
process.exit(1);
|
|
13795
14328
|
}
|
|
13796
14329
|
try {
|
|
13797
|
-
const
|
|
14330
|
+
const axios4 = (await import("axios")).default;
|
|
13798
14331
|
const baseUrl = process.env.SPEAK_BASE_URL ?? "https://api.speakai.co";
|
|
13799
|
-
const res = await
|
|
14332
|
+
const res = await axios4.post(
|
|
13800
14333
|
`${baseUrl}/v1/auth/accessToken`,
|
|
13801
14334
|
{},
|
|
13802
14335
|
{ headers: { "Content-Type": "application/json", "x-speakai-key": key } }
|
|
@@ -13839,9 +14372,9 @@ function createCli() {
|
|
|
13839
14372
|
}
|
|
13840
14373
|
process.stdout.write(" Validating...");
|
|
13841
14374
|
try {
|
|
13842
|
-
const
|
|
14375
|
+
const axios4 = (await import("axios")).default;
|
|
13843
14376
|
const baseUrl = process.env.SPEAK_BASE_URL ?? "https://api.speakai.co";
|
|
13844
|
-
const res = await
|
|
14377
|
+
const res = await axios4.post(
|
|
13845
14378
|
`${baseUrl}/v1/auth/accessToken`,
|
|
13846
14379
|
{},
|
|
13847
14380
|
{ headers: { "Content-Type": "application/json", "x-speakai-key": key } }
|
|
@@ -14067,8 +14600,8 @@ function createCli() {
|
|
|
14067
14600
|
}
|
|
14068
14601
|
process.stdout.write("Uploading...");
|
|
14069
14602
|
const fileBuffer = fs3.readFileSync(source);
|
|
14070
|
-
const
|
|
14071
|
-
await
|
|
14603
|
+
const axios4 = (await import("axios")).default;
|
|
14604
|
+
await axios4.put(uploadUrl, fileBuffer, {
|
|
14072
14605
|
headers: { "Content-Type": mimeType },
|
|
14073
14606
|
maxBodyLength: Infinity,
|
|
14074
14607
|
maxContentLength: Infinity
|
|
@@ -15129,7 +15662,7 @@ if (isCliMode) {
|
|
|
15129
15662
|
name: "speak-ai",
|
|
15130
15663
|
version: "1.0.0"
|
|
15131
15664
|
});
|
|
15132
|
-
registerAllTools2(server, void 0, { localFileAccess: true, voiceTestRuns: true, aiChat: true, automations: true, voiceTestRunDetails: true });
|
|
15665
|
+
registerAllTools2(server, void 0, { localFileAccess: true, voiceTestRuns: true, aiChat: true, automations: true, voiceTestRunDetails: true, cards: process.env.SPEAK_MCP_CARDS === "true" });
|
|
15133
15666
|
registerResources2(server);
|
|
15134
15667
|
registerPrompts2(server);
|
|
15135
15668
|
const transport = new StdioServerTransport();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speakai/mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.43.0",
|
|
4
4
|
"mcpName": "io.github.speakai/mcp-server",
|
|
5
5
|
"description": "Official Speak AI MCP Server — capture meetings, search thousands of recordings, run async voice and video surveys, create clips, and automate workflows from your AI assistant.",
|
|
6
6
|
"homepage": "https://docs.speakai.co/mcp",
|