@mosadd/mcp 3.0.0-alpha.15 → 3.0.0-alpha.17
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 +71 -0
- package/README.md +44 -29
- package/dist/bin/mcp.js +38 -2
- package/dist/{chunk-ZT7IBWW7.js → chunk-5ZMJB5YU.js} +551 -31
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/package.json +3 -2
- package/src/bin/mcp.ts +45 -0
- package/src/providers/blob-upload.ts +116 -0
- package/src/server.ts +6 -0
- package/src/tools/actions.ts +162 -0
- package/src/tools/attachments.ts +328 -0
- package/src/tools/index.ts +11 -1
- package/src/tools/mail-provenance.ts +137 -0
- package/src/tools/mail.ts +5 -2
- package/src/tools/ptt-ingest.ts +91 -0
package/dist/index.d.ts
CHANGED
|
@@ -195,7 +195,9 @@ declare function createMosaddServer(options?: MosaddServerOptions): McpServer;
|
|
|
195
195
|
/**
|
|
196
196
|
* Tool registry. Each m* module contributes a set of tools.
|
|
197
197
|
*
|
|
198
|
-
* Live modules (6): mDM, mIRC, mROOM, mTALK, mAIL, mRAG —
|
|
198
|
+
* Live modules (6): mDM, mIRC, mROOM, mTALK, mAIL, mRAG — 70 tools + comms_capabilities.
|
|
199
|
+
* Plus action links: comms_action_create (agent → user one-link browser action,
|
|
200
|
+
* incl. screen_share) + comms_action_frame_get (see the recipient's shared screen).
|
|
199
201
|
* mURL is a consumer/brand surface (murl.mosadd.com), NOT a dev product — its tools
|
|
200
202
|
* live in tools/murl.ts but are NOT registered here (founder decision 2026-06-10).
|
|
201
203
|
* mCALL is carrier-pending (no telephony carrier live yet): its tools live in
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mosadd/mcp",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
4
|
-
"description": "Model Context Protocol server for mosadd. Exposes the 6 live m* modules (mDM, mIRC, mROOM, mTALK, mAIL, mRAG) —
|
|
3
|
+
"version": "3.0.0-alpha.17",
|
|
4
|
+
"description": "Model Context Protocol server for mosadd. Exposes the 6 live m* modules (mDM, mIRC, mROOM, mTALK, mAIL, mRAG) — 70 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": {
|
|
7
7
|
"type": "git",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"dist",
|
|
28
28
|
"src",
|
|
29
29
|
"README.md",
|
|
30
|
+
"CHANGELOG.md",
|
|
30
31
|
"LICENSE"
|
|
31
32
|
],
|
|
32
33
|
"publishConfig": {
|
package/src/bin/mcp.ts
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
13
|
+
import { createClient } from "@supabase/supabase-js";
|
|
13
14
|
import { createMosaddServer } from "../server.js";
|
|
15
|
+
import { loadSession, saveSession, isSessionExpired } from "../config.js";
|
|
14
16
|
|
|
15
17
|
const DEFAULT_EXCHANGE =
|
|
16
18
|
"https://rooffhgbxafyjcwmwpsy.supabase.co/functions/v1/hub-key-exchange";
|
|
@@ -51,6 +53,47 @@ async function bootstrapFromApiKey(): Promise<void> {
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
/**
|
|
57
|
+
* `mosadd login` path: refresh the saved session at boot so a stored token that
|
|
58
|
+
* expired since the last launch (Supabase access tokens last ~1h) is renewed
|
|
59
|
+
* silently from its refresh token — instead of failing the first tool call with
|
|
60
|
+
* "session expired, run `mosadd login` again". This makes a single `mosadd login`
|
|
61
|
+
* durable across restarts (the founder's "set once, forget" expectation). No-op
|
|
62
|
+
* when an explicit env JWT or hub key already resolved a session, when there is no
|
|
63
|
+
* saved session, or when the saved token is still valid.
|
|
64
|
+
*/
|
|
65
|
+
async function bootstrapFromSavedSession(): Promise<void> {
|
|
66
|
+
if (process.env.MOSADD_USER_JWT) return;
|
|
67
|
+
const session = loadSession();
|
|
68
|
+
if (!session?.refreshToken) return;
|
|
69
|
+
// Still-valid token → the provider uses it as-is; don't churn the refresh token.
|
|
70
|
+
if (!isSessionExpired(session)) return;
|
|
71
|
+
try {
|
|
72
|
+
const client = createClient(session.url, session.anonKey, {
|
|
73
|
+
auth: { persistSession: false, autoRefreshToken: false, detectSessionInUrl: false },
|
|
74
|
+
});
|
|
75
|
+
const { data, error } = await client.auth.refreshSession({ refresh_token: session.refreshToken });
|
|
76
|
+
if (error || !data.session) {
|
|
77
|
+
process.stderr.write(
|
|
78
|
+
JSON.stringify({ level: "warn", msg: "mosadd session refresh failed — run `mosadd login`", error: error?.message }) + "\n",
|
|
79
|
+
);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
saveSession({
|
|
83
|
+
url: session.url,
|
|
84
|
+
anonKey: session.anonKey,
|
|
85
|
+
accessToken: data.session.access_token,
|
|
86
|
+
refreshToken: data.session.refresh_token ?? session.refreshToken,
|
|
87
|
+
expiresAt: data.session.expires_at,
|
|
88
|
+
email: data.user?.email ?? session.email,
|
|
89
|
+
});
|
|
90
|
+
} catch (err) {
|
|
91
|
+
process.stderr.write(
|
|
92
|
+
JSON.stringify({ level: "warn", msg: "mosadd session refresh error — run `mosadd login`", error: String(err) }) + "\n",
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
54
97
|
async function main(): Promise<void> {
|
|
55
98
|
// Auth subcommands: `mosadd login | logout | whoami`. Everything else starts the server.
|
|
56
99
|
const sub = process.argv[2];
|
|
@@ -62,6 +105,8 @@ async function main(): Promise<void> {
|
|
|
62
105
|
|
|
63
106
|
// Hosted: trade MOSADD_API_KEY for a live session before the server reads env.
|
|
64
107
|
await bootstrapFromApiKey();
|
|
108
|
+
// `mosadd login`: renew a saved session whose access token expired since last launch.
|
|
109
|
+
await bootstrapFromSavedSession();
|
|
65
110
|
|
|
66
111
|
const server = createMosaddServer({
|
|
67
112
|
apiKey: process.env.MOSADD_API_KEY,
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Voice/file blob upload helper.
|
|
3
|
+
*
|
|
4
|
+
* The `message-send` contract carries voice/ptt/file bodies via an
|
|
5
|
+
* `attachments[]` array of `{ kind, bucket, path, mime, duration_ms, key_ref }`
|
|
6
|
+
* descriptors. The actual bytes must be uploaded to Supabase Storage FIRST; the
|
|
7
|
+
* message row only references them by `{ bucket, path }`.
|
|
8
|
+
*
|
|
9
|
+
* This module centralises that upload so every channel's voice/file/ptt tool
|
|
10
|
+
* (mDM, mROOM, mIRC) produces an identical attachment descriptor.
|
|
11
|
+
*
|
|
12
|
+
* STATUS: scaffold. The Storage upload path below is real (supabase-js
|
|
13
|
+
* `storage.from(bucket).upload`), but two things are TODO and gated on the
|
|
14
|
+
* Lane A / CTO backend contract:
|
|
15
|
+
* - TODO(Lane A): confirm bucket names (`voice-blobs` for voice/ptt) and the
|
|
16
|
+
* RLS/policy that lets an agent JWT or hub-claim JWT write to them.
|
|
17
|
+
* - TODO(Lane A): mDM voice is CLIENT-ENCRYPTED — the bytes must be sealed
|
|
18
|
+
* (per-recipient, via @mosadd/crypto) before upload and `key_ref` must point
|
|
19
|
+
* at the wrapped content key. Today this helper uploads the bytes as-is and
|
|
20
|
+
* sets key_ref:null. Do NOT use for mDM voice until the seal step lands.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { getSupabase, readSupabaseEnv } from "./supabase.js";
|
|
24
|
+
|
|
25
|
+
export type AttachmentKind = "voice" | "file" | "ptt";
|
|
26
|
+
|
|
27
|
+
/** The descriptor shape `message-send` expects inside `attachments[]`. */
|
|
28
|
+
export interface AttachmentDescriptor {
|
|
29
|
+
kind: AttachmentKind;
|
|
30
|
+
bucket: string;
|
|
31
|
+
path: string;
|
|
32
|
+
mime: string;
|
|
33
|
+
duration_ms?: number | null;
|
|
34
|
+
/** Reference to the wrapped content-encryption key (E2EE channels only). */
|
|
35
|
+
key_ref?: string | null;
|
|
36
|
+
/** Original filename, for `kind:'file'`. */
|
|
37
|
+
filename?: string | null;
|
|
38
|
+
size_bytes?: number | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface UploadBlobArgs {
|
|
42
|
+
kind: AttachmentKind;
|
|
43
|
+
/** Raw bytes to upload. Caller is responsible for any E2EE sealing first. */
|
|
44
|
+
bytes: Uint8Array;
|
|
45
|
+
mime: string;
|
|
46
|
+
/** Storage bucket. Defaults: voice/ptt → 'voice-blobs', file → 'file-blobs'. */
|
|
47
|
+
bucket?: string;
|
|
48
|
+
/** Sub-path prefix inside the bucket (e.g. the thread id). */
|
|
49
|
+
prefix?: string;
|
|
50
|
+
duration_ms?: number | null;
|
|
51
|
+
filename?: string | null;
|
|
52
|
+
/** Reference to the wrapped content key, when the caller pre-sealed the bytes. */
|
|
53
|
+
key_ref?: string | null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function defaultBucket(kind: AttachmentKind): string {
|
|
57
|
+
// TODO(Lane A): confirm canonical bucket names + write policy for agent JWTs.
|
|
58
|
+
return kind === "file" ? "file-blobs" : "voice-blobs";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function randomId(): string {
|
|
62
|
+
// crypto.randomUUID is available on Node >=18 (package engines floor).
|
|
63
|
+
return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Upload bytes to Supabase Storage and return the attachment descriptor to embed
|
|
68
|
+
* in `message-send`'s `attachments[]`.
|
|
69
|
+
*/
|
|
70
|
+
export async function uploadBlob(args: UploadBlobArgs): Promise<AttachmentDescriptor> {
|
|
71
|
+
readSupabaseEnv();
|
|
72
|
+
const sb = getSupabase();
|
|
73
|
+
const bucket = args.bucket ?? defaultBucket(args.kind);
|
|
74
|
+
const ext = args.filename?.split(".").pop() ?? mimeExt(args.mime);
|
|
75
|
+
const path = `${args.prefix ? args.prefix.replace(/[^a-zA-Z0-9._/-]/g, "-") + "/" : ""}${randomId()}${ext ? "." + ext : ""}`;
|
|
76
|
+
|
|
77
|
+
const { error } = await sb.storage.from(bucket).upload(path, args.bytes, {
|
|
78
|
+
contentType: args.mime,
|
|
79
|
+
upsert: false,
|
|
80
|
+
});
|
|
81
|
+
if (error) {
|
|
82
|
+
throw new Error(`blob upload to ${bucket}/${path} failed: ${error.message}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
kind: args.kind,
|
|
87
|
+
bucket,
|
|
88
|
+
path,
|
|
89
|
+
mime: args.mime,
|
|
90
|
+
duration_ms: args.duration_ms ?? null,
|
|
91
|
+
key_ref: args.key_ref ?? null,
|
|
92
|
+
filename: args.filename ?? null,
|
|
93
|
+
size_bytes: args.bytes.byteLength,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function mimeExt(mime: string): string {
|
|
98
|
+
const map: Record<string, string> = {
|
|
99
|
+
"audio/ogg": "ogg",
|
|
100
|
+
"audio/mpeg": "mp3",
|
|
101
|
+
"audio/mp4": "m4a",
|
|
102
|
+
"audio/wav": "wav",
|
|
103
|
+
"audio/webm": "webm",
|
|
104
|
+
};
|
|
105
|
+
return map[mime] ?? "";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Decode a base64 / data-URL string into bytes. Agents hand us audio/file
|
|
110
|
+
* content as base64 (MCP is JSON-only — no binary channel), so every voice/file
|
|
111
|
+
* tool funnels through this.
|
|
112
|
+
*/
|
|
113
|
+
export function decodeBase64Body(b64: string): Uint8Array {
|
|
114
|
+
const cleaned = b64.includes(",") && b64.startsWith("data:") ? b64.slice(b64.indexOf(",") + 1) : b64;
|
|
115
|
+
return new Uint8Array(Buffer.from(cleaned, "base64"));
|
|
116
|
+
}
|
package/src/server.ts
CHANGED
|
@@ -86,6 +86,12 @@ export function createMosaddServer(options: MosaddServerOptions = {}) {
|
|
|
86
86
|
const parsed = tool.inputSchema.parse(input);
|
|
87
87
|
try {
|
|
88
88
|
const result = await tool.handler(parsed as never, ctx);
|
|
89
|
+
// A tool may return rich MCP content (e.g. an image frame from
|
|
90
|
+
// comms_action_frame_get) via `mcpContent`; pass it through verbatim.
|
|
91
|
+
const rich = result as { mcpContent?: unknown[] } | null;
|
|
92
|
+
if (rich && Array.isArray(rich.mcpContent)) {
|
|
93
|
+
return { content: rich.mcpContent as never[] };
|
|
94
|
+
}
|
|
89
95
|
return {
|
|
90
96
|
content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }],
|
|
91
97
|
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action links — agent → user one-link actions (Tier 1).
|
|
3
|
+
*
|
|
4
|
+
* Mint a single-use, expiring link (`https://mosadd.com/do/<token>`) that asks a
|
|
5
|
+
* human to DO something in their browser — confirm, pick a file, fill a form, or
|
|
6
|
+
* open a vetted URL — with explicit consent. Send the returned `link` to the
|
|
7
|
+
* person via any channel (mDM/mIRC/mAIL). They open it, see what's asked, consent,
|
|
8
|
+
* and the browser performs the action IN ITS SANDBOX, then the result is recorded
|
|
9
|
+
* against the action. No install, no OS access, nothing runs without a user gesture.
|
|
10
|
+
*
|
|
11
|
+
* Backend: mosadd `action-create` Edge Function. The action is owned by the
|
|
12
|
+
* calling user (user-JWT scoped — `mosadd login` / MOSADD_USER_JWT), so only you
|
|
13
|
+
* can later read its result.
|
|
14
|
+
*
|
|
15
|
+
* Result read-back (an `action_status` tool) is a follow-up — it needs a small
|
|
16
|
+
* creator-scoped read Edge Function (`action-status`). For now, the recipient's
|
|
17
|
+
* outcome is recorded on the action row; surface it once that EF ships.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
22
|
+
import { invokeFunction, readSupabaseEnv, getSupabase } from "../providers/supabase.js";
|
|
23
|
+
|
|
24
|
+
const formField = z.object({
|
|
25
|
+
name: z.string().min(1).max(60).describe("Field key — returned verbatim in the result."),
|
|
26
|
+
label: z.string().max(120).optional().describe("Human label shown to the recipient. Defaults to `name`."),
|
|
27
|
+
type: z.enum(["text", "email", "number", "textarea", "tel", "url"]).optional().describe("Input type. Default 'text'."),
|
|
28
|
+
required: z.boolean().optional().describe("Whether the recipient must fill this field."),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const action_create_input = z.object({
|
|
32
|
+
action_type: z.enum(["confirm", "file_request", "form", "open_url", "screen_share"]).describe(
|
|
33
|
+
"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), 'screen_share' (recipient shares their screen so you can SEE it via comms_action_frame_get — view only).",
|
|
34
|
+
),
|
|
35
|
+
message: z.string().min(1).max(2000).describe("What you're asking — shown on the consent screen above the action UI."),
|
|
36
|
+
creator_label: z.string().max(80).optional().describe("How you're identified to the recipient (e.g. your agent name). Default 'Agent'."),
|
|
37
|
+
// confirm
|
|
38
|
+
yes_label: z.string().max(40).optional().describe("[confirm] Affirmative button label. Default 'Tak'."),
|
|
39
|
+
no_label: z.string().max(40).optional().describe("[confirm] Negative button label. Default 'Nie'."),
|
|
40
|
+
// file_request
|
|
41
|
+
accept: z.string().max(200).optional().describe("[file_request] Accepted file types (HTML accept attr, e.g. 'image/*,.pdf')."),
|
|
42
|
+
max_bytes: z.number().int().positive().max(5_242_880).optional().describe("[file_request] Max file size in bytes (≤ 5 MB). NOTE: the returned file is NOT yet end-to-end encrypted — do not request sensitive files until Tier 1.1 ships."),
|
|
43
|
+
// form
|
|
44
|
+
fields: z.array(formField).min(1).max(20).optional().describe("[form] Fields to collect from the recipient."),
|
|
45
|
+
// open_url
|
|
46
|
+
url: z.string().url().optional().describe("[open_url] The https URL to open. The full URL is shown to the recipient before they open it."),
|
|
47
|
+
// screen_share
|
|
48
|
+
max_width: z.number().int().positive().max(1920).optional().describe("[screen_share] Max captured frame width in px (default 1280). Frames are downscaled JPEGs."),
|
|
49
|
+
// lifecycle
|
|
50
|
+
ttl_ms: z.number().int().positive().optional().describe("Link lifetime in milliseconds. Default 24h, capped at 7d."),
|
|
51
|
+
max_uses: z.number().int().min(1).max(50).optional().describe("How many times the link can be redeemed. Default 1 (single-use)."),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
function buildParams(input: z.infer<typeof action_create_input>): Record<string, unknown> {
|
|
55
|
+
switch (input.action_type) {
|
|
56
|
+
case "confirm":
|
|
57
|
+
return { message: input.message, yesLabel: input.yes_label, noLabel: input.no_label };
|
|
58
|
+
case "file_request":
|
|
59
|
+
return { message: input.message, accept: input.accept, maxBytes: input.max_bytes };
|
|
60
|
+
case "form":
|
|
61
|
+
if (!input.fields?.length) throw new Error("action_type 'form' requires a non-empty `fields` array.");
|
|
62
|
+
return { message: input.message, fields: input.fields };
|
|
63
|
+
case "open_url":
|
|
64
|
+
if (!input.url) throw new Error("action_type 'open_url' requires `url`.");
|
|
65
|
+
return { message: input.message, url: input.url };
|
|
66
|
+
case "screen_share":
|
|
67
|
+
return { message: input.message, maxWidth: input.max_width };
|
|
68
|
+
default:
|
|
69
|
+
return { message: input.message };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface ActionCreateResult {
|
|
74
|
+
action_id: string;
|
|
75
|
+
token: string;
|
|
76
|
+
link: string;
|
|
77
|
+
action_type: string;
|
|
78
|
+
expires_at: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function action_create(
|
|
82
|
+
input: z.infer<typeof action_create_input>,
|
|
83
|
+
ctx: MosaddToolContext,
|
|
84
|
+
): Promise<ActionCreateResult> {
|
|
85
|
+
readSupabaseEnv();
|
|
86
|
+
ctx.log("debug", "action_create invoking action-create", { action_type: input.action_type });
|
|
87
|
+
|
|
88
|
+
const body: Record<string, unknown> = {
|
|
89
|
+
action_type: input.action_type,
|
|
90
|
+
params: buildParams(input),
|
|
91
|
+
};
|
|
92
|
+
if (input.creator_label !== undefined) body.creator_label = input.creator_label;
|
|
93
|
+
if (input.ttl_ms !== undefined) body.ttl_ms = input.ttl_ms;
|
|
94
|
+
if (input.max_uses !== undefined) body.max_uses = input.max_uses;
|
|
95
|
+
|
|
96
|
+
const res = await invokeFunction<Partial<ActionCreateResult> & { error?: string }>("action-create", body);
|
|
97
|
+
if (res.error) throw new Error(res.error);
|
|
98
|
+
if (!res.link || !res.token) throw new Error("action-create returned a malformed response (missing link/token).");
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
action_id: res.action_id ?? "",
|
|
102
|
+
token: res.token,
|
|
103
|
+
link: res.link,
|
|
104
|
+
action_type: res.action_type ?? input.action_type,
|
|
105
|
+
expires_at: res.expires_at ?? "",
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ── comms_action_frame_get — read the latest screen frame (Tier 1.5) ──────────
|
|
110
|
+
const action_frame_get_input = z.object({
|
|
111
|
+
action_id: z.string().min(1).describe("The action_id returned by comms_action_create for a 'screen_share' action you created."),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
async function action_frame_get(
|
|
115
|
+
input: z.infer<typeof action_frame_get_input>,
|
|
116
|
+
ctx: MosaddToolContext,
|
|
117
|
+
): Promise<{ mcpContent: Array<Record<string, unknown>> }> {
|
|
118
|
+
readSupabaseEnv();
|
|
119
|
+
ctx.log("debug", "action_frame_get reading frame", { action_id: input.action_id });
|
|
120
|
+
// Read directly via RLS ("creators read own frames") — the agent's JWT gates it
|
|
121
|
+
// to screen_share actions it created. No edge function needed.
|
|
122
|
+
const sb = getSupabase();
|
|
123
|
+
const { data, error } = await sb
|
|
124
|
+
.from("action_screen_frames")
|
|
125
|
+
.select("image_jpeg, width, seq, updated_at")
|
|
126
|
+
.eq("action_id", input.action_id)
|
|
127
|
+
.maybeSingle();
|
|
128
|
+
if (error) throw new Error(error.message);
|
|
129
|
+
if (!data) {
|
|
130
|
+
return { mcpContent: [{ type: "text", text: "No frame yet — the recipient hasn't started sharing their screen (or you don't own this action)." }] };
|
|
131
|
+
}
|
|
132
|
+
const row = data as { image_jpeg: string; width: number | null; seq: number; updated_at: string };
|
|
133
|
+
const ageSec = Math.round((Date.now() - new Date(row.updated_at).getTime()) / 1000);
|
|
134
|
+
return {
|
|
135
|
+
mcpContent: [
|
|
136
|
+
{ type: "text", text: `Latest screen frame — seq ${row.seq}, ${row.width ?? "?"}px wide, ${ageSec}s old.` },
|
|
137
|
+
{ type: "image", data: row.image_jpeg, mimeType: "image/jpeg" },
|
|
138
|
+
],
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export const actionTools: MosaddTool[] = [
|
|
143
|
+
{
|
|
144
|
+
// RFC 0001: channel-agnostic capability (link is sent over ANY channel), so it
|
|
145
|
+
// lives in the `comms_` namespace rather than a channel `m<MODULE>_` prefix.
|
|
146
|
+
// A dedicated `mACT` module (create/get/status) is a possible RFC follow-up.
|
|
147
|
+
name: "comms_action_create",
|
|
148
|
+
requires: "network",
|
|
149
|
+
description:
|
|
150
|
+
"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 — 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).",
|
|
151
|
+
inputSchema: action_create_input,
|
|
152
|
+
handler: action_create as MosaddTool["handler"],
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "comms_action_frame_get",
|
|
156
|
+
requires: "network",
|
|
157
|
+
description:
|
|
158
|
+
"See the LATEST screen frame from a 'screen_share' action you created (pass the action_id from comms_action_create). Returns the current screenshot AS AN IMAGE you can look at, plus how old it is. The recipient must have opened the link and clicked 'share screen' first. Poll this every few seconds to watch live. VIEW ONLY — you cannot click or control their screen. Returns a 'no frame yet' note until they start sharing.",
|
|
159
|
+
inputSchema: action_frame_get_input,
|
|
160
|
+
handler: action_frame_get as MosaddTool["handler"],
|
|
161
|
+
},
|
|
162
|
+
];
|