@mosadd/mcp 3.0.0-alpha.15 → 3.0.0-alpha.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/mcp.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createMosaddServer
4
- } from "../chunk-ZT7IBWW7.js";
4
+ } from "../chunk-KZ3HIZ74.js";
5
5
  import "../chunk-Z7WR52GE.js";
6
6
 
7
7
  // src/bin/mcp.ts
@@ -1437,8 +1437,8 @@ async function mAIL_send(input, ctx) {
1437
1437
  }
1438
1438
  async function mAIL_view(input, ctx) {
1439
1439
  readSupabaseEnv();
1440
- ctx.log("debug", "mAIL_view invoking mp0st-view", { message_id: input.message_id });
1441
- return await invokeFunction("mp0st-view", { message_id: input.message_id });
1440
+ ctx.log("debug", "mAIL_view invoking mp0st-get", { message_id: input.message_id });
1441
+ return await invokeFunction("mp0st-get", { message_id: input.message_id });
1442
1442
  }
1443
1443
  async function mAIL_list(input, ctx) {
1444
1444
  readSupabaseEnv();
@@ -1576,17 +1576,97 @@ var mailTools = [
1576
1576
  }
1577
1577
  ];
1578
1578
 
1579
- // src/tools/mtalk.ts
1579
+ // src/tools/mail-provenance.ts
1580
1580
  import { z as z10 } from "zod";
1581
- 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.");
1582
- var RoomId4 = z10.string().min(1).describe("Room id returned by mTALK_open.");
1583
- var mTALK_open_input = z10.object({
1581
+ var DEFAULT_SUPABASE_URL2 = "https://rooffhgbxafyjcwmwpsy.supabase.co";
1582
+ function supabaseUrl2() {
1583
+ return process.env.MOSADD_SUPABASE_URL?.replace(/\/$/, "") ?? process.env.SUPABASE_URL?.replace(/\/$/, "") ?? DEFAULT_SUPABASE_URL2;
1584
+ }
1585
+ function hubKey2() {
1586
+ return process.env.MOSADD_API_KEY ?? process.env.MOSADD_HUB_KEY ?? null;
1587
+ }
1588
+ var EmailAddress2 = z10.string().email().max(254);
1589
+ var mAIL_send_as_agent_input = z10.object({
1590
+ to: z10.union([EmailAddress2, z10.array(EmailAddress2).min(1).max(50)]),
1591
+ subject: z10.string().min(1).max(998),
1592
+ body_text: z10.string().max(1048576).optional(),
1593
+ body_html: z10.string().max(1048576).optional(),
1594
+ cc: z10.array(EmailAddress2).max(50).optional(),
1595
+ bcc: z10.array(EmailAddress2).max(50).optional(),
1596
+ reply_to: EmailAddress2.optional(),
1597
+ tracking: z10.boolean().optional(),
1598
+ agent_id: z10.string().min(1).max(120).describe("Stable id of the agent doing the send. Stamped as sent_by_agent_id for provenance."),
1599
+ task_id: z10.string().min(1).max(120).optional().describe("Optional id of the task/run this send belongs to. Stamped as sent_by_task_id.")
1600
+ });
1601
+ async function mintHubClaim(agentId, taskId) {
1602
+ const key = hubKey2();
1603
+ if (!key) {
1604
+ throw new Error("mAIL_send_as_agent needs MOSADD_API_KEY (hub key) to mint a provenance claim.");
1605
+ }
1606
+ const r = await fetch(`${supabaseUrl2()}/functions/v1/hub-claim-mint`, {
1607
+ method: "POST",
1608
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
1609
+ body: JSON.stringify({ scope: "mail:send", agent_id: agentId, task_id: taskId ?? null })
1610
+ });
1611
+ if (!r.ok) {
1612
+ const b = await r.text().catch(() => "");
1613
+ throw new Error(`hub-claim-mint ${r.status}: ${b.slice(0, 200)}`);
1614
+ }
1615
+ const data = await r.json();
1616
+ if (!data?.token) throw new Error("hub-claim-mint: no token in response");
1617
+ return data.token;
1618
+ }
1619
+ async function mAIL_send_as_agent(input, ctx) {
1620
+ if (!input.body_text && !input.body_html) {
1621
+ throw new Error("mAIL_send_as_agent requires at least one of body_text or body_html.");
1622
+ }
1623
+ const claim = await mintHubClaim(input.agent_id, input.task_id);
1624
+ ctx.log("debug", "mAIL_send_as_agent invoking mp0st-send with hub-claim", { agent_id: input.agent_id });
1625
+ const { agent_id, task_id, ...mailFields } = input;
1626
+ const r = await fetch(`${supabaseUrl2()}/functions/v1/mp0st-send`, {
1627
+ method: "POST",
1628
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${claim}` },
1629
+ body: JSON.stringify({
1630
+ ...mailFields,
1631
+ sent_by: "agent",
1632
+ sent_by_agent_id: agent_id,
1633
+ sent_by_task_id: task_id ?? null
1634
+ })
1635
+ });
1636
+ if (!r.ok) {
1637
+ const b = await r.text().catch(() => "");
1638
+ throw new Error(`mp0st-send ${r.status}: ${b.slice(0, 200)}`);
1639
+ }
1640
+ const res = await r.json();
1641
+ if (res.error) throw new Error(res.error);
1642
+ return {
1643
+ message_id: res.email_id ?? "",
1644
+ status: res.status ?? "sent",
1645
+ is_internal: res.is_internal ?? false,
1646
+ sent_by: "agent"
1647
+ };
1648
+ }
1649
+ var mailProvenanceTools = [
1650
+ {
1651
+ name: "mAIL_send_as_agent",
1652
+ requires: "network",
1653
+ description: "Send an email ATTRIBUTED TO THE AGENT (provenance-stamped). Unlike mAIL_send (sends as the user), this stamps sent_by='agent' plus your agent_id and optional task_id onto the email record and audit trail \u2014 so recipients and compliance can see the mail was agent-originated. Auth: presents a hub-claim JWT (needs MOSADD_API_KEY). SCAFFOLD: depends on mp0st-send honoring the hub-claim + provenance fields (TODO Lane A).",
1654
+ inputSchema: mAIL_send_as_agent_input,
1655
+ handler: mAIL_send_as_agent
1656
+ }
1657
+ ];
1658
+
1659
+ // src/tools/mtalk.ts
1660
+ import { z as z11 } from "zod";
1661
+ var RoomLabel = z11.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.");
1662
+ var RoomId4 = z11.string().min(1).describe("Room id returned by mTALK_open.");
1663
+ var mTALK_open_input = z11.object({
1584
1664
  label: RoomLabel.optional().describe("Optional label; defaults to a personal room.")
1585
1665
  });
1586
- var mTALK_join_input = z10.object({ room_id: RoomId4 });
1587
- var mTALK_press_input = z10.object({ room_id: RoomId4 });
1588
- var mTALK_release_input = z10.object({ room_id: RoomId4 });
1589
- var mTALK_state_input = z10.object({ room_id: RoomId4 });
1666
+ var mTALK_join_input = z11.object({ room_id: RoomId4 });
1667
+ var mTALK_press_input = z11.object({ room_id: RoomId4 });
1668
+ var mTALK_release_input = z11.object({ room_id: RoomId4 });
1669
+ var mTALK_state_input = z11.object({ room_id: RoomId4 });
1590
1670
  async function mTALK_open(input, ctx) {
1591
1671
  const { roomId } = await ctx.providers.voice.createRoom(input.label);
1592
1672
  ctx.log("debug", "mTALK_open", { room_id: roomId });
@@ -1649,13 +1729,334 @@ var mtalkTools = [
1649
1729
  }
1650
1730
  ];
1651
1731
 
1732
+ // src/tools/attachments.ts
1733
+ import { z as z12 } from "zod";
1734
+
1735
+ // src/providers/blob-upload.ts
1736
+ function defaultBucket(kind) {
1737
+ return kind === "file" ? "file-blobs" : "voice-blobs";
1738
+ }
1739
+ function randomId2() {
1740
+ return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`;
1741
+ }
1742
+ async function uploadBlob(args) {
1743
+ readSupabaseEnv();
1744
+ const sb = getSupabase();
1745
+ const bucket = args.bucket ?? defaultBucket(args.kind);
1746
+ const ext = args.filename?.split(".").pop() ?? mimeExt(args.mime);
1747
+ const path = `${args.prefix ? args.prefix.replace(/[^a-zA-Z0-9._/-]/g, "-") + "/" : ""}${randomId2()}${ext ? "." + ext : ""}`;
1748
+ const { error } = await sb.storage.from(bucket).upload(path, args.bytes, {
1749
+ contentType: args.mime,
1750
+ upsert: false
1751
+ });
1752
+ if (error) {
1753
+ throw new Error(`blob upload to ${bucket}/${path} failed: ${error.message}`);
1754
+ }
1755
+ return {
1756
+ kind: args.kind,
1757
+ bucket,
1758
+ path,
1759
+ mime: args.mime,
1760
+ duration_ms: args.duration_ms ?? null,
1761
+ key_ref: args.key_ref ?? null,
1762
+ filename: args.filename ?? null,
1763
+ size_bytes: args.bytes.byteLength
1764
+ };
1765
+ }
1766
+ function mimeExt(mime) {
1767
+ const map = {
1768
+ "audio/ogg": "ogg",
1769
+ "audio/mpeg": "mp3",
1770
+ "audio/mp4": "m4a",
1771
+ "audio/wav": "wav",
1772
+ "audio/webm": "webm"
1773
+ };
1774
+ return map[mime] ?? "";
1775
+ }
1776
+ function decodeBase64Body(b64) {
1777
+ const cleaned = b64.includes(",") && b64.startsWith("data:") ? b64.slice(b64.indexOf(",") + 1) : b64;
1778
+ return new Uint8Array(Buffer.from(cleaned, "base64"));
1779
+ }
1780
+
1781
+ // src/tools/attachments.ts
1782
+ var PROTOCOL_VERSION5 = "mosadd.chat.v1";
1783
+ var Base64Body = z12.string().min(1).max(2e7).describe("Attachment bytes as base64 (or a data: URL). MCP is JSON-only, so binary is base64-encoded. Max ~15 MB decoded.");
1784
+ var Mime = z12.string().min(1).max(120).describe("MIME type, e.g. audio/ogg, application/pdf, image/png.");
1785
+ var DurationMs = z12.number().int().positive().optional().describe("Audio clip length in ms (voice only), if known.");
1786
+ var Filename = z12.string().min(1).max(255).optional().describe("Original filename (file only).");
1787
+ var ReplyTo = z12.string().optional().describe("Optional id of the message being replied to.");
1788
+ var ContactRef3 = z12.string().min(1).describe("Recipient identity id (UUID). Use mDM_list_contacts to find it.");
1789
+ var RoomId5 = z12.string().min(1).describe("Room/channel id (UUID).");
1790
+ var ThreadLabel = z12.string().max(120).regex(/^[a-zA-Z0-9._-]+$/).optional().describe("Optional thread label within the conversation (mDM USP: multiple threads per contact).");
1791
+ function dmThreadId3(selfId, otherId, label) {
1792
+ const [a, b] = [selfId, otherId].sort();
1793
+ return label ? `dm:${a}:${b}:${label}` : `dm:${a}:${b}`;
1794
+ }
1795
+ async function sendAttachmentMessage(ctx, args) {
1796
+ readSupabaseEnv();
1797
+ const captionEnvelope = {
1798
+ v: PROTOCOL_VERSION5,
1799
+ type: args.message_type,
1800
+ text: args.caption ?? "",
1801
+ sent_at: (/* @__PURE__ */ new Date()).toISOString()
1802
+ };
1803
+ const encrypted_payload = Buffer.from(JSON.stringify(captionEnvelope), "utf8").toString("base64");
1804
+ ctx.log("debug", "sendAttachmentMessage", {
1805
+ thread_id: args.thread_id,
1806
+ message_type: args.message_type,
1807
+ bucket: args.attachment.bucket
1808
+ });
1809
+ const data = await invokeFunction("message-send", {
1810
+ space_id: args.space_id,
1811
+ thread_id: args.thread_id,
1812
+ message_type: args.message_type,
1813
+ attachments: [args.attachment],
1814
+ // TODO(Lane A): confirm field placement
1815
+ encrypted_payload,
1816
+ protocol_version: PROTOCOL_VERSION5,
1817
+ recipient_account_id: args.recipient_account_id ?? null,
1818
+ reply_to_id: args.reply_to_id ?? null
1819
+ });
1820
+ if (!data?.message?.id) throw new Error("message-send returned no message id (attachment)");
1821
+ return {
1822
+ message_id: data.message.id,
1823
+ delivered_at: data.message.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
1824
+ thread_id: args.thread_id
1825
+ };
1826
+ }
1827
+ async function resolveLinkedSpaceId2(channelId) {
1828
+ const data = await invokeFunction("channel-manage", { action: "get", channel_id: channelId });
1829
+ const spaceId = data?.linked_space_id ?? data?.channel?.metadata?.linked_space_id;
1830
+ if (!spaceId) throw new Error(`Channel ${channelId} has no linked space yet \u2014 run mIRC_join/mIRC_list first or pass space_id.`);
1831
+ return spaceId;
1832
+ }
1833
+ var mDM_send_voice_input = z12.object({
1834
+ to: ContactRef3,
1835
+ audio_base64: Base64Body,
1836
+ mime: Mime.default("audio/ogg"),
1837
+ duration_ms: DurationMs,
1838
+ caption: z12.string().max(2e3).optional(),
1839
+ thread_label: ThreadLabel,
1840
+ reply_to_id: ReplyTo
1841
+ });
1842
+ var mDM_send_file_input = z12.object({
1843
+ to: ContactRef3,
1844
+ file_base64: Base64Body,
1845
+ filename: Filename,
1846
+ mime: Mime,
1847
+ caption: z12.string().max(2e3).optional(),
1848
+ thread_label: ThreadLabel,
1849
+ reply_to_id: ReplyTo
1850
+ });
1851
+ async function mDM_send_voice(input, ctx) {
1852
+ const dm = ctx.providers.dm;
1853
+ const selfId = await dm.selfId();
1854
+ const thread_id = dmThreadId3(selfId, input.to, input.thread_label);
1855
+ const attachment = await uploadBlob({
1856
+ kind: "voice",
1857
+ bytes: decodeBase64Body(input.audio_base64),
1858
+ mime: input.mime,
1859
+ prefix: thread_id,
1860
+ duration_ms: input.duration_ms
1861
+ });
1862
+ return sendAttachmentMessage(ctx, {
1863
+ space_id: "dm",
1864
+ thread_id,
1865
+ message_type: "voice",
1866
+ attachment,
1867
+ caption: input.caption,
1868
+ reply_to_id: input.reply_to_id,
1869
+ recipient_account_id: input.to
1870
+ });
1871
+ }
1872
+ async function mDM_send_file(input, ctx) {
1873
+ const dm = ctx.providers.dm;
1874
+ const selfId = await dm.selfId();
1875
+ const thread_id = dmThreadId3(selfId, input.to, input.thread_label);
1876
+ const attachment = await uploadBlob({
1877
+ kind: "file",
1878
+ bytes: decodeBase64Body(input.file_base64),
1879
+ mime: input.mime,
1880
+ prefix: thread_id,
1881
+ filename: input.filename
1882
+ });
1883
+ return sendAttachmentMessage(ctx, {
1884
+ space_id: "dm",
1885
+ thread_id,
1886
+ message_type: "file",
1887
+ attachment,
1888
+ caption: input.caption,
1889
+ reply_to_id: input.reply_to_id,
1890
+ recipient_account_id: input.to
1891
+ });
1892
+ }
1893
+ var mROOM_send_voice_input = z12.object({
1894
+ room_id: RoomId5,
1895
+ audio_base64: Base64Body,
1896
+ mime: Mime.default("audio/ogg"),
1897
+ duration_ms: DurationMs,
1898
+ caption: z12.string().max(2e3).optional(),
1899
+ reply_to_id: ReplyTo
1900
+ });
1901
+ var mROOM_send_file_input = z12.object({
1902
+ room_id: RoomId5,
1903
+ file_base64: Base64Body,
1904
+ filename: Filename,
1905
+ mime: Mime,
1906
+ caption: z12.string().max(2e3).optional(),
1907
+ reply_to_id: ReplyTo
1908
+ });
1909
+ async function mROOM_send_voice(input, ctx) {
1910
+ const thread_id = `privroom:${input.room_id}`;
1911
+ const attachment = await uploadBlob({
1912
+ kind: "voice",
1913
+ bytes: decodeBase64Body(input.audio_base64),
1914
+ mime: input.mime,
1915
+ prefix: thread_id,
1916
+ duration_ms: input.duration_ms
1917
+ });
1918
+ return sendAttachmentMessage(ctx, { space_id: "rooms", thread_id, message_type: "voice", attachment, caption: input.caption, reply_to_id: input.reply_to_id });
1919
+ }
1920
+ async function mROOM_send_file(input, ctx) {
1921
+ const thread_id = `privroom:${input.room_id}`;
1922
+ const attachment = await uploadBlob({
1923
+ kind: "file",
1924
+ bytes: decodeBase64Body(input.file_base64),
1925
+ mime: input.mime,
1926
+ prefix: thread_id,
1927
+ filename: input.filename
1928
+ });
1929
+ return sendAttachmentMessage(ctx, { space_id: "rooms", thread_id, message_type: "file", attachment, caption: input.caption, reply_to_id: input.reply_to_id });
1930
+ }
1931
+ var mIRC_send_voice_input = z12.object({
1932
+ channel_id: RoomId5,
1933
+ audio_base64: Base64Body,
1934
+ mime: Mime.default("audio/ogg"),
1935
+ duration_ms: DurationMs,
1936
+ caption: z12.string().max(2e3).optional(),
1937
+ reply_to_id: ReplyTo,
1938
+ space_id: z12.string().optional().describe("Backing space id. Resolved automatically if omitted.")
1939
+ });
1940
+ var mIRC_send_file_input = z12.object({
1941
+ channel_id: RoomId5,
1942
+ file_base64: Base64Body,
1943
+ filename: Filename,
1944
+ mime: Mime,
1945
+ caption: z12.string().max(2e3).optional(),
1946
+ reply_to_id: ReplyTo,
1947
+ space_id: z12.string().optional()
1948
+ });
1949
+ async function mIRC_send_voice(input, ctx) {
1950
+ const space_id = input.space_id ?? await resolveLinkedSpaceId2(input.channel_id);
1951
+ const thread_id = `chat:${input.channel_id}`;
1952
+ const attachment = await uploadBlob({ kind: "voice", bytes: decodeBase64Body(input.audio_base64), mime: input.mime, prefix: thread_id, duration_ms: input.duration_ms });
1953
+ return sendAttachmentMessage(ctx, { space_id, thread_id, message_type: "voice", attachment, caption: input.caption, reply_to_id: input.reply_to_id });
1954
+ }
1955
+ async function mIRC_send_file(input, ctx) {
1956
+ const space_id = input.space_id ?? await resolveLinkedSpaceId2(input.channel_id);
1957
+ const thread_id = `chat:${input.channel_id}`;
1958
+ const attachment = await uploadBlob({ kind: "file", bytes: decodeBase64Body(input.file_base64), mime: input.mime, prefix: thread_id, filename: input.filename });
1959
+ return sendAttachmentMessage(ctx, { space_id, thread_id, message_type: "file", attachment, caption: input.caption, reply_to_id: input.reply_to_id });
1960
+ }
1961
+ var attachmentTools = [
1962
+ {
1963
+ name: "mDM_send_voice",
1964
+ requires: "network",
1965
+ description: "Send a VOICE note to a contact as a first-class mDM `voice` message (not a URL stub). Pass audio bytes as base64; the tool uploads to Storage and posts via message-send with the voice attachment descriptor. SCAFFOLD: mDM is client-encrypted \u2014 until the seal step ships, bytes are uploaded unsealed (TODO Lane A).",
1966
+ inputSchema: mDM_send_voice_input,
1967
+ handler: mDM_send_voice
1968
+ },
1969
+ {
1970
+ name: "mDM_send_file",
1971
+ requires: "network",
1972
+ description: "Send a FILE to a contact as a first-class mDM `file` message. Base64 bytes \u2192 Storage \u2192 message-send file attachment. SCAFFOLD: mDM E2EE seal is TODO (Lane A).",
1973
+ inputSchema: mDM_send_file_input,
1974
+ handler: mDM_send_file
1975
+ },
1976
+ {
1977
+ name: "mROOM_send_voice",
1978
+ requires: "network",
1979
+ description: "Send a VOICE note into a room as a first-class `voice` message. Base64 audio \u2192 Storage \u2192 message-send. Be a room member first (mROOM_join).",
1980
+ inputSchema: mROOM_send_voice_input,
1981
+ handler: mROOM_send_voice
1982
+ },
1983
+ {
1984
+ name: "mROOM_send_file",
1985
+ requires: "network",
1986
+ description: "Send a FILE into a room as a first-class `file` message. Base64 bytes \u2192 Storage \u2192 message-send.",
1987
+ inputSchema: mROOM_send_file_input,
1988
+ handler: mROOM_send_file
1989
+ },
1990
+ {
1991
+ name: "mIRC_send_voice",
1992
+ requires: "network",
1993
+ description: "Send a VOICE note into a persistent channel as a first-class `voice` message. Base64 audio \u2192 Storage \u2192 message-send (backing space resolved automatically).",
1994
+ inputSchema: mIRC_send_voice_input,
1995
+ handler: mIRC_send_voice
1996
+ },
1997
+ {
1998
+ name: "mIRC_send_file",
1999
+ requires: "network",
2000
+ description: "Send a FILE into a persistent channel as a first-class `file` message. Base64 bytes \u2192 Storage \u2192 message-send.",
2001
+ inputSchema: mIRC_send_file_input,
2002
+ handler: mIRC_send_file
2003
+ }
2004
+ ];
2005
+
2006
+ // src/tools/ptt-ingest.ts
2007
+ import { z as z13 } from "zod";
2008
+ var mTALK_ingest_ptt_input = z13.object({
2009
+ audio_base64: z13.string().min(1).max(2e7).describe("Recorded PTT 'over' as base64 (or data: URL)."),
2010
+ mime: z13.string().min(1).max(120).default("audio/ogg"),
2011
+ duration_ms: z13.number().int().positive().optional(),
2012
+ // Routing: exactly one of room_id / channel_id identifies where the over lands.
2013
+ channel_id: z13.string().optional().describe("mIRC channel id \u2014 route the queued PTT into a persistent channel's PTT log."),
2014
+ room_id: z13.string().optional().describe("mROOM/mTALK room id \u2014 route into an ephemeral room's PTT log."),
2015
+ transcribe: z13.boolean().optional().describe("Request RAG transcription. Honored only if the user has opted in to rag ingest; ignored otherwise. Default true.")
2016
+ });
2017
+ async function mTALK_ingest_ptt(input, ctx) {
2018
+ readSupabaseEnv();
2019
+ if (!input.channel_id && !input.room_id) {
2020
+ throw new Error("mTALK_ingest_ptt requires one of channel_id or room_id to route the queued PTT.");
2021
+ }
2022
+ const prefix = input.channel_id ? `chat:${input.channel_id}` : `room:${input.room_id}`;
2023
+ const attachment = await uploadBlob({
2024
+ kind: "ptt",
2025
+ bytes: decodeBase64Body(input.audio_base64),
2026
+ mime: input.mime,
2027
+ prefix,
2028
+ duration_ms: input.duration_ms
2029
+ });
2030
+ ctx.log("debug", "mTALK_ingest_ptt invoking ptt-ingest", { prefix, transcribe: input.transcribe ?? true });
2031
+ const res = await invokeFunction("ptt-ingest", {
2032
+ attachment,
2033
+ channel_id: input.channel_id ?? null,
2034
+ room_id: input.room_id ?? null,
2035
+ transcribe: input.transcribe ?? true
2036
+ });
2037
+ return {
2038
+ ptt_id: res.ptt_id ?? "",
2039
+ queued: true,
2040
+ transcription: res.transcription ?? "queued"
2041
+ };
2042
+ }
2043
+ var pttIngestTools = [
2044
+ {
2045
+ name: "mTALK_ingest_ptt",
2046
+ requires: "network",
2047
+ description: "Capture a finished PTT transmission (an 'over') as a durable, QUEUED PTT message in a channel (mIRC) or room (mROOM), and \u2014 if the user has opted in to RAG \u2014 transcribe it into searchable knowledge. Pass the clip as base64 + a route (channel_id OR room_id). Complements mTALK_press/release (which only manage the live floor). SCAFFOLD: depends on the not-yet-deployed `ptt-ingest` Edge Function.",
2048
+ inputSchema: mTALK_ingest_ptt_input,
2049
+ handler: mTALK_ingest_ptt
2050
+ }
2051
+ ];
2052
+
1652
2053
  // src/tools/knowledge.ts
1653
- import { z as z11 } from "zod";
1654
- var mRAG_search_input = z11.object({
1655
- query: z11.string().min(1).max(2e3).describe("Natural-language question to answer from the user's own indexed messages/emails/calls/notes."),
1656
- 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."),
1657
- source_types: z11.array(z11.enum(["message", "email", "call", "note", "contact"])).optional().describe("Restrict retrieval to these source types. Omit to search everything."),
1658
- thread_id: z11.string().optional().describe("Optional: restrict retrieval to a single thread id (e.g. a dm:/chat: thread).")
2054
+ import { z as z14 } from "zod";
2055
+ var mRAG_search_input = z14.object({
2056
+ query: z14.string().min(1).max(2e3).describe("Natural-language question to answer from the user's own indexed messages/emails/calls/notes."),
2057
+ top_k: z14.number().int().min(1).max(25).optional().describe("Max number of source chunks to retrieve and ground the answer in. Default 8."),
2058
+ source_types: z14.array(z14.enum(["message", "email", "call", "note", "contact"])).optional().describe("Restrict retrieval to these source types. Omit to search everything."),
2059
+ thread_id: z14.string().optional().describe("Optional: restrict retrieval to a single thread id (e.g. a dm:/chat: thread).")
1659
2060
  });
1660
2061
  async function mRAG_search(input, ctx) {
1661
2062
  readSupabaseEnv();
@@ -1672,12 +2073,12 @@ async function mRAG_search(input, ctx) {
1672
2073
  chunks_found: data.chunks_found ?? (data.sources?.length ?? 0)
1673
2074
  };
1674
2075
  }
1675
- var mRAG_ingest_input = z11.object({
1676
- 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."),
1677
- 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."),
1678
- source_id: z11.string().optional().describe("Optional stable id for the source so re-ingests can be grouped."),
1679
- thread_id: z11.string().optional().describe("Optional thread id to associate this knowledge with (e.g. a dm:/chat: thread)."),
1680
- title: z11.string().max(300).optional().describe("Optional human title, stored in metadata.")
2076
+ var mRAG_ingest_input = z14.object({
2077
+ content_text: z14.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."),
2078
+ source_type: z14.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."),
2079
+ source_id: z14.string().optional().describe("Optional stable id for the source so re-ingests can be grouped."),
2080
+ thread_id: z14.string().optional().describe("Optional thread id to associate this knowledge with (e.g. a dm:/chat: thread)."),
2081
+ title: z14.string().max(300).optional().describe("Optional human title, stored in metadata.")
1681
2082
  });
1682
2083
  async function mRAG_ingest(input, ctx) {
1683
2084
  readSupabaseEnv();
@@ -1692,15 +2093,15 @@ async function mRAG_ingest(input, ctx) {
1692
2093
  });
1693
2094
  return { indexed: data.indexed ?? 0, chunk_count: data.chunk_count ?? 0 };
1694
2095
  }
1695
- var mRAG_list_sources_input = z11.object({});
2096
+ var mRAG_list_sources_input = z14.object({});
1696
2097
  async function mRAG_list_sources(_input, ctx) {
1697
2098
  readSupabaseEnv();
1698
2099
  ctx.log("debug", "mRAG_list_sources via rag-sources");
1699
2100
  return await invokeFunction("rag-sources", { action: "list" });
1700
2101
  }
1701
- var mRAG_delete_input = z11.object({
1702
- source_id: z11.string().optional().describe("Delete every indexed chunk with this source_id (from mRAG_list_sources)."),
1703
- thread_id: z11.string().optional().describe("Delete every indexed chunk associated with this thread_id.")
2102
+ var mRAG_delete_input = z14.object({
2103
+ source_id: z14.string().optional().describe("Delete every indexed chunk with this source_id (from mRAG_list_sources)."),
2104
+ thread_id: z14.string().optional().describe("Delete every indexed chunk associated with this thread_id.")
1704
2105
  }).refine((v) => v.source_id || v.thread_id, {
1705
2106
  message: "Provide source_id or thread_id \u2014 mRAG_delete refuses to purge the whole index."
1706
2107
  });
@@ -1744,8 +2145,86 @@ var knowledgeTools = [
1744
2145
  }
1745
2146
  ];
1746
2147
 
2148
+ // src/tools/actions.ts
2149
+ import { z as z15 } from "zod";
2150
+ var formField = z15.object({
2151
+ name: z15.string().min(1).max(60).describe("Field key \u2014 returned verbatim in the result."),
2152
+ label: z15.string().max(120).optional().describe("Human label shown to the recipient. Defaults to `name`."),
2153
+ type: z15.enum(["text", "email", "number", "textarea", "tel", "url"]).optional().describe("Input type. Default 'text'."),
2154
+ required: z15.boolean().optional().describe("Whether the recipient must fill this field.")
2155
+ });
2156
+ var action_create_input = z15.object({
2157
+ action_type: z15.enum(["confirm", "file_request", "form", "open_url"]).describe(
2158
+ "What you want the recipient to do: 'confirm' (yes/no), 'file_request' (pick a file from their computer), 'form' (fill fields), 'open_url' (open a vetted https URL)."
2159
+ ),
2160
+ message: z15.string().min(1).max(2e3).describe("What you're asking \u2014 shown on the consent screen above the action UI."),
2161
+ creator_label: z15.string().max(80).optional().describe("How you're identified to the recipient (e.g. your agent name). Default 'Agent'."),
2162
+ // confirm
2163
+ yes_label: z15.string().max(40).optional().describe("[confirm] Affirmative button label. Default 'Tak'."),
2164
+ no_label: z15.string().max(40).optional().describe("[confirm] Negative button label. Default 'Nie'."),
2165
+ // file_request
2166
+ accept: z15.string().max(200).optional().describe("[file_request] Accepted file types (HTML accept attr, e.g. 'image/*,.pdf')."),
2167
+ max_bytes: z15.number().int().positive().max(5242880).optional().describe("[file_request] Max file size in bytes (\u2264 5 MB). NOTE: the returned file is NOT yet end-to-end encrypted \u2014 do not request sensitive files until Tier 1.1 ships."),
2168
+ // form
2169
+ fields: z15.array(formField).min(1).max(20).optional().describe("[form] Fields to collect from the recipient."),
2170
+ // open_url
2171
+ url: z15.string().url().optional().describe("[open_url] The https URL to open. The full URL is shown to the recipient before they open it."),
2172
+ // lifecycle
2173
+ ttl_ms: z15.number().int().positive().optional().describe("Link lifetime in milliseconds. Default 24h, capped at 7d."),
2174
+ max_uses: z15.number().int().min(1).max(50).optional().describe("How many times the link can be redeemed. Default 1 (single-use).")
2175
+ });
2176
+ function buildParams(input) {
2177
+ switch (input.action_type) {
2178
+ case "confirm":
2179
+ return { message: input.message, yesLabel: input.yes_label, noLabel: input.no_label };
2180
+ case "file_request":
2181
+ return { message: input.message, accept: input.accept, maxBytes: input.max_bytes };
2182
+ case "form":
2183
+ if (!input.fields?.length) throw new Error("action_type 'form' requires a non-empty `fields` array.");
2184
+ return { message: input.message, fields: input.fields };
2185
+ case "open_url":
2186
+ if (!input.url) throw new Error("action_type 'open_url' requires `url`.");
2187
+ return { message: input.message, url: input.url };
2188
+ default:
2189
+ return { message: input.message };
2190
+ }
2191
+ }
2192
+ async function action_create(input, ctx) {
2193
+ readSupabaseEnv();
2194
+ ctx.log("debug", "action_create invoking action-create", { action_type: input.action_type });
2195
+ const body = {
2196
+ action_type: input.action_type,
2197
+ params: buildParams(input)
2198
+ };
2199
+ if (input.creator_label !== void 0) body.creator_label = input.creator_label;
2200
+ if (input.ttl_ms !== void 0) body.ttl_ms = input.ttl_ms;
2201
+ if (input.max_uses !== void 0) body.max_uses = input.max_uses;
2202
+ const res = await invokeFunction("action-create", body);
2203
+ if (res.error) throw new Error(res.error);
2204
+ if (!res.link || !res.token) throw new Error("action-create returned a malformed response (missing link/token).");
2205
+ return {
2206
+ action_id: res.action_id ?? "",
2207
+ token: res.token,
2208
+ link: res.link,
2209
+ action_type: res.action_type ?? input.action_type,
2210
+ expires_at: res.expires_at ?? ""
2211
+ };
2212
+ }
2213
+ var actionTools = [
2214
+ {
2215
+ // RFC 0001: channel-agnostic capability (link is sent over ANY channel), so it
2216
+ // lives in the `comms_` namespace rather than a channel `m<MODULE>_` prefix.
2217
+ // A dedicated `mACT` module (create/get/status) is a possible RFC follow-up.
2218
+ name: "comms_action_create",
2219
+ requires: "network",
2220
+ description: "Mint a single-use, expiring action link (https://mosadd.com/do/<token>) that asks a human to DO something in their browser, with explicit consent. action_type: 'confirm' (yes/no) | 'file_request' (recipient picks a file from their computer) | 'form' (recipient fills fields you define) | 'open_url' (recipient opens a vetted https URL). Returns { action_id, token, link, expires_at }. Send the `link` to the person via mDM/mIRC/mAIL; they open it, consent, and the browser performs the action in its sandbox (no install, no OS access). The action is owned by you (the calling user). HONEST LIMITS: this is browser-sandbox only \u2014 it cannot click other apps, run programs, or read files the user didn't pick; and file_request payloads are not yet end-to-end encrypted (don't request sensitive files until Tier 1.1).",
2221
+ inputSchema: action_create_input,
2222
+ handler: action_create
2223
+ }
2224
+ ];
2225
+
1747
2226
  // src/tools/capabilities.ts
1748
- import { z as z12 } from "zod";
2227
+ import { z as z16 } from "zod";
1749
2228
  var CONTRACT_VERSION = "1.0.0";
1750
2229
  var ALL_REQUIREMENTS = ["any", "radio", "network"];
1751
2230
  function buildCapabilityManifest(tools) {
@@ -1768,7 +2247,7 @@ function makeCapabilitiesTool(channelTools2) {
1768
2247
  name: "comms_capabilities",
1769
2248
  requires: "any",
1770
2249
  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.",
1771
- inputSchema: z12.object({}),
2250
+ inputSchema: z16.object({}),
1772
2251
  handler: async () => buildCapabilityManifest([...channelTools2, tool])
1773
2252
  };
1774
2253
  return tool;
@@ -1785,8 +2264,13 @@ var channelTools = [
1785
2264
  ...mroomTools,
1786
2265
  ...mroomMessagesTools,
1787
2266
  ...mailTools,
2267
+ ...mailProvenanceTools,
1788
2268
  ...mtalkTools,
1789
- ...knowledgeTools
2269
+ ...attachmentTools,
2270
+ ...pttIngestTools,
2271
+ ...knowledgeTools,
2272
+ ...actionTools
2273
+ // Action links (Tier 1): agent → user one-link browser action via action-create EF
1790
2274
  // ...murlTools, // mURL: brand/consumer surface (murl.mosadd.com), not a dev product
1791
2275
  // ...mcallTools, // mCALL: carrier-pending (no telephony carrier live) — re-register when a carrier is configured
1792
2276
  // mirlTools,
@@ -1806,7 +2290,7 @@ var allTools = [
1806
2290
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
1807
2291
 
1808
2292
  // src/providers/supabase-dm.ts
1809
- var PROTOCOL_VERSION5 = "mosadd.chat.v1";
2293
+ var PROTOCOL_VERSION6 = "mosadd.chat.v1";
1810
2294
  var SupabaseDmProvider = class {
1811
2295
  cachedSelfId = null;
1812
2296
  async selfId() {
@@ -1833,7 +2317,7 @@ var SupabaseDmProvider = class {
1833
2317
  thread_id: args.threadId,
1834
2318
  encrypted_payload,
1835
2319
  message_type: "text",
1836
- protocol_version: PROTOCOL_VERSION5,
2320
+ protocol_version: PROTOCOL_VERSION6,
1837
2321
  recipient_account_id: args.to,
1838
2322
  reply_to_id: args.replyToId ?? null
1839
2323
  });
package/dist/index.d.ts CHANGED
@@ -196,6 +196,7 @@ declare function createMosaddServer(options?: MosaddServerOptions): McpServer;
196
196
  * Tool registry. Each m* module contributes a set of tools.
197
197
  *
198
198
  * Live modules (6): mDM, mIRC, mROOM, mTALK, mAIL, mRAG — 61 tools + comms_capabilities.
199
+ * Plus action links (Tier 1): comms_action_create — agent → user one-link browser action.
199
200
  * mURL is a consumer/brand surface (murl.mosadd.com), NOT a dev product — its tools
200
201
  * live in tools/murl.ts but are NOT registered here (founder decision 2026-06-10).
201
202
  * mCALL is carrier-pending (no telephony carrier live yet): its tools live in
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  createMosaddServer,
4
4
  defaultProviders,
5
5
  runWithSupabaseEnv
6
- } from "./chunk-ZT7IBWW7.js";
6
+ } from "./chunk-KZ3HIZ74.js";
7
7
  import "./chunk-Z7WR52GE.js";
8
8
  export {
9
9
  allTools,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mosadd/mcp",
3
- "version": "3.0.0-alpha.15",
3
+ "version": "3.0.0-alpha.16",
4
4
  "description": "Model Context Protocol server for mosadd. Exposes the 6 live m* modules (mDM, mIRC, mROOM, mTALK, mAIL, mRAG) — 61 tools — to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
5
5
  "homepage": "https://github.com/Hei33enberg/mosadd-os/tree/main/packages/mcp",
6
6
  "repository": {
@@ -37,8 +37,8 @@
37
37
  "@supabase/supabase-js": "^2.48.0",
38
38
  "zod": "^4.3.6",
39
39
  "@mosadd/crypto": "3.0.0-alpha.4",
40
- "@mosadd/providers": "3.0.0-alpha.4",
41
- "@mosadd/protocol": "3.0.0-alpha.4"
40
+ "@mosadd/protocol": "3.0.0-alpha.4",
41
+ "@mosadd/providers": "3.0.0-alpha.4"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.3.5",