@mosadd/mcp 3.0.0-alpha.4 → 3.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,11 +3,13 @@ import {
3
3
  loadSession
4
4
  } from "./chunk-Z7WR52GE.js";
5
5
 
6
- // src/tools/mdm.ts
7
- import { z } from "zod";
8
-
9
6
  // src/providers/supabase.ts
7
+ import { AsyncLocalStorage } from "async_hooks";
10
8
  import { createClient } from "@supabase/supabase-js";
9
+ var requestEnv = new AsyncLocalStorage();
10
+ function runWithSupabaseEnv(env, fn) {
11
+ return requestEnv.run(env, fn);
12
+ }
11
13
  var MissingSupabaseEnvError = class extends Error {
12
14
  constructor(missing) {
13
15
  super(
@@ -17,6 +19,8 @@ var MissingSupabaseEnvError = class extends Error {
17
19
  }
18
20
  };
19
21
  function readSupabaseEnv() {
22
+ const perRequest = requestEnv.getStore();
23
+ if (perRequest) return perRequest;
20
24
  const env = (canonical, legacy) => process.env[canonical] ?? process.env[legacy];
21
25
  const userJwtEnv = env("MOSADD_USER_JWT", "M0SSAD_USER_JWT");
22
26
  const session = loadSession();
@@ -57,6 +61,9 @@ async function invokeFunction(fn, body) {
57
61
  return data;
58
62
  }
59
63
 
64
+ // src/tools/mdm.ts
65
+ import { z } from "zod";
66
+
60
67
  // src/crypto/mdm-session.ts
61
68
  import {
62
69
  decryptBytes,
@@ -457,6 +464,33 @@ async function mDM_respond_request(input, ctx) {
457
464
  return { ok: true };
458
465
  }
459
466
  var mDM_publish_keys_input = z.object({});
467
+ var mDM_edit_input = z.object({
468
+ message_id: z.string().min(1).describe("Id of the message to edit (from mDM_list)."),
469
+ new_text: z.string().min(1).max(64e3).describe("Replacement message body (UTF-8). Max 64 KB.")
470
+ });
471
+ var mDM_delete_input = z.object({
472
+ message_id: z.string().min(1).describe("Id of the message to delete (from mDM_list).")
473
+ });
474
+ async function mDM_edit(input, ctx) {
475
+ readSupabaseEnv();
476
+ const envelope = {
477
+ v: PROTOCOL_VERSION,
478
+ type: "text",
479
+ text: input.new_text,
480
+ edited: true,
481
+ sent_at: (/* @__PURE__ */ new Date()).toISOString()
482
+ };
483
+ const encrypted_payload = Buffer.from(JSON.stringify(envelope), "utf8").toString("base64");
484
+ ctx.log("debug", "mDM_edit via message-edit", { message_id: input.message_id });
485
+ await invokeFunction("message-edit", { message_id: input.message_id, encrypted_payload });
486
+ return { message_id: input.message_id, edited: true };
487
+ }
488
+ async function mDM_delete(input, ctx) {
489
+ readSupabaseEnv();
490
+ ctx.log("debug", "mDM_delete via message-delete", { message_id: input.message_id });
491
+ await invokeFunction("message-delete", { message_id: input.message_id });
492
+ return { message_id: input.message_id, deleted: true };
493
+ }
460
494
  var mdmTools = [
461
495
  {
462
496
  name: "mDM_list_contacts",
@@ -499,41 +533,178 @@ var mdmTools = [
499
533
  description: "Accept or reject an incoming DM request from a contact who is not yet in the user's whitelist.",
500
534
  inputSchema: mDM_respond_request_input,
501
535
  handler: mDM_respond_request
536
+ },
537
+ {
538
+ name: "mDM_edit",
539
+ requires: "any",
540
+ description: "Edit a direct message you sent \u2014 replace its body by message_id (from mDM_list). Stores a server-readable edited body; on an end-to-end-encrypted thread this does not re-encrypt, so for E2EE prefer deleting and re-sending.",
541
+ inputSchema: mDM_edit_input,
542
+ handler: mDM_edit
543
+ },
544
+ {
545
+ name: "mDM_delete",
546
+ requires: "any",
547
+ description: "Delete a direct message you sent by message_id (from mDM_list). Soft-deletes server-side so it stops showing in mDM_list for both sides.",
548
+ inputSchema: mDM_delete_input,
549
+ handler: mDM_delete
502
550
  }
503
551
  ];
504
552
 
505
- // src/tools/mirc.ts
553
+ // src/tools/mdm-voice.ts
506
554
  import { z as z2 } from "zod";
507
- var ChannelId = z2.string().min(1).max(120).describe("Channel id (UUID). Use mIRC_list to discover available channels.");
508
- var AccessMode = z2.enum(["open", "password", "private"]).describe("open: anyone can join \xB7 password: join with a shared password \xB7 private: invite-only.");
509
- var Capabilities = z2.object({
510
- txt: z2.boolean().default(true),
511
- ptt: z2.boolean().default(false),
512
- live: z2.boolean().default(false)
555
+ var PROTOCOL_VERSION2 = "mosadd.chat.v1";
556
+ var ContactRef2 = z2.string().min(1).describe("Recipient identity id (UUID). Use mDM_list_contacts to find it.");
557
+ var RoomId = z2.string().min(1).describe("Voice room id (from mDM_call_start's call_invite).");
558
+ var mDM_call_start_input = z2.object({
559
+ to: ContactRef2,
560
+ video: z2.boolean().optional().describe("Request a video call instead of audio-only. Default false."),
561
+ thread_label: z2.string().max(120).regex(/^[a-zA-Z0-9._-]+$/).optional().describe("Optional thread label to place the call invite in. Defaults to the contact's main thread.")
562
+ });
563
+ var mDM_call_answer_input = z2.object({ room_id: RoomId });
564
+ var mDM_call_end_input = z2.object({
565
+ room_id: RoomId,
566
+ to: ContactRef2.optional().describe("If set, also drop a call_end control message in this contact's DM thread."),
567
+ thread_label: z2.string().max(120).regex(/^[a-zA-Z0-9._-]+$/).optional()
568
+ });
569
+ var mDM_voice_note_input = z2.object({
570
+ to: ContactRef2,
571
+ audio_url: z2.string().url().describe("URL of the recorded audio clip (already uploaded by the client)."),
572
+ duration_ms: z2.number().int().positive().optional().describe("Clip length in milliseconds, if known."),
573
+ mime: z2.string().max(120).optional().describe("Audio MIME type, e.g. audio/ogg, audio/mpeg. Default audio/ogg."),
574
+ thread_label: z2.string().max(120).regex(/^[a-zA-Z0-9._-]+$/).optional()
575
+ });
576
+ function dmThreadId2(selfId, otherId, label) {
577
+ const [a, b] = [selfId, otherId].sort();
578
+ return label ? `dm:${a}:${b}:${label}` : `dm:${a}:${b}`;
579
+ }
580
+ function packEnvelope(obj) {
581
+ const envelope = { v: PROTOCOL_VERSION2, sent_at: (/* @__PURE__ */ new Date()).toISOString(), ...obj };
582
+ return new Uint8Array(Buffer.from(JSON.stringify(envelope), "utf8"));
583
+ }
584
+ async function signalDm(ctx, to, threadLabel, envelope) {
585
+ const dm = ctx.providers.dm;
586
+ const selfId = await dm.selfId();
587
+ const threadId = dmThreadId2(selfId, to, threadLabel);
588
+ const res = await dm.send({ to, threadId, payload: packEnvelope(envelope) });
589
+ return { message_id: res?.message_id, thread_id: threadId };
590
+ }
591
+ async function mDM_call_start(input, ctx) {
592
+ const dm = ctx.providers.dm;
593
+ const selfId = await dm.selfId();
594
+ const mode = input.video ? "video" : "audio";
595
+ const label = `dmcall-${dmThreadId2(selfId, input.to, input.thread_label).replace(/[^a-zA-Z0-9._-]/g, "-")}`.slice(0, 120);
596
+ const { roomId } = await ctx.providers.voice.createRoom(label);
597
+ const ticket = await ctx.providers.voice.joinTicket(roomId);
598
+ let invited = false;
599
+ let thread_id = dmThreadId2(selfId, input.to, input.thread_label);
600
+ try {
601
+ const sig = await signalDm(ctx, input.to, input.thread_label, {
602
+ type: "call_invite",
603
+ room_id: roomId,
604
+ mode,
605
+ from: selfId
606
+ });
607
+ thread_id = sig.thread_id;
608
+ invited = true;
609
+ } catch (e) {
610
+ ctx.log("warn", "mDM_call_start: invite signal failed (room still usable)", {
611
+ error: e.message
612
+ });
613
+ }
614
+ ctx.log("debug", "mDM_call_start", { room_id: roomId, mode, invited });
615
+ return { room_id: roomId, token: ticket.token, url: ticket.url, identity: ticket.identity, mode, invited, thread_id };
616
+ }
617
+ async function mDM_call_answer(input, ctx) {
618
+ const ticket = await ctx.providers.voice.joinTicket(input.room_id);
619
+ ctx.log("debug", "mDM_call_answer", { room_id: ticket.roomId, identity: ticket.identity });
620
+ return { room_id: ticket.roomId, token: ticket.token, url: ticket.url, identity: ticket.identity };
621
+ }
622
+ async function mDM_call_end(input, ctx) {
623
+ let signalled = false;
624
+ if (input.to) {
625
+ try {
626
+ await signalDm(ctx, input.to, input.thread_label, { type: "call_end", room_id: input.room_id });
627
+ signalled = true;
628
+ } catch (e) {
629
+ ctx.log("warn", "mDM_call_end: hangup signal failed", { error: e.message });
630
+ }
631
+ }
632
+ ctx.log("debug", "mDM_call_end", { room_id: input.room_id, signalled });
633
+ return { room_id: input.room_id, signalled };
634
+ }
635
+ async function mDM_voice_note(input, ctx) {
636
+ const sig = await signalDm(ctx, input.to, input.thread_label, {
637
+ type: "voice_note",
638
+ audio_url: input.audio_url,
639
+ duration_ms: input.duration_ms ?? null,
640
+ mime: input.mime ?? "audio/ogg"
641
+ });
642
+ ctx.log("debug", "mDM_voice_note", { thread_id: sig.thread_id });
643
+ return sig;
644
+ }
645
+ var mdmVoiceTools = [
646
+ {
647
+ name: "mDM_call_start",
648
+ requires: "network",
649
+ description: "Start a 1:1 real-time voice (or video) call with a contact \u2014 the ordinary full-duplex phone-style call (NOT walkie-talkie mTALK, NOT PSTN mCALL). Creates a room, returns join credentials (token + media url), and drops a `call_invite` control message in the DM thread so the contact can answer. Set video:true for video.",
650
+ inputSchema: mDM_call_start_input,
651
+ handler: mDM_call_start
652
+ },
653
+ {
654
+ name: "mDM_call_answer",
655
+ requires: "network",
656
+ description: "Answer an incoming 1:1 call by its room_id (from the call_invite seen via mDM_list). Returns join credentials (token + media url) for the same room.",
657
+ inputSchema: mDM_call_answer_input,
658
+ handler: mDM_call_answer
659
+ },
660
+ {
661
+ name: "mDM_call_end",
662
+ requires: "network",
663
+ description: "End a 1:1 call. The audio leg ends when clients disconnect; pass `to` to also drop a `call_end` (hangup) control message in the contact's DM thread.",
664
+ inputSchema: mDM_call_end_input,
665
+ handler: mDM_call_end
666
+ },
667
+ {
668
+ name: "mDM_voice_note",
669
+ requires: "network",
670
+ description: "Send an asynchronous voice note to a contact: references an already-uploaded audio clip (audio_url) and posts it as a `voice_note` message in the DM thread. Use for fire-and-forget voice instead of a live call.",
671
+ inputSchema: mDM_voice_note_input,
672
+ handler: mDM_voice_note
673
+ }
674
+ ];
675
+
676
+ // src/tools/mirc.ts
677
+ import { z as z3 } from "zod";
678
+ var ChannelId = z3.string().min(1).max(120).describe("Channel id (UUID). Use mIRC_list to discover available channels.");
679
+ var AccessMode = z3.enum(["open", "password", "private"]).describe("open: anyone can join \xB7 password: join with a shared password \xB7 private: invite-only.");
680
+ var Capabilities = z3.object({
681
+ txt: z3.boolean().default(true),
682
+ ptt: z3.boolean().default(false),
683
+ live: z3.boolean().default(false)
513
684
  }).describe("Which modes are enabled in this channel: txt (text), ptt (push-to-talk voice), live (live stream).").optional();
514
- var mIRC_create_input = z2.object({
515
- name: z2.string().min(1).max(80).describe("Channel display name."),
516
- topic: z2.string().max(500).optional().describe("Optional channel topic/description."),
685
+ var mIRC_create_input = z3.object({
686
+ name: z3.string().min(1).max(80).describe("Channel display name."),
687
+ topic: z3.string().max(500).optional().describe("Optional channel topic/description."),
517
688
  access_mode: AccessMode.default("open"),
518
- password: z2.string().min(6).max(120).optional().describe("Password (only for access_mode=password)."),
689
+ password: z3.string().min(6).max(120).optional().describe("Password (only for access_mode=password)."),
519
690
  capabilities: Capabilities
520
691
  });
521
- var mIRC_list_input = z2.object({
522
- limit: z2.number().int().min(1).max(500).default(100).optional(),
523
- offset: z2.number().int().min(0).default(0).optional(),
692
+ var mIRC_list_input = z3.object({
693
+ limit: z3.number().int().min(1).max(500).default(100).optional(),
694
+ offset: z3.number().int().min(0).default(0).optional(),
524
695
  access_mode: AccessMode.optional().describe("Filter to a single access mode.")
525
696
  });
526
- var mIRC_get_input = z2.object({
697
+ var mIRC_get_input = z3.object({
527
698
  channel_id: ChannelId
528
699
  });
529
- var mIRC_update_input = z2.object({
700
+ var mIRC_update_input = z3.object({
530
701
  channel_id: ChannelId,
531
- name: z2.string().min(1).max(80).optional(),
532
- topic: z2.string().max(500).optional(),
702
+ name: z3.string().min(1).max(80).optional(),
703
+ topic: z3.string().max(500).optional(),
533
704
  access_mode: AccessMode.optional(),
534
705
  capabilities: Capabilities
535
706
  });
536
- var mIRC_delete_input = z2.object({
707
+ var mIRC_delete_input = z3.object({
537
708
  channel_id: ChannelId
538
709
  });
539
710
  async function mIRC_create(input, ctx) {
@@ -616,51 +787,51 @@ var mircTools = [
616
787
  ];
617
788
 
618
789
  // src/tools/mirc-members.ts
619
- import { z as z3 } from "zod";
620
- var ChannelId2 = z3.string().min(1).max(120).describe("Channel id (UUID). From mIRC_list / mIRC_create.");
621
- var MemberIdentity = z3.string().min(1).describe("Target user's identity id (UUID). From mDM_list_contacts or radar logs.");
622
- var Role = z3.enum(["owner", "admin", "moderator", "member", "guest"]).describe("Member role within the channel.");
623
- var mIRC_join_input = z3.object({
790
+ import { z as z4 } from "zod";
791
+ var ChannelId2 = z4.string().min(1).max(120).describe("Channel id (UUID). From mIRC_list / mIRC_create.");
792
+ var MemberIdentity = z4.string().min(1).describe("Target user's identity id (UUID). From mDM_list_contacts or radar logs.");
793
+ var Role = z4.enum(["owner", "admin", "moderator", "member", "guest"]).describe("Member role within the channel.");
794
+ var mIRC_join_input = z4.object({
624
795
  channel_id: ChannelId2,
625
- password: z3.string().min(1).optional().describe("Required if the channel is access_mode=private.")
796
+ password: z4.string().min(1).optional().describe("Required if the channel is access_mode=private.")
626
797
  });
627
- var mIRC_request_access_input = z3.object({
798
+ var mIRC_request_access_input = z4.object({
628
799
  channel_id: ChannelId2,
629
- message: z3.string().max(500).optional().describe("Optional note for the channel owner explaining why.")
800
+ message: z4.string().max(500).optional().describe("Optional note for the channel owner explaining why.")
630
801
  });
631
- var mIRC_leave_input = z3.object({
802
+ var mIRC_leave_input = z4.object({
632
803
  channel_id: ChannelId2
633
804
  });
634
- var mIRC_approve_request_input = z3.object({
805
+ var mIRC_approve_request_input = z4.object({
635
806
  channel_id: ChannelId2,
636
- request_id: z3.string().min(1).describe("Pending request id.")
807
+ request_id: z4.string().min(1).describe("Pending request id.")
637
808
  });
638
809
  var mIRC_reject_request_input = mIRC_approve_request_input;
639
- var mIRC_kick_input = z3.object({
810
+ var mIRC_kick_input = z4.object({
640
811
  channel_id: ChannelId2,
641
812
  identity_id: MemberIdentity,
642
- reason: z3.string().max(500).optional()
813
+ reason: z4.string().max(500).optional()
643
814
  });
644
- var mIRC_ban_input = z3.object({
815
+ var mIRC_ban_input = z4.object({
645
816
  channel_id: ChannelId2,
646
817
  identity_id: MemberIdentity,
647
- reason: z3.string().max(500).optional(),
818
+ reason: z4.string().max(500).optional(),
648
819
  /** Optional unban deadline (ISO-8601). Omit for permanent ban. */
649
- until: z3.string().optional()
820
+ until: z4.string().optional()
650
821
  });
651
- var mIRC_unban_input = z3.object({
822
+ var mIRC_unban_input = z4.object({
652
823
  channel_id: ChannelId2,
653
824
  identity_id: MemberIdentity
654
825
  });
655
- var mIRC_set_role_input = z3.object({
826
+ var mIRC_set_role_input = z4.object({
656
827
  channel_id: ChannelId2,
657
828
  identity_id: MemberIdentity,
658
829
  role: Role
659
830
  });
660
- var mIRC_set_ptt_input = z3.object({
831
+ var mIRC_set_ptt_input = z4.object({
661
832
  channel_id: ChannelId2,
662
833
  identity_id: MemberIdentity,
663
- ptt_enabled: z3.boolean().describe("Allow this member to hold the PTT floor in voice mode.")
834
+ ptt_enabled: z4.boolean().describe("Allow this member to hold the PTT floor in voice mode.")
664
835
  });
665
836
  async function invokeChannelMembers(action, body, ctx) {
666
837
  readSupabaseEnv();
@@ -741,24 +912,24 @@ var mircMembersTools = [
741
912
  ];
742
913
 
743
914
  // src/tools/mirc-messages.ts
744
- import { z as z4 } from "zod";
745
- var PROTOCOL_VERSION2 = "mosadd.chat.v1";
746
- var ChannelId3 = z4.string().min(1).max(120).describe("Channel id (UUID). From mIRC_create / mIRC_list.");
747
- var mIRC_post_message_input = z4.object({
915
+ import { z as z5 } from "zod";
916
+ var PROTOCOL_VERSION3 = "mosadd.chat.v1";
917
+ var ChannelId3 = z5.string().min(1).max(120).describe("Channel id (UUID). From mIRC_create / mIRC_list.");
918
+ var mIRC_post_message_input = z5.object({
748
919
  channel_id: ChannelId3,
749
- text: z4.string().min(1).max(64e3).describe("Message body (UTF-8). Max 64 KB."),
750
- reply_to_id: z4.string().optional().describe("Optional id of the message being replied to."),
751
- space_id: z4.string().optional().describe("Optional backing space id. Resolved automatically from the channel if omitted.")
920
+ text: z5.string().min(1).max(64e3).describe("Message body (UTF-8). Max 64 KB."),
921
+ reply_to_id: z5.string().optional().describe("Optional id of the message being replied to."),
922
+ space_id: z5.string().optional().describe("Optional backing space id. Resolved automatically from the channel if omitted.")
752
923
  });
753
- var mIRC_list_messages_input = z4.object({
924
+ var mIRC_list_messages_input = z5.object({
754
925
  channel_id: ChannelId3,
755
- limit: z4.number().int().min(1).max(200).default(50).optional(),
756
- cursor: z4.string().optional().describe("Opaque pagination cursor from a prior list response."),
757
- space_id: z4.string().optional().describe("Optional backing space id. Resolved automatically if omitted.")
926
+ limit: z5.number().int().min(1).max(200).default(50).optional(),
927
+ cursor: z5.string().optional().describe("Opaque pagination cursor from a prior list response."),
928
+ space_id: z5.string().optional().describe("Optional backing space id. Resolved automatically if omitted.")
758
929
  });
759
930
  function packPlaintextPayload2(text, replyToId) {
760
931
  const envelope = {
761
- v: PROTOCOL_VERSION2,
932
+ v: PROTOCOL_VERSION3,
762
933
  type: "text",
763
934
  text,
764
935
  reply_to: replyToId ?? null,
@@ -794,7 +965,7 @@ async function mIRC_post_message(input, ctx) {
794
965
  thread_id,
795
966
  encrypted_payload: packPlaintextPayload2(input.text, input.reply_to_id),
796
967
  message_type: "txt",
797
- protocol_version: PROTOCOL_VERSION2,
968
+ protocol_version: PROTOCOL_VERSION3,
798
969
  reply_to_id: input.reply_to_id ?? null
799
970
  });
800
971
  if (!data?.message?.id) throw new Error("message-send returned no message id");
@@ -825,7 +996,7 @@ var mircMessagesTools = [
825
996
  {
826
997
  name: "mIRC_post_message",
827
998
  requires: "network",
828
- description: "Post a text message into a persistent channel (mIRC). Pass channel_id from mIRC_create / mIRC_list; the backing space is resolved automatically. You must be a member of private channels (use mIRC_join first). This is how an agent actually talks in a channel \u2014 the other mIRC_* tools only manage it.",
999
+ description: "Post a text message into a persistent channel (mIRC). Pass channel_id from mIRC_create / mIRC_list; the backing space is resolved automatically. You must be a member of private channels (use mIRC_join first). This is how an agent actually talks in a channel \u2014 the other mIRC_* tools only manage it. NOTE (alpha): the payload is NOT end-to-end encrypted \u2014 it is plaintext base64 and is readable by the server; the mosadd.com app uses per-channel group-key encryption, so app clients cannot read these messages yet (and vice-versa). Group-key parity is planned.",
829
1000
  inputSchema: mIRC_post_message_input,
830
1001
  handler: mIRC_post_message
831
1002
  },
@@ -838,26 +1009,141 @@ var mircMessagesTools = [
838
1009
  }
839
1010
  ];
840
1011
 
1012
+ // src/tools/mirc-edge.ts
1013
+ import { z as z6 } from "zod";
1014
+ var DEFAULT_EDGE_URL = "https://mosadd-edge.mr-brics-33.workers.dev";
1015
+ var DEFAULT_SUPABASE_URL = "https://rooffhgbxafyjcwmwpsy.supabase.co";
1016
+ function edgeUrl() {
1017
+ return process.env.MOSADD_EDGE_URL?.replace(/\/$/, "") ?? DEFAULT_EDGE_URL;
1018
+ }
1019
+ function supabaseUrl() {
1020
+ return process.env.MOSADD_SUPABASE_URL?.replace(/\/$/, "") ?? process.env.SUPABASE_URL?.replace(/\/$/, "") ?? DEFAULT_SUPABASE_URL;
1021
+ }
1022
+ function hubKey() {
1023
+ const key = process.env.MOSADD_API_KEY ?? process.env.MOSADD_HUB_KEY ?? "";
1024
+ if (!key) throw new Error("MOSADD_API_KEY required for mIRC edge tools (see mosadd login or hub-keys).");
1025
+ return key;
1026
+ }
1027
+ var mIRC_send_edge_input = z6.object({
1028
+ channel_id: z6.string().min(1).max(128).describe("Channel id (UUID). Same as mIRC_create / mIRC_list."),
1029
+ text: z6.string().min(1).max(64e3).describe("Message body (UTF-8, max 64 KB)."),
1030
+ from: z6.string().max(120).optional().describe("Sender hint shown to other clients (defaults to the hub-key owner).")
1031
+ });
1032
+ async function mIRC_send_edge(input, ctx) {
1033
+ ctx.log("debug", "mIRC_send_edge", { channel_id: input.channel_id });
1034
+ const r = await fetch(`${edgeUrl()}/c/${input.channel_id}/send`, {
1035
+ method: "POST",
1036
+ headers: {
1037
+ "Content-Type": "application/json",
1038
+ Authorization: `Bearer ${hubKey()}`
1039
+ },
1040
+ body: JSON.stringify({ text: input.text, from: input.from })
1041
+ });
1042
+ if (!r.ok) {
1043
+ const errBody = await r.text().catch(() => "");
1044
+ throw new Error(`mosadd-edge ${r.status}: ${errBody.slice(0, 200)}`);
1045
+ }
1046
+ const data = await r.json();
1047
+ if (!data?.id) throw new Error("mosadd-edge: send returned no id");
1048
+ return { message_id: data.id, delivered_at: data.ts ?? Date.now(), channel_id: input.channel_id };
1049
+ }
1050
+ var mIRC_history_edge_input = z6.object({
1051
+ channel_id: z6.string().min(1).max(128).describe("Channel id (UUID)."),
1052
+ limit: z6.number().int().min(1).max(100).default(50).optional().describe("How many recent messages to return (max 100, the DO ring size).")
1053
+ });
1054
+ async function mIRC_history_edge(input, ctx) {
1055
+ const limit = input.limit ?? 50;
1056
+ ctx.log("debug", "mIRC_history_edge", { channel_id: input.channel_id, limit });
1057
+ const r = await fetch(`${edgeUrl()}/c/${input.channel_id}/history?limit=${limit}`, {
1058
+ headers: { Authorization: `Bearer ${hubKey()}` }
1059
+ });
1060
+ if (!r.ok) {
1061
+ const errBody = await r.text().catch(() => "");
1062
+ throw new Error(`mosadd-edge ${r.status}: ${errBody.slice(0, 200)}`);
1063
+ }
1064
+ const data = await r.json();
1065
+ return {
1066
+ channel_id: input.channel_id,
1067
+ messages: (data.messages ?? []).map((m) => ({
1068
+ id: m.id,
1069
+ from: m.from ?? null,
1070
+ text: m.text,
1071
+ timestamp: m.ts
1072
+ }))
1073
+ };
1074
+ }
1075
+ var mIRC_mint_channel_token_input = z6.object({
1076
+ channel_id: z6.string().min(1).max(128).describe("Channel id \u2014 the JWT will be scoped to this channel only. Must match the WS upgrade path."),
1077
+ user_id: z6.string().min(1).max(120).optional().describe("Optional end-user id. Stamped onto messages as 'from'. Useful when one hub key fronts many end-users (relay topology).")
1078
+ });
1079
+ async function mIRC_mint_channel_token(input, ctx) {
1080
+ ctx.log("debug", "mIRC_mint_channel_token", { channel_id: input.channel_id });
1081
+ const r = await fetch(`${supabaseUrl()}/functions/v1/hub-mint-channel-token`, {
1082
+ method: "POST",
1083
+ headers: {
1084
+ "Content-Type": "application/json",
1085
+ Authorization: `Bearer ${hubKey()}`
1086
+ },
1087
+ body: JSON.stringify({ channel_id: input.channel_id, user_id: input.user_id })
1088
+ });
1089
+ if (!r.ok) {
1090
+ const errBody = await r.text().catch(() => "");
1091
+ throw new Error(`hub-mint-channel-token ${r.status}: ${errBody.slice(0, 200)}`);
1092
+ }
1093
+ const data = await r.json();
1094
+ if (!data?.token || !data?.expires_in || !data?.channel_id || !data?.scope) {
1095
+ throw new Error("hub-mint-channel-token: malformed response");
1096
+ }
1097
+ return data;
1098
+ }
1099
+ var mircEdgeTools = [
1100
+ {
1101
+ name: "mIRC_mint_channel_token",
1102
+ requires: "network",
1103
+ description: "Exchange the hub key (MOSADD_API_KEY) for a short-lived (5min), channel-scoped JWT. Returns { token, expires_in, channel_id, scope }. The token is safe to hand to a browser to open a WS via `Sec-WebSocket-Protocol: mosadd.v1, bearer.<token>`. The hub key NEVER leaves the server. Use this from any server-side route (Next.js /api/chat-token, Express, etc.) before showing chat in a browser. Required by LINEAR-2675/E6 to avoid leaking the hub key into CDN access logs.",
1104
+ inputSchema: mIRC_mint_channel_token_input,
1105
+ handler: mIRC_mint_channel_token
1106
+ },
1107
+ {
1108
+ name: "mIRC_send_edge",
1109
+ requires: "network",
1110
+ description: "Send a text message into a persistent channel via the mosadd-edge Cloudflare Worker (Durable Object backend). Sub-100ms global fan-out to all WebSocket subscribers of the channel + async flush to Supabase as system-of-record (idempotent). Use this when you want native realtime push without polling. Parallel to mIRC_post_message (Supabase path); pick one per channel. Auth: MOSADD_API_KEY env (hub key).",
1111
+ inputSchema: mIRC_send_edge_input,
1112
+ handler: mIRC_send_edge
1113
+ },
1114
+ {
1115
+ name: "mIRC_history_edge",
1116
+ requires: "network",
1117
+ description: "Read the last N (max 100) messages held in the channel's Durable Object ring buffer at the edge. Hot path is the DO, not Supabase \u2014 same data lands in messages_meta via async flush, so cold reads / pagination beyond 100 should use mIRC_list_messages.",
1118
+ inputSchema: mIRC_history_edge_input,
1119
+ handler: mIRC_history_edge
1120
+ }
1121
+ ];
1122
+
841
1123
  // src/tools/mroom.ts
842
- import { z as z5 } from "zod";
843
- var RoomId = z5.string().min(1).describe("Private room id (UUID).");
844
- var mROOM_create_input = z5.object({
845
- ttl_seconds: z5.number().int().min(60).max(86400 * 30).default(86400).optional().describe("Time-to-live in seconds. Defaults to 24 h. Max 30 days.")
1124
+ import { z as z7 } from "zod";
1125
+ var RoomId2 = z7.string().min(1).describe("Private room id (UUID).");
1126
+ var mROOM_voice_join_input = z7.object({
1127
+ room_id: RoomId2,
1128
+ video: z7.boolean().optional().describe("Request video instead of audio-only. Default false.")
846
1129
  });
847
- var mROOM_join_input = z5.object({
848
- room_id: RoomId
1130
+ var mROOM_create_input = z7.object({
1131
+ ttl_seconds: z7.number().int().min(60).max(86400 * 30).default(86400).optional().describe("Time-to-live in seconds. Defaults to 24 h. Max 30 days.")
849
1132
  });
850
- var mROOM_close_input = z5.object({
851
- room_id: RoomId
1133
+ var mROOM_join_input = z7.object({
1134
+ room_id: RoomId2
852
1135
  });
853
- var mROOM_leave_input = z5.object({
854
- room_id: RoomId
1136
+ var mROOM_close_input = z7.object({
1137
+ room_id: RoomId2
855
1138
  });
856
- var mROOM_list_input = z5.object({});
857
- var mROOM_create_guest_link_input = z5.object({
858
- room_id: RoomId,
859
- display_name: z5.string().min(1).max(80).describe("Display name the guest will appear under. They never sign up \u2014 this is the only identifier."),
860
- ttl_seconds: z5.number().int().min(60).max(86400 * 7).default(3600).optional().describe("How long the guest token is valid. Default 1 h, max 7 days.")
1139
+ var mROOM_leave_input = z7.object({
1140
+ room_id: RoomId2
1141
+ });
1142
+ var mROOM_list_input = z7.object({});
1143
+ var mROOM_create_guest_link_input = z7.object({
1144
+ room_id: RoomId2,
1145
+ display_name: z7.string().min(1).max(80).describe("Display name the guest will appear under. They never sign up \u2014 this is the only identifier."),
1146
+ ttl_seconds: z7.number().int().min(60).max(86400 * 7).default(3600).optional().describe("How long the guest token is valid. Default 1 h, max 7 days.")
861
1147
  });
862
1148
  async function mROOM_create(input, ctx) {
863
1149
  readSupabaseEnv();
@@ -913,6 +1199,17 @@ async function mROOM_create_guest_link(input, ctx) {
913
1199
  expires_at: result.expires_at
914
1200
  };
915
1201
  }
1202
+ async function mROOM_voice_join(input, ctx) {
1203
+ const ticket = await ctx.providers.voice.joinTicket(input.room_id);
1204
+ ctx.log("debug", "mROOM_voice_join", { room_id: ticket.roomId, identity: ticket.identity });
1205
+ return {
1206
+ room_id: ticket.roomId,
1207
+ token: ticket.token,
1208
+ url: ticket.url,
1209
+ identity: ticket.identity,
1210
+ mode: input.video ? "video" : "audio"
1211
+ };
1212
+ }
916
1213
  var mroomTools = [
917
1214
  {
918
1215
  name: "mROOM_create",
@@ -955,26 +1252,33 @@ var mroomTools = [
955
1252
  description: "List private rooms the current user belongs to.",
956
1253
  inputSchema: mROOM_list_input,
957
1254
  handler: mROOM_list
1255
+ },
1256
+ {
1257
+ name: "mROOM_voice_join",
1258
+ requires: "network",
1259
+ description: "Join an mROOM's full-duplex GROUP voice (everyone can talk \u2014 no walkie-talkie floor; that's mTALK). Returns media credentials (token + url) for the room's audio/video transport. Be a room member first (mROOM_join or a guest link). Set video:true for video.",
1260
+ inputSchema: mROOM_voice_join_input,
1261
+ handler: mROOM_voice_join
958
1262
  }
959
1263
  ];
960
1264
 
961
1265
  // src/tools/mroom-messages.ts
962
- import { z as z6 } from "zod";
963
- var PROTOCOL_VERSION3 = "mosadd.chat.v1";
964
- var RoomId2 = z6.string().min(1).describe("Private room id (UUID). From mROOM_create / mROOM_list.");
965
- var mROOM_send_message_input = z6.object({
966
- room_id: RoomId2,
967
- text: z6.string().min(1).max(64e3).describe("Message body (UTF-8). Max 64 KB."),
968
- reply_to_id: z6.string().optional().describe("Optional id of the message being replied to.")
1266
+ import { z as z8 } from "zod";
1267
+ var PROTOCOL_VERSION4 = "mosadd.chat.v1";
1268
+ var RoomId3 = z8.string().min(1).describe("Private room id (UUID). From mROOM_create / mROOM_list.");
1269
+ var mROOM_send_message_input = z8.object({
1270
+ room_id: RoomId3,
1271
+ text: z8.string().min(1).max(64e3).describe("Message body (UTF-8). Max 64 KB."),
1272
+ reply_to_id: z8.string().optional().describe("Optional id of the message being replied to.")
969
1273
  });
970
- var mROOM_list_messages_input = z6.object({
971
- room_id: RoomId2,
972
- limit: z6.number().int().min(1).max(200).default(50).optional(),
973
- cursor: z6.string().optional().describe("Opaque pagination cursor from a prior list response.")
1274
+ var mROOM_list_messages_input = z8.object({
1275
+ room_id: RoomId3,
1276
+ limit: z8.number().int().min(1).max(200).default(50).optional(),
1277
+ cursor: z8.string().optional().describe("Opaque pagination cursor from a prior list response.")
974
1278
  });
975
1279
  function packPlaintextPayload3(text, replyToId) {
976
1280
  const envelope = {
977
- v: PROTOCOL_VERSION3,
1281
+ v: PROTOCOL_VERSION4,
978
1282
  type: "text",
979
1283
  text,
980
1284
  reply_to: replyToId ?? null,
@@ -1002,7 +1306,7 @@ async function mROOM_send_message(input, ctx) {
1002
1306
  thread_id,
1003
1307
  encrypted_payload: packPlaintextPayload3(input.text, input.reply_to_id),
1004
1308
  message_type: "text",
1005
- protocol_version: PROTOCOL_VERSION3,
1309
+ protocol_version: PROTOCOL_VERSION4,
1006
1310
  reply_to_id: input.reply_to_id ?? null
1007
1311
  }
1008
1312
  );
@@ -1053,23 +1357,31 @@ var mroomMessagesTools = [
1053
1357
  ];
1054
1358
 
1055
1359
  // src/tools/mail.ts
1056
- import { z as z7 } from "zod";
1057
- var EmailAddress = z7.string().email().max(254).describe("RFC 5321 email address.");
1058
- var MessageId = z7.string().min(1).describe("Message id (UUID) from mAIL_send or inbox.");
1059
- var mAIL_send_input = z7.object({
1060
- to: z7.union([EmailAddress, z7.array(EmailAddress).min(1).max(50)]).describe(
1360
+ import { z as z9 } from "zod";
1361
+ var EmailAddress = z9.string().email().max(254).describe("RFC 5321 email address.");
1362
+ var MessageId = z9.string().min(1).describe("Message id (UUID) from mAIL_send or inbox.");
1363
+ var mAIL_send_input = z9.object({
1364
+ to: z9.union([EmailAddress, z9.array(EmailAddress).min(1).max(50)]).describe(
1061
1365
  "Recipient(s). Single address or array of up to 50."
1062
1366
  ),
1063
- subject: z7.string().min(1).max(998).describe("Email subject line. Max 998 chars (RFC 5322)."),
1064
- body_text: z7.string().max(1048576).optional().describe("Plain text body. Max 1 MB."),
1065
- body_html: z7.string().max(1048576).optional().describe("HTML body. Max 1 MB."),
1066
- cc: z7.array(EmailAddress).max(50).optional(),
1067
- bcc: z7.array(EmailAddress).max(50).optional(),
1367
+ subject: z9.string().min(1).max(998).describe("Email subject line. Max 998 chars (RFC 5322)."),
1368
+ body_text: z9.string().max(1048576).optional().describe("Plain text body. Max 1 MB."),
1369
+ body_html: z9.string().max(1048576).optional().describe("HTML body. Max 1 MB."),
1370
+ cc: z9.array(EmailAddress).max(50).optional(),
1371
+ bcc: z9.array(EmailAddress).max(50).optional(),
1068
1372
  reply_to: EmailAddress.optional()
1069
1373
  });
1070
- var mAIL_view_input = z7.object({
1374
+ var mAIL_view_input = z9.object({
1375
+ message_id: MessageId
1376
+ });
1377
+ var mAIL_delete_input = z9.object({
1071
1378
  message_id: MessageId
1072
1379
  });
1380
+ var mAIL_list_input = z9.object({
1381
+ direction: z9.enum(["inbound", "outbound"]).optional().describe("Filter to received (inbound) or sent (outbound) mail. Omit for both."),
1382
+ limit: z9.number().int().min(1).max(200).optional().describe("Max emails to return. Default 50."),
1383
+ before: z9.string().optional().describe("Pagination cursor: pass the previous response's next_cursor to get the next (older) page.")
1384
+ });
1073
1385
  async function mAIL_send(input, ctx) {
1074
1386
  readSupabaseEnv();
1075
1387
  if (!input.body_text && !input.body_html) {
@@ -1083,7 +1395,30 @@ async function mAIL_view(input, ctx) {
1083
1395
  ctx.log("debug", "mAIL_view invoking mp0st-view", { message_id: input.message_id });
1084
1396
  return await invokeFunction("mp0st-view", { message_id: input.message_id });
1085
1397
  }
1398
+ async function mAIL_list(input, ctx) {
1399
+ readSupabaseEnv();
1400
+ ctx.log("debug", "mAIL_list invoking mp0st-list", { direction: input.direction });
1401
+ return await invokeFunction("mp0st-list", {
1402
+ direction: input.direction ?? null,
1403
+ limit: input.limit ?? 50,
1404
+ before: input.before ?? null
1405
+ });
1406
+ }
1407
+ async function mAIL_delete(input, ctx) {
1408
+ readSupabaseEnv();
1409
+ ctx.log("debug", "mAIL_delete invoking mp0st-delete", { message_id: input.message_id });
1410
+ return await invokeFunction("mp0st-delete", {
1411
+ message_id: input.message_id
1412
+ });
1413
+ }
1086
1414
  var mailTools = [
1415
+ {
1416
+ name: "mAIL_list",
1417
+ requires: "network",
1418
+ description: "List the user's mailbox (their <userId>@mosadd.com inbox/outbox) newest-first, with sender, subject, status and a short snippet. Filter by direction ('inbound' = received, 'outbound' = sent). Use the returned next_cursor with `before` to page through older mail. Call mAIL_view to read a full message body.",
1419
+ inputSchema: mAIL_list_input,
1420
+ handler: mAIL_list
1421
+ },
1087
1422
  {
1088
1423
  name: "mAIL_send",
1089
1424
  requires: "network",
@@ -1097,20 +1432,27 @@ var mailTools = [
1097
1432
  description: "Read the full body and metadata of an email by message_id.",
1098
1433
  inputSchema: mAIL_view_input,
1099
1434
  handler: mAIL_view
1435
+ },
1436
+ {
1437
+ name: "mAIL_delete",
1438
+ requires: "network",
1439
+ description: "Delete one of the user's emails by message_id (from mAIL_list). Soft-delete \u2014 it stops showing in mAIL_list. Owner-scoped: only your own mail.",
1440
+ inputSchema: mAIL_delete_input,
1441
+ handler: mAIL_delete
1100
1442
  }
1101
1443
  ];
1102
1444
 
1103
1445
  // src/tools/mtalk.ts
1104
- import { z as z8 } from "zod";
1105
- var RoomLabel = z8.string().min(1).max(120).regex(/^[a-zA-Z0-9._-]+$/).describe("Human-readable room label (e.g. 'ops', 'field-team'). Used to derive a stable room id.");
1106
- var RoomId3 = z8.string().min(1).describe("Room id returned by mTALK_open.");
1107
- var mTALK_open_input = z8.object({
1446
+ import { z as z10 } from "zod";
1447
+ var RoomLabel = z10.string().min(1).max(120).regex(/^[a-zA-Z0-9._-]+$/).describe("Human-readable room label (e.g. 'ops', 'field-team'). Used to derive a stable room id.");
1448
+ var RoomId4 = z10.string().min(1).describe("Room id returned by mTALK_open.");
1449
+ var mTALK_open_input = z10.object({
1108
1450
  label: RoomLabel.optional().describe("Optional label; defaults to a personal room.")
1109
1451
  });
1110
- var mTALK_join_input = z8.object({ room_id: RoomId3 });
1111
- var mTALK_press_input = z8.object({ room_id: RoomId3 });
1112
- var mTALK_release_input = z8.object({ room_id: RoomId3 });
1113
- var mTALK_state_input = z8.object({ room_id: RoomId3 });
1452
+ var mTALK_join_input = z10.object({ room_id: RoomId4 });
1453
+ var mTALK_press_input = z10.object({ room_id: RoomId4 });
1454
+ var mTALK_release_input = z10.object({ room_id: RoomId4 });
1455
+ var mTALK_state_input = z10.object({ room_id: RoomId4 });
1114
1456
  async function mTALK_open(input, ctx) {
1115
1457
  const { roomId } = await ctx.providers.voice.createRoom(input.label);
1116
1458
  ctx.log("debug", "mTALK_open", { room_id: roomId });
@@ -1174,16 +1516,16 @@ var mtalkTools = [
1174
1516
  ];
1175
1517
 
1176
1518
  // src/tools/knowledge.ts
1177
- import { z as z9 } from "zod";
1178
- var mKB_search_input = z9.object({
1179
- query: z9.string().min(1).max(2e3).describe("Natural-language question to answer from the user's own indexed messages/emails/calls/notes."),
1180
- top_k: z9.number().int().min(1).max(25).optional().describe("Max number of source chunks to retrieve and ground the answer in. Default 8."),
1181
- source_types: z9.array(z9.enum(["message", "email", "call", "note", "contact"])).optional().describe("Restrict retrieval to these source types. Omit to search everything."),
1182
- thread_id: z9.string().optional().describe("Optional: restrict retrieval to a single thread id (e.g. a dm:/chat: thread).")
1519
+ import { z as z11 } from "zod";
1520
+ var mRAG_search_input = z11.object({
1521
+ query: z11.string().min(1).max(2e3).describe("Natural-language question to answer from the user's own indexed messages/emails/calls/notes."),
1522
+ top_k: z11.number().int().min(1).max(25).optional().describe("Max number of source chunks to retrieve and ground the answer in. Default 8."),
1523
+ source_types: z11.array(z11.enum(["message", "email", "call", "note", "contact"])).optional().describe("Restrict retrieval to these source types. Omit to search everything."),
1524
+ thread_id: z11.string().optional().describe("Optional: restrict retrieval to a single thread id (e.g. a dm:/chat: thread).")
1183
1525
  });
1184
- async function mKB_search(input, ctx) {
1526
+ async function mRAG_search(input, ctx) {
1185
1527
  readSupabaseEnv();
1186
- ctx.log("debug", "mKB_search via rag-query", { top_k: input.top_k ?? 8 });
1528
+ ctx.log("debug", "mRAG_search via rag-query", { top_k: input.top_k ?? 8 });
1187
1529
  const data = await invokeFunction("rag-query", {
1188
1530
  query: input.query,
1189
1531
  top_k: input.top_k ?? 8,
@@ -1196,18 +1538,45 @@ async function mKB_search(input, ctx) {
1196
1538
  chunks_found: data.chunks_found ?? (data.sources?.length ?? 0)
1197
1539
  };
1198
1540
  }
1541
+ var mRAG_ingest_input = z11.object({
1542
+ content_text: z11.string().min(1).max(2e5).describe("Text to index into the user's private knowledge base (a note, document, transcript, pasted page\u2026). Chunked + embedded server-side."),
1543
+ source_type: z11.enum(["file", "note", "message", "email", "contact", "call"]).optional().describe("What kind of source this is. Default 'file' (a document/note). Use 'note' for ad-hoc text."),
1544
+ source_id: z11.string().optional().describe("Optional stable id for the source so re-ingests can be grouped."),
1545
+ thread_id: z11.string().optional().describe("Optional thread id to associate this knowledge with (e.g. a dm:/chat: thread)."),
1546
+ title: z11.string().max(300).optional().describe("Optional human title, stored in metadata.")
1547
+ });
1548
+ async function mRAG_ingest(input, ctx) {
1549
+ readSupabaseEnv();
1550
+ const backendType = input.source_type === "note" ? "file" : input.source_type ?? "file";
1551
+ ctx.log("debug", "mRAG_ingest via rag-index", { source_type: backendType });
1552
+ const data = await invokeFunction("rag-index", {
1553
+ source_type: backendType,
1554
+ source_id: input.source_id ?? null,
1555
+ thread_id: input.thread_id ?? null,
1556
+ content_text: input.content_text,
1557
+ metadata: { ...input.title ? { title: input.title } : {}, ingested_via: "mRAG_ingest" }
1558
+ });
1559
+ return { indexed: data.indexed ?? 0, chunk_count: data.chunk_count ?? 0 };
1560
+ }
1199
1561
  var knowledgeTools = [
1200
1562
  {
1201
- name: "mKB_search",
1563
+ name: "mRAG_ingest",
1564
+ requires: "network",
1565
+ description: "Add text to the USER'S OWN private knowledge base so mRAG_search can recall it later. Pass content_text (a note, document, transcript, pasted page); it is semantically chunked, embedded (1536-d) and stored in the per-user vector index mRAG_search reads. Returns how many chunks were indexed. NOTE: indexed content is stored server-side in plaintext \u2014 NOT covered by the zero-knowledge / E2EE guarantee. Only ingest what the user opted to make searchable.",
1566
+ inputSchema: mRAG_ingest_input,
1567
+ handler: mRAG_ingest
1568
+ },
1569
+ {
1570
+ name: "mRAG_search",
1202
1571
  requires: "network",
1203
- description: "Search and answer questions over the USER'S OWN mosadd data (messages, emails, calls, notes) with a private RAG index \u2014 hybrid vector + keyword retrieval, reranked, grounded in cited sources (no fabrication). Use it to recall 'what did X say about Y', summarize a thread, or pull facts the user has received. Returns an answer plus the source snippets it used. This is agent memory (mKB = knowledge base) over the user's communications, available outside the mosadd app.",
1204
- inputSchema: mKB_search_input,
1205
- handler: mKB_search
1572
+ description: "Search and answer questions over the USER'S OWN mosadd data (messages, emails, calls, notes) with a private per-user RAG index \u2014 hybrid vector + keyword retrieval, reranked, grounded in cited sources (no fabrication). Use it to recall 'what did X say about Y', summarize a thread, or pull facts the user has received. Returns an answer plus the source snippets it used. This is agent memory (mRAG = RAG over your own data) over the user's communications, available outside the mosadd app. NOTE: RAG requires content to be indexed server-side in plaintext, so anything searchable here is NOT covered by the zero-knowledge / E2EE guarantee \u2014 only data the user has explicitly opted into indexing is searchable. See docs/security/e2ee-posture.md.",
1573
+ inputSchema: mRAG_search_input,
1574
+ handler: mRAG_search
1206
1575
  }
1207
1576
  ];
1208
1577
 
1209
1578
  // src/tools/capabilities.ts
1210
- import { z as z10 } from "zod";
1579
+ import { z as z12 } from "zod";
1211
1580
  var CONTRACT_VERSION = "1.0.0";
1212
1581
  var ALL_REQUIREMENTS = ["any", "radio", "network"];
1213
1582
  function buildCapabilityManifest(tools) {
@@ -1230,7 +1599,7 @@ function makeCapabilitiesTool(channelTools2) {
1230
1599
  name: "comms_capabilities",
1231
1600
  requires: "any",
1232
1601
  description: "Discover which mosadd tools are available and what transport each requires (any | radio | network). Carrier-aware hosts (e.g. off-grid radio devices) call this once to gate the tool list to what the current carrier supports. Returns a manifest with per-tool requirements grouped by transport.",
1233
- inputSchema: z10.object({}),
1602
+ inputSchema: z12.object({}),
1234
1603
  handler: async () => buildCapabilityManifest([...channelTools2, tool])
1235
1604
  };
1236
1605
  return tool;
@@ -1239,15 +1608,18 @@ function makeCapabilitiesTool(channelTools2) {
1239
1608
  // src/tools/index.ts
1240
1609
  var channelTools = [
1241
1610
  ...mdmTools,
1611
+ ...mdmVoiceTools,
1242
1612
  ...mircTools,
1243
1613
  ...mircMembersTools,
1244
1614
  ...mircMessagesTools,
1615
+ ...mircEdgeTools,
1245
1616
  ...mroomTools,
1246
1617
  ...mroomMessagesTools,
1247
1618
  ...mailTools,
1248
1619
  ...mtalkTools,
1249
1620
  ...knowledgeTools
1250
- // mcallTools, mirlTools,
1621
+ // ...mcallTools, // mCALL: carrier-pending (no telephony carrier live) — re-register when a carrier is configured
1622
+ // mirlTools,
1251
1623
  // mmatrixTools, mdiscordTools, mtelegramTools, mslackTools, msignalTools,
1252
1624
  //
1253
1625
  // Each m* module registers its tools here as it ships.
@@ -1264,7 +1636,7 @@ var allTools = [
1264
1636
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
1265
1637
 
1266
1638
  // src/providers/supabase-dm.ts
1267
- var PROTOCOL_VERSION4 = "mosadd.chat.v1";
1639
+ var PROTOCOL_VERSION5 = "mosadd.chat.v1";
1268
1640
  var SupabaseDmProvider = class {
1269
1641
  cachedSelfId = null;
1270
1642
  async selfId() {
@@ -1291,7 +1663,7 @@ var SupabaseDmProvider = class {
1291
1663
  thread_id: args.threadId,
1292
1664
  encrypted_payload,
1293
1665
  message_type: "text",
1294
- protocol_version: PROTOCOL_VERSION4,
1666
+ protocol_version: PROTOCOL_VERSION5,
1295
1667
  recipient_account_id: args.to,
1296
1668
  reply_to_id: args.replyToId ?? null
1297
1669
  });
@@ -1465,6 +1837,7 @@ function shouldLog(level, threshold) {
1465
1837
  }
1466
1838
 
1467
1839
  export {
1840
+ runWithSupabaseEnv,
1468
1841
  allTools,
1469
1842
  defaultProviders,
1470
1843
  createMosaddServer