mcp-voice-hooks 1.0.6 → 1.0.8
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/.claude/hooks/pre-speak-hook.sh +3 -0
- package/.claude/hooks/pre-tool-hook.sh +1 -31
- package/.claude/hooks/pre-wait-hook.sh +3 -0
- package/.claude/hooks/stop-hook.sh +1 -30
- package/bin/cli.js +20 -43
- package/dist/unified-server.js +208 -3
- package/dist/unified-server.js.map +1 -1
- package/package.json +5 -3
- package/.claude/hooks/post-tool-voice-hook.sh +0 -10
@@ -1,33 +1,3 @@
|
|
1
1
|
#!/bin/bash
|
2
|
-
|
3
|
-
# Pre-Tool Hook - Checks for pending utterances before allowing tool execution
|
4
|
-
# Forces Claude to use dequeue_utterances tool if there are pending utterances
|
5
|
-
|
6
|
-
# Get port from environment variable or use default
|
7
2
|
PORT="${MCP_VOICE_HOOKS_PORT:-5111}"
|
8
|
-
|
9
|
-
# Check has-pending-utterances endpoint
|
10
|
-
response=$(curl -s http://localhost:${PORT}/api/has-pending-utterances 2>/dev/null)
|
11
|
-
|
12
|
-
if [ $? -ne 0 ]; then
|
13
|
-
# Server not available, allow tool execution
|
14
|
-
echo '{"decision": "approve"}'
|
15
|
-
exit 0
|
16
|
-
fi
|
17
|
-
|
18
|
-
# Extract pending status
|
19
|
-
hasPending=$(echo "$response" | jq -r '.hasPending')
|
20
|
-
pendingCount=$(echo "$response" | jq -r '.pendingCount')
|
21
|
-
|
22
|
-
if [ "$hasPending" = "true" ]; then
|
23
|
-
# There are pending utterances, block tool execution
|
24
|
-
cat <<EOF
|
25
|
-
{
|
26
|
-
"decision": "block",
|
27
|
-
"reason": "There are $pendingCount pending voice utterances. Please use dequeue_utterances to process them first."
|
28
|
-
}
|
29
|
-
EOF
|
30
|
-
else
|
31
|
-
# No pending utterances, allow tool execution
|
32
|
-
echo '{"decision": "approve"}'
|
33
|
-
fi
|
3
|
+
curl -s -X POST http://localhost:${PORT}/api/hooks/pre-tool || echo '{"decision": "approve"}'
|
@@ -1,32 +1,3 @@
|
|
1
1
|
#!/bin/bash
|
2
|
-
|
3
|
-
# Stop Hook - Intelligently decides whether to wait for voice input
|
4
|
-
# Checks if there have been any utterances since the last timeout
|
5
|
-
|
6
|
-
# Get port from environment variable or use default
|
7
2
|
PORT="${MCP_VOICE_HOOKS_PORT:-5111}"
|
8
|
-
|
9
|
-
# Check should-wait endpoint
|
10
|
-
response=$(curl -s http://localhost:${PORT}/api/should-wait 2>/dev/null)
|
11
|
-
|
12
|
-
if [ $? -ne 0 ]; then
|
13
|
-
# Server not available, allow stop
|
14
|
-
echo '{"decision": "approve"}'
|
15
|
-
exit 0
|
16
|
-
fi
|
17
|
-
|
18
|
-
# Extract shouldWait boolean
|
19
|
-
shouldWait=$(echo "$response" | jq -r '.shouldWait')
|
20
|
-
|
21
|
-
if [ "$shouldWait" = "true" ]; then
|
22
|
-
# There have been utterances since last timeout, block and ask to wait
|
23
|
-
cat <<EOF
|
24
|
-
{
|
25
|
-
"decision": "block",
|
26
|
-
"reason": "Assistant tried to end its response. Stopping is not allowed without first checking for voice input. Assistant should now use wait_for_utterance to check for voice input"
|
27
|
-
}
|
28
|
-
EOF
|
29
|
-
else
|
30
|
-
# No utterances since last timeout, allow stop
|
31
|
-
echo '{"decision": "approve", "reason": "No utterances since last timeout"}'
|
32
|
-
fi
|
3
|
+
curl -s -X POST http://localhost:${PORT}/api/hooks/stop || echo '{"decision": "approve"}'
|
package/bin/cli.js
CHANGED
@@ -163,15 +163,22 @@ async function configureClaudeCodeSettings() {
|
|
163
163
|
"command": "sh ~/.mcp-voice-hooks/hooks/pre-tool-hook.sh"
|
164
164
|
}
|
165
165
|
]
|
166
|
-
}
|
167
|
-
|
168
|
-
|
166
|
+
},
|
167
|
+
{
|
168
|
+
"matcher": "^mcp__voice-hooks__speak$",
|
169
|
+
"hooks": [
|
170
|
+
{
|
171
|
+
"type": "command",
|
172
|
+
"command": "sh ~/.mcp-voice-hooks/hooks/pre-speak-hook.sh"
|
173
|
+
}
|
174
|
+
]
|
175
|
+
},
|
169
176
|
{
|
170
|
-
"matcher": "^mcp__voice-
|
177
|
+
"matcher": "^mcp__voice-hooks__wait_for_utterance$",
|
171
178
|
"hooks": [
|
172
179
|
{
|
173
180
|
"type": "command",
|
174
|
-
"command": "sh ~/.mcp-voice-hooks/hooks/
|
181
|
+
"command": "sh ~/.mcp-voice-hooks/hooks/pre-wait-hook.sh"
|
175
182
|
}
|
176
183
|
]
|
177
184
|
}
|
@@ -199,49 +206,19 @@ async function configureClaudeCodeSettings() {
|
|
199
206
|
async function ensureHooksInstalled() {
|
200
207
|
const userDir = path.join(os.homedir(), '.mcp-voice-hooks');
|
201
208
|
const hooksDir = path.join(userDir, 'hooks');
|
202
|
-
const packageHooksDir = path.join(__dirname, '..', '.claude', 'hooks');
|
203
209
|
|
204
210
|
try {
|
205
|
-
|
206
|
-
if (!fs.existsSync(hooksDir)) {
|
207
|
-
fs.mkdirSync(hooksDir, { recursive: true });
|
208
|
-
console.log('🔧 Installing hooks for first time...');
|
209
|
-
}
|
211
|
+
console.log('🔄 Updating hooks to latest version...');
|
210
212
|
|
211
|
-
//
|
212
|
-
|
213
|
-
|
214
|
-
const hookFiles = fs.readdirSync(packageHooksDir).filter(file => file.endsWith('.sh'));
|
215
|
-
|
216
|
-
for (const hookFile of hookFiles) {
|
217
|
-
const sourcePath = path.join(packageHooksDir, hookFile);
|
218
|
-
const destPath = path.join(hooksDir, hookFile);
|
219
|
-
|
220
|
-
// Check if hook doesn't exist or is different
|
221
|
-
if (!fs.existsSync(destPath)) {
|
222
|
-
needsUpdate = true;
|
223
|
-
break;
|
224
|
-
}
|
225
|
-
|
226
|
-
const sourceContent = fs.readFileSync(sourcePath, 'utf8');
|
227
|
-
const destContent = fs.readFileSync(destPath, 'utf8');
|
228
|
-
|
229
|
-
if (sourceContent !== destContent) {
|
230
|
-
needsUpdate = true;
|
231
|
-
break;
|
232
|
-
}
|
233
|
-
}
|
213
|
+
// Always remove and recreate the hooks directory to ensure clean state
|
214
|
+
if (fs.existsSync(hooksDir)) {
|
215
|
+
fs.rmSync(hooksDir, { recursive: true, force: true });
|
234
216
|
}
|
235
217
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
console.log('✅ Hooks and settings updated');
|
241
|
-
} else {
|
242
|
-
// Even if hooks are up to date, ensure settings are correct
|
243
|
-
await configureClaudeCodeSettings();
|
244
|
-
}
|
218
|
+
// Recreate with latest hooks
|
219
|
+
await ensureUserDirectorySetup();
|
220
|
+
await configureClaudeCodeSettings();
|
221
|
+
console.log('✅ Hooks and settings updated');
|
245
222
|
} catch (error) {
|
246
223
|
// Silently continue if hooks can't be updated
|
247
224
|
console.warn('⚠️ Could not auto-update hooks:', error.message);
|
package/dist/unified-server.js
CHANGED
@@ -63,6 +63,8 @@ var UtteranceQueue = class {
|
|
63
63
|
var IS_MCP_MANAGED = process.argv.includes("--mcp-managed");
|
64
64
|
var queue = new UtteranceQueue();
|
65
65
|
var lastTimeoutTimestamp = null;
|
66
|
+
var lastToolUseTimestamp = null;
|
67
|
+
var lastSpeakTimestamp = null;
|
66
68
|
var app = express();
|
67
69
|
app.use(cors());
|
68
70
|
app.use(express.json());
|
@@ -196,6 +198,122 @@ app.get("/api/has-pending-utterances", (req, res) => {
|
|
196
198
|
pendingCount
|
197
199
|
});
|
198
200
|
});
|
201
|
+
app.post("/api/validate-action", (req, res) => {
|
202
|
+
const { action } = req.body;
|
203
|
+
const voiceResponsesEnabled = process.env.VOICE_RESPONSES_ENABLED === "true";
|
204
|
+
if (!action || !["tool-use", "stop"].includes(action)) {
|
205
|
+
res.status(400).json({ error: 'Invalid action. Must be "tool-use" or "stop"' });
|
206
|
+
return;
|
207
|
+
}
|
208
|
+
const pendingUtterances = queue.utterances.filter((u) => u.status === "pending");
|
209
|
+
if (pendingUtterances.length > 0) {
|
210
|
+
res.json({
|
211
|
+
allowed: false,
|
212
|
+
requiredAction: "dequeue_utterances",
|
213
|
+
reason: `${pendingUtterances.length} pending utterance(s) must be dequeued first. Please use dequeue_utterances to process them.`
|
214
|
+
});
|
215
|
+
return;
|
216
|
+
}
|
217
|
+
if (voiceResponsesEnabled) {
|
218
|
+
const deliveredUtterances = queue.utterances.filter((u) => u.status === "delivered");
|
219
|
+
if (deliveredUtterances.length > 0) {
|
220
|
+
res.json({
|
221
|
+
allowed: false,
|
222
|
+
requiredAction: "speak",
|
223
|
+
reason: `${deliveredUtterances.length} delivered utterance(s) require voice response. Please use the speak tool to respond before proceeding.`
|
224
|
+
});
|
225
|
+
return;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
if (action === "stop") {
|
229
|
+
const shouldWait = !lastTimeoutTimestamp || queue.utterances.some((u) => u.timestamp > lastTimeoutTimestamp);
|
230
|
+
if (shouldWait) {
|
231
|
+
res.json({
|
232
|
+
allowed: false,
|
233
|
+
requiredAction: "wait_for_utterance",
|
234
|
+
reason: "Assistant tried to end its response. Stopping is not allowed without first checking for voice input. Assistant should now use wait_for_utterance to check for voice input"
|
235
|
+
});
|
236
|
+
return;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
res.json({
|
240
|
+
allowed: true
|
241
|
+
});
|
242
|
+
});
|
243
|
+
function handleHookRequest(attemptedAction) {
|
244
|
+
const voiceResponsesEnabled = process.env.VOICE_RESPONSES_ENABLED === "true";
|
245
|
+
const pendingUtterances = queue.utterances.filter((u) => u.status === "pending");
|
246
|
+
if (pendingUtterances.length > 0) {
|
247
|
+
return {
|
248
|
+
decision: "block",
|
249
|
+
reason: `${pendingUtterances.length} pending utterance(s) must be dequeued first. Please use dequeue_utterances to process them.`
|
250
|
+
};
|
251
|
+
}
|
252
|
+
if (voiceResponsesEnabled) {
|
253
|
+
const deliveredUtterances = queue.utterances.filter((u) => u.status === "delivered");
|
254
|
+
if (deliveredUtterances.length > 0) {
|
255
|
+
if (attemptedAction === "speak") {
|
256
|
+
return { decision: "approve" };
|
257
|
+
}
|
258
|
+
return {
|
259
|
+
decision: "block",
|
260
|
+
reason: `${deliveredUtterances.length} delivered utterance(s) require voice response. Please use the speak tool to respond before proceeding.`
|
261
|
+
};
|
262
|
+
}
|
263
|
+
}
|
264
|
+
if (attemptedAction === "tool") {
|
265
|
+
lastToolUseTimestamp = /* @__PURE__ */ new Date();
|
266
|
+
return { decision: "approve" };
|
267
|
+
}
|
268
|
+
if (attemptedAction === "wait") {
|
269
|
+
if (voiceResponsesEnabled && lastToolUseTimestamp && (!lastSpeakTimestamp || lastSpeakTimestamp < lastToolUseTimestamp)) {
|
270
|
+
return {
|
271
|
+
decision: "block",
|
272
|
+
reason: "Assistant must speak after using tools. Please use the speak tool to respond before waiting for utterances."
|
273
|
+
};
|
274
|
+
}
|
275
|
+
return { decision: "approve" };
|
276
|
+
}
|
277
|
+
if (attemptedAction === "speak") {
|
278
|
+
return { decision: "approve" };
|
279
|
+
}
|
280
|
+
if (attemptedAction === "stop") {
|
281
|
+
if (voiceResponsesEnabled && lastToolUseTimestamp && (!lastSpeakTimestamp || lastSpeakTimestamp < lastToolUseTimestamp)) {
|
282
|
+
return {
|
283
|
+
decision: "block",
|
284
|
+
reason: "Assistant must speak after using tools. Please use the speak tool to respond before proceeding."
|
285
|
+
};
|
286
|
+
}
|
287
|
+
const shouldWait = !lastTimeoutTimestamp || queue.utterances.some((u) => u.timestamp > lastTimeoutTimestamp);
|
288
|
+
if (shouldWait) {
|
289
|
+
return {
|
290
|
+
decision: "block",
|
291
|
+
reason: "Assistant tried to end its response. Stopping is not allowed without first checking for voice input. Assistant should now use wait_for_utterance to check for voice input"
|
292
|
+
};
|
293
|
+
}
|
294
|
+
return {
|
295
|
+
decision: "approve",
|
296
|
+
reason: "No utterances since last timeout"
|
297
|
+
};
|
298
|
+
}
|
299
|
+
return { decision: "approve" };
|
300
|
+
}
|
301
|
+
app.post("/api/hooks/pre-tool", (_req, res) => {
|
302
|
+
const result = handleHookRequest("tool");
|
303
|
+
res.json(result);
|
304
|
+
});
|
305
|
+
app.post("/api/hooks/stop", (_req, res) => {
|
306
|
+
const result = handleHookRequest("stop");
|
307
|
+
res.json(result);
|
308
|
+
});
|
309
|
+
app.post("/api/hooks/pre-speak", (_req, res) => {
|
310
|
+
const result = handleHookRequest("speak");
|
311
|
+
res.json(result);
|
312
|
+
});
|
313
|
+
app.post("/api/hooks/pre-wait", (_req, res) => {
|
314
|
+
const result = handleHookRequest("wait");
|
315
|
+
res.json(result);
|
316
|
+
});
|
199
317
|
app.delete("/api/utterances", (req, res) => {
|
200
318
|
const clearedCount = queue.utterances.length;
|
201
319
|
queue.clear();
|
@@ -205,7 +323,35 @@ app.delete("/api/utterances", (req, res) => {
|
|
205
323
|
clearedCount
|
206
324
|
});
|
207
325
|
});
|
208
|
-
app.
|
326
|
+
app.post("/api/speak", async (req, res) => {
|
327
|
+
const { text } = req.body;
|
328
|
+
if (!text || !text.trim()) {
|
329
|
+
res.status(400).json({ error: "Text is required" });
|
330
|
+
return;
|
331
|
+
}
|
332
|
+
try {
|
333
|
+
await execAsync(`say -r 350 "${text.replace(/"/g, '\\"')}"`);
|
334
|
+
debugLog(`[Speak] Spoke text: "${text}"`);
|
335
|
+
const deliveredUtterances = queue.utterances.filter((u) => u.status === "delivered");
|
336
|
+
deliveredUtterances.forEach((u) => {
|
337
|
+
u.status = "responded";
|
338
|
+
debugLog(`[Queue] marked as responded: "${u.text}" [id: ${u.id}]`);
|
339
|
+
});
|
340
|
+
lastSpeakTimestamp = /* @__PURE__ */ new Date();
|
341
|
+
res.json({
|
342
|
+
success: true,
|
343
|
+
message: "Text spoken successfully",
|
344
|
+
respondedCount: deliveredUtterances.length
|
345
|
+
});
|
346
|
+
} catch (error) {
|
347
|
+
debugLog(`[Speak] Failed to speak text: ${error}`);
|
348
|
+
res.status(500).json({
|
349
|
+
error: "Failed to speak text",
|
350
|
+
details: error instanceof Error ? error.message : String(error)
|
351
|
+
});
|
352
|
+
}
|
353
|
+
});
|
354
|
+
app.get("/", (_req, res) => {
|
209
355
|
res.sendFile(path.join(__dirname, "..", "public", "index.html"));
|
210
356
|
});
|
211
357
|
var HTTP_PORT = process.env.MCP_VOICE_HOOKS_PORT ? parseInt(process.env.MCP_VOICE_HOOKS_PORT) : 5111;
|
@@ -213,6 +359,10 @@ app.listen(HTTP_PORT, () => {
|
|
213
359
|
console.log(`[HTTP] Server listening on http://localhost:${HTTP_PORT}`);
|
214
360
|
console.log(`[Mode] Running in ${IS_MCP_MANAGED ? "MCP-managed" : "standalone"} mode`);
|
215
361
|
});
|
362
|
+
function getVoiceResponseReminder() {
|
363
|
+
const voiceResponsesEnabled = process.env.VOICE_RESPONSES_ENABLED === "true";
|
364
|
+
return voiceResponsesEnabled ? "\n\nThe user has enabled voice responses, so use the 'speak' tool to respond to the user's voice input before proceeding." : "";
|
365
|
+
}
|
216
366
|
if (IS_MCP_MANAGED) {
|
217
367
|
console.log("[MCP] Initializing MCP server...");
|
218
368
|
const mcpServer = new Server(
|
@@ -258,6 +408,20 @@ if (IS_MCP_MANAGED) {
|
|
258
408
|
}
|
259
409
|
}
|
260
410
|
}
|
411
|
+
},
|
412
|
+
{
|
413
|
+
name: "speak",
|
414
|
+
description: "Speak text using text-to-speech and mark delivered utterances as responded",
|
415
|
+
inputSchema: {
|
416
|
+
type: "object",
|
417
|
+
properties: {
|
418
|
+
text: {
|
419
|
+
type: "string",
|
420
|
+
description: "The text to speak"
|
421
|
+
}
|
422
|
+
},
|
423
|
+
required: ["text"]
|
424
|
+
}
|
261
425
|
}
|
262
426
|
]
|
263
427
|
};
|
@@ -289,7 +453,7 @@ if (IS_MCP_MANAGED) {
|
|
289
453
|
type: "text",
|
290
454
|
text: `Dequeued ${data.utterances.length} utterance(s):
|
291
455
|
|
292
|
-
${data.utterances.reverse().map((u) => `"${u.text}" [time: ${new Date(u.timestamp).toISOString()}]`).join("\n")}`
|
456
|
+
${data.utterances.reverse().map((u) => `"${u.text}" [time: ${new Date(u.timestamp).toISOString()}]`).join("\n")}${getVoiceResponseReminder()}`
|
293
457
|
}
|
294
458
|
]
|
295
459
|
};
|
@@ -315,7 +479,7 @@ ${data.utterances.reverse().map((u) => `"${u.text}" [time: ${new Date(u.timestam
|
|
315
479
|
type: "text",
|
316
480
|
text: `Found ${data.count} utterance(s):
|
317
481
|
|
318
|
-
${utteranceTexts}`
|
482
|
+
${utteranceTexts}${getVoiceResponseReminder()}`
|
319
483
|
}
|
320
484
|
]
|
321
485
|
};
|
@@ -330,6 +494,47 @@ ${utteranceTexts}`
|
|
330
494
|
};
|
331
495
|
}
|
332
496
|
}
|
497
|
+
if (name === "speak") {
|
498
|
+
const text = args?.text;
|
499
|
+
if (!text || !text.trim()) {
|
500
|
+
return {
|
501
|
+
content: [
|
502
|
+
{
|
503
|
+
type: "text",
|
504
|
+
text: "Error: Text is required for speak tool"
|
505
|
+
}
|
506
|
+
],
|
507
|
+
isError: true
|
508
|
+
};
|
509
|
+
}
|
510
|
+
const response = await fetch(`http://localhost:${HTTP_PORT}/api/speak`, {
|
511
|
+
method: "POST",
|
512
|
+
headers: { "Content-Type": "application/json" },
|
513
|
+
body: JSON.stringify({ text })
|
514
|
+
});
|
515
|
+
const data = await response.json();
|
516
|
+
if (response.ok) {
|
517
|
+
return {
|
518
|
+
content: [
|
519
|
+
{
|
520
|
+
type: "text",
|
521
|
+
text: `Spoke: "${text}"
|
522
|
+
${data.respondedCount > 0 ? `Marked ${data.respondedCount} utterance(s) as responded.` : "No delivered utterances to mark as responded."}`
|
523
|
+
}
|
524
|
+
]
|
525
|
+
};
|
526
|
+
} else {
|
527
|
+
return {
|
528
|
+
content: [
|
529
|
+
{
|
530
|
+
type: "text",
|
531
|
+
text: `Error speaking text: ${data.error || "Unknown error"}`
|
532
|
+
}
|
533
|
+
],
|
534
|
+
isError: true
|
535
|
+
};
|
536
|
+
}
|
537
|
+
}
|
333
538
|
throw new Error(`Unknown tool: ${name}`);
|
334
539
|
} catch (error) {
|
335
540
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/unified-server.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport express from 'express';\nimport type { Request, Response } from 'express';\nimport cors from 'cors';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { randomUUID } from 'crypto';\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\nimport { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { debugLog } from './debug.ts';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Constants\nconst DEFAULT_WAIT_TIMEOUT_SECONDS = 30;\nconst MIN_WAIT_TIMEOUT_SECONDS = 30;\nconst MAX_WAIT_TIMEOUT_SECONDS = 60;\n\n// Promisified exec for async/await\nconst execAsync = promisify(exec);\n\n// Function to play a sound notification\nasync function playNotificationSound() {\n try {\n // Use macOS system sound\n await execAsync('afplay /System/Library/Sounds/Funk.aiff');\n debugLog('[Sound] Played notification sound');\n } catch (error) {\n debugLog(`[Sound] Failed to play sound: ${error}`);\n // Don't throw - sound is not critical\n }\n}\n\n// Shared utterance queue\ninterface Utterance {\n id: string;\n text: string;\n timestamp: Date;\n status: 'pending' | 'delivered';\n}\n\nclass UtteranceQueue {\n utterances: Utterance[] = [];\n\n add(text: string, timestamp?: Date): Utterance {\n const utterance: Utterance = {\n id: randomUUID(),\n text: text.trim(),\n timestamp: timestamp || new Date(),\n status: 'pending'\n };\n\n this.utterances.push(utterance);\n debugLog(`[Queue] queued: \"${utterance.text}\"\t[id: ${utterance.id}]`);\n return utterance;\n }\n\n getRecent(limit: number = 10): Utterance[] {\n return this.utterances\n .sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime())\n .slice(0, limit);\n }\n\n markDelivered(id: string): void {\n const utterance = this.utterances.find(u => u.id === id);\n if (utterance) {\n utterance.status = 'delivered';\n debugLog(`[Queue] delivered: \"${utterance.text}\"\t[id: ${id}]`);\n }\n }\n\n clear(): void {\n const count = this.utterances.length;\n this.utterances = [];\n debugLog(`[Queue] Cleared ${count} utterances`);\n }\n}\n\n// Determine if we're running in MCP-managed mode\nconst IS_MCP_MANAGED = process.argv.includes('--mcp-managed');\n\n// Global state\nconst queue = new UtteranceQueue();\nlet lastTimeoutTimestamp: Date | null = null;\n\n// HTTP Server Setup (always created)\nconst app = express();\napp.use(cors());\napp.use(express.json());\napp.use(express.static(path.join(__dirname, '..', 'public')));\n\n// API Routes\napp.post('/api/potential-utterances', (req: Request, res: Response) => {\n const { text, timestamp } = req.body;\n\n if (!text || !text.trim()) {\n res.status(400).json({ error: 'Text is required' });\n return;\n }\n\n const parsedTimestamp = timestamp ? new Date(timestamp) : undefined;\n const utterance = queue.add(text, parsedTimestamp);\n res.json({\n success: true,\n utterance: {\n id: utterance.id,\n text: utterance.text,\n timestamp: utterance.timestamp,\n status: utterance.status,\n },\n });\n});\n\napp.get('/api/utterances', (req: Request, res: Response) => {\n const limit = parseInt(req.query.limit as string) || 10;\n const utterances = queue.getRecent(limit);\n\n res.json({\n utterances: utterances.map(u => ({\n id: u.id,\n text: u.text,\n timestamp: u.timestamp,\n status: u.status,\n })),\n });\n});\n\napp.get('/api/utterances/status', (req: Request, res: Response) => {\n const total = queue.utterances.length;\n const pending = queue.utterances.filter(u => u.status === 'pending').length;\n const delivered = queue.utterances.filter(u => u.status === 'delivered').length;\n\n res.json({\n total,\n pending,\n delivered,\n });\n});\n\n// MCP server integration\napp.post('/api/dequeue-utterances', (req: Request, res: Response) => {\n const { limit = 10 } = req.body;\n const pendingUtterances = queue.utterances\n .filter(u => u.status === 'pending')\n .sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime())\n .slice(0, limit);\n\n // Mark as delivered\n pendingUtterances.forEach(u => {\n queue.markDelivered(u.id);\n });\n\n res.json({\n success: true,\n utterances: pendingUtterances.map(u => ({\n text: u.text,\n timestamp: u.timestamp,\n })),\n });\n});\n\n// Wait for utterance endpoint\napp.post('/api/wait-for-utterances', async (req: Request, res: Response) => {\n const { seconds_to_wait = DEFAULT_WAIT_TIMEOUT_SECONDS } = req.body;\n const secondsToWait = Math.max(\n MIN_WAIT_TIMEOUT_SECONDS,\n Math.min(MAX_WAIT_TIMEOUT_SECONDS, seconds_to_wait)\n );\n const maxWaitMs = secondsToWait * 1000;\n const startTime = Date.now();\n\n debugLog(`[Server] Starting wait_for_utterance (${secondsToWait}s)`);\n\n // Check if we should return immediately\n if (lastTimeoutTimestamp) {\n const hasNewUtterances = queue.utterances.some(\n u => u.timestamp > lastTimeoutTimestamp!\n );\n if (!hasNewUtterances) {\n debugLog('[Server] No new utterances since last timeout, returning immediately');\n res.json({\n success: true,\n utterances: [],\n message: `No utterances found after waiting ${secondsToWait} seconds.`,\n waitTime: 0,\n });\n return;\n }\n }\n\n let firstTime = true;\n\n // Poll for utterances\n while (Date.now() - startTime < maxWaitMs) {\n const pendingUtterances = queue.utterances.filter(\n u => u.status === 'pending' &&\n (!lastTimeoutTimestamp || u.timestamp > lastTimeoutTimestamp)\n );\n\n if (pendingUtterances.length > 0) {\n // Found utterances - clear lastTimeoutTimestamp\n lastTimeoutTimestamp = null;\n\n // Sort by timestamp (oldest first)\n const sortedUtterances = pendingUtterances\n .sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());\n\n // Mark utterances as delivered\n sortedUtterances.forEach(u => {\n queue.markDelivered(u.id);\n });\n\n res.json({\n success: true,\n utterances: sortedUtterances.map(u => ({\n id: u.id,\n text: u.text,\n timestamp: u.timestamp,\n status: 'delivered', // They are now delivered\n })),\n count: pendingUtterances.length,\n waitTime: Date.now() - startTime,\n });\n return;\n }\n\n if (firstTime) {\n firstTime = false;\n // Play notification sound since we're about to start waiting\n await playNotificationSound();\n }\n\n // Wait 100ms before checking again\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n\n // Timeout reached - no utterances found\n lastTimeoutTimestamp = new Date();\n\n res.json({\n success: true,\n utterances: [],\n message: `No utterances found after waiting ${secondsToWait} seconds.`,\n waitTime: maxWaitMs,\n });\n});\n\n// API for the stop hook to check if it should wait\napp.get('/api/should-wait', (req: Request, res: Response) => {\n const shouldWait = !lastTimeoutTimestamp ||\n queue.utterances.some(u => u.timestamp > lastTimeoutTimestamp!);\n\n res.json({ shouldWait });\n});\n\n// API for pre-tool hook to check for pending utterances\napp.get('/api/has-pending-utterances', (req: Request, res: Response) => {\n const pendingCount = queue.utterances.filter(u => u.status === 'pending').length;\n const hasPending = pendingCount > 0;\n\n res.json({\n hasPending,\n pendingCount\n });\n});\n\n// API to clear all utterances\napp.delete('/api/utterances', (req: Request, res: Response) => {\n const clearedCount = queue.utterances.length;\n queue.clear();\n\n res.json({\n success: true,\n message: `Cleared ${clearedCount} utterances`,\n clearedCount\n });\n});\n\napp.get('/', (req: Request, res: Response) => {\n res.sendFile(path.join(__dirname, '..', 'public', 'index.html'));\n});\n\n// Start HTTP server\nconst HTTP_PORT = process.env.MCP_VOICE_HOOKS_PORT ? parseInt(process.env.MCP_VOICE_HOOKS_PORT) : 5111;\napp.listen(HTTP_PORT, () => {\n console.log(`[HTTP] Server listening on http://localhost:${HTTP_PORT}`);\n console.log(`[Mode] Running in ${IS_MCP_MANAGED ? 'MCP-managed' : 'standalone'} mode`);\n});\n\n// MCP Server Setup (only if MCP-managed)\nif (IS_MCP_MANAGED) {\n console.log('[MCP] Initializing MCP server...');\n\n const mcpServer = new Server(\n {\n name: 'voice-hooks',\n version: '1.0.0',\n },\n {\n capabilities: {\n tools: {},\n },\n }\n );\n\n // Tool handlers\n mcpServer.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: 'dequeue_utterances',\n description: 'Dequeue pending utterances and mark them as delivered',\n inputSchema: {\n type: 'object',\n properties: {\n limit: {\n type: 'number',\n description: 'Maximum number of utterances to dequeue (default: 10)',\n default: 10,\n },\n },\n },\n },\n {\n name: 'wait_for_utterance',\n description: 'Wait for an utterance to be available or until timeout. Returns immediately if no utterances since last timeout.',\n inputSchema: {\n type: 'object',\n properties: {\n seconds_to_wait: {\n type: 'number',\n description: `Maximum seconds to wait for an utterance (default: ${DEFAULT_WAIT_TIMEOUT_SECONDS}, min: ${MIN_WAIT_TIMEOUT_SECONDS}, max: ${MAX_WAIT_TIMEOUT_SECONDS})`,\n default: DEFAULT_WAIT_TIMEOUT_SECONDS,\n minimum: MIN_WAIT_TIMEOUT_SECONDS,\n maximum: MAX_WAIT_TIMEOUT_SECONDS,\n },\n },\n },\n },\n ],\n };\n });\n\n mcpServer.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n try {\n if (name === 'dequeue_utterances') {\n const limit = (args?.limit as number) ?? 10;\n const response = await fetch(`http://localhost:${HTTP_PORT}/api/dequeue-utterances`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ limit }),\n });\n\n const data = await response.json() as any;\n\n if (data.utterances.length === 0) {\n return {\n content: [\n {\n type: 'text',\n text: 'No recent utterances found.',\n },\n ],\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Dequeued ${data.utterances.length} utterance(s):\\n\\n${data.utterances.reverse().map((u: any) => `\"${u.text}\"\\t[time: ${new Date(u.timestamp).toISOString()}]`).join('\\n')\n }`,\n },\n ],\n };\n }\n\n if (name === 'wait_for_utterance') {\n const requestedSeconds = (args?.seconds_to_wait as number) ?? DEFAULT_WAIT_TIMEOUT_SECONDS;\n const secondsToWait = Math.max(\n MIN_WAIT_TIMEOUT_SECONDS,\n Math.min(MAX_WAIT_TIMEOUT_SECONDS, requestedSeconds)\n );\n debugLog(`[MCP] Calling wait_for_utterance with ${secondsToWait}s timeout`);\n\n const response = await fetch(`http://localhost:${HTTP_PORT}/api/wait-for-utterances`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ seconds_to_wait: secondsToWait }),\n });\n\n const data = await response.json() as any;\n\n if (data.utterances && data.utterances.length > 0) {\n const utteranceTexts = data.utterances\n .map((u: any) => `[${u.timestamp}] \"${u.text}\"`)\n .join('\\n');\n\n return {\n content: [\n {\n type: 'text',\n text: `Found ${data.count} utterance(s):\\n\\n${utteranceTexts}`,\n },\n ],\n };\n } else {\n return {\n content: [\n {\n type: 'text',\n text: data.message || `No utterances found after waiting ${secondsToWait} seconds.`,\n },\n ],\n };\n }\n }\n\n throw new Error(`Unknown tool: ${name}`);\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n isError: true,\n };\n }\n });\n\n // Connect via stdio\n const transport = new StdioServerTransport();\n mcpServer.connect(transport);\n console.log('[MCP] Server connected via stdio');\n} else {\n console.log('[MCP] Skipping MCP server initialization (not in MCP-managed mode)');\n}"],"mappings":";;;;;;AAEA,OAAO,aAAa;AAEpB,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AAEvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;AAGzC,IAAM,+BAA+B;AACrC,IAAM,2BAA2B;AACjC,IAAM,2BAA2B;AAGjC,IAAM,YAAY,UAAU,IAAI;AAGhC,eAAe,wBAAwB;AACrC,MAAI;AAEF,UAAM,UAAU,yCAAyC;AACzD,aAAS,mCAAmC;AAAA,EAC9C,SAAS,OAAO;AACd,aAAS,iCAAiC,KAAK,EAAE;AAAA,EAEnD;AACF;AAUA,IAAM,iBAAN,MAAqB;AAAA,EACnB,aAA0B,CAAC;AAAA,EAE3B,IAAI,MAAc,WAA6B;AAC7C,UAAM,YAAuB;AAAA,MAC3B,IAAI,WAAW;AAAA,MACf,MAAM,KAAK,KAAK;AAAA,MAChB,WAAW,aAAa,oBA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AAS;AAAA,cACP;AAAA,gBACE,MAAM;AAAA,gBACN,MAAM,KAAK,WAAW,qCAAqC,aAAa;AAAA,cAC1E;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,YAAM,IAAI,MAAM,iBAAiB,IAAI,EAAE;AAAA,IACzC,SAAS,OAAO;AACd,aAAO;AAAA,QACL,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,UACxE;AAAA,QACF;AAAA,QACA,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF,CAAC;AAGD,QAAM,YAAY,IAAI,qBAAqB;AAC3C,YAAU,QAAQ,SAAS;AAC3B,UAAQ,IAAI,kCAAkC;AAChD,OAAO;AACL,UAAQ,IAAI,oEAAoE;AAClF;","names":[]}
|
1
|
+
{"version":3,"sources":["../src/unified-server.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport express from 'express';\nimport type { Request, Response } from 'express';\nimport cors from 'cors';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { randomUUID } from 'crypto';\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\nimport { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { debugLog } from './debug.ts';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Constants\nconst DEFAULT_WAIT_TIMEOUT_SECONDS = 30;\nconst MIN_WAIT_TIMEOUT_SECONDS = 30;\nconst MAX_WAIT_TIMEOUT_SECONDS = 60;\n\n// Promisified exec for async/await\nconst execAsync = promisify(exec);\n\n// Function to play a sound notification\nasync function playNotificationSound() {\n try {\n // Use macOS system sound\n await execAsync('afplay /System/Library/Sounds/Funk.aiff');\n debugLog('[Sound] Played notification sound');\n } catch (error) {\n debugLog(`[Sound] Failed to play sound: ${error}`);\n // Don't throw - sound is not critical\n }\n}\n\n// Shared utterance queue\ninterface Utterance {\n id: string;\n text: string;\n timestamp: Date;\n status: 'pending' | 'delivered' | 'responded';\n}\n\nclass UtteranceQueue {\n utterances: Utterance[] = [];\n\n add(text: string, timestamp?: Date): Utterance {\n const utterance: Utterance = {\n id: randomUUID(),\n text: text.trim(),\n timestamp: timestamp || new Date(),\n status: 'pending'\n };\n\n this.utterances.push(utterance);\n debugLog(`[Queue] queued: \"${utterance.text}\"\t[id: ${utterance.id}]`);\n return utterance;\n }\n\n getRecent(limit: number = 10): Utterance[] {\n return this.utterances\n .sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime())\n .slice(0, limit);\n }\n\n markDelivered(id: string): void {\n const utterance = this.utterances.find(u => u.id === id);\n if (utterance) {\n utterance.status = 'delivered';\n debugLog(`[Queue] delivered: \"${utterance.text}\"\t[id: ${id}]`);\n }\n }\n\n clear(): void {\n const count = this.utterances.length;\n this.utterances = [];\n debugLog(`[Queue] Cleared ${count} utterances`);\n }\n}\n\n// Determine if we're running in MCP-managed mode\nconst IS_MCP_MANAGED = process.argv.includes('--mcp-managed');\n\n// Global state\nconst queue = new UtteranceQueue();\nlet lastTimeoutTimestamp: Date | null = null;\nlet lastToolUseTimestamp: Date | null = null;\nlet lastSpeakTimestamp: Date | null = null;\n\n// HTTP Server Setup (always created)\nconst app = express();\napp.use(cors());\napp.use(express.json());\napp.use(express.static(path.join(__dirname, '..', 'public')));\n\n// API Routes\napp.post('/api/potential-utterances', (req: Request, res: Response) => {\n const { text, timestamp } = req.body;\n\n if (!text || !text.trim()) {\n res.status(400).json({ error: 'Text is required' });\n return;\n }\n\n const parsedTimestamp = timestamp ? new Date(timestamp) : undefined;\n const utterance = queue.add(text, parsedTimestamp);\n res.json({\n success: true,\n utterance: {\n id: utterance.id,\n text: utterance.text,\n timestamp: utterance.timestamp,\n status: utterance.status,\n },\n });\n});\n\napp.get('/api/utterances', (req: Request, res: Response) => {\n const limit = parseInt(req.query.limit as string) || 10;\n const utterances = queue.getRecent(limit);\n\n res.json({\n utterances: utterances.map(u => ({\n id: u.id,\n text: u.text,\n timestamp: u.timestamp,\n status: u.status,\n })),\n });\n});\n\napp.get('/api/utterances/status', (req: Request, res: Response) => {\n const total = queue.utterances.length;\n const pending = queue.utterances.filter(u => u.status === 'pending').length;\n const delivered = queue.utterances.filter(u => u.status === 'delivered').length;\n\n res.json({\n total,\n pending,\n delivered,\n });\n});\n\n// MCP server integration\napp.post('/api/dequeue-utterances', (req: Request, res: Response) => {\n const { limit = 10 } = req.body;\n const pendingUtterances = queue.utterances\n .filter(u => u.status === 'pending')\n .sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime())\n .slice(0, limit);\n\n // Mark as delivered\n pendingUtterances.forEach(u => {\n queue.markDelivered(u.id);\n });\n\n res.json({\n success: true,\n utterances: pendingUtterances.map(u => ({\n text: u.text,\n timestamp: u.timestamp,\n })),\n });\n});\n\n// Wait for utterance endpoint\napp.post('/api/wait-for-utterances', async (req: Request, res: Response) => {\n const { seconds_to_wait = DEFAULT_WAIT_TIMEOUT_SECONDS } = req.body;\n const secondsToWait = Math.max(\n MIN_WAIT_TIMEOUT_SECONDS,\n Math.min(MAX_WAIT_TIMEOUT_SECONDS, seconds_to_wait)\n );\n const maxWaitMs = secondsToWait * 1000;\n const startTime = Date.now();\n\n debugLog(`[Server] Starting wait_for_utterance (${secondsToWait}s)`);\n\n // Check if we should return immediately\n if (lastTimeoutTimestamp) {\n const hasNewUtterances = queue.utterances.some(\n u => u.timestamp > lastTimeoutTimestamp!\n );\n if (!hasNewUtterances) {\n debugLog('[Server] No new utterances since last timeout, returning immediately');\n res.json({\n success: true,\n utterances: [],\n message: `No utterances found after waiting ${secondsToWait} seconds.`,\n waitTime: 0,\n });\n return;\n }\n }\n\n let firstTime = true;\n\n // Poll for utterances\n while (Date.now() - startTime < maxWaitMs) {\n const pendingUtterances = queue.utterances.filter(\n u => u.status === 'pending' &&\n (!lastTimeoutTimestamp || u.timestamp > lastTimeoutTimestamp)\n );\n\n if (pendingUtterances.length > 0) {\n // Found utterances - clear lastTimeoutTimestamp\n lastTimeoutTimestamp = null;\n\n // Sort by timestamp (oldest first)\n const sortedUtterances = pendingUtterances\n .sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());\n\n // Mark utterances as delivered\n sortedUtterances.forEach(u => {\n queue.markDelivered(u.id);\n });\n\n res.json({\n success: true,\n utterances: sortedUtterances.map(u => ({\n id: u.id,\n text: u.text,\n timestamp: u.timestamp,\n status: 'delivered', // They are now delivered\n })),\n count: pendingUtterances.length,\n waitTime: Date.now() - startTime,\n });\n return;\n }\n\n if (firstTime) {\n firstTime = false;\n // Play notification sound since we're about to start waiting\n await playNotificationSound();\n }\n\n // Wait 100ms before checking again\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n\n // Timeout reached - no utterances found\n lastTimeoutTimestamp = new Date();\n\n res.json({\n success: true,\n utterances: [],\n message: `No utterances found after waiting ${secondsToWait} seconds.`,\n waitTime: maxWaitMs,\n });\n});\n\n// API for the stop hook to check if it should wait\napp.get('/api/should-wait', (req: Request, res: Response) => {\n const shouldWait = !lastTimeoutTimestamp ||\n queue.utterances.some(u => u.timestamp > lastTimeoutTimestamp!);\n\n res.json({ shouldWait });\n});\n\n// API for pre-tool hook to check for pending utterances\napp.get('/api/has-pending-utterances', (req: Request, res: Response) => {\n const pendingCount = queue.utterances.filter(u => u.status === 'pending').length;\n const hasPending = pendingCount > 0;\n\n res.json({\n hasPending,\n pendingCount\n });\n});\n\n// Unified action validation endpoint\napp.post('/api/validate-action', (req: Request, res: Response) => {\n const { action } = req.body;\n const voiceResponsesEnabled = process.env.VOICE_RESPONSES_ENABLED === 'true';\n\n if (!action || !['tool-use', 'stop'].includes(action)) {\n res.status(400).json({ error: 'Invalid action. Must be \"tool-use\" or \"stop\"' });\n return;\n }\n\n // Check for pending utterances (both actions)\n const pendingUtterances = queue.utterances.filter(u => u.status === 'pending');\n if (pendingUtterances.length > 0) {\n res.json({\n allowed: false,\n requiredAction: 'dequeue_utterances',\n reason: `${pendingUtterances.length} pending utterance(s) must be dequeued first. Please use dequeue_utterances to process them.`\n });\n return;\n }\n\n // Check for delivered but unresponded utterances (when voice enabled)\n if (voiceResponsesEnabled) {\n const deliveredUtterances = queue.utterances.filter(u => u.status === 'delivered');\n if (deliveredUtterances.length > 0) {\n res.json({\n allowed: false,\n requiredAction: 'speak',\n reason: `${deliveredUtterances.length} delivered utterance(s) require voice response. Please use the speak tool to respond before proceeding.`\n });\n return;\n }\n }\n\n // For stop action, check if we should wait\n if (action === 'stop') {\n const shouldWait = !lastTimeoutTimestamp ||\n queue.utterances.some(u => u.timestamp > lastTimeoutTimestamp!);\n\n if (shouldWait) {\n res.json({\n allowed: false,\n requiredAction: 'wait_for_utterance',\n reason: 'Assistant tried to end its response. Stopping is not allowed without first checking for voice input. Assistant should now use wait_for_utterance to check for voice input'\n });\n return;\n }\n }\n\n // All checks passed - action is allowed\n res.json({\n allowed: true\n });\n});\n\n// Unified hook handler\nfunction handleHookRequest(attemptedAction: 'tool' | 'speak' | 'wait' | 'stop'): { decision: 'approve' | 'block', reason?: string } {\n const voiceResponsesEnabled = process.env.VOICE_RESPONSES_ENABLED === 'true';\n \n // 1. Check for pending utterances\n const pendingUtterances = queue.utterances.filter(u => u.status === 'pending');\n if (pendingUtterances.length > 0) {\n // Allow dequeue to proceed (dequeue doesn't go through hooks)\n return {\n decision: 'block',\n reason: `${pendingUtterances.length} pending utterance(s) must be dequeued first. Please use dequeue_utterances to process them.`\n };\n }\n \n // 2. Check for delivered utterances (when voice enabled)\n if (voiceResponsesEnabled) {\n const deliveredUtterances = queue.utterances.filter(u => u.status === 'delivered');\n if (deliveredUtterances.length > 0) {\n // Only allow speak to proceed\n if (attemptedAction === 'speak') {\n return { decision: 'approve' };\n }\n return {\n decision: 'block',\n reason: `${deliveredUtterances.length} delivered utterance(s) require voice response. Please use the speak tool to respond before proceeding.`\n };\n }\n }\n \n // 3. Handle tool action\n if (attemptedAction === 'tool') {\n lastToolUseTimestamp = new Date();\n return { decision: 'approve' };\n }\n \n // 4. Handle wait for utterance\n if (attemptedAction === 'wait') {\n if (voiceResponsesEnabled && lastToolUseTimestamp && \n (!lastSpeakTimestamp || lastSpeakTimestamp < lastToolUseTimestamp)) {\n return {\n decision: 'block',\n reason: 'Assistant must speak after using tools. Please use the speak tool to respond before waiting for utterances.'\n };\n }\n return { decision: 'approve' };\n }\n \n // 5. Handle speak\n if (attemptedAction === 'speak') {\n return { decision: 'approve' };\n }\n \n // 6. Handle stop\n if (attemptedAction === 'stop') {\n // Check if must speak after tool use\n if (voiceResponsesEnabled && lastToolUseTimestamp && \n (!lastSpeakTimestamp || lastSpeakTimestamp < lastToolUseTimestamp)) {\n return {\n decision: 'block',\n reason: 'Assistant must speak after using tools. Please use the speak tool to respond before proceeding.'\n };\n }\n \n // Check if should wait for utterances\n const shouldWait = !lastTimeoutTimestamp ||\n queue.utterances.some(u => u.timestamp > lastTimeoutTimestamp!);\n \n if (shouldWait) {\n return {\n decision: 'block',\n reason: 'Assistant tried to end its response. Stopping is not allowed without first checking for voice input. Assistant should now use wait_for_utterance to check for voice input'\n };\n }\n \n return {\n decision: 'approve',\n reason: 'No utterances since last timeout'\n };\n }\n \n // Default to approve (shouldn't reach here)\n return { decision: 'approve' };\n}\n\n// Dedicated hook endpoints that return in Claude's expected format\napp.post('/api/hooks/pre-tool', (_req: Request, res: Response) => {\n const result = handleHookRequest('tool');\n res.json(result);\n});\n\napp.post('/api/hooks/stop', (_req: Request, res: Response) => {\n const result = handleHookRequest('stop');\n res.json(result);\n});\n\n// Pre-speak hook endpoint\napp.post('/api/hooks/pre-speak', (_req: Request, res: Response) => {\n const result = handleHookRequest('speak');\n res.json(result);\n});\n\n// Pre-wait hook endpoint\napp.post('/api/hooks/pre-wait', (_req: Request, res: Response) => {\n const result = handleHookRequest('wait');\n res.json(result);\n});\n\n// API to clear all utterances\napp.delete('/api/utterances', (req: Request, res: Response) => {\n const clearedCount = queue.utterances.length;\n queue.clear();\n\n res.json({\n success: true,\n message: `Cleared ${clearedCount} utterances`,\n clearedCount\n });\n});\n\n// API for text-to-speech\napp.post('/api/speak', async (req: Request, res: Response) => {\n const { text } = req.body;\n\n if (!text || !text.trim()) {\n res.status(400).json({ error: 'Text is required' });\n return;\n }\n\n try {\n // Execute text-to-speech using macOS say command\n await execAsync(`say -r 350 \"${text.replace(/\"/g, '\\\\\"')}\"`);\n debugLog(`[Speak] Spoke text: \"${text}\"`);\n\n // Mark all delivered utterances as responded\n const deliveredUtterances = queue.utterances.filter(u => u.status === 'delivered');\n deliveredUtterances.forEach(u => {\n u.status = 'responded';\n debugLog(`[Queue] marked as responded: \"${u.text}\"\t[id: ${u.id}]`);\n });\n\n // Track that speak was called\n lastSpeakTimestamp = new Date();\n\n res.json({\n success: true,\n message: 'Text spoken successfully',\n respondedCount: deliveredUtterances.length\n });\n } catch (error) {\n debugLog(`[Speak] Failed to speak text: ${error}`);\n res.status(500).json({\n error: 'Failed to speak text',\n details: error instanceof Error ? error.message : String(error)\n });\n }\n});\n\napp.get('/', (_req: Request, res: Response) => {\n res.sendFile(path.join(__dirname, '..', 'public', 'index.html'));\n});\n\n// Start HTTP server\nconst HTTP_PORT = process.env.MCP_VOICE_HOOKS_PORT ? parseInt(process.env.MCP_VOICE_HOOKS_PORT) : 5111;\napp.listen(HTTP_PORT, () => {\n console.log(`[HTTP] Server listening on http://localhost:${HTTP_PORT}`);\n console.log(`[Mode] Running in ${IS_MCP_MANAGED ? 'MCP-managed' : 'standalone'} mode`);\n});\n\n// Helper function to get voice response reminder\nfunction getVoiceResponseReminder(): string {\n const voiceResponsesEnabled = process.env.VOICE_RESPONSES_ENABLED === 'true';\n return voiceResponsesEnabled\n ? '\\n\\nThe user has enabled voice responses, so use the \\'speak\\' tool to respond to the user\\'s voice input before proceeding.'\n : '';\n}\n\n// MCP Server Setup (only if MCP-managed)\nif (IS_MCP_MANAGED) {\n console.log('[MCP] Initializing MCP server...');\n\n const mcpServer = new Server(\n {\n name: 'voice-hooks',\n version: '1.0.0',\n },\n {\n capabilities: {\n tools: {},\n },\n }\n );\n\n // Tool handlers\n mcpServer.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: 'dequeue_utterances',\n description: 'Dequeue pending utterances and mark them as delivered',\n inputSchema: {\n type: 'object',\n properties: {\n limit: {\n type: 'number',\n description: 'Maximum number of utterances to dequeue (default: 10)',\n default: 10,\n },\n },\n },\n },\n {\n name: 'wait_for_utterance',\n description: 'Wait for an utterance to be available or until timeout. Returns immediately if no utterances since last timeout.',\n inputSchema: {\n type: 'object',\n properties: {\n seconds_to_wait: {\n type: 'number',\n description: `Maximum seconds to wait for an utterance (default: ${DEFAULT_WAIT_TIMEOUT_SECONDS}, min: ${MIN_WAIT_TIMEOUT_SECONDS}, max: ${MAX_WAIT_TIMEOUT_SECONDS})`,\n default: DEFAULT_WAIT_TIMEOUT_SECONDS,\n minimum: MIN_WAIT_TIMEOUT_SECONDS,\n maximum: MAX_WAIT_TIMEOUT_SECONDS,\n },\n },\n },\n },\n {\n name: 'speak',\n description: 'Speak text using text-to-speech and mark delivered utterances as responded',\n inputSchema: {\n type: 'object',\n properties: {\n text: {\n type: 'string',\n description: 'The text to speak',\n },\n },\n required: ['text'],\n },\n },\n ],\n };\n });\n\n mcpServer.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n try {\n if (name === 'dequeue_utterances') {\n const limit = (args?.limit as number) ?? 10;\n const response = await fetch(`http://localhost:${HTTP_PORT}/api/dequeue-utterances`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ limit }),\n });\n\n const data = await response.json() as any;\n\n if (data.utterances.length === 0) {\n return {\n content: [\n {\n type: 'text',\n text: 'No recent utterances found.',\n },\n ],\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Dequeued ${data.utterances.length} utterance(s):\\n\\n${data.utterances.reverse().map((u: any) => `\"${u.text}\"\\t[time: ${new Date(u.timestamp).toISOString()}]`).join('\\n')\n }${getVoiceResponseReminder()}`,\n },\n ],\n };\n }\n\n if (name === 'wait_for_utterance') {\n const requestedSeconds = (args?.seconds_to_wait as number) ?? DEFAULT_WAIT_TIMEOUT_SECONDS;\n const secondsToWait = Math.max(\n MIN_WAIT_TIMEOUT_SECONDS,\n Math.min(MAX_WAIT_TIMEOUT_SECONDS, requestedSeconds)\n );\n debugLog(`[MCP] Calling wait_for_utterance with ${secondsToWait}s timeout`);\n\n const response = await fetch(`http://localhost:${HTTP_PORT}/api/wait-for-utterances`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ seconds_to_wait: secondsToWait }),\n });\n\n const data = await response.json() as any;\n\n if (data.utterances && data.utterances.length > 0) {\n const utteranceTexts = data.utterances\n .map((u: any) => `[${u.timestamp}] \"${u.text}\"`)\n .join('\\n');\n\n return {\n content: [\n {\n type: 'text',\n text: `Found ${data.count} utterance(s):\\n\\n${utteranceTexts}${getVoiceResponseReminder()}`,\n },\n ],\n };\n } else {\n return {\n content: [\n {\n type: 'text',\n text: data.message || `No utterances found after waiting ${secondsToWait} seconds.`,\n },\n ],\n };\n }\n }\n\n if (name === 'speak') {\n const text = args?.text as string;\n\n if (!text || !text.trim()) {\n return {\n content: [\n {\n type: 'text',\n text: 'Error: Text is required for speak tool',\n },\n ],\n isError: true,\n };\n }\n\n const response = await fetch(`http://localhost:${HTTP_PORT}/api/speak`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ text }),\n });\n\n const data = await response.json() as any;\n\n if (response.ok) {\n return {\n content: [\n {\n type: 'text',\n text: `Spoke: \"${text}\"\\n${data.respondedCount > 0 ? `Marked ${data.respondedCount} utterance(s) as responded.` : 'No delivered utterances to mark as responded.'}`,\n },\n ],\n };\n } else {\n return {\n content: [\n {\n type: 'text',\n text: `Error speaking text: ${data.error || 'Unknown error'}`,\n },\n ],\n isError: true,\n };\n }\n }\n\n throw new Error(`Unknown tool: ${name}`);\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n isError: true,\n };\n }\n });\n\n // Connect via stdio\n const transport = new StdioServerTransport();\n mcpServer.connect(transport);\n console.log('[MCP] Server connected via stdio');\n} else {\n console.log('[MCP] Skipping MCP server initialization (not in MCP-managed mode)');\n}"],"mappings":";;;;;;AAEA,OAAO,aAAa;AAEpB,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AAEvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;AAGzC,IAAM,+BAA+B;AACrC,IAAM,2BAA2B;AACjC,IAAM,2BAA2B;AAGjC,IAAM,YAAY,UAAU,IAAI;AAGhC,eAAe,wBAAwB;AACrC,MAAI;AAEF,UAAM,UAAU,yCAAyC;AACzD,aAAS,mCAAmC;AAAA,EAC9C,SAAS,OAAO;AACd,aAAS,iCAAiC,KAAK,EAAE;AAAA,EAEnD;AACF;AAUA,IAAM,iBAAN,MAAqB;AAAA,EACnB,aAA0B,CAAC;AAAA,EAE3B,IAAI,MAAc,WAA6B;AAC7C,UAAM,YAAuB;AAAA,MAC3B,IAAI,WAAW;AAAA,MACf,MAAM,KAAK,KAAK;AAAA,MAChB,WAAW,aAAa,oBAAI,KAAK;AAAA,MACjC,QAAQ;AAAA,IACV;AAEA,SAAK,WAAW,KAAK,SAAS;AAC9B,aAAS,oBAAoB,UAAU,IAAI,UAAU,UAAU,EAAE,GAAG;AACpE,WAAO;AAAA,EACT;AAAA,EAEA,UAAU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BAAiB,IAAI,EAAE;AAAA,IACzC,SAAS,OAAO;AACd,aAAO;AAAA,QACL,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,UACxE;AAAA,QACF;AAAA,QACA,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF,CAAC;AAGD,QAAM,YAAY,IAAI,qBAAqB;AAC3C,YAAU,QAAQ,SAAS;AAC3B,UAAQ,IAAI,kCAAkC;AAChD,OAAO;AACL,UAAQ,IAAI,oEAAoE;AAClF;","names":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mcp-voice-hooks",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.8",
|
4
4
|
"main": "dist/index.js",
|
5
5
|
"type": "module",
|
6
6
|
"bin": {
|
@@ -40,9 +40,9 @@
|
|
40
40
|
"url": "git+https://github.com/johnmatthewtennant/mcp-voice-hooks.git"
|
41
41
|
},
|
42
42
|
"bugs": {
|
43
|
-
"url": "https://github.com/
|
43
|
+
"url": "https://github.com/johnmatthewtennant/mcp-voice-hooks/issues"
|
44
44
|
},
|
45
|
-
"homepage": "https://github.com/
|
45
|
+
"homepage": "https://github.com/johnmatthewtennant/mcp-voice-hooks#readme",
|
46
46
|
"dependencies": {
|
47
47
|
"@modelcontextprotocol/sdk": "^1.13.3",
|
48
48
|
"cors": "^2.8.5",
|
@@ -53,10 +53,12 @@
|
|
53
53
|
"@types/express": "^5.0.3",
|
54
54
|
"@types/jest": "^30.0.0",
|
55
55
|
"@types/node": "^24.0.10",
|
56
|
+
"@types/supertest": "^6.0.3",
|
56
57
|
"husky": "^9.1.7",
|
57
58
|
"jest": "^29.7.0",
|
58
59
|
"knip": "^5.61.3",
|
59
60
|
"nodemon": "^3.1.10",
|
61
|
+
"supertest": "^7.1.1",
|
60
62
|
"ts-jest": "^29.4.0",
|
61
63
|
"ts-node": "^10.9.2",
|
62
64
|
"ts-prune": "^0.10.3",
|
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# Check if voice responses are enabled (defaults to false)
|
4
|
-
VOICE_RESPONSES_ENABLED="${VOICE_RESPONSES_ENABLED:-false}"
|
5
|
-
|
6
|
-
if [ "$VOICE_RESPONSES_ENABLED" == "true" ]; then
|
7
|
-
echo "Use the 'say' command to respond to the user's voice input before proceeding." >&2
|
8
|
-
echo "Example: bash -c 'say -r 300 \"I understand your request. I'll start working on...\"'" >&2
|
9
|
-
exit 2
|
10
|
-
fi
|