@blockrun/franklin 3.21.8 → 3.21.9
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/dist/tools/voice.d.ts +1 -0
- package/dist/tools/voice.js +40 -21
- package/package.json +1 -1
package/dist/tools/voice.d.ts
CHANGED
|
@@ -15,5 +15,6 @@
|
|
|
15
15
|
* x402 payment flow mirrors src/tools/exa.ts.
|
|
16
16
|
*/
|
|
17
17
|
import type { CapabilityHandler } from '../agent/types.js';
|
|
18
|
+
export declare function buildVoiceCallBody(input: Record<string, unknown>): Record<string, unknown>;
|
|
18
19
|
export declare const voiceCallCapability: CapabilityHandler;
|
|
19
20
|
export declare const voiceStatusCapability: CapabilityHandler;
|
package/dist/tools/voice.js
CHANGED
|
@@ -183,6 +183,34 @@ async function extractPaymentReq(response) {
|
|
|
183
183
|
return header;
|
|
184
184
|
}
|
|
185
185
|
// ─── Tools ─────────────────────────────────────────────────────────────────
|
|
186
|
+
export function buildVoiceCallBody(input) {
|
|
187
|
+
const body = {
|
|
188
|
+
to: input.to,
|
|
189
|
+
from: input.from,
|
|
190
|
+
task: input.task,
|
|
191
|
+
};
|
|
192
|
+
// The gateway validates additionalProperties: false - only forward known
|
|
193
|
+
// optional fields, don't echo back whatever the caller passed.
|
|
194
|
+
if (typeof input.voice === 'string')
|
|
195
|
+
body.voice = input.voice;
|
|
196
|
+
if (typeof input.max_duration === 'number')
|
|
197
|
+
body.max_duration = input.max_duration;
|
|
198
|
+
if (typeof input.language === 'string')
|
|
199
|
+
body.language = input.language;
|
|
200
|
+
if (typeof input.first_sentence === 'string')
|
|
201
|
+
body.first_sentence = input.first_sentence;
|
|
202
|
+
if (typeof input.wait_for_greeting === 'boolean')
|
|
203
|
+
body.wait_for_greeting = input.wait_for_greeting;
|
|
204
|
+
if (typeof input.voicemail_action === 'string')
|
|
205
|
+
body.voicemail_action = input.voicemail_action;
|
|
206
|
+
if (typeof input.voicemail_message === 'string')
|
|
207
|
+
body.voicemail_message = input.voicemail_message;
|
|
208
|
+
if (typeof input.interruption_threshold === 'number')
|
|
209
|
+
body.interruption_threshold = input.interruption_threshold;
|
|
210
|
+
if (typeof input.model === 'string')
|
|
211
|
+
body.model = input.model;
|
|
212
|
+
return body;
|
|
213
|
+
}
|
|
186
214
|
export const voiceCallCapability = {
|
|
187
215
|
spec: {
|
|
188
216
|
name: 'VoiceCall',
|
|
@@ -252,6 +280,17 @@ export const voiceCallCapability = {
|
|
|
252
280
|
description: 'The message to leave when voicemail_action is "leave_message" (≤1000 chars). ' +
|
|
253
281
|
'Voicemail is one-way — this is spoken once as a monologue, there is no back-and-forth.',
|
|
254
282
|
},
|
|
283
|
+
interruption_threshold: {
|
|
284
|
+
type: 'integer',
|
|
285
|
+
minimum: 50,
|
|
286
|
+
maximum: 500,
|
|
287
|
+
description: 'Milliseconds of recipient speech before the agent pauses to listen (50-500).',
|
|
288
|
+
},
|
|
289
|
+
model: {
|
|
290
|
+
type: 'string',
|
|
291
|
+
enum: ['base', 'enhanced', 'turbo'],
|
|
292
|
+
description: 'Call model tier to use for the conversation.',
|
|
293
|
+
},
|
|
255
294
|
},
|
|
256
295
|
required: ['to', 'from', 'task'],
|
|
257
296
|
},
|
|
@@ -264,27 +303,7 @@ export const voiceCallCapability = {
|
|
|
264
303
|
if (typeof input.task !== 'string' || input.task.length < 10) {
|
|
265
304
|
return { output: 'task required (10–4000 chars natural-language description)', isError: true };
|
|
266
305
|
}
|
|
267
|
-
const body =
|
|
268
|
-
to: input.to,
|
|
269
|
-
from: input.from,
|
|
270
|
-
task: input.task,
|
|
271
|
-
};
|
|
272
|
-
// The gateway validates additionalProperties: false — only forward known
|
|
273
|
-
// optional fields, don't echo back whatever the caller passed.
|
|
274
|
-
if (typeof input.voice === 'string')
|
|
275
|
-
body.voice = input.voice;
|
|
276
|
-
if (typeof input.max_duration === 'number')
|
|
277
|
-
body.max_duration = input.max_duration;
|
|
278
|
-
if (typeof input.language === 'string')
|
|
279
|
-
body.language = input.language;
|
|
280
|
-
if (typeof input.first_sentence === 'string')
|
|
281
|
-
body.first_sentence = input.first_sentence;
|
|
282
|
-
if (typeof input.wait_for_greeting === 'boolean')
|
|
283
|
-
body.wait_for_greeting = input.wait_for_greeting;
|
|
284
|
-
if (typeof input.voicemail_action === 'string')
|
|
285
|
-
body.voicemail_action = input.voicemail_action;
|
|
286
|
-
if (typeof input.voicemail_message === 'string')
|
|
287
|
-
body.voicemail_message = input.voicemail_message;
|
|
306
|
+
const body = buildVoiceCallBody(input);
|
|
288
307
|
try {
|
|
289
308
|
const res = await postWithPayment('/v1/voice/call', body, ctx, { tool: 'VoiceCall', priceUsd: 0.54 });
|
|
290
309
|
const callId = (res.call_id || res.id);
|
package/package.json
CHANGED