@speakai/mcp-server 1.26.0 → 1.28.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/dist/index.js CHANGED
@@ -1871,7 +1871,7 @@ function register(server, client) {
1871
1871
  {
1872
1872
  title: "Toggle Media Favorite",
1873
1873
  readOnlyHint: false,
1874
- destructiveHint: false,
1874
+ destructiveHint: true,
1875
1875
  idempotentHint: true,
1876
1876
  openWorldHint: false
1877
1877
  },
@@ -1905,7 +1905,7 @@ function register(server, client) {
1905
1905
  {
1906
1906
  title: "Re-analyze Media",
1907
1907
  readOnlyHint: false,
1908
- destructiveHint: false,
1908
+ destructiveHint: true,
1909
1909
  idempotentHint: false,
1910
1910
  openWorldHint: false
1911
1911
  },
@@ -2052,7 +2052,7 @@ function register2(server, client) {
2052
2052
  readOnlyHint: false,
2053
2053
  destructiveHint: false,
2054
2054
  idempotentHint: false,
2055
- openWorldHint: false
2055
+ openWorldHint: true
2056
2056
  },
2057
2057
  async (body) => {
2058
2058
  try {
@@ -2110,7 +2110,7 @@ function register2(server, client) {
2110
2110
  {
2111
2111
  title: "Re-analyze Text Note",
2112
2112
  readOnlyHint: false,
2113
- destructiveHint: false,
2113
+ destructiveHint: true,
2114
2114
  idempotentHint: false,
2115
2115
  openWorldHint: false
2116
2116
  },
@@ -2719,7 +2719,7 @@ function register5(server, client) {
2719
2719
  readOnlyHint: false,
2720
2720
  destructiveHint: false,
2721
2721
  idempotentHint: false,
2722
- openWorldHint: false
2722
+ openWorldHint: true
2723
2723
  },
2724
2724
  async (body) => {
2725
2725
  try {
@@ -2780,7 +2780,7 @@ function register5(server, client) {
2780
2780
  readOnlyHint: false,
2781
2781
  destructiveHint: false,
2782
2782
  idempotentHint: false,
2783
- openWorldHint: false
2783
+ openWorldHint: true
2784
2784
  },
2785
2785
  async (body) => {
2786
2786
  try {
@@ -2892,9 +2892,9 @@ function register5(server, client) {
2892
2892
  {
2893
2893
  title: "Update Recorder Settings",
2894
2894
  readOnlyHint: false,
2895
- destructiveHint: false,
2895
+ destructiveHint: true,
2896
2896
  idempotentHint: true,
2897
- openWorldHint: false
2897
+ openWorldHint: true
2898
2898
  },
2899
2899
  async ({ recorderId, ...body }) => {
2900
2900
  try {
@@ -2930,7 +2930,7 @@ function register5(server, client) {
2930
2930
  readOnlyHint: false,
2931
2931
  destructiveHint: true,
2932
2932
  idempotentHint: true,
2933
- openWorldHint: false
2933
+ openWorldHint: true
2934
2934
  },
2935
2935
  async ({ recorderId, ...body }) => {
2936
2936
  try {
@@ -2958,7 +2958,7 @@ function register5(server, client) {
2958
2958
  readOnlyHint: false,
2959
2959
  destructiveHint: true,
2960
2960
  idempotentHint: true,
2961
- openWorldHint: false
2961
+ openWorldHint: true
2962
2962
  },
2963
2963
  async ({ recorderId }) => {
2964
2964
  try {
@@ -3021,7 +3021,7 @@ function register6(server, client) {
3021
3021
  registerSpeakTool(
3022
3022
  server,
3023
3023
  "create_embed",
3024
- "Create an embeddable player/transcript widget for a media file or a set of folders. Provide `mediaId` for a single-media embed, or `folderIds` for a folder/library embed.",
3024
+ "Create an embeddable player/transcript widget for a media file or a set of folders. Provide `mediaId` for a single-media embed, or `folderIds` for a folder/library embed. The embed is publicly viewable by default; use update_embed to set a password or privacy mode.",
3025
3025
  {
3026
3026
  mediaId: import_zod7.z.string().optional().describe("Media file to embed (for a single-media embed)"),
3027
3027
  folderIds: import_zod7.z.array(import_zod7.z.string()).optional().describe("Folder IDs to embed (for a folder/library embed)")
@@ -3029,9 +3029,9 @@ function register6(server, client) {
3029
3029
  {
3030
3030
  title: "Create Embed Widget",
3031
3031
  readOnlyHint: false,
3032
- destructiveHint: false,
3032
+ destructiveHint: true,
3033
3033
  idempotentHint: false,
3034
- openWorldHint: false
3034
+ openWorldHint: true
3035
3035
  },
3036
3036
  async (body) => {
3037
3037
  try {
@@ -3067,7 +3067,7 @@ function register6(server, client) {
3067
3067
  readOnlyHint: false,
3068
3068
  destructiveHint: true,
3069
3069
  idempotentHint: true,
3070
- openWorldHint: false
3070
+ openWorldHint: true
3071
3071
  },
3072
3072
  async ({ embedId, ...body }) => {
3073
3073
  try {
@@ -3485,7 +3485,7 @@ function register7(server, client) {
3485
3485
  {
3486
3486
  title: "Toggle Prompt Favorite",
3487
3487
  readOnlyHint: false,
3488
- destructiveHint: false,
3488
+ destructiveHint: true,
3489
3489
  idempotentHint: true,
3490
3490
  openWorldHint: false
3491
3491
  },
@@ -3514,7 +3514,7 @@ function register7(server, client) {
3514
3514
  {
3515
3515
  title: "Rename Chat",
3516
3516
  readOnlyHint: false,
3517
- destructiveHint: false,
3517
+ destructiveHint: true,
3518
3518
  idempotentHint: true,
3519
3519
  openWorldHint: false
3520
3520
  },
@@ -3688,7 +3688,7 @@ function register8(server, client) {
3688
3688
  {
3689
3689
  title: "Schedule AI Meeting Assistant",
3690
3690
  readOnlyHint: false,
3691
- destructiveHint: false,
3691
+ destructiveHint: true,
3692
3692
  idempotentHint: false,
3693
3693
  openWorldHint: true
3694
3694
  },
@@ -3719,7 +3719,7 @@ function register8(server, client) {
3719
3719
  {
3720
3720
  title: "Remove Assistant from Meeting",
3721
3721
  readOnlyHint: false,
3722
- destructiveHint: false,
3722
+ destructiveHint: true,
3723
3723
  idempotentHint: true,
3724
3724
  openWorldHint: true
3725
3725
  },
@@ -3785,7 +3785,7 @@ function register8(server, client) {
3785
3785
  readOnlyHint: true,
3786
3786
  destructiveHint: false,
3787
3787
  idempotentHint: false,
3788
- openWorldHint: true
3788
+ openWorldHint: false
3789
3789
  },
3790
3790
  async ({ meetingAssistantEventId, mediaId, sinceEndInSec }) => {
3791
3791
  if (!meetingAssistantEventId && !mediaId) {
@@ -4869,7 +4869,7 @@ function register10(server, client) {
4869
4869
  readOnlyHint: false,
4870
4870
  destructiveHint: false,
4871
4871
  idempotentHint: false,
4872
- openWorldHint: false
4872
+ openWorldHint: true
4873
4873
  },
4874
4874
  async (body) => {
4875
4875
  try {
@@ -4911,7 +4911,7 @@ function register10(server, client) {
4911
4911
  readOnlyHint: false,
4912
4912
  destructiveHint: true,
4913
4913
  idempotentHint: true,
4914
- openWorldHint: false
4914
+ openWorldHint: true
4915
4915
  },
4916
4916
  async ({ automationId, ...body }) => {
4917
4917
  try {
@@ -4949,7 +4949,7 @@ function register10(server, client) {
4949
4949
  {
4950
4950
  title: "Toggle Automation Status",
4951
4951
  readOnlyHint: false,
4952
- destructiveHint: false,
4952
+ destructiveHint: true,
4953
4953
  idempotentHint: false,
4954
4954
  openWorldHint: false
4955
4955
  },
@@ -4978,7 +4978,7 @@ function register10(server, client) {
4978
4978
  {
4979
4979
  title: "Bulk Update Automation Status",
4980
4980
  readOnlyHint: false,
4981
- destructiveHint: false,
4981
+ destructiveHint: true,
4982
4982
  idempotentHint: true,
4983
4983
  openWorldHint: false
4984
4984
  },
@@ -5036,7 +5036,7 @@ function register10(server, client) {
5036
5036
  {
5037
5037
  title: "Run Automations",
5038
5038
  readOnlyHint: false,
5039
- destructiveHint: false,
5039
+ destructiveHint: true,
5040
5040
  idempotentHint: false,
5041
5041
  openWorldHint: true
5042
5042
  },
@@ -5496,7 +5496,7 @@ function register11(server, client) {
5496
5496
  {
5497
5497
  title: "Update Webhook",
5498
5498
  readOnlyHint: false,
5499
- destructiveHint: false,
5499
+ destructiveHint: true,
5500
5500
  idempotentHint: true,
5501
5501
  openWorldHint: true
5502
5502
  },
@@ -5840,7 +5840,7 @@ function register13(server, client) {
5840
5840
  {
5841
5841
  title: "Update Clip",
5842
5842
  readOnlyHint: false,
5843
- destructiveHint: false,
5843
+ destructiveHint: true,
5844
5844
  idempotentHint: true,
5845
5845
  openWorldHint: false
5846
5846
  },
@@ -5949,7 +5949,7 @@ function resolveField(ref, fields) {
5949
5949
  const available = fields.map((f) => f.name).slice(0, 25).join(", ");
5950
5950
  throw new Error(`Unknown custom field "${ref}". Available fields: ${available || "(none \u2014 create one with create_field)"}`);
5951
5951
  }
5952
- function register14(server, client) {
5952
+ function register14(server, client, options = {}) {
5953
5953
  const api = client ?? speakClient;
5954
5954
  registerSpeakTool(
5955
5955
  server,
@@ -5961,7 +5961,7 @@ function register14(server, client) {
5961
5961
  readOnlyHint: false,
5962
5962
  destructiveHint: true,
5963
5963
  idempotentHint: false,
5964
- openWorldHint: false
5964
+ openWorldHint: true
5965
5965
  },
5966
5966
  async (args2) => {
5967
5967
  const { name, trigger, steps, automationId, description, isActive, orTriggers } = args2;
@@ -6420,7 +6420,7 @@ ${JSON.stringify(uploadRes.data, null, 2)}` }],
6420
6420
  };
6421
6421
  }
6422
6422
  );
6423
- registerSpeakTool(
6423
+ if (options.localFileAccess) registerSpeakTool(
6424
6424
  server,
6425
6425
  "upload_local_file",
6426
6426
  [
@@ -7268,7 +7268,7 @@ function register16(server, client) {
7268
7268
  readOnlyHint: false,
7269
7269
  destructiveHint: true,
7270
7270
  idempotentHint: false,
7271
- openWorldHint: false
7271
+ openWorldHint: true
7272
7272
  },
7273
7273
  async ({ dashboardId, title, revision, description, source, dateRange, sections, widgets, ...metadata }) => {
7274
7274
  try {
@@ -7319,7 +7319,7 @@ function register16(server, client) {
7319
7319
  readOnlyHint: false,
7320
7320
  destructiveHint: true,
7321
7321
  idempotentHint: true,
7322
- openWorldHint: false
7322
+ openWorldHint: true
7323
7323
  },
7324
7324
  async ({ dashboardId }) => {
7325
7325
  try {
@@ -7373,9 +7373,9 @@ function register16(server, client) {
7373
7373
  {
7374
7374
  title: "Share Dashboard",
7375
7375
  readOnlyHint: false,
7376
- destructiveHint: false,
7376
+ destructiveHint: true,
7377
7377
  idempotentHint: true,
7378
- openWorldHint: false
7378
+ openWorldHint: true
7379
7379
  },
7380
7380
  async ({ dashboardId }) => {
7381
7381
  try {
@@ -7556,145 +7556,1306 @@ var init_dashboards = __esm({
7556
7556
  }
7557
7557
  });
7558
7558
 
7559
- // src/tools/index.ts
7560
- var tools_exports = {};
7561
- __export(tools_exports, {
7562
- registerAllTools: () => registerAllTools
7563
- });
7564
- function registerAllTools(server, client) {
7565
- for (const mod of modules) {
7566
- mod.register(server, client);
7567
- }
7568
- }
7569
- var modules;
7570
- var init_tools = __esm({
7571
- "src/tools/index.ts"() {
7572
- "use strict";
7573
- init_media3();
7574
- init_text2();
7575
- init_exports();
7576
- init_folders();
7577
- init_recorder3();
7578
- init_embed3();
7579
- init_prompt3();
7580
- init_meeting3();
7581
- init_fields2();
7582
- init_automations();
7583
- init_webhooks();
7584
- init_analytics();
7585
- init_clips();
7586
- init_workflows();
7587
- init_users();
7588
- init_dashboards();
7589
- modules = [
7590
- media_exports,
7591
- text_exports,
7592
- exports_exports,
7593
- folders_exports,
7594
- recorder_exports,
7595
- embed_exports,
7596
- prompt_exports,
7597
- meeting_exports,
7598
- fields_exports,
7599
- automations_exports,
7600
- webhooks_exports,
7601
- analytics_exports,
7602
- clips_exports,
7603
- workflows_exports,
7604
- users_exports,
7605
- dashboards_exports
7606
- ];
7607
- }
7608
- });
7609
-
7610
- // src/resources.ts
7611
- var resources_exports = {};
7612
- __export(resources_exports, {
7613
- registerResources: () => registerResources
7559
+ // src/tools/voice.ts
7560
+ var voice_exports = {};
7561
+ __export(voice_exports, {
7562
+ register: () => register17
7614
7563
  });
7615
- function asJsonContent(uri, data) {
7616
- return {
7617
- contents: [
7618
- {
7619
- uri,
7620
- mimeType: "application/json",
7621
- text: JSON.stringify(data, null, 2)
7622
- }
7623
- ]
7624
- };
7625
- }
7626
- function reportError(label, err) {
7627
- const detail = formatAxiosError(err);
7628
- throw new Error(`Speak AI resource '${label}' failed: ${detail}`);
7629
- }
7630
- function registerResources(server, client) {
7564
+ function register17(server, client) {
7631
7565
  const api = client ?? speakClient;
7632
- server.resource(
7633
- "media-library",
7634
- "speakai://media",
7635
- { description: "List of all media files in your Speak AI workspace" },
7566
+ registerSpeakTool(
7567
+ server,
7568
+ "list_voice_agents",
7569
+ "List the voice agents in the company (newest first). Each agent includes its agentId, name, personality/instructions, and voice/stt/llm/avatar configuration. Use the returned agentId with get_voice_agent or to filter list_voice_conversations.",
7570
+ {},
7571
+ {
7572
+ title: "List Voice Agents",
7573
+ readOnlyHint: true,
7574
+ destructiveHint: false,
7575
+ idempotentHint: true,
7576
+ openWorldHint: false
7577
+ },
7636
7578
  async () => {
7637
7579
  try {
7638
- const result = await api.get("/v1/media", {
7639
- params: { page: 0, pageSize: 50, sortBy: "createdAt:desc", filterMedia: 2 }
7640
- });
7641
- return asJsonContent("speakai://media", result.data?.data);
7580
+ const result = await api.get("/v1/voice/agents");
7581
+ return {
7582
+ content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
7583
+ };
7642
7584
  } catch (err) {
7643
- reportError("media-library", err);
7585
+ return {
7586
+ content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
7587
+ isError: true
7588
+ };
7644
7589
  }
7645
7590
  }
7646
7591
  );
7647
- server.resource(
7648
- "folders",
7649
- "speakai://folders",
7650
- { description: "List of all folders in your Speak AI workspace" },
7651
- async () => {
7592
+ registerSpeakTool(
7593
+ server,
7594
+ "get_voice_agent",
7595
+ "Fetch a single voice agent by its agentId. Returns the full agent configuration. A cross-company agentId returns 404.",
7596
+ {
7597
+ agentId: import_zod18.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)")
7598
+ },
7599
+ {
7600
+ title: "Get Voice Agent",
7601
+ readOnlyHint: true,
7602
+ destructiveHint: false,
7603
+ idempotentHint: true,
7604
+ openWorldHint: false
7605
+ },
7606
+ async ({ agentId }) => {
7652
7607
  try {
7653
- const result = await api.get("/v1/folder", {
7654
- params: { page: 0, pageSize: 100, sortBy: "createdAt:desc" }
7655
- });
7656
- return asJsonContent("speakai://folders", result.data?.data);
7608
+ const result = await api.get(`/v1/voice/agents/${agentId}`);
7609
+ return {
7610
+ content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
7611
+ };
7657
7612
  } catch (err) {
7658
- reportError("folders", err);
7613
+ return {
7614
+ content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
7615
+ isError: true
7616
+ };
7659
7617
  }
7660
7618
  }
7661
7619
  );
7662
- server.resource(
7663
- "supported-languages",
7664
- "speakai://languages",
7665
- { description: "List of supported transcription languages" },
7666
- async () => {
7620
+ registerSpeakTool(
7621
+ server,
7622
+ "list_voice_conversations",
7623
+ "List the company's voice conversations (newest first). Optionally filter to a single agent. Each conversation includes its conversationId, agentId, status, duration, transcript summary, and usage/costs. Use conversationId with get_voice_conversation for the full record.",
7624
+ {
7625
+ agentId: import_zod18.z.string().optional().describe("Filter conversations to a single agent (from list_voice_agents)"),
7626
+ page: import_zod18.z.number().int().min(1).optional().describe("1-based page index (default 1)"),
7627
+ limit: import_zod18.z.number().int().min(1).max(200).optional().describe("Results per page (default 50, max 200)")
7628
+ },
7629
+ {
7630
+ title: "List Voice Conversations",
7631
+ readOnlyHint: true,
7632
+ destructiveHint: false,
7633
+ idempotentHint: true,
7634
+ openWorldHint: false
7635
+ },
7636
+ async (params) => {
7667
7637
  try {
7668
- const result = await api.get("/v1/media/supportedLanguages");
7669
- return asJsonContent("speakai://languages", result.data?.data);
7638
+ const result = await api.get("/v1/voice/conversations", { params });
7639
+ return {
7640
+ content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
7641
+ };
7670
7642
  } catch (err) {
7671
- reportError("supported-languages", err);
7643
+ return {
7644
+ content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
7645
+ isError: true
7646
+ };
7672
7647
  }
7673
7648
  }
7674
7649
  );
7675
- server.resource(
7676
- "transcript",
7677
- new import_mcp.ResourceTemplate("speakai://media/{mediaId}/transcript", { list: void 0 }),
7678
- { description: "Full transcript for a specific media file" },
7679
- async (uri, { mediaId }) => {
7650
+ registerSpeakTool(
7651
+ server,
7652
+ "get_voice_conversation",
7653
+ "Fetch a single voice conversation by its conversationId, including transcript, usage, costs, and analysis. A cross-company conversationId returns 404.",
7654
+ {
7655
+ conversationId: import_zod18.z.string().min(1).describe("ID of the conversation (from list_voice_conversations)")
7656
+ },
7657
+ {
7658
+ title: "Get Voice Conversation",
7659
+ readOnlyHint: true,
7660
+ destructiveHint: false,
7661
+ idempotentHint: true,
7662
+ openWorldHint: false
7663
+ },
7664
+ async ({ conversationId }) => {
7680
7665
  try {
7681
- const result = await api.get(`/v1/media/transcript/${mediaId}`);
7682
- return asJsonContent(uri.href, result.data?.data);
7666
+ const result = await api.get(`/v1/voice/conversations/${conversationId}`);
7667
+ return {
7668
+ content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
7669
+ };
7683
7670
  } catch (err) {
7684
- reportError(`transcript(${mediaId})`, err);
7671
+ return {
7672
+ content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
7673
+ isError: true
7674
+ };
7685
7675
  }
7686
7676
  }
7687
7677
  );
7688
- server.resource(
7689
- "insights",
7690
- new import_mcp.ResourceTemplate("speakai://media/{mediaId}/insights", { list: void 0 }),
7691
- { description: "AI-generated insights for a specific media file" },
7692
- async (uri, { mediaId }) => {
7678
+ registerSpeakTool(
7679
+ server,
7680
+ "create_voice_agent",
7681
+ "Create a voice agent. Requires the OWNER or ADMIN role. name, personality, instructions, and voice (provider + voiceId) are required; everything else can be set now or later with update_voice_agent. Call list_voice_avatars or list_voices first to get valid ids.",
7682
+ voiceInputSchema,
7683
+ {
7684
+ title: "Create Voice Agent",
7685
+ readOnlyHint: false,
7686
+ destructiveHint: false,
7687
+ idempotentHint: false,
7688
+ openWorldHint: false
7689
+ },
7690
+ async (body) => {
7693
7691
  try {
7694
- const result = await api.get(`/v1/media/insight/${mediaId}`);
7695
- return asJsonContent(uri.href, result.data?.data);
7692
+ const result = await api.post("/v1/voice/agents", body);
7693
+ return {
7694
+ content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
7695
+ };
7696
7696
  } catch (err) {
7697
- reportError(`insights(${mediaId})`, err);
7697
+ return {
7698
+ content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
7699
+ isError: true
7700
+ };
7701
+ }
7702
+ }
7703
+ );
7704
+ registerSpeakTool(
7705
+ server,
7706
+ "update_voice_agent",
7707
+ "Update a voice agent. Requires the OWNER or ADMIN role. Send only the fields you want to change; agentId, companyId, and userId are immutable and silently dropped if sent.",
7708
+ {
7709
+ agentId: import_zod18.z.string().min(1).describe("ID of the voice agent to update (from list_voice_agents)"),
7710
+ ...Object.fromEntries(
7711
+ Object.entries(voiceInputSchema).map(([key, schema]) => [key, schema.optional()])
7712
+ )
7713
+ },
7714
+ {
7715
+ title: "Update Voice Agent",
7716
+ readOnlyHint: false,
7717
+ destructiveHint: true,
7718
+ idempotentHint: false,
7719
+ openWorldHint: false
7720
+ },
7721
+ async ({ agentId, ...body }) => {
7722
+ try {
7723
+ const result = await api.put(`/v1/voice/agents/${agentId}`, body);
7724
+ return {
7725
+ content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
7726
+ };
7727
+ } catch (err) {
7728
+ return {
7729
+ content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
7730
+ isError: true
7731
+ };
7732
+ }
7733
+ }
7734
+ );
7735
+ registerSpeakTool(
7736
+ server,
7737
+ "list_voice_avatars",
7738
+ "List the video avatars available to attach to a voice agent (your company's own uploads plus the shared system catalog). Use the returned avatarId with create_voice_agent or update_voice_agent.",
7739
+ {},
7740
+ {
7741
+ title: "List Voice Avatars",
7742
+ readOnlyHint: true,
7743
+ destructiveHint: false,
7744
+ idempotentHint: true,
7745
+ openWorldHint: false
7746
+ },
7747
+ async () => {
7748
+ try {
7749
+ const result = await api.get("/v1/voice/avatars");
7750
+ return {
7751
+ content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
7752
+ };
7753
+ } catch (err) {
7754
+ return {
7755
+ content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
7756
+ isError: true
7757
+ };
7758
+ }
7759
+ }
7760
+ );
7761
+ registerSpeakTool(
7762
+ server,
7763
+ "list_voices",
7764
+ "List the text-to-speech voices available to a voice agent. Use the returned provider/voiceId with create_voice_agent or update_voice_agent's voice field. When an agent's llm.model is a Live (speech-to-speech) model, its usable voices are a fixed, smaller set scoped to that model instead of this full catalog.",
7765
+ {},
7766
+ {
7767
+ title: "List Voices",
7768
+ readOnlyHint: true,
7769
+ destructiveHint: false,
7770
+ idempotentHint: true,
7771
+ openWorldHint: false
7772
+ },
7773
+ async () => {
7774
+ try {
7775
+ const result = await api.get("/v1/voice/voices");
7776
+ return {
7777
+ content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
7778
+ };
7779
+ } catch (err) {
7780
+ return {
7781
+ content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
7782
+ isError: true
7783
+ };
7784
+ }
7785
+ }
7786
+ );
7787
+ registerSpeakTool(
7788
+ server,
7789
+ "delete_voice_agent",
7790
+ "Permanently delete a voice agent. Requires the OWNER or ADMIN role. Irreversible: also removes its questions, test suite, and share link; past conversations are kept for record-keeping but are no longer reachable from this agent.",
7791
+ { agentId: import_zod18.z.string().min(1).describe("ID of the voice agent to delete (from list_voice_agents)") },
7792
+ { title: "Delete Voice Agent", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
7793
+ async ({ agentId }) => {
7794
+ try {
7795
+ const result = await api.delete(`/v1/voice/agents/${agentId}`);
7796
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
7797
+ } catch (err) {
7798
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
7799
+ }
7800
+ }
7801
+ );
7802
+ registerSpeakTool(
7803
+ server,
7804
+ "create_voice_agent_from_prompt",
7805
+ "Create a new voice agent by describing it in plain English instead of filling in name/personality/instructions/voice yourself. Requires the OWNER or ADMIN role. Response always includes the new agentId, plus either the generated agent config, or needsFollowUp: true with a follow-up question if the prompt was too thin to act on \u2014 call generate_voice_agent_config again on that agentId with more detail (or manualInstructions) when that happens.",
7806
+ {
7807
+ prompt: import_zod18.z.string().min(1).describe('Plain-English description of the agent to build, e.g. "a friendly dental clinic receptionist that books appointments and answers insurance questions".'),
7808
+ name: import_zod18.z.string().optional().describe("Agent name. Defaults to one derived from the prompt if omitted."),
7809
+ manualInstructions: import_zod18.z.string().optional().describe("Skip generation and use this as the agent's instructions verbatim.")
7810
+ },
7811
+ { title: "Create Voice Agent From Prompt", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
7812
+ async (body) => {
7813
+ try {
7814
+ const result = await api.post("/v1/voice/agents/generation", body);
7815
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
7816
+ } catch (err) {
7817
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
7818
+ }
7819
+ }
7820
+ );
7821
+ registerSpeakTool(
7822
+ server,
7823
+ "generate_voice_agent_config",
7824
+ "Run the same prompt-to-config generation as create_voice_agent_from_prompt, but against an existing agent instead of creating a new one. Requires the OWNER or ADMIN role. On success the generated config is persisted onto the agent immediately. If the prompt is too thin and manualInstructions was not sent, the response has needsFollowUp: true with a follow-up question instead \u2014 call this again with more detail.",
7825
+ {
7826
+ agentId: import_zod18.z.string().min(1).describe("ID of the existing voice agent to generate config for (from list_voice_agents)"),
7827
+ prompt: import_zod18.z.string().min(1).describe("Plain-English description of what the agent should do."),
7828
+ manualInstructions: import_zod18.z.string().optional().describe("Skip generation and set the agent's instructions to this verbatim.")
7829
+ },
7830
+ { title: "Generate Voice Agent Config", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
7831
+ async ({ agentId, ...body }) => {
7832
+ try {
7833
+ const result = await api.post(`/v1/voice/agents/${agentId}/generation/generate`, body);
7834
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
7835
+ } catch (err) {
7836
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
7837
+ }
7838
+ }
7839
+ );
7840
+ registerSpeakTool(
7841
+ server,
7842
+ "get_voice_agent_setup_guide",
7843
+ "Discovery + how-to helper for building and operating a Speak AI voice agent end to end. Returns the four configuration pieces every agent is built from, which tool covers each one, the recommended build order, and how testing/questions/knowledge-base/intelligence tools chain together after the agent exists. Call this before create_voice_agent or create_voice_agent_from_prompt if you are not already familiar with this tool surface.",
7844
+ {},
7845
+ { title: "Get Voice Agent Setup Guide", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
7846
+ async () => {
7847
+ const data = {
7848
+ overview: "A voice agent is a standalone resource: create it once, then it holds live spoken conversations, asking configured questions and answering from a knowledge base. It is built from four independent pieces, plus optional testing, sharing, and self-improvement layers.",
7849
+ buildOrder: [
7850
+ {
7851
+ step: 1,
7852
+ piece: "The agent record itself",
7853
+ tools: ["create_voice_agent", "create_voice_agent_from_prompt"],
7854
+ notes: "name, personality, instructions, and voice (provider+voiceId) are the only required fields. Call list_voices and list_voice_avatars first to get valid ids."
7855
+ },
7856
+ {
7857
+ step: 2,
7858
+ piece: "Voice & avatar",
7859
+ tools: ["list_voices", "list_voice_avatars", "update_voice_agent"],
7860
+ notes: "Every agent needs a voice. It only needs an avatar if conversationMode is video_avatar."
7861
+ },
7862
+ {
7863
+ step: 3,
7864
+ piece: "Instructions & behavior",
7865
+ tools: ["update_voice_agent", "generate_voice_agent_config"],
7866
+ notes: "personality/instructions are plain fields on the agent record; generate_voice_agent_config can (re)write them from a prompt instead of hand-authoring."
7867
+ },
7868
+ {
7869
+ step: 4,
7870
+ piece: "Questions",
7871
+ tools: ["list_voice_question_templates", "create_voice_question", "reorder_voice_questions"],
7872
+ notes: "Optional. Attaches a question template to the agent so it collects structured data mid-call. See the Questions tool group."
7873
+ },
7874
+ {
7875
+ step: 5,
7876
+ piece: "Knowledge base",
7877
+ tools: ["Knowledge Base tool group (separate from voice agents)"],
7878
+ notes: "Optional. A knowledge base collection is attached to the agent from the Knowledge Base API, not a voice-agent tool -- an agent has no documents of its own until one is attached."
7879
+ }
7880
+ ],
7881
+ afterTheAgentExists: [
7882
+ {
7883
+ area: "Testing",
7884
+ tools: ["get_voice_test_suite", "update_voice_test_suite", "generate_voice_test_suite", "start_voice_test_run"],
7885
+ notes: "Scripted scenarios and a run history. The run lifecycle is live; the engine that drives a simulated conversation is not wired up yet, so a run stays queued."
7886
+ },
7887
+ {
7888
+ area: "Feedback / self-improvement (Intelligence)",
7889
+ tools: [
7890
+ "list_voice_kb_gaps",
7891
+ "list_voice_faq_suggestions",
7892
+ "analyze_voice_instruction_gaps",
7893
+ "list_voice_agent_resources"
7894
+ ],
7895
+ notes: "What the agent surfaces from real calls: knowledge it lacked, questions callers repeat, and gaps in its own instructions. Nothing is written automatically -- every suggestion needs an explicit add/apply/dismiss call."
7896
+ },
7897
+ {
7898
+ area: "Conversations & analytics",
7899
+ tools: ["list_voice_conversations", "get_voice_conversation"],
7900
+ notes: "Read call history and transcripts once the agent has taken calls."
7901
+ }
7902
+ ],
7903
+ commonMistakes: [
7904
+ "Calling create_voice_agent with a made-up voiceId instead of one from list_voices -- the create call fails validation.",
7905
+ "Expecting start_voice_test_run to return real scores -- the execution engine isn't wired up yet, see the Testing tools' own descriptions.",
7906
+ "Looking for a knowledge-base tool in this group -- collections are managed by the separate Knowledge Base tool group and only attached here."
7907
+ ]
7908
+ };
7909
+ return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
7910
+ }
7911
+ );
7912
+ }
7913
+ var import_zod18, voiceInputSchema;
7914
+ var init_voice = __esm({
7915
+ "src/tools/voice.ts"() {
7916
+ "use strict";
7917
+ import_zod18 = require("zod");
7918
+ init_helpers();
7919
+ init_client();
7920
+ voiceInputSchema = {
7921
+ name: import_zod18.z.string().min(1).describe("Required on create. Trimmed, non-empty."),
7922
+ personality: import_zod18.z.string().describe("Required on create. Free text describing the agent's tone."),
7923
+ instructions: import_zod18.z.string().describe("Required on create. The agent's system instructions."),
7924
+ voice: import_zod18.z.object({
7925
+ provider: import_zod18.z.string().describe("TTS provider, e.g. elevenlabs or openai."),
7926
+ voiceId: import_zod18.z.string(),
7927
+ model: import_zod18.z.string().optional()
7928
+ }).describe("Required on create."),
7929
+ llm: import_zod18.z.object({
7930
+ provider: import_zod18.z.string().optional().describe("Must be one of the voice-agent LLM providers if sent."),
7931
+ model: import_zod18.z.string().optional().describe("Must be one of the voice-agent model ids if sent.")
7932
+ }).optional(),
7933
+ avatar: import_zod18.z.object({
7934
+ avatarId: import_zod18.z.string().describe("Must match a row in your company's avatar catalog (list_voice_avatars) or the shared system catalog.")
7935
+ }).optional().describe("Set to attach a video avatar; avatarUrl/provider are derived server-side from the catalog row."),
7936
+ conversationMode: import_zod18.z.enum(["voice_only", "video_avatar"]).optional(),
7937
+ folderId: import_zod18.z.string().optional().describe("Folder to file this agent's conversations under."),
7938
+ enableWebSearch: import_zod18.z.boolean().optional().describe("Let the agent search the web mid-call, separate from any attached knowledge base.")
7939
+ };
7940
+ }
7941
+ });
7942
+
7943
+ // src/tools/voice-testing.ts
7944
+ var voice_testing_exports = {};
7945
+ __export(voice_testing_exports, {
7946
+ register: () => register18
7947
+ });
7948
+ function register18(server, client) {
7949
+ const api = client ?? speakClient;
7950
+ registerSpeakTool(
7951
+ server,
7952
+ "get_voice_test_suite",
7953
+ "Get a voice agent's test suite (its scenarios and run settings). Returns null in data.suite if none has been created yet \u2014 not a 404.",
7954
+ { agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)") },
7955
+ { title: "Get Voice Test Suite", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
7956
+ async ({ agentId }) => {
7957
+ try {
7958
+ const result = await api.get(`/v1/voice/testing/${agentId}/suite`);
7959
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
7960
+ } catch (err) {
7961
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
7962
+ }
7963
+ }
7964
+ );
7965
+ registerSpeakTool(
7966
+ server,
7967
+ "update_voice_test_suite",
7968
+ "Create or update a voice agent's test suite. Requires the OWNER or ADMIN role. Upserts. Send the full scenarios array you want to keep \u2014 it replaces the stored one, it is not merged.",
7969
+ {
7970
+ agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
7971
+ scenarios: import_zod19.z.array(scenarioSchema).optional(),
7972
+ maxCostPerRun: import_zod19.z.number().min(0).optional(),
7973
+ autoRunOnKbUpdate: import_zod19.z.boolean().optional(),
7974
+ autoRunOnInstructionSave: import_zod19.z.boolean().optional(),
7975
+ scheduledCron: import_zod19.z.string().optional().nullable()
7976
+ },
7977
+ { title: "Update Voice Test Suite", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
7978
+ async ({ agentId, ...body }) => {
7979
+ try {
7980
+ const result = await api.put(`/v1/voice/testing/${agentId}/suite`, body);
7981
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
7982
+ } catch (err) {
7983
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
7984
+ }
7985
+ }
7986
+ );
7987
+ registerSpeakTool(
7988
+ server,
7989
+ "generate_voice_test_suite",
7990
+ "Auto-generate a default test suite for a voice agent from its own instructions and knowledge base, via an LLM call. Requires the OWNER or ADMIN role. Overwrites the suite's existing scenarios.",
7991
+ { agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)") },
7992
+ { title: "Generate Voice Test Suite", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
7993
+ async ({ agentId }) => {
7994
+ try {
7995
+ const result = await api.post(`/v1/voice/testing/${agentId}/suite/generate`);
7996
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
7997
+ } catch (err) {
7998
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
7999
+ }
8000
+ }
8001
+ );
8002
+ registerSpeakTool(
8003
+ server,
8004
+ "start_voice_test_run",
8005
+ "Start a test run against a voice agent's suite. Requires the OWNER or ADMIN role. Rejects with 409 if the agent has no test suite." + NOT_WIRED_NOTE,
8006
+ { agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)") },
8007
+ { title: "Start Voice Test Run", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
8008
+ async ({ agentId }) => {
8009
+ try {
8010
+ const result = await api.post(`/v1/voice/testing/${agentId}/run`);
8011
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8012
+ } catch (err) {
8013
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8014
+ }
8015
+ }
8016
+ );
8017
+ registerSpeakTool(
8018
+ server,
8019
+ "get_active_voice_test_run",
8020
+ "Get a voice agent's currently active test run (queued, running, or paused). Returns null in data.run if none is active \u2014 not a 404.",
8021
+ { agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)") },
8022
+ { title: "Get Active Voice Test Run", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
8023
+ async ({ agentId }) => {
8024
+ try {
8025
+ const result = await api.get(`/v1/voice/testing/${agentId}/run/active`);
8026
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8027
+ } catch (err) {
8028
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8029
+ }
8030
+ }
8031
+ );
8032
+ registerSpeakTool(
8033
+ server,
8034
+ "pause_voice_test_run",
8035
+ "Pause a voice agent's test run. Requires the OWNER or ADMIN role. Valid only from queued or running." + NOT_WIRED_NOTE,
8036
+ {
8037
+ agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8038
+ runId: import_zod19.z.string().min(1).describe("ID of the run (from get_active_voice_test_run or list_voice_test_runs)")
8039
+ },
8040
+ { title: "Pause Voice Test Run", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
8041
+ async ({ agentId, runId }) => {
8042
+ try {
8043
+ const result = await api.post(`/v1/voice/testing/${agentId}/run/${runId}/pause`);
8044
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8045
+ } catch (err) {
8046
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8047
+ }
8048
+ }
8049
+ );
8050
+ registerSpeakTool(
8051
+ server,
8052
+ "resume_voice_test_run",
8053
+ "Resume a paused voice agent test run, transitioning it back to running. Requires the OWNER or ADMIN role. Valid only from paused.",
8054
+ {
8055
+ agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8056
+ runId: import_zod19.z.string().min(1).describe("ID of the run (from get_active_voice_test_run or list_voice_test_runs)")
8057
+ },
8058
+ { title: "Resume Voice Test Run", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
8059
+ async ({ agentId, runId }) => {
8060
+ try {
8061
+ const result = await api.post(`/v1/voice/testing/${agentId}/run/${runId}/resume`);
8062
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8063
+ } catch (err) {
8064
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8065
+ }
8066
+ }
8067
+ );
8068
+ registerSpeakTool(
8069
+ server,
8070
+ "cancel_voice_test_run",
8071
+ "Cancel a voice agent test run. Requires the OWNER or ADMIN role. Valid from queued, running, or paused. Terminal \u2014 a cancelled run can never be resumed.",
8072
+ {
8073
+ agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8074
+ runId: import_zod19.z.string().min(1).describe("ID of the run (from get_active_voice_test_run or list_voice_test_runs)")
8075
+ },
8076
+ { title: "Cancel Voice Test Run", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
8077
+ async ({ agentId, runId }) => {
8078
+ try {
8079
+ const result = await api.post(`/v1/voice/testing/${agentId}/run/${runId}/cancel`);
8080
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8081
+ } catch (err) {
8082
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8083
+ }
8084
+ }
8085
+ );
8086
+ registerSpeakTool(
8087
+ server,
8088
+ "list_voice_test_runs",
8089
+ "List a voice agent's test runs, most recent first. Capped at 100 regardless of limit.",
8090
+ {
8091
+ agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8092
+ limit: import_zod19.z.number().int().min(1).optional()
8093
+ },
8094
+ { title: "List Voice Test Runs", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
8095
+ async ({ agentId, ...params }) => {
8096
+ try {
8097
+ const result = await api.get(`/v1/voice/testing/${agentId}/runs`, { params });
8098
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8099
+ } catch (err) {
8100
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8101
+ }
8102
+ }
8103
+ );
8104
+ registerSpeakTool(
8105
+ server,
8106
+ "get_voice_test_run",
8107
+ "Get a test run's full detail, including scenarioResults and recommendations. Scoped to your company; agentId is not used to filter this lookup, only runId.",
8108
+ {
8109
+ agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8110
+ runId: import_zod19.z.string().min(1).describe("ID of the run (from list_voice_test_runs)")
8111
+ },
8112
+ { title: "Get Voice Test Run", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
8113
+ async ({ agentId, runId }) => {
8114
+ try {
8115
+ const result = await api.get(`/v1/voice/testing/${agentId}/runs/${runId}`);
8116
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8117
+ } catch (err) {
8118
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8119
+ }
8120
+ }
8121
+ );
8122
+ registerSpeakTool(
8123
+ server,
8124
+ "apply_voice_test_recommendation",
8125
+ "Apply a test run recommendation's quick action to the agent (e.g. patch_instructions appends the suggested fix to the agent's instructions). Requires the OWNER or ADMIN role.",
8126
+ {
8127
+ agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8128
+ runId: import_zod19.z.string().min(1).describe("ID of the run (from get_voice_test_run)"),
8129
+ recId: import_zod19.z.string().min(1).describe("ID of the recommendation within that run's recommendations list")
8130
+ },
8131
+ { title: "Apply Voice Test Recommendation", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
8132
+ async ({ agentId, runId, recId }) => {
8133
+ try {
8134
+ const result = await api.post(`/v1/voice/testing/${agentId}/runs/${runId}/recommendations/${recId}/apply`);
8135
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8136
+ } catch (err) {
8137
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8138
+ }
8139
+ }
8140
+ );
8141
+ registerSpeakTool(
8142
+ server,
8143
+ "get_voice_test_baseline",
8144
+ "Get a voice agent's best-scoring completed test run, used to detect regressions on later runs. Returns null in data.baseline if no run has completed yet.",
8145
+ { agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)") },
8146
+ { title: "Get Voice Test Baseline", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
8147
+ async ({ agentId }) => {
8148
+ try {
8149
+ const result = await api.get(`/v1/voice/testing/${agentId}/baseline`);
8150
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8151
+ } catch (err) {
8152
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8153
+ }
8154
+ }
8155
+ );
8156
+ registerSpeakTool(
8157
+ server,
8158
+ "get_voice_test_score_history",
8159
+ "Get completed-run score points for a voice agent, most recent first, for charting. Capped at 100 regardless of limit. Only status=completed runs are included.",
8160
+ {
8161
+ agentId: import_zod19.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8162
+ limit: import_zod19.z.number().int().min(1).optional()
8163
+ },
8164
+ { title: "Get Voice Test Score History", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
8165
+ async ({ agentId, ...params }) => {
8166
+ try {
8167
+ const result = await api.get(`/v1/voice/testing/${agentId}/score-history`, { params });
8168
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8169
+ } catch (err) {
8170
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8171
+ }
8172
+ }
8173
+ );
8174
+ }
8175
+ var import_zod19, NOT_WIRED_NOTE, criterionSchema, scenarioSchema;
8176
+ var init_voice_testing = __esm({
8177
+ "src/tools/voice-testing.ts"() {
8178
+ "use strict";
8179
+ import_zod19 = require("zod");
8180
+ init_helpers();
8181
+ init_client();
8182
+ NOT_WIRED_NOTE = " The live execution engine is not wired up yet: a run created here stays queued, scenarioResults stays empty, and overallScore stays 0.";
8183
+ criterionSchema = import_zod19.z.object({
8184
+ criterionId: import_zod19.z.string().optional(),
8185
+ name: import_zod19.z.string(),
8186
+ evaluationPrompt: import_zod19.z.string().describe("What the LLM judge is asked to evaluate."),
8187
+ weight: import_zod19.z.number().min(1).max(10).optional(),
8188
+ isCritical: import_zod19.z.boolean().optional(),
8189
+ type: import_zod19.z.enum(["llm_judged", "response_length", "regex_match", "tool_called"]).optional().describe("Defaults to llm_judged. The other three route through a deterministic code check before the LLM judge runs."),
8190
+ maxWords: import_zod19.z.number().int().optional().describe("For type=response_length: fails if any agent response exceeds this word count."),
8191
+ regexPattern: import_zod19.z.string().optional().describe("For type=regex_match: JS regex source, no slashes."),
8192
+ mustMatch: import_zod19.z.boolean().optional().describe("For type=regex_match: true (default) requires a match, false requires none."),
8193
+ expectedToolName: import_zod19.z.string().optional().describe("For type=tool_called: the tool name to look for in the transcript's tool calls.")
8194
+ });
8195
+ scenarioSchema = import_zod19.z.object({
8196
+ scenarioId: import_zod19.z.string().optional(),
8197
+ name: import_zod19.z.string(),
8198
+ description: import_zod19.z.string().optional(),
8199
+ userMessages: import_zod19.z.array(import_zod19.z.string()).min(1).describe("The scripted turns sent to the agent."),
8200
+ criteria: import_zod19.z.array(criterionSchema).optional().describe("Defaults to an empty array."),
8201
+ category: import_zod19.z.enum(["greeting", "kb_retrieval", "off_topic", "edge_case", "custom"]).optional(),
8202
+ isEnabled: import_zod19.z.boolean().optional()
8203
+ });
8204
+ }
8205
+ });
8206
+
8207
+ // src/tools/voice-questions.ts
8208
+ var voice_questions_exports = {};
8209
+ __export(voice_questions_exports, {
8210
+ register: () => register19
8211
+ });
8212
+ function register19(server, client) {
8213
+ const api = client ?? speakClient;
8214
+ registerSpeakTool(
8215
+ server,
8216
+ "list_voice_questions",
8217
+ "List the questions configured on a voice agent, in the order it asks them. Each is an agent-level instance of a question template with its own required/attempts/no-response settings and optional field mapping.",
8218
+ {
8219
+ agentId: import_zod20.z.string().min(1).describe("Required. Returns 404 if the agent does not exist or does not belong to your company."),
8220
+ enabledOnly: import_zod20.z.boolean().optional()
8221
+ },
8222
+ { title: "List Voice Questions", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
8223
+ async (params) => {
8224
+ try {
8225
+ const result = await api.get("/v1/voice/questions", { params });
8226
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8227
+ } catch (err) {
8228
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8229
+ }
8230
+ }
8231
+ );
8232
+ registerSpeakTool(
8233
+ server,
8234
+ "get_voice_question",
8235
+ "Fetch a single voice agent question by its fieldId, scoped to your company.",
8236
+ { fieldId: import_zod20.z.string().min(1).describe("ID of the question (from list_voice_questions)") },
8237
+ { title: "Get Voice Question", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
8238
+ async ({ fieldId }) => {
8239
+ try {
8240
+ const result = await api.get(`/v1/voice/questions/${fieldId}`);
8241
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8242
+ } catch (err) {
8243
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8244
+ }
8245
+ }
8246
+ );
8247
+ registerSpeakTool(
8248
+ server,
8249
+ "create_voice_question",
8250
+ "Attach a question template to a voice agent. Requires the OWNER or ADMIN role. agentId and templateId are both required and must belong to your company (or, for templateId, be a public system template) \u2014 404 if either isn't found.",
8251
+ {
8252
+ agentId: import_zod20.z.string().min(1),
8253
+ templateId: import_zod20.z.string().min(1).describe("From list_voice_question_templates."),
8254
+ customConfig: customConfigSchema.optional().describe("Agent-level override of the template's defaultConfig; only the keys you send are overridden."),
8255
+ required: import_zod20.z.boolean().optional(),
8256
+ maxPromptAttempts: import_zod20.z.number().min(1).max(3).optional(),
8257
+ noResponseBehavior: import_zod20.z.enum(["move_to_next_question", "end_conversation"]).optional(),
8258
+ triggerCondition: import_zod20.z.string().optional(),
8259
+ order: import_zod20.z.number().optional(),
8260
+ enabled: import_zod20.z.boolean().optional(),
8261
+ mappedFieldId: import_zod20.z.string().optional().nullable().describe("ID of an existing company Field to write this question's collected answer onto after each call.")
8262
+ },
8263
+ { title: "Create Voice Question", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
8264
+ async (body) => {
8265
+ try {
8266
+ const result = await api.post("/v1/voice/questions", body);
8267
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8268
+ } catch (err) {
8269
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8270
+ }
8271
+ }
8272
+ );
8273
+ registerSpeakTool(
8274
+ server,
8275
+ "update_voice_question",
8276
+ "Partially update a voice agent question \u2014 only the fields you send are changed. Requires the OWNER or ADMIN role. agentId and templateId are fixed after create; sending them is silently dropped.",
8277
+ {
8278
+ fieldId: import_zod20.z.string().min(1).describe("ID of the question to update (from list_voice_questions)"),
8279
+ customConfig: customConfigSchema.optional(),
8280
+ required: import_zod20.z.boolean().optional(),
8281
+ maxPromptAttempts: import_zod20.z.number().min(1).max(3).optional(),
8282
+ noResponseBehavior: import_zod20.z.enum(["move_to_next_question", "end_conversation"]).optional(),
8283
+ triggerCondition: import_zod20.z.string().optional(),
8284
+ order: import_zod20.z.number().optional(),
8285
+ enabled: import_zod20.z.boolean().optional(),
8286
+ mappedFieldId: import_zod20.z.string().optional().nullable()
8287
+ },
8288
+ { title: "Update Voice Question", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
8289
+ async ({ fieldId, ...body }) => {
8290
+ try {
8291
+ const result = await api.put(`/v1/voice/questions/${fieldId}`, body);
8292
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8293
+ } catch (err) {
8294
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8295
+ }
8296
+ }
8297
+ );
8298
+ registerSpeakTool(
8299
+ server,
8300
+ "delete_voice_question",
8301
+ "Permanently remove a question from a voice agent and decrement the underlying template's usageCount. Requires the OWNER or ADMIN role. The template itself is not deleted and can be attached to another agent later.",
8302
+ { fieldId: import_zod20.z.string().min(1).describe("ID of the question to remove (from list_voice_questions)") },
8303
+ { title: "Delete Voice Question", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
8304
+ async ({ fieldId }) => {
8305
+ try {
8306
+ const result = await api.delete(`/v1/voice/questions/${fieldId}`);
8307
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8308
+ } catch (err) {
8309
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8310
+ }
8311
+ }
8312
+ );
8313
+ registerSpeakTool(
8314
+ server,
8315
+ "reorder_voice_questions",
8316
+ "Set the order a voice agent asks its questions in. Requires the OWNER or ADMIN role. Bulk-writes the order value on each listed question (written directly, not resequenced), then returns the agent's full question list in its new order. Entries whose fieldId doesn't belong to agentId are silently skipped.",
8317
+ {
8318
+ agentId: import_zod20.z.string().min(1),
8319
+ fieldOrders: import_zod20.z.array(import_zod20.z.object({ fieldId: import_zod20.z.string().min(1), order: import_zod20.z.number() })).min(1).describe("The new order for some or all of the agent's questions.")
8320
+ },
8321
+ { title: "Reorder Voice Questions", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
8322
+ async (body) => {
8323
+ try {
8324
+ const result = await api.put("/v1/voice/questions/reorder", body);
8325
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8326
+ } catch (err) {
8327
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8328
+ }
8329
+ }
8330
+ );
8331
+ registerSpeakTool(
8332
+ server,
8333
+ "list_voice_question_templates",
8334
+ "List the question templates visible to your company: Speak's shared system templates, plus your own company's templates. Use the returned templateId with create_voice_question.",
8335
+ { category: import_zod20.z.enum(QUESTION_CATEGORIES).optional() },
8336
+ { title: "List Voice Question Templates", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
8337
+ async (params) => {
8338
+ try {
8339
+ const result = await api.get("/v1/voice/question-templates", { params });
8340
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8341
+ } catch (err) {
8342
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8343
+ }
8344
+ }
8345
+ );
8346
+ registerSpeakTool(
8347
+ server,
8348
+ "create_voice_question_template",
8349
+ `Create a company-scoped question template \u2014 the "custom question" a user names themselves rather than picking from Speak's shared library. Requires the OWNER or ADMIN role. The server stamps companyId and forces isSystemTemplate to false, so this template is only ever visible to your company.`,
8350
+ {
8351
+ name: import_zod20.z.string().min(1),
8352
+ description: import_zod20.z.string().min(1),
8353
+ category: import_zod20.z.enum(QUESTION_CATEGORIES),
8354
+ fieldType: import_zod20.z.enum(["email", "phone", "date", "time", "datetime", "text", "number", "boolean", "choice", "url"]),
8355
+ defaultConfig: import_zod20.z.object({
8356
+ displayLabel: import_zod20.z.string(),
8357
+ question: import_zod20.z.string().describe("The prompt text the agent speaks to ask this."),
8358
+ confirmationText: import_zod20.z.string().optional(),
8359
+ validationPrompt: import_zod20.z.string().optional(),
8360
+ validation: validationSchema.optional()
8361
+ }).describe("displayLabel and question are both required within this object."),
8362
+ isPublic: import_zod20.z.boolean().optional(),
8363
+ tags: import_zod20.z.array(import_zod20.z.string()).optional()
8364
+ },
8365
+ { title: "Create Voice Question Template", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
8366
+ async (body) => {
8367
+ try {
8368
+ const result = await api.post("/v1/voice/question-templates", body);
8369
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8370
+ } catch (err) {
8371
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8372
+ }
8373
+ }
8374
+ );
8375
+ }
8376
+ var import_zod20, QUESTION_CATEGORIES, validationSchema, customConfigSchema;
8377
+ var init_voice_questions = __esm({
8378
+ "src/tools/voice-questions.ts"() {
8379
+ "use strict";
8380
+ import_zod20 = require("zod");
8381
+ init_helpers();
8382
+ init_client();
8383
+ QUESTION_CATEGORIES = ["contact", "booking", "qualification", "custom"];
8384
+ validationSchema = import_zod20.z.object({
8385
+ pattern: import_zod20.z.string().optional(),
8386
+ minLength: import_zod20.z.number().optional(),
8387
+ maxLength: import_zod20.z.number().optional(),
8388
+ min: import_zod20.z.number().optional(),
8389
+ max: import_zod20.z.number().optional(),
8390
+ allowedValues: import_zod20.z.array(import_zod20.z.string()).optional()
8391
+ });
8392
+ customConfigSchema = import_zod20.z.object({
8393
+ displayLabel: import_zod20.z.string().optional(),
8394
+ question: import_zod20.z.string().optional().describe("The prompt text the agent speaks to ask this question."),
8395
+ confirmationText: import_zod20.z.string().optional(),
8396
+ validationPrompt: import_zod20.z.string().optional(),
8397
+ validation: validationSchema.optional()
8398
+ });
8399
+ }
8400
+ });
8401
+
8402
+ // src/tools/voice-intelligence.ts
8403
+ var voice_intelligence_exports = {};
8404
+ __export(voice_intelligence_exports, {
8405
+ register: () => register20
8406
+ });
8407
+ function register20(server, client) {
8408
+ const api = client ?? speakClient;
8409
+ registerSpeakTool(
8410
+ server,
8411
+ "list_voice_kb_gaps",
8412
+ `List a voice agent's pending knowledge-base gaps \u2014 questions callers asked that the agent answered with low confidence or an explicit "I don't know," surfaced automatically after calls. Up to the 50 most recent pending gaps, newest first.`,
8413
+ { agentId: import_zod21.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)") },
8414
+ { title: "List Voice KB Gaps", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
8415
+ async ({ agentId }) => {
8416
+ try {
8417
+ const result = await api.get(`/v1/voice/knowledge-base/${agentId}/gaps`);
8418
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8419
+ } catch (err) {
8420
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8421
+ }
8422
+ }
8423
+ );
8424
+ registerSpeakTool(
8425
+ server,
8426
+ "analyze_voice_kb_gaps",
8427
+ "Trigger knowledge-base gap analysis over a voice agent's recent calls. Requires the OWNER or ADMIN role. Runs in the background and returns immediately \u2014 new gaps appear in list_voice_kb_gaps once analysis finishes, not synchronously with this response.",
8428
+ { agentId: import_zod21.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)") },
8429
+ { title: "Analyze Voice KB Gaps", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
8430
+ async ({ agentId }) => {
8431
+ try {
8432
+ const result = await api.post(`/v1/voice/knowledge-base/${agentId}/gaps/analyze`);
8433
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8434
+ } catch (err) {
8435
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8436
+ }
8437
+ }
8438
+ );
8439
+ registerSpeakTool(
8440
+ server,
8441
+ "add_voice_kb_gap",
8442
+ "Write a knowledge-base gap's answer into the voice agent's attached knowledge base as a new document, and mark the gap added. Requires the OWNER or ADMIN role. Fails with 409 if the gap was already added or dismissed, or if the agent has no knowledge base collection to write into.",
8443
+ {
8444
+ agentId: import_zod21.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8445
+ gapId: import_zod21.z.string().min(1).describe("ID of the gap (from list_voice_kb_gaps)"),
8446
+ answer: import_zod21.z.string().optional().describe("Overrides the gap's suggested answer."),
8447
+ title: import_zod21.z.string().optional().describe("Overrides the gap's suggested title.")
8448
+ },
8449
+ { title: "Add Voice KB Gap", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
8450
+ async ({ agentId, gapId, ...body }) => {
8451
+ try {
8452
+ const result = await api.post(`/v1/voice/knowledge-base/${agentId}/gaps/${gapId}/add`, body);
8453
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8454
+ } catch (err) {
8455
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8456
+ }
8457
+ }
8458
+ );
8459
+ registerSpeakTool(
8460
+ server,
8461
+ "dismiss_voice_kb_gap",
8462
+ "Mark a voice agent's knowledge-base gap dismissed without writing anything to the knowledge base. Requires the OWNER or ADMIN role.",
8463
+ {
8464
+ agentId: import_zod21.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8465
+ gapId: import_zod21.z.string().min(1).describe("ID of the gap (from list_voice_kb_gaps)")
8466
+ },
8467
+ { title: "Dismiss Voice KB Gap", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
8468
+ async ({ agentId, gapId }) => {
8469
+ try {
8470
+ const result = await api.delete(`/v1/voice/knowledge-base/${agentId}/gaps/${gapId}`);
8471
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8472
+ } catch (err) {
8473
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8474
+ }
8475
+ }
8476
+ );
8477
+ registerSpeakTool(
8478
+ server,
8479
+ "list_voice_faq_suggestions",
8480
+ "List a voice agent's pending FAQ suggestions \u2014 questions multiple callers asked in similar form, clustered and drafted into a reusable question/answer pair. Up to the 20 largest clusters, largest first.",
8481
+ { agentId: import_zod21.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)") },
8482
+ { title: "List Voice FAQ Suggestions", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
8483
+ async ({ agentId }) => {
8484
+ try {
8485
+ const result = await api.get(`/v1/voice/knowledge-base/${agentId}/faqs`);
8486
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8487
+ } catch (err) {
8488
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8489
+ }
8490
+ }
8491
+ );
8492
+ registerSpeakTool(
8493
+ server,
8494
+ "generate_voice_faq_suggestions",
8495
+ "Trigger FAQ clustering over a voice agent's recent calls. Requires the OWNER or ADMIN role. Runs in the background and returns immediately \u2014 new suggestions appear in list_voice_faq_suggestions once generation finishes, not synchronously with this response.",
8496
+ { agentId: import_zod21.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)") },
8497
+ { title: "Generate Voice FAQ Suggestions", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
8498
+ async ({ agentId }) => {
8499
+ try {
8500
+ const result = await api.post(`/v1/voice/knowledge-base/${agentId}/faqs/generate`);
8501
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8502
+ } catch (err) {
8503
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8504
+ }
8505
+ }
8506
+ );
8507
+ registerSpeakTool(
8508
+ server,
8509
+ "add_voice_faq_suggestion",
8510
+ "Write an FAQ suggestion's question/answer into the voice agent's attached knowledge base as a new document, and mark the suggestion added. Requires the OWNER or ADMIN role. Fails with 409 if the suggestion was already added or dismissed, or if the agent has no knowledge base collection to write into.",
8511
+ {
8512
+ agentId: import_zod21.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8513
+ suggestionId: import_zod21.z.string().min(1).describe("ID of the suggestion (from list_voice_faq_suggestions)"),
8514
+ question: import_zod21.z.string().optional().describe("Overrides the suggested question."),
8515
+ answer: import_zod21.z.string().optional().describe("Overrides the suggested answer.")
8516
+ },
8517
+ { title: "Add Voice FAQ Suggestion", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
8518
+ async ({ agentId, suggestionId, ...body }) => {
8519
+ try {
8520
+ const result = await api.post(`/v1/voice/knowledge-base/${agentId}/faqs/${suggestionId}/add`, body);
8521
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8522
+ } catch (err) {
8523
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8524
+ }
8525
+ }
8526
+ );
8527
+ registerSpeakTool(
8528
+ server,
8529
+ "update_voice_faq_suggestion",
8530
+ "Edit a still-pending FAQ suggestion's question and/or answer before adding it. Requires the OWNER or ADMIN role. Fails with 400 if the suggestion was already added or dismissed.",
8531
+ {
8532
+ agentId: import_zod21.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8533
+ suggestionId: import_zod21.z.string().min(1).describe("ID of the suggestion (from list_voice_faq_suggestions)"),
8534
+ question: import_zod21.z.string().optional(),
8535
+ answer: import_zod21.z.string().optional()
8536
+ },
8537
+ { title: "Update Voice FAQ Suggestion", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
8538
+ async ({ agentId, suggestionId, ...body }) => {
8539
+ try {
8540
+ const result = await api.put(`/v1/voice/knowledge-base/${agentId}/faqs/${suggestionId}`, body);
8541
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8542
+ } catch (err) {
8543
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8544
+ }
8545
+ }
8546
+ );
8547
+ registerSpeakTool(
8548
+ server,
8549
+ "dismiss_voice_faq_suggestion",
8550
+ "Mark a voice agent's FAQ suggestion dismissed without writing anything to the knowledge base. Requires the OWNER or ADMIN role.",
8551
+ {
8552
+ agentId: import_zod21.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8553
+ suggestionId: import_zod21.z.string().min(1).describe("ID of the suggestion (from list_voice_faq_suggestions)")
8554
+ },
8555
+ { title: "Dismiss Voice FAQ Suggestion", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
8556
+ async ({ agentId, suggestionId }) => {
8557
+ try {
8558
+ const result = await api.delete(`/v1/voice/knowledge-base/${agentId}/faqs/${suggestionId}`);
8559
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8560
+ } catch (err) {
8561
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8562
+ }
8563
+ }
8564
+ );
8565
+ registerSpeakTool(
8566
+ server,
8567
+ "list_voice_agent_resources",
8568
+ "List the knowledge documents/links a voice agent searches during calls \u2014 separate from KB gaps and FAQ suggestions, which are the self-improvement layer that surfaces what an agent is missing, not the content itself.",
8569
+ {
8570
+ agentId: import_zod21.z.string().optional(),
8571
+ page: import_zod21.z.number().int().min(1).optional(),
8572
+ limit: import_zod21.z.number().int().min(1).optional(),
8573
+ search: import_zod21.z.string().optional().describe("Search by title/description.")
8574
+ },
8575
+ { title: "List Voice Agent Resources", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
8576
+ async (params) => {
8577
+ try {
8578
+ const result = await api.get("/v1/voice/agent-resources", { params });
8579
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8580
+ } catch (err) {
8581
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8582
+ }
8583
+ }
8584
+ );
8585
+ registerSpeakTool(
8586
+ server,
8587
+ "create_voice_agent_resource",
8588
+ "Add one document/link to a voice agent's knowledge base. Requires the OWNER or ADMIN role. The server fetches and embeds the content in the background (status moves from pending to completed).",
8589
+ { agentId: import_zod21.z.string().min(1), ...resourceBodySchema },
8590
+ { title: "Create Voice Agent Resource", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
8591
+ async (body) => {
8592
+ try {
8593
+ const result = await api.post("/v1/voice/agent-resources", body);
8594
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8595
+ } catch (err) {
8596
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8597
+ }
8598
+ }
8599
+ );
8600
+ registerSpeakTool(
8601
+ server,
8602
+ "bulk_create_voice_agent_resources",
8603
+ "Add up to 100 documents/links to a voice agent's knowledge base in one call. Requires the OWNER or ADMIN role. Each is fetched and embedded independently in the background. Use this instead of calling create_voice_agent_resource in a loop.",
8604
+ {
8605
+ agentId: import_zod21.z.string().min(1),
8606
+ resources: import_zod21.z.array(import_zod21.z.object(resourceBodySchema)).min(1).max(100).describe("1 to 100 entries, each shaped like create_voice_agent_resource's body minus agentId.")
8607
+ },
8608
+ { title: "Bulk Create Voice Agent Resources", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
8609
+ async (body) => {
8610
+ try {
8611
+ const result = await api.post("/v1/voice/agent-resources/bulk", body);
8612
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8613
+ } catch (err) {
8614
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8615
+ }
8616
+ }
8617
+ );
8618
+ registerSpeakTool(
8619
+ server,
8620
+ "update_voice_agent_resource",
8621
+ "Partially update a voice agent resource \u2014 send at least one field. Requires the OWNER or ADMIN role. agentId cannot be changed. Changing url, title, or description re-triggers embedding.",
8622
+ {
8623
+ resourceId: import_zod21.z.string().min(1).describe("ID of the resource to update (from list_voice_agent_resources)"),
8624
+ url: import_zod21.z.string().url().optional(),
8625
+ title: import_zod21.z.string().max(200).optional(),
8626
+ description: import_zod21.z.string().max(1e3).optional(),
8627
+ action: import_zod21.z.enum(["link", "presentation"]).optional(),
8628
+ contentType: import_zod21.z.enum(["video", "pdf", "image"]).optional()
8629
+ },
8630
+ { title: "Update Voice Agent Resource", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
8631
+ async ({ resourceId, ...body }) => {
8632
+ try {
8633
+ const result = await api.put(`/v1/voice/agent-resources/${resourceId}`, body);
8634
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8635
+ } catch (err) {
8636
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8637
+ }
8638
+ }
8639
+ );
8640
+ registerSpeakTool(
8641
+ server,
8642
+ "delete_voice_agent_resource",
8643
+ "Soft-delete a voice agent resource \u2014 it stops appearing in lists and the agent stops searching it, but the document is not physically removed. Requires the OWNER or ADMIN role.",
8644
+ { resourceId: import_zod21.z.string().min(1).describe("ID of the resource to delete (from list_voice_agent_resources)") },
8645
+ { title: "Delete Voice Agent Resource", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
8646
+ async ({ resourceId }) => {
8647
+ try {
8648
+ const result = await api.delete(`/v1/voice/agent-resources/${resourceId}`);
8649
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8650
+ } catch (err) {
8651
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8652
+ }
8653
+ }
8654
+ );
8655
+ registerSpeakTool(
8656
+ server,
8657
+ "analyze_voice_instruction_gaps",
8658
+ "Advisory only \u2014 compares a voice agent's current instructions against anchors/original intent/recent call summaries you supply and suggests up to 3 patches. Requires the OWNER or ADMIN role. Nothing is written; pass a suggestion's suggestedPatch to apply_voice_instruction_gap to actually apply it.",
8659
+ {
8660
+ agentId: import_zod21.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8661
+ anchors: import_zod21.z.array(import_zod21.z.string()).optional().describe("Specific requirements the instructions must cover. Defaults to empty."),
8662
+ originalPrompt: import_zod21.z.string().optional().describe("The original generation prompt, for context."),
8663
+ conversationSummaries: import_zod21.z.array(import_zod21.z.string()).optional().describe("Recent call summaries, to ground suggestions in what actually came up. Defaults to empty.")
8664
+ },
8665
+ { title: "Analyze Voice Instruction Gaps", readOnlyHint: true, destructiveHint: false, idempotentHint: false, openWorldHint: false },
8666
+ async ({ agentId, ...body }) => {
8667
+ try {
8668
+ const result = await api.post(`/v1/voice/agents/${agentId}/generation/gaps/analyze`, body);
8669
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8670
+ } catch (err) {
8671
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8672
+ }
8673
+ }
8674
+ );
8675
+ registerSpeakTool(
8676
+ server,
8677
+ "apply_voice_instruction_gap",
8678
+ "Insert a suggested instruction patch into a voice agent's instructions and persist the result. Requires the OWNER or ADMIN role. suggestedPatch is typically taken directly from analyze_voice_instruction_gaps.",
8679
+ {
8680
+ agentId: import_zod21.z.string().min(1).describe("ID of the voice agent (from list_voice_agents)"),
8681
+ suggestedPatch: import_zod21.z.string().min(1),
8682
+ insertAfterSection: import_zod21.z.string().optional().nullable().describe("Insert after this named section heading; omit or null to append at the end.")
8683
+ },
8684
+ { title: "Apply Voice Instruction Gap", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
8685
+ async ({ agentId, ...body }) => {
8686
+ try {
8687
+ const result = await api.post(`/v1/voice/agents/${agentId}/generation/gaps/apply`, body);
8688
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
8689
+ } catch (err) {
8690
+ return { content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }], isError: true };
8691
+ }
8692
+ }
8693
+ );
8694
+ }
8695
+ var import_zod21, resourceBodySchema;
8696
+ var init_voice_intelligence = __esm({
8697
+ "src/tools/voice-intelligence.ts"() {
8698
+ "use strict";
8699
+ import_zod21 = require("zod");
8700
+ init_helpers();
8701
+ init_client();
8702
+ resourceBodySchema = {
8703
+ url: import_zod21.z.string().url(),
8704
+ title: import_zod21.z.string().max(200),
8705
+ description: import_zod21.z.string().max(1e3),
8706
+ action: import_zod21.z.enum(["link", "presentation"]),
8707
+ contentType: import_zod21.z.enum(["video", "pdf", "image"]).optional()
8708
+ };
8709
+ }
8710
+ });
8711
+
8712
+ // src/tools/index.ts
8713
+ var tools_exports = {};
8714
+ __export(tools_exports, {
8715
+ registerAllTools: () => registerAllTools
8716
+ });
8717
+ function registerAllTools(server, client, options = {}) {
8718
+ for (const mod of modules) {
8719
+ mod.register(server, client, options);
8720
+ }
8721
+ }
8722
+ var modules;
8723
+ var init_tools = __esm({
8724
+ "src/tools/index.ts"() {
8725
+ "use strict";
8726
+ init_media3();
8727
+ init_text2();
8728
+ init_exports();
8729
+ init_folders();
8730
+ init_recorder3();
8731
+ init_embed3();
8732
+ init_prompt3();
8733
+ init_meeting3();
8734
+ init_fields2();
8735
+ init_automations();
8736
+ init_webhooks();
8737
+ init_analytics();
8738
+ init_clips();
8739
+ init_workflows();
8740
+ init_users();
8741
+ init_dashboards();
8742
+ init_voice();
8743
+ init_voice_testing();
8744
+ init_voice_questions();
8745
+ init_voice_intelligence();
8746
+ modules = [
8747
+ media_exports,
8748
+ text_exports,
8749
+ exports_exports,
8750
+ folders_exports,
8751
+ recorder_exports,
8752
+ embed_exports,
8753
+ prompt_exports,
8754
+ meeting_exports,
8755
+ fields_exports,
8756
+ automations_exports,
8757
+ webhooks_exports,
8758
+ analytics_exports,
8759
+ clips_exports,
8760
+ workflows_exports,
8761
+ users_exports,
8762
+ dashboards_exports,
8763
+ voice_exports,
8764
+ voice_testing_exports,
8765
+ voice_questions_exports,
8766
+ voice_intelligence_exports
8767
+ ];
8768
+ }
8769
+ });
8770
+
8771
+ // src/resources.ts
8772
+ var resources_exports = {};
8773
+ __export(resources_exports, {
8774
+ registerResources: () => registerResources
8775
+ });
8776
+ function asJsonContent(uri, data) {
8777
+ return {
8778
+ contents: [
8779
+ {
8780
+ uri,
8781
+ mimeType: "application/json",
8782
+ text: JSON.stringify(data, null, 2)
8783
+ }
8784
+ ]
8785
+ };
8786
+ }
8787
+ function reportError(label, err) {
8788
+ const detail = formatAxiosError(err);
8789
+ throw new Error(`Speak AI resource '${label}' failed: ${detail}`);
8790
+ }
8791
+ function registerResources(server, client) {
8792
+ const api = client ?? speakClient;
8793
+ server.resource(
8794
+ "media-library",
8795
+ "speakai://media",
8796
+ { description: "List of all media files in your Speak AI workspace" },
8797
+ async () => {
8798
+ try {
8799
+ const result = await api.get("/v1/media", {
8800
+ params: { page: 0, pageSize: 50, sortBy: "createdAt:desc", filterMedia: 2 }
8801
+ });
8802
+ return asJsonContent("speakai://media", result.data?.data);
8803
+ } catch (err) {
8804
+ reportError("media-library", err);
8805
+ }
8806
+ }
8807
+ );
8808
+ server.resource(
8809
+ "folders",
8810
+ "speakai://folders",
8811
+ { description: "List of all folders in your Speak AI workspace" },
8812
+ async () => {
8813
+ try {
8814
+ const result = await api.get("/v1/folder", {
8815
+ params: { page: 0, pageSize: 100, sortBy: "createdAt:desc" }
8816
+ });
8817
+ return asJsonContent("speakai://folders", result.data?.data);
8818
+ } catch (err) {
8819
+ reportError("folders", err);
8820
+ }
8821
+ }
8822
+ );
8823
+ server.resource(
8824
+ "supported-languages",
8825
+ "speakai://languages",
8826
+ { description: "List of supported transcription languages" },
8827
+ async () => {
8828
+ try {
8829
+ const result = await api.get("/v1/media/supportedLanguages");
8830
+ return asJsonContent("speakai://languages", result.data?.data);
8831
+ } catch (err) {
8832
+ reportError("supported-languages", err);
8833
+ }
8834
+ }
8835
+ );
8836
+ server.resource(
8837
+ "transcript",
8838
+ new import_mcp.ResourceTemplate("speakai://media/{mediaId}/transcript", { list: void 0 }),
8839
+ { description: "Full transcript for a specific media file" },
8840
+ async (uri, { mediaId }) => {
8841
+ try {
8842
+ const result = await api.get(`/v1/media/transcript/${mediaId}`);
8843
+ return asJsonContent(uri.href, result.data?.data);
8844
+ } catch (err) {
8845
+ reportError(`transcript(${mediaId})`, err);
8846
+ }
8847
+ }
8848
+ );
8849
+ server.resource(
8850
+ "insights",
8851
+ new import_mcp.ResourceTemplate("speakai://media/{mediaId}/insights", { list: void 0 }),
8852
+ { description: "AI-generated insights for a specific media file" },
8853
+ async (uri, { mediaId }) => {
8854
+ try {
8855
+ const result = await api.get(`/v1/media/insight/${mediaId}`);
8856
+ return asJsonContent(uri.href, result.data?.data);
8857
+ } catch (err) {
8858
+ reportError(`insights(${mediaId})`, err);
7698
8859
  }
7699
8860
  }
7700
8861
  );
@@ -7719,8 +8880,8 @@ function registerPrompts(server) {
7719
8880
  "analyze-meeting",
7720
8881
  "Upload a meeting recording and get a full analysis \u2014 transcript, insights, action items, and key takeaways.",
7721
8882
  {
7722
- url: import_zod18.z.string().describe(`URL of the meeting recording \u2014 a direct file link, or a shareable page link from ${SUPPORTED_URL_SOURCES} (resolved to the underlying media automatically)`),
7723
- name: import_zod18.z.string().optional().describe("Meeting name (optional)")
8883
+ url: import_zod22.z.string().describe(`URL of the meeting recording \u2014 a direct file link, or a shareable page link from ${SUPPORTED_URL_SOURCES} (resolved to the underlying media automatically)`),
8884
+ name: import_zod22.z.string().optional().describe("Meeting name (optional)")
7724
8885
  },
7725
8886
  async ({ url, name }) => ({
7726
8887
  messages: [
@@ -7755,8 +8916,8 @@ function registerPrompts(server) {
7755
8916
  "research-across-media",
7756
8917
  "Search for themes, patterns, or topics across multiple recordings or your entire media library.",
7757
8918
  {
7758
- topic: import_zod18.z.string().describe("The topic, theme, or question to research"),
7759
- folder: import_zod18.z.string().optional().describe("Folder ID to scope the research (optional)")
8919
+ topic: import_zod22.z.string().describe("The topic, theme, or question to research"),
8920
+ folder: import_zod22.z.string().optional().describe("Folder ID to scope the research (optional)")
7760
8921
  },
7761
8922
  async ({ topic, folder }) => ({
7762
8923
  messages: [
@@ -7789,8 +8950,8 @@ function registerPrompts(server) {
7789
8950
  "meeting-brief",
7790
8951
  "Prepare a brief from recent meetings \u2014 pull transcripts, extract decisions, and summarize open items.",
7791
8952
  {
7792
- days: import_zod18.z.string().optional().describe("Number of days to look back (default: 7)"),
7793
- folder: import_zod18.z.string().optional().describe("Folder ID to scope to (optional)")
8953
+ days: import_zod22.z.string().optional().describe("Number of days to look back (default: 7)"),
8954
+ folder: import_zod22.z.string().optional().describe("Folder ID to scope to (optional)")
7794
8955
  },
7795
8956
  async ({ days, folder }) => {
7796
8957
  const lookback = parseInt(days ?? "7");
@@ -7827,11 +8988,11 @@ function registerPrompts(server) {
7827
8988
  }
7828
8989
  );
7829
8990
  }
7830
- var import_zod18;
8991
+ var import_zod22;
7831
8992
  var init_prompts = __esm({
7832
8993
  "src/prompts.ts"() {
7833
8994
  "use strict";
7834
- import_zod18 = require("zod");
8995
+ import_zod22 = require("zod");
7835
8996
  init_media_utils();
7836
8997
  }
7837
8998
  });
@@ -7980,7 +9141,61 @@ var init_tool_names = __esm({
7980
9141
  "delete_dashboard",
7981
9142
  "duplicate_dashboard",
7982
9143
  "share_dashboard",
7983
- "get_dashboard_speakers_insight"
9144
+ "get_dashboard_speakers_insight",
9145
+ // voice: agents + conversations
9146
+ "list_voice_agents",
9147
+ "get_voice_agent",
9148
+ "create_voice_agent",
9149
+ "update_voice_agent",
9150
+ "list_voice_avatars",
9151
+ "list_voices",
9152
+ "list_voice_conversations",
9153
+ "get_voice_conversation",
9154
+ // voice: testing
9155
+ "get_voice_test_suite",
9156
+ "update_voice_test_suite",
9157
+ "generate_voice_test_suite",
9158
+ "start_voice_test_run",
9159
+ "get_active_voice_test_run",
9160
+ "pause_voice_test_run",
9161
+ "resume_voice_test_run",
9162
+ "cancel_voice_test_run",
9163
+ "list_voice_test_runs",
9164
+ "get_voice_test_run",
9165
+ "apply_voice_test_recommendation",
9166
+ "get_voice_test_baseline",
9167
+ "get_voice_test_score_history",
9168
+ // voice: agents round-out + discovery
9169
+ "delete_voice_agent",
9170
+ "create_voice_agent_from_prompt",
9171
+ "generate_voice_agent_config",
9172
+ "get_voice_agent_setup_guide",
9173
+ // voice: questions
9174
+ "list_voice_questions",
9175
+ "get_voice_question",
9176
+ "create_voice_question",
9177
+ "update_voice_question",
9178
+ "delete_voice_question",
9179
+ "reorder_voice_questions",
9180
+ "list_voice_question_templates",
9181
+ "create_voice_question_template",
9182
+ // voice: intelligence (kb gaps, faq suggestions, agent resources, instruction gaps)
9183
+ "list_voice_kb_gaps",
9184
+ "analyze_voice_kb_gaps",
9185
+ "add_voice_kb_gap",
9186
+ "dismiss_voice_kb_gap",
9187
+ "list_voice_faq_suggestions",
9188
+ "generate_voice_faq_suggestions",
9189
+ "add_voice_faq_suggestion",
9190
+ "update_voice_faq_suggestion",
9191
+ "dismiss_voice_faq_suggestion",
9192
+ "list_voice_agent_resources",
9193
+ "create_voice_agent_resource",
9194
+ "bulk_create_voice_agent_resources",
9195
+ "update_voice_agent_resource",
9196
+ "delete_voice_agent_resource",
9197
+ "analyze_voice_instruction_gaps",
9198
+ "apply_voice_instruction_gap"
7984
9199
  ];
7985
9200
  }
7986
9201
  });
@@ -9037,7 +10252,7 @@ function createCli() {
9037
10252
  }
9038
10253
  };
9039
10254
  const { registerAllTools: registerAllTools2 } = await Promise.resolve().then(() => (init_tools(), tools_exports));
9040
- registerAllTools2(stub, client);
10255
+ registerAllTools2(stub, client, { localFileAccess: true });
9041
10256
  return handlers;
9042
10257
  }
9043
10258
  program.command("tools").description("List every MCP tool callable via `call`").option("--json", "Output raw JSON").action(async (opts) => {
@@ -9183,7 +10398,7 @@ if (isCliMode) {
9183
10398
  name: "speak-ai",
9184
10399
  version: "1.0.0"
9185
10400
  });
9186
- registerAllTools2(server);
10401
+ registerAllTools2(server, void 0, { localFileAccess: true });
9187
10402
  registerResources2(server);
9188
10403
  registerPrompts2(server);
9189
10404
  const transport = new StdioServerTransport();