@fonoster/autopilot 0.27.0 → 0.31.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.
Files changed (153) hide show
  1. package/README.md +15 -52
  2. package/dist/index.d.ts +0 -5
  3. package/dist/index.js +0 -5
  4. package/dist/knowledge/AbstractKnowledgeBase.d.ts +3 -2
  5. package/dist/knowledge/AbstractKnowledgeBase.js +2 -7
  6. package/dist/knowledge/FilesKnowledgeBase.d.ts +1 -1
  7. package/dist/knowledge/MeteredEmbeddings.d.ts +47 -0
  8. package/dist/knowledge/MeteredEmbeddings.js +58 -0
  9. package/dist/knowledge/types.d.ts +1 -1
  10. package/dist/models/LanguageModelFactory.d.ts +5 -24
  11. package/dist/models/LanguageModelFactory.js +0 -1
  12. package/dist/models/createLanguageModel.d.ts +2 -2
  13. package/dist/models/createLanguageModel.js +2 -2
  14. package/dist/models/evaluations/createEvalEffectiveConfig.d.ts +10 -106
  15. package/dist/models/evaluations/createEvalEffectiveConfig.js +47 -7
  16. package/dist/models/evaluations/createEvaluateIntelligence.d.ts +21 -20
  17. package/dist/models/evaluations/createEvaluateIntelligence.js +53 -23
  18. package/dist/models/evaluations/createTestTextSimilarity.d.ts +7 -1
  19. package/dist/models/evaluations/createTestTextSimilarity.js +19 -1
  20. package/dist/models/evaluations/evalTestCases.d.ts +2 -2
  21. package/dist/models/evaluations/evalTestCases.js +7 -7
  22. package/dist/models/evaluations/evaluateScenario.js +2 -2
  23. package/dist/models/evaluations/evaluateStep.d.ts +1 -1
  24. package/dist/models/evaluations/evaluateStep.js +2 -2
  25. package/dist/models/evaluations/extractAiResponse.d.ts +2 -3
  26. package/dist/models/evaluations/extractAiResponse.js +3 -3
  27. package/dist/models/evaluations/index.d.ts +1 -0
  28. package/dist/models/evaluations/index.js +1 -0
  29. package/dist/models/evaluations/runEval.d.ts +2 -20
  30. package/dist/models/evaluations/runEval.js +7 -7
  31. package/dist/models/evaluations/session/EvalSession.d.ts +73 -0
  32. package/dist/models/evaluations/session/EvalSession.js +134 -0
  33. package/dist/models/evaluations/session/evaluateSessionScenario.d.ts +58 -0
  34. package/dist/models/evaluations/session/evaluateSessionScenario.js +182 -0
  35. package/dist/{vad → models/evaluations/session}/index.d.ts +3 -2
  36. package/dist/{vad → models/evaluations/session}/index.js +3 -2
  37. package/dist/models/evaluations/session/runSessionEval.d.ts +20 -0
  38. package/dist/models/evaluations/session/runSessionEval.js +59 -0
  39. package/dist/models/evaluations/textSimilaryPrompt.d.ts +1 -1
  40. package/dist/models/evaluations/textSimilaryPrompt.js +1 -1
  41. package/dist/models/evaluations/types.d.ts +7 -6
  42. package/dist/models/types.d.ts +19 -1
  43. package/dist/session/Agent.d.ts +173 -0
  44. package/dist/session/Agent.js +548 -0
  45. package/dist/{loadAssistantFromAPI.d.ts → session/AsyncQueue.d.ts} +12 -7
  46. package/dist/session/AsyncQueue.js +67 -0
  47. package/dist/{machine/guards/index.d.ts → session/config.d.ts} +2 -2
  48. package/dist/session/config.js +27 -0
  49. package/dist/session/createAutopilot.d.ts +48 -0
  50. package/dist/session/createAutopilot.js +151 -0
  51. package/dist/session/hosted.d.ts +454 -0
  52. package/dist/session/hosted.js +501 -0
  53. package/dist/{assistants → session}/index.d.ts +11 -2
  54. package/dist/{machine/actors → session}/index.js +11 -3
  55. package/dist/{machine/actions/appendSpeech.js → session/knowledge.d.ts} +14 -17
  56. package/dist/session/knowledge.js +10 -0
  57. package/dist/session/llm.d.ts +113 -0
  58. package/dist/session/llm.js +127 -0
  59. package/dist/session/machine.d.ts +206 -0
  60. package/dist/session/machine.js +126 -0
  61. package/dist/session/main.js +45 -0
  62. package/dist/session/meteredThink.d.ts +45 -0
  63. package/dist/session/meteredThink.js +125 -0
  64. package/dist/session/sentences.d.ts +5 -0
  65. package/dist/session/sentences.js +53 -0
  66. package/dist/session/telemetry.d.ts +34 -0
  67. package/dist/session/telemetry.js +55 -0
  68. package/dist/{machine/actors/index.d.ts → session/think.d.ts} +2 -3
  69. package/dist/{machine/actions/announceSystemError.js → session/think.js} +8 -10
  70. package/dist/session/tools.d.ts +22 -0
  71. package/dist/session/tools.js +83 -0
  72. package/dist/tools/builtin/transferToolDefinition.js +1 -1
  73. package/dist/voice/index.d.ts +0 -1
  74. package/dist/voice/index.js +0 -1
  75. package/dist/voice/types.d.ts +5 -18
  76. package/package.json +15 -16
  77. package/dist/Autopilot.d.ts +0 -14
  78. package/dist/Autopilot.js +0 -133
  79. package/dist/assistants/index.js +0 -36
  80. package/dist/assistants/loadAndValidateAssistant.d.ts +0 -3
  81. package/dist/assistants/loadAndValidateAssistant.js +0 -49
  82. package/dist/assistants/types.d.ts +0 -24
  83. package/dist/assistants/types.js +0 -2
  84. package/dist/envs.d.ts +0 -15
  85. package/dist/envs.js +0 -78
  86. package/dist/handleVoiceRequest.d.ts +0 -3
  87. package/dist/handleVoiceRequest.js +0 -167
  88. package/dist/loadAssistantConfigFromFile.d.ts +0 -3
  89. package/dist/loadAssistantConfigFromFile.js +0 -68
  90. package/dist/loadAssistantFromAPI.js +0 -98
  91. package/dist/machine/actions/announceSystemError.d.ts +0 -4
  92. package/dist/machine/actions/appendSpeech.d.ts +0 -1
  93. package/dist/machine/actions/cleanSpeech.d.ts +0 -1
  94. package/dist/machine/actions/cleanSpeech.js +0 -23
  95. package/dist/machine/actions/goodbye.d.ts +0 -4
  96. package/dist/machine/actions/goodbye.js +0 -31
  97. package/dist/machine/actions/increaseIdleTimeoutCount.d.ts +0 -1
  98. package/dist/machine/actions/increaseIdleTimeoutCount.js +0 -31
  99. package/dist/machine/actions/index.d.ts +0 -26
  100. package/dist/machine/actions/index.js +0 -37
  101. package/dist/machine/actions/interruptPlayback.d.ts +0 -4
  102. package/dist/machine/actions/interruptPlayback.js +0 -43
  103. package/dist/machine/actions/resetIdleTimeoutCount.d.ts +0 -1
  104. package/dist/machine/actions/resetIdleTimeoutCount.js +0 -31
  105. package/dist/machine/actions/resetState.d.ts +0 -1
  106. package/dist/machine/actions/resetState.js +0 -32
  107. package/dist/machine/actors/doAnnounceIdleTimeout.d.ts +0 -4
  108. package/dist/machine/actors/doAnnounceIdleTimeout.js +0 -41
  109. package/dist/machine/actors/doGreetUser.d.ts +0 -4
  110. package/dist/machine/actors/doGreetUser.js +0 -45
  111. package/dist/machine/actors/doProcessUserRequest.d.ts +0 -4
  112. package/dist/machine/actors/doProcessUserRequest.js +0 -75
  113. package/dist/machine/context.d.ts +0 -52
  114. package/dist/machine/context.js +0 -28
  115. package/dist/machine/delays.d.ts +0 -30
  116. package/dist/machine/delays.js +0 -37
  117. package/dist/machine/guards/hasSpeechResult.d.ts +0 -4
  118. package/dist/machine/guards/hasSpeechResult.js +0 -30
  119. package/dist/machine/guards/idleTimeoutCountExceedsMax.d.ts +0 -4
  120. package/dist/machine/guards/idleTimeoutCountExceedsMax.js +0 -31
  121. package/dist/machine/guards/index.js +0 -25
  122. package/dist/machine/index.d.ts +0 -19
  123. package/dist/machine/index.js +0 -23
  124. package/dist/machine/machine.d.ts +0 -408
  125. package/dist/machine/machine.js +0 -206
  126. package/dist/machine/setup.d.ts +0 -328
  127. package/dist/machine/setup.js +0 -116
  128. package/dist/machine/types.d.ts +0 -54
  129. package/dist/machine/types.js +0 -2
  130. package/dist/sendConversationEndedEvent.d.ts +0 -32
  131. package/dist/sendConversationEndedEvent.js +0 -66
  132. package/dist/sendConversationStartedEvent.d.ts +0 -6
  133. package/dist/sendConversationStartedEvent.js +0 -63
  134. package/dist/server.d.ts +0 -2
  135. package/dist/server.js +0 -25
  136. package/dist/types.d.ts +0 -40
  137. package/dist/types.js +0 -8
  138. package/dist/vad/SileroVad.d.ts +0 -18
  139. package/dist/vad/SileroVad.js +0 -40
  140. package/dist/vad/SileroVadModel.d.ts +0 -14
  141. package/dist/vad/SileroVadModel.js +0 -83
  142. package/dist/vad/chunkToFloat32Array.d.ts +0 -20
  143. package/dist/vad/chunkToFloat32Array.js +0 -34
  144. package/dist/vad/createVad.d.ts +0 -3
  145. package/dist/vad/createVad.js +0 -126
  146. package/dist/vad/types.d.ts +0 -60
  147. package/dist/vad/types.js +0 -2
  148. package/dist/vadWorker.js +0 -36
  149. package/dist/voice/Voice.d.ts +0 -61
  150. package/dist/voice/Voice.js +0 -96
  151. package/dist/voiceServerSetup.d.ts +0 -2
  152. package/dist/voiceServerSetup.js +0 -29
  153. /package/dist/{vadWorker.d.ts → session/main.d.ts} +0 -0
@@ -1,30 +0,0 @@
1
- /**
2
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
- * http://github.com/fonoster/fonoster
4
- *
5
- * This file is part of Fonoster
6
- *
7
- * Licensed under the MIT License (the "License");
8
- * you may not use this file except in compliance with
9
- * the License. You may obtain a copy of the License at
10
- *
11
- * https://opensource.org/licenses/MIT
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
- declare const delays: {
20
- IDLE_TIMEOUT: ({ context }: {
21
- context: any;
22
- }) => any;
23
- MAX_SPEECH_WAIT_TIMEOUT: ({ context }: {
24
- context: any;
25
- }) => any;
26
- MAX_SESSION_DURATION: ({ context }: {
27
- context: any;
28
- }) => any;
29
- };
30
- export { delays as default };
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = void 0;
4
- /**
5
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
- * http://github.com/fonoster/fonoster
7
- *
8
- * This file is part of Fonoster
9
- *
10
- * Licensed under the MIT License (the "License");
11
- * you may not use this file except in compliance with
12
- * the License. You may obtain a copy of the License at
13
- *
14
- * https://opensource.org/licenses/MIT
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
- const delays = {
23
- IDLE_TIMEOUT: ({ context }) => context.idleTimeout,
24
- MAX_SPEECH_WAIT_TIMEOUT: ({ context }) => {
25
- // If this is the first conversational turn and there is no firstMessage,
26
- // use 0 timeout to avoid unnecessary delay during the intro. (Outbound calls)
27
- if (context.isFirstTurn && !context.firstMessage) {
28
- return 0;
29
- }
30
- else if (context.hasLateSpeech) {
31
- return 0;
32
- }
33
- return context.maxSpeechWaitTimeout;
34
- },
35
- MAX_SESSION_DURATION: ({ context }) => context.maxSessionDuration
36
- };
37
- exports.default = delays;
@@ -1,4 +0,0 @@
1
- import { AutopilotContext } from "../types";
2
- export declare const hasSpeechResult: ({ context }: {
3
- context: AutopilotContext;
4
- }) => boolean;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasSpeechResult = void 0;
4
- /**
5
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
- * http://github.com/fonoster/fonoster
7
- *
8
- * This file is part of Fonoster
9
- *
10
- * Licensed under the MIT License (the "License");
11
- * you may not use this file except in compliance with
12
- * the License. You may obtain a copy of the License at
13
- *
14
- * https://opensource.org/licenses/MIT
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
- const logger_1 = require("@fonoster/logger");
23
- const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
24
- const hasSpeechResult = ({ context }) => {
25
- logger.verbose("called the hasSpeechResult guard", {
26
- speechBuffer: context.speechBuffer
27
- });
28
- return Boolean(context.speechBuffer);
29
- };
30
- exports.hasSpeechResult = hasSpeechResult;
@@ -1,4 +0,0 @@
1
- import { AutopilotContext } from "../types";
2
- export declare const idleTimeoutCountExceedsMax: ({ context }: {
3
- context: AutopilotContext;
4
- }) => boolean;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.idleTimeoutCountExceedsMax = void 0;
4
- /**
5
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
- * http://github.com/fonoster/fonoster
7
- *
8
- * This file is part of Fonoster
9
- *
10
- * Licensed under the MIT License (the "License");
11
- * you may not use this file except in compliance with
12
- * the License. You may obtain a copy of the License at
13
- *
14
- * https://opensource.org/licenses/MIT
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
- const logger_1 = require("@fonoster/logger");
23
- const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
24
- const idleTimeoutCountExceedsMax = ({ context }) => {
25
- logger.verbose("called the idleTimeoutCountExceedsMax guard", {
26
- idleTimeoutCount: context.idleTimeoutCount + 1,
27
- maxIdleTimeoutCount: context.maxIdleTimeoutCount
28
- });
29
- return context.idleTimeoutCount + 1 > context.maxIdleTimeoutCount;
30
- };
31
- exports.idleTimeoutCountExceedsMax = idleTimeoutCountExceedsMax;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasSpeechResult = exports.idleTimeoutCountExceedsMax = void 0;
4
- /**
5
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
- * http://github.com/fonoster/fonoster
7
- *
8
- * This file is part of Fonoster
9
- *
10
- * Licensed under the MIT License (the "License");
11
- * you may not use this file except in compliance with
12
- * the License. You may obtain a copy of the License at
13
- *
14
- * https://opensource.org/licenses/MIT
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
- var idleTimeoutCountExceedsMax_1 = require("./idleTimeoutCountExceedsMax");
23
- Object.defineProperty(exports, "idleTimeoutCountExceedsMax", { enumerable: true, get: function () { return idleTimeoutCountExceedsMax_1.idleTimeoutCountExceedsMax; } });
24
- var hasSpeechResult_1 = require("./hasSpeechResult");
25
- Object.defineProperty(exports, "hasSpeechResult", { enumerable: true, get: function () { return hasSpeechResult_1.hasSpeechResult; } });
@@ -1,19 +0,0 @@
1
- /**
2
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
- * http://github.com/fonoster/fonoster
4
- *
5
- * This file is part of Fonoster
6
- *
7
- * Licensed under the MIT License (the "License");
8
- * you may not use this file except in compliance with
9
- * the License. You may obtain a copy of the License at
10
- *
11
- * https://opensource.org/licenses/MIT
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
- export { machine } from "./machine";
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.machine = void 0;
4
- /**
5
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
- * http://github.com/fonoster/fonoster
7
- *
8
- * This file is part of Fonoster
9
- *
10
- * Licensed under the MIT License (the "License");
11
- * you may not use this file except in compliance with
12
- * the License. You may obtain a copy of the License at
13
- *
14
- * https://opensource.org/licenses/MIT
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
- var machine_1 = require("./machine");
23
- Object.defineProperty(exports, "machine", { enumerable: true, get: function () { return machine_1.machine; } });
@@ -1,408 +0,0 @@
1
- declare const machine: import("xstate").StateMachine<any, import("./types").AutopilotEvents, {
2
- [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<void, {
3
- context: import("./types").AutopilotContext;
4
- }, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<void, {
5
- context: import("./types").AutopilotContext;
6
- }, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<void, {
7
- context: import("./types").AutopilotContext;
8
- }, import("xstate").EventObject>>;
9
- }, import("xstate").Values<{
10
- doProcessUserRequest: {
11
- src: "doProcessUserRequest";
12
- logic: import("xstate").PromiseActorLogic<void, {
13
- context: import("./types").AutopilotContext;
14
- }, import("xstate").EventObject>;
15
- id: string;
16
- };
17
- doGreetUser: {
18
- src: "doGreetUser";
19
- logic: import("xstate").PromiseActorLogic<void, {
20
- context: import("./types").AutopilotContext;
21
- }, import("xstate").EventObject>;
22
- id: string;
23
- };
24
- doAnnounceIdleTimeout: {
25
- src: "doAnnounceIdleTimeout";
26
- logic: import("xstate").PromiseActorLogic<void, {
27
- context: import("./types").AutopilotContext;
28
- }, import("xstate").EventObject>;
29
- id: string;
30
- };
31
- }>, import("xstate").Values<{
32
- appendSpeech: {
33
- type: "appendSpeech";
34
- params: unknown;
35
- };
36
- cleanSpeech: {
37
- type: "cleanSpeech";
38
- params: unknown;
39
- };
40
- increaseIdleTimeoutCount: {
41
- type: "increaseIdleTimeoutCount";
42
- params: unknown;
43
- };
44
- resetIdleTimeoutCount: {
45
- type: "resetIdleTimeoutCount";
46
- params: unknown;
47
- };
48
- resetState: {
49
- type: "resetState";
50
- params: unknown;
51
- };
52
- goodbye: {
53
- type: "goodbye";
54
- params: unknown;
55
- };
56
- announceSystemError: {
57
- type: "announceSystemError";
58
- params: unknown;
59
- };
60
- interruptPlayback: {
61
- type: "interruptPlayback";
62
- params: unknown;
63
- };
64
- }>, import("xstate").Values<{
65
- idleTimeoutCountExceedsMax: {
66
- type: "idleTimeoutCountExceedsMax";
67
- params: unknown;
68
- };
69
- hasSpeechResult: {
70
- type: "hasSpeechResult";
71
- params: unknown;
72
- };
73
- }>, "IDLE_TIMEOUT" | "MAX_SPEECH_WAIT_TIMEOUT" | "MAX_SESSION_DURATION", "hangup" | "greeting" | "idle" | "listeningToUser" | "announcingIdleTimeout" | "waitingForSpeechTimeout" | "processingUserRequest", string, {
74
- conversationSettings: import("..").ConversationSettings;
75
- languageModel: import("..").LanguageModel;
76
- voice: import("..").Voice;
77
- }, {}, import("xstate").EventObject, import("xstate").MetaObject, {
78
- readonly context: ({ input }: {
79
- input: {
80
- voice: import("..").Voice;
81
- languageModel: import("..").LanguageModel;
82
- conversationSettings: import("..").ConversationSettings;
83
- };
84
- }) => {
85
- mediaSessionRef: string;
86
- voice: import("..").Voice;
87
- languageModel: import("..").LanguageModel;
88
- speechBuffer: string;
89
- firstMessage: string;
90
- goodbyeMessage: string;
91
- transferMessage: string;
92
- transferPhoneNumber: string;
93
- transferTimeout: number;
94
- systemErrorMessage: string;
95
- idleMessage: string;
96
- idleTimeout: number;
97
- maxIdleTimeoutCount: number;
98
- idleTimeoutCount: number;
99
- maxSpeechWaitTimeout: number;
100
- allowUserBargeIn: boolean;
101
- sessionStartTime: number;
102
- maxSessionDuration: number;
103
- initialDtmf: string;
104
- previousState: any;
105
- hasLateSpeech: boolean;
106
- isFirstTurn: boolean;
107
- };
108
- readonly id: "fnAI";
109
- readonly initial: "greeting";
110
- readonly states: {
111
- readonly greeting: {
112
- readonly invoke: {
113
- readonly src: "doGreetUser";
114
- readonly description: "Answer the call and play the first message";
115
- readonly input: ({ context }: {
116
- context: any;
117
- event: import("./types").AutopilotEvents;
118
- self: import("xstate").ActorRef<import("xstate").MachineSnapshot<any, import("./types").AutopilotEvents, Record<string, import("xstate").AnyActorRef>, import("xstate").StateValue, string, unknown, any, any>, import("./types").AutopilotEvents, import("xstate").AnyEventObject>;
119
- }) => {
120
- context: any;
121
- };
122
- readonly onDone: {
123
- readonly target: "idle";
124
- readonly description: "Transition to idle after the initial greeting.";
125
- };
126
- readonly onError: {
127
- readonly target: "idle";
128
- };
129
- };
130
- readonly on: {
131
- readonly SPEECH_START: {
132
- readonly target: "listeningToUser";
133
- readonly description: "The user barged in during the greeting.";
134
- };
135
- };
136
- };
137
- readonly idle: {
138
- readonly entry: readonly [{
139
- readonly type: "cleanSpeech";
140
- }];
141
- readonly on: {
142
- readonly SPEECH_START: {
143
- readonly target: "listeningToUser";
144
- readonly description: "Event from VAD system.";
145
- };
146
- };
147
- readonly after: {
148
- readonly IDLE_TIMEOUT: readonly [{
149
- readonly target: "hangup";
150
- readonly actions: {
151
- readonly type: "goodbye";
152
- };
153
- readonly guard: import("xstate/dist/declarations/src/guards").GuardPredicate<any, import("./types").AutopilotEvents, unknown, {
154
- type: "idleTimeoutCountExceedsMax";
155
- params: undefined;
156
- }>;
157
- }, {
158
- readonly target: "announcingIdleTimeout";
159
- }];
160
- };
161
- };
162
- readonly announcingIdleTimeout: {
163
- readonly entry: readonly [{
164
- readonly type: "increaseIdleTimeoutCount";
165
- }];
166
- readonly invoke: {
167
- readonly src: "doAnnounceIdleTimeout";
168
- readonly description: "Play the idle message";
169
- readonly input: ({ context }: {
170
- context: any;
171
- event: import("./types").AutopilotEvents;
172
- self: import("xstate").ActorRef<import("xstate").MachineSnapshot<any, import("./types").AutopilotEvents, Record<string, import("xstate").AnyActorRef>, import("xstate").StateValue, string, unknown, any, any>, import("./types").AutopilotEvents, import("xstate").AnyEventObject>;
173
- }) => {
174
- context: any;
175
- };
176
- readonly onDone: {
177
- readonly target: "idle";
178
- readonly description: "Re-arm the idle clock once the idle message finishes.";
179
- };
180
- readonly onError: {
181
- readonly target: "idle";
182
- };
183
- };
184
- readonly on: {
185
- readonly SPEECH_START: {
186
- readonly target: "listeningToUser";
187
- readonly description: "The user spoke while the idle message was playing.";
188
- };
189
- };
190
- };
191
- readonly listeningToUser: {
192
- readonly entry: readonly [{
193
- readonly type: "interruptPlayback";
194
- }, {
195
- readonly type: "resetIdleTimeoutCount";
196
- }, import("xstate").ActionFunction<any, import("./types").AutopilotEvents, import("./types").AutopilotEvents, undefined, import("xstate").Values<{
197
- doProcessUserRequest: {
198
- src: "doProcessUserRequest";
199
- logic: import("xstate").PromiseActorLogic<void, {
200
- context: import("./types").AutopilotContext;
201
- }, import("xstate").EventObject>;
202
- id: string;
203
- };
204
- doGreetUser: {
205
- src: "doGreetUser";
206
- logic: import("xstate").PromiseActorLogic<void, {
207
- context: import("./types").AutopilotContext;
208
- }, import("xstate").EventObject>;
209
- id: string;
210
- };
211
- doAnnounceIdleTimeout: {
212
- src: "doAnnounceIdleTimeout";
213
- logic: import("xstate").PromiseActorLogic<void, {
214
- context: import("./types").AutopilotContext;
215
- }, import("xstate").EventObject>;
216
- id: string;
217
- };
218
- }>, never, never, never, never>];
219
- readonly on: {
220
- readonly SPEECH_RESULT: {
221
- readonly target: "waitingForSpeechTimeout";
222
- readonly actions: {
223
- readonly type: "appendSpeech";
224
- };
225
- readonly description: "Append final speech and process the request.";
226
- readonly reenter: true;
227
- };
228
- };
229
- readonly after: {
230
- readonly IDLE_TIMEOUT: readonly [{
231
- readonly target: "hangup";
232
- readonly actions: {
233
- readonly type: "goodbye";
234
- };
235
- readonly guard: import("xstate/dist/declarations/src/guards").GuardPredicate<any, import("./types").AutopilotEvents, unknown, {
236
- type: "idleTimeoutCountExceedsMax";
237
- params: undefined;
238
- }>;
239
- }, {
240
- readonly target: "announcingIdleTimeout";
241
- }];
242
- };
243
- };
244
- readonly waitingForSpeechTimeout: {
245
- readonly on: {
246
- readonly SPEECH_START: {
247
- readonly target: "listeningToUser";
248
- readonly description: "User started speaking again.";
249
- readonly guard: ({ context }: import("xstate/dist/declarations/src/guards").GuardArgs<any, {
250
- type: "SPEECH_START";
251
- }>) => any;
252
- };
253
- readonly SPEECH_RESULT: {
254
- readonly target: "waitingForSpeechTimeout";
255
- readonly description: "Capture late speech, but only once.";
256
- readonly guard: ({ context }: import("xstate/dist/declarations/src/guards").GuardArgs<any, {
257
- type: "SPEECH_RESULT";
258
- speech: string;
259
- responseTime: number;
260
- }>) => boolean;
261
- readonly actions: readonly [{
262
- readonly type: "appendSpeech";
263
- }, import("xstate").ActionFunction<any, {
264
- type: "SPEECH_RESULT";
265
- speech: string;
266
- responseTime: number;
267
- }, import("./types").AutopilotEvents, undefined, import("xstate").Values<{
268
- doProcessUserRequest: {
269
- src: "doProcessUserRequest";
270
- logic: import("xstate").PromiseActorLogic<void, {
271
- context: import("./types").AutopilotContext;
272
- }, import("xstate").EventObject>;
273
- id: string;
274
- };
275
- doGreetUser: {
276
- src: "doGreetUser";
277
- logic: import("xstate").PromiseActorLogic<void, {
278
- context: import("./types").AutopilotContext;
279
- }, import("xstate").EventObject>;
280
- id: string;
281
- };
282
- doAnnounceIdleTimeout: {
283
- src: "doAnnounceIdleTimeout";
284
- logic: import("xstate").PromiseActorLogic<void, {
285
- context: import("./types").AutopilotContext;
286
- }, import("xstate").EventObject>;
287
- id: string;
288
- };
289
- }>, never, never, never, never>];
290
- };
291
- };
292
- readonly after: {
293
- readonly MAX_SPEECH_WAIT_TIMEOUT: {
294
- readonly target: "processingUserRequest";
295
- readonly description: "This will give the person time to breathe and speak again.";
296
- readonly reenter: true;
297
- };
298
- };
299
- };
300
- readonly hangup: {
301
- readonly type: "final";
302
- };
303
- readonly processingUserRequest: {
304
- readonly on: {
305
- readonly SPEECH_START: {
306
- readonly target: "listeningToUser";
307
- readonly description: "Event from VAD or similar system.";
308
- readonly guard: ({ context }: import("xstate/dist/declarations/src/guards").GuardArgs<any, {
309
- type: "SPEECH_START";
310
- }>) => any;
311
- readonly actions: readonly [{
312
- readonly type: "cleanSpeech";
313
- }];
314
- };
315
- readonly SPEECH_RESULT: {
316
- readonly target: "processingUserRequest";
317
- readonly description: "Capture only a single late speech across the entire request processing.";
318
- readonly guard: ({ context }: import("xstate/dist/declarations/src/guards").GuardArgs<any, {
319
- type: "SPEECH_RESULT";
320
- speech: string;
321
- responseTime: number;
322
- }>) => boolean;
323
- readonly actions: readonly [{
324
- readonly type: "interruptPlayback";
325
- }, {
326
- readonly type: "appendSpeech";
327
- }, import("xstate").ActionFunction<any, {
328
- type: "SPEECH_RESULT";
329
- speech: string;
330
- responseTime: number;
331
- }, import("./types").AutopilotEvents, undefined, import("xstate").Values<{
332
- doProcessUserRequest: {
333
- src: "doProcessUserRequest";
334
- logic: import("xstate").PromiseActorLogic<void, {
335
- context: import("./types").AutopilotContext;
336
- }, import("xstate").EventObject>;
337
- id: string;
338
- };
339
- doGreetUser: {
340
- src: "doGreetUser";
341
- logic: import("xstate").PromiseActorLogic<void, {
342
- context: import("./types").AutopilotContext;
343
- }, import("xstate").EventObject>;
344
- id: string;
345
- };
346
- doAnnounceIdleTimeout: {
347
- src: "doAnnounceIdleTimeout";
348
- logic: import("xstate").PromiseActorLogic<void, {
349
- context: import("./types").AutopilotContext;
350
- }, import("xstate").EventObject>;
351
- id: string;
352
- };
353
- }>, never, never, never, never>];
354
- readonly reenter: true;
355
- };
356
- };
357
- readonly invoke: {
358
- readonly src: "doProcessUserRequest";
359
- readonly description: "Process the user request";
360
- readonly input: ({ context }: {
361
- context: any;
362
- event: import("./types").AutopilotEvents;
363
- self: import("xstate").ActorRef<import("xstate").MachineSnapshot<any, import("./types").AutopilotEvents, Record<string, import("xstate").AnyActorRef>, import("xstate").StateValue, string, unknown, any, any>, import("./types").AutopilotEvents, import("xstate").AnyEventObject>;
364
- }) => {
365
- context: any;
366
- };
367
- readonly onDone: {
368
- readonly target: "listeningToUser";
369
- readonly reenter: true;
370
- readonly actions: readonly [{
371
- readonly type: "cleanSpeech";
372
- }, import("xstate").ActionFunction<any, import("xstate").DoneActorEvent<void, string>, import("./types").AutopilotEvents, undefined, import("xstate").Values<{
373
- doProcessUserRequest: {
374
- src: "doProcessUserRequest";
375
- logic: import("xstate").PromiseActorLogic<void, {
376
- context: import("./types").AutopilotContext;
377
- }, import("xstate").EventObject>;
378
- id: string;
379
- };
380
- doGreetUser: {
381
- src: "doGreetUser";
382
- logic: import("xstate").PromiseActorLogic<void, {
383
- context: import("./types").AutopilotContext;
384
- }, import("xstate").EventObject>;
385
- id: string;
386
- };
387
- doAnnounceIdleTimeout: {
388
- src: "doAnnounceIdleTimeout";
389
- logic: import("xstate").PromiseActorLogic<void, {
390
- context: import("./types").AutopilotContext;
391
- }, import("xstate").EventObject>;
392
- id: string;
393
- };
394
- }>, never, never, never, never>];
395
- };
396
- };
397
- };
398
- };
399
- readonly after: {
400
- readonly MAX_SESSION_DURATION: {
401
- readonly target: ".hangup";
402
- readonly actions: {
403
- readonly type: "goodbye";
404
- };
405
- };
406
- };
407
- }>;
408
- export { machine };