@sinch/functions-runtime 0.6.3 → 0.7.1
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 +7 -7
- package/dist/bin/sinch-runtime.js +11 -3
- package/dist/bin/sinch-runtime.js.map +1 -1
- package/dist/{chunk-H2JZGXXT.js → chunk-5K5FDUEL.js} +1003 -192
- package/dist/chunk-5K5FDUEL.js.map +1 -0
- package/dist/index.d.ts +68 -2
- package/dist/index.js +13 -1
- package/dist/voice/v2.d.ts +5 -0
- package/dist/voice/v2.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-H2JZGXXT.js.map +0 -1
|
@@ -15640,7 +15640,7 @@ var require_mime_types = __commonJS({
|
|
|
15640
15640
|
}
|
|
15641
15641
|
return exports.types[extension2] || false;
|
|
15642
15642
|
}
|
|
15643
|
-
function populateMaps(extensions,
|
|
15643
|
+
function populateMaps(extensions, types2) {
|
|
15644
15644
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
15645
15645
|
var mime = db[type];
|
|
15646
15646
|
var exts = mime.extensions;
|
|
@@ -15650,14 +15650,14 @@ var require_mime_types = __commonJS({
|
|
|
15650
15650
|
extensions[type] = exts;
|
|
15651
15651
|
for (var i = 0; i < exts.length; i++) {
|
|
15652
15652
|
var extension2 = exts[i];
|
|
15653
|
-
|
|
15653
|
+
types2[extension2] = _preferredType(extension2, types2[extension2], type);
|
|
15654
15654
|
const legacyType = _preferredTypeLegacy(
|
|
15655
15655
|
extension2,
|
|
15656
|
-
|
|
15656
|
+
types2[extension2],
|
|
15657
15657
|
type
|
|
15658
15658
|
);
|
|
15659
|
-
if (legacyType !==
|
|
15660
|
-
exports._extensionConflicts.push([extension2, legacyType,
|
|
15659
|
+
if (legacyType !== types2[extension2]) {
|
|
15660
|
+
exports._extensionConflicts.push([extension2, legacyType, types2[extension2]]);
|
|
15661
15661
|
}
|
|
15662
15662
|
}
|
|
15663
15663
|
});
|
|
@@ -15763,23 +15763,23 @@ var require_type_is = __commonJS({
|
|
|
15763
15763
|
module.exports.match = mimeMatch;
|
|
15764
15764
|
function typeis(value, types_) {
|
|
15765
15765
|
var i;
|
|
15766
|
-
var
|
|
15766
|
+
var types2 = types_;
|
|
15767
15767
|
var val = tryNormalizeType(value);
|
|
15768
15768
|
if (!val) {
|
|
15769
15769
|
return false;
|
|
15770
15770
|
}
|
|
15771
|
-
if (
|
|
15772
|
-
|
|
15773
|
-
for (i = 0; i <
|
|
15774
|
-
|
|
15771
|
+
if (types2 && !Array.isArray(types2)) {
|
|
15772
|
+
types2 = new Array(arguments.length - 1);
|
|
15773
|
+
for (i = 0; i < types2.length; i++) {
|
|
15774
|
+
types2[i] = arguments[i + 1];
|
|
15775
15775
|
}
|
|
15776
15776
|
}
|
|
15777
|
-
if (!
|
|
15777
|
+
if (!types2 || !types2.length) {
|
|
15778
15778
|
return val;
|
|
15779
15779
|
}
|
|
15780
15780
|
var type;
|
|
15781
|
-
for (i = 0; i <
|
|
15782
|
-
if (mimeMatch(normalize(type =
|
|
15781
|
+
for (i = 0; i < types2.length; i++) {
|
|
15782
|
+
if (mimeMatch(normalize(type = types2[i]), val)) {
|
|
15783
15783
|
return type[0] === "+" || type.indexOf("*") !== -1 ? val : type;
|
|
15784
15784
|
}
|
|
15785
15785
|
}
|
|
@@ -15790,9 +15790,9 @@ var require_type_is = __commonJS({
|
|
|
15790
15790
|
}
|
|
15791
15791
|
function typeofrequest(req, types_) {
|
|
15792
15792
|
if (!hasbody(req)) return null;
|
|
15793
|
-
var
|
|
15793
|
+
var types2 = arguments.length > 2 ? Array.prototype.slice.call(arguments, 1) : types_;
|
|
15794
15794
|
var value = req.headers["content-type"];
|
|
15795
|
-
return typeis(value,
|
|
15795
|
+
return typeis(value, types2);
|
|
15796
15796
|
}
|
|
15797
15797
|
function normalize(type) {
|
|
15798
15798
|
if (typeof type !== "string") {
|
|
@@ -16315,7 +16315,7 @@ var require_object_inspect = __commonJS({
|
|
|
16315
16315
|
} else if (indexOf(seen, obj) >= 0) {
|
|
16316
16316
|
return "[Circular]";
|
|
16317
16317
|
}
|
|
16318
|
-
function
|
|
16318
|
+
function inspect3(value, from, noIndent) {
|
|
16319
16319
|
if (from) {
|
|
16320
16320
|
seen = $arrSlice.call(seen);
|
|
16321
16321
|
seen.push(from);
|
|
@@ -16333,7 +16333,7 @@ var require_object_inspect = __commonJS({
|
|
|
16333
16333
|
}
|
|
16334
16334
|
if (typeof obj === "function" && !isRegExp2(obj)) {
|
|
16335
16335
|
var name = nameOf(obj);
|
|
16336
|
-
var keys = arrObjKeys(obj,
|
|
16336
|
+
var keys = arrObjKeys(obj, inspect3);
|
|
16337
16337
|
return "[Function" + (name ? ": " + name : " (anonymous)") + "]" + (keys.length > 0 ? " { " + $join.call(keys, ", ") + " }" : "");
|
|
16338
16338
|
}
|
|
16339
16339
|
if (isSymbol(obj)) {
|
|
@@ -16357,16 +16357,16 @@ var require_object_inspect = __commonJS({
|
|
|
16357
16357
|
if (obj.length === 0) {
|
|
16358
16358
|
return "[]";
|
|
16359
16359
|
}
|
|
16360
|
-
var xs = arrObjKeys(obj,
|
|
16360
|
+
var xs = arrObjKeys(obj, inspect3);
|
|
16361
16361
|
if (indent && !singleLineValues(xs)) {
|
|
16362
16362
|
return "[" + indentedJoin(xs, indent) + "]";
|
|
16363
16363
|
}
|
|
16364
16364
|
return "[ " + $join.call(xs, ", ") + " ]";
|
|
16365
16365
|
}
|
|
16366
16366
|
if (isError(obj)) {
|
|
16367
|
-
var parts = arrObjKeys(obj,
|
|
16367
|
+
var parts = arrObjKeys(obj, inspect3);
|
|
16368
16368
|
if (!("cause" in Error.prototype) && "cause" in obj && !isEnumerable.call(obj, "cause")) {
|
|
16369
|
-
return "{ [" + String(obj) + "] " + $join.call($concat.call("[cause]: " +
|
|
16369
|
+
return "{ [" + String(obj) + "] " + $join.call($concat.call("[cause]: " + inspect3(obj.cause), parts), ", ") + " }";
|
|
16370
16370
|
}
|
|
16371
16371
|
if (parts.length === 0) {
|
|
16372
16372
|
return "[" + String(obj) + "]";
|
|
@@ -16384,7 +16384,7 @@ var require_object_inspect = __commonJS({
|
|
|
16384
16384
|
var mapParts = [];
|
|
16385
16385
|
if (mapForEach) {
|
|
16386
16386
|
mapForEach.call(obj, function(value, key) {
|
|
16387
|
-
mapParts.push(
|
|
16387
|
+
mapParts.push(inspect3(key, obj, true) + " => " + inspect3(value, obj));
|
|
16388
16388
|
});
|
|
16389
16389
|
}
|
|
16390
16390
|
return collectionOf("Map", mapSize.call(obj), mapParts, indent);
|
|
@@ -16393,7 +16393,7 @@ var require_object_inspect = __commonJS({
|
|
|
16393
16393
|
var setParts = [];
|
|
16394
16394
|
if (setForEach) {
|
|
16395
16395
|
setForEach.call(obj, function(value) {
|
|
16396
|
-
setParts.push(
|
|
16396
|
+
setParts.push(inspect3(value, obj));
|
|
16397
16397
|
});
|
|
16398
16398
|
}
|
|
16399
16399
|
return collectionOf("Set", setSize.call(obj), setParts, indent);
|
|
@@ -16408,16 +16408,16 @@ var require_object_inspect = __commonJS({
|
|
|
16408
16408
|
return weakCollectionOf("WeakRef");
|
|
16409
16409
|
}
|
|
16410
16410
|
if (isNumber2(obj)) {
|
|
16411
|
-
return markBoxed(
|
|
16411
|
+
return markBoxed(inspect3(Number(obj)));
|
|
16412
16412
|
}
|
|
16413
16413
|
if (isBigInt(obj)) {
|
|
16414
|
-
return markBoxed(
|
|
16414
|
+
return markBoxed(inspect3(bigIntValueOf.call(obj)));
|
|
16415
16415
|
}
|
|
16416
16416
|
if (isBoolean2(obj)) {
|
|
16417
16417
|
return markBoxed(booleanValueOf.call(obj));
|
|
16418
16418
|
}
|
|
16419
16419
|
if (isString2(obj)) {
|
|
16420
|
-
return markBoxed(
|
|
16420
|
+
return markBoxed(inspect3(String(obj)));
|
|
16421
16421
|
}
|
|
16422
16422
|
if (typeof window !== "undefined" && obj === window) {
|
|
16423
16423
|
return "{ [object Window] }";
|
|
@@ -16426,7 +16426,7 @@ var require_object_inspect = __commonJS({
|
|
|
16426
16426
|
return "{ [object globalThis] }";
|
|
16427
16427
|
}
|
|
16428
16428
|
if (!isDate2(obj) && !isRegExp2(obj)) {
|
|
16429
|
-
var ys = arrObjKeys(obj,
|
|
16429
|
+
var ys = arrObjKeys(obj, inspect3);
|
|
16430
16430
|
var isPlainObject3 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
|
|
16431
16431
|
var protoTag = obj instanceof Object ? "" : "null prototype";
|
|
16432
16432
|
var stringTag = !isPlainObject3 && toStringTag2 && Object(obj) === obj && toStringTag2 in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
|
|
@@ -16680,13 +16680,13 @@ var require_object_inspect = __commonJS({
|
|
|
16680
16680
|
var lineJoiner = "\n" + indent.prev + indent.base;
|
|
16681
16681
|
return lineJoiner + $join.call(xs, "," + lineJoiner) + "\n" + indent.prev;
|
|
16682
16682
|
}
|
|
16683
|
-
function arrObjKeys(obj,
|
|
16683
|
+
function arrObjKeys(obj, inspect3) {
|
|
16684
16684
|
var isArr = isArray2(obj);
|
|
16685
16685
|
var xs = [];
|
|
16686
16686
|
if (isArr) {
|
|
16687
16687
|
xs.length = obj.length;
|
|
16688
16688
|
for (var i = 0; i < obj.length; i++) {
|
|
16689
|
-
xs[i] = has(obj, i) ?
|
|
16689
|
+
xs[i] = has(obj, i) ? inspect3(obj[i], obj) : "";
|
|
16690
16690
|
}
|
|
16691
16691
|
}
|
|
16692
16692
|
var syms = typeof gOPS === "function" ? gOPS(obj) : [];
|
|
@@ -16707,15 +16707,15 @@ var require_object_inspect = __commonJS({
|
|
|
16707
16707
|
if (hasShammedSymbols && symMap["$" + key] instanceof Symbol) {
|
|
16708
16708
|
continue;
|
|
16709
16709
|
} else if ($test.call(/[^\w$]/, key)) {
|
|
16710
|
-
xs.push(
|
|
16710
|
+
xs.push(inspect3(key, obj) + ": " + inspect3(obj[key], obj));
|
|
16711
16711
|
} else {
|
|
16712
|
-
xs.push(key + ": " +
|
|
16712
|
+
xs.push(key + ": " + inspect3(obj[key], obj));
|
|
16713
16713
|
}
|
|
16714
16714
|
}
|
|
16715
16715
|
if (typeof gOPS === "function") {
|
|
16716
16716
|
for (var j = 0; j < syms.length; j++) {
|
|
16717
16717
|
if (isEnumerable.call(obj, syms[j])) {
|
|
16718
|
-
xs.push("[" +
|
|
16718
|
+
xs.push("[" + inspect3(syms[j]) + "]: " + inspect3(obj[syms[j]], obj));
|
|
16719
16719
|
}
|
|
16720
16720
|
}
|
|
16721
16721
|
}
|
|
@@ -16728,7 +16728,7 @@ var require_object_inspect = __commonJS({
|
|
|
16728
16728
|
var require_side_channel_list = __commonJS({
|
|
16729
16729
|
"../../node_modules/side-channel-list/index.js"(exports, module) {
|
|
16730
16730
|
"use strict";
|
|
16731
|
-
var
|
|
16731
|
+
var inspect3 = require_object_inspect();
|
|
16732
16732
|
var $TypeError = require_type();
|
|
16733
16733
|
var listGetNode = function(list, key, isDelete) {
|
|
16734
16734
|
var prev = list;
|
|
@@ -16782,7 +16782,7 @@ var require_side_channel_list = __commonJS({
|
|
|
16782
16782
|
var channel = {
|
|
16783
16783
|
assert: function(key) {
|
|
16784
16784
|
if (!channel.has(key)) {
|
|
16785
|
-
throw new $TypeError("Side channel does not contain " +
|
|
16785
|
+
throw new $TypeError("Side channel does not contain " + inspect3(key));
|
|
16786
16786
|
}
|
|
16787
16787
|
},
|
|
16788
16788
|
"delete": function(key) {
|
|
@@ -17642,7 +17642,7 @@ var require_side_channel_map = __commonJS({
|
|
|
17642
17642
|
"use strict";
|
|
17643
17643
|
var GetIntrinsic = require_get_intrinsic();
|
|
17644
17644
|
var callBound = require_call_bound();
|
|
17645
|
-
var
|
|
17645
|
+
var inspect3 = require_object_inspect();
|
|
17646
17646
|
var $TypeError = require_type();
|
|
17647
17647
|
var $Map = GetIntrinsic("%Map%", true);
|
|
17648
17648
|
var $mapGet = callBound("Map.prototype.get", true);
|
|
@@ -17656,7 +17656,7 @@ var require_side_channel_map = __commonJS({
|
|
|
17656
17656
|
var channel = {
|
|
17657
17657
|
assert: function(key) {
|
|
17658
17658
|
if (!channel.has(key)) {
|
|
17659
|
-
throw new $TypeError("Side channel does not contain " +
|
|
17659
|
+
throw new $TypeError("Side channel does not contain " + inspect3(key));
|
|
17660
17660
|
}
|
|
17661
17661
|
},
|
|
17662
17662
|
"delete": function(key) {
|
|
@@ -17698,7 +17698,7 @@ var require_side_channel_weakmap = __commonJS({
|
|
|
17698
17698
|
"use strict";
|
|
17699
17699
|
var GetIntrinsic = require_get_intrinsic();
|
|
17700
17700
|
var callBound = require_call_bound();
|
|
17701
|
-
var
|
|
17701
|
+
var inspect3 = require_object_inspect();
|
|
17702
17702
|
var getSideChannelMap = require_side_channel_map();
|
|
17703
17703
|
var $TypeError = require_type();
|
|
17704
17704
|
var $WeakMap = GetIntrinsic("%WeakMap%", true);
|
|
@@ -17714,7 +17714,7 @@ var require_side_channel_weakmap = __commonJS({
|
|
|
17714
17714
|
var channel = {
|
|
17715
17715
|
assert: function(key) {
|
|
17716
17716
|
if (!channel.has(key)) {
|
|
17717
|
-
throw new $TypeError("Side channel does not contain " +
|
|
17717
|
+
throw new $TypeError("Side channel does not contain " + inspect3(key));
|
|
17718
17718
|
}
|
|
17719
17719
|
},
|
|
17720
17720
|
"delete": function(key) {
|
|
@@ -17770,7 +17770,7 @@ var require_side_channel = __commonJS({
|
|
|
17770
17770
|
"../../node_modules/side-channel/index.js"(exports, module) {
|
|
17771
17771
|
"use strict";
|
|
17772
17772
|
var $TypeError = require_type();
|
|
17773
|
-
var
|
|
17773
|
+
var inspect3 = require_object_inspect();
|
|
17774
17774
|
var getSideChannelList = require_side_channel_list();
|
|
17775
17775
|
var getSideChannelMap = require_side_channel_map();
|
|
17776
17776
|
var getSideChannelWeakMap = require_side_channel_weakmap();
|
|
@@ -17780,7 +17780,7 @@ var require_side_channel = __commonJS({
|
|
|
17780
17780
|
var channel = {
|
|
17781
17781
|
assert: function(key) {
|
|
17782
17782
|
if (!channel.has(key)) {
|
|
17783
|
-
throw new $TypeError("Side channel does not contain " +
|
|
17783
|
+
throw new $TypeError("Side channel does not contain " + inspect3(key));
|
|
17784
17784
|
}
|
|
17785
17785
|
},
|
|
17786
17786
|
"delete": function(key) {
|
|
@@ -19320,7 +19320,7 @@ var require_mime_types2 = __commonJS({
|
|
|
19320
19320
|
}
|
|
19321
19321
|
return exports.types[extension2] || false;
|
|
19322
19322
|
}
|
|
19323
|
-
function populateMaps(extensions,
|
|
19323
|
+
function populateMaps(extensions, types2) {
|
|
19324
19324
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
19325
19325
|
var mime = db[type];
|
|
19326
19326
|
var exts = mime.extensions;
|
|
@@ -19330,14 +19330,14 @@ var require_mime_types2 = __commonJS({
|
|
|
19330
19330
|
extensions[type] = exts;
|
|
19331
19331
|
for (var i = 0; i < exts.length; i++) {
|
|
19332
19332
|
var extension2 = exts[i];
|
|
19333
|
-
|
|
19333
|
+
types2[extension2] = _preferredType(extension2, types2[extension2], type);
|
|
19334
19334
|
const legacyType = _preferredTypeLegacy(
|
|
19335
19335
|
extension2,
|
|
19336
|
-
|
|
19336
|
+
types2[extension2],
|
|
19337
19337
|
type
|
|
19338
19338
|
);
|
|
19339
|
-
if (legacyType !==
|
|
19340
|
-
exports._extensionConflicts.push([extension2, legacyType,
|
|
19339
|
+
if (legacyType !== types2[extension2]) {
|
|
19340
|
+
exports._extensionConflicts.push([extension2, legacyType, types2[extension2]]);
|
|
19341
19341
|
}
|
|
19342
19342
|
}
|
|
19343
19343
|
});
|
|
@@ -20206,8 +20206,8 @@ var require_utils3 = __commonJS({
|
|
|
20206
20206
|
exports.normalizeType = function(type) {
|
|
20207
20207
|
return ~type.indexOf("/") ? acceptParams(type) : { value: mime.lookup(type) || "application/octet-stream", params: {} };
|
|
20208
20208
|
};
|
|
20209
|
-
exports.normalizeTypes = function(
|
|
20210
|
-
return
|
|
20209
|
+
exports.normalizeTypes = function(types2) {
|
|
20210
|
+
return types2.map(exports.normalizeType);
|
|
20211
20211
|
};
|
|
20212
20212
|
function acceptParams(str) {
|
|
20213
20213
|
var length = str.length;
|
|
@@ -20781,7 +20781,7 @@ var require_layer = __commonJS({
|
|
|
20781
20781
|
this.params = void 0;
|
|
20782
20782
|
this.path = void 0;
|
|
20783
20783
|
this.slash = path7 === "/" && opts.end === false;
|
|
20784
|
-
function
|
|
20784
|
+
function matcher2(_path) {
|
|
20785
20785
|
if (_path instanceof RegExp) {
|
|
20786
20786
|
const keys = [];
|
|
20787
20787
|
let name = 0;
|
|
@@ -20819,7 +20819,7 @@ var require_layer = __commonJS({
|
|
|
20819
20819
|
decode: decodeParam
|
|
20820
20820
|
});
|
|
20821
20821
|
}
|
|
20822
|
-
this.matchers = Array.isArray(path7) ? path7.map(
|
|
20822
|
+
this.matchers = Array.isArray(path7) ? path7.map(matcher2) : [matcher2(path7)];
|
|
20823
20823
|
}
|
|
20824
20824
|
Layer.prototype.handleError = function handleError(error, req, res, next) {
|
|
20825
20825
|
const fn = this.handle;
|
|
@@ -22312,7 +22312,7 @@ var require_mime_types3 = __commonJS({
|
|
|
22312
22312
|
}
|
|
22313
22313
|
return exports.types[extension2] || false;
|
|
22314
22314
|
}
|
|
22315
|
-
function populateMaps(extensions,
|
|
22315
|
+
function populateMaps(extensions, types2) {
|
|
22316
22316
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
22317
22317
|
var mime = db[type];
|
|
22318
22318
|
var exts = mime.extensions;
|
|
@@ -22322,14 +22322,14 @@ var require_mime_types3 = __commonJS({
|
|
|
22322
22322
|
extensions[type] = exts;
|
|
22323
22323
|
for (var i = 0; i < exts.length; i++) {
|
|
22324
22324
|
var extension2 = exts[i];
|
|
22325
|
-
|
|
22325
|
+
types2[extension2] = _preferredType(extension2, types2[extension2], type);
|
|
22326
22326
|
const legacyType = _preferredTypeLegacy(
|
|
22327
22327
|
extension2,
|
|
22328
|
-
|
|
22328
|
+
types2[extension2],
|
|
22329
22329
|
type
|
|
22330
22330
|
);
|
|
22331
|
-
if (legacyType !==
|
|
22332
|
-
exports._extensionConflicts.push([extension2, legacyType,
|
|
22331
|
+
if (legacyType !== types2[extension2]) {
|
|
22332
|
+
exports._extensionConflicts.push([extension2, legacyType, types2[extension2]]);
|
|
22333
22333
|
}
|
|
22334
22334
|
}
|
|
22335
22335
|
});
|
|
@@ -22366,23 +22366,23 @@ var require_accepts = __commonJS({
|
|
|
22366
22366
|
this.negotiator = new Negotiator(req);
|
|
22367
22367
|
}
|
|
22368
22368
|
Accepts.prototype.type = Accepts.prototype.types = function(types_) {
|
|
22369
|
-
var
|
|
22370
|
-
if (
|
|
22371
|
-
|
|
22372
|
-
for (var i = 0; i <
|
|
22373
|
-
|
|
22369
|
+
var types2 = types_;
|
|
22370
|
+
if (types2 && !Array.isArray(types2)) {
|
|
22371
|
+
types2 = new Array(arguments.length);
|
|
22372
|
+
for (var i = 0; i < types2.length; i++) {
|
|
22373
|
+
types2[i] = arguments[i];
|
|
22374
22374
|
}
|
|
22375
22375
|
}
|
|
22376
|
-
if (!
|
|
22376
|
+
if (!types2 || types2.length === 0) {
|
|
22377
22377
|
return this.negotiator.mediaTypes();
|
|
22378
22378
|
}
|
|
22379
22379
|
if (!this.headers.accept) {
|
|
22380
|
-
return
|
|
22380
|
+
return types2[0];
|
|
22381
22381
|
}
|
|
22382
|
-
var mimes =
|
|
22382
|
+
var mimes = types2.map(extToMime);
|
|
22383
22383
|
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime));
|
|
22384
22384
|
var first = accepts[0];
|
|
22385
|
-
return first ?
|
|
22385
|
+
return first ? types2[mimes.indexOf(first)] : false;
|
|
22386
22386
|
};
|
|
22387
22387
|
Accepts.prototype.encoding = Accepts.prototype.encodings = function(encodings_) {
|
|
22388
22388
|
var encodings = encodings_;
|
|
@@ -22643,9 +22643,9 @@ var require_request = __commonJS({
|
|
|
22643
22643
|
var querystring = parse2(this).query;
|
|
22644
22644
|
return queryparse(querystring);
|
|
22645
22645
|
});
|
|
22646
|
-
req.is = function is(
|
|
22647
|
-
var arr =
|
|
22648
|
-
if (!Array.isArray(
|
|
22646
|
+
req.is = function is(types2) {
|
|
22647
|
+
var arr = types2;
|
|
22648
|
+
if (!Array.isArray(types2)) {
|
|
22649
22649
|
arr = new Array(arguments.length);
|
|
22650
22650
|
for (var i = 0; i < arr.length; i++) {
|
|
22651
22651
|
arr[i] = arguments[i];
|
|
@@ -23192,7 +23192,7 @@ var require_mime_types4 = __commonJS({
|
|
|
23192
23192
|
}
|
|
23193
23193
|
return exports.types[extension2] || false;
|
|
23194
23194
|
}
|
|
23195
|
-
function populateMaps(extensions,
|
|
23195
|
+
function populateMaps(extensions, types2) {
|
|
23196
23196
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
23197
23197
|
var mime = db[type];
|
|
23198
23198
|
var exts = mime.extensions;
|
|
@@ -23202,14 +23202,14 @@ var require_mime_types4 = __commonJS({
|
|
|
23202
23202
|
extensions[type] = exts;
|
|
23203
23203
|
for (var i = 0; i < exts.length; i++) {
|
|
23204
23204
|
var extension2 = exts[i];
|
|
23205
|
-
|
|
23205
|
+
types2[extension2] = _preferredType(extension2, types2[extension2], type);
|
|
23206
23206
|
const legacyType = _preferredTypeLegacy(
|
|
23207
23207
|
extension2,
|
|
23208
|
-
|
|
23208
|
+
types2[extension2],
|
|
23209
23209
|
type
|
|
23210
23210
|
);
|
|
23211
|
-
if (legacyType !==
|
|
23212
|
-
exports._extensionConflicts.push([extension2, legacyType,
|
|
23211
|
+
if (legacyType !== types2[extension2]) {
|
|
23212
|
+
exports._extensionConflicts.push([extension2, legacyType, types2[extension2]]);
|
|
23213
23213
|
}
|
|
23214
23214
|
}
|
|
23215
23215
|
});
|
|
@@ -44303,7 +44303,7 @@ var require_mime_types5 = __commonJS({
|
|
|
44303
44303
|
}
|
|
44304
44304
|
return exports.types[extension2] || false;
|
|
44305
44305
|
}
|
|
44306
|
-
function populateMaps(extensions,
|
|
44306
|
+
function populateMaps(extensions, types2) {
|
|
44307
44307
|
var preference = ["nginx", "apache", void 0, "iana"];
|
|
44308
44308
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
44309
44309
|
var mime = db[type];
|
|
@@ -44314,14 +44314,14 @@ var require_mime_types5 = __commonJS({
|
|
|
44314
44314
|
extensions[type] = exts;
|
|
44315
44315
|
for (var i = 0; i < exts.length; i++) {
|
|
44316
44316
|
var extension2 = exts[i];
|
|
44317
|
-
if (
|
|
44318
|
-
var from = preference.indexOf(db[
|
|
44317
|
+
if (types2[extension2]) {
|
|
44318
|
+
var from = preference.indexOf(db[types2[extension2]].source);
|
|
44319
44319
|
var to = preference.indexOf(mime.source);
|
|
44320
|
-
if (
|
|
44320
|
+
if (types2[extension2] !== "application/octet-stream" && (from > to || from === to && types2[extension2].substr(0, 12) === "application/")) {
|
|
44321
44321
|
continue;
|
|
44322
44322
|
}
|
|
44323
44323
|
}
|
|
44324
|
-
|
|
44324
|
+
types2[extension2] = type;
|
|
44325
44325
|
}
|
|
44326
44326
|
});
|
|
44327
44327
|
}
|
|
@@ -59157,7 +59157,9 @@ function createConnectAgentAction(provider, agentId, options) {
|
|
|
59157
59157
|
transport,
|
|
59158
59158
|
...options?.cli && { cli: options.cli },
|
|
59159
59159
|
...options?.maxDuration !== void 0 && { maxDuration: options.maxDuration },
|
|
59160
|
-
...options?.suppressCallbacks !== void 0 && {
|
|
59160
|
+
...options?.suppressCallbacks !== void 0 && {
|
|
59161
|
+
suppressCallbacks: options.suppressCallbacks
|
|
59162
|
+
},
|
|
59161
59163
|
...callHeaders2 && { callHeaders: callHeaders2 }
|
|
59162
59164
|
};
|
|
59163
59165
|
}
|
|
@@ -59886,7 +59888,8 @@ var UniversalConfig = class {
|
|
|
59886
59888
|
secrets: {},
|
|
59887
59889
|
hasApplicationCredentials: !!this.getApplicationCredentials()
|
|
59888
59890
|
};
|
|
59889
|
-
for (const
|
|
59891
|
+
for (const key of Object.getOwnPropertyNames(this.env)) {
|
|
59892
|
+
const value = this.env[key];
|
|
59890
59893
|
if (secretKeys.some((secretKey) => key.includes(secretKey))) {
|
|
59891
59894
|
summary.secrets[key] = value ? "[REDACTED]" : "[NOT SET]";
|
|
59892
59895
|
} else if (["NODE_ENV", "PORT", "SINCH_REGION"].includes(key)) {
|
|
@@ -60223,6 +60226,67 @@ function toHeaderMap(headers) {
|
|
|
60223
60226
|
return { ...headers };
|
|
60224
60227
|
}
|
|
60225
60228
|
|
|
60229
|
+
// ../voice-v2-preview/dist/core/say-limit.js
|
|
60230
|
+
var MAX_SAY_CHARS = 600;
|
|
60231
|
+
var MAX_MESSAGES = 10;
|
|
60232
|
+
var EXCERPT_CHARS = 40;
|
|
60233
|
+
var WHITESPACE = "\\u0009-\\u000D\\u0020\\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000";
|
|
60234
|
+
var SENTENCE_BREAK = new RegExp(`(?<=[.!?]+["'\u201D\u2019)\\]]*)[${WHITESPACE}]+`, "g");
|
|
60235
|
+
var EDGE_WHITESPACE = new RegExp(`^[${WHITESPACE}]+|[${WHITESPACE}]+$`, "g");
|
|
60236
|
+
function sayParts(text, format) {
|
|
60237
|
+
if (text.length <= MAX_SAY_CHARS)
|
|
60238
|
+
return [text];
|
|
60239
|
+
if (format === "SSML") {
|
|
60240
|
+
throw new Error(`Voice v2 limits each SAY message to ${MAX_SAY_CHARS} characters, and SSML is never split. This SSML document is ${text.length} characters. Shorten it, or pass it as several say() calls.`);
|
|
60241
|
+
}
|
|
60242
|
+
return packSentences(text.replace(EDGE_WHITESPACE, ""));
|
|
60243
|
+
}
|
|
60244
|
+
function assertPromptFits(text) {
|
|
60245
|
+
if (text.length > MAX_SAY_CHARS) {
|
|
60246
|
+
throw new Error(`Voice v2 limits each SAY message to ${MAX_SAY_CHARS} characters, and menu prompts are never split. This prompt is ${text.length} characters. Shorten it.`);
|
|
60247
|
+
}
|
|
60248
|
+
}
|
|
60249
|
+
function assertMessageCount(count) {
|
|
60250
|
+
if (count > MAX_MESSAGES) {
|
|
60251
|
+
throw new Error(`Voice v2 limits a messages list to ${MAX_MESSAGES} items, and each SAY message to ${MAX_SAY_CHARS} characters. These say()/play() calls need ${count} items once long text is split. Shorten the text.`);
|
|
60252
|
+
}
|
|
60253
|
+
}
|
|
60254
|
+
function assertPromptMessageCount(count) {
|
|
60255
|
+
if (count > MAX_MESSAGES) {
|
|
60256
|
+
throw new Error(`Voice v2 limits a menu prompt to ${MAX_MESSAGES} messages. This prompt's say()/play() calls need ${count}. Remove some.`);
|
|
60257
|
+
}
|
|
60258
|
+
}
|
|
60259
|
+
function packSentences(text) {
|
|
60260
|
+
const sentences = sentenceSpans(text);
|
|
60261
|
+
for (const { start, end } of sentences) {
|
|
60262
|
+
if (end - start > MAX_SAY_CHARS) {
|
|
60263
|
+
throw new Error(`Voice v2 limits each SAY message to ${MAX_SAY_CHARS} characters. Longer text is split between sentences, but this sentence alone is ${end - start} characters: "${text.slice(start, start + EXCERPT_CHARS)}\u2026". Shorten it.`);
|
|
60264
|
+
}
|
|
60265
|
+
}
|
|
60266
|
+
const parts = [];
|
|
60267
|
+
let first = 0;
|
|
60268
|
+
while (first < sentences.length) {
|
|
60269
|
+
const start = sentences[first].start;
|
|
60270
|
+
let last = first;
|
|
60271
|
+
while (last + 1 < sentences.length && sentences[last + 1].end - start <= MAX_SAY_CHARS) {
|
|
60272
|
+
last++;
|
|
60273
|
+
}
|
|
60274
|
+
parts.push(text.slice(start, sentences[last].end));
|
|
60275
|
+
first = last + 1;
|
|
60276
|
+
}
|
|
60277
|
+
return parts;
|
|
60278
|
+
}
|
|
60279
|
+
function sentenceSpans(text) {
|
|
60280
|
+
const spans = [];
|
|
60281
|
+
let start = 0;
|
|
60282
|
+
for (const separator of text.matchAll(SENTENCE_BREAK)) {
|
|
60283
|
+
spans.push({ start, end: separator.index });
|
|
60284
|
+
start = separator.index + separator[0].length;
|
|
60285
|
+
}
|
|
60286
|
+
spans.push({ start, end: text.length });
|
|
60287
|
+
return spans;
|
|
60288
|
+
}
|
|
60289
|
+
|
|
60226
60290
|
// ../voice-v2-preview/dist/core/commands.js
|
|
60227
60291
|
function internals(builder) {
|
|
60228
60292
|
return builder;
|
|
@@ -60435,8 +60499,12 @@ var PromptBuilder = class {
|
|
|
60435
60499
|
*
|
|
60436
60500
|
* @param text - Text to synthesise, or an SSML document when `format` is `SSML`
|
|
60437
60501
|
* @param options - Voice and format overrides
|
|
60502
|
+
* @throws If `text` is over 600 characters (prompts are never split), or the prompt would hold
|
|
60503
|
+
* more than 10 messages
|
|
60438
60504
|
*/
|
|
60439
60505
|
say(text, options = {}) {
|
|
60506
|
+
assertPromptFits(text);
|
|
60507
|
+
assertPromptMessageCount(this.messages.length + 1);
|
|
60440
60508
|
this.messages.push(sayMessage(text, options));
|
|
60441
60509
|
return this;
|
|
60442
60510
|
}
|
|
@@ -60444,8 +60512,10 @@ var PromptBuilder = class {
|
|
|
60444
60512
|
* Play an audio file.
|
|
60445
60513
|
*
|
|
60446
60514
|
* @param url - Publicly reachable URL of the audio file
|
|
60515
|
+
* @throws If the prompt would hold more than 10 messages
|
|
60447
60516
|
*/
|
|
60448
60517
|
play(url2) {
|
|
60518
|
+
assertPromptMessageCount(this.messages.length + 1);
|
|
60449
60519
|
this.messages.push({ type: "PLAY", play: { url: url2 } });
|
|
60450
60520
|
return this;
|
|
60451
60521
|
}
|
|
@@ -60501,6 +60571,7 @@ var MenuItemBuilder = class {
|
|
|
60501
60571
|
* Prompt played when the menu is entered.
|
|
60502
60572
|
*
|
|
60503
60573
|
* @param prompt - Plain text, a {@link PromptBuilder}, or a callback receiving one
|
|
60574
|
+
* @throws If any prompt text is over 600 characters, or a callback queues more than 10 messages
|
|
60504
60575
|
*/
|
|
60505
60576
|
prompt(prompt) {
|
|
60506
60577
|
this.item.prompt = resolvePrompt(prompt);
|
|
@@ -60510,6 +60581,7 @@ var MenuItemBuilder = class {
|
|
|
60510
60581
|
* Prompt played on each retry. Falls back to `prompt` when unset.
|
|
60511
60582
|
*
|
|
60512
60583
|
* @param prompt - Plain text, a {@link PromptBuilder}, or a callback receiving one
|
|
60584
|
+
* @throws If any prompt text is over 600 characters, or a callback queues more than 10 messages
|
|
60513
60585
|
*/
|
|
60514
60586
|
repeatPrompt(prompt) {
|
|
60515
60587
|
this.item.repeatPrompt = resolvePrompt(prompt);
|
|
@@ -60657,21 +60729,28 @@ var CommandBuilder = class {
|
|
|
60657
60729
|
/** Set only on the builder `onCall` injects — see {@link FlowScope} */
|
|
60658
60730
|
scope;
|
|
60659
60731
|
/**
|
|
60660
|
-
* Speak text on the call.
|
|
60732
|
+
* Speak text on the call. `TEXT` over 600 characters is split between sentences into
|
|
60733
|
+
* consecutive messages.
|
|
60661
60734
|
*
|
|
60662
60735
|
* @param text - Text to synthesise, or an SSML document when `format` is `SSML`
|
|
60663
60736
|
* @param options - Voice and format overrides
|
|
60737
|
+
* @throws If a sentence, or any SSML document, is over 600 characters, or the pending
|
|
60738
|
+
* messages would pass 10 items
|
|
60664
60739
|
*/
|
|
60665
60740
|
say(text, options = {}) {
|
|
60666
|
-
|
|
60741
|
+
const messages = sayParts(text, options.format).map((part) => sayMessage(part, options));
|
|
60742
|
+
assertMessageCount(this.pending.length + messages.length);
|
|
60743
|
+
this.pending.push(...messages);
|
|
60667
60744
|
return this;
|
|
60668
60745
|
}
|
|
60669
60746
|
/**
|
|
60670
60747
|
* Play an audio file on the call.
|
|
60671
60748
|
*
|
|
60672
60749
|
* @param url - Publicly reachable URL of the audio file
|
|
60750
|
+
* @throws If the pending messages would pass 10 items
|
|
60673
60751
|
*/
|
|
60674
60752
|
play(url2) {
|
|
60753
|
+
assertMessageCount(this.pending.length + 1);
|
|
60675
60754
|
this.pending.push({ type: "PLAY", play: { url: url2 } });
|
|
60676
60755
|
return this;
|
|
60677
60756
|
}
|
|
@@ -60794,7 +60873,12 @@ var CommandBuilder = class {
|
|
|
60794
60873
|
return this.push(bridgeStep(agentEndpoint(target), options2, STREAM_AGENT_LEG));
|
|
60795
60874
|
}
|
|
60796
60875
|
const { headers, transport, host, port, ...options } = sipOptions;
|
|
60797
|
-
const address = sipAgentAddress(target, numberOrOptions, {
|
|
60876
|
+
const address = sipAgentAddress(target, numberOrOptions, {
|
|
60877
|
+
headers,
|
|
60878
|
+
transport,
|
|
60879
|
+
host,
|
|
60880
|
+
port
|
|
60881
|
+
});
|
|
60798
60882
|
return this.push(bridgeStep((scope) => address(scope?.event), options, SIP_AGENT_LEG));
|
|
60799
60883
|
}
|
|
60800
60884
|
/**
|
|
@@ -61563,7 +61647,12 @@ var Client = class {
|
|
|
61563
61647
|
return this.transferTo(target, endpoint, numberOrOptions ?? {});
|
|
61564
61648
|
}
|
|
61565
61649
|
const { headers, transport, host, port, ...options } = sipOptions;
|
|
61566
|
-
const address = sipAgentAddress(agent, numberOrOptions, {
|
|
61650
|
+
const address = sipAgentAddress(agent, numberOrOptions, {
|
|
61651
|
+
headers,
|
|
61652
|
+
transport,
|
|
61653
|
+
host,
|
|
61654
|
+
port
|
|
61655
|
+
});
|
|
61567
61656
|
return this.transferTo(target, address, options, DEFAULT_AGENT_MAX_DURATION);
|
|
61568
61657
|
}
|
|
61569
61658
|
async transferTo(target, to, options, maxDuration) {
|
|
@@ -61755,8 +61844,261 @@ function connectAgent(provider, number, options = {}) {
|
|
|
61755
61844
|
};
|
|
61756
61845
|
}
|
|
61757
61846
|
|
|
61847
|
+
// ../runtime-shared/dist/security/context-secrets.js
|
|
61848
|
+
import { inspect } from "util";
|
|
61849
|
+
var HIDDEN_ENV_KEYS = [
|
|
61850
|
+
"PROJECT_ID_API_KEY",
|
|
61851
|
+
"PROJECT_ID_API_SECRET",
|
|
61852
|
+
"VOICE_APPLICATION_KEY",
|
|
61853
|
+
"VOICE_APPLICATION_SECRET",
|
|
61854
|
+
"VOICE_SERVICE_SECRET",
|
|
61855
|
+
"CONVERSATION_WEBHOOK_SECRET",
|
|
61856
|
+
"ADMIN_USER",
|
|
61857
|
+
"ADMIN_PASSWORD"
|
|
61858
|
+
];
|
|
61859
|
+
var HIDDEN_ENV_PATTERN = /SECRET|TOKEN|PASS|PRIVATE|CREDENTIAL|AUTH|APIKEY|ACCESS_KEY|DSN|CONNECTION_STRING|_URL|_URI|_KEY$|_KEY_ID$|^(?!(?:OLD)?PWD$).*PWD/i;
|
|
61860
|
+
var VISIBLE_ENV_KEYS = /* @__PURE__ */ new Set([
|
|
61861
|
+
"API_URL",
|
|
61862
|
+
"SINCH_API_URL",
|
|
61863
|
+
"FUNCTION_URL",
|
|
61864
|
+
"STREAM_URL",
|
|
61865
|
+
"TUNNEL_GATEWAY_URL"
|
|
61866
|
+
]);
|
|
61867
|
+
var hiddenKeys = new Set(HIDDEN_ENV_KEYS);
|
|
61868
|
+
var functionEnvs = /* @__PURE__ */ new WeakSet();
|
|
61869
|
+
var OPAQUE = /* @__PURE__ */ Symbol("sinch.opaque");
|
|
61870
|
+
function isHiddenEnvKey(key) {
|
|
61871
|
+
return hiddenKeys.has(key) || !VISIBLE_ENV_KEYS.has(key) && HIDDEN_ENV_PATTERN.test(key);
|
|
61872
|
+
}
|
|
61873
|
+
function createFunctionEnv(source) {
|
|
61874
|
+
const env = {};
|
|
61875
|
+
for (const key of Object.keys(source)) {
|
|
61876
|
+
Object.defineProperty(env, key, {
|
|
61877
|
+
value: source[key],
|
|
61878
|
+
enumerable: !isHiddenEnvKey(key),
|
|
61879
|
+
writable: true,
|
|
61880
|
+
configurable: true
|
|
61881
|
+
});
|
|
61882
|
+
}
|
|
61883
|
+
functionEnvs.add(env);
|
|
61884
|
+
return env;
|
|
61885
|
+
}
|
|
61886
|
+
function makeOpaque(target, label) {
|
|
61887
|
+
if (target === null || typeof target !== "object" && typeof target !== "function")
|
|
61888
|
+
return;
|
|
61889
|
+
if (Object.prototype.hasOwnProperty.call(target, OPAQUE) || !Object.isExtensible(target))
|
|
61890
|
+
return;
|
|
61891
|
+
const tag = `[${label}]`;
|
|
61892
|
+
Object.defineProperties(target, {
|
|
61893
|
+
[OPAQUE]: { value: true },
|
|
61894
|
+
toJSON: { value: () => tag, configurable: true, writable: true },
|
|
61895
|
+
[inspect.custom]: { value: () => tag, configurable: true, writable: true }
|
|
61896
|
+
});
|
|
61897
|
+
}
|
|
61898
|
+
var HOLDER_SEARCH_DEPTH = 4;
|
|
61899
|
+
var API_CLIENT_SEARCH_DEPTH = 8;
|
|
61900
|
+
var SDK_CREDENTIAL_FIELDS = /* @__PURE__ */ new Set([
|
|
61901
|
+
"keyId",
|
|
61902
|
+
"keySecret",
|
|
61903
|
+
"applicationKey",
|
|
61904
|
+
"applicationSecret",
|
|
61905
|
+
"applicationId",
|
|
61906
|
+
"apiToken",
|
|
61907
|
+
"mailgunApiKey",
|
|
61908
|
+
"userName",
|
|
61909
|
+
"password",
|
|
61910
|
+
"token"
|
|
61911
|
+
]);
|
|
61912
|
+
var searchedClients = /* @__PURE__ */ new WeakSet();
|
|
61913
|
+
var guardedLazyClients = /* @__PURE__ */ new WeakSet();
|
|
61914
|
+
var wrappedSetCredentials = /* @__PURE__ */ new WeakSet();
|
|
61915
|
+
function isObject(value) {
|
|
61916
|
+
return typeof value === "object" && value !== null;
|
|
61917
|
+
}
|
|
61918
|
+
function canDefine(obj, key) {
|
|
61919
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, key);
|
|
61920
|
+
return descriptor ? descriptor.configurable === true : Object.isExtensible(obj);
|
|
61921
|
+
}
|
|
61922
|
+
function dataValues(obj) {
|
|
61923
|
+
return Object.values(Object.getOwnPropertyDescriptors(obj)).filter((descriptor) => "value" in descriptor).map((descriptor) => descriptor.value);
|
|
61924
|
+
}
|
|
61925
|
+
function isCredentialField(key, value, secrets) {
|
|
61926
|
+
return SDK_CREDENTIAL_FIELDS.has(key) || typeof value === "string" && secrets.has(value);
|
|
61927
|
+
}
|
|
61928
|
+
function hideCredentialFields(obj, secrets) {
|
|
61929
|
+
let found = false;
|
|
61930
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(obj))) {
|
|
61931
|
+
if (!("value" in descriptor) || !isCredentialField(key, descriptor.value, secrets))
|
|
61932
|
+
continue;
|
|
61933
|
+
found = true;
|
|
61934
|
+
if (descriptor.enumerable && descriptor.configurable) {
|
|
61935
|
+
Object.defineProperty(obj, key, { enumerable: false });
|
|
61936
|
+
}
|
|
61937
|
+
}
|
|
61938
|
+
if (found)
|
|
61939
|
+
makeOpaque(obj, "Sinch credentials");
|
|
61940
|
+
return found;
|
|
61941
|
+
}
|
|
61942
|
+
function revealCredentialFields(obj, secrets) {
|
|
61943
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(obj))) {
|
|
61944
|
+
if (!("value" in descriptor) || descriptor.enumerable || !descriptor.configurable)
|
|
61945
|
+
continue;
|
|
61946
|
+
if (isCredentialField(key, descriptor.value, secrets)) {
|
|
61947
|
+
Object.defineProperty(obj, key, { enumerable: true });
|
|
61948
|
+
}
|
|
61949
|
+
}
|
|
61950
|
+
}
|
|
61951
|
+
function isLazyClient(obj) {
|
|
61952
|
+
const config = Object.getOwnPropertyDescriptor(obj, "sharedConfig");
|
|
61953
|
+
return typeof obj.getApiClient === "function" && (isObject(config?.value) || typeof config?.get === "function");
|
|
61954
|
+
}
|
|
61955
|
+
function isOAuth2Plugin(obj) {
|
|
61956
|
+
const plugin = obj;
|
|
61957
|
+
return typeof plugin.getOAuth2Token === "function" && typeof plugin.invalidateToken === "function";
|
|
61958
|
+
}
|
|
61959
|
+
function hideCredentialsBelow(obj, secrets, depth, maxDepth, seen) {
|
|
61960
|
+
if (depth > maxDepth || seen.has(obj))
|
|
61961
|
+
return;
|
|
61962
|
+
seen.add(obj);
|
|
61963
|
+
if (isOAuth2Plugin(obj) && !Object.prototype.hasOwnProperty.call(obj, "token") && canDefine(obj, "token")) {
|
|
61964
|
+
Object.defineProperty(obj, "token", {
|
|
61965
|
+
value: void 0,
|
|
61966
|
+
enumerable: false,
|
|
61967
|
+
writable: true,
|
|
61968
|
+
configurable: true
|
|
61969
|
+
});
|
|
61970
|
+
}
|
|
61971
|
+
hideCredentialFields(obj, secrets);
|
|
61972
|
+
for (const value of dataValues(obj)) {
|
|
61973
|
+
if (isObject(value))
|
|
61974
|
+
hideCredentialsBelow(value, secrets, depth + 1, maxDepth, seen);
|
|
61975
|
+
}
|
|
61976
|
+
}
|
|
61977
|
+
function protectApiClient(client, secrets) {
|
|
61978
|
+
if (!isObject(client))
|
|
61979
|
+
return;
|
|
61980
|
+
makeOpaque(client, "Sinch API client");
|
|
61981
|
+
hideCredentialsBelow(client, secrets, 0, API_CLIENT_SEARCH_DEPTH, /* @__PURE__ */ new Set());
|
|
61982
|
+
}
|
|
61983
|
+
function guardLazyClient(lazy, secrets) {
|
|
61984
|
+
if (guardedLazyClients.has(lazy))
|
|
61985
|
+
return;
|
|
61986
|
+
guardedLazyClients.add(lazy);
|
|
61987
|
+
let config = lazy.sharedConfig;
|
|
61988
|
+
let apiClient = lazy.apiFetchClient;
|
|
61989
|
+
if (isObject(config))
|
|
61990
|
+
hideCredentialFields(config, secrets);
|
|
61991
|
+
protectApiClient(apiClient, secrets);
|
|
61992
|
+
if (!canDefine(lazy, "sharedConfig") || !canDefine(lazy, "apiFetchClient"))
|
|
61993
|
+
return;
|
|
61994
|
+
Object.defineProperties(lazy, {
|
|
61995
|
+
sharedConfig: {
|
|
61996
|
+
get: () => config,
|
|
61997
|
+
set: (next) => {
|
|
61998
|
+
if (!isObject(next)) {
|
|
61999
|
+
config = next;
|
|
62000
|
+
return;
|
|
62001
|
+
}
|
|
62002
|
+
config = Object.create(Object.getPrototypeOf(next), Object.getOwnPropertyDescriptors(next));
|
|
62003
|
+
hideCredentialFields(config, secrets);
|
|
62004
|
+
},
|
|
62005
|
+
enumerable: true,
|
|
62006
|
+
configurable: true
|
|
62007
|
+
},
|
|
62008
|
+
apiFetchClient: {
|
|
62009
|
+
get: () => apiClient,
|
|
62010
|
+
set: (next) => {
|
|
62011
|
+
apiClient = next;
|
|
62012
|
+
protectApiClient(next, secrets);
|
|
62013
|
+
},
|
|
62014
|
+
enumerable: false,
|
|
62015
|
+
configurable: true
|
|
62016
|
+
}
|
|
62017
|
+
});
|
|
62018
|
+
}
|
|
62019
|
+
function keepCredentialsForSetCredentials(owner, lazies, secrets) {
|
|
62020
|
+
const original = owner.setCredentials;
|
|
62021
|
+
if (typeof original !== "function" || wrappedSetCredentials.has(owner))
|
|
62022
|
+
return;
|
|
62023
|
+
if (!canDefine(owner, "setCredentials"))
|
|
62024
|
+
return;
|
|
62025
|
+
wrappedSetCredentials.add(owner);
|
|
62026
|
+
Object.defineProperty(owner, "setCredentials", {
|
|
62027
|
+
value: function setCredentials(...args) {
|
|
62028
|
+
const configs = lazies.map((lazy) => lazy.sharedConfig).filter(isObject);
|
|
62029
|
+
for (const config of configs)
|
|
62030
|
+
revealCredentialFields(config, secrets);
|
|
62031
|
+
try {
|
|
62032
|
+
return original.apply(this, args);
|
|
62033
|
+
} finally {
|
|
62034
|
+
for (const config of configs)
|
|
62035
|
+
hideCredentialFields(config, secrets);
|
|
62036
|
+
}
|
|
62037
|
+
},
|
|
62038
|
+
enumerable: false,
|
|
62039
|
+
writable: true,
|
|
62040
|
+
configurable: true
|
|
62041
|
+
});
|
|
62042
|
+
}
|
|
62043
|
+
function guardSdkObjects(obj, secrets, lazies, depth, seen) {
|
|
62044
|
+
if (depth > HOLDER_SEARCH_DEPTH || seen.has(obj))
|
|
62045
|
+
return;
|
|
62046
|
+
seen.add(obj);
|
|
62047
|
+
if (isLazyClient(obj)) {
|
|
62048
|
+
lazies.push(obj);
|
|
62049
|
+
guardLazyClient(obj, secrets);
|
|
62050
|
+
return;
|
|
62051
|
+
}
|
|
62052
|
+
keepCredentialsForSetCredentials(obj, lazies, secrets);
|
|
62053
|
+
hideCredentialFields(obj, secrets);
|
|
62054
|
+
for (const value of dataValues(obj)) {
|
|
62055
|
+
if (isObject(value))
|
|
62056
|
+
guardSdkObjects(value, secrets, lazies, depth + 1, seen);
|
|
62057
|
+
}
|
|
62058
|
+
}
|
|
62059
|
+
function protectSdkClient(client, label, secrets) {
|
|
62060
|
+
if (!isObject(client) || searchedClients.has(client))
|
|
62061
|
+
return;
|
|
62062
|
+
searchedClients.add(client);
|
|
62063
|
+
makeOpaque(client, label);
|
|
62064
|
+
for (const member of dataValues(client)) {
|
|
62065
|
+
if (isObject(member))
|
|
62066
|
+
makeOpaque(member, label);
|
|
62067
|
+
}
|
|
62068
|
+
guardSdkObjects(client, secrets(), [], 0, /* @__PURE__ */ new Set());
|
|
62069
|
+
}
|
|
62070
|
+
function hiddenValues(env) {
|
|
62071
|
+
const values = /* @__PURE__ */ new Set();
|
|
62072
|
+
for (const key of env ? Object.getOwnPropertyNames(env) : []) {
|
|
62073
|
+
const value = env?.[key];
|
|
62074
|
+
if (value && isHiddenEnvKey(key))
|
|
62075
|
+
values.add(value);
|
|
62076
|
+
}
|
|
62077
|
+
return values;
|
|
62078
|
+
}
|
|
62079
|
+
function protectContext(context, v1) {
|
|
62080
|
+
const ctx = context;
|
|
62081
|
+
const original = ctx.env;
|
|
62082
|
+
if (original && !functionEnvs.has(original)) {
|
|
62083
|
+
const env = createFunctionEnv(original);
|
|
62084
|
+
ctx.env = env;
|
|
62085
|
+
if (ctx.config && ctx.config.variables === original) {
|
|
62086
|
+
ctx.config.variables = env;
|
|
62087
|
+
}
|
|
62088
|
+
}
|
|
62089
|
+
let secrets;
|
|
62090
|
+
const credentialValues = () => secrets ??= hiddenValues(ctx.env);
|
|
62091
|
+
protectSdkClient(ctx.conversation, "Sinch Conversation client", credentialValues);
|
|
62092
|
+
protectSdkClient(ctx.sms, "Sinch SMS client", credentialValues);
|
|
62093
|
+
protectSdkClient(ctx.numbers, "Sinch Numbers client", credentialValues);
|
|
62094
|
+
protectSdkClient(v1, "Sinch Voice v1 client", credentialValues);
|
|
62095
|
+
makeOpaque(ctx.cache, "Function cache");
|
|
62096
|
+
makeOpaque(ctx.storage, "Function storage");
|
|
62097
|
+
}
|
|
62098
|
+
|
|
61758
62099
|
// ../runtime-shared/dist/voice/client.js
|
|
61759
62100
|
function attachVoiceClient(context, v1) {
|
|
62101
|
+
protectContext(context, v1);
|
|
61760
62102
|
attachConfigAccessors(context);
|
|
61761
62103
|
let client;
|
|
61762
62104
|
Object.defineProperty(context, "voice", {
|
|
@@ -62278,6 +62620,238 @@ function createSecurityOptions(config) {
|
|
|
62278
62620
|
};
|
|
62279
62621
|
}
|
|
62280
62622
|
|
|
62623
|
+
// ../runtime-shared/dist/security/redact.js
|
|
62624
|
+
import { inspect as inspect2 } from "util";
|
|
62625
|
+
var REDACTED2 = "[REDACTED]";
|
|
62626
|
+
var MIN_SECRET_LENGTH = 8;
|
|
62627
|
+
var BASIC_AUTH_PAIRS = [
|
|
62628
|
+
["PROJECT_ID_API_KEY", "PROJECT_ID_API_SECRET"],
|
|
62629
|
+
["VOICE_APPLICATION_KEY", "VOICE_APPLICATION_SECRET"],
|
|
62630
|
+
["ADMIN_USER", "ADMIN_PASSWORD"]
|
|
62631
|
+
];
|
|
62632
|
+
var MAX_PATTERN_SOURCE = 16 * 1024;
|
|
62633
|
+
var MAX_PATTERN_NEEDLE = 1024;
|
|
62634
|
+
var matcher = null;
|
|
62635
|
+
function escapeRegExp(text) {
|
|
62636
|
+
return text.replace(/[\\^$.*+?()[\]{}|/-]/g, "\\$&");
|
|
62637
|
+
}
|
|
62638
|
+
function percentEncodedForms(value) {
|
|
62639
|
+
const component = encodeURIComponent(value);
|
|
62640
|
+
const strict = component.replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
62641
|
+
const form = new URLSearchParams([["", value]]).toString().slice(1);
|
|
62642
|
+
return [component, strict, form].flatMap((encoded) => [
|
|
62643
|
+
encoded,
|
|
62644
|
+
encoded.replace(/%[0-9A-F]{2}/g, (hex) => hex.toLowerCase())
|
|
62645
|
+
]);
|
|
62646
|
+
}
|
|
62647
|
+
function buildSecretNeedles(env) {
|
|
62648
|
+
const needles = /* @__PURE__ */ new Set();
|
|
62649
|
+
const add = (text) => {
|
|
62650
|
+
if (text.length >= MIN_SECRET_LENGTH)
|
|
62651
|
+
needles.add(text);
|
|
62652
|
+
};
|
|
62653
|
+
const addQuotedForms = (text) => {
|
|
62654
|
+
add(text);
|
|
62655
|
+
add(JSON.stringify(text).slice(1, -1));
|
|
62656
|
+
add(inspect2(text).slice(1, -1));
|
|
62657
|
+
};
|
|
62658
|
+
for (const key of Object.getOwnPropertyNames(env)) {
|
|
62659
|
+
const value = env[key];
|
|
62660
|
+
if (typeof value !== "string" || value.length < MIN_SECRET_LENGTH || !isHiddenEnvKey(key)) {
|
|
62661
|
+
continue;
|
|
62662
|
+
}
|
|
62663
|
+
addQuotedForms(value);
|
|
62664
|
+
for (const form of percentEncodedForms(value))
|
|
62665
|
+
add(form);
|
|
62666
|
+
for (const line of value.split(/\r?\n|(?:\\r)?\\n/))
|
|
62667
|
+
addQuotedForms(line.trim());
|
|
62668
|
+
}
|
|
62669
|
+
for (const [userKey, secretKey] of BASIC_AUTH_PAIRS) {
|
|
62670
|
+
const user = env[userKey];
|
|
62671
|
+
const secret = env[secretKey];
|
|
62672
|
+
if (user && secret)
|
|
62673
|
+
add(Buffer.from(`${user}:${secret}`).toString("base64"));
|
|
62674
|
+
}
|
|
62675
|
+
const sessions = collectCredentials2({
|
|
62676
|
+
authKey: env.PROJECT_ID_API_KEY,
|
|
62677
|
+
authSecret: env.PROJECT_ID_API_SECRET,
|
|
62678
|
+
adminUser: env.ADMIN_USER,
|
|
62679
|
+
adminPassword: env.ADMIN_PASSWORD
|
|
62680
|
+
});
|
|
62681
|
+
for (const { user, password } of sessions)
|
|
62682
|
+
add(sessionToken(user, password));
|
|
62683
|
+
return [...needles].sort((a, b) => b.length - a.length);
|
|
62684
|
+
}
|
|
62685
|
+
function configureSecretRedaction(env) {
|
|
62686
|
+
const needles = buildSecretNeedles(env);
|
|
62687
|
+
if (needles.length === 0) {
|
|
62688
|
+
matcher = null;
|
|
62689
|
+
return;
|
|
62690
|
+
}
|
|
62691
|
+
const patterns = [];
|
|
62692
|
+
const literals = [];
|
|
62693
|
+
let group = [];
|
|
62694
|
+
let groupSource = 0;
|
|
62695
|
+
const closeGroup = () => {
|
|
62696
|
+
if (group.length === 0)
|
|
62697
|
+
return;
|
|
62698
|
+
const alternation = group.join("|");
|
|
62699
|
+
patterns.push({
|
|
62700
|
+
any: new RegExp(alternation),
|
|
62701
|
+
starts: new RegExp(`(?=(${alternation}))`, "g")
|
|
62702
|
+
});
|
|
62703
|
+
group = [];
|
|
62704
|
+
groupSource = 0;
|
|
62705
|
+
};
|
|
62706
|
+
for (const needle of needles) {
|
|
62707
|
+
const source = escapeRegExp(needle);
|
|
62708
|
+
if (needle.length > MAX_PATTERN_NEEDLE) {
|
|
62709
|
+
literals.push(needle);
|
|
62710
|
+
continue;
|
|
62711
|
+
}
|
|
62712
|
+
if (groupSource + source.length + 1 > MAX_PATTERN_SOURCE)
|
|
62713
|
+
closeGroup();
|
|
62714
|
+
group.push(source);
|
|
62715
|
+
groupSource += source.length + 1;
|
|
62716
|
+
}
|
|
62717
|
+
closeGroup();
|
|
62718
|
+
matcher = {
|
|
62719
|
+
patterns,
|
|
62720
|
+
literals,
|
|
62721
|
+
shortest: needles[needles.length - 1].length,
|
|
62722
|
+
longest: needles[0].length,
|
|
62723
|
+
longestBytes: Math.max(...needles.map((needle) => Buffer.byteLength(needle)))
|
|
62724
|
+
};
|
|
62725
|
+
}
|
|
62726
|
+
function findSpans(m, text) {
|
|
62727
|
+
const found = [];
|
|
62728
|
+
for (const pattern of m.patterns) {
|
|
62729
|
+
if (!pattern.any.test(text))
|
|
62730
|
+
continue;
|
|
62731
|
+
for (const match of text.matchAll(pattern.starts)) {
|
|
62732
|
+
found.push([match.index, match.index + match[1].length]);
|
|
62733
|
+
}
|
|
62734
|
+
}
|
|
62735
|
+
for (const needle of m.literals) {
|
|
62736
|
+
for (let at = text.indexOf(needle); at !== -1; at = text.indexOf(needle, at + 1)) {
|
|
62737
|
+
found.push([at, at + needle.length]);
|
|
62738
|
+
}
|
|
62739
|
+
}
|
|
62740
|
+
if (found.length === 0)
|
|
62741
|
+
return found;
|
|
62742
|
+
found.sort((a, b) => a[0] - b[0]);
|
|
62743
|
+
const merged = [found[0]];
|
|
62744
|
+
for (const [start, end] of found) {
|
|
62745
|
+
const last = merged[merged.length - 1];
|
|
62746
|
+
if (start <= last[1])
|
|
62747
|
+
last[1] = Math.max(last[1], end);
|
|
62748
|
+
else
|
|
62749
|
+
merged.push([start, end]);
|
|
62750
|
+
}
|
|
62751
|
+
return merged;
|
|
62752
|
+
}
|
|
62753
|
+
function redactSecrets(text) {
|
|
62754
|
+
const m = matcher;
|
|
62755
|
+
if (!m || text.length < m.shortest)
|
|
62756
|
+
return text;
|
|
62757
|
+
let spans;
|
|
62758
|
+
try {
|
|
62759
|
+
spans = findSpans(m, text);
|
|
62760
|
+
} catch {
|
|
62761
|
+
return REDACTED2;
|
|
62762
|
+
}
|
|
62763
|
+
if (spans.length === 0)
|
|
62764
|
+
return text;
|
|
62765
|
+
let out = "";
|
|
62766
|
+
let copied = 0;
|
|
62767
|
+
for (const [start, end] of spans) {
|
|
62768
|
+
out += text.slice(copied, start) + REDACTED2;
|
|
62769
|
+
copied = end;
|
|
62770
|
+
}
|
|
62771
|
+
return out + text.slice(copied);
|
|
62772
|
+
}
|
|
62773
|
+
function redactAsText(value) {
|
|
62774
|
+
if (value === void 0 || value === null)
|
|
62775
|
+
return value;
|
|
62776
|
+
if (typeof value === "string")
|
|
62777
|
+
return redactSecrets(value);
|
|
62778
|
+
let text;
|
|
62779
|
+
try {
|
|
62780
|
+
text = JSON.stringify(value);
|
|
62781
|
+
} catch {
|
|
62782
|
+
}
|
|
62783
|
+
try {
|
|
62784
|
+
text ??= String(value);
|
|
62785
|
+
} catch {
|
|
62786
|
+
return REDACTED2;
|
|
62787
|
+
}
|
|
62788
|
+
return redactSecrets(text);
|
|
62789
|
+
}
|
|
62790
|
+
function secretLookaheadBytes() {
|
|
62791
|
+
return matcher ? matcher.longestBytes : 0;
|
|
62792
|
+
}
|
|
62793
|
+
function safeCut(prefix, continuation) {
|
|
62794
|
+
const m = matcher;
|
|
62795
|
+
if (!m || continuation.length === 0)
|
|
62796
|
+
return prefix;
|
|
62797
|
+
try {
|
|
62798
|
+
const cut = prefix.length;
|
|
62799
|
+
const after = continuation.slice(0, m.longest - 1);
|
|
62800
|
+
for (let reach = m.longest; ; reach *= 2) {
|
|
62801
|
+
const from = Math.max(0, cut - reach);
|
|
62802
|
+
const crossing = findSpans(m, prefix.slice(from) + after).find(([start, end]) => start < cut - from && end > cut - from);
|
|
62803
|
+
if (!crossing)
|
|
62804
|
+
return prefix;
|
|
62805
|
+
if (from === 0 || crossing[0] >= m.longest)
|
|
62806
|
+
return prefix.slice(0, from + crossing[0]);
|
|
62807
|
+
}
|
|
62808
|
+
} catch {
|
|
62809
|
+
return "";
|
|
62810
|
+
}
|
|
62811
|
+
}
|
|
62812
|
+
var wrappedStreams = /* @__PURE__ */ new WeakSet();
|
|
62813
|
+
function isTextEncoding(encoding) {
|
|
62814
|
+
return typeof encoding !== "string" || !/^(hex|base64|base64url)$/i.test(encoding);
|
|
62815
|
+
}
|
|
62816
|
+
function redactBytes(bytes) {
|
|
62817
|
+
const text = bytes.toString("utf8");
|
|
62818
|
+
const redacted = redactSecrets(text);
|
|
62819
|
+
return redacted === text ? void 0 : Buffer.from(redacted, "utf8");
|
|
62820
|
+
}
|
|
62821
|
+
function redactChunk(chunk, encoding) {
|
|
62822
|
+
if (!matcher)
|
|
62823
|
+
return chunk;
|
|
62824
|
+
if (typeof chunk === "string") {
|
|
62825
|
+
if (isTextEncoding(encoding))
|
|
62826
|
+
return redactSecrets(chunk);
|
|
62827
|
+
const notation = encoding;
|
|
62828
|
+
return redactBytes(Buffer.from(chunk, notation))?.toString(notation) ?? chunk;
|
|
62829
|
+
}
|
|
62830
|
+
if (ArrayBuffer.isView(chunk)) {
|
|
62831
|
+
return redactBytes(Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength)) ?? chunk;
|
|
62832
|
+
}
|
|
62833
|
+
return chunk;
|
|
62834
|
+
}
|
|
62835
|
+
function wrapStreamWrite(stream5) {
|
|
62836
|
+
if (wrappedStreams.has(stream5))
|
|
62837
|
+
return;
|
|
62838
|
+
wrappedStreams.add(stream5);
|
|
62839
|
+
const write = stream5.write;
|
|
62840
|
+
stream5.write = function(chunk, ...rest) {
|
|
62841
|
+
let safe;
|
|
62842
|
+
try {
|
|
62843
|
+
safe = redactChunk(chunk, rest[0]);
|
|
62844
|
+
} catch {
|
|
62845
|
+
safe = typeof chunk === "string" ? REDACTED2 : Buffer.from(REDACTED2);
|
|
62846
|
+
}
|
|
62847
|
+
return write.call(this, safe, ...rest);
|
|
62848
|
+
};
|
|
62849
|
+
}
|
|
62850
|
+
function installStdioRedaction() {
|
|
62851
|
+
wrapStreamWrite(process.stdout);
|
|
62852
|
+
wrapStreamWrite(process.stderr);
|
|
62853
|
+
}
|
|
62854
|
+
|
|
62281
62855
|
// ../runtime-shared/dist/security/voice-signature.js
|
|
62282
62856
|
import { createHash, createHmac as createHmac2, timingSafeEqual as timingSafeEqual3 } from "crypto";
|
|
62283
62857
|
var VOICE_TIMESTAMP_SKEW_MS = 5 * 60 * 1e3;
|
|
@@ -62475,6 +63049,52 @@ function safeToolOutput(value) {
|
|
|
62475
63049
|
}
|
|
62476
63050
|
}
|
|
62477
63051
|
|
|
63052
|
+
// ../runtime-shared/dist/host/exports.js
|
|
63053
|
+
import { types } from "util";
|
|
63054
|
+
var fnToString = Function.prototype.toString;
|
|
63055
|
+
var fnBind = Function.prototype.bind;
|
|
63056
|
+
var OBJECT_PROTOTYPE_NAMES = new Set(Object.getOwnPropertyNames(Object.prototype));
|
|
63057
|
+
function isAuthorClassPrototype(proto) {
|
|
63058
|
+
if (types.isProxy(proto))
|
|
63059
|
+
return false;
|
|
63060
|
+
const ctor = Object.getOwnPropertyDescriptor(proto, "constructor")?.value;
|
|
63061
|
+
if (typeof ctor !== "function" || types.isProxy(ctor))
|
|
63062
|
+
return false;
|
|
63063
|
+
if (Object.getOwnPropertyDescriptor(ctor, "prototype")?.value !== proto)
|
|
63064
|
+
return false;
|
|
63065
|
+
if (!/^class\b/.test(fnToString.call(ctor)))
|
|
63066
|
+
return false;
|
|
63067
|
+
const name = Object.getOwnPropertyDescriptor(ctor, "name")?.value;
|
|
63068
|
+
return !(typeof name === "string" && Object.getOwnPropertyDescriptor(globalThis, name)?.value === ctor);
|
|
63069
|
+
}
|
|
63070
|
+
function findExport(target, name) {
|
|
63071
|
+
if (OBJECT_PROTOTYPE_NAMES.has(name))
|
|
63072
|
+
return void 0;
|
|
63073
|
+
if (Object.hasOwn(target, name)) {
|
|
63074
|
+
const value = target[name];
|
|
63075
|
+
return typeof value === "function" ? fnBind.call(value, target) : void 0;
|
|
63076
|
+
}
|
|
63077
|
+
if (types.isProxy(target))
|
|
63078
|
+
return void 0;
|
|
63079
|
+
for (let proto = Object.getPrototypeOf(target); proto !== null && isAuthorClassPrototype(proto); proto = Object.getPrototypeOf(proto)) {
|
|
63080
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, name);
|
|
63081
|
+
if (descriptor) {
|
|
63082
|
+
return typeof descriptor.value === "function" ? fnBind.call(descriptor.value, target) : void 0;
|
|
63083
|
+
}
|
|
63084
|
+
}
|
|
63085
|
+
return void 0;
|
|
63086
|
+
}
|
|
63087
|
+
function listExports(target) {
|
|
63088
|
+
const candidates = new Set(Object.keys(target));
|
|
63089
|
+
if (!types.isProxy(target)) {
|
|
63090
|
+
for (let proto = Object.getPrototypeOf(target); proto !== null && isAuthorClassPrototype(proto); proto = Object.getPrototypeOf(proto)) {
|
|
63091
|
+
for (const name of Object.getOwnPropertyNames(proto))
|
|
63092
|
+
candidates.add(name);
|
|
63093
|
+
}
|
|
63094
|
+
}
|
|
63095
|
+
return [...candidates].filter((name) => findExport(target, name) !== void 0);
|
|
63096
|
+
}
|
|
63097
|
+
|
|
62478
63098
|
// ../runtime-shared/dist/host/app.js
|
|
62479
63099
|
import { createRequire } from "module";
|
|
62480
63100
|
import { pathToFileURL } from "url";
|
|
@@ -62720,8 +63340,10 @@ function buildBaseContext(req, config = {}) {
|
|
|
62720
63340
|
}
|
|
62721
63341
|
};
|
|
62722
63342
|
}
|
|
63343
|
+
var ExportNotFoundError = class extends Error {
|
|
63344
|
+
};
|
|
62723
63345
|
async function handleVoiceV1Callback(functionName, userFunction, context, callbackData, logger) {
|
|
62724
|
-
const handler = userFunction
|
|
63346
|
+
const handler = findExport(userFunction, functionName);
|
|
62725
63347
|
if (!handler || typeof handler !== "function") {
|
|
62726
63348
|
if (functionName === "ice") {
|
|
62727
63349
|
throw new Error(`Voice callback 'ice' not found \u2014 export an ice() function in function.ts`);
|
|
@@ -62767,7 +63389,7 @@ async function handleVoiceV1Callback(functionName, userFunction, context, callba
|
|
|
62767
63389
|
return formatSvamlResponse(result2, functionName);
|
|
62768
63390
|
}
|
|
62769
63391
|
async function handleVoiceWebhook(userFunction, context, event, request, logger) {
|
|
62770
|
-
const handler = userFunction
|
|
63392
|
+
const handler = findExport(userFunction, VOICE_WEBHOOK_HANDLER);
|
|
62771
63393
|
if (!handler || typeof handler !== "function") {
|
|
62772
63394
|
throw new Error(`No export '${VOICE_WEBHOOK_HANDLER}' found for Voice v2 event '${event?.event}'. Export one built with onCall({ incoming: ... }), or drop VOICE_SERVICE_ID to stay on the v1 ice/ace/pie/dice callbacks.`);
|
|
62773
63395
|
}
|
|
@@ -62782,20 +63404,24 @@ async function handleVoiceWebhook(userFunction, context, event, request, logger)
|
|
|
62782
63404
|
return formatCustomResponse(result2);
|
|
62783
63405
|
}
|
|
62784
63406
|
const body = await context.voice.onCall({ fallback: () => result2 })(event);
|
|
62785
|
-
return body === void 0 ? { statusCode: 204 } : {
|
|
63407
|
+
return body === void 0 ? { statusCode: 204 } : {
|
|
63408
|
+
statusCode: 200,
|
|
63409
|
+
headers: { "Content-Type": "application/json" },
|
|
63410
|
+
body: stringify(body)
|
|
63411
|
+
};
|
|
62786
63412
|
}
|
|
62787
63413
|
function isVoiceResult(result2) {
|
|
62788
63414
|
return Array.isArray(result2) || result2 instanceof CommandBuilder || typeof result2 === "object" && Array.isArray(result2.commands);
|
|
62789
63415
|
}
|
|
62790
63416
|
async function handleCustomEndpoint(functionName, userFunction, context, request, logger) {
|
|
62791
|
-
let handler = userFunction
|
|
63417
|
+
let handler = findExport(userFunction, functionName);
|
|
62792
63418
|
if ((!handler || typeof handler !== "function") && functionName === "default") {
|
|
62793
|
-
handler = userFunction
|
|
63419
|
+
handler = findExport(userFunction, "home");
|
|
62794
63420
|
}
|
|
62795
63421
|
if (!handler || typeof handler !== "function") {
|
|
62796
|
-
const available =
|
|
63422
|
+
const available = listExports(userFunction);
|
|
62797
63423
|
const pathHint = functionName.endsWith("Webhook") ? `/webhook/${functionName.replace("Webhook", "")}` : `/${functionName}`;
|
|
62798
|
-
throw new
|
|
63424
|
+
throw new ExportNotFoundError(`No export '${functionName}' found for path ${pathHint}. Available exports: [${available.join(", ")}]. Custom endpoints require a named export matching the last path segment.`);
|
|
62799
63425
|
}
|
|
62800
63426
|
const result2 = await handler(context, request);
|
|
62801
63427
|
if (logger) {
|
|
@@ -62881,7 +63507,12 @@ function setupRequestHandler(app, options = {}) {
|
|
|
62881
63507
|
}, buildContext = (req) => attachVoiceClient(buildBaseContext(req)), logger = console.log, landingPageEnabled = true, authConfig, authKey, authSecret, adminUser, adminPassword, onRequestStart = () => {
|
|
62882
63508
|
}, onRequestEnd = () => {
|
|
62883
63509
|
} } = options;
|
|
62884
|
-
const credentials = collectCredentials2({
|
|
63510
|
+
const credentials = collectCredentials2({
|
|
63511
|
+
authKey,
|
|
63512
|
+
authSecret,
|
|
63513
|
+
adminUser,
|
|
63514
|
+
adminPassword
|
|
63515
|
+
});
|
|
62885
63516
|
const functionDisplayName = process.env.FUNCTION_NAME || "Sinch Function";
|
|
62886
63517
|
app.use("/{*splat}", async (req, res) => {
|
|
62887
63518
|
const startTime = Date.now();
|
|
@@ -62894,7 +63525,7 @@ function setupRequestHandler(app, options = {}) {
|
|
|
62894
63525
|
const functionName = extractFunctionName(req.originalUrl, req.body);
|
|
62895
63526
|
logger(`[${(/* @__PURE__ */ new Date()).toISOString()}] ${req.method} ${req.path} -> ${functionName}`);
|
|
62896
63527
|
const userFunction = await Promise.resolve(loadUserFunction());
|
|
62897
|
-
const hasAuthorExport = (name) => typeof userFunction
|
|
63528
|
+
const hasAuthorExport = (name) => typeof findExport(userFunction, name) === "function";
|
|
62898
63529
|
if (functionName === "login" && !hasAuthorExport("login")) {
|
|
62899
63530
|
if (req.method === "GET") {
|
|
62900
63531
|
handleLoginPageRequest(req, res, { credentials, functionName: functionDisplayName });
|
|
@@ -62961,7 +63592,10 @@ function setupRequestHandler(app, options = {}) {
|
|
|
62961
63592
|
}
|
|
62962
63593
|
}
|
|
62963
63594
|
if (functionName === VOICE_WEBHOOK_HANDLER && isVoiceWebhook(req.body)) {
|
|
62964
|
-
const verdict = verifyVoiceWebhook(buildVoiceSignedRequest(req), {
|
|
63595
|
+
const verdict = verifyVoiceWebhook(buildVoiceSignedRequest(req), {
|
|
63596
|
+
mode: protectionMode,
|
|
63597
|
+
isDevelopment: isDev
|
|
63598
|
+
});
|
|
62965
63599
|
if (!verdict.valid) {
|
|
62966
63600
|
logger(`[SECURITY] Voice v2 webhook signature validation failed: ${verdict.reason}`);
|
|
62967
63601
|
res.status(401).json({ error: "Invalid webhook signature" });
|
|
@@ -63030,17 +63664,22 @@ function setupRequestHandler(app, options = {}) {
|
|
|
63030
63664
|
stack: error.stack,
|
|
63031
63665
|
function: extractFunctionName(req.originalUrl, req.body)
|
|
63032
63666
|
});
|
|
63033
|
-
|
|
63034
|
-
error: "
|
|
63035
|
-
|
|
63036
|
-
|
|
63037
|
-
|
|
63667
|
+
if (error instanceof ExportNotFoundError) {
|
|
63668
|
+
res.status(404).json({ error: "Not found", message: error.message });
|
|
63669
|
+
} else {
|
|
63670
|
+
const { message, stack } = error ?? {};
|
|
63671
|
+
res.status(500).json({
|
|
63672
|
+
error: "Internal server error",
|
|
63673
|
+
message: redactAsText(message),
|
|
63674
|
+
...process.env.NODE_ENV === "development" && { stack: redactAsText(stack) }
|
|
63675
|
+
});
|
|
63676
|
+
}
|
|
63038
63677
|
onRequestEnd({
|
|
63039
63678
|
functionName: extractFunctionName(req.originalUrl, req.body),
|
|
63040
63679
|
req,
|
|
63041
63680
|
error,
|
|
63042
63681
|
duration,
|
|
63043
|
-
statusCode: 500
|
|
63682
|
+
statusCode: error instanceof ExportNotFoundError ? 404 : 500
|
|
63044
63683
|
});
|
|
63045
63684
|
}
|
|
63046
63685
|
});
|
|
@@ -63855,9 +64494,9 @@ function closeAnyState(ws) {
|
|
|
63855
64494
|
function sanitizeVendorError(err) {
|
|
63856
64495
|
const message = err instanceof Error ? err.message : String(err);
|
|
63857
64496
|
const code = err?.code;
|
|
63858
|
-
return { message:
|
|
64497
|
+
return { message: redactSecrets2(message), ...code ? { code } : {} };
|
|
63859
64498
|
}
|
|
63860
|
-
function
|
|
64499
|
+
function redactSecrets2(message) {
|
|
63861
64500
|
return message.replace(/([?&](?:key|api_key|apikey|token)=)[^&\s"']+/gi, "$1[REDACTED]").replace(/(authorization:?\s*(?:bearer|token)\s+)\S+/gi, "$1[REDACTED]");
|
|
63862
64501
|
}
|
|
63863
64502
|
|
|
@@ -63873,7 +64512,12 @@ function providerOptionsFor(options) {
|
|
|
63873
64512
|
return options.providerOptions?.["deepgram"] ?? {};
|
|
63874
64513
|
}
|
|
63875
64514
|
function encodeTools(tools) {
|
|
63876
|
-
return tools.map((t) => ({
|
|
64515
|
+
return tools.map((t) => ({
|
|
64516
|
+
name: t.name,
|
|
64517
|
+
description: t.description,
|
|
64518
|
+
parameters: t.parameters,
|
|
64519
|
+
defer_until_eot: true
|
|
64520
|
+
}));
|
|
63877
64521
|
}
|
|
63878
64522
|
async function dispatchToolCall(fn, tools, ctx, dgWs, callbacks, session) {
|
|
63879
64523
|
const start = Date.now();
|
|
@@ -63957,7 +64601,10 @@ function buildSettingsFrame(options) {
|
|
|
63957
64601
|
}
|
|
63958
64602
|
},
|
|
63959
64603
|
think: {
|
|
63960
|
-
provider: {
|
|
64604
|
+
provider: {
|
|
64605
|
+
type: dg.llmProvider ?? DEFAULT_LLM_PROVIDER,
|
|
64606
|
+
model: dg.llmModel ?? DEFAULT_LLM_MODEL
|
|
64607
|
+
},
|
|
63961
64608
|
prompt: options.prompt,
|
|
63962
64609
|
functions: encodeTools(options.tools ?? [])
|
|
63963
64610
|
},
|
|
@@ -63979,7 +64626,9 @@ function createDeepgramAdapter(webSocketClient) {
|
|
|
63979
64626
|
throw new Error("realtimeAgent: provider 'deepgram' needs DEEPGRAM_API_KEY \u2014 set it as a function secret.");
|
|
63980
64627
|
}
|
|
63981
64628
|
const WebSocketClient = webSocketClient ?? loadWebSocketClient("deepgram");
|
|
63982
|
-
const dgWs = new WebSocketClient(DEEPGRAM_URL, {
|
|
64629
|
+
const dgWs = new WebSocketClient(DEEPGRAM_URL, {
|
|
64630
|
+
headers: { Authorization: `Token ${apiKey}` }
|
|
64631
|
+
});
|
|
63983
64632
|
const bytesPerMs = (options.audio === "wideband" ? 16e3 : 8e3) * 2 / 1e3;
|
|
63984
64633
|
const session = {
|
|
63985
64634
|
ws: dgWs,
|
|
@@ -64046,7 +64695,9 @@ function createDeepgramAdapter(webSocketClient) {
|
|
|
64046
64695
|
return;
|
|
64047
64696
|
}
|
|
64048
64697
|
if (isOversizedFrame(raw)) {
|
|
64049
|
-
callbacks.onError({
|
|
64698
|
+
callbacks.onError({
|
|
64699
|
+
message: "Received an oversized text frame from Deepgram \u2014 dropped"
|
|
64700
|
+
});
|
|
64050
64701
|
return;
|
|
64051
64702
|
}
|
|
64052
64703
|
const msg = parseVendorFrame(raw);
|
|
@@ -64074,7 +64725,11 @@ function createDeepgramAdapter(webSocketClient) {
|
|
|
64074
64725
|
for (const fn of functions) {
|
|
64075
64726
|
void dispatchToolCall(fn, tools, ctx, dgWs, callbacks, session).catch((err) => {
|
|
64076
64727
|
const sanitized = sanitizeVendorError(err);
|
|
64077
|
-
callbacks.onError({
|
|
64728
|
+
callbacks.onError({
|
|
64729
|
+
message: sanitized.message,
|
|
64730
|
+
code: sanitized.code,
|
|
64731
|
+
raw: sanitized
|
|
64732
|
+
});
|
|
64078
64733
|
});
|
|
64079
64734
|
}
|
|
64080
64735
|
break;
|
|
@@ -64362,7 +65017,10 @@ function builtInTools(hangupEnabled, transferNumber, ctx) {
|
|
|
64362
65017
|
type: "object",
|
|
64363
65018
|
properties: {
|
|
64364
65019
|
reason: { type: "string", description: "Why the call is being transferred." },
|
|
64365
|
-
summary: {
|
|
65020
|
+
summary: {
|
|
65021
|
+
type: "string",
|
|
65022
|
+
description: "A brief summary of the call so far, for the human."
|
|
65023
|
+
}
|
|
64366
65024
|
},
|
|
64367
65025
|
required: ["reason", "summary"]
|
|
64368
65026
|
},
|
|
@@ -64423,7 +65081,12 @@ function providerOptionsFor2(options) {
|
|
|
64423
65081
|
return options.providerOptions?.["openai"] ?? {};
|
|
64424
65082
|
}
|
|
64425
65083
|
function encodeResponsesTools(tools) {
|
|
64426
|
-
return tools.map((t) => ({
|
|
65084
|
+
return tools.map((t) => ({
|
|
65085
|
+
type: "function",
|
|
65086
|
+
name: t.name,
|
|
65087
|
+
description: t.description,
|
|
65088
|
+
parameters: t.parameters
|
|
65089
|
+
}));
|
|
64427
65090
|
}
|
|
64428
65091
|
function buildInstructions(options) {
|
|
64429
65092
|
if (!options.greeting)
|
|
@@ -64520,7 +65183,9 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64520
65183
|
throw new Error("realtimeAgent: provider 'openai' needs OPENAI_API_KEY \u2014 set it as a function secret.");
|
|
64521
65184
|
}
|
|
64522
65185
|
const WebSocketClient = webSocketClient ?? loadWebSocketClient("openai");
|
|
64523
|
-
const vendorWs = new WebSocketClient(GPT_LIVE_URL, {
|
|
65186
|
+
const vendorWs = new WebSocketClient(GPT_LIVE_URL, {
|
|
65187
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
65188
|
+
});
|
|
64524
65189
|
const session = {
|
|
64525
65190
|
ws: vendorWs,
|
|
64526
65191
|
ready: false,
|
|
@@ -64626,7 +65291,14 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64626
65291
|
session.lastDelegationId = void 0;
|
|
64627
65292
|
}
|
|
64628
65293
|
if (text)
|
|
64629
|
-
callbacks.onTurn({
|
|
65294
|
+
callbacks.onTurn({
|
|
65295
|
+
role: "agent",
|
|
65296
|
+
text,
|
|
65297
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
65298
|
+
playbackStartAt,
|
|
65299
|
+
playbackEndAt,
|
|
65300
|
+
delegationMs
|
|
65301
|
+
});
|
|
64630
65302
|
};
|
|
64631
65303
|
const scheduleAgentTurnFlush = () => {
|
|
64632
65304
|
if (session.agentTurnTimer !== void 0)
|
|
@@ -64645,7 +65317,13 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64645
65317
|
const text = session.pendingUserTurnText;
|
|
64646
65318
|
session.pendingUserTurnText = "";
|
|
64647
65319
|
if (text)
|
|
64648
|
-
callbacks.onTurn({
|
|
65320
|
+
callbacks.onTurn({
|
|
65321
|
+
role: "user",
|
|
65322
|
+
text,
|
|
65323
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
65324
|
+
speechStartAt,
|
|
65325
|
+
speechEndAt
|
|
65326
|
+
});
|
|
64649
65327
|
};
|
|
64650
65328
|
const scheduleUserTurnFlush = () => {
|
|
64651
65329
|
if (session.userTurnTimer !== void 0)
|
|
@@ -64692,7 +65370,9 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64692
65370
|
};
|
|
64693
65371
|
vendorWs.on("message", (raw) => {
|
|
64694
65372
|
if (isOversizedFrame(raw)) {
|
|
64695
|
-
callbacks.onError({
|
|
65373
|
+
callbacks.onError({
|
|
65374
|
+
message: "Received an oversized frame from OpenAI GPT-Live \u2014 dropped"
|
|
65375
|
+
});
|
|
64696
65376
|
return;
|
|
64697
65377
|
}
|
|
64698
65378
|
const msg = parseVendorFrame(raw);
|
|
@@ -64719,7 +65399,9 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64719
65399
|
case "session.output_audio.delta": {
|
|
64720
65400
|
const mulaw = safeBase64ToBuffer(msg["delta"]);
|
|
64721
65401
|
if (!mulaw) {
|
|
64722
|
-
callbacks.onError({
|
|
65402
|
+
callbacks.onError({
|
|
65403
|
+
message: "Received a malformed audio delta from OpenAI GPT-Live"
|
|
65404
|
+
});
|
|
64723
65405
|
break;
|
|
64724
65406
|
}
|
|
64725
65407
|
const pcm8k = mulawToPcm16(mulaw);
|
|
@@ -64852,7 +65534,11 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64852
65534
|
}
|
|
64853
65535
|
case "error": {
|
|
64854
65536
|
const err = msg["error"];
|
|
64855
|
-
callbacks.onError({
|
|
65537
|
+
callbacks.onError({
|
|
65538
|
+
message: err?.message ?? "OpenAI GPT-Live error",
|
|
65539
|
+
code: err?.code,
|
|
65540
|
+
raw: msg
|
|
65541
|
+
});
|
|
64856
65542
|
if (!settled) {
|
|
64857
65543
|
settle2(() => reject(new Error(err?.message ?? "realtimeAgent: OpenAI GPT-Live error before session.started")));
|
|
64858
65544
|
closeAnyState(vendorWs);
|
|
@@ -64914,7 +65600,12 @@ var VENDOR_RATE2 = 8e3;
|
|
|
64914
65600
|
var MULAW_BYTES_PER_MS = 8;
|
|
64915
65601
|
var HANDSHAKE_TIMEOUT_MS3 = 1e4;
|
|
64916
65602
|
function encodeTools2(tools) {
|
|
64917
|
-
return tools.map((t) => ({
|
|
65603
|
+
return tools.map((t) => ({
|
|
65604
|
+
type: "function",
|
|
65605
|
+
name: t.name,
|
|
65606
|
+
description: t.description,
|
|
65607
|
+
parameters: t.parameters
|
|
65608
|
+
}));
|
|
64918
65609
|
}
|
|
64919
65610
|
async function dispatchToolCall3(callId, name, rawArgs, tools, ctx, vendorWs, callbacks) {
|
|
64920
65611
|
const start = Date.now();
|
|
@@ -65073,7 +65764,9 @@ function createOpenAiCompatibleAdapter(config, webSocketClient) {
|
|
|
65073
65764
|
};
|
|
65074
65765
|
vendorWs.on("message", (raw) => {
|
|
65075
65766
|
if (isOversizedFrame(raw)) {
|
|
65076
|
-
callbacks.onError({
|
|
65767
|
+
callbacks.onError({
|
|
65768
|
+
message: `Received an oversized frame from ${config.provider} \u2014 dropped`
|
|
65769
|
+
});
|
|
65077
65770
|
return;
|
|
65078
65771
|
}
|
|
65079
65772
|
const msg = parseVendorFrame(raw);
|
|
@@ -65106,7 +65799,9 @@ function createOpenAiCompatibleAdapter(config, webSocketClient) {
|
|
|
65106
65799
|
}
|
|
65107
65800
|
const mulaw = safeBase64ToBuffer(msg["delta"]);
|
|
65108
65801
|
if (!mulaw) {
|
|
65109
|
-
callbacks.onError({
|
|
65802
|
+
callbacks.onError({
|
|
65803
|
+
message: `Received a malformed audio delta from ${config.provider}`
|
|
65804
|
+
});
|
|
65110
65805
|
break;
|
|
65111
65806
|
}
|
|
65112
65807
|
session.bytesSentForItem += mulaw.length;
|
|
@@ -65142,7 +65837,10 @@ function createOpenAiCompatibleAdapter(config, webSocketClient) {
|
|
|
65142
65837
|
if (usage) {
|
|
65143
65838
|
session.totalInputTokens += usage.input_tokens ?? 0;
|
|
65144
65839
|
session.totalOutputTokens += usage.output_tokens ?? 0;
|
|
65145
|
-
callbacks.onUsage?.({
|
|
65840
|
+
callbacks.onUsage?.({
|
|
65841
|
+
inputTokens: session.totalInputTokens,
|
|
65842
|
+
outputTokens: session.totalOutputTokens
|
|
65843
|
+
});
|
|
65146
65844
|
}
|
|
65147
65845
|
closeResponse();
|
|
65148
65846
|
break;
|
|
@@ -65268,7 +65966,10 @@ function buildGrokSession(options, tools) {
|
|
|
65268
65966
|
// that field.
|
|
65269
65967
|
input: {
|
|
65270
65968
|
format: { type: "audio/pcmu" },
|
|
65271
|
-
transcription: {
|
|
65969
|
+
transcription: {
|
|
65970
|
+
model: "grok-transcribe",
|
|
65971
|
+
language_hint: options.language ?? DEFAULT_LANGUAGE
|
|
65972
|
+
}
|
|
65272
65973
|
},
|
|
65273
65974
|
output: { format: { type: "audio/pcmu" } }
|
|
65274
65975
|
},
|
|
@@ -65312,7 +66013,11 @@ function flushPendingTurns(session, callbacks) {
|
|
|
65312
66013
|
}
|
|
65313
66014
|
function flushPendingAgentTurn(session, callbacks) {
|
|
65314
66015
|
if (session.pendingAgentText) {
|
|
65315
|
-
callbacks.onTurn({
|
|
66016
|
+
callbacks.onTurn({
|
|
66017
|
+
role: "agent",
|
|
66018
|
+
text: session.pendingAgentText,
|
|
66019
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
66020
|
+
});
|
|
65316
66021
|
session.pendingAgentText = "";
|
|
65317
66022
|
}
|
|
65318
66023
|
}
|
|
@@ -65332,7 +66037,10 @@ function toGeminiSchema(schema) {
|
|
|
65332
66037
|
if (schema["enum"])
|
|
65333
66038
|
out["enum"] = schema["enum"];
|
|
65334
66039
|
if (kind === "object" && schema["properties"] && typeof schema["properties"] === "object") {
|
|
65335
|
-
out["properties"] = Object.fromEntries(Object.entries(schema["properties"]).map(([k, v]) => [
|
|
66040
|
+
out["properties"] = Object.fromEntries(Object.entries(schema["properties"]).map(([k, v]) => [
|
|
66041
|
+
k,
|
|
66042
|
+
toGeminiSchema(v)
|
|
66043
|
+
]));
|
|
65336
66044
|
if (Array.isArray(schema["required"]))
|
|
65337
66045
|
out["required"] = schema["required"];
|
|
65338
66046
|
}
|
|
@@ -65367,7 +66075,9 @@ function buildSetupMessage(options, model, tools, resumptionHandle) {
|
|
|
65367
66075
|
// own default voice.
|
|
65368
66076
|
speechConfig: {
|
|
65369
66077
|
languageCode: options.language ?? DEFAULT_LANGUAGE,
|
|
65370
|
-
...options.voice && {
|
|
66078
|
+
...options.voice && {
|
|
66079
|
+
voiceConfig: { prebuiltVoiceConfig: { voiceName: options.voice } }
|
|
66080
|
+
}
|
|
65371
66081
|
}
|
|
65372
66082
|
},
|
|
65373
66083
|
systemInstruction: { parts: [{ text: options.prompt }] },
|
|
@@ -65375,7 +66085,11 @@ function buildSetupMessage(options, model, tools, resumptionHandle) {
|
|
|
65375
66085
|
inputAudioTranscription: {},
|
|
65376
66086
|
outputAudioTranscription: {},
|
|
65377
66087
|
realtimeInputConfig: {
|
|
65378
|
-
automaticActivityDetection: {
|
|
66088
|
+
automaticActivityDetection: {
|
|
66089
|
+
disabled: false,
|
|
66090
|
+
silenceDurationMs: 500,
|
|
66091
|
+
prefixPaddingMs: 20
|
|
66092
|
+
},
|
|
65379
66093
|
activityHandling: "START_OF_ACTIVITY_INTERRUPTS"
|
|
65380
66094
|
},
|
|
65381
66095
|
// A phone call routinely outlives the Live API's 15-minute audio-only session window (see
|
|
@@ -65403,7 +66117,13 @@ async function dispatchToolCall4(fc, tools, ctx, session, callbacks) {
|
|
|
65403
66117
|
error = err instanceof Error ? err.message : String(err);
|
|
65404
66118
|
}
|
|
65405
66119
|
}
|
|
65406
|
-
callbacks.onToolCall({
|
|
66120
|
+
callbacks.onToolCall({
|
|
66121
|
+
name: fc.name,
|
|
66122
|
+
args: fc.args,
|
|
66123
|
+
result: result2,
|
|
66124
|
+
error,
|
|
66125
|
+
latencyMs: Date.now() - start
|
|
66126
|
+
});
|
|
65407
66127
|
if (session.cancelledCallIds.delete(fc.id))
|
|
65408
66128
|
return;
|
|
65409
66129
|
if (session.ws.readyState !== session.ws.OPEN)
|
|
@@ -65412,14 +66132,20 @@ async function dispatchToolCall4(fc, tools, ctx, session, callbacks) {
|
|
|
65412
66132
|
session.ws.send(JSON.stringify({
|
|
65413
66133
|
toolResponse: {
|
|
65414
66134
|
// The structured result object itself, not a JSON-encoded string — see the file header.
|
|
65415
|
-
functionResponses: [
|
|
66135
|
+
functionResponses: [
|
|
66136
|
+
{ id: fc.id, name: fc.name, response: error ? { error } : result2 ?? {} }
|
|
66137
|
+
]
|
|
65416
66138
|
}
|
|
65417
66139
|
}));
|
|
65418
66140
|
} catch {
|
|
65419
66141
|
session.ws.send(JSON.stringify({
|
|
65420
66142
|
toolResponse: {
|
|
65421
66143
|
functionResponses: [
|
|
65422
|
-
{
|
|
66144
|
+
{
|
|
66145
|
+
id: fc.id,
|
|
66146
|
+
name: fc.name,
|
|
66147
|
+
response: { error: "realtimeAgent: tool result could not be serialized" }
|
|
66148
|
+
}
|
|
65423
66149
|
]
|
|
65424
66150
|
}
|
|
65425
66151
|
}));
|
|
@@ -65462,7 +66188,11 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65462
66188
|
let greeted = false;
|
|
65463
66189
|
const sendRealtimeAudio = (pcm) => {
|
|
65464
66190
|
const pcm16k = session.resamplerIn.push(pcm);
|
|
65465
|
-
session.ws.send(JSON.stringify({
|
|
66191
|
+
session.ws.send(JSON.stringify({
|
|
66192
|
+
realtimeInput: {
|
|
66193
|
+
audio: { data: pcm16k.toString("base64"), mimeType: "audio/pcm;rate=16000" }
|
|
66194
|
+
}
|
|
66195
|
+
}));
|
|
65466
66196
|
};
|
|
65467
66197
|
const flushBufferedAudio = () => {
|
|
65468
66198
|
const chunks = session.audioBuffer;
|
|
@@ -65520,7 +66250,9 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65520
66250
|
});
|
|
65521
66251
|
liveWs.on("message", (raw) => {
|
|
65522
66252
|
if (isOversizedFrame(raw)) {
|
|
65523
|
-
callbacks.onError({
|
|
66253
|
+
callbacks.onError({
|
|
66254
|
+
message: "Received an oversized frame from Gemini Live \u2014 dropped"
|
|
66255
|
+
});
|
|
65524
66256
|
return;
|
|
65525
66257
|
}
|
|
65526
66258
|
const msg = parseVendorFrame(raw);
|
|
@@ -65565,21 +66297,27 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65565
66297
|
if (Array.isArray(parts)) {
|
|
65566
66298
|
for (const part of parts) {
|
|
65567
66299
|
if (!isPlainObject(part)) {
|
|
65568
|
-
callbacks.onError({
|
|
66300
|
+
callbacks.onError({
|
|
66301
|
+
message: "Received a malformed audio part from Gemini Live"
|
|
66302
|
+
});
|
|
65569
66303
|
continue;
|
|
65570
66304
|
}
|
|
65571
66305
|
const inlineData = part["inlineData"];
|
|
65572
66306
|
const data = isPlainObject(inlineData) ? inlineData["data"] : void 0;
|
|
65573
66307
|
const pcm24k = safeBase64ToBuffer(data);
|
|
65574
66308
|
if (data && !pcm24k) {
|
|
65575
|
-
callbacks.onError({
|
|
66309
|
+
callbacks.onError({
|
|
66310
|
+
message: "Received a malformed audio part from Gemini Live"
|
|
66311
|
+
});
|
|
65576
66312
|
continue;
|
|
65577
66313
|
}
|
|
65578
66314
|
if (pcm24k)
|
|
65579
66315
|
callbacks.onAudioOut(session.resamplerOut.push(pcm24k));
|
|
65580
66316
|
}
|
|
65581
66317
|
} else if (parts !== void 0) {
|
|
65582
|
-
callbacks.onError({
|
|
66318
|
+
callbacks.onError({
|
|
66319
|
+
message: "Received a malformed modelTurn from Gemini Live \u2014 parts was not an array"
|
|
66320
|
+
});
|
|
65583
66321
|
}
|
|
65584
66322
|
if (content.interimInputTranscription?.text && !session.speechStartReported) {
|
|
65585
66323
|
session.speechStartReported = true;
|
|
@@ -65604,12 +66342,18 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65604
66342
|
if (Array.isArray(functionCalls)) {
|
|
65605
66343
|
for (const fc of functionCalls) {
|
|
65606
66344
|
if (!isPlainObject(fc) || typeof fc["id"] !== "string" || typeof fc["name"] !== "string") {
|
|
65607
|
-
callbacks.onError({
|
|
66345
|
+
callbacks.onError({
|
|
66346
|
+
message: "Received a malformed function call from Gemini Live"
|
|
66347
|
+
});
|
|
65608
66348
|
continue;
|
|
65609
66349
|
}
|
|
65610
66350
|
void dispatchToolCall4({ id: fc["id"], name: fc["name"], args: fc["args"] }, tools, ctx, session, callbacks).catch((err) => {
|
|
65611
66351
|
const sanitized = sanitizeVendorError(err);
|
|
65612
|
-
callbacks.onError({
|
|
66352
|
+
callbacks.onError({
|
|
66353
|
+
message: sanitized.message,
|
|
66354
|
+
code: sanitized.code,
|
|
66355
|
+
raw: sanitized
|
|
66356
|
+
});
|
|
65613
66357
|
});
|
|
65614
66358
|
}
|
|
65615
66359
|
} else if (functionCalls !== void 0) {
|
|
@@ -65630,7 +66374,10 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65630
66374
|
});
|
|
65631
66375
|
}
|
|
65632
66376
|
if (msg["goAway"] !== void 0) {
|
|
65633
|
-
callbacks.onError({
|
|
66377
|
+
callbacks.onError({
|
|
66378
|
+
message: "Gemini Live sent goAway \u2014 session will close soon",
|
|
66379
|
+
raw: msg["goAway"]
|
|
66380
|
+
});
|
|
65634
66381
|
}
|
|
65635
66382
|
});
|
|
65636
66383
|
liveWs.on("error", (err) => {
|
|
@@ -65688,7 +66435,11 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65688
66435
|
return;
|
|
65689
66436
|
}
|
|
65690
66437
|
const pcm16k = s.resamplerIn.push(pcm);
|
|
65691
|
-
s.ws.send(JSON.stringify({
|
|
66438
|
+
s.ws.send(JSON.stringify({
|
|
66439
|
+
realtimeInput: {
|
|
66440
|
+
audio: { data: pcm16k.toString("base64"), mimeType: "audio/pcm;rate=16000" }
|
|
66441
|
+
}
|
|
66442
|
+
}));
|
|
65692
66443
|
},
|
|
65693
66444
|
clear() {
|
|
65694
66445
|
},
|
|
@@ -65814,7 +66565,12 @@ function toResponsesInput(input) {
|
|
|
65814
66565
|
return { type: "function_call_output", call_id: turn.toolCallId, output: turn.output };
|
|
65815
66566
|
}
|
|
65816
66567
|
if (turn.role === "tool_call") {
|
|
65817
|
-
return {
|
|
66568
|
+
return {
|
|
66569
|
+
type: "function_call",
|
|
66570
|
+
call_id: turn.id,
|
|
66571
|
+
name: turn.name,
|
|
66572
|
+
arguments: JSON.stringify(turn.arguments ?? {})
|
|
66573
|
+
};
|
|
65818
66574
|
}
|
|
65819
66575
|
return { role: turn.role, content: turn.content };
|
|
65820
66576
|
});
|
|
@@ -65870,7 +66626,12 @@ function createResponsesEventState(callbacks) {
|
|
|
65870
66626
|
let functionCallDetected = false;
|
|
65871
66627
|
const dispatch = (entry, finalArgs) => {
|
|
65872
66628
|
const { value, error } = parseToolArgs(finalArgs);
|
|
65873
|
-
callbacks.onToolCall({
|
|
66629
|
+
callbacks.onToolCall({
|
|
66630
|
+
id: entry.callId,
|
|
66631
|
+
name: entry.name,
|
|
66632
|
+
arguments: value,
|
|
66633
|
+
...error && { argsError: error }
|
|
66634
|
+
});
|
|
65874
66635
|
};
|
|
65875
66636
|
return {
|
|
65876
66637
|
feedEvent(event) {
|
|
@@ -65891,7 +66652,12 @@ function createResponsesEventState(callbacks) {
|
|
|
65891
66652
|
case "response.output_item.added": {
|
|
65892
66653
|
const item = event["item"];
|
|
65893
66654
|
if (item?.type === "function_call" && item.id && item.name) {
|
|
65894
|
-
toolCalls.set(item.id, {
|
|
66655
|
+
toolCalls.set(item.id, {
|
|
66656
|
+
callId: item.call_id ?? item.id,
|
|
66657
|
+
name: item.name,
|
|
66658
|
+
args: "",
|
|
66659
|
+
dispatched: false
|
|
66660
|
+
});
|
|
65895
66661
|
if (!functionCallDetected) {
|
|
65896
66662
|
functionCallDetected = true;
|
|
65897
66663
|
callbacks.onFunctionCallDetected?.(item.name);
|
|
@@ -65928,7 +66694,10 @@ function createResponsesEventState(callbacks) {
|
|
|
65928
66694
|
const flushed = sentences.flush();
|
|
65929
66695
|
if (flushed)
|
|
65930
66696
|
callbacks.onSentence(flushed);
|
|
65931
|
-
const usage = response?.usage ? {
|
|
66697
|
+
const usage = response?.usage ? {
|
|
66698
|
+
inputTokens: response.usage.input_tokens,
|
|
66699
|
+
outputTokens: response.usage.output_tokens
|
|
66700
|
+
} : void 0;
|
|
65932
66701
|
return { text, responseId, usage };
|
|
65933
66702
|
}
|
|
65934
66703
|
case "response.failed": {
|
|
@@ -66012,7 +66781,9 @@ var RawResponsesWs = class {
|
|
|
66012
66781
|
errorHandlers = [];
|
|
66013
66782
|
constructor(apiKey, baseUrl) {
|
|
66014
66783
|
const WebSocketClient = loadWebSocketClient("voice-relay");
|
|
66015
|
-
this.socket = new WebSocketClient(buildResponsesWsUrl(baseUrl), {
|
|
66784
|
+
this.socket = new WebSocketClient(buildResponsesWsUrl(baseUrl), {
|
|
66785
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
66786
|
+
});
|
|
66016
66787
|
this.socket.on("message", (data) => {
|
|
66017
66788
|
let event;
|
|
66018
66789
|
try {
|
|
@@ -66436,7 +67207,9 @@ function attach(options, pendingByCallId, transferredCallIds, call) {
|
|
|
66436
67207
|
usage.outputTokens = (usage.outputTokens ?? 0) + (result2.usage.outputTokens ?? 0);
|
|
66437
67208
|
}
|
|
66438
67209
|
call.send("", { last: true });
|
|
66439
|
-
const roundItems = [
|
|
67210
|
+
const roundItems = [
|
|
67211
|
+
...newInput
|
|
67212
|
+
];
|
|
66440
67213
|
let agentEntry;
|
|
66441
67214
|
if (result2.text) {
|
|
66442
67215
|
agentEntry = { role: "agent", text: result2.text, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -66462,7 +67235,12 @@ function attach(options, pendingByCallId, transferredCallIds, call) {
|
|
|
66462
67235
|
previousResponseId = result2.responseId ?? previousResponseId;
|
|
66463
67236
|
const nextInput = inFlight.map((f, i) => {
|
|
66464
67237
|
if (!chainingEnabled) {
|
|
66465
|
-
roundItems.push({
|
|
67238
|
+
roundItems.push({
|
|
67239
|
+
role: "tool_call",
|
|
67240
|
+
id: f.call.id,
|
|
67241
|
+
name: f.call.name,
|
|
67242
|
+
arguments: f.call.arguments
|
|
67243
|
+
});
|
|
66466
67244
|
}
|
|
66467
67245
|
const outcome = outcomes[i];
|
|
66468
67246
|
return {
|
|
@@ -66586,7 +67364,14 @@ async function resolvePerCallOptions(options, call, context, ctx) {
|
|
|
66586
67364
|
if (offersHangup(tools)) {
|
|
66587
67365
|
resolvedPrompt += options.provider === "openai" ? DELEGATED_CALL_TERMINATION_INSTRUCTIONS : CALL_TERMINATION_INSTRUCTIONS;
|
|
66588
67366
|
}
|
|
66589
|
-
return {
|
|
67367
|
+
return {
|
|
67368
|
+
...rest,
|
|
67369
|
+
prompt: resolvedPrompt,
|
|
67370
|
+
greeting,
|
|
67371
|
+
voice,
|
|
67372
|
+
tools,
|
|
67373
|
+
language: language ?? DEFAULT_LANGUAGE
|
|
67374
|
+
};
|
|
66590
67375
|
}
|
|
66591
67376
|
function realtimeAgent(options) {
|
|
66592
67377
|
if (!options.provider) {
|
|
@@ -66770,7 +67555,11 @@ function realtimeAgent(options) {
|
|
|
66770
67555
|
});
|
|
66771
67556
|
},
|
|
66772
67557
|
onTurn(turn) {
|
|
66773
|
-
const entry = {
|
|
67558
|
+
const entry = {
|
|
67559
|
+
role: turn.role,
|
|
67560
|
+
text: turn.text,
|
|
67561
|
+
timestamp: turn.timestamp
|
|
67562
|
+
};
|
|
66774
67563
|
if (turn.role === "user") {
|
|
66775
67564
|
flushPendingStreamLog();
|
|
66776
67565
|
lastUserTurnAt = Date.now();
|
|
@@ -67429,7 +68218,7 @@ function semver_compare_default(a, b) {
|
|
|
67429
68218
|
|
|
67430
68219
|
// ../../node_modules/libphonenumber-js/es6/helpers/isObject.js
|
|
67431
68220
|
var objectConstructor = {}.constructor;
|
|
67432
|
-
function
|
|
68221
|
+
function isObject2(object) {
|
|
67433
68222
|
return object !== void 0 && object !== null && object.constructor === objectConstructor;
|
|
67434
68223
|
}
|
|
67435
68224
|
|
|
@@ -67837,7 +68626,7 @@ var NumberingPlan = /* @__PURE__ */ (function() {
|
|
|
67837
68626
|
}
|
|
67838
68627
|
}, {
|
|
67839
68628
|
key: "types",
|
|
67840
|
-
value: function
|
|
68629
|
+
value: function types2() {
|
|
67841
68630
|
return this.metadata[this.v1 ? 9 : this.v2 ? 10 : 11];
|
|
67842
68631
|
}
|
|
67843
68632
|
}, {
|
|
@@ -67934,36 +68723,36 @@ var Type = /* @__PURE__ */ (function() {
|
|
|
67934
68723
|
}
|
|
67935
68724
|
}]);
|
|
67936
68725
|
})();
|
|
67937
|
-
function getType(
|
|
68726
|
+
function getType(types2, type) {
|
|
67938
68727
|
switch (type) {
|
|
67939
68728
|
case "FIXED_LINE":
|
|
67940
|
-
return
|
|
68729
|
+
return types2[0];
|
|
67941
68730
|
case "MOBILE":
|
|
67942
|
-
return
|
|
68731
|
+
return types2[1];
|
|
67943
68732
|
case "TOLL_FREE":
|
|
67944
|
-
return
|
|
68733
|
+
return types2[2];
|
|
67945
68734
|
case "PREMIUM_RATE":
|
|
67946
|
-
return
|
|
68735
|
+
return types2[3];
|
|
67947
68736
|
case "PERSONAL_NUMBER":
|
|
67948
|
-
return
|
|
68737
|
+
return types2[4];
|
|
67949
68738
|
case "VOICEMAIL":
|
|
67950
|
-
return
|
|
68739
|
+
return types2[5];
|
|
67951
68740
|
case "UAN":
|
|
67952
|
-
return
|
|
68741
|
+
return types2[6];
|
|
67953
68742
|
case "PAGER":
|
|
67954
|
-
return
|
|
68743
|
+
return types2[7];
|
|
67955
68744
|
case "VOIP":
|
|
67956
|
-
return
|
|
68745
|
+
return types2[8];
|
|
67957
68746
|
case "SHARED_COST":
|
|
67958
|
-
return
|
|
68747
|
+
return types2[9];
|
|
67959
68748
|
}
|
|
67960
68749
|
}
|
|
67961
68750
|
function validateMetadata(metadata) {
|
|
67962
68751
|
if (!metadata) {
|
|
67963
68752
|
throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");
|
|
67964
68753
|
}
|
|
67965
|
-
if (!
|
|
67966
|
-
throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(
|
|
68754
|
+
if (!isObject2(metadata) || !isObject2(metadata.countries)) {
|
|
68755
|
+
throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(isObject2(metadata) ? "an object of shape: { " + Object.keys(metadata).join(", ") + " }" : "a " + typeOf(metadata) + ": " + metadata, "."));
|
|
67967
68756
|
}
|
|
67968
68757
|
}
|
|
67969
68758
|
var typeOf = function typeOf2(_) {
|
|
@@ -68264,10 +69053,10 @@ var VALID_DIGITS = "0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9";
|
|
|
68264
69053
|
var DASHES = "-\u2010-\u2015\u2212\u30FC\uFF0D";
|
|
68265
69054
|
var SLASHES = "\uFF0F/";
|
|
68266
69055
|
var DOTS = "\uFF0E.";
|
|
68267
|
-
var
|
|
69056
|
+
var WHITESPACE2 = " \xA0\xAD\u200B\u2060\u3000";
|
|
68268
69057
|
var BRACKETS = "()\uFF08\uFF09\uFF3B\uFF3D\\[\\]";
|
|
68269
69058
|
var TILDES = "~\u2053\u223C\uFF5E";
|
|
68270
|
-
var VALID_PUNCTUATION = "".concat(DASHES).concat(SLASHES).concat(DOTS).concat(
|
|
69059
|
+
var VALID_PUNCTUATION = "".concat(DASHES).concat(SLASHES).concat(DOTS).concat(WHITESPACE2).concat(BRACKETS).concat(TILDES);
|
|
68271
69060
|
var PLUS_CHARS = "+\uFF0B";
|
|
68272
69061
|
|
|
68273
69062
|
// ../../node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js
|
|
@@ -68816,7 +69605,7 @@ var PhoneNumber = /* @__PURE__ */ (function() {
|
|
|
68816
69605
|
if (countryOrCountryCallingCode[0] === "+" && !nationalNumber) {
|
|
68817
69606
|
throw new TypeError("`metadata` argument not passed");
|
|
68818
69607
|
}
|
|
68819
|
-
if (
|
|
69608
|
+
if (isObject2(nationalNumber) && isObject2(nationalNumber.countries)) {
|
|
68820
69609
|
metadata = nationalNumber;
|
|
68821
69610
|
var e164Number = countryOrCountryCallingCode;
|
|
68822
69611
|
if (!E164_NUMBER_REGEXP.test(e164Number)) {
|
|
@@ -69629,7 +70418,7 @@ function normalizeArguments(args) {
|
|
|
69629
70418
|
defaultCountry: arg_2
|
|
69630
70419
|
}, options);
|
|
69631
70420
|
}
|
|
69632
|
-
} else if (
|
|
70421
|
+
} else if (isObject2(arg_2)) {
|
|
69633
70422
|
if (arg_3) {
|
|
69634
70423
|
options = arg_2;
|
|
69635
70424
|
metadata = arg_3;
|
|
@@ -70152,7 +70941,7 @@ function isArrayBufferView(val) {
|
|
|
70152
70941
|
var isString = typeOfTest("string");
|
|
70153
70942
|
var isFunction = typeOfTest("function");
|
|
70154
70943
|
var isNumber = typeOfTest("number");
|
|
70155
|
-
var
|
|
70944
|
+
var isObject3 = (thing) => thing !== null && typeof thing === "object";
|
|
70156
70945
|
var isBoolean = (thing) => thing === true || thing === false;
|
|
70157
70946
|
var isPlainObject2 = (val) => {
|
|
70158
70947
|
if (kindOf(val) !== "object") {
|
|
@@ -70162,7 +70951,7 @@ var isPlainObject2 = (val) => {
|
|
|
70162
70951
|
return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(toStringTag in val) && !(iterator in val);
|
|
70163
70952
|
};
|
|
70164
70953
|
var isEmptyObject = (val) => {
|
|
70165
|
-
if (!
|
|
70954
|
+
if (!isObject3(val) || isBuffer(val)) {
|
|
70166
70955
|
return false;
|
|
70167
70956
|
}
|
|
70168
70957
|
try {
|
|
@@ -70179,7 +70968,7 @@ var isReactNativeBlob = (value) => {
|
|
|
70179
70968
|
var isReactNative = (formData) => formData && typeof formData.getParts !== "undefined";
|
|
70180
70969
|
var isBlob2 = kindOfTest("Blob");
|
|
70181
70970
|
var isFileList = kindOfTest("FileList");
|
|
70182
|
-
var isStream = (val) =>
|
|
70971
|
+
var isStream = (val) => isObject3(val) && isFunction(val.pipe);
|
|
70183
70972
|
function getGlobal() {
|
|
70184
70973
|
if (typeof globalThis !== "undefined") return globalThis;
|
|
70185
70974
|
if (typeof self !== "undefined") return self;
|
|
@@ -70451,7 +71240,7 @@ function isSpecCompliantForm(thing) {
|
|
|
70451
71240
|
var toJSONObject = (obj) => {
|
|
70452
71241
|
const stack = new Array(10);
|
|
70453
71242
|
const visit = (source, i) => {
|
|
70454
|
-
if (
|
|
71243
|
+
if (isObject3(source)) {
|
|
70455
71244
|
if (stack.indexOf(source) >= 0) {
|
|
70456
71245
|
return;
|
|
70457
71246
|
}
|
|
@@ -70474,7 +71263,7 @@ var toJSONObject = (obj) => {
|
|
|
70474
71263
|
return visit(obj, 0);
|
|
70475
71264
|
};
|
|
70476
71265
|
var isAsyncFn = kindOfTest("AsyncFunction");
|
|
70477
|
-
var isThenable = (thing) => thing && (
|
|
71266
|
+
var isThenable = (thing) => thing && (isObject3(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
70478
71267
|
var _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
70479
71268
|
if (setImmediateSupported) {
|
|
70480
71269
|
return setImmediate;
|
|
@@ -70506,7 +71295,7 @@ var utils_default = {
|
|
|
70506
71295
|
isString,
|
|
70507
71296
|
isNumber,
|
|
70508
71297
|
isBoolean,
|
|
70509
|
-
isObject:
|
|
71298
|
+
isObject: isObject3,
|
|
70510
71299
|
isPlainObject: isPlainObject2,
|
|
70511
71300
|
isEmptyObject,
|
|
70512
71301
|
isReadableStream,
|
|
@@ -70740,22 +71529,22 @@ var AxiosHeaders = class {
|
|
|
70740
71529
|
}
|
|
70741
71530
|
}
|
|
70742
71531
|
}
|
|
70743
|
-
has(header,
|
|
71532
|
+
has(header, matcher2) {
|
|
70744
71533
|
header = normalizeHeader(header);
|
|
70745
71534
|
if (header) {
|
|
70746
71535
|
const key = utils_default.findKey(this, header);
|
|
70747
|
-
return !!(key && this[key] !== void 0 && (!
|
|
71536
|
+
return !!(key && this[key] !== void 0 && (!matcher2 || matchHeaderValue(this, this[key], key, matcher2)));
|
|
70748
71537
|
}
|
|
70749
71538
|
return false;
|
|
70750
71539
|
}
|
|
70751
|
-
delete(header,
|
|
71540
|
+
delete(header, matcher2) {
|
|
70752
71541
|
const self2 = this;
|
|
70753
71542
|
let deleted = false;
|
|
70754
71543
|
function deleteHeader(_header) {
|
|
70755
71544
|
_header = normalizeHeader(_header);
|
|
70756
71545
|
if (_header) {
|
|
70757
71546
|
const key = utils_default.findKey(self2, _header);
|
|
70758
|
-
if (key && (!
|
|
71547
|
+
if (key && (!matcher2 || matchHeaderValue(self2, self2[key], key, matcher2))) {
|
|
70759
71548
|
delete self2[key];
|
|
70760
71549
|
deleted = true;
|
|
70761
71550
|
}
|
|
@@ -70768,13 +71557,13 @@ var AxiosHeaders = class {
|
|
|
70768
71557
|
}
|
|
70769
71558
|
return deleted;
|
|
70770
71559
|
}
|
|
70771
|
-
clear(
|
|
71560
|
+
clear(matcher2) {
|
|
70772
71561
|
const keys = Object.keys(this);
|
|
70773
71562
|
let i = keys.length;
|
|
70774
71563
|
let deleted = false;
|
|
70775
71564
|
while (i--) {
|
|
70776
71565
|
const key = keys[i];
|
|
70777
|
-
if (!
|
|
71566
|
+
if (!matcher2 || matchHeaderValue(this, this[key], key, matcher2, true)) {
|
|
70778
71567
|
delete this[key];
|
|
70779
71568
|
deleted = true;
|
|
70780
71569
|
}
|
|
@@ -70868,7 +71657,7 @@ utils_default.freezeMethods(AxiosHeaders);
|
|
|
70868
71657
|
var AxiosHeaders_default = AxiosHeaders;
|
|
70869
71658
|
|
|
70870
71659
|
// ../../node_modules/axios/lib/core/AxiosError.js
|
|
70871
|
-
var
|
|
71660
|
+
var REDACTED3 = "[REDACTED ****]";
|
|
70872
71661
|
function hasOwnOrPrototypeToJSON(source) {
|
|
70873
71662
|
if (utils_default.hasOwnProp(source, "toJSON")) {
|
|
70874
71663
|
return true;
|
|
@@ -70909,7 +71698,7 @@ function redactConfig(config, redactKeys) {
|
|
|
70909
71698
|
}
|
|
70910
71699
|
result2 = /* @__PURE__ */ Object.create(null);
|
|
70911
71700
|
for (const [key, value] of Object.entries(source)) {
|
|
70912
|
-
const reducedValue = lowerKeys.has(key.toLowerCase()) ?
|
|
71701
|
+
const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED3 : visit(value);
|
|
70913
71702
|
if (!utils_default.isUndefined(reducedValue)) {
|
|
70914
71703
|
result2[key] = reducedValue;
|
|
70915
71704
|
}
|
|
@@ -74609,6 +75398,7 @@ async function configureConversationWebhooks(webhookUrl, config) {
|
|
|
74609
75398
|
const hmacSecret = randomBytes(32).toString("hex");
|
|
74610
75399
|
process.env.CONVERSATION_WEBHOOK_SECRET = hmacSecret;
|
|
74611
75400
|
resetSinchClients();
|
|
75401
|
+
configureSecretRedaction(process.env);
|
|
74612
75402
|
await sinchClient.conversation.webhooks.update({
|
|
74613
75403
|
webhook_id: deployedWebhook.id,
|
|
74614
75404
|
webhookUpdateRequestBody: {
|
|
@@ -74621,7 +75411,10 @@ async function configureConversationWebhooks(webhookUrl, config) {
|
|
|
74621
75411
|
console.log("\u{1F512} HMAC secret configured for webhook signature validation");
|
|
74622
75412
|
console.log("\u{1F4AC} Send a message to your Conversation app to test!");
|
|
74623
75413
|
} catch (error) {
|
|
74624
|
-
console.log(
|
|
75414
|
+
console.log(
|
|
75415
|
+
"\u26A0\uFE0F Could not configure Conversation webhooks:",
|
|
75416
|
+
error instanceof Error ? error.message : error
|
|
75417
|
+
);
|
|
74625
75418
|
}
|
|
74626
75419
|
}
|
|
74627
75420
|
async function cleanupConversationWebhook(config) {
|
|
@@ -74661,7 +75454,10 @@ async function cleanupConversationWebhook(config) {
|
|
|
74661
75454
|
delete process.env.CONVERSATION_WEBHOOK_SECRET;
|
|
74662
75455
|
resetSinchClients();
|
|
74663
75456
|
} catch (error) {
|
|
74664
|
-
console.log(
|
|
75457
|
+
console.log(
|
|
75458
|
+
"\u26A0\uFE0F Could not restore Conversation webhook:",
|
|
75459
|
+
error instanceof Error ? error.message : error
|
|
75460
|
+
);
|
|
74665
75461
|
}
|
|
74666
75462
|
}
|
|
74667
75463
|
async function configureElevenLabs() {
|
|
@@ -74676,7 +75472,10 @@ async function configureElevenLabs() {
|
|
|
74676
75472
|
console.log("\u{1F916} ElevenLabs auto-configuration enabled");
|
|
74677
75473
|
console.log(` Agent ID: ${agentId}`);
|
|
74678
75474
|
} catch (error) {
|
|
74679
|
-
console.log(
|
|
75475
|
+
console.log(
|
|
75476
|
+
"\u26A0\uFE0F Could not configure ElevenLabs:",
|
|
75477
|
+
error instanceof Error ? error.message : error
|
|
75478
|
+
);
|
|
74680
75479
|
}
|
|
74681
75480
|
}
|
|
74682
75481
|
var VOICE_V2_HOST = "https://voice.api.sinch.com";
|
|
@@ -75263,9 +76062,16 @@ var TunnelClient = class {
|
|
|
75263
76062
|
}
|
|
75264
76063
|
this.ws?.send(JSON.stringify(responseMessage));
|
|
75265
76064
|
} catch (error) {
|
|
75266
|
-
console.error(
|
|
76065
|
+
console.error(
|
|
76066
|
+
`Error forwarding request: ${error.message} (${error.response?.status || "no response"})`
|
|
76067
|
+
);
|
|
75267
76068
|
if (verbose && error.response?.data) {
|
|
75268
|
-
console.error(
|
|
76069
|
+
console.error(
|
|
76070
|
+
` \u2192 Error body: ${typeof error.response.data === "string" ? error.response.data : JSON.stringify(error.response.data)}`.substring(
|
|
76071
|
+
0,
|
|
76072
|
+
2e3
|
|
76073
|
+
)
|
|
76074
|
+
);
|
|
75269
76075
|
}
|
|
75270
76076
|
const errorResponse = {
|
|
75271
76077
|
type: "response",
|
|
@@ -75310,7 +76116,10 @@ var TunnelClient = class {
|
|
|
75310
76116
|
await this.configureVoiceWebhooks();
|
|
75311
76117
|
}
|
|
75312
76118
|
if (autoConfigConversation && process.env.CONVERSATION_APP_ID) {
|
|
75313
|
-
await configureConversationWebhooks(
|
|
76119
|
+
await configureConversationWebhooks(
|
|
76120
|
+
this.buildTunnelUrl("/webhook/conversation"),
|
|
76121
|
+
this.webhookConfig
|
|
76122
|
+
);
|
|
75314
76123
|
}
|
|
75315
76124
|
if (process.env.ELEVENLABS_AUTO_CONFIGURE === "true") {
|
|
75316
76125
|
await configureElevenLabs();
|
|
@@ -75610,11 +76419,9 @@ var macKeychain = {
|
|
|
75610
76419
|
},
|
|
75611
76420
|
async deletePassword(service, account) {
|
|
75612
76421
|
try {
|
|
75613
|
-
await execFileAsync(
|
|
75614
|
-
|
|
75615
|
-
|
|
75616
|
-
{ timeout: 15e3 }
|
|
75617
|
-
);
|
|
76422
|
+
await execFileAsync("security", ["delete-generic-password", "-s", service, "-a", account], {
|
|
76423
|
+
timeout: 15e3
|
|
76424
|
+
});
|
|
75618
76425
|
return true;
|
|
75619
76426
|
} catch {
|
|
75620
76427
|
return false;
|
|
@@ -75679,11 +76486,9 @@ var linuxKeychain = {
|
|
|
75679
76486
|
},
|
|
75680
76487
|
async deletePassword(service, account) {
|
|
75681
76488
|
try {
|
|
75682
|
-
await execFileAsync(
|
|
75683
|
-
|
|
75684
|
-
|
|
75685
|
-
{ timeout: 15e3 }
|
|
75686
|
-
);
|
|
76489
|
+
await execFileAsync("secret-tool", ["clear", "service", service, "account", account], {
|
|
76490
|
+
timeout: 15e3
|
|
76491
|
+
});
|
|
75687
76492
|
return true;
|
|
75688
76493
|
} catch (err) {
|
|
75689
76494
|
debugKeychain("clear", err);
|
|
@@ -76044,6 +76849,12 @@ export {
|
|
|
76044
76849
|
shouldValidateWebhook,
|
|
76045
76850
|
getProtectionMode,
|
|
76046
76851
|
createSecurityOptions,
|
|
76852
|
+
configureSecretRedaction,
|
|
76853
|
+
redactSecrets,
|
|
76854
|
+
redactAsText,
|
|
76855
|
+
secretLookaheadBytes,
|
|
76856
|
+
safeCut,
|
|
76857
|
+
installStdioRedaction,
|
|
76047
76858
|
VOICE_TIMESTAMP_SKEW_MS,
|
|
76048
76859
|
VOICE_MISSING_SECRET_WARNING,
|
|
76049
76860
|
validateVoiceSignature,
|
|
@@ -76419,4 +77230,4 @@ serve-static/index.js:
|
|
|
76419
77230
|
* MIT Licensed
|
|
76420
77231
|
*)
|
|
76421
77232
|
*/
|
|
76422
|
-
//# sourceMappingURL=chunk-
|
|
77233
|
+
//# sourceMappingURL=chunk-5K5FDUEL.js.map
|