@fonoster/autopilot 0.8.50 → 0.8.52
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/Autopilot.js +5 -4
- package/dist/machine/actions/announceIdleTimeout.d.ts +4 -0
- package/dist/machine/actions/announceIdleTimeout.js +30 -0
- package/dist/machine/actions/announceSystemError.d.ts +4 -0
- package/dist/machine/actions/announceSystemError.js +30 -0
- package/dist/machine/actions/appendSpeech.d.ts +1 -0
- package/dist/machine/actions/appendSpeech.js +35 -0
- package/dist/machine/actions/cleanSpeech.d.ts +1 -0
- package/dist/machine/actions/cleanSpeech.js +23 -0
- package/dist/machine/actions/goodbye.d.ts +4 -0
- package/dist/machine/actions/goodbye.js +31 -0
- package/dist/machine/actions/greetUser.d.ts +4 -0
- package/dist/machine/actions/greetUser.js +33 -0
- package/dist/machine/actions/increaseIdleTimeoutCount.d.ts +1 -0
- package/dist/machine/actions/increaseIdleTimeoutCount.js +31 -0
- package/dist/machine/actions/index.d.ts +12 -0
- package/dist/machine/actions/index.js +45 -0
- package/dist/machine/actions/interruptPlayback.d.ts +4 -0
- package/dist/machine/actions/interruptPlayback.js +30 -0
- package/dist/machine/actions/resetIdleTimeoutCount.d.ts +1 -0
- package/dist/machine/actions/resetIdleTimeoutCount.js +31 -0
- package/dist/machine/actions/resetState.d.ts +1 -0
- package/dist/machine/actions/resetState.js +33 -0
- package/dist/machine/actions/setSpeaking.d.ts +1 -0
- package/dist/machine/actions/setSpeaking.js +29 -0
- package/dist/machine/actions/setSpeakingDone.d.ts +1 -0
- package/dist/machine/actions/setSpeakingDone.js +29 -0
- package/dist/machine/actors/doProcessUserRequest.d.ts +4 -0
- package/dist/machine/actors/doProcessUserRequest.js +65 -0
- package/dist/machine/actors/index.d.ts +1 -0
- package/dist/machine/actors/index.js +35 -0
- package/dist/machine/context.d.ts +22 -0
- package/dist/machine/context.js +41 -0
- package/dist/machine/delays.d.ts +12 -0
- package/dist/machine/delays.js +31 -0
- package/dist/machine/guards/hasSpeechResult.d.ts +4 -0
- package/dist/machine/guards/hasSpeechResult.js +30 -0
- package/dist/machine/guards/idleTimeoutCountExceedsMax.d.ts +4 -0
- package/dist/machine/guards/idleTimeoutCountExceedsMax.js +31 -0
- package/dist/machine/guards/index.d.ts +3 -0
- package/dist/machine/guards/index.js +27 -0
- package/dist/machine/guards/isSpeaking.d.ts +4 -0
- package/dist/machine/guards/isSpeaking.js +30 -0
- package/dist/machine/machine.d.ts +222 -74
- package/dist/machine/machine.js +19 -221
- package/dist/machine/setup.d.ts +172 -0
- package/dist/machine/setup.js +81 -0
- package/dist/voice/Voice.d.ts +8 -2
- package/dist/voice/Voice.js +4 -1
- package/dist/voice/types.d.ts +4 -1
- package/package.json +7 -7
package/dist/Autopilot.js
CHANGED
|
@@ -89,10 +89,11 @@ class Autopilot {
|
|
|
89
89
|
async setupSpeechGathering() {
|
|
90
90
|
const { voice } = this.params;
|
|
91
91
|
const stream = await voice.sgather();
|
|
92
|
-
stream.onData((
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
stream.onData((payload) => {
|
|
93
|
+
const { speech, responseTime } = payload;
|
|
94
|
+
logger.verbose("received speech result", { speech, responseTime });
|
|
95
|
+
if (payload.speech) {
|
|
96
|
+
this.actor.send({ type: "SPEECH_RESULT", speech, responseTime });
|
|
96
97
|
}
|
|
97
98
|
});
|
|
98
99
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.announceIdleTimeout = 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 announceIdleTimeout = async ({ context }) => {
|
|
25
|
+
logger.verbose("called the announceIdleTimeout action", {
|
|
26
|
+
idleMessage: context.idleMessage
|
|
27
|
+
});
|
|
28
|
+
await context.voice.say(context.idleMessage);
|
|
29
|
+
};
|
|
30
|
+
exports.announceIdleTimeout = announceIdleTimeout;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.announceSystemError = 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 announceSystemError = async ({ context }) => {
|
|
25
|
+
logger.verbose("called the announceSystemError action", {
|
|
26
|
+
systemErrorMessage: context.systemErrorMessage
|
|
27
|
+
});
|
|
28
|
+
await context.voice.say(context.systemErrorMessage);
|
|
29
|
+
};
|
|
30
|
+
exports.announceSystemError = announceSystemError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const appendSpeech: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, import("xstate").NonReducibleUnknown, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appendSpeech = 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
|
+
const logger_1 = require("@fonoster/logger");
|
|
24
|
+
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
25
|
+
exports.appendSpeech = (0, xstate_1.assign)(({ context, event }) => {
|
|
26
|
+
const speech = event.speech;
|
|
27
|
+
logger.verbose("called the appendSpeech action", { speech });
|
|
28
|
+
if (!speech) {
|
|
29
|
+
return context;
|
|
30
|
+
}
|
|
31
|
+
context.speechBuffer = ((context.speechBuffer ?? "") +
|
|
32
|
+
" " +
|
|
33
|
+
speech).trimStart();
|
|
34
|
+
return context;
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cleanSpeech: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, import("xstate").NonReducibleUnknown, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -0,0 +1,23 @@
|
|
|
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: "" });
|
|
@@ -0,0 +1,31 @@
|
|
|
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;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.greetUser = 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 greetUser = async ({ context }) => {
|
|
25
|
+
logger.verbose("called the greetUser action", {
|
|
26
|
+
firstMessage: context.firstMessage
|
|
27
|
+
});
|
|
28
|
+
await context.voice.answer();
|
|
29
|
+
if (context.firstMessage) {
|
|
30
|
+
await context.voice.say(context.firstMessage);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.greetUser = greetUser;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const increaseIdleTimeoutCount: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, import("xstate").NonReducibleUnknown, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 xstate_1 = require("xstate");
|
|
23
|
+
const logger_1 = require("@fonoster/logger");
|
|
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
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { greetUser } from "./greetUser";
|
|
2
|
+
export { goodbye } from "./goodbye";
|
|
3
|
+
export { announceSystemError } from "./announceSystemError";
|
|
4
|
+
export { interruptPlayback } from "./interruptPlayback";
|
|
5
|
+
export { announceIdleTimeout } from "./announceIdleTimeout";
|
|
6
|
+
export { increaseIdleTimeoutCount } from "./increaseIdleTimeoutCount";
|
|
7
|
+
export { cleanSpeech } from "./cleanSpeech";
|
|
8
|
+
export { appendSpeech } from "./appendSpeech";
|
|
9
|
+
export { resetIdleTimeoutCount } from "./resetIdleTimeoutCount";
|
|
10
|
+
export { setSpeaking } from "./setSpeaking";
|
|
11
|
+
export { setSpeakingDone } from "./setSpeakingDone";
|
|
12
|
+
export { resetState } from "./resetState";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetState = exports.setSpeakingDone = exports.setSpeaking = exports.resetIdleTimeoutCount = exports.appendSpeech = exports.cleanSpeech = exports.increaseIdleTimeoutCount = exports.announceIdleTimeout = exports.interruptPlayback = exports.announceSystemError = exports.goodbye = exports.greetUser = 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 greetUser_1 = require("./greetUser");
|
|
23
|
+
Object.defineProperty(exports, "greetUser", { enumerable: true, get: function () { return greetUser_1.greetUser; } });
|
|
24
|
+
var goodbye_1 = require("./goodbye");
|
|
25
|
+
Object.defineProperty(exports, "goodbye", { enumerable: true, get: function () { return goodbye_1.goodbye; } });
|
|
26
|
+
var announceSystemError_1 = require("./announceSystemError");
|
|
27
|
+
Object.defineProperty(exports, "announceSystemError", { enumerable: true, get: function () { return announceSystemError_1.announceSystemError; } });
|
|
28
|
+
var interruptPlayback_1 = require("./interruptPlayback");
|
|
29
|
+
Object.defineProperty(exports, "interruptPlayback", { enumerable: true, get: function () { return interruptPlayback_1.interruptPlayback; } });
|
|
30
|
+
var announceIdleTimeout_1 = require("./announceIdleTimeout");
|
|
31
|
+
Object.defineProperty(exports, "announceIdleTimeout", { enumerable: true, get: function () { return announceIdleTimeout_1.announceIdleTimeout; } });
|
|
32
|
+
var increaseIdleTimeoutCount_1 = require("./increaseIdleTimeoutCount");
|
|
33
|
+
Object.defineProperty(exports, "increaseIdleTimeoutCount", { enumerable: true, get: function () { return increaseIdleTimeoutCount_1.increaseIdleTimeoutCount; } });
|
|
34
|
+
var cleanSpeech_1 = require("./cleanSpeech");
|
|
35
|
+
Object.defineProperty(exports, "cleanSpeech", { enumerable: true, get: function () { return cleanSpeech_1.cleanSpeech; } });
|
|
36
|
+
var appendSpeech_1 = require("./appendSpeech");
|
|
37
|
+
Object.defineProperty(exports, "appendSpeech", { enumerable: true, get: function () { return appendSpeech_1.appendSpeech; } });
|
|
38
|
+
var resetIdleTimeoutCount_1 = require("./resetIdleTimeoutCount");
|
|
39
|
+
Object.defineProperty(exports, "resetIdleTimeoutCount", { enumerable: true, get: function () { return resetIdleTimeoutCount_1.resetIdleTimeoutCount; } });
|
|
40
|
+
var setSpeaking_1 = require("./setSpeaking");
|
|
41
|
+
Object.defineProperty(exports, "setSpeaking", { enumerable: true, get: function () { return setSpeaking_1.setSpeaking; } });
|
|
42
|
+
var setSpeakingDone_1 = require("./setSpeakingDone");
|
|
43
|
+
Object.defineProperty(exports, "setSpeakingDone", { enumerable: true, get: function () { return setSpeakingDone_1.setSpeakingDone; } });
|
|
44
|
+
var resetState_1 = require("./resetState");
|
|
45
|
+
Object.defineProperty(exports, "resetState", { enumerable: true, get: function () { return resetState_1.resetState; } });
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
sessionRef: context.sessionRef
|
|
27
|
+
});
|
|
28
|
+
await context.voice.stopSpeech();
|
|
29
|
+
};
|
|
30
|
+
exports.interruptPlayback = interruptPlayback;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resetIdleTimeoutCount: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, import("xstate").NonReducibleUnknown, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 xstate_1 = require("xstate");
|
|
23
|
+
const logger_1 = require("@fonoster/logger");
|
|
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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resetState: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, import("xstate").NonReducibleUnknown, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -0,0 +1,33 @@
|
|
|
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 xstate_1 = require("xstate");
|
|
23
|
+
const logger_1 = require("@fonoster/logger");
|
|
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
|
+
isSpeaking: false
|
|
32
|
+
};
|
|
33
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const setSpeaking: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, import("xstate").NonReducibleUnknown, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setSpeaking = 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
|
+
const logger_1 = require("@fonoster/logger");
|
|
24
|
+
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
25
|
+
exports.setSpeaking = (0, xstate_1.assign)(({ context }) => {
|
|
26
|
+
logger.verbose("called the setSpeaking action", { isSpeaking: true });
|
|
27
|
+
context.isSpeaking = true;
|
|
28
|
+
return context;
|
|
29
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const setSpeakingDone: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").AnyEventObject, import("xstate").EventObject, import("xstate").NonReducibleUnknown, import("xstate").ProvidedActor, never, never, never, never>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setSpeakingDone = 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
|
+
const logger_1 = require("@fonoster/logger");
|
|
24
|
+
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
25
|
+
exports.setSpeakingDone = (0, xstate_1.assign)(({ context }) => {
|
|
26
|
+
logger.verbose("called the setSpeakingDone action", { isSpeaking: false });
|
|
27
|
+
context.isSpeaking = false;
|
|
28
|
+
return context;
|
|
29
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
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 xstate_1 = require("xstate");
|
|
23
|
+
const logger_1 = require("@fonoster/logger");
|
|
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
|
+
});
|
|
30
|
+
// Stop any speech that might be playing
|
|
31
|
+
await context.voice.stopSpeech();
|
|
32
|
+
const languageModel = context.languageModel;
|
|
33
|
+
const speech = context.speechBuffer.trim();
|
|
34
|
+
const response = await languageModel.invoke(speech);
|
|
35
|
+
try {
|
|
36
|
+
if (response.type === "say" && !response.content) {
|
|
37
|
+
logger.verbose("call might already be hung up");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
else if (response.type === "hangup") {
|
|
41
|
+
const message = context.goodbyeMessage;
|
|
42
|
+
await context.voice.say(message);
|
|
43
|
+
await context.voice.hangup();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
else if (response.type === "transfer") {
|
|
47
|
+
logger.verbose("transferring call to a number in the PSTN", {
|
|
48
|
+
phoneNumber: context.transferPhoneNumber
|
|
49
|
+
});
|
|
50
|
+
const message = context.transferMessage;
|
|
51
|
+
await context.voice.say(message);
|
|
52
|
+
await context.voice.stopStreams();
|
|
53
|
+
await context.voice.transfer(context.transferPhoneNumber, {
|
|
54
|
+
record: true,
|
|
55
|
+
timeout: 30
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
await context.voice.say(response.content);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
logger.error("error processing user request", { error });
|
|
63
|
+
await context.voice.say(context.systemErrorMessage);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./doProcessUserRequest";
|
|
@@ -0,0 +1,35 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/*
|
|
18
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
19
|
+
* http://github.com/fonoster/fonoster
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Fonoster
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the MIT License (the "License");
|
|
24
|
+
* you may not use this file except in compliance with
|
|
25
|
+
* the License. You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* https://opensource.org/licenses/MIT
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
__exportStar(require("./doProcessUserRequest"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare const context: ({ input }: {
|
|
2
|
+
input: any;
|
|
3
|
+
}) => {
|
|
4
|
+
sessionRef: any;
|
|
5
|
+
voice: any;
|
|
6
|
+
languageModel: any;
|
|
7
|
+
speechBuffer: string;
|
|
8
|
+
firstMessage: any;
|
|
9
|
+
goodbyeMessage: any;
|
|
10
|
+
transferMessage: any;
|
|
11
|
+
transferPhoneNumber: any;
|
|
12
|
+
systemErrorMessage: any;
|
|
13
|
+
idleMessage: any;
|
|
14
|
+
idleTimeout: any;
|
|
15
|
+
maxIdleTimeoutCount: any;
|
|
16
|
+
idleTimeoutCount: number;
|
|
17
|
+
maxSpeechWaitTimeout: any;
|
|
18
|
+
isSpeaking: boolean;
|
|
19
|
+
sessionStartTime: number;
|
|
20
|
+
maxSessionDuration: any;
|
|
21
|
+
};
|
|
22
|
+
export { context };
|