@mosadd/mcp 3.0.0-alpha.55 → 3.0.0-alpha.57

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +15 -11
  2. package/README.md +152 -150
  3. package/dist/bin/mcp.js +1 -1
  4. package/dist/{chunk-IWUGKLDX.js → chunk-WEGSITAH.js} +30 -14
  5. package/dist/index.js +1 -1
  6. package/package.json +2 -2
  7. package/src/__tests__/blob-upload.test.ts +93 -93
  8. package/src/__tests__/channel-e2ee.test.ts +62 -62
  9. package/src/__tests__/flota-jawnie.test.ts +2 -2
  10. package/src/__tests__/golden-path.test.ts +139 -139
  11. package/src/__tests__/integration.test.ts +217 -182
  12. package/src/__tests__/label-room-owner.test.ts +22 -0
  13. package/src/__tests__/mdm-e2ee.test.ts +212 -212
  14. package/src/__tests__/mdm-mcp-readable.test.ts +390 -390
  15. package/src/__tests__/mirc-invite.test.ts +112 -112
  16. package/src/__tests__/mtalk.test.ts +122 -122
  17. package/src/__tests__/presence.test.ts +199 -199
  18. package/src/__tests__/server.test.ts +71 -71
  19. package/src/__tests__/tool-count-consistency.test.ts +259 -199
  20. package/src/__tests__/voice-fields.test.ts +24 -0
  21. package/src/bin/login.ts +138 -138
  22. package/src/bin/mcp.ts +145 -145
  23. package/src/config.ts +66 -66
  24. package/src/crypto/channel-e2ee.ts +288 -288
  25. package/src/crypto/mdm-session.ts +842 -842
  26. package/src/index.ts +19 -19
  27. package/src/observability/sentry.ts +79 -79
  28. package/src/providers/blob-upload.ts +162 -162
  29. package/src/providers/memory-voice.ts +79 -79
  30. package/src/providers/supabase-dm.ts +212 -202
  31. package/src/providers/supabase-voice.ts +103 -91
  32. package/src/server.ts +195 -195
  33. package/src/tools/actions.ts +166 -166
  34. package/src/tools/attachments.ts +276 -276
  35. package/src/tools/capabilities.ts +70 -70
  36. package/src/tools/channel-payload.ts +2 -2
  37. package/src/tools/embed.ts +110 -110
  38. package/src/tools/index.ts +181 -181
  39. package/src/tools/knowledge.ts +344 -344
  40. package/src/tools/mail-aliases.ts +25 -25
  41. package/src/tools/mail-provenance.ts +137 -137
  42. package/src/tools/mail.ts +403 -403
  43. package/src/tools/mdm-as-agent.ts +138 -126
  44. package/src/tools/mdm.ts +6 -4
  45. package/src/tools/mirc-edge.ts +196 -196
  46. package/src/tools/mirc-members.ts +287 -287
  47. package/src/tools/mirc-messages.ts +1 -1
  48. package/src/tools/mirc.ts +308 -308
  49. package/src/tools/mroom.ts +221 -221
  50. package/src/tools/mtalk.ts +131 -131
  51. package/src/tools/presence.ts +442 -442
  52. package/src/tools/voice-format.ts +43 -28
  53. package/src/types.ts +121 -121
  54. package/src/voice/floor.ts +132 -132
@@ -1,25 +1,25 @@
1
- // =============================================================================
2
- // mail-aliases.ts — back-compat mp0st_* aliases for mAYL_* tools
3
- // =============================================================================
4
- // The mosADD re-arch (2026-06-27) renamed the email module from `mp0st` to
5
- // `mAYL` (LINEAR-3938 / 3985). The canonical tool names are mAYL_* — see
6
- // `tools/mail.ts`. THIS module exposes back-compat aliases so any agent already
7
- // wired to mp0st_send / mp0st_view / etc. KEEPS WORKING in this release.
8
- //
9
- // Rule: never drop an alias in the release that adds its replacement — live
10
- // agents would 404. mp0st_* aliases stay through alpha.25 and the next minor;
11
- // flag for removal goes into the a later release's notes.
12
- // =============================================================================
13
-
14
- import type { MosaddTool } from "../types.js";
15
- import { mailTools } from "./mail.js";
16
-
17
- /** Same handlers/schemas as `mailTools`, but registered under the legacy mp0st_* names. */
18
- export const mailAliasTools: MosaddTool[] = mailTools.map((tool) => ({
19
- ...tool,
20
- name: tool.name.replace(/^mAYL_/, "mp0st_"),
21
- description:
22
- `[DEPRECATED — use ${tool.name} instead. mp0st_* aliases stay through alpha.25 ` +
23
- `for back-compat; will be removed in a later alpha.] ` +
24
- tool.description,
25
- }));
1
+ // =============================================================================
2
+ // mail-aliases.ts — back-compat mp0st_* aliases for mAYL_* tools
3
+ // =============================================================================
4
+ // The mosADD re-arch (2026-06-27) renamed the email module from `mp0st` to
5
+ // `mAYL` (LINEAR-3938 / 3985). The canonical tool names are mAYL_* — see
6
+ // `tools/mail.ts`. THIS module exposes back-compat aliases so any agent already
7
+ // wired to mp0st_send / mp0st_view / etc. KEEPS WORKING in this release.
8
+ //
9
+ // Rule: never drop an alias in the release that adds its replacement — live
10
+ // agents would 404. mp0st_* aliases stay through alpha.25 and the next minor;
11
+ // flag for removal goes into the a later release's notes.
12
+ // =============================================================================
13
+
14
+ import type { MosaddTool } from "../types.js";
15
+ import { mailTools } from "./mail.js";
16
+
17
+ /** Same handlers/schemas as `mailTools`, but registered under the legacy mp0st_* names. */
18
+ export const mailAliasTools: MosaddTool[] = mailTools.map((tool) => ({
19
+ ...tool,
20
+ name: tool.name.replace(/^mAYL_/, "mp0st_"),
21
+ description:
22
+ `[DEPRECATED — use ${tool.name} instead. mp0st_* aliases stay through alpha.25 ` +
23
+ `for back-compat; will be removed in a later alpha.] ` +
24
+ tool.description,
25
+ }));
@@ -1,137 +1,137 @@
1
- /**
2
- * mp0st provenance — agent-attributed email send.
3
- *
4
- * The plain `mp0st_send` (mail.ts) sends as the USER. When an AGENT sends mail on
5
- * the user's behalf, the recipient (and the audit trail) should be able to tell
6
- * it was agent-originated. Per the Lane A contract, `mp0st-send`, when called
7
- * with a HUB-CLAIM JWT, stamps the row with:
8
- * sent_by = 'agent', sent_by_agent_id, sent_by_task_id
9
- *
10
- * This tool mints/forwards that hub-claim JWT and sets the provenance fields.
11
- *
12
- * AUTH MODEL (differs from the rest of mp0st):
13
- * - mp0st_send uses the user's Supabase session JWT (via invokeFunction).
14
- * - mp0st_send_as_agent presents a HUB-CLAIM JWT (hub key → claim exchange) so
15
- * mp0st-send can attribute the send to the agent/task.
16
- *
17
- * STATUS: scaffold. The hub-claim exchange endpoint is assumed (TODO Lane A —
18
- * confirm the exact route + claim shape). Falls back to the user session JWT if
19
- * no hub key is configured, with provenance fields passed through for the EF to
20
- * honor once deployed.
21
- */
22
-
23
- import { z } from "zod";
24
- import type { MosaddTool, MosaddToolContext } from "../types.js";
25
-
26
- const DEFAULT_SUPABASE_URL = "https://rooffhgbxafyjcwmwpsy.supabase.co";
27
-
28
- function supabaseUrl(): string {
29
- return (
30
- process.env.MOSADD_SUPABASE_URL?.replace(/\/$/, "") ??
31
- process.env.SUPABASE_URL?.replace(/\/$/, "") ??
32
- DEFAULT_SUPABASE_URL
33
- );
34
- }
35
-
36
- function hubKey(): string | null {
37
- return process.env.MOSADD_API_KEY ?? process.env.MOSADD_HUB_KEY ?? null;
38
- }
39
-
40
- const EmailAddress = z.string().email().max(254);
41
-
42
- const mp0st_send_as_agent_input = z.object({
43
- to: z.union([EmailAddress, z.array(EmailAddress).min(1).max(50)]),
44
- subject: z.string().min(1).max(998),
45
- body_text: z.string().max(1_048_576).optional(),
46
- body_html: z.string().max(1_048_576).optional(),
47
- cc: z.array(EmailAddress).max(50).optional(),
48
- bcc: z.array(EmailAddress).max(50).optional(),
49
- reply_to: EmailAddress.optional(),
50
- tracking: z.boolean().optional(),
51
- agent_id: z
52
- .string()
53
- .min(1)
54
- .max(120)
55
- .describe("Stable id of the agent doing the send. Stamped as sent_by_agent_id for provenance."),
56
- task_id: z
57
- .string()
58
- .min(1)
59
- .max(120)
60
- .optional()
61
- .describe("Optional id of the task/run this send belongs to. Stamped as sent_by_task_id."),
62
- });
63
-
64
- /**
65
- * Exchange the hub key for an HS256 hub-claim JWT that authorizes agent-attributed
66
- * mail sends. The `mp0st-send` EF verifies this token with HUB_JWT_SECRET and reads
67
- * `agent_id` + `task_id` from its claims authoritatively (body fields are NOT trusted
68
- * for provenance). LINEAR-3991.
69
- */
70
- async function mintHubClaim(agentId: string, taskId?: string): Promise<string> {
71
- const key = hubKey();
72
- if (!key) {
73
- throw new Error("mAYL_send_as_agent needs MOSADD_API_KEY (hub key) to mint a provenance claim.");
74
- }
75
- const r = await fetch(`${supabaseUrl()}/functions/v1/hub-claim-mint`, {
76
- method: "POST",
77
- headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
78
- body: JSON.stringify({ agent_id: agentId, task_id: taskId ?? null }),
79
- });
80
- if (!r.ok) {
81
- const b = await r.text().catch(() => "");
82
- throw new Error(`hub-claim-mint ${r.status}: ${b.slice(0, 200)}`);
83
- }
84
- const data = (await r.json()) as { access_token?: string };
85
- if (!data?.access_token) throw new Error("hub-claim-mint: no access_token in response");
86
- return data.access_token;
87
- }
88
-
89
- async function mAYL_send_as_agent(
90
- input: z.infer<typeof mp0st_send_as_agent_input>,
91
- ctx: MosaddToolContext,
92
- ): Promise<{ message_id: string; status: string; is_internal: boolean; sent_by: "agent" }> {
93
- if (!input.body_text && !input.body_html) {
94
- throw new Error("mAYL_send_as_agent requires at least one of body_text or body_html.");
95
- }
96
-
97
- // Mint the hub-claim JWT and present it directly to mp0st-send (NOT the user
98
- // session client) so the EF attributes the row to the agent. mp0st-send verifies
99
- // the HS256 signature with HUB_JWT_SECRET and stamps sent_by_agent_id /
100
- // sent_by_task_id from the verified claims — body fields are NOT trusted for
101
- // provenance.
102
- const claim = await mintHubClaim(input.agent_id, input.task_id);
103
- ctx.log("debug", "mAYL_send_as_agent invoking mp0st-send with hub-claim", { agent_id: input.agent_id });
104
-
105
- const { agent_id: _ai, task_id: _ti, ...mailFields } = input;
106
- const r = await fetch(`${supabaseUrl()}/functions/v1/mp0st-send`, {
107
- method: "POST",
108
- headers: { "Content-Type": "application/json", Authorization: `Bearer ${claim}` },
109
- body: JSON.stringify(mailFields),
110
- });
111
- if (!r.ok) {
112
- const b = await r.text().catch(() => "");
113
- throw new Error(`mp0st-send ${r.status}: ${b.slice(0, 200)}`);
114
- }
115
- const res = (await r.json()) as { email_id?: string; status?: string; is_internal?: boolean; error?: string };
116
- if (res.error) throw new Error(res.error);
117
-
118
- return {
119
- message_id: res.email_id ?? "",
120
- status: res.status ?? "sent",
121
- is_internal: res.is_internal ?? false,
122
- sent_by: "agent",
123
- };
124
- }
125
-
126
- export const mailProvenanceTools: MosaddTool[] = [
127
- {
128
- name: "mAYL_send_as_agent",
129
- title: "Send email as your agent",
130
- annotations: { readOnlyHint: false },
131
- requires: "network",
132
- description:
133
- "Send an email ATTRIBUTED TO THE AGENT (provenance-stamped). Unlike mAYL_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 — so recipients and compliance can see the mail was agent-originated. Auth: presents a hub-claim JWT (needs MOSADD_API_KEY). The mp0st-send EF verifies the claim with HUB_JWT_SECRET; body trust is never granted for provenance.",
134
- inputSchema: mp0st_send_as_agent_input,
135
- handler: mAYL_send_as_agent as MosaddTool["handler"],
136
- },
137
- ];
1
+ /**
2
+ * mp0st provenance — agent-attributed email send.
3
+ *
4
+ * The plain `mp0st_send` (mail.ts) sends as the USER. When an AGENT sends mail on
5
+ * the user's behalf, the recipient (and the audit trail) should be able to tell
6
+ * it was agent-originated. Per the Lane A contract, `mp0st-send`, when called
7
+ * with a HUB-CLAIM JWT, stamps the row with:
8
+ * sent_by = 'agent', sent_by_agent_id, sent_by_task_id
9
+ *
10
+ * This tool mints/forwards that hub-claim JWT and sets the provenance fields.
11
+ *
12
+ * AUTH MODEL (differs from the rest of mp0st):
13
+ * - mp0st_send uses the user's Supabase session JWT (via invokeFunction).
14
+ * - mp0st_send_as_agent presents a HUB-CLAIM JWT (hub key → claim exchange) so
15
+ * mp0st-send can attribute the send to the agent/task.
16
+ *
17
+ * STATUS: scaffold. The hub-claim exchange endpoint is assumed (TODO Lane A —
18
+ * confirm the exact route + claim shape). Falls back to the user session JWT if
19
+ * no hub key is configured, with provenance fields passed through for the EF to
20
+ * honor once deployed.
21
+ */
22
+
23
+ import { z } from "zod";
24
+ import type { MosaddTool, MosaddToolContext } from "../types.js";
25
+
26
+ const DEFAULT_SUPABASE_URL = "https://rooffhgbxafyjcwmwpsy.supabase.co";
27
+
28
+ function supabaseUrl(): string {
29
+ return (
30
+ process.env.MOSADD_SUPABASE_URL?.replace(/\/$/, "") ??
31
+ process.env.SUPABASE_URL?.replace(/\/$/, "") ??
32
+ DEFAULT_SUPABASE_URL
33
+ );
34
+ }
35
+
36
+ function hubKey(): string | null {
37
+ return process.env.MOSADD_API_KEY ?? process.env.MOSADD_HUB_KEY ?? null;
38
+ }
39
+
40
+ const EmailAddress = z.string().email().max(254);
41
+
42
+ const mp0st_send_as_agent_input = z.object({
43
+ to: z.union([EmailAddress, z.array(EmailAddress).min(1).max(50)]),
44
+ subject: z.string().min(1).max(998),
45
+ body_text: z.string().max(1_048_576).optional(),
46
+ body_html: z.string().max(1_048_576).optional(),
47
+ cc: z.array(EmailAddress).max(50).optional(),
48
+ bcc: z.array(EmailAddress).max(50).optional(),
49
+ reply_to: EmailAddress.optional(),
50
+ tracking: z.boolean().optional(),
51
+ agent_id: z
52
+ .string()
53
+ .min(1)
54
+ .max(120)
55
+ .describe("Stable id of the agent doing the send. Stamped as sent_by_agent_id for provenance."),
56
+ task_id: z
57
+ .string()
58
+ .min(1)
59
+ .max(120)
60
+ .optional()
61
+ .describe("Optional id of the task/run this send belongs to. Stamped as sent_by_task_id."),
62
+ });
63
+
64
+ /**
65
+ * Exchange the hub key for an HS256 hub-claim JWT that authorizes agent-attributed
66
+ * mail sends. The `mp0st-send` EF verifies this token with HUB_JWT_SECRET and reads
67
+ * `agent_id` + `task_id` from its claims authoritatively (body fields are NOT trusted
68
+ * for provenance). LINEAR-3991.
69
+ */
70
+ async function mintHubClaim(agentId: string, taskId?: string): Promise<string> {
71
+ const key = hubKey();
72
+ if (!key) {
73
+ throw new Error("mAYL_send_as_agent needs MOSADD_API_KEY (hub key) to mint a provenance claim.");
74
+ }
75
+ const r = await fetch(`${supabaseUrl()}/functions/v1/hub-claim-mint`, {
76
+ method: "POST",
77
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
78
+ body: JSON.stringify({ agent_id: agentId, task_id: taskId ?? null }),
79
+ });
80
+ if (!r.ok) {
81
+ const b = await r.text().catch(() => "");
82
+ throw new Error(`hub-claim-mint ${r.status}: ${b.slice(0, 200)}`);
83
+ }
84
+ const data = (await r.json()) as { access_token?: string };
85
+ if (!data?.access_token) throw new Error("hub-claim-mint: no access_token in response");
86
+ return data.access_token;
87
+ }
88
+
89
+ async function mAYL_send_as_agent(
90
+ input: z.infer<typeof mp0st_send_as_agent_input>,
91
+ ctx: MosaddToolContext,
92
+ ): Promise<{ message_id: string; status: string; is_internal: boolean; sent_by: "agent" }> {
93
+ if (!input.body_text && !input.body_html) {
94
+ throw new Error("mAYL_send_as_agent requires at least one of body_text or body_html.");
95
+ }
96
+
97
+ // Mint the hub-claim JWT and present it directly to mp0st-send (NOT the user
98
+ // session client) so the EF attributes the row to the agent. mp0st-send verifies
99
+ // the HS256 signature with HUB_JWT_SECRET and stamps sent_by_agent_id /
100
+ // sent_by_task_id from the verified claims — body fields are NOT trusted for
101
+ // provenance.
102
+ const claim = await mintHubClaim(input.agent_id, input.task_id);
103
+ ctx.log("debug", "mAYL_send_as_agent invoking mp0st-send with hub-claim", { agent_id: input.agent_id });
104
+
105
+ const { agent_id: _ai, task_id: _ti, ...mailFields } = input;
106
+ const r = await fetch(`${supabaseUrl()}/functions/v1/mp0st-send`, {
107
+ method: "POST",
108
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${claim}` },
109
+ body: JSON.stringify(mailFields),
110
+ });
111
+ if (!r.ok) {
112
+ const b = await r.text().catch(() => "");
113
+ throw new Error(`mp0st-send ${r.status}: ${b.slice(0, 200)}`);
114
+ }
115
+ const res = (await r.json()) as { email_id?: string; status?: string; is_internal?: boolean; error?: string };
116
+ if (res.error) throw new Error(res.error);
117
+
118
+ return {
119
+ message_id: res.email_id ?? "",
120
+ status: res.status ?? "sent",
121
+ is_internal: res.is_internal ?? false,
122
+ sent_by: "agent",
123
+ };
124
+ }
125
+
126
+ export const mailProvenanceTools: MosaddTool[] = [
127
+ {
128
+ name: "mAYL_send_as_agent",
129
+ title: "Send email as your agent",
130
+ annotations: { readOnlyHint: false },
131
+ requires: "network",
132
+ description:
133
+ "Send an email ATTRIBUTED TO THE AGENT (provenance-stamped). Unlike mAYL_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 — so recipients and compliance can see the mail was agent-originated. Auth: presents a hub-claim JWT (needs MOSADD_API_KEY). The mp0st-send EF verifies the claim with HUB_JWT_SECRET; body trust is never granted for provenance.",
134
+ inputSchema: mp0st_send_as_agent_input,
135
+ handler: mAYL_send_as_agent as MosaddTool["handler"],
136
+ },
137
+ ];