@fonoster/common 0.25.1 → 0.27.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.
@@ -18,6 +18,16 @@
18
18
  */
19
19
  import { z } from "zod";
20
20
  declare const assistantSchema: z.ZodObject<{
21
+ audioFilters: z.ZodDefault<z.ZodArray<z.ZodObject<{
22
+ name: z.ZodString;
23
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ options?: Record<string, unknown>;
26
+ name?: string;
27
+ }, {
28
+ options?: Record<string, unknown>;
29
+ name?: string;
30
+ }>, "many">>;
21
31
  conversationSettings: z.ZodObject<{
22
32
  firstMessage: z.ZodOptional<z.ZodString>;
23
33
  systemPrompt: z.ZodString;
@@ -526,6 +536,10 @@ declare const assistantSchema: z.ZodObject<{
526
536
  }[];
527
537
  }>>;
528
538
  }, "strip", z.ZodTypeAny, {
539
+ audioFilters?: {
540
+ options?: Record<string, unknown>;
541
+ name?: string;
542
+ }[];
529
543
  conversationSettings?: {
530
544
  firstMessage?: string;
531
545
  systemPrompt?: string;
@@ -622,6 +636,10 @@ declare const assistantSchema: z.ZodObject<{
622
636
  }[];
623
637
  };
624
638
  }, {
639
+ audioFilters?: {
640
+ options?: Record<string, unknown>;
641
+ name?: string;
642
+ }[];
625
643
  conversationSettings?: {
626
644
  firstMessage?: string;
627
645
  systemPrompt?: string;
@@ -20,11 +20,15 @@ exports.assistantSchema = void 0;
20
20
  * limitations under the License.
21
21
  */
22
22
  const zod_1 = require("zod");
23
+ const audioFiltersSchema_1 = require("./audioFiltersSchema");
23
24
  const conversationSettingsSchema_1 = require("./conversationSettingsSchema");
24
25
  const eventsHookSchema_1 = require("./eventsHookSchema");
25
26
  const languageModelConfigSchema_1 = require("./languageModelConfigSchema");
26
27
  const testCasesSchema_1 = require("./testCasesSchema");
27
28
  const assistantSchema = zod_1.z.object({
29
+ // Audio filters the Media Server runs on the caller's audio, before speech
30
+ // recognition and voice activity detection. Optional; none by default.
31
+ audioFilters: audioFiltersSchema_1.audioFiltersSchema,
28
32
  conversationSettings: conversationSettingsSchema_1.conversationSettingsSchema,
29
33
  languageModel: languageModelConfigSchema_1.languageModelConfigSchema,
30
34
  eventsHook: eventsHookSchema_1.eventsHookSchema.optional(),
@@ -0,0 +1,30 @@
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 { z } from "zod";
20
+ declare const audioFiltersSchema: z.ZodDefault<z.ZodArray<z.ZodObject<{
21
+ name: z.ZodString;
22
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ options?: Record<string, unknown>;
25
+ name?: string;
26
+ }, {
27
+ options?: Record<string, unknown>;
28
+ name?: string;
29
+ }>, "many">>;
30
+ export { audioFiltersSchema };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.audioFiltersSchema = 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 zod_1 = require("zod");
23
+ // Audio filters run in the Media Server. Options carry tuning values only;
24
+ // credentials live in the Media Server's environment, never in this config,
25
+ // so assistant files stay safe to commit and share.
26
+ const audioFiltersSchema = zod_1.z
27
+ .array(zod_1.z.object({
28
+ name: zod_1.z.string().min(1, { message: "An audio filter name is required" }),
29
+ options: zod_1.z.record(zod_1.z.unknown()).optional()
30
+ }))
31
+ .default([]);
32
+ exports.audioFiltersSchema = audioFiltersSchema;
@@ -17,6 +17,7 @@
17
17
  * limitations under the License.
18
18
  */
19
19
  export * from "./tools";
20
+ export * from "./audioFiltersSchema";
20
21
  export * from "./assistantSchema";
21
22
  export * from "./LanguageModelProvider";
22
23
  export * from "./conversationSettingsSchema";
@@ -33,6 +33,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
33
  * limitations under the License.
34
34
  */
35
35
  __exportStar(require("./tools"), exports);
36
+ __exportStar(require("./audioFiltersSchema"), exports);
36
37
  __exportStar(require("./assistantSchema"), exports);
37
38
  __exportStar(require("./LanguageModelProvider"), exports);
38
39
  __exportStar(require("./conversationSettingsSchema"), exports);
@@ -405,6 +405,36 @@ message StreamGatherPayload {
405
405
  int32 response_time = 4;
406
406
  }
407
407
 
408
+ // An audio filter the application wants applied to the caller's audio
409
+ message AudioFilter {
410
+ // Name of a filter registered in the Media Server (e.g. "aiCoustics")
411
+ string name = 1;
412
+
413
+ // Filter-specific options. Carries tuning values only; credentials are read
414
+ // from the Media Server's environment and never travel on this stream.
415
+ google.protobuf.Struct options = 2;
416
+ }
417
+
418
+ // Request to set the audio filters for the session. Sending it again replaces
419
+ // the previous filters; an empty list removes them.
420
+ message SetAudioFiltersRequest {
421
+ // The session reference generated by the Media Server
422
+ string media_session_ref = 1;
423
+
424
+ // Filters to run, in order
425
+ repeated AudioFilter filters = 2;
426
+ }
427
+
428
+ // Result of setting the session's audio filters. `error` is set when the
429
+ // filters could not be applied; the call continues with unfiltered audio.
430
+ message SetAudioFiltersResponse {
431
+ // The session reference generated by the Media Server
432
+ string media_session_ref = 1;
433
+
434
+ // Empty when the filters were applied
435
+ string error = 2;
436
+ }
437
+
408
438
  // VoiceInStream is the input stream for the voice service
409
439
  message VoiceInStream {
410
440
  oneof content {
@@ -461,6 +491,9 @@ message VoiceInStream {
461
491
 
462
492
  // Message with payload for the stream gather
463
493
  StreamGatherPayload stream_gather_payload = 17;
494
+
495
+ // Response to setting the session's audio filters
496
+ SetAudioFiltersResponse set_audio_filters_response = 19;
464
497
  }
465
498
  }
466
499
 
@@ -517,5 +550,8 @@ message VoiceOutStream {
517
550
 
518
551
  // Request to stop a stream gather
519
552
  StopStreamGatherRequest stop_stream_gather_request = 18;
553
+
554
+ // Request to set the audio filters for the session
555
+ SetAudioFiltersRequest set_audio_filters_request = 20;
520
556
  }
521
557
  }
@@ -71,8 +71,22 @@ declare enum StreamContent {
71
71
  START_STREAM_GATHER_RESPONSE = "startStreamGatherResponse",
72
72
  STOP_STREAM_GATHER_REQUEST = "stopStreamGatherRequest",
73
73
  STOP_STREAM_GATHER_RESPONSE = "stopStreamGatherResponse",
74
- STREAM_GATHER_PAYLOAD = "streamGatherPayload"
74
+ STREAM_GATHER_PAYLOAD = "streamGatherPayload",
75
+ SET_AUDIO_FILTERS_REQUEST = "setAudioFiltersRequest",
76
+ SET_AUDIO_FILTERS_RESPONSE = "setAudioFiltersResponse"
75
77
  }
78
+ type AudioFilterConfig = {
79
+ name: string;
80
+ options?: Record<string, unknown>;
81
+ };
82
+ type SetAudioFiltersRequest = {
83
+ mediaSessionRef: string;
84
+ filters: AudioFilterConfig[];
85
+ };
86
+ type SetAudioFiltersResponse = {
87
+ mediaSessionRef: string;
88
+ error?: string;
89
+ };
76
90
  declare enum AmdStatus {
77
91
  UNSPECIFIED = "AMD_STATUS_UNSPECIFIED",
78
92
  HUMAN = "HUMAN",
@@ -123,6 +137,7 @@ type VoiceIn = {
123
137
  startStreamGatherResponse?: VerbResponse;
124
138
  stopStreamGatherResponse?: VerbResponse;
125
139
  stopSayResponse?: VerbResponse;
140
+ setAudioFiltersResponse?: SetAudioFiltersResponse;
126
141
  };
127
142
  type VoiceOut = {
128
143
  answerRequest?: VerbRequest;
@@ -142,6 +157,7 @@ type VoiceOut = {
142
157
  startStreamGatherRequest?: StartStreamGatherRequest;
143
158
  stopStreamGatherRequest?: VerbRequest;
144
159
  stopSayRequest?: StopSayRequest;
160
+ setAudioFiltersRequest?: SetAudioFiltersRequest;
145
161
  };
146
162
  type BaseVoiceStream<T, W> = {
147
163
  removeListener: (e: StreamEvent, cb: (voice: T) => void) => void;
@@ -152,4 +168,4 @@ type BaseVoiceStream<T, W> = {
152
168
  };
153
169
  type VoiceSessionStreamServer = BaseVoiceStream<VoiceIn, VoiceOut>;
154
170
  type VoiceSessionStreamClient = BaseVoiceStream<VoiceOut | GrpcError, VoiceIn | GrpcError>;
155
- export { Amd, AmdStatus, DATA, END, ERROR, StreamContent, StreamEvent, VoiceClientConfig, VoiceIn, VoiceOut, VoiceSessionStreamClient, VoiceSessionStreamServer };
171
+ export { Amd, AmdStatus, AudioFilterConfig, DATA, END, ERROR, SetAudioFiltersRequest, SetAudioFiltersResponse, StreamContent, StreamEvent, VoiceClientConfig, VoiceIn, VoiceOut, VoiceSessionStreamClient, VoiceSessionStreamServer };
@@ -49,6 +49,8 @@ var StreamContent;
49
49
  StreamContent["STOP_STREAM_GATHER_REQUEST"] = "stopStreamGatherRequest";
50
50
  StreamContent["STOP_STREAM_GATHER_RESPONSE"] = "stopStreamGatherResponse";
51
51
  StreamContent["STREAM_GATHER_PAYLOAD"] = "streamGatherPayload";
52
+ StreamContent["SET_AUDIO_FILTERS_REQUEST"] = "setAudioFiltersRequest";
53
+ StreamContent["SET_AUDIO_FILTERS_RESPONSE"] = "setAudioFiltersResponse";
52
54
  })(StreamContent || (exports.StreamContent = StreamContent = {}));
53
55
  // Answering Machine Detection verdict. String values match the proto enum value
54
56
  // names so the object round-trips through @grpc/proto-loader (enums: String).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/common",
3
- "version": "0.25.1",
3
+ "version": "0.27.0",
4
4
  "description": "Common library for Fonoster projects",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -18,8 +18,8 @@
18
18
  "clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo"
19
19
  },
20
20
  "dependencies": {
21
- "@fonoster/logger": "^0.25.0",
22
- "@fonoster/types": "^0.25.0",
21
+ "@fonoster/logger": "^0.27.0",
22
+ "@fonoster/types": "^0.27.0",
23
23
  "@grpc/grpc-js": "~1.10.11",
24
24
  "@grpc/proto-loader": "^0.7.15",
25
25
  "@influxdata/influxdb-client": "^1.35.0",
@@ -50,5 +50,5 @@
50
50
  "devDependencies": {
51
51
  "@types/nodemailer": "^6.4.21"
52
52
  },
53
- "gitHead": "7a3786a2704ae379211fbd350a3f6e8d913a5fd6"
53
+ "gitHead": "1191b34677b51a36000177887ff82303ef2693e1"
54
54
  }