@mosadd/mcp 3.0.0-alpha.0 → 3.0.0-alpha.10
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/README.md +127 -116
- package/dist/bin/login.d.ts +13 -0
- package/dist/bin/login.js +110 -0
- package/dist/bin/mcp.js +36 -1
- package/dist/chunk-6EPYADVR.js +2095 -0
- package/dist/chunk-Z7WR52GE.js +45 -0
- package/dist/index.d.ts +46 -4
- package/dist/index.js +6 -3
- package/package.json +11 -7
- package/src/__tests__/golden-path.test.ts +137 -132
- package/src/__tests__/integration.test.ts +178 -175
- package/src/__tests__/mdm-e2ee.test.ts +178 -149
- package/src/__tests__/mtalk.test.ts +122 -0
- package/src/__tests__/server.test.ts +67 -67
- package/src/bin/login.ts +138 -0
- package/src/bin/mcp.ts +97 -47
- package/src/config.ts +66 -0
- package/src/crypto/mdm-session.ts +403 -378
- package/src/index.ts +19 -17
- package/src/observability/sentry.ts +79 -79
- package/src/providers/memory-voice.ts +79 -0
- package/src/providers/supabase-dm.ts +117 -117
- package/src/providers/supabase-voice.ts +91 -0
- package/src/providers/supabase.ts +49 -9
- package/src/server.ts +105 -103
- package/src/tools/capabilities.ts +68 -68
- package/src/tools/index.ts +53 -37
- package/src/tools/knowledge.ts +191 -0
- package/src/tools/mail.ts +371 -89
- package/src/tools/mcall.ts +216 -0
- package/src/tools/mdm-voice.ts +206 -0
- package/src/tools/mdm.ts +448 -379
- package/src/tools/mirc-edge.ts +190 -0
- package/src/tools/mirc-members.ts +177 -177
- package/src/tools/mirc-messages.ts +156 -0
- package/src/tools/mirc.ts +170 -170
- package/src/tools/mroom-messages.ts +142 -142
- package/src/tools/mroom.ts +221 -189
- package/src/tools/mtalk.ts +121 -0
- package/src/tools/murl.ts +141 -0
- package/src/types.ts +85 -79
- package/src/voice/floor.ts +132 -0
- package/dist/chunk-25L536JZ.js +0 -1182
package/src/tools/mroom.ts
CHANGED
|
@@ -1,189 +1,221 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* mROOM — Ephemeral rooms with no-account join links.
|
|
3
|
-
*
|
|
4
|
-
* USP: anyone can join via a short-lived link without signing up. Distinct from
|
|
5
|
-
* mIRC (persistent channels for known users). Use cases: customer support drop-in
|
|
6
|
-
* call, live-stream after-party, anonymous tipline, incident bridge.
|
|
7
|
-
*
|
|
8
|
-
* Phase 1 alpha: wired to
|
|
9
|
-
* Edge Functions.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
14
|
-
import { invokeFunction, readSupabaseEnv } from "../providers/supabase.js";
|
|
15
|
-
|
|
16
|
-
// ---- Schemas ----
|
|
17
|
-
|
|
18
|
-
const RoomId = z.string().min(1).describe("Private room id (UUID).");
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.
|
|
56
|
-
.
|
|
57
|
-
|
|
58
|
-
.
|
|
59
|
-
.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
1
|
+
/**
|
|
2
|
+
* mROOM — Ephemeral rooms with no-account join links.
|
|
3
|
+
*
|
|
4
|
+
* USP: anyone can join via a short-lived link without signing up. Distinct from
|
|
5
|
+
* mIRC (persistent channels for known users). Use cases: customer support drop-in
|
|
6
|
+
* call, live-stream after-party, anonymous tipline, incident bridge.
|
|
7
|
+
*
|
|
8
|
+
* Phase 1 alpha: wired to the mosadd backend's `privroom-manage` + `privroom-guest-token`
|
|
9
|
+
* Edge Functions.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
14
|
+
import { invokeFunction, readSupabaseEnv } from "../providers/supabase.js";
|
|
15
|
+
|
|
16
|
+
// ---- Schemas ----
|
|
17
|
+
|
|
18
|
+
const RoomId = z.string().min(1).describe("Private room id (UUID).");
|
|
19
|
+
|
|
20
|
+
const mROOM_voice_join_input = z.object({
|
|
21
|
+
room_id: RoomId,
|
|
22
|
+
video: z.boolean().optional().describe("Request video instead of audio-only. Default false."),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const mROOM_create_input = z.object({
|
|
26
|
+
ttl_seconds: z
|
|
27
|
+
.number()
|
|
28
|
+
.int()
|
|
29
|
+
.min(60)
|
|
30
|
+
.max(86_400 * 30)
|
|
31
|
+
.default(86_400)
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Time-to-live in seconds. Defaults to 24 h. Max 30 days."),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const mROOM_join_input = z.object({
|
|
37
|
+
room_id: RoomId,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const mROOM_close_input = z.object({
|
|
41
|
+
room_id: RoomId,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const mROOM_leave_input = z.object({
|
|
45
|
+
room_id: RoomId,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const mROOM_list_input = z.object({});
|
|
49
|
+
|
|
50
|
+
const mROOM_create_guest_link_input = z.object({
|
|
51
|
+
room_id: RoomId,
|
|
52
|
+
display_name: z
|
|
53
|
+
.string()
|
|
54
|
+
.min(1)
|
|
55
|
+
.max(80)
|
|
56
|
+
.describe("Display name the guest will appear under. They never sign up — this is the only identifier."),
|
|
57
|
+
ttl_seconds: z
|
|
58
|
+
.number()
|
|
59
|
+
.int()
|
|
60
|
+
.min(60)
|
|
61
|
+
.max(86_400 * 7)
|
|
62
|
+
.default(3600)
|
|
63
|
+
.optional()
|
|
64
|
+
.describe("How long the guest token is valid. Default 1 h, max 7 days."),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// ---- Handlers ----
|
|
68
|
+
|
|
69
|
+
async function mROOM_create(
|
|
70
|
+
input: z.infer<typeof mROOM_create_input>,
|
|
71
|
+
ctx: MosaddToolContext,
|
|
72
|
+
): Promise<{ room: unknown }> {
|
|
73
|
+
readSupabaseEnv();
|
|
74
|
+
const expires_at = new Date(Date.now() + (input.ttl_seconds ?? 86_400) * 1000).toISOString();
|
|
75
|
+
ctx.log("debug", "mROOM_create invoking privroom-manage", { expires_at });
|
|
76
|
+
return await invokeFunction<{ room: unknown }>("privroom-manage", {
|
|
77
|
+
action: "create",
|
|
78
|
+
expires_at,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function mROOM_join(
|
|
83
|
+
input: z.infer<typeof mROOM_join_input>,
|
|
84
|
+
ctx: MosaddToolContext,
|
|
85
|
+
): Promise<{ joined: true; room_id: string }> {
|
|
86
|
+
readSupabaseEnv();
|
|
87
|
+
ctx.log("debug", "mROOM_join invoking privroom-manage", { room_id: input.room_id });
|
|
88
|
+
return await invokeFunction<{ joined: true; room_id: string }>("privroom-manage", {
|
|
89
|
+
action: "join",
|
|
90
|
+
room_id: input.room_id,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function mROOM_close(
|
|
95
|
+
input: z.infer<typeof mROOM_close_input>,
|
|
96
|
+
ctx: MosaddToolContext,
|
|
97
|
+
): Promise<{ closed: true; room_id: string }> {
|
|
98
|
+
readSupabaseEnv();
|
|
99
|
+
ctx.log("debug", "mROOM_close invoking privroom-manage", { room_id: input.room_id });
|
|
100
|
+
return await invokeFunction<{ closed: true; room_id: string }>("privroom-manage", {
|
|
101
|
+
action: "close",
|
|
102
|
+
room_id: input.room_id,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function mROOM_leave(
|
|
107
|
+
input: z.infer<typeof mROOM_leave_input>,
|
|
108
|
+
ctx: MosaddToolContext,
|
|
109
|
+
): Promise<{ left: true; room_id: string }> {
|
|
110
|
+
readSupabaseEnv();
|
|
111
|
+
ctx.log("debug", "mROOM_leave invoking privroom-manage", { room_id: input.room_id });
|
|
112
|
+
return await invokeFunction<{ left: true; room_id: string }>("privroom-manage", {
|
|
113
|
+
action: "leave",
|
|
114
|
+
room_id: input.room_id,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function mROOM_list(
|
|
119
|
+
_input: z.infer<typeof mROOM_list_input>,
|
|
120
|
+
ctx: MosaddToolContext,
|
|
121
|
+
): Promise<{ rooms: unknown[] }> {
|
|
122
|
+
readSupabaseEnv();
|
|
123
|
+
ctx.log("debug", "mROOM_list invoking privroom-manage");
|
|
124
|
+
return await invokeFunction<{ rooms: unknown[] }>("privroom-manage", { action: "list" });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function mROOM_create_guest_link(
|
|
128
|
+
input: z.infer<typeof mROOM_create_guest_link_input>,
|
|
129
|
+
ctx: MosaddToolContext,
|
|
130
|
+
): Promise<{ token: string; join_url: string; expires_at: string }> {
|
|
131
|
+
readSupabaseEnv();
|
|
132
|
+
ctx.log("debug", "mROOM_create_guest_link invoking privroom-guest-token", {
|
|
133
|
+
room_id: input.room_id,
|
|
134
|
+
});
|
|
135
|
+
const result = await invokeFunction<{ token: string; expires_at: string }>("privroom-guest-token", {
|
|
136
|
+
room_id: input.room_id,
|
|
137
|
+
display_name: input.display_name,
|
|
138
|
+
ttl_seconds: input.ttl_seconds ?? 3600,
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
token: result.token,
|
|
142
|
+
join_url: `https://mosadd.com/r/${input.room_id}?t=${result.token}`,
|
|
143
|
+
expires_at: result.expires_at,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function mROOM_voice_join(
|
|
148
|
+
input: z.infer<typeof mROOM_voice_join_input>,
|
|
149
|
+
ctx: MosaddToolContext,
|
|
150
|
+
): Promise<{ room_id: string; token: string; url: string; identity: string; mode: "audio" | "video" }> {
|
|
151
|
+
// Full-duplex GROUP voice in an mROOM. Audio rides the VoiceProvider's media
|
|
152
|
+
// transport (LiveKit by default) — same minting path as mTALK/mDM voice, but
|
|
153
|
+
// no floor control (everyone can talk). Join the membership first via
|
|
154
|
+
// mROOM_join (or a guest link) so you're authorized in the room.
|
|
155
|
+
const ticket = await ctx.providers.voice.joinTicket(input.room_id);
|
|
156
|
+
ctx.log("debug", "mROOM_voice_join", { room_id: ticket.roomId, identity: ticket.identity });
|
|
157
|
+
return {
|
|
158
|
+
room_id: ticket.roomId,
|
|
159
|
+
token: ticket.token,
|
|
160
|
+
url: ticket.url,
|
|
161
|
+
identity: ticket.identity,
|
|
162
|
+
mode: input.video ? "video" : "audio",
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ---- Registration ----
|
|
167
|
+
|
|
168
|
+
export const mroomTools: MosaddTool[] = [
|
|
169
|
+
{
|
|
170
|
+
name: "mROOM_create",
|
|
171
|
+
requires: "network",
|
|
172
|
+
description:
|
|
173
|
+
"Create an ephemeral private room. Auto-joins the creator. Defaults to 24 h TTL — pass ttl_seconds to override.",
|
|
174
|
+
inputSchema: mROOM_create_input,
|
|
175
|
+
handler: mROOM_create as MosaddTool["handler"],
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "mROOM_create_guest_link",
|
|
179
|
+
requires: "network",
|
|
180
|
+
description:
|
|
181
|
+
"USP: Generate a short-lived join link that lets a person enter the room WITHOUT a mosadd account. Returns { token, join_url, expires_at }. Share the join_url out-of-band (email, SMS, QR). Use case: support call, live-stream after-party, anonymous tipline.",
|
|
182
|
+
inputSchema: mROOM_create_guest_link_input,
|
|
183
|
+
handler: mROOM_create_guest_link as MosaddTool["handler"],
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: "mROOM_join",
|
|
187
|
+
requires: "network",
|
|
188
|
+
description: "Join an existing private room (current user, not a guest).",
|
|
189
|
+
inputSchema: mROOM_join_input,
|
|
190
|
+
handler: mROOM_join as MosaddTool["handler"],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "mROOM_leave",
|
|
194
|
+
requires: "network",
|
|
195
|
+
description: "Leave a private room.",
|
|
196
|
+
inputSchema: mROOM_leave_input,
|
|
197
|
+
handler: mROOM_leave as MosaddTool["handler"],
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "mROOM_close",
|
|
201
|
+
requires: "network",
|
|
202
|
+
description: "Close a private room and remove all members. Founder only.",
|
|
203
|
+
inputSchema: mROOM_close_input,
|
|
204
|
+
handler: mROOM_close as MosaddTool["handler"],
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "mROOM_list",
|
|
208
|
+
requires: "network",
|
|
209
|
+
description: "List private rooms the current user belongs to.",
|
|
210
|
+
inputSchema: mROOM_list_input,
|
|
211
|
+
handler: mROOM_list as MosaddTool["handler"],
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "mROOM_voice_join",
|
|
215
|
+
requires: "network",
|
|
216
|
+
description:
|
|
217
|
+
"Join an mROOM's full-duplex GROUP voice (everyone can talk — no walkie-talkie floor; that's mTALK). Returns media credentials (token + url) for the room's audio/video transport. Be a room member first (mROOM_join or a guest link). Set video:true for video.",
|
|
218
|
+
inputSchema: mROOM_voice_join_input,
|
|
219
|
+
handler: mROOM_voice_join as MosaddTool["handler"],
|
|
220
|
+
},
|
|
221
|
+
];
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mTALK — Push-to-Talk (the kill feature).
|
|
3
|
+
*
|
|
4
|
+
* Half-duplex voice over a real-time room, with a walkie-talkie floor
|
|
5
|
+
* discipline: one transmitter at a time, others queue, and an anti-hog timeout
|
|
6
|
+
* keeps the floor moving. An AGENT uses these tools to: spin up a PTT room, get
|
|
7
|
+
* join credentials for a human/bot client, and drive the floor (press/release
|
|
8
|
+
* PTT, see who's transmitting). The audio itself flows over the media transport
|
|
9
|
+
* the VoiceProvider points at (LiveKit by default); these tools coordinate WHO
|
|
10
|
+
* may transmit, which is the part that makes a PTT channel work.
|
|
11
|
+
*
|
|
12
|
+
* Transport-agnostic: the same tools drive an off-grid radio host, where the
|
|
13
|
+
* floor is the physical RF channel (the host injects its own VoiceProvider).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { z } from "zod";
|
|
17
|
+
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
18
|
+
|
|
19
|
+
const RoomLabel = z
|
|
20
|
+
.string()
|
|
21
|
+
.min(1)
|
|
22
|
+
.max(120)
|
|
23
|
+
.regex(/^[a-zA-Z0-9._-]+$/)
|
|
24
|
+
.describe("Human-readable room label (e.g. 'ops', 'field-team'). Used to derive a stable room id.");
|
|
25
|
+
|
|
26
|
+
const RoomId = z.string().min(1).describe("Room id returned by mTALK_open.");
|
|
27
|
+
|
|
28
|
+
const mTALK_open_input = z.object({
|
|
29
|
+
label: RoomLabel.optional().describe("Optional label; defaults to a personal room."),
|
|
30
|
+
});
|
|
31
|
+
const mTALK_join_input = z.object({ room_id: RoomId });
|
|
32
|
+
const mTALK_press_input = z.object({ room_id: RoomId });
|
|
33
|
+
const mTALK_release_input = z.object({ room_id: RoomId });
|
|
34
|
+
const mTALK_state_input = z.object({ room_id: RoomId });
|
|
35
|
+
|
|
36
|
+
async function mTALK_open(
|
|
37
|
+
input: z.infer<typeof mTALK_open_input>,
|
|
38
|
+
ctx: MosaddToolContext,
|
|
39
|
+
): Promise<{ room_id: string }> {
|
|
40
|
+
const { roomId } = await ctx.providers.voice.createRoom(input.label);
|
|
41
|
+
ctx.log("debug", "mTALK_open", { room_id: roomId });
|
|
42
|
+
return { room_id: roomId };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function mTALK_join(
|
|
46
|
+
input: z.infer<typeof mTALK_join_input>,
|
|
47
|
+
ctx: MosaddToolContext,
|
|
48
|
+
): Promise<{ room_id: string; token: string; url: string; identity: string }> {
|
|
49
|
+
const ticket = await ctx.providers.voice.joinTicket(input.room_id);
|
|
50
|
+
ctx.log("debug", "mTALK_join", { room_id: ticket.roomId, identity: ticket.identity });
|
|
51
|
+
return { room_id: ticket.roomId, token: ticket.token, url: ticket.url, identity: ticket.identity };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function mTALK_press(
|
|
55
|
+
input: z.infer<typeof mTALK_press_input>,
|
|
56
|
+
ctx: MosaddToolContext,
|
|
57
|
+
): Promise<{ granted: boolean; position: number; holder: string | null; queue: string[] }> {
|
|
58
|
+
const res = await ctx.providers.voice.requestFloor(input.room_id);
|
|
59
|
+
ctx.log("debug", "mTALK_press", { room_id: input.room_id, granted: res.granted, position: res.position });
|
|
60
|
+
return { granted: res.granted, position: res.position, holder: res.snapshot.holder, queue: res.snapshot.queue };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function mTALK_release(
|
|
64
|
+
input: z.infer<typeof mTALK_release_input>,
|
|
65
|
+
ctx: MosaddToolContext,
|
|
66
|
+
): Promise<{ holder: string | null; queue: string[] }> {
|
|
67
|
+
const snap = await ctx.providers.voice.releaseFloor(input.room_id);
|
|
68
|
+
ctx.log("debug", "mTALK_release", { room_id: input.room_id, holder: snap.holder });
|
|
69
|
+
return { holder: snap.holder, queue: snap.queue };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function mTALK_state(
|
|
73
|
+
input: z.infer<typeof mTALK_state_input>,
|
|
74
|
+
ctx: MosaddToolContext,
|
|
75
|
+
): Promise<{ holder: string | null; since: string | null; queue: string[] }> {
|
|
76
|
+
const snap = await ctx.providers.voice.floorState(input.room_id);
|
|
77
|
+
return { holder: snap.holder, since: snap.since, queue: snap.queue };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const mtalkTools: MosaddTool[] = [
|
|
81
|
+
{
|
|
82
|
+
name: "mTALK_open",
|
|
83
|
+
requires: "any",
|
|
84
|
+
description:
|
|
85
|
+
"Open (or get) a push-to-talk room. Returns a stable room_id. Pass an optional label to share a named room (e.g. 'ops'); omit it for a personal room. Works over network (LiveKit) or off-grid radio depending on the host.",
|
|
86
|
+
inputSchema: mTALK_open_input,
|
|
87
|
+
handler: mTALK_open as MosaddTool["handler"],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "mTALK_join",
|
|
91
|
+
requires: "network",
|
|
92
|
+
description:
|
|
93
|
+
"Get credentials (token + media URL) to join a PTT room's audio transport. Hand these to a human or bot client to connect. The agent itself drives the floor with mTALK_press / mTALK_release.",
|
|
94
|
+
inputSchema: mTALK_join_input,
|
|
95
|
+
handler: mTALK_join as MosaddTool["handler"],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "mTALK_press",
|
|
99
|
+
requires: "any",
|
|
100
|
+
description:
|
|
101
|
+
"Press push-to-talk: request the floor in a room. Half-duplex — if no one is transmitting you are GRANTED the floor (granted=true) and may speak; otherwise you are queued FIFO and `position` tells you where you are. Call mTALK_release when done. A holder who never releases is auto-bumped after the anti-hog timeout.",
|
|
102
|
+
inputSchema: mTALK_press_input,
|
|
103
|
+
handler: mTALK_press as MosaddTool["handler"],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "mTALK_release",
|
|
107
|
+
requires: "any",
|
|
108
|
+
description:
|
|
109
|
+
"Release push-to-talk: give up the floor (or cancel your queued request). If you held the floor, the next participant in the queue is promoted automatically. Returns the new holder and queue.",
|
|
110
|
+
inputSchema: mTALK_release_input,
|
|
111
|
+
handler: mTALK_release as MosaddTool["handler"],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "mTALK_state",
|
|
115
|
+
requires: "any",
|
|
116
|
+
description:
|
|
117
|
+
"Read a PTT room's floor state without changing it: who is currently transmitting (holder), since when, and the waiting queue.",
|
|
118
|
+
inputSchema: mTALK_state_input,
|
|
119
|
+
handler: mTALK_state as MosaddTool["handler"],
|
|
120
|
+
},
|
|
121
|
+
];
|