@fonoster/common 0.22.0 → 0.23.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.
@@ -67,6 +67,40 @@ message CreateSessionRequest {
67
67
 
68
68
  // Metadata associated with the session
69
69
  map<string, string> metadata = 10;
70
+
71
+ // Answering Machine Detection result, computed on early call audio before
72
+ // this session is dispatched. Absent/UNSPECIFIED when the probe is disabled.
73
+ Amd amd = 12;
74
+ }
75
+
76
+ // Answering Machine Detection verdict for the answered call
77
+ message Amd {
78
+ enum Status {
79
+ // The probe was disabled or did not run
80
+ AMD_STATUS_UNSPECIFIED = 0;
81
+ // A live person answered
82
+ HUMAN = 1;
83
+ // A generic answering machine answered
84
+ MACHINE = 2;
85
+ // A personal or carrier voicemail greeting answered
86
+ VOICEMAIL = 3;
87
+ // An auto-attendant / IVR menu answered
88
+ IVR = 4;
89
+ // The probe ran but was inconclusive (low confidence, silence, or timeout)
90
+ UNKNOWN = 5;
91
+ }
92
+
93
+ // The detected class of answerer
94
+ Status status = 1;
95
+
96
+ // Model confidence for the reported status, 0..1
97
+ float confidence = 2;
98
+
99
+ // Identifier of the detector that produced the verdict (e.g. "asterisk-amd@1")
100
+ string detector = 3;
101
+
102
+ // Wall-clock time spent producing the verdict, in milliseconds
103
+ int32 latency_ms = 4;
70
104
  }
71
105
 
72
106
  // Common request for verbs
@@ -65,7 +65,20 @@ function sendHttpRequest(request) {
65
65
  method: effectiveMethod
66
66
  });
67
67
  if (!waitForResponse && effectiveMethod === AllowedHttpMethod.POST) {
68
- setTimeout(() => fetch(effectiveUrl, options), 0);
68
+ setTimeout(() => {
69
+ fetch(effectiveUrl, options)
70
+ .then((res) => {
71
+ logger.verbose(`fire-and-forget request to ${effectiveUrl} completed`, {
72
+ status: res.status,
73
+ ok: res.ok
74
+ });
75
+ })
76
+ .catch((error) => {
77
+ logger.error(`fire-and-forget request to ${effectiveUrl} failed`, {
78
+ error: error instanceof Error ? error.message : error
79
+ });
80
+ });
81
+ }, 0);
69
82
  return { result: "success" };
70
83
  }
71
84
  else {
@@ -73,6 +73,20 @@ declare enum StreamContent {
73
73
  STOP_STREAM_GATHER_RESPONSE = "stopStreamGatherResponse",
74
74
  STREAM_GATHER_PAYLOAD = "streamGatherPayload"
75
75
  }
76
+ declare enum AmdStatus {
77
+ UNSPECIFIED = "AMD_STATUS_UNSPECIFIED",
78
+ HUMAN = "HUMAN",
79
+ MACHINE = "MACHINE",
80
+ VOICEMAIL = "VOICEMAIL",
81
+ IVR = "IVR",
82
+ UNKNOWN = "UNKNOWN"
83
+ }
84
+ type Amd = {
85
+ status: AmdStatus;
86
+ confidence: number;
87
+ detector: string;
88
+ latencyMs: number;
89
+ };
76
90
  type VoiceClientConfig = {
77
91
  appRef: string;
78
92
  accessKeyId: string;
@@ -85,6 +99,7 @@ type VoiceClientConfig = {
85
99
  sessionToken: string;
86
100
  callDirection: CallDirection;
87
101
  metadata?: Record<string, string>;
102
+ amd?: Amd;
88
103
  };
89
104
  type VoiceIn = {
90
105
  request?: VoiceRequest;
@@ -137,4 +152,4 @@ type BaseVoiceStream<T, W> = {
137
152
  };
138
153
  type VoiceSessionStreamServer = BaseVoiceStream<VoiceIn, VoiceOut>;
139
154
  type VoiceSessionStreamClient = BaseVoiceStream<VoiceOut | GrpcError, VoiceIn | GrpcError>;
140
- export { DATA, END, ERROR, StreamContent, StreamEvent, VoiceClientConfig, VoiceIn, VoiceOut, VoiceSessionStreamClient, VoiceSessionStreamServer };
155
+ export { Amd, AmdStatus, DATA, END, ERROR, StreamContent, StreamEvent, VoiceClientConfig, VoiceIn, VoiceOut, VoiceSessionStreamClient, VoiceSessionStreamServer };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StreamEvent = exports.StreamContent = exports.ERROR = exports.END = exports.DATA = void 0;
3
+ exports.StreamEvent = exports.StreamContent = exports.ERROR = exports.END = exports.DATA = exports.AmdStatus = void 0;
4
4
  const DATA = "data";
5
5
  exports.DATA = DATA;
6
6
  const END = "end";
@@ -50,3 +50,14 @@ var StreamContent;
50
50
  StreamContent["STOP_STREAM_GATHER_RESPONSE"] = "stopStreamGatherResponse";
51
51
  StreamContent["STREAM_GATHER_PAYLOAD"] = "streamGatherPayload";
52
52
  })(StreamContent || (exports.StreamContent = StreamContent = {}));
53
+ // Answering Machine Detection verdict. String values match the proto enum value
54
+ // names so the object round-trips through @grpc/proto-loader (enums: String).
55
+ var AmdStatus;
56
+ (function (AmdStatus) {
57
+ AmdStatus["UNSPECIFIED"] = "AMD_STATUS_UNSPECIFIED";
58
+ AmdStatus["HUMAN"] = "HUMAN";
59
+ AmdStatus["MACHINE"] = "MACHINE";
60
+ AmdStatus["VOICEMAIL"] = "VOICEMAIL";
61
+ AmdStatus["IVR"] = "IVR";
62
+ AmdStatus["UNKNOWN"] = "UNKNOWN";
63
+ })(AmdStatus || (exports.AmdStatus = AmdStatus = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/common",
3
- "version": "0.22.0",
3
+ "version": "0.23.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,7 +18,7 @@
18
18
  "clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo"
19
19
  },
20
20
  "dependencies": {
21
- "@fonoster/logger": "^0.22.0",
21
+ "@fonoster/logger": "^0.23.0",
22
22
  "@grpc/grpc-js": "~1.10.11",
23
23
  "@grpc/proto-loader": "^0.7.15",
24
24
  "@influxdata/influxdb-client": "^1.35.0",
@@ -49,5 +49,5 @@
49
49
  "devDependencies": {
50
50
  "@types/nodemailer": "^6.4.21"
51
51
  },
52
- "gitHead": "6095b02e5744b17ddc65f48ff1eb6cb54b8de48f"
52
+ "gitHead": "acdd199a840d56419e25dae015d3b74892fe86cc"
53
53
  }