call-me-cloud-mcp 1.0.2 → 1.1.0
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/bin/run.js +4 -2
- package/index.ts +53 -4
- package/package.json +1 -1
package/bin/run.js
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
import { spawn } from 'node:child_process';
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
6
7
|
|
|
7
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
9
|
const indexPath = join(__dirname, '..', 'index.ts');
|
|
9
10
|
|
|
10
|
-
//
|
|
11
|
-
const
|
|
11
|
+
// Use createRequire to properly resolve tsx from wherever npm installed it
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const tsxLoaderPath = require.resolve('tsx/esm');
|
|
12
14
|
|
|
13
15
|
// Spawn node with tsx loader using --import flag (Node 20.6+/18.19+ compatible)
|
|
14
16
|
const child = spawn(
|
package/index.ts
CHANGED
|
@@ -125,22 +125,71 @@ async function main() {
|
|
|
125
125
|
try {
|
|
126
126
|
if (request.params.name === 'initiate_call') {
|
|
127
127
|
const { message } = request.params.arguments as { message: string };
|
|
128
|
-
const result = await apiCall('/api/call', { message }) as {
|
|
128
|
+
const result = await apiCall('/api/call', { message }) as {
|
|
129
|
+
callId: string;
|
|
130
|
+
response: string;
|
|
131
|
+
contactMode?: 'voice' | 'whatsapp';
|
|
132
|
+
whatsappSessionWindow?: {
|
|
133
|
+
expiresAt: number;
|
|
134
|
+
minutesRemaining: number;
|
|
135
|
+
status: 'active' | 'expiring_soon' | 'expired';
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
let responseText = `Call initiated successfully.\n\nCall ID: ${result.callId}`;
|
|
140
|
+
|
|
141
|
+
// Add contact mode information if present
|
|
142
|
+
if (result.contactMode) {
|
|
143
|
+
responseText += `\nContact mode: ${result.contactMode}`;
|
|
144
|
+
|
|
145
|
+
// Add WhatsApp session window info if in WhatsApp mode
|
|
146
|
+
if (result.contactMode === 'whatsapp' && result.whatsappSessionWindow) {
|
|
147
|
+
const { minutesRemaining, status } = result.whatsappSessionWindow;
|
|
148
|
+
responseText += `\nWhatsApp session: ${Math.round(minutesRemaining)} minutes remaining`;
|
|
149
|
+
|
|
150
|
+
if (status === 'expiring_soon') {
|
|
151
|
+
responseText += ` (expires soon - switch to template messages after expiry)`;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
responseText += `\n\nUser's response:\n${result.response}\n\nUse continue_call to ask follow-ups or end_call to hang up.`;
|
|
129
157
|
|
|
130
158
|
return {
|
|
131
159
|
content: [{
|
|
132
160
|
type: 'text',
|
|
133
|
-
text:
|
|
161
|
+
text: responseText,
|
|
134
162
|
}],
|
|
135
163
|
};
|
|
136
164
|
}
|
|
137
165
|
|
|
138
166
|
if (request.params.name === 'continue_call') {
|
|
139
167
|
const { call_id, message } = request.params.arguments as { call_id: string; message: string };
|
|
140
|
-
const result = await apiCall(`/api/call/${call_id}/continue`, { message }) as {
|
|
168
|
+
const result = await apiCall(`/api/call/${call_id}/continue`, { message }) as {
|
|
169
|
+
response: string;
|
|
170
|
+
contactMode?: 'voice' | 'whatsapp';
|
|
171
|
+
whatsappSessionWindow?: {
|
|
172
|
+
expiresAt: number;
|
|
173
|
+
minutesRemaining: number;
|
|
174
|
+
status: 'active' | 'expiring_soon' | 'expired';
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
let responseText = `User's response:\n${result.response}`;
|
|
179
|
+
|
|
180
|
+
// Add WhatsApp session window warning if expiring soon
|
|
181
|
+
if (result.contactMode === 'whatsapp' && result.whatsappSessionWindow) {
|
|
182
|
+
const { minutesRemaining, status } = result.whatsappSessionWindow;
|
|
183
|
+
|
|
184
|
+
if (status === 'expiring_soon') {
|
|
185
|
+
responseText += `\n\n⚠️ WhatsApp session expiring in ${Math.round(minutesRemaining)} minutes. Consider wrapping up or asking user to reply to extend window.`;
|
|
186
|
+
} else if (status === 'expired') {
|
|
187
|
+
responseText += `\n\n⚠️ WhatsApp session expired. Future messages require approved templates.`;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
141
190
|
|
|
142
191
|
return {
|
|
143
|
-
content: [{ type: 'text', text:
|
|
192
|
+
content: [{ type: 'text', text: responseText }],
|
|
144
193
|
};
|
|
145
194
|
}
|
|
146
195
|
|