@mosadd/mcp 3.0.0-alpha.22 → 3.0.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,43 @@ gateway (Phase 2) ships.
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [3.0.0-alpha.23] — 2026-06-26
12
+
13
+ Toolkit hardening pass: every registered tool's request/response contract was
14
+ adversarially verified against the deployed edge functions. Two tools were broken on
15
+ every call; the rest had silent field drops, wrong results, or a confidentiality/access gap.
16
+
17
+ ### Fixed
18
+ - **Edge-function errors are now legible.** `invokeFunction` only ever surfaced the fixed
19
+ string "Edge Function returned a non-2xx status code"; the real reason lives in
20
+ `error.context`. It now reads that body (and the HTTP status), so every EF-backed tool
21
+ returns an actionable error the agent can act on — the single highest-impact fix.
22
+ - **mDM_edit no longer strips E2EE.** It used to store a server-readable plaintext body even
23
+ on an E2EE thread (and the forward-only ratchet means an edit can't be re-sealed). It now
24
+ refuses to edit E2EE messages (use delete + re-send) and only edits legacy plaintext.
25
+ - **mp0st_send cc/bcc/reply_to are actually delivered** — the backend dropped them silently;
26
+ now forwarded to the mail provider (edge-function fix, deployed).
27
+ - **mDM call rooms are access-gated (security)** — call-room tokens were mintable by any
28
+ authenticated user who learned the room name; the backend now restricts them to the two
29
+ participants, and the room name is per-pair so the gate is robust (edge-function fix, deployed).
30
+ - **mDM_call_end / mDM_voice_note** now return the real message id (was always undefined).
31
+ - **mp0st_view** no longer advertises a `received_at` field the backend doesn't return (it's `sent_at`).
32
+
33
+ ### Changed
34
+ - **Unregistered `comms_embed_create`** — its `embed-keys` edge function isn't deployed (404
35
+ on every call) and the embed surface is parked. Tool count **62 → 61**. Re-register when the
36
+ backend + widget ship.
37
+ - **mIRC tools stop advertising fields the backend ignores.** Removed: `mIRC_kick` `reason`,
38
+ `mIRC_request_access` `message`, `mIRC_ban` `reason`+`until` (the latter silently made a
39
+ "temporary" ban permanent), and `access_mode` on `mIRC_update`/`mIRC_list` (no-ops). Added
40
+ `wrapped_group_key` to `mIRC_create`/`mIRC_approve_request` so E2EE (password/private)
41
+ channels are honestly callable. Descriptions corrected to match.
42
+ - **mp0st_consent** now fails fast client-side when `check`/`optin` is missing a recipient.
43
+
44
+ ### Verified (no changes needed)
45
+ - Install/boot, full build + typecheck across all packages, dependency-export resolution, and
46
+ the mDM X3DH + Double-Ratchet crypto round-trip all pass.
47
+
11
48
  ## [3.0.0-alpha.22] — 2026-06-26
12
49
 
13
50
  ### Fixed
package/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  MCP server for [mosADD](https://mosadd.com) — exposes the OS modules (m\*) as Model Context Protocol tools so any agent runtime can talk to mosadd: Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom.
4
4
 
5
- > **3.0.0-alpha.20** — **62 live tools across 5 live modules** (mDM incl. voice + files, mIRC, mp0st, mTALK, mRAG) + agent→user action links + the `comms_capabilities` discovery tool + the defensive `threat_*` engine, wired to the mosADD backend (BYOK) as a strangler-fig step. Phase 2 routes through the hosted gateway at `mcp.mosadd.com` with the 166-event radar in front.
5
+ > **3.0.0-alpha.23** — **61 live tools across 5 live modules** (mDM incl. voice + files, mIRC, mp0st, mTALK, mRAG) + agent→user action links + the `comms_capabilities` discovery tool + the defensive `threat_*` engine, wired to the mosADD backend (BYOK) as a strangler-fig step. Phase 2 routes through the hosted gateway at `mcp.mosadd.com` with the 166-event radar in front.
6
6
 
7
7
  ## Connect your agent
8
8
 
9
- Three ways to authenticate, friendliest first — all three end with the same ~62 tools.
9
+ Three ways to authenticate, friendliest first — all three end with the same ~61 tools.
10
10
 
11
11
  ### 1. `mosadd login` — recommended (one command, stays logged in)
12
12
 
@@ -65,7 +65,7 @@ In Phase 2 the hosted gateway at `mcp.mosadd.com` removes even this — add a UR
65
65
 
66
66
  ## Tools shipped in alpha
67
67
 
68
- **62 live tools across 5 live modules** (mDM, mIRC, mp0st, mTALK, mRAG) + agent→user action links + the `comms_capabilities` discovery tool + the defensive `threat_*` engine. Highlights per module:
68
+ **61 live tools across 5 live modules** (mDM, mIRC, mp0st, mTALK, mRAG) + agent→user action links + the `comms_capabilities` discovery tool + the defensive `threat_*` engine. Highlights per module:
69
69
 
70
70
  | Module | Tools | What it does |
71
71
  |---|---|---|
@@ -74,10 +74,10 @@ In Phase 2 the hosted gateway at `mcp.mosadd.com` removes even this — add a UR
74
74
  | **mp0st** (11) | `mp0st_send`, `mp0st_view`, `mp0st_list`, `mp0st_delete`, `mp0st_stats`, `mp0st_events`, `mp0st_metrics`, `mp0st_revoke`, `mp0st_audit_export`, `mp0st_consent`, `mp0st_notify` | Mail; every user gets `<id>@mosadd.com`. `mp0st_revoke` recalls secure-reader access; `mp0st_audit_export` emits an HMAC-SHA256-signed engagement audit; `mp0st_consent` manages recipient tracking opt-outs (GDPR); `mp0st_notify` pulls the inbound-mail feed |
75
75
  | **mTALK** (5) | `mTALK_open`, `mTALK_join`, `mTALK_press`, `mTALK_release`, `mTALK_state` | Half-duplex push-to-talk: one speaker, FIFO queue, anti-hog auto-release |
76
76
  | **mRAG** (4) | `mRAG_ingest`, `mRAG_search`, `mRAG_list_sources`, `mRAG_delete` | RAG recall over the user's own data (hybrid vector + BM25) |
77
- | **comms_** (4) | `comms_action_create`, `comms_action_frame_get`, `comms_capabilities`, `comms_embed_create` | `comms_action_create` mints an agent→user one-link browser action (Tier 1); `comms_action_frame_get` fetches a framed action; `comms_capabilities` is one-call discovery of every tool's transport `requires` flag; `comms_embed_create` builds an embeddable surface |
77
+ | **comms_** (3) | `comms_action_create`, `comms_action_frame_get`, `comms_capabilities` | `comms_action_create` mints an agent→user one-link browser action (Tier 1); `comms_action_frame_get` fetches a framed action; `comms_capabilities` is one-call discovery of every tool's transport `requires` flag |
78
78
  | **threat_** (2) | `threat_catalog`, `threat_classify` | Pure defensive threat-event classification engine — enumerate the catalog and classify an operation against it |
79
79
 
80
- Counts by module prefix sum to **56 channel tools**; the 4 `comms_*` tools and 2 `threat_*` tools make **62 callable** in total. `mCALL` (telephony), `mROOM`, `mURL` — and the `mp0st_send_as_agent` provenance + `mTALK_ingest_ptt` scaffolds (backend contract not yet wired) — exist in the source but are **not registered**, so agents only ever see tools that actually work.
80
+ Counts by module prefix sum to **56 channel tools**; the 3 `comms_*` tools and 2 `threat_*` tools make **61 callable** in total. `mCALL` (telephony), `mROOM`, `mURL` — and the `mp0st_send_as_agent` provenance, `mTALK_ingest_ptt` PTT-ingest, and `comms_embed_create` (embed-keys EF undeployed) scaffolds — exist in the source but are **not registered**, so agents only ever see tools that actually work.
81
81
 
82
82
  All tool names follow [RFC 0001](https://github.com/Hei33enberg/mosadd-os/blob/main/docs/rfcs/0001-module-naming.md) — `m<MODULE>_<operation>` snake_case.
83
83
 
package/dist/bin/mcp.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createMosaddServer
4
- } from "../chunk-TNWL6GPV.js";
4
+ } from "../chunk-KO7VS2KY.js";
5
5
  import {
6
6
  isSessionExpired,
7
7
  loadSession,
@@ -52,7 +52,25 @@ async function invokeFunction(fn, body) {
52
52
  const client = getSupabase();
53
53
  const { data, error } = await client.functions.invoke(fn, { body });
54
54
  if (error) {
55
- const msg = error instanceof Error ? error.message : typeof error?.message === "string" ? error.message : `Edge function ${fn} failed`;
55
+ let msg = error instanceof Error && error.message ? error.message : `Edge function ${fn} failed`;
56
+ const ctx = error.context;
57
+ if (ctx && typeof ctx.text === "function") {
58
+ const res = ctx;
59
+ try {
60
+ const raw = await res.text();
61
+ if (raw) {
62
+ let detail = raw;
63
+ try {
64
+ const parsed = JSON.parse(raw);
65
+ detail = typeof parsed.error === "string" && parsed.error || typeof parsed.message === "string" && parsed.message || raw;
66
+ } catch {
67
+ }
68
+ const status = typeof res.status === "number" ? res.status : void 0;
69
+ msg = status ? `${fn} (${status}): ${detail}` : `${fn}: ${detail}`;
70
+ }
71
+ } catch {
72
+ }
73
+ }
56
74
  throw new Error(msg);
57
75
  }
58
76
  if (data == null) {
@@ -535,14 +553,33 @@ async function mDM_respond_request(input, ctx) {
535
553
  }
536
554
  var mDM_publish_keys_input = z.object({});
537
555
  var mDM_edit_input = z.object({
556
+ to: ContactRef.describe(
557
+ "Recipient identity id of the conversation the message is in (needed to locate it and verify the edit won't break E2EE)."
558
+ ),
538
559
  message_id: z.string().min(1).describe("Id of the message to edit (from mDM_list)."),
539
- new_text: z.string().min(1).max(64e3).describe("Replacement message body (UTF-8). Max 64 KB.")
560
+ new_text: z.string().min(1).max(64e3).describe("Replacement message body (UTF-8). Max 64 KB."),
561
+ thread_label: ThreadSuffix.optional()
540
562
  });
541
563
  var mDM_delete_input = z.object({
542
564
  message_id: z.string().min(1).describe("Id of the message to delete (from mDM_list).")
543
565
  });
544
566
  async function mDM_edit(input, ctx) {
545
567
  readSupabaseEnv();
568
+ const dm = ctx.providers.dm;
569
+ const selfId = await dm.selfId();
570
+ const threadId = dmThreadId(selfId, input.to, input.thread_label);
571
+ const recent = await dm.list({ threadId, limit: 100 });
572
+ const target = recent.messages.find((m) => m.id === input.message_id);
573
+ if (!target) {
574
+ throw new Error(
575
+ `mDM_edit could not find message ${input.message_id} in the recent history of this thread. Pass the 'to' (and 'thread_label') of the conversation the message belongs to.`
576
+ );
577
+ }
578
+ if (isE2eeEnvelope(target.payload)) {
579
+ throw new Error(
580
+ "mDM_edit cannot edit an end-to-end-encrypted message: the Double Ratchet is forward-only, so the edit can't be re-sealed and storing a new body would strip E2EE. Delete it with mDM_delete and send a replacement with mDM_send instead."
581
+ );
582
+ }
546
583
  const envelope = {
547
584
  v: PROTOCOL_VERSION,
548
585
  type: "text",
@@ -551,7 +588,7 @@ async function mDM_edit(input, ctx) {
551
588
  sent_at: (/* @__PURE__ */ new Date()).toISOString()
552
589
  };
553
590
  const encrypted_payload = Buffer.from(JSON.stringify(envelope), "utf8").toString("base64");
554
- ctx.log("debug", "mDM_edit via message-edit", { message_id: input.message_id });
591
+ ctx.log("debug", "mDM_edit via message-edit (legacy plaintext only)", { message_id: input.message_id });
555
592
  await invokeFunction("message-edit", { message_id: input.message_id, encrypted_payload });
556
593
  return { message_id: input.message_id, edited: true };
557
594
  }
@@ -607,7 +644,7 @@ var mdmTools = [
607
644
  {
608
645
  name: "mDM_edit",
609
646
  requires: "any",
610
- 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.",
647
+ description: "Edit a direct message you sent \u2014 replace its body by message_id (pass the conversation's `to` so it can be located). NOTE: end-to-end-encrypted messages CANNOT be edited (the ratchet is forward-only) \u2014 mDM_edit refuses them and you should mDM_delete + mDM_send a replacement instead. Only legacy non-E2EE messages are editable.",
611
648
  inputSchema: mDM_edit_input,
612
649
  handler: mDM_edit
613
650
  },
@@ -656,13 +693,13 @@ async function signalDm(ctx, to, threadLabel, envelope) {
656
693
  const selfId = await dm.selfId();
657
694
  const threadId = dmThreadId2(selfId, to, threadLabel);
658
695
  const res = await dm.send({ to, threadId, payload: packEnvelope(envelope) });
659
- return { message_id: res?.message_id, thread_id: threadId };
696
+ return { message_id: res?.id, thread_id: threadId };
660
697
  }
661
698
  async function mDM_call_start(input, ctx) {
662
699
  const dm = ctx.providers.dm;
663
700
  const selfId = await dm.selfId();
664
701
  const mode = input.video ? "video" : "audio";
665
- const label = `dmcall-${dmThreadId2(selfId, input.to, input.thread_label).replace(/[^a-zA-Z0-9._-]/g, "-")}`.slice(0, 120);
702
+ const label = `dmcall-${dmThreadId2(selfId, input.to).replace(/[^a-zA-Z0-9._-]/g, "-")}`.slice(0, 120);
666
703
  const { roomId } = await ctx.providers.voice.createRoom(label);
667
704
  const ticket = await ctx.providers.voice.joinTicket(roomId);
668
705
  let invited = false;
@@ -757,12 +794,17 @@ var mIRC_create_input = z3.object({
757
794
  topic: z3.string().max(500).optional().describe("Optional channel topic/description."),
758
795
  access_mode: AccessMode.default("open"),
759
796
  password: z3.string().min(6).max(120).optional().describe("Password (only for access_mode=password)."),
760
- capabilities: Capabilities
797
+ capabilities: Capabilities,
798
+ wrapped_group_key: z3.string().optional().describe(
799
+ "Required for access_mode=password|private (these are E2EE channels): the channel's group key wrapped to the creator's identity key. Open channels ignore it. If omitted on a non-open channel the backend rejects the call with a 'wrapped_group_key required' error."
800
+ )
761
801
  });
762
802
  var mIRC_list_input = z3.object({
763
803
  limit: z3.number().int().min(1).max(500).default(100).optional(),
764
- offset: z3.number().int().min(0).default(0).optional(),
765
- access_mode: AccessMode.optional().describe("Filter to a single access mode.")
804
+ offset: z3.number().int().min(0).default(0).optional()
805
+ // NOTE: an access_mode filter was removed — channel-manage's list branch doesn't
806
+ // filter by it (it was a silent no-op). Filter client-side on the returned
807
+ // access_mode field. Server-side filtering is tracked in the consistency ticket.
766
808
  });
767
809
  var mIRC_get_input = z3.object({
768
810
  channel_id: ChannelId
@@ -771,7 +813,9 @@ var mIRC_update_input = z3.object({
771
813
  channel_id: ChannelId,
772
814
  name: z3.string().min(1).max(80).optional(),
773
815
  topic: z3.string().max(500).optional(),
774
- access_mode: AccessMode.optional(),
816
+ // NOTE: access_mode was removed — channel-manage's update branch ignores it, and
817
+ // switching an existing channel to/from an E2EE (password/private) mode needs
818
+ // group-key handling that isn't wired yet. Recreate the channel to change mode.
775
819
  capabilities: Capabilities
776
820
  });
777
821
  var mIRC_delete_input = z3.object({
@@ -780,9 +824,11 @@ var mIRC_delete_input = z3.object({
780
824
  async function mIRC_create(input, ctx) {
781
825
  readSupabaseEnv();
782
826
  ctx.log("debug", "mIRC_create invoking channel-manage", { name: input.name });
827
+ const { topic, ...rest } = input;
828
+ const payload = topic !== void 0 ? { ...rest, description: topic } : { ...rest };
783
829
  return await invokeFunction("channel-manage", {
784
830
  action: "create",
785
- ...input
831
+ ...payload
786
832
  });
787
833
  }
788
834
  async function mIRC_list(input, ctx) {
@@ -824,14 +870,14 @@ var mircTools = [
824
870
  {
825
871
  name: "mIRC_create",
826
872
  requires: "network",
827
- description: "Create a new persistent channel (Discord/Slack-style). Set access_mode to open (anyone joins), password (shared-password gated), or private (invite-only). capabilities controls modes (txt/ptt/live).",
873
+ description: "Create a new persistent channel (Discord/Slack-style). Set access_mode to open (anyone joins), password (shared-password gated), or private (invite-only). capabilities controls modes (txt/ptt/live). NOTE: password and private channels are end-to-end encrypted \u2014 you must supply wrapped_group_key (the group key wrapped to your identity key); open channels do not need it.",
828
874
  inputSchema: mIRC_create_input,
829
875
  handler: mIRC_create
830
876
  },
831
877
  {
832
878
  name: "mIRC_list",
833
879
  requires: "network",
834
- description: "List channels available to the current user. Optionally filter by access_mode.",
880
+ description: "List channels available to the current user.",
835
881
  inputSchema: mIRC_list_input,
836
882
  handler: mIRC_list
837
883
  },
@@ -845,7 +891,7 @@ var mircTools = [
845
891
  {
846
892
  name: "mIRC_update",
847
893
  requires: "network",
848
- description: "Update channel metadata (name, topic, access_mode, capabilities). Owner only.",
894
+ description: "Update channel metadata (name, topic, capabilities). Owner only. Access mode is fixed at creation \u2014 recreate the channel to change it.",
849
895
  inputSchema: mIRC_update_input,
850
896
  handler: mIRC_update
851
897
  },
@@ -868,31 +914,34 @@ var mIRC_join_input = z4.object({
868
914
  password: z4.string().min(1).optional().describe("Required if the channel is access_mode=private.")
869
915
  });
870
916
  var mIRC_request_access_input = z4.object({
871
- channel_id: ChannelId2,
872
- message: z4.string().max(500).optional().describe("Optional note for the channel owner explaining why.")
917
+ channel_id: ChannelId2
873
918
  });
874
919
  var mIRC_leave_input = z4.object({
875
920
  channel_id: ChannelId2
876
921
  });
877
- var mIRC_approve_request_input = z4.object({
922
+ var mIRC_reject_request_input = z4.object({
878
923
  channel_id: ChannelId2,
879
- // EF channel-members-manage reads `target_identity_id` (normalizer below maps
880
- // identity_id → target_identity_id). The old `request_id` field was ignored →
881
- // 400 "target_identity_id required" on every approve/reject.
882
- identity_id: z4.string().min(1).describe("Identity id of the requester to approve/reject (state=requested; from mIRC_list members). NOTE: approving an E2EE channel also needs a wrapped group key \u2014 LINEAR-3523.")
924
+ identity_id: z4.string().min(1).describe("Identity id of the requester to reject (state=requested; from mIRC_list members).")
925
+ });
926
+ var mIRC_approve_request_input = mIRC_reject_request_input.extend({
927
+ wrapped_group_key: z4.string().optional().describe(
928
+ "Required to approve a join to a password/private (E2EE) channel: the channel group key wrapped to the approved member's identity key. Without it the backend rejects the approval with a 'wrapped_group_key required' error. (Access requests only exist on non-open channels, so this is effectively always required.)"
929
+ )
883
930
  });
884
- var mIRC_reject_request_input = mIRC_approve_request_input;
885
931
  var mIRC_kick_input = z4.object({
886
932
  channel_id: ChannelId2,
887
- identity_id: MemberIdentity,
888
- reason: z4.string().max(500).optional()
933
+ identity_id: MemberIdentity
934
+ // NOTE: a `reason` field used to be advertised here but channel-members-manage
935
+ // never persists it (no audit row on kick) — removed until the backend logs it
936
+ // (see consistency ticket) so the tool doesn't claim an audit trail it can't deliver.
889
937
  });
890
938
  var mIRC_ban_input = z4.object({
891
939
  channel_id: ChannelId2,
892
- identity_id: MemberIdentity,
893
- reason: z4.string().max(500).optional(),
894
- /** Optional unban deadline (ISO-8601). Omit for permanent ban. */
895
- until: z4.string().optional()
940
+ identity_id: MemberIdentity
941
+ // NOTE: `reason` (no storage) and `until` (timed ban) were removed — the EF ban
942
+ // branch ignores both, so `until` produced a SILENT PERMANENT ban when a caller
943
+ // asked for a temporary one. Ban is permanent-until-unban; enforced temp-bans +
944
+ // ban audit are tracked in the consistency ticket.
896
945
  });
897
946
  var mIRC_unban_input = z4.object({
898
947
  channel_id: ChannelId2,
@@ -937,7 +986,7 @@ var mircMembersTools = [
937
986
  {
938
987
  name: "mIRC_request_access",
939
988
  requires: "network",
940
- description: "Request access to an invite_only channel. Owner / admins get a notification with the optional message.",
989
+ description: "Request access to a password/private channel (your membership goes to state=requested for an admin to approve).",
941
990
  inputSchema: mIRC_request_access_input,
942
991
  handler: ((input, ctx) => invokeChannelMembers("request-access", input, ctx))
943
992
  },
@@ -951,7 +1000,7 @@ var mircMembersTools = [
951
1000
  {
952
1001
  name: "mIRC_approve_request",
953
1002
  requires: "network",
954
- description: "Approve a pending access request. Admins / moderators / owner only.",
1003
+ description: "Approve a pending access request (state=requested \u2192 active). Admins / moderators / owner only. Because access requests only exist on E2EE (password/private) channels, you must pass wrapped_group_key \u2014 the channel group key wrapped to the approved member's identity key.",
955
1004
  inputSchema: mIRC_approve_request_input,
956
1005
  handler: ((input, ctx) => invokeChannelMembers("approve-request", input, ctx))
957
1006
  },
@@ -965,14 +1014,14 @@ var mircMembersTools = [
965
1014
  {
966
1015
  name: "mIRC_kick",
967
1016
  requires: "network",
968
- description: "Remove a member from the channel. They can rejoin if not banned. Requires moderator+. `reason` is logged to channel-event-log.",
1017
+ description: "Remove a member from the channel. They can rejoin if not banned. Requires moderator+.",
969
1018
  inputSchema: mIRC_kick_input,
970
1019
  handler: ((input, ctx) => invokeChannelMembers("kick", input, ctx))
971
1020
  },
972
1021
  {
973
1022
  name: "mIRC_ban",
974
1023
  requires: "network",
975
- description: "Ban a member from the channel. They cannot rejoin until unbanned. `until` (ISO-8601) for time-bound ban; omit for permanent. Requires admin+.",
1024
+ description: "Ban a member from the channel. The ban is permanent until you call mIRC_unban. Requires admin+.",
976
1025
  inputSchema: mIRC_ban_input,
977
1026
  handler: ((input, ctx) => invokeChannelMembers("ban", input, ctx))
978
1027
  },
@@ -1324,6 +1373,9 @@ async function mp0st_audit_export(input, ctx) {
1324
1373
  }
1325
1374
  async function mp0st_consent(input, ctx) {
1326
1375
  readSupabaseEnv();
1376
+ if ((input.action === "check" || input.action === "optin") && !input.recipient) {
1377
+ throw new Error(`mp0st_consent action '${input.action}' requires a 'recipient' email address.`);
1378
+ }
1327
1379
  ctx.log("debug", "mp0st_consent invoking mp0st-consent", { action: input.action });
1328
1380
  return await invokeFunction("mp0st-consent", { action: input.action, recipient: input.recipient ?? null });
1329
1381
  }
@@ -1912,70 +1964,16 @@ var actionTools = [
1912
1964
  }
1913
1965
  ];
1914
1966
 
1915
- // src/tools/embed.ts
1916
- import { z as z12 } from "zod";
1917
- var EMBED_CDN = (process.env.MOSADD_EMBED_CDN ?? "https://embed.mosadd.com").replace(/\/+$/, "");
1918
- var POSITIONS = ["inline", "sidebar-left", "sidebar-right", "floating-bl", "floating-br", "fullscreen"];
1919
- var SKINS = ["default", "retro-irc-1990", "terminal", "minimal-dark", "minimal-light"];
1920
- var embed_create_input = z12.object({
1921
- channel: z12.string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/).describe("The mIRC channel id everyone on the embed shares (e.g. 'acme-support'). Auto-created on first message if new."),
1922
- allowed_origins: z12.array(z12.string().min(1)).min(1).max(10).describe("REQUIRED. Domain(s) where the widget will be served \u2014 the key only works from these origins. Use the host(s) of the app you're building, e.g. ['app.acme.com','*.acme.com']. For local testing use mode:'test' and e.g. 'localhost:3000'."),
1923
- name: z12.string().max(64).optional().describe("Label for the key in the owner's dashboard. Default 'embed: <channel>'."),
1924
- position: z12.enum(POSITIONS).optional().describe("Where the widget renders. Default 'inline'."),
1925
- skin: z12.enum(SKINS).optional().describe("Visual skin. Default 'default' (mosadd-branded retro mIRC)."),
1926
- title: z12.string().max(60).optional().describe("Header title shown in the widget. Default 'mIRC'."),
1927
- anon: z12.boolean().optional().describe("Allow visitors to join with just a nick (no mosadd account). Default true."),
1928
- locale: z12.enum(["en", "pl"]).optional().describe("Widget UI language. Default 'en'."),
1929
- mode: z12.enum(["live", "test"]).optional().describe("Key mode \u2014 'test' for local/dev origins, 'live' for production. Default 'live'.")
1930
- });
1931
- var attrSafe = (s) => s.replace(/["'<>]/g, "");
1932
- function buildSnippet(input, key) {
1933
- const attrs = [`data-channel="${attrSafe(input.channel)}"`, `data-position="${input.position ?? "inline"}"`];
1934
- if (input.skin) attrs.push(`data-skin="${input.skin}"`);
1935
- if (input.title) attrs.push(`data-title="${attrSafe(input.title)}"`);
1936
- if (input.anon === false) attrs.push(`data-anon="false"`);
1937
- if (input.locale) attrs.push(`data-locale="${input.locale}"`);
1938
- return `<div id="mosadd-mirc" ${attrs.join(" ")}></div>
1939
- <script src="${EMBED_CDN}/v1.js" data-key="${key}"></script>`;
1940
- }
1941
- async function embed_create(input, ctx) {
1942
- readSupabaseEnv();
1943
- ctx.log("debug", "comms_embed_create minting embed key", { channel: input.channel, origins: input.allowed_origins.length });
1944
- const res = await invokeFunction("embed-keys", {
1945
- name: input.name ?? `embed: ${input.channel}`,
1946
- channels: [input.channel],
1947
- allowed_origins: input.allowed_origins,
1948
- mode: input.mode ?? "live"
1949
- });
1950
- if (res.error) throw new Error(res.error);
1951
- if (!res.key) throw new Error("embed-keys returned no publishable key (missing `key`).");
1952
- return {
1953
- embed_key: res.key,
1954
- channel: input.channel,
1955
- allowed_origins: input.allowed_origins,
1956
- snippet: buildSnippet(input, res.key)
1957
- };
1958
- }
1959
- var embedTools = [
1960
- {
1961
- name: "comms_embed_create",
1962
- requires: "network",
1963
- description: "Embed a LIVE mosadd chat channel into an app/site you're building (great for builder-agents on Lovable/Bolt/Cursor/v0). Mints a publishable embed key scoped to a channel + the app's domain(s) and returns a ready-to-paste HTML snippet (a <div> + <script src=embed.mosadd.com/v1.js data-key=\u2026>). Visitors of the host page chat in real time (anonymous nick or mosadd login). REQUIRES `allowed_origins` \u2014 the domain(s) the app is served from (the key only works there). The publishable key is browser-safe (mints only channel-scoped JWTs); your hub key never leaves the server. Returns { embed_key, channel, allowed_origins, snippet }.",
1964
- inputSchema: embed_create_input,
1965
- handler: embed_create
1966
- }
1967
- ];
1968
-
1969
1967
  // src/tools/threat.ts
1970
- import { z as z13 } from "zod";
1968
+ import { z as z12 } from "zod";
1971
1969
  import {
1972
1970
  THREAT_EVENTS,
1973
1971
  THREAT_EVENT_COUNT,
1974
1972
  evaluateEvent
1975
1973
  } from "@mosadd/threat-engine";
1976
- var threat_catalog_input = z13.object({
1977
- category: z13.enum(["COMINT", "ELINT", "MASINT", "CYBER", "BEHAVIORAL", "PRIVACY", "SIGINT", "OSINT", "MPOST"]).optional().describe("Filter the catalog to one intelligence-discipline category. Omit for the full catalog."),
1978
- platform: z13.enum(["apk", "ios", "pwa", "harmony"]).optional().describe("Filter to events detectable on this platform. Omit for all platforms.")
1974
+ var threat_catalog_input = z12.object({
1975
+ category: z12.enum(["COMINT", "ELINT", "MASINT", "CYBER", "BEHAVIORAL", "PRIVACY", "SIGINT", "OSINT", "MPOST"]).optional().describe("Filter the catalog to one intelligence-discipline category. Omit for the full catalog."),
1976
+ platform: z12.enum(["apk", "ios", "pwa", "harmony"]).optional().describe("Filter to events detectable on this platform. Omit for all platforms.")
1979
1977
  });
1980
1978
  async function threat_catalog(input, _ctx) {
1981
1979
  let events = THREAT_EVENTS;
@@ -1983,10 +1981,10 @@ async function threat_catalog(input, _ctx) {
1983
1981
  if (input.platform) events = events.filter((e) => e.platforms.includes(input.platform));
1984
1982
  return { count: events.length, total: THREAT_EVENT_COUNT, events };
1985
1983
  }
1986
- var threat_classify_input = z13.object({
1987
- event_type: z13.string().min(1).max(120).describe('Event type to classify, e.g. "SIM_SWAP", "AUTH_BRUTEFORCE", "TOLL_FRAUD". Case-insensitive.'),
1988
- severity: z13.string().optional().describe('Optional producer severity hint. "killswitch" \u2192 lock_account; "critical" \u2192 revoke_sessions; anything else is informational.'),
1989
- details: z13.string().max(2e3).optional().describe("Optional free-text context (informational only).")
1984
+ var threat_classify_input = z12.object({
1985
+ event_type: z12.string().min(1).max(120).describe('Event type to classify, e.g. "SIM_SWAP", "AUTH_BRUTEFORCE", "TOLL_FRAUD". Case-insensitive.'),
1986
+ severity: z12.string().optional().describe('Optional producer severity hint. "killswitch" \u2192 lock_account; "critical" \u2192 revoke_sessions; anything else is informational.'),
1987
+ details: z12.string().max(2e3).optional().describe("Optional free-text context (informational only).")
1990
1988
  });
1991
1989
  async function threat_classify(input, _ctx) {
1992
1990
  return evaluateEvent({ eventType: input.event_type, severity: input.severity, details: input.details });
@@ -2009,7 +2007,7 @@ var threatTools = [
2009
2007
  ];
2010
2008
 
2011
2009
  // src/tools/capabilities.ts
2012
- import { z as z14 } from "zod";
2010
+ import { z as z13 } from "zod";
2013
2011
  var CONTRACT_VERSION = "1.0.0";
2014
2012
  var ALL_REQUIREMENTS = ["any", "radio", "network"];
2015
2013
  function buildCapabilityManifest(tools) {
@@ -2032,7 +2030,7 @@ function makeCapabilitiesTool(channelTools2) {
2032
2030
  name: "comms_capabilities",
2033
2031
  requires: "any",
2034
2032
  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.",
2035
- inputSchema: z14.object({}),
2033
+ inputSchema: z13.object({}),
2036
2034
  handler: async () => buildCapabilityManifest([...channelTools2, tool])
2037
2035
  };
2038
2036
  return tool;
@@ -2060,8 +2058,7 @@ var channelTools = [
2060
2058
  ...knowledgeTools,
2061
2059
  ...actionTools,
2062
2060
  // Action links (Tier 1): agent → user one-link browser action via action-create EF
2063
- ...embedTools,
2064
- // comms_embed_create: agent embeds a live channel into the app it builds (embed-keys EF + embed.mosadd.com widget)
2061
+ // ...embedTools, // comms_embed_create: SCAFFOLD — embed-keys EF undeployed (404) + embed widget parked. Unregistered.
2065
2062
  ...threatTools
2066
2063
  // threat_catalog + threat_classify: pure defensive threat-event engine (@mosadd/threat-engine, LINEAR-3498)
2067
2064
  // ...murlTools, // mURL: brand/consumer surface (murl.mosadd.com), not a dev product
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  createMosaddServer,
4
4
  defaultProviders,
5
5
  runWithSupabaseEnv
6
- } from "./chunk-TNWL6GPV.js";
6
+ } from "./chunk-KO7VS2KY.js";
7
7
  import "./chunk-Z7WR52GE.js";
8
8
  export {
9
9
  allTools,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@mosadd/mcp",
3
- "version": "3.0.0-alpha.22",
3
+ "version": "3.0.0-alpha.23",
4
4
  "mcpName": "io.github.hei33enberg/mosadd-mcp",
5
- "description": "Model Context Protocol server for mosadd. Exposes the 5 live m* modules (mDM, mIRC, mTALK, mp0st, mRAG) plus comms + threat tools — 62 tools — to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
5
+ "description": "Model Context Protocol server for mosadd. Exposes the 5 live m* modules (mDM, mIRC, mTALK, mp0st, mRAG) plus comms + threat tools — 61 tools — to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
6
6
  "homepage": "https://github.com/Hei33enberg/mosADD-OS/tree/main/packages/mcp",
7
7
  "repository": {
8
8
  "type": "git",
@@ -105,12 +105,40 @@ export async function invokeFunction<T = unknown>(
105
105
  const client = getSupabase();
106
106
  const { data, error } = await client.functions.invoke<T>(fn, { body });
107
107
  if (error) {
108
- const msg =
109
- error instanceof Error
108
+ // supabase-js throws FunctionsHttpError for any non-2xx, whose `.message`
109
+ // is the FIXED generic string "Edge Function returned a non-2xx status
110
+ // code" — the *real* reason (e.g. {"error":"wrapped_group_key required"},
111
+ // "forbidden", an RLS denial) lives in `error.context`, a Response. Read it
112
+ // so the agent gets an actionable message (and the HTTP status) it can
113
+ // reason about and self-correct on, instead of the same opaque sentence
114
+ // for every failure across mDM/mIRC/mp0st/mRAG/prekey/message-list.
115
+ let msg =
116
+ error instanceof Error && error.message
110
117
  ? error.message
111
- : typeof (error as { message?: unknown })?.message === "string"
112
- ? (error as { message: string }).message
113
- : `Edge function ${fn} failed`;
118
+ : `Edge function ${fn} failed`;
119
+ const ctx = (error as { context?: unknown }).context;
120
+ if (ctx && typeof (ctx as Response).text === "function") {
121
+ const res = ctx as Response;
122
+ try {
123
+ const raw = await res.text();
124
+ if (raw) {
125
+ let detail = raw;
126
+ try {
127
+ const parsed = JSON.parse(raw) as { error?: unknown; message?: unknown };
128
+ detail =
129
+ (typeof parsed.error === "string" && parsed.error) ||
130
+ (typeof parsed.message === "string" && parsed.message) ||
131
+ raw;
132
+ } catch {
133
+ // non-JSON body — use the raw text as-is
134
+ }
135
+ const status = typeof res.status === "number" ? res.status : undefined;
136
+ msg = status ? `${fn} (${status}): ${detail}` : `${fn}: ${detail}`;
137
+ }
138
+ } catch {
139
+ // body already consumed or unreadable — keep the generic message
140
+ }
141
+ }
114
142
  throw new Error(msg);
115
143
  }
116
144
  if (data == null) {
@@ -31,7 +31,9 @@ import { attachmentTools } from "./attachments.js";
31
31
  // import { mcallTools } from "./mcall.js"; // mCALL: carrier-pending — not registered (see header note)
32
32
  import { knowledgeTools } from "./knowledge.js";
33
33
  import { actionTools } from "./actions.js";
34
- import { embedTools } from "./embed.js";
34
+ // import { embedTools } from "./embed.js"; // comms_embed_create: SCAFFOLD — its
35
+ // embed-keys EF is NOT deployed to prod (404s every call) and the embed.mosadd.com
36
+ // widget surface is parked. Unregister until both ship. See consistency ticket.
35
37
  import { threatTools } from "./threat.js";
36
38
  // import { murlTools } from "./murl.js"; // mURL: brand/consumer surface, not a dev product — not registered
37
39
  import { makeCapabilitiesTool } from "./capabilities.js";
@@ -57,7 +59,7 @@ const channelTools: MosaddTool[] = [
57
59
  // call) and the PTT→RAG path needs rework. Unregister until both are fixed. See consistency ticket.
58
60
  ...knowledgeTools,
59
61
  ...actionTools, // Action links (Tier 1): agent → user one-link browser action via action-create EF
60
- ...embedTools, // comms_embed_create: agent embeds a live channel into the app it builds (embed-keys EF + embed.mosadd.com widget)
62
+ // ...embedTools, // comms_embed_create: SCAFFOLD — embed-keys EF undeployed (404) + embed widget parked. Unregistered.
61
63
  ...threatTools, // threat_catalog + threat_classify: pure defensive threat-event engine (@mosadd/threat-engine, LINEAR-3498)
62
64
  // ...murlTools, // mURL: brand/consumer surface (murl.mosadd.com), not a dev product
63
65
  // ...mcallTools, // mCALL: carrier-pending (no telephony carrier live) — re-register when a carrier is configured
package/src/tools/mail.ts CHANGED
@@ -150,7 +150,7 @@ async function mp0st_view(
150
150
  subject: string;
151
151
  body_text: string | null;
152
152
  body_html: string | null;
153
- received_at: string;
153
+ sent_at: string;
154
154
  }> {
155
155
  readSupabaseEnv();
156
156
  // mp0st-get (NOT mp0st-view): mp0st-view is the open-tracking pixel endpoint
@@ -268,6 +268,9 @@ async function mp0st_consent(
268
268
  ctx: MosaddToolContext,
269
269
  ): Promise<Record<string, unknown>> {
270
270
  readSupabaseEnv();
271
+ if ((input.action === "check" || input.action === "optin") && !input.recipient) {
272
+ throw new Error(`mp0st_consent action '${input.action}' requires a 'recipient' email address.`);
273
+ }
271
274
  ctx.log("debug", "mp0st_consent invoking mp0st-consent", { action: input.action });
272
275
  return await invokeFunction("mp0st-consent", { action: input.action, recipient: input.recipient ?? null });
273
276
  }
@@ -80,8 +80,10 @@ async function signalDm(
80
80
  const dm = ctx.providers.dm;
81
81
  const selfId = await dm.selfId();
82
82
  const threadId = dmThreadId(selfId, to, threadLabel);
83
+ // DmProvider.send returns DmSendResult { id, deliveredAt } — read `id` (the old
84
+ // `message_id` lookup was always undefined, so the echoed id never populated).
83
85
  const res = await dm.send({ to, threadId, payload: packEnvelope(envelope) });
84
- return { message_id: (res as { message_id?: string })?.message_id, thread_id: threadId };
86
+ return { message_id: (res as { id?: string })?.id, thread_id: threadId };
85
87
  }
86
88
 
87
89
  // ---- Handlers ----
@@ -102,8 +104,12 @@ async function mDM_call_start(
102
104
  const selfId = await dm.selfId();
103
105
  const mode = input.video ? "video" : "audio";
104
106
 
105
- // Stable room label tied to the DM pair so re-dials reuse one room.
106
- const label = `dmcall-${dmThreadId(selfId, input.to, input.thread_label).replace(/[^a-zA-Z0-9._-]/g, "-")}`.slice(0, 120);
107
+ // Stable room label tied to the DM PAIR (no thread_label) so re-dials reuse one
108
+ // room AND the name stays short enough that both participants' full identity ids
109
+ // are always present — the livekit-token gate authorizes by full-id inclusion, so
110
+ // truncating an id would lock a real participant out. (thread_label still routes
111
+ // the call_invite message below, just not the room id.)
112
+ const label = `dmcall-${dmThreadId(selfId, input.to).replace(/[^a-zA-Z0-9._-]/g, "-")}`.slice(0, 120);
107
113
  const { roomId } = await ctx.providers.voice.createRoom(label);
108
114
  const ticket = await ctx.providers.voice.joinTicket(roomId);
109
115
 
package/src/tools/mdm.ts CHANGED
@@ -342,8 +342,12 @@ async function mDM_respond_request(
342
342
  const mDM_publish_keys_input = z.object({});
343
343
 
344
344
  const mDM_edit_input = z.object({
345
+ to: ContactRef.describe(
346
+ "Recipient identity id of the conversation the message is in (needed to locate it and verify the edit won't break E2EE).",
347
+ ),
345
348
  message_id: z.string().min(1).describe("Id of the message to edit (from mDM_list)."),
346
349
  new_text: z.string().min(1).max(64_000).describe("Replacement message body (UTF-8). Max 64 KB."),
350
+ thread_label: ThreadSuffix.optional(),
347
351
  });
348
352
 
349
353
  const mDM_delete_input = z.object({
@@ -355,9 +359,33 @@ async function mDM_edit(
355
359
  ctx: MosaddToolContext,
356
360
  ): Promise<{ message_id: string; edited: true }> {
357
361
  readSupabaseEnv();
358
- // Wire format = base64(JSON envelope), matching the EF (which atob()s it).
359
- // NOTE: stored server-readable (like mDM_send_unencrypted). On an E2EE thread
360
- // this does NOT re-seal the message — prefer delete + re-send for ciphertext.
362
+ const dm = ctx.providers.dm;
363
+ const selfId = await dm.selfId();
364
+ const threadId = dmThreadId(selfId, input.to, input.thread_label);
365
+
366
+ // Locate the target message before editing. mDM is E2EE by default and the
367
+ // Double Ratchet is FORWARD-ONLY (strict in-order, no skipped keys) — an edit
368
+ // cannot be re-sealed (the recipient's ratchet has already advanced past this
369
+ // message, so a re-encrypt would decrypt as <undecryptable>), and writing a
370
+ // fresh plaintext body would SILENTLY STRIP E2EE. So only legacy plaintext
371
+ // messages are editable; E2EE messages must be deleted + re-sent.
372
+ const recent = await dm.list({ threadId, limit: 100 });
373
+ const target = recent.messages.find((m) => m.id === input.message_id);
374
+ if (!target) {
375
+ throw new Error(
376
+ `mDM_edit could not find message ${input.message_id} in the recent history of this thread. ` +
377
+ `Pass the 'to' (and 'thread_label') of the conversation the message belongs to.`,
378
+ );
379
+ }
380
+ if (isE2eeEnvelope(target.payload)) {
381
+ throw new Error(
382
+ "mDM_edit cannot edit an end-to-end-encrypted message: the Double Ratchet is forward-only, so the edit " +
383
+ "can't be re-sealed and storing a new body would strip E2EE. Delete it with mDM_delete and send a " +
384
+ "replacement with mDM_send instead.",
385
+ );
386
+ }
387
+
388
+ // Legacy plaintext message — a plaintext edit matches its (non-E2EE) storage.
361
389
  const envelope = {
362
390
  v: PROTOCOL_VERSION,
363
391
  type: "text",
@@ -366,7 +394,7 @@ async function mDM_edit(
366
394
  sent_at: new Date().toISOString(),
367
395
  };
368
396
  const encrypted_payload = Buffer.from(JSON.stringify(envelope), "utf8").toString("base64");
369
- ctx.log("debug", "mDM_edit via message-edit", { message_id: input.message_id });
397
+ ctx.log("debug", "mDM_edit via message-edit (legacy plaintext only)", { message_id: input.message_id });
370
398
  await invokeFunction("message-edit", { message_id: input.message_id, encrypted_payload });
371
399
  return { message_id: input.message_id, edited: true };
372
400
  }
@@ -436,7 +464,7 @@ export const mdmTools: MosaddTool[] = [
436
464
  name: "mDM_edit",
437
465
  requires: "any",
438
466
  description:
439
- "Edit a direct message you sent — 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.",
467
+ "Edit a direct message you sent — replace its body by message_id (pass the conversation's `to` so it can be located). NOTE: end-to-end-encrypted messages CANNOT be edited (the ratchet is forward-only) — mDM_edit refuses them and you should mDM_delete + mDM_send a replacement instead. Only legacy non-E2EE messages are editable.",
440
468
  inputSchema: mDM_edit_input,
441
469
  handler: mDM_edit as MosaddTool["handler"],
442
470
  },
@@ -38,35 +38,44 @@ const mIRC_join_input = z.object({
38
38
 
39
39
  const mIRC_request_access_input = z.object({
40
40
  channel_id: ChannelId,
41
- message: z.string().max(500).optional().describe("Optional note for the channel owner explaining why."),
42
41
  });
43
42
 
44
43
  const mIRC_leave_input = z.object({
45
44
  channel_id: ChannelId,
46
45
  });
47
46
 
48
- const mIRC_approve_request_input = z.object({
47
+ // EF channel-members-manage reads `target_identity_id` (the normalizer below maps
48
+ // identity_id → target_identity_id). The old `request_id` field was ignored →
49
+ // 400 "target_identity_id required" on every approve/reject.
50
+ const mIRC_reject_request_input = z.object({
49
51
  channel_id: ChannelId,
50
- // EF channel-members-manage reads `target_identity_id` (normalizer below maps
51
- // identity_id → target_identity_id). The old `request_id` field was ignored →
52
- // 400 "target_identity_id required" on every approve/reject.
53
- identity_id: z.string().min(1).describe("Identity id of the requester to approve/reject (state=requested; from mIRC_list members). NOTE: approving an E2EE channel also needs a wrapped group key — LINEAR-3523."),
52
+ identity_id: z.string().min(1).describe("Identity id of the requester to reject (state=requested; from mIRC_list members)."),
54
53
  });
55
54
 
56
- const mIRC_reject_request_input = mIRC_approve_request_input;
55
+ const mIRC_approve_request_input = mIRC_reject_request_input.extend({
56
+ wrapped_group_key: z
57
+ .string()
58
+ .optional()
59
+ .describe(
60
+ "Required to approve a join to a password/private (E2EE) channel: the channel group key wrapped to the approved member's identity key. Without it the backend rejects the approval with a 'wrapped_group_key required' error. (Access requests only exist on non-open channels, so this is effectively always required.)",
61
+ ),
62
+ });
57
63
 
58
64
  const mIRC_kick_input = z.object({
59
65
  channel_id: ChannelId,
60
66
  identity_id: MemberIdentity,
61
- reason: z.string().max(500).optional(),
67
+ // NOTE: a `reason` field used to be advertised here but channel-members-manage
68
+ // never persists it (no audit row on kick) — removed until the backend logs it
69
+ // (see consistency ticket) so the tool doesn't claim an audit trail it can't deliver.
62
70
  });
63
71
 
64
72
  const mIRC_ban_input = z.object({
65
73
  channel_id: ChannelId,
66
74
  identity_id: MemberIdentity,
67
- reason: z.string().max(500).optional(),
68
- /** Optional unban deadline (ISO-8601). Omit for permanent ban. */
69
- until: z.string().optional(),
75
+ // NOTE: `reason` (no storage) and `until` (timed ban) were removed — the EF ban
76
+ // branch ignores both, so `until` produced a SILENT PERMANENT ban when a caller
77
+ // asked for a temporary one. Ban is permanent-until-unban; enforced temp-bans +
78
+ // ban audit are tracked in the consistency ticket.
70
79
  });
71
80
 
72
81
  const mIRC_unban_input = z.object({
@@ -121,7 +130,7 @@ export const mircMembersTools: MosaddTool[] = [
121
130
  name: "mIRC_request_access",
122
131
  requires: "network",
123
132
  description:
124
- "Request access to an invite_only channel. Owner / admins get a notification with the optional message.",
133
+ "Request access to a password/private channel (your membership goes to state=requested for an admin to approve).",
125
134
  inputSchema: mIRC_request_access_input,
126
135
  handler: ((input, ctx) => invokeChannelMembers("request-access", input as Record<string, unknown>, ctx)) as MosaddTool["handler"],
127
136
  },
@@ -135,7 +144,8 @@ export const mircMembersTools: MosaddTool[] = [
135
144
  {
136
145
  name: "mIRC_approve_request",
137
146
  requires: "network",
138
- description: "Approve a pending access request. Admins / moderators / owner only.",
147
+ description:
148
+ "Approve a pending access request (state=requested → active). Admins / moderators / owner only. Because access requests only exist on E2EE (password/private) channels, you must pass wrapped_group_key — the channel group key wrapped to the approved member's identity key.",
139
149
  inputSchema: mIRC_approve_request_input,
140
150
  handler: ((input, ctx) => invokeChannelMembers("approve-request", input as Record<string, unknown>, ctx)) as MosaddTool["handler"],
141
151
  },
@@ -150,7 +160,7 @@ export const mircMembersTools: MosaddTool[] = [
150
160
  name: "mIRC_kick",
151
161
  requires: "network",
152
162
  description:
153
- "Remove a member from the channel. They can rejoin if not banned. Requires moderator+. `reason` is logged to channel-event-log.",
163
+ "Remove a member from the channel. They can rejoin if not banned. Requires moderator+.",
154
164
  inputSchema: mIRC_kick_input,
155
165
  handler: ((input, ctx) => invokeChannelMembers("kick", input as Record<string, unknown>, ctx)) as MosaddTool["handler"],
156
166
  },
@@ -158,7 +168,7 @@ export const mircMembersTools: MosaddTool[] = [
158
168
  name: "mIRC_ban",
159
169
  requires: "network",
160
170
  description:
161
- "Ban a member from the channel. They cannot rejoin until unbanned. `until` (ISO-8601) for time-bound ban; omit for permanent. Requires admin+.",
171
+ "Ban a member from the channel. The ban is permanent until you call mIRC_unban. Requires admin+.",
162
172
  inputSchema: mIRC_ban_input,
163
173
  handler: ((input, ctx) => invokeChannelMembers("ban", input as Record<string, unknown>, ctx)) as MosaddTool["handler"],
164
174
  },
package/src/tools/mirc.ts CHANGED
@@ -42,12 +42,20 @@ const mIRC_create_input = z.object({
42
42
  access_mode: AccessMode.default("open"),
43
43
  password: z.string().min(6).max(120).optional().describe("Password (only for access_mode=password)."),
44
44
  capabilities: Capabilities,
45
+ wrapped_group_key: z
46
+ .string()
47
+ .optional()
48
+ .describe(
49
+ "Required for access_mode=password|private (these are E2EE channels): the channel's group key wrapped to the creator's identity key. Open channels ignore it. If omitted on a non-open channel the backend rejects the call with a 'wrapped_group_key required' error.",
50
+ ),
45
51
  });
46
52
 
47
53
  const mIRC_list_input = z.object({
48
54
  limit: z.number().int().min(1).max(500).default(100).optional(),
49
55
  offset: z.number().int().min(0).default(0).optional(),
50
- access_mode: AccessMode.optional().describe("Filter to a single access mode."),
56
+ // NOTE: an access_mode filter was removed — channel-manage's list branch doesn't
57
+ // filter by it (it was a silent no-op). Filter client-side on the returned
58
+ // access_mode field. Server-side filtering is tracked in the consistency ticket.
51
59
  });
52
60
 
53
61
  const mIRC_get_input = z.object({
@@ -58,7 +66,9 @@ const mIRC_update_input = z.object({
58
66
  channel_id: ChannelId,
59
67
  name: z.string().min(1).max(80).optional(),
60
68
  topic: z.string().max(500).optional(),
61
- access_mode: AccessMode.optional(),
69
+ // NOTE: access_mode was removed — channel-manage's update branch ignores it, and
70
+ // switching an existing channel to/from an E2EE (password/private) mode needs
71
+ // group-key handling that isn't wired yet. Recreate the channel to change mode.
62
72
  capabilities: Capabilities,
63
73
  });
64
74
 
@@ -74,9 +84,13 @@ async function mIRC_create(
74
84
  ): Promise<{ channel: unknown }> {
75
85
  readSupabaseEnv();
76
86
  ctx.log("debug", "mIRC_create invoking channel-manage", { name: input.name });
87
+ // channel-manage reads `description`, not `topic` — map it so the channel
88
+ // topic isn't silently dropped on create (the update handler does the same).
89
+ const { topic, ...rest } = input as typeof input & { topic?: string };
90
+ const payload = topic !== undefined ? { ...rest, description: topic } : { ...rest };
77
91
  return await invokeFunction<{ channel: unknown }>("channel-manage", {
78
92
  action: "create",
79
- ...input,
93
+ ...payload,
80
94
  });
81
95
  }
82
96
 
@@ -140,7 +154,7 @@ export const mircTools: MosaddTool[] = [
140
154
  name: "mIRC_create",
141
155
  requires: "network",
142
156
  description:
143
- "Create a new persistent channel (Discord/Slack-style). Set access_mode to open (anyone joins), password (shared-password gated), or private (invite-only). capabilities controls modes (txt/ptt/live).",
157
+ "Create a new persistent channel (Discord/Slack-style). Set access_mode to open (anyone joins), password (shared-password gated), or private (invite-only). capabilities controls modes (txt/ptt/live). NOTE: password and private channels are end-to-end encrypted — you must supply wrapped_group_key (the group key wrapped to your identity key); open channels do not need it.",
144
158
  inputSchema: mIRC_create_input,
145
159
  handler: mIRC_create as MosaddTool["handler"],
146
160
  },
@@ -148,7 +162,7 @@ export const mircTools: MosaddTool[] = [
148
162
  name: "mIRC_list",
149
163
  requires: "network",
150
164
  description:
151
- "List channels available to the current user. Optionally filter by access_mode.",
165
+ "List channels available to the current user.",
152
166
  inputSchema: mIRC_list_input,
153
167
  handler: mIRC_list as MosaddTool["handler"],
154
168
  },
@@ -162,7 +176,7 @@ export const mircTools: MosaddTool[] = [
162
176
  {
163
177
  name: "mIRC_update",
164
178
  requires: "network",
165
- description: "Update channel metadata (name, topic, access_mode, capabilities). Owner only.",
179
+ description: "Update channel metadata (name, topic, capabilities). Owner only. Access mode is fixed at creation — recreate the channel to change it.",
166
180
  inputSchema: mIRC_update_input,
167
181
  handler: mIRC_update as MosaddTool["handler"],
168
182
  },