@onereach/step-voice 7.0.30-VOIC1729functionstotools.0 → 7.0.30
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.
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const voice_1 = tslib_1.__importDefault(require("./voice"));
|
|
5
|
-
class
|
|
5
|
+
class VoiceAgentFunctionResult extends voice_1.default {
|
|
6
6
|
async runStep() {
|
|
7
7
|
const { result, stopAgent } = this.data;
|
|
8
8
|
const ctx = await this.thread.get(`__voiceAgentContext_${this.thread.id}`);
|
|
9
9
|
if (!ctx?.callId) {
|
|
10
|
-
throw new Error('Voice Agent
|
|
10
|
+
throw new Error('Voice Agent Function Result: missing call context (must be placed on a Voice Agent function exit)');
|
|
11
11
|
}
|
|
12
|
-
const { callId, callCallback, name:
|
|
13
|
-
this.log.info(
|
|
12
|
+
const { callId, callCallback, name: functionName, functionId } = ctx;
|
|
13
|
+
this.log.info("Voice Agent Function Result", { functionId, callId, threadId: this.thread.id });
|
|
14
14
|
const params = {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
functionName,
|
|
16
|
+
functionId,
|
|
17
17
|
result,
|
|
18
18
|
options: { stop: stopAgent }
|
|
19
19
|
};
|
|
@@ -22,7 +22,7 @@ class VoiceAgentToolResult extends voice_1.default {
|
|
|
22
22
|
name: 'out/voice/voicer',
|
|
23
23
|
params: {
|
|
24
24
|
id: callId,
|
|
25
|
-
commands: [{ name: '
|
|
25
|
+
commands: [{ name: 'agentFunctionResult', params }]
|
|
26
26
|
}
|
|
27
27
|
}, {
|
|
28
28
|
target: callCallback,
|
|
@@ -32,4 +32,4 @@ class VoiceAgentToolResult extends voice_1.default {
|
|
|
32
32
|
this.exitStep('next');
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
exports.default =
|
|
35
|
+
exports.default = VoiceAgentFunctionResult;
|
package/dst/Voice Agent.js
CHANGED
|
@@ -8,19 +8,19 @@ class VoiceAgent extends voice_1.default {
|
|
|
8
8
|
const call = await this.fetchData();
|
|
9
9
|
this.triggers.local(`in/voice/${call.id}`, async (event) => {
|
|
10
10
|
switch (event.params.type) {
|
|
11
|
-
case '
|
|
12
|
-
if (event.params.type !== '
|
|
11
|
+
case 'function_call': {
|
|
12
|
+
if (event.params.type !== 'function_call')
|
|
13
13
|
return;
|
|
14
14
|
const cb = this.thread.takeCallback();
|
|
15
|
-
const name = event.params.name ?? '
|
|
15
|
+
const name = event.params.name ?? 'function_call';
|
|
16
16
|
const params = event.params.arguments ?? {};
|
|
17
|
-
const
|
|
18
|
-
const exitId = this.findExitByLabel(name) ?? this.getExitStepId('
|
|
17
|
+
const functionId = event.params.functionId ?? '';
|
|
18
|
+
const exitId = this.findExitByLabel(name) ?? this.getExitStepId('function_call');
|
|
19
19
|
if (exitId) {
|
|
20
20
|
this.exitStep(exitId, {
|
|
21
21
|
[name]: params,
|
|
22
22
|
name,
|
|
23
|
-
|
|
23
|
+
functionId,
|
|
24
24
|
__voicecb: cb,
|
|
25
25
|
callId: call.id,
|
|
26
26
|
callType: call.type,
|
|
@@ -28,7 +28,7 @@ class VoiceAgent extends voice_1.default {
|
|
|
28
28
|
}, true);
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
this.log.warn('no exit for
|
|
31
|
+
this.log.warn('no exit for function_call', { name });
|
|
32
32
|
}
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
@@ -297,7 +297,13 @@ class VoiceAgent extends voice_1.default {
|
|
|
297
297
|
if (!Array.isArray(systemTools)) {
|
|
298
298
|
this.throwError(new Error('Voice Agent: system_tools must be an array'));
|
|
299
299
|
}
|
|
300
|
-
return systemTools
|
|
300
|
+
return systemTools
|
|
301
|
+
.filter(entry => entry != null && typeof entry === 'object')
|
|
302
|
+
.filter((entry) => !lodash_1.default.isEmpty(entry.name))
|
|
303
|
+
.map((entry) => ({
|
|
304
|
+
...entry,
|
|
305
|
+
description: lodash_1.default.isEmpty(entry.description) ? undefined : entry.description
|
|
306
|
+
}));
|
|
301
307
|
}
|
|
302
308
|
parseAgentServiceOptions(label, options) {
|
|
303
309
|
if (options == null || options === '')
|