@absolutejs/voice 0.0.22-beta.589 → 0.0.22-beta.590
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/core/agent.d.ts +7 -0
- package/dist/index.js +7 -0
- package/package.json +1 -1
package/dist/core/agent.d.ts
CHANGED
|
@@ -48,6 +48,13 @@ export type VoiceAgentTool<TContext = unknown, TSession extends VoiceSessionReco
|
|
|
48
48
|
name: string;
|
|
49
49
|
parameters?: Record<string, unknown>;
|
|
50
50
|
resultToMessage?: (result: TToolResult) => string;
|
|
51
|
+
/** End the turn after this tool runs — do NOT loop back to the model for
|
|
52
|
+
* another generation. Use for tools that wrap up the call (an app-defined
|
|
53
|
+
* end_call) where the closing line is already in the SAME response: without
|
|
54
|
+
* this the agent generates again off the tool result and the caller hears a
|
|
55
|
+
* SECOND closing. Built-in lifecycle tools (complete/transfer/…) are already
|
|
56
|
+
* terminal; this flag gives an app tool the same behavior. Default false. */
|
|
57
|
+
endsTurn?: boolean;
|
|
51
58
|
};
|
|
52
59
|
export type VoiceAgentModelInput<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord> = {
|
|
53
60
|
agentId: string;
|
package/dist/index.js
CHANGED
|
@@ -7656,6 +7656,7 @@ var createVoiceAgent = (options) => {
|
|
|
7656
7656
|
if (appToolCalls.length === 0 || isLifecycleRequested(output) || round === maxToolRounds) {
|
|
7657
7657
|
break;
|
|
7658
7658
|
}
|
|
7659
|
+
let endTurnAfterDispatch = false;
|
|
7659
7660
|
for (const toolCall of appToolCalls) {
|
|
7660
7661
|
const tool = toolMap.get(toolCall.name);
|
|
7661
7662
|
if (!tool) {
|
|
@@ -7772,6 +7773,9 @@ var createVoiceAgent = (options) => {
|
|
|
7772
7773
|
role: "tool",
|
|
7773
7774
|
toolCallId: toolCall.id
|
|
7774
7775
|
});
|
|
7776
|
+
if (tool.endsTurn) {
|
|
7777
|
+
endTurnAfterDispatch = true;
|
|
7778
|
+
}
|
|
7775
7779
|
} catch (error) {
|
|
7776
7780
|
const errorMessage = toErrorMessage3(error);
|
|
7777
7781
|
toolResults.push({
|
|
@@ -7812,6 +7816,9 @@ var createVoiceAgent = (options) => {
|
|
|
7812
7816
|
});
|
|
7813
7817
|
}
|
|
7814
7818
|
}
|
|
7819
|
+
if (endTurnAfterDispatch) {
|
|
7820
|
+
break;
|
|
7821
|
+
}
|
|
7815
7822
|
}
|
|
7816
7823
|
await appendVoiceAgentTrace({
|
|
7817
7824
|
agentId: options.id,
|