@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,60 +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
- type VadEvent = "SPEECH_START" | "SPEECH_END";
20
- type Vad = {
21
- processChunk: (chunk: Uint8Array, callback: (event: VadEvent) => void) => void;
22
- };
23
- type VadParams = {
24
- pathToModel?: string;
25
- activationThreshold: number;
26
- deactivationThreshold: number;
27
- debounceFrames: number;
28
- };
29
- export interface SpeechProbabilities {
30
- notSpeech: number;
31
- isSpeech: number;
32
- }
33
- export interface ONNXRuntimeAPI {
34
- InferenceSession: {
35
- create: (modelPath: ArrayBuffer | string, options?: {
36
- interOpNumThreads: number;
37
- intraOpNumThreads: number;
38
- enableCpuMemArena: boolean;
39
- }) => Promise<ONNXSession>;
40
- };
41
- Tensor: new (type: string, data: Float32Array | bigint[], dims: number[]) => ONNXTensor;
42
- }
43
- export interface ONNXSession {
44
- run: (feeds: {
45
- [key: string]: ONNXTensor;
46
- }) => Promise<{
47
- output: {
48
- data: Float32Array;
49
- };
50
- stateN: ONNXTensor;
51
- }>;
52
- inputNames: string[];
53
- outputNames: string[];
54
- }
55
- export interface ONNXTensor {
56
- data: Float32Array | bigint[];
57
- dims: number[];
58
- type: string;
59
- }
60
- export { Vad, VadEvent, VadParams };
package/dist/vad/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/dist/vadWorker.js DELETED
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
5
- * http://github.com/fonoster/fonoster
6
- *
7
- * This file is part of Fonoster
8
- *
9
- * Licensed under the MIT License (the "License");
10
- * you may not use this file except in compliance with
11
- * the License. You may obtain a copy of the License at
12
- *
13
- * https://opensource.org/licenses/MIT
14
- *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
20
- */
21
- const path_1 = require("path");
22
- const worker_threads_1 = require("worker_threads");
23
- const SileroVad_1 = require("./vad/SileroVad");
24
- const vad = new SileroVad_1.SileroVad({
25
- ...worker_threads_1.workerData,
26
- pathToModel: (0, path_1.join)(__dirname, "..", "silero_vad_v5.onnx")
27
- });
28
- vad.init().then(() => {
29
- // Send ready message to parent
30
- worker_threads_1.parentPort?.postMessage("VAD_READY");
31
- worker_threads_1.parentPort?.on("message", (chunk) => {
32
- vad.processChunk(chunk, (voiceActivity) => {
33
- worker_threads_1.parentPort?.postMessage(voiceActivity);
34
- });
35
- });
36
- });
@@ -1,61 +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
- import { AudioFilterConfig } from "@fonoster/common";
20
- import { VoiceResponse } from "@fonoster/voice";
21
- import { Voice } from "./types";
22
- declare class VoiceImpl implements Voice {
23
- private readonly voice;
24
- private readonly playbackRef;
25
- mediaSessionRef: string;
26
- sgatherStream: {
27
- stop: () => Promise<void>;
28
- onData: (cb: (payload: {
29
- speech: string;
30
- responseTime: number;
31
- }) => void) => void;
32
- };
33
- vadStream: {
34
- stop: () => Promise<void>;
35
- onData: (cb: (chunk: Uint8Array) => void) => void;
36
- };
37
- constructor(mediaSessionRef: string, voice: VoiceResponse);
38
- answer(): Promise<void>;
39
- setAudioFilters(filters: AudioFilterConfig[]): Promise<void>;
40
- hangup(): Promise<void>;
41
- say(text: string): Promise<void>;
42
- playDtmf(dtmf: string): Promise<void>;
43
- sgather(): Promise<{
44
- stop: () => Promise<void>;
45
- onData: (cb: (payload: {
46
- speech: string;
47
- responseTime: number;
48
- }) => void) => void;
49
- }>;
50
- stream(): Promise<{
51
- stop: () => Promise<void>;
52
- onData: (cb: (chunk: Uint8Array) => void) => void;
53
- }>;
54
- transfer(to: string, options: {
55
- record: boolean;
56
- timeout: number;
57
- }): Promise<void>;
58
- stopSpeech(): Promise<void>;
59
- stopStreams(): Promise<void>;
60
- }
61
- export { VoiceImpl };
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VoiceImpl = 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 common_1 = require("@fonoster/common");
23
- const uuid_1 = require("uuid");
24
- class VoiceImpl {
25
- constructor(mediaSessionRef, voice) {
26
- this.voice = voice;
27
- this.mediaSessionRef = mediaSessionRef;
28
- this.playbackRef = (0, uuid_1.v4)();
29
- }
30
- async answer() {
31
- await this.voice.answer();
32
- }
33
- async setAudioFilters(filters) {
34
- await this.voice.setAudioFilters(filters);
35
- }
36
- async hangup() {
37
- await this.voice.hangup();
38
- }
39
- async say(text) {
40
- await this.voice.say(text, { playbackRef: this.playbackRef });
41
- }
42
- async playDtmf(dtmf) {
43
- await this.voice.playDtmf(dtmf);
44
- }
45
- async sgather() {
46
- const stream = await this.voice.sgather({
47
- source: common_1.StreamGatherSource.SPEECH
48
- });
49
- this.sgatherStream = {
50
- stop: async () => {
51
- stream.close();
52
- stream.cleanup(() => { });
53
- },
54
- onData: (cb) => {
55
- stream.onPayload((payload) => {
56
- cb({
57
- speech: payload.speech,
58
- responseTime: payload.responseTime
59
- });
60
- });
61
- }
62
- };
63
- return this.sgatherStream;
64
- }
65
- async stream() {
66
- const stream = await this.voice.stream();
67
- this.vadStream = {
68
- stop: async () => {
69
- stream.close();
70
- stream.cleanup(() => { });
71
- },
72
- onData: (cb) => {
73
- stream.onPayload((payload) => {
74
- cb(payload.data);
75
- });
76
- }
77
- };
78
- return this.vadStream;
79
- }
80
- async transfer(to, options) {
81
- const { record, timeout } = options;
82
- const effectiveOptions = {
83
- recordDirection: record ? common_1.DialRecordDirection.BOTH : undefined,
84
- timeout
85
- };
86
- await this.voice.dial(to, effectiveOptions);
87
- }
88
- async stopSpeech() {
89
- await this.voice.stopSay();
90
- }
91
- async stopStreams() {
92
- await this.vadStream.stop();
93
- await this.sgatherStream.stop();
94
- }
95
- }
96
- exports.VoiceImpl = VoiceImpl;
@@ -1,2 +0,0 @@
1
- declare function startVoiceServer(skipIdentity: boolean): void;
2
- export { startVoiceServer };
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.startVoiceServer = startVoiceServer;
7
- /**
8
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
9
- * http://github.com/fonoster/fonoster
10
- *
11
- * This file is part of Fonoster
12
- *
13
- * Licensed under the MIT License (the "License");
14
- * you may not use this file except in compliance with
15
- * the License. You may obtain a copy of the License at
16
- *
17
- * https://opensource.org/licenses/MIT
18
- *
19
- * Unless required by applicable law or agreed to in writing, software
20
- * distributed under the License is distributed on an "AS IS" BASIS,
21
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- * See the License for the specific language governing permissions and
23
- * limitations under the License.
24
- */
25
- const voice_1 = __importDefault(require("@fonoster/voice"));
26
- const handleVoiceRequest_1 = require("./handleVoiceRequest");
27
- function startVoiceServer(skipIdentity) {
28
- new voice_1.default({ skipIdentity }).listen(handleVoiceRequest_1.handleVoiceRequest);
29
- }
File without changes