@fonoster/autopilot 0.26.0 → 0.30.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.
- package/README.md +14 -51
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -5
- package/dist/knowledge/AbstractKnowledgeBase.d.ts +3 -2
- package/dist/knowledge/AbstractKnowledgeBase.js +2 -7
- package/dist/knowledge/FilesKnowledgeBase.d.ts +1 -1
- package/dist/knowledge/types.d.ts +1 -1
- package/dist/models/LanguageModelFactory.d.ts +5 -24
- package/dist/models/LanguageModelFactory.js +0 -1
- package/dist/models/createLanguageModel.d.ts +2 -2
- package/dist/models/evaluations/createEvalEffectiveConfig.d.ts +10 -106
- package/dist/models/evaluations/createEvalEffectiveConfig.js +47 -7
- package/dist/models/evaluations/createEvaluateIntelligence.d.ts +10 -20
- package/dist/models/evaluations/createEvaluateIntelligence.js +32 -23
- package/dist/models/evaluations/evalTestCases.d.ts +2 -2
- package/dist/models/evaluations/extractAiResponse.d.ts +2 -3
- package/dist/models/evaluations/index.d.ts +1 -0
- package/dist/models/evaluations/index.js +1 -0
- package/dist/models/evaluations/runEval.d.ts +2 -20
- package/dist/models/evaluations/session/EvalSession.d.ts +73 -0
- package/dist/models/evaluations/session/EvalSession.js +134 -0
- package/dist/models/evaluations/session/evaluateSessionScenario.d.ts +58 -0
- package/dist/models/evaluations/session/evaluateSessionScenario.js +182 -0
- package/dist/{vad → models/evaluations/session}/index.d.ts +3 -2
- package/dist/{vad → models/evaluations/session}/index.js +3 -2
- package/dist/models/evaluations/session/runSessionEval.d.ts +17 -0
- package/dist/models/evaluations/session/runSessionEval.js +59 -0
- package/dist/models/evaluations/types.d.ts +7 -6
- package/dist/models/types.d.ts +19 -1
- package/dist/session/Agent.d.ts +138 -0
- package/dist/session/Agent.js +474 -0
- package/dist/{loadAssistantFromAPI.d.ts → session/AsyncQueue.d.ts} +12 -7
- package/dist/session/AsyncQueue.js +67 -0
- package/dist/{machine/guards/index.d.ts → session/config.d.ts} +2 -2
- package/dist/session/config.js +27 -0
- package/dist/session/convertLegacyAssistant.d.ts +77 -0
- package/dist/session/convertLegacyAssistant.js +118 -0
- package/dist/session/createAutopilot.d.ts +47 -0
- package/dist/session/createAutopilot.js +119 -0
- package/dist/session/hosted.d.ts +456 -0
- package/dist/session/hosted.js +506 -0
- package/dist/{assistants → session}/index.d.ts +11 -2
- package/dist/{machine/actors → session}/index.js +11 -3
- package/dist/{machine/actions/appendSpeech.js → session/knowledge.d.ts} +14 -17
- package/dist/session/knowledge.js +10 -0
- package/dist/session/llm.d.ts +86 -0
- package/dist/session/llm.js +83 -0
- package/dist/session/machine.d.ts +206 -0
- package/dist/session/machine.js +126 -0
- package/dist/session/main.js +44 -0
- package/dist/session/sentences.d.ts +5 -0
- package/dist/session/sentences.js +53 -0
- package/dist/{machine/actors/index.d.ts → session/think.d.ts} +2 -3
- package/dist/{machine/actions/announceSystemError.js → session/think.js} +8 -10
- package/dist/session/tools.d.ts +22 -0
- package/dist/session/tools.js +83 -0
- package/dist/tools/builtin/transferToolDefinition.js +1 -1
- package/dist/voice/index.d.ts +0 -1
- package/dist/voice/index.js +0 -1
- package/dist/voice/types.d.ts +5 -18
- package/package.json +13 -14
- package/dist/Autopilot.d.ts +0 -14
- package/dist/Autopilot.js +0 -133
- package/dist/assistants/index.js +0 -36
- package/dist/assistants/loadAndValidateAssistant.d.ts +0 -3
- package/dist/assistants/loadAndValidateAssistant.js +0 -49
- package/dist/assistants/types.d.ts +0 -24
- package/dist/assistants/types.js +0 -2
- package/dist/envs.d.ts +0 -15
- package/dist/envs.js +0 -78
- package/dist/handleVoiceRequest.d.ts +0 -3
- package/dist/handleVoiceRequest.js +0 -167
- package/dist/loadAssistantConfigFromFile.d.ts +0 -3
- package/dist/loadAssistantConfigFromFile.js +0 -68
- package/dist/loadAssistantFromAPI.js +0 -98
- package/dist/machine/actions/announceSystemError.d.ts +0 -4
- package/dist/machine/actions/appendSpeech.d.ts +0 -1
- package/dist/machine/actions/cleanSpeech.d.ts +0 -1
- package/dist/machine/actions/cleanSpeech.js +0 -23
- package/dist/machine/actions/goodbye.d.ts +0 -4
- package/dist/machine/actions/goodbye.js +0 -31
- package/dist/machine/actions/increaseIdleTimeoutCount.d.ts +0 -1
- package/dist/machine/actions/increaseIdleTimeoutCount.js +0 -31
- package/dist/machine/actions/index.d.ts +0 -26
- package/dist/machine/actions/index.js +0 -37
- package/dist/machine/actions/interruptPlayback.d.ts +0 -4
- package/dist/machine/actions/interruptPlayback.js +0 -43
- package/dist/machine/actions/resetIdleTimeoutCount.d.ts +0 -1
- package/dist/machine/actions/resetIdleTimeoutCount.js +0 -31
- package/dist/machine/actions/resetState.d.ts +0 -1
- package/dist/machine/actions/resetState.js +0 -32
- package/dist/machine/actors/doAnnounceIdleTimeout.d.ts +0 -4
- package/dist/machine/actors/doAnnounceIdleTimeout.js +0 -41
- package/dist/machine/actors/doGreetUser.d.ts +0 -4
- package/dist/machine/actors/doGreetUser.js +0 -45
- package/dist/machine/actors/doProcessUserRequest.d.ts +0 -4
- package/dist/machine/actors/doProcessUserRequest.js +0 -75
- package/dist/machine/context.d.ts +0 -52
- package/dist/machine/context.js +0 -28
- package/dist/machine/delays.d.ts +0 -30
- package/dist/machine/delays.js +0 -37
- package/dist/machine/guards/hasSpeechResult.d.ts +0 -4
- package/dist/machine/guards/hasSpeechResult.js +0 -30
- package/dist/machine/guards/idleTimeoutCountExceedsMax.d.ts +0 -4
- package/dist/machine/guards/idleTimeoutCountExceedsMax.js +0 -31
- package/dist/machine/guards/index.js +0 -25
- package/dist/machine/index.d.ts +0 -19
- package/dist/machine/index.js +0 -23
- package/dist/machine/machine.d.ts +0 -408
- package/dist/machine/machine.js +0 -206
- package/dist/machine/setup.d.ts +0 -328
- package/dist/machine/setup.js +0 -116
- package/dist/machine/types.d.ts +0 -54
- package/dist/machine/types.js +0 -2
- package/dist/sendConversationEndedEvent.d.ts +0 -32
- package/dist/sendConversationEndedEvent.js +0 -66
- package/dist/sendConversationStartedEvent.d.ts +0 -6
- package/dist/sendConversationStartedEvent.js +0 -63
- package/dist/server.d.ts +0 -2
- package/dist/server.js +0 -25
- package/dist/types.d.ts +0 -40
- package/dist/types.js +0 -8
- package/dist/vad/SileroVad.d.ts +0 -18
- package/dist/vad/SileroVad.js +0 -40
- package/dist/vad/SileroVadModel.d.ts +0 -14
- package/dist/vad/SileroVadModel.js +0 -83
- package/dist/vad/chunkToFloat32Array.d.ts +0 -20
- package/dist/vad/chunkToFloat32Array.js +0 -34
- package/dist/vad/createVad.d.ts +0 -3
- package/dist/vad/createVad.js +0 -126
- package/dist/vad/types.d.ts +0 -60
- package/dist/vad/types.js +0 -2
- package/dist/vadWorker.js +0 -36
- package/dist/voice/Voice.d.ts +0 -61
- package/dist/voice/Voice.js +0 -96
- package/dist/voiceServerSetup.d.ts +0 -2
- package/dist/voiceServerSetup.js +0 -29
- /package/dist/{vadWorker.d.ts → session/main.d.ts} +0 -0
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.loadAssistantConfigFromFile = loadAssistantConfigFromFile;
|
|
37
|
-
/**
|
|
38
|
-
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
39
|
-
* http://github.com/fonoster/fonoster
|
|
40
|
-
*
|
|
41
|
-
* This file is part of Fonoster
|
|
42
|
-
*
|
|
43
|
-
* Licensed under the MIT License (the "License");
|
|
44
|
-
* you may not use this file except in compliance with
|
|
45
|
-
* the License. You may obtain a copy of the License at
|
|
46
|
-
*
|
|
47
|
-
* https://opensource.org/licenses/MIT
|
|
48
|
-
*
|
|
49
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
50
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
51
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
52
|
-
* See the License for the specific language governing permissions and
|
|
53
|
-
* limitations under the License.
|
|
54
|
-
*/
|
|
55
|
-
const path = __importStar(require("path"));
|
|
56
|
-
const logger_1 = require("@fonoster/logger");
|
|
57
|
-
const _1 = require(".");
|
|
58
|
-
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
59
|
-
function loadAssistantConfigFromFile(pathToAssistantConfig) {
|
|
60
|
-
try {
|
|
61
|
-
const assistantPath = path.resolve(process.cwd(), pathToAssistantConfig);
|
|
62
|
-
return (0, _1.loadAndValidateAssistant)(assistantPath);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
logger.error("Error loading assistant config from file", error);
|
|
66
|
-
throw error;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.loadAssistantFromAPI = loadAssistantFromAPI;
|
|
37
|
-
/**
|
|
38
|
-
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
39
|
-
* http://github.com/fonoster/fonoster
|
|
40
|
-
*
|
|
41
|
-
* This file is part of Fonoster
|
|
42
|
-
*
|
|
43
|
-
* Licensed under the MIT License (the "License");
|
|
44
|
-
* you may not use this file except in compliance with
|
|
45
|
-
* the License. You may obtain a copy of the License at
|
|
46
|
-
*
|
|
47
|
-
* https://opensource.org/licenses/MIT
|
|
48
|
-
*
|
|
49
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
50
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
51
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
52
|
-
* See the License for the specific language governing permissions and
|
|
53
|
-
* limitations under the License.
|
|
54
|
-
*/
|
|
55
|
-
const common_1 = require("@fonoster/common");
|
|
56
|
-
const common_2 = require("@fonoster/common");
|
|
57
|
-
const logger_1 = require("@fonoster/logger");
|
|
58
|
-
const SDK = __importStar(require("@fonoster/sdk"));
|
|
59
|
-
const envs_1 = require("./envs");
|
|
60
|
-
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
61
|
-
function loadAssistantFromAPI(req,
|
|
62
|
-
// TODO: Add validation for integrations
|
|
63
|
-
integrations) {
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
const clientConfig = {
|
|
66
|
-
accessKeyId: req.accessKeyId,
|
|
67
|
-
endpoint: envs_1.APISERVER_ENDPOINT,
|
|
68
|
-
allowInsecure: true,
|
|
69
|
-
withoutInterceptors: true
|
|
70
|
-
};
|
|
71
|
-
const client = new SDK.Client(clientConfig);
|
|
72
|
-
client.setAccessToken(req.sessionToken);
|
|
73
|
-
const applications = new SDK.Applications(client);
|
|
74
|
-
logger.verbose(`loading assistant config from api`, {
|
|
75
|
-
apiserver: envs_1.APISERVER_ENDPOINT,
|
|
76
|
-
appRef: req.appRef
|
|
77
|
-
});
|
|
78
|
-
applications
|
|
79
|
-
.getApplication(req.appRef)
|
|
80
|
-
.then((app) => {
|
|
81
|
-
logger.verbose(`get credentials for assistant`, {
|
|
82
|
-
appRef: req.appRef,
|
|
83
|
-
productRef: app.intelligence.productRef
|
|
84
|
-
});
|
|
85
|
-
const credentials = (0, common_1.findIntegrationsCredentials)(integrations, app.intelligence.productRef);
|
|
86
|
-
resolve(common_2.assistantSchema.parse({
|
|
87
|
-
...app.intelligence.config,
|
|
88
|
-
languageModel: {
|
|
89
|
-
...app.intelligence.config.languageModel,
|
|
90
|
-
apiKey: credentials.apiKey
|
|
91
|
-
}
|
|
92
|
-
}));
|
|
93
|
-
})
|
|
94
|
-
.catch((err) => {
|
|
95
|
-
reject(new Error(`Failed to load assistant config from API: ${err}`));
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const appendSpeech: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, {}, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const cleanSpeech: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, {}, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cleanSpeech = 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 xstate_1 = require("xstate");
|
|
23
|
-
exports.cleanSpeech = (0, xstate_1.assign)({ speechBuffer: "" });
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.goodbye = 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 goodbye = async ({ context }) => {
|
|
25
|
-
logger.verbose("called the goodbye action", {
|
|
26
|
-
goodbyeMessage: context.goodbyeMessage
|
|
27
|
-
});
|
|
28
|
-
await context.voice.say(context.goodbyeMessage);
|
|
29
|
-
await context.voice.hangup();
|
|
30
|
-
};
|
|
31
|
-
exports.goodbye = goodbye;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const increaseIdleTimeoutCount: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, {}, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.increaseIdleTimeoutCount = 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 xstate_1 = require("xstate");
|
|
24
|
-
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
25
|
-
exports.increaseIdleTimeoutCount = (0, xstate_1.assign)(({ context }) => {
|
|
26
|
-
logger.verbose("called the increaseIdleTimeoutCount action", {
|
|
27
|
-
idleTimeoutCount: context.idleTimeoutCount + 1
|
|
28
|
-
});
|
|
29
|
-
context.idleTimeoutCount++;
|
|
30
|
-
return context;
|
|
31
|
-
});
|
|
@@ -1,26 +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 { goodbye } from "./goodbye";
|
|
20
|
-
export { announceSystemError } from "./announceSystemError";
|
|
21
|
-
export { interruptPlayback } from "./interruptPlayback";
|
|
22
|
-
export { increaseIdleTimeoutCount } from "./increaseIdleTimeoutCount";
|
|
23
|
-
export { cleanSpeech } from "./cleanSpeech";
|
|
24
|
-
export { appendSpeech } from "./appendSpeech";
|
|
25
|
-
export { resetIdleTimeoutCount } from "./resetIdleTimeoutCount";
|
|
26
|
-
export { resetState } from "./resetState";
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resetState = exports.resetIdleTimeoutCount = exports.appendSpeech = exports.cleanSpeech = exports.increaseIdleTimeoutCount = exports.interruptPlayback = exports.announceSystemError = exports.goodbye = 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 goodbye_1 = require("./goodbye");
|
|
23
|
-
Object.defineProperty(exports, "goodbye", { enumerable: true, get: function () { return goodbye_1.goodbye; } });
|
|
24
|
-
var announceSystemError_1 = require("./announceSystemError");
|
|
25
|
-
Object.defineProperty(exports, "announceSystemError", { enumerable: true, get: function () { return announceSystemError_1.announceSystemError; } });
|
|
26
|
-
var interruptPlayback_1 = require("./interruptPlayback");
|
|
27
|
-
Object.defineProperty(exports, "interruptPlayback", { enumerable: true, get: function () { return interruptPlayback_1.interruptPlayback; } });
|
|
28
|
-
var increaseIdleTimeoutCount_1 = require("./increaseIdleTimeoutCount");
|
|
29
|
-
Object.defineProperty(exports, "increaseIdleTimeoutCount", { enumerable: true, get: function () { return increaseIdleTimeoutCount_1.increaseIdleTimeoutCount; } });
|
|
30
|
-
var cleanSpeech_1 = require("./cleanSpeech");
|
|
31
|
-
Object.defineProperty(exports, "cleanSpeech", { enumerable: true, get: function () { return cleanSpeech_1.cleanSpeech; } });
|
|
32
|
-
var appendSpeech_1 = require("./appendSpeech");
|
|
33
|
-
Object.defineProperty(exports, "appendSpeech", { enumerable: true, get: function () { return appendSpeech_1.appendSpeech; } });
|
|
34
|
-
var resetIdleTimeoutCount_1 = require("./resetIdleTimeoutCount");
|
|
35
|
-
Object.defineProperty(exports, "resetIdleTimeoutCount", { enumerable: true, get: function () { return resetIdleTimeoutCount_1.resetIdleTimeoutCount; } });
|
|
36
|
-
var resetState_1 = require("./resetState");
|
|
37
|
-
Object.defineProperty(exports, "resetState", { enumerable: true, get: function () { return resetState_1.resetState; } });
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.interruptPlayback = 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 interruptPlayback = async ({ context }) => {
|
|
25
|
-
logger.verbose("called the interruptPlayback action", {
|
|
26
|
-
mediaSessionRef: context.mediaSessionRef
|
|
27
|
-
});
|
|
28
|
-
try {
|
|
29
|
-
await context.voice.stopSpeech();
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
// The call may have hung up (or the session otherwise ended) right as we
|
|
33
|
-
// asked it to stop speaking, so the underlying verb never gets a
|
|
34
|
-
// response and rejects. There's nothing left to interrupt at that point,
|
|
35
|
-
// so this is expected and must not escape as an unhandled rejection —
|
|
36
|
-
// this action isn't awaited by the state machine.
|
|
37
|
-
logger.verbose("stopSpeech failed while interrupting playback", {
|
|
38
|
-
mediaSessionRef: context.mediaSessionRef,
|
|
39
|
-
error
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
exports.interruptPlayback = interruptPlayback;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const resetIdleTimeoutCount: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, {}, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resetIdleTimeoutCount = 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 xstate_1 = require("xstate");
|
|
24
|
-
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
25
|
-
exports.resetIdleTimeoutCount = (0, xstate_1.assign)(({ context }) => {
|
|
26
|
-
logger.verbose("called the resetIdleTimeoutCount action", {
|
|
27
|
-
idleTimeoutCount: 0
|
|
28
|
-
});
|
|
29
|
-
context.idleTimeoutCount = 0;
|
|
30
|
-
return context;
|
|
31
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const resetState: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, {}, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resetState = 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 xstate_1 = require("xstate");
|
|
24
|
-
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
25
|
-
exports.resetState = (0, xstate_1.assign)(({ context }) => {
|
|
26
|
-
logger.verbose("called the resetState action");
|
|
27
|
-
return {
|
|
28
|
-
...context,
|
|
29
|
-
speechBuffer: "",
|
|
30
|
-
idleTimeoutCount: 0
|
|
31
|
-
};
|
|
32
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.doAnnounceIdleTimeout = 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 xstate_1 = require("xstate");
|
|
24
|
-
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
25
|
-
// Invoked (not fired-and-forgotten) so the machine stays in
|
|
26
|
-
// "announcingIdleTimeout" until the idle message has been fully played. The
|
|
27
|
-
// idle clock is re-armed only when the machine returns to "idle", so the time
|
|
28
|
-
// the assistant spends talking never counts as user silence.
|
|
29
|
-
exports.doAnnounceIdleTimeout = (0, xstate_1.fromPromise)(async ({ input }) => {
|
|
30
|
-
const { context } = input;
|
|
31
|
-
logger.verbose("called the doAnnounceIdleTimeout actor", {
|
|
32
|
-
idleMessage: context.idleMessage,
|
|
33
|
-
idleTimeoutCount: context.idleTimeoutCount
|
|
34
|
-
});
|
|
35
|
-
try {
|
|
36
|
-
await context.voice.say(context.idleMessage);
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
logger.error("error while announcing the idle timeout", { error });
|
|
40
|
-
}
|
|
41
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.doGreetUser = 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 xstate_1 = require("xstate");
|
|
24
|
-
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
25
|
-
// Invoked (not fired-and-forgotten) so the machine stays in "greeting" until
|
|
26
|
-
// the first message has been fully played. Otherwise the idle clock would start
|
|
27
|
-
// while the assistant is still talking.
|
|
28
|
-
exports.doGreetUser = (0, xstate_1.fromPromise)(async ({ input }) => {
|
|
29
|
-
const { context } = input;
|
|
30
|
-
logger.verbose("called the doGreetUser actor", {
|
|
31
|
-
firstMessage: context.firstMessage
|
|
32
|
-
});
|
|
33
|
-
try {
|
|
34
|
-
await context.voice.answer();
|
|
35
|
-
if (context.initialDtmf) {
|
|
36
|
-
await context.voice.playDtmf(context.initialDtmf);
|
|
37
|
-
}
|
|
38
|
-
if (context.firstMessage) {
|
|
39
|
-
await context.voice.say(context.firstMessage);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
logger.error("error while greeting the user", { error });
|
|
44
|
-
}
|
|
45
|
-
});
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.doProcessUserRequest = 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 xstate_1 = require("xstate");
|
|
24
|
-
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
25
|
-
exports.doProcessUserRequest = (0, xstate_1.fromPromise)(async ({ input }) => {
|
|
26
|
-
const { context } = input;
|
|
27
|
-
logger.verbose("called processUserRequest actor", {
|
|
28
|
-
speechBuffer: context.speechBuffer,
|
|
29
|
-
hasLateSpeech: context.hasLateSpeech
|
|
30
|
-
});
|
|
31
|
-
// Stop any speech that might be playing. The call may have already hung
|
|
32
|
-
// up, in which case the underlying verb rejects because it never gets a
|
|
33
|
-
// response - there's nothing left to interrupt, so we swallow it rather
|
|
34
|
-
// than let it fail the whole actor.
|
|
35
|
-
try {
|
|
36
|
-
await context.voice.stopSpeech();
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
logger.verbose("stopSpeech failed while processing user request", {
|
|
40
|
-
mediaSessionRef: context.mediaSessionRef,
|
|
41
|
-
error
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
const languageModel = context.languageModel;
|
|
45
|
-
const speech = context.speechBuffer.trim();
|
|
46
|
-
const response = await languageModel.invoke(speech, context.hasLateSpeech);
|
|
47
|
-
try {
|
|
48
|
-
if (response.type === "say" && !response.content) {
|
|
49
|
-
logger.warn("ignoring say response with no content");
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
else if (response.type === "hangup") {
|
|
53
|
-
await context.voice.say(context.goodbyeMessage);
|
|
54
|
-
await context.voice.hangup();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
else if (response.type === "transfer") {
|
|
58
|
-
logger.verbose("transferring call to a number in the PSTN", {
|
|
59
|
-
phoneNumber: context.transferPhoneNumber
|
|
60
|
-
});
|
|
61
|
-
await context.voice.say(context.transferMessage);
|
|
62
|
-
await context.voice.stopStreams();
|
|
63
|
-
await context.voice.transfer(context.transferPhoneNumber, {
|
|
64
|
-
record: true,
|
|
65
|
-
timeout: context.transferTimeout / 1000
|
|
66
|
-
});
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
await context.voice.say(response.content);
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
logger.error("error processing user request", { error });
|
|
73
|
-
await context.voice.say(context.systemErrorMessage);
|
|
74
|
-
}
|
|
75
|
-
});
|