@mclean-capital/neura 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/server.bundled.mjs +131 -86
- package/core/server.bundled.mjs.map +4 -4
- package/core/version.txt +1 -1
- package/package.json +3 -2
package/core/server.bundled.mjs
CHANGED
|
@@ -2885,11 +2885,11 @@ var require_tools = __commonJS({
|
|
|
2885
2885
|
}
|
|
2886
2886
|
}
|
|
2887
2887
|
}
|
|
2888
|
-
function buildFormatters(level2, bindings,
|
|
2888
|
+
function buildFormatters(level2, bindings, log37) {
|
|
2889
2889
|
return {
|
|
2890
2890
|
level: level2,
|
|
2891
2891
|
bindings,
|
|
2892
|
-
log:
|
|
2892
|
+
log: log37
|
|
2893
2893
|
};
|
|
2894
2894
|
}
|
|
2895
2895
|
function normalizeDestFileDescriptor(destination) {
|
|
@@ -3272,11 +3272,11 @@ var require_proto = __commonJS({
|
|
|
3272
3272
|
}
|
|
3273
3273
|
} else instance[serializersSym] = serializers;
|
|
3274
3274
|
if (options.hasOwnProperty("formatters")) {
|
|
3275
|
-
const { level: level2, bindings: chindings, log:
|
|
3275
|
+
const { level: level2, bindings: chindings, log: log37 } = options.formatters;
|
|
3276
3276
|
instance[formattersSym] = buildFormatters(
|
|
3277
3277
|
level2 || formatters2.level,
|
|
3278
3278
|
chindings || resetChildingsFormatter,
|
|
3279
|
-
|
|
3279
|
+
log37 || formatters2.log
|
|
3280
3280
|
);
|
|
3281
3281
|
} else {
|
|
3282
3282
|
instance[formattersSym] = buildFormatters(
|
|
@@ -8018,7 +8018,7 @@ var require_depd = __commonJS({
|
|
|
8018
8018
|
var site = callSiteLocation(stack[1]);
|
|
8019
8019
|
var file2 = site[0];
|
|
8020
8020
|
function deprecate3(message) {
|
|
8021
|
-
|
|
8021
|
+
log37.call(deprecate3, message);
|
|
8022
8022
|
}
|
|
8023
8023
|
deprecate3._file = file2;
|
|
8024
8024
|
deprecate3._ignored = isignored(namespace);
|
|
@@ -8047,7 +8047,7 @@ var require_depd = __commonJS({
|
|
|
8047
8047
|
var str2 = process.env.TRACE_DEPRECATION || "";
|
|
8048
8048
|
return containsNamespace(str2, namespace);
|
|
8049
8049
|
}
|
|
8050
|
-
function
|
|
8050
|
+
function log37(message, site) {
|
|
8051
8051
|
var haslisteners = eehaslisteners(process, "deprecation");
|
|
8052
8052
|
if (!haslisteners && this._ignored) {
|
|
8053
8053
|
return;
|
|
@@ -8187,7 +8187,7 @@ var require_depd = __commonJS({
|
|
|
8187
8187
|
"message",
|
|
8188
8188
|
"site",
|
|
8189
8189
|
'"use strict"\nreturn function (' + args + ") {log.call(deprecate, message, site)\nreturn fn.apply(this, arguments)\n}"
|
|
8190
|
-
)(fn,
|
|
8190
|
+
)(fn, log37, this, message, site);
|
|
8191
8191
|
return deprecatedfn;
|
|
8192
8192
|
}
|
|
8193
8193
|
function wrapproperty(obj, prop, message) {
|
|
@@ -8212,13 +8212,13 @@ var require_depd = __commonJS({
|
|
|
8212
8212
|
var set2 = descriptor.set;
|
|
8213
8213
|
if (typeof get === "function") {
|
|
8214
8214
|
descriptor.get = function getter() {
|
|
8215
|
-
|
|
8215
|
+
log37.call(deprecate3, message, site);
|
|
8216
8216
|
return get.apply(this, arguments);
|
|
8217
8217
|
};
|
|
8218
8218
|
}
|
|
8219
8219
|
if (typeof set2 === "function") {
|
|
8220
8220
|
descriptor.set = function setter() {
|
|
8221
|
-
|
|
8221
|
+
log37.call(deprecate3, message, site);
|
|
8222
8222
|
return set2.apply(this, arguments);
|
|
8223
8223
|
};
|
|
8224
8224
|
}
|
|
@@ -9055,7 +9055,7 @@ var require_debug = __commonJS({
|
|
|
9055
9055
|
var require_browser = __commonJS({
|
|
9056
9056
|
"../../node_modules/body-parser/node_modules/debug/src/browser.js"(exports, module) {
|
|
9057
9057
|
exports = module.exports = require_debug();
|
|
9058
|
-
exports.log =
|
|
9058
|
+
exports.log = log37;
|
|
9059
9059
|
exports.formatArgs = formatArgs;
|
|
9060
9060
|
exports.save = save;
|
|
9061
9061
|
exports.load = load;
|
|
@@ -9103,7 +9103,7 @@ var require_browser = __commonJS({
|
|
|
9103
9103
|
});
|
|
9104
9104
|
args.splice(lastC, 0, c);
|
|
9105
9105
|
}
|
|
9106
|
-
function
|
|
9106
|
+
function log37() {
|
|
9107
9107
|
return "object" === typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments);
|
|
9108
9108
|
}
|
|
9109
9109
|
function save(namespaces) {
|
|
@@ -9144,7 +9144,7 @@ var require_node = __commonJS({
|
|
|
9144
9144
|
var util = __require("util");
|
|
9145
9145
|
exports = module.exports = require_debug();
|
|
9146
9146
|
exports.init = init;
|
|
9147
|
-
exports.log =
|
|
9147
|
+
exports.log = log37;
|
|
9148
9148
|
exports.formatArgs = formatArgs;
|
|
9149
9149
|
exports.save = save;
|
|
9150
9150
|
exports.load = load;
|
|
@@ -9195,7 +9195,7 @@ var require_node = __commonJS({
|
|
|
9195
9195
|
args[0] = (/* @__PURE__ */ new Date()).toUTCString() + " " + name + " " + args[0];
|
|
9196
9196
|
}
|
|
9197
9197
|
}
|
|
9198
|
-
function
|
|
9198
|
+
function log37() {
|
|
9199
9199
|
return stream.write(util.format.apply(util, arguments) + "\n");
|
|
9200
9200
|
}
|
|
9201
9201
|
function save(namespaces) {
|
|
@@ -25402,7 +25402,7 @@ var require_debug2 = __commonJS({
|
|
|
25402
25402
|
var require_browser2 = __commonJS({
|
|
25403
25403
|
"../../node_modules/finalhandler/node_modules/debug/src/browser.js"(exports, module) {
|
|
25404
25404
|
exports = module.exports = require_debug2();
|
|
25405
|
-
exports.log =
|
|
25405
|
+
exports.log = log37;
|
|
25406
25406
|
exports.formatArgs = formatArgs;
|
|
25407
25407
|
exports.save = save;
|
|
25408
25408
|
exports.load = load;
|
|
@@ -25450,7 +25450,7 @@ var require_browser2 = __commonJS({
|
|
|
25450
25450
|
});
|
|
25451
25451
|
args.splice(lastC, 0, c);
|
|
25452
25452
|
}
|
|
25453
|
-
function
|
|
25453
|
+
function log37() {
|
|
25454
25454
|
return "object" === typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments);
|
|
25455
25455
|
}
|
|
25456
25456
|
function save(namespaces) {
|
|
@@ -25491,7 +25491,7 @@ var require_node2 = __commonJS({
|
|
|
25491
25491
|
var util = __require("util");
|
|
25492
25492
|
exports = module.exports = require_debug2();
|
|
25493
25493
|
exports.init = init;
|
|
25494
|
-
exports.log =
|
|
25494
|
+
exports.log = log37;
|
|
25495
25495
|
exports.formatArgs = formatArgs;
|
|
25496
25496
|
exports.save = save;
|
|
25497
25497
|
exports.load = load;
|
|
@@ -25542,7 +25542,7 @@ var require_node2 = __commonJS({
|
|
|
25542
25542
|
args[0] = (/* @__PURE__ */ new Date()).toUTCString() + " " + name + " " + args[0];
|
|
25543
25543
|
}
|
|
25544
25544
|
}
|
|
25545
|
-
function
|
|
25545
|
+
function log37() {
|
|
25546
25546
|
return stream.write(util.format.apply(util, arguments) + "\n");
|
|
25547
25547
|
}
|
|
25548
25548
|
function save(namespaces) {
|
|
@@ -26121,7 +26121,7 @@ var require_debug3 = __commonJS({
|
|
|
26121
26121
|
var require_browser3 = __commonJS({
|
|
26122
26122
|
"../../node_modules/express/node_modules/debug/src/browser.js"(exports, module) {
|
|
26123
26123
|
exports = module.exports = require_debug3();
|
|
26124
|
-
exports.log =
|
|
26124
|
+
exports.log = log37;
|
|
26125
26125
|
exports.formatArgs = formatArgs;
|
|
26126
26126
|
exports.save = save;
|
|
26127
26127
|
exports.load = load;
|
|
@@ -26169,7 +26169,7 @@ var require_browser3 = __commonJS({
|
|
|
26169
26169
|
});
|
|
26170
26170
|
args.splice(lastC, 0, c);
|
|
26171
26171
|
}
|
|
26172
|
-
function
|
|
26172
|
+
function log37() {
|
|
26173
26173
|
return "object" === typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments);
|
|
26174
26174
|
}
|
|
26175
26175
|
function save(namespaces) {
|
|
@@ -26210,7 +26210,7 @@ var require_node3 = __commonJS({
|
|
|
26210
26210
|
var util = __require("util");
|
|
26211
26211
|
exports = module.exports = require_debug3();
|
|
26212
26212
|
exports.init = init;
|
|
26213
|
-
exports.log =
|
|
26213
|
+
exports.log = log37;
|
|
26214
26214
|
exports.formatArgs = formatArgs;
|
|
26215
26215
|
exports.save = save;
|
|
26216
26216
|
exports.load = load;
|
|
@@ -26261,7 +26261,7 @@ var require_node3 = __commonJS({
|
|
|
26261
26261
|
args[0] = (/* @__PURE__ */ new Date()).toUTCString() + " " + name + " " + args[0];
|
|
26262
26262
|
}
|
|
26263
26263
|
}
|
|
26264
|
-
function
|
|
26264
|
+
function log37() {
|
|
26265
26265
|
return stream.write(util.format.apply(util, arguments) + "\n");
|
|
26266
26266
|
}
|
|
26267
26267
|
function save(namespaces) {
|
|
@@ -27687,7 +27687,7 @@ var require_debug4 = __commonJS({
|
|
|
27687
27687
|
var require_browser4 = __commonJS({
|
|
27688
27688
|
"../../node_modules/send/node_modules/debug/src/browser.js"(exports, module) {
|
|
27689
27689
|
exports = module.exports = require_debug4();
|
|
27690
|
-
exports.log =
|
|
27690
|
+
exports.log = log37;
|
|
27691
27691
|
exports.formatArgs = formatArgs;
|
|
27692
27692
|
exports.save = save;
|
|
27693
27693
|
exports.load = load;
|
|
@@ -27735,7 +27735,7 @@ var require_browser4 = __commonJS({
|
|
|
27735
27735
|
});
|
|
27736
27736
|
args.splice(lastC, 0, c);
|
|
27737
27737
|
}
|
|
27738
|
-
function
|
|
27738
|
+
function log37() {
|
|
27739
27739
|
return "object" === typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments);
|
|
27740
27740
|
}
|
|
27741
27741
|
function save(namespaces) {
|
|
@@ -27776,7 +27776,7 @@ var require_node4 = __commonJS({
|
|
|
27776
27776
|
var util = __require("util");
|
|
27777
27777
|
exports = module.exports = require_debug4();
|
|
27778
27778
|
exports.init = init;
|
|
27779
|
-
exports.log =
|
|
27779
|
+
exports.log = log37;
|
|
27780
27780
|
exports.formatArgs = formatArgs;
|
|
27781
27781
|
exports.save = save;
|
|
27782
27782
|
exports.load = load;
|
|
@@ -27827,7 +27827,7 @@ var require_node4 = __commonJS({
|
|
|
27827
27827
|
args[0] = (/* @__PURE__ */ new Date()).toUTCString() + " " + name + " " + args[0];
|
|
27828
27828
|
}
|
|
27829
27829
|
}
|
|
27830
|
-
function
|
|
27830
|
+
function log37() {
|
|
27831
27831
|
return stream.write(util.format.apply(util, arguments) + "\n");
|
|
27832
27832
|
}
|
|
27833
27833
|
function save(namespaces) {
|
|
@@ -33132,7 +33132,7 @@ var require_node5 = __commonJS({
|
|
|
33132
33132
|
var tty = __require("tty");
|
|
33133
33133
|
var util = __require("util");
|
|
33134
33134
|
exports.init = init;
|
|
33135
|
-
exports.log =
|
|
33135
|
+
exports.log = log37;
|
|
33136
33136
|
exports.formatArgs = formatArgs;
|
|
33137
33137
|
exports.save = save;
|
|
33138
33138
|
exports.load = load;
|
|
@@ -33267,7 +33267,7 @@ var require_node5 = __commonJS({
|
|
|
33267
33267
|
}
|
|
33268
33268
|
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
33269
33269
|
}
|
|
33270
|
-
function
|
|
33270
|
+
function log37(...args) {
|
|
33271
33271
|
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + "\n");
|
|
33272
33272
|
}
|
|
33273
33273
|
function save(namespaces) {
|
|
@@ -42706,7 +42706,7 @@ var require_logging_utils = __commonJS({
|
|
|
42706
42706
|
exports.getDebugBackend = getDebugBackend;
|
|
42707
42707
|
exports.getStructuredBackend = getStructuredBackend;
|
|
42708
42708
|
exports.setBackend = setBackend;
|
|
42709
|
-
exports.log =
|
|
42709
|
+
exports.log = log37;
|
|
42710
42710
|
var events_1 = __require("events");
|
|
42711
42711
|
var process3 = __importStar(__require("process"));
|
|
42712
42712
|
var util = __importStar(__require("util"));
|
|
@@ -42738,7 +42738,7 @@ var require_logging_utils = __commonJS({
|
|
|
42738
42738
|
this.func.info = (...args) => this.invokeSeverity(LogSeverity.INFO, ...args);
|
|
42739
42739
|
this.func.warn = (...args) => this.invokeSeverity(LogSeverity.WARNING, ...args);
|
|
42740
42740
|
this.func.error = (...args) => this.invokeSeverity(LogSeverity.ERROR, ...args);
|
|
42741
|
-
this.func.sublog = (namespace2) =>
|
|
42741
|
+
this.func.sublog = (namespace2) => log37(namespace2, this.func);
|
|
42742
42742
|
}
|
|
42743
42743
|
invoke(fields, ...args) {
|
|
42744
42744
|
if (this.upstream) {
|
|
@@ -42905,7 +42905,7 @@ var require_logging_utils = __commonJS({
|
|
|
42905
42905
|
cachedBackend = backend;
|
|
42906
42906
|
loggerCache.clear();
|
|
42907
42907
|
}
|
|
42908
|
-
function
|
|
42908
|
+
function log37(namespace, parent) {
|
|
42909
42909
|
if (!cachedBackend) {
|
|
42910
42910
|
const enablesFlag = process3.env[exports.env.nodeEnables];
|
|
42911
42911
|
if (!enablesFlag) {
|
|
@@ -43038,7 +43038,7 @@ var require_src8 = __commonJS({
|
|
|
43038
43038
|
exports.HEADER_NAME = "Metadata-Flavor";
|
|
43039
43039
|
exports.HEADER_VALUE = "Google";
|
|
43040
43040
|
exports.HEADERS = Object.freeze({ [exports.HEADER_NAME]: exports.HEADER_VALUE });
|
|
43041
|
-
var
|
|
43041
|
+
var log37 = logger.log("gcp-metadata");
|
|
43042
43042
|
exports.METADATA_SERVER_DETECTION = Object.freeze({
|
|
43043
43043
|
"assume-present": "don't try to ping the metadata server, but assume it's present",
|
|
43044
43044
|
none: "don't try to ping the metadata server, but don't try to use it either",
|
|
@@ -43101,9 +43101,9 @@ var require_src8 = __commonJS({
|
|
|
43101
43101
|
responseType: "text",
|
|
43102
43102
|
timeout: requestTimeout()
|
|
43103
43103
|
};
|
|
43104
|
-
|
|
43104
|
+
log37.info("instance request %j", req);
|
|
43105
43105
|
const res = await requestMethod(req);
|
|
43106
|
-
|
|
43106
|
+
log37.info("instance metadata is %s", res.data);
|
|
43107
43107
|
const metadataFlavor = res.headers.get(exports.HEADER_NAME);
|
|
43108
43108
|
if (metadataFlavor !== exports.HEADER_VALUE) {
|
|
43109
43109
|
throw new RangeError(`Invalid response from metadata service: incorrect ${exports.HEADER_NAME} header. Expected '${exports.HEADER_VALUE}', got ${metadataFlavor ? `'${metadataFlavor}'` : "no header"}`);
|
|
@@ -65609,9 +65609,9 @@ var multipartFormRequestOptions = async (opts, fetch3) => {
|
|
|
65609
65609
|
var supportsFormDataMap = /* @__PURE__ */ new WeakMap();
|
|
65610
65610
|
function supportsFormData(fetchObject) {
|
|
65611
65611
|
const fetch3 = typeof fetchObject === "function" ? fetchObject : fetchObject.fetch;
|
|
65612
|
-
const
|
|
65613
|
-
if (
|
|
65614
|
-
return
|
|
65612
|
+
const cached3 = supportsFormDataMap.get(fetch3);
|
|
65613
|
+
if (cached3)
|
|
65614
|
+
return cached3;
|
|
65615
65615
|
const promise2 = (async () => {
|
|
65616
65616
|
try {
|
|
65617
65617
|
const FetchResponse = "Response" in fetch3 ? fetch3.Response : (await fetch3("data:,")).constructor;
|
|
@@ -96980,8 +96980,35 @@ import { join as join6 } from "path";
|
|
|
96980
96980
|
// src/presence/onnx-wake-detector.ts
|
|
96981
96981
|
import { existsSync as existsSync7 } from "fs";
|
|
96982
96982
|
import { join as join5 } from "path";
|
|
96983
|
-
|
|
96984
|
-
|
|
96983
|
+
|
|
96984
|
+
// src/presence/ort-loader.ts
|
|
96985
|
+
var log32 = new Logger("ort-loader");
|
|
96986
|
+
var cached2;
|
|
96987
|
+
async function loadOrt() {
|
|
96988
|
+
if (cached2 !== void 0) return cached2;
|
|
96989
|
+
try {
|
|
96990
|
+
const mod = await import("onnxruntime-node");
|
|
96991
|
+
cached2 = { ort: mod, backend: "native" };
|
|
96992
|
+
log32.info("ONNX runtime loaded", { backend: "native" });
|
|
96993
|
+
return cached2;
|
|
96994
|
+
} catch {
|
|
96995
|
+
log32.debug("onnxruntime-node unavailable, trying WASM fallback");
|
|
96996
|
+
}
|
|
96997
|
+
try {
|
|
96998
|
+
const mod = await import("onnxruntime-web");
|
|
96999
|
+
mod.env.wasm.numThreads = 1;
|
|
97000
|
+
cached2 = { ort: mod, backend: "wasm" };
|
|
97001
|
+
log32.info("ONNX runtime loaded", { backend: "wasm" });
|
|
97002
|
+
return cached2;
|
|
97003
|
+
} catch {
|
|
97004
|
+
log32.warn("no ONNX runtime available \u2014 wake word detection will be disabled");
|
|
97005
|
+
}
|
|
97006
|
+
cached2 = null;
|
|
97007
|
+
return null;
|
|
97008
|
+
}
|
|
97009
|
+
|
|
97010
|
+
// src/presence/onnx-wake-detector.ts
|
|
97011
|
+
var log33 = new Logger("onnx-wake");
|
|
96985
97012
|
var MODEL_SAMPLE_RATE = 16e3;
|
|
96986
97013
|
var INPUT_SAMPLE_RATE = 24e3;
|
|
96987
97014
|
var EMBEDDING_WINDOW = 76;
|
|
@@ -96996,6 +97023,8 @@ var MAX_REPLAY_BYTES = 24e3 * 2 * 4;
|
|
|
96996
97023
|
var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
96997
97024
|
config;
|
|
96998
97025
|
threshold;
|
|
97026
|
+
ort;
|
|
97027
|
+
backend;
|
|
96999
97028
|
// ONNX sessions
|
|
97000
97029
|
melSession;
|
|
97001
97030
|
melInputName;
|
|
@@ -97022,9 +97051,11 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
97022
97051
|
lastDetectionTime = 0;
|
|
97023
97052
|
inferenceInProgress = false;
|
|
97024
97053
|
closed = false;
|
|
97025
|
-
constructor(config2, melSession, embeddingSession, classifierSession) {
|
|
97054
|
+
constructor(config2, ort, backend, melSession, embeddingSession, classifierSession) {
|
|
97026
97055
|
this.config = config2;
|
|
97027
97056
|
this.threshold = config2.threshold ?? 0.5;
|
|
97057
|
+
this.ort = ort;
|
|
97058
|
+
this.backend = backend;
|
|
97028
97059
|
this.melSession = melSession;
|
|
97029
97060
|
this.melInputName = melSession.inputNames[0];
|
|
97030
97061
|
this.melOutputName = melSession.outputNames[0];
|
|
@@ -97036,6 +97067,11 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
97036
97067
|
this.classifierOutputName = classifierSession.outputNames[0];
|
|
97037
97068
|
}
|
|
97038
97069
|
static async create(config2) {
|
|
97070
|
+
const result = await loadOrt();
|
|
97071
|
+
if (!result) {
|
|
97072
|
+
throw new Error("No ONNX runtime available (tried native and WASM)");
|
|
97073
|
+
}
|
|
97074
|
+
const { ort, backend } = result;
|
|
97039
97075
|
const melPath = join5(config2.modelsDir, "melspectrogram.onnx");
|
|
97040
97076
|
const embeddingPath = join5(config2.modelsDir, "embedding_model.onnx");
|
|
97041
97077
|
const classifierPath = join5(config2.modelsDir, `${config2.assistantName}.onnx`);
|
|
@@ -97048,22 +97084,30 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
97048
97084
|
throw new Error(`ONNX ${name} model not found: ${path3}`);
|
|
97049
97085
|
}
|
|
97050
97086
|
}
|
|
97087
|
+
const provider = backend === "native" ? "cpu" : "wasm";
|
|
97051
97088
|
const opts = {
|
|
97052
|
-
executionProviders: [
|
|
97053
|
-
interOpNumThreads: 1,
|
|
97054
|
-
intraOpNumThreads: 1
|
|
97089
|
+
executionProviders: [provider],
|
|
97090
|
+
...backend === "native" && { interOpNumThreads: 1, intraOpNumThreads: 1 }
|
|
97055
97091
|
};
|
|
97056
97092
|
const [melSession, embeddingSession, classifierSession] = await Promise.all([
|
|
97057
97093
|
ort.InferenceSession.create(melPath, opts),
|
|
97058
97094
|
ort.InferenceSession.create(embeddingPath, opts),
|
|
97059
97095
|
ort.InferenceSession.create(classifierPath, opts)
|
|
97060
97096
|
]);
|
|
97061
|
-
|
|
97097
|
+
log33.info("ONNX models loaded", {
|
|
97098
|
+
backend,
|
|
97062
97099
|
mel: melPath,
|
|
97063
97100
|
embedding: embeddingPath,
|
|
97064
97101
|
classifier: classifierPath
|
|
97065
97102
|
});
|
|
97066
|
-
return new _OnnxWakeDetector(
|
|
97103
|
+
return new _OnnxWakeDetector(
|
|
97104
|
+
config2,
|
|
97105
|
+
ort,
|
|
97106
|
+
backend,
|
|
97107
|
+
melSession,
|
|
97108
|
+
embeddingSession,
|
|
97109
|
+
classifierSession
|
|
97110
|
+
);
|
|
97067
97111
|
}
|
|
97068
97112
|
feedAudio(base64Pcm) {
|
|
97069
97113
|
if (this.closed) return;
|
|
@@ -97100,19 +97144,20 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
97100
97144
|
}
|
|
97101
97145
|
setAssistantName(name) {
|
|
97102
97146
|
this.config.assistantName = name;
|
|
97103
|
-
|
|
97147
|
+
log33.info("assistant name updated, reloading classifier", { assistantName: name });
|
|
97104
97148
|
const classifierPath = join5(this.config.modelsDir, `${name}.onnx`);
|
|
97105
97149
|
if (!existsSync7(classifierPath)) {
|
|
97106
|
-
|
|
97150
|
+
log33.warn("no ONNX classifier for new name", { name, path: classifierPath });
|
|
97107
97151
|
return;
|
|
97108
97152
|
}
|
|
97109
|
-
|
|
97110
|
-
|
|
97153
|
+
const provider = this.backend === "native" ? "cpu" : "wasm";
|
|
97154
|
+
void this.ort.InferenceSession.create(classifierPath, {
|
|
97155
|
+
executionProviders: [provider]
|
|
97111
97156
|
}).then((session) => {
|
|
97112
97157
|
this.classifierSession = session;
|
|
97113
97158
|
this.classifierInputName = session.inputNames[0];
|
|
97114
97159
|
this.classifierOutputName = session.outputNames[0];
|
|
97115
|
-
|
|
97160
|
+
log33.info("classifier reloaded", { name });
|
|
97116
97161
|
});
|
|
97117
97162
|
}
|
|
97118
97163
|
close() {
|
|
@@ -97161,11 +97206,11 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
97161
97206
|
const score = await this.runPipeline(chunk);
|
|
97162
97207
|
const isWake = score >= this.threshold;
|
|
97163
97208
|
if (score > 0.1) {
|
|
97164
|
-
|
|
97209
|
+
log33.debug("inference result", { score: score.toFixed(4), isWake });
|
|
97165
97210
|
}
|
|
97166
97211
|
this.config.onDebug?.({ score, isWake });
|
|
97167
97212
|
if (isWake && !this.closed) {
|
|
97168
|
-
|
|
97213
|
+
log33.info("wake word detected via ONNX", { score: score.toFixed(4) });
|
|
97169
97214
|
this.lastDetectionTime = Date.now();
|
|
97170
97215
|
const chunks = [...this.replayChunks];
|
|
97171
97216
|
this.replayChunks.length = 0;
|
|
@@ -97173,13 +97218,13 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
97173
97218
|
this.config.onWake(chunks);
|
|
97174
97219
|
}
|
|
97175
97220
|
} catch (err) {
|
|
97176
|
-
|
|
97221
|
+
log33.error("ONNX inference failed", { err: String(err) });
|
|
97177
97222
|
} finally {
|
|
97178
97223
|
this.inferenceInProgress = false;
|
|
97179
97224
|
}
|
|
97180
97225
|
}
|
|
97181
97226
|
async runPipeline(audio16k) {
|
|
97182
|
-
const melInput = new ort.Tensor("float32", audio16k, [1, audio16k.length]);
|
|
97227
|
+
const melInput = new this.ort.Tensor("float32", audio16k, [1, audio16k.length]);
|
|
97183
97228
|
const melResult = await this.melSession.run({ [this.melInputName]: melInput });
|
|
97184
97229
|
const melOutput = melResult[this.melOutputName];
|
|
97185
97230
|
const melData = melOutput.data;
|
|
@@ -97203,7 +97248,7 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
97203
97248
|
windowData[dstStart + i2] = normalizedMel[srcStart + i2];
|
|
97204
97249
|
}
|
|
97205
97250
|
}
|
|
97206
|
-
const embInput = new ort.Tensor("float32", windowData, [
|
|
97251
|
+
const embInput = new this.ort.Tensor("float32", windowData, [
|
|
97207
97252
|
nWindows,
|
|
97208
97253
|
EMBEDDING_WINDOW,
|
|
97209
97254
|
melBands,
|
|
@@ -97219,7 +97264,7 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
97219
97264
|
const srcOffset = (startWindow + i2) * embDim;
|
|
97220
97265
|
classifierData.set(embData.subarray(srcOffset, srcOffset + embDim), i2 * embDim);
|
|
97221
97266
|
}
|
|
97222
|
-
const classInput = new ort.Tensor("float32", classifierData, [1, MIN_EMBEDDINGS, embDim]);
|
|
97267
|
+
const classInput = new this.ort.Tensor("float32", classifierData, [1, MIN_EMBEDDINGS, embDim]);
|
|
97223
97268
|
const classResult = await this.classifierSession.run({
|
|
97224
97269
|
[this.classifierInputName]: classInput
|
|
97225
97270
|
});
|
|
@@ -97259,7 +97304,7 @@ function rms(samples) {
|
|
|
97259
97304
|
}
|
|
97260
97305
|
|
|
97261
97306
|
// src/presence/presence-manager.ts
|
|
97262
|
-
var
|
|
97307
|
+
var log34 = new Logger("presence");
|
|
97263
97308
|
var ACTIVE_IDLE_TIMEOUT_MS = 5 * 6e4;
|
|
97264
97309
|
var PresenceManager = class {
|
|
97265
97310
|
_state = "passive";
|
|
@@ -97300,7 +97345,7 @@ var PresenceManager = class {
|
|
|
97300
97345
|
if (this.idleTimer) clearTimeout(this.idleTimer);
|
|
97301
97346
|
this.idleTimer = setTimeout(() => {
|
|
97302
97347
|
if (this._state === "active") {
|
|
97303
|
-
|
|
97348
|
+
log34.info("active idle timeout, going passive");
|
|
97304
97349
|
this.enterMode("passive");
|
|
97305
97350
|
}
|
|
97306
97351
|
}, ACTIVE_IDLE_TIMEOUT_MS);
|
|
@@ -97319,13 +97364,13 @@ var PresenceManager = class {
|
|
|
97319
97364
|
if (this._state === newState) return;
|
|
97320
97365
|
const prev = this._state;
|
|
97321
97366
|
this._state = newState;
|
|
97322
|
-
|
|
97367
|
+
log34.info("state transition", { from: prev, to: newState });
|
|
97323
97368
|
this.callbacks.onStateChange(newState);
|
|
97324
97369
|
}
|
|
97325
97370
|
};
|
|
97326
97371
|
|
|
97327
97372
|
// src/server/websocket.ts
|
|
97328
|
-
var
|
|
97373
|
+
var log35 = new Logger("server");
|
|
97329
97374
|
var IDLE_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
97330
97375
|
var COST_UPDATE_INTERVAL_MS = 3e4;
|
|
97331
97376
|
var INFRA_MODELS = /* @__PURE__ */ new Set(["melspectrogram", "embedding_model"]);
|
|
@@ -97361,13 +97406,13 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97361
97406
|
if (token && verifyToken(token, authToken)) {
|
|
97362
97407
|
done(true);
|
|
97363
97408
|
} else {
|
|
97364
|
-
|
|
97409
|
+
log35.warn("websocket auth rejected");
|
|
97365
97410
|
done(false, 401, "Unauthorized");
|
|
97366
97411
|
}
|
|
97367
97412
|
} : void 0
|
|
97368
97413
|
});
|
|
97369
97414
|
wss2.on("connection", (ws) => {
|
|
97370
|
-
|
|
97415
|
+
log35.info("client connected");
|
|
97371
97416
|
if (ws.readyState === import_websocket.default.OPEN) {
|
|
97372
97417
|
ws.send(JSON.stringify({ type: "presenceState", state: "passive" }));
|
|
97373
97418
|
}
|
|
@@ -97383,7 +97428,7 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97383
97428
|
}
|
|
97384
97429
|
const visionProviderLabel = visionRoute ? `${visionRoute.provider}/${visionRoute.model} (${visionRoute.mode})` : "none";
|
|
97385
97430
|
const sessionIdPromise = store ? store.createSession(voiceProviderLabel, visionProviderLabel).catch((err) => {
|
|
97386
|
-
|
|
97431
|
+
log35.warn("session creation failed", { err: String(err) });
|
|
97387
97432
|
return null;
|
|
97388
97433
|
}) : Promise.resolve(null);
|
|
97389
97434
|
const pendingWrites = /* @__PURE__ */ new Set();
|
|
@@ -97401,7 +97446,7 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97401
97446
|
await memoryManager.queueExtraction(sid);
|
|
97402
97447
|
}
|
|
97403
97448
|
}).catch((err) => {
|
|
97404
|
-
|
|
97449
|
+
log35.warn("extraction failed", { err: String(err) });
|
|
97405
97450
|
});
|
|
97406
97451
|
pendingCleanups.add(extractionPromise);
|
|
97407
97452
|
void extractionPromise.finally(() => pendingCleanups.delete(extractionPromise));
|
|
@@ -97410,7 +97455,7 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97410
97455
|
function resetIdleTimer() {
|
|
97411
97456
|
if (idleTimer) clearTimeout(idleTimer);
|
|
97412
97457
|
idleTimer = setTimeout(() => {
|
|
97413
|
-
|
|
97458
|
+
log35.info("idle timeout, triggering extraction");
|
|
97414
97459
|
triggerExtraction();
|
|
97415
97460
|
}, IDLE_TIMEOUT_MS);
|
|
97416
97461
|
}
|
|
@@ -97451,12 +97496,12 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97451
97496
|
cameraWatcher.close();
|
|
97452
97497
|
cameraWatcher = null;
|
|
97453
97498
|
costTracker.markVisionInactive("camera");
|
|
97454
|
-
|
|
97499
|
+
log35.info("camera watcher closed");
|
|
97455
97500
|
} else if (source === "screen" && screenWatcher) {
|
|
97456
97501
|
screenWatcher.close();
|
|
97457
97502
|
screenWatcher = null;
|
|
97458
97503
|
costTracker.markVisionInactive("screen");
|
|
97459
|
-
|
|
97504
|
+
log35.info("screen watcher closed");
|
|
97460
97505
|
}
|
|
97461
97506
|
}
|
|
97462
97507
|
const memoryTools = memoryManager ? {
|
|
@@ -97527,7 +97572,7 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97527
97572
|
sessionIdPromise.then(async (sid) => {
|
|
97528
97573
|
if (sid) await store.appendTranscript(sid, "user", text);
|
|
97529
97574
|
}).catch((err) => {
|
|
97530
|
-
|
|
97575
|
+
log35.warn("transcript write failed", { err: String(err) });
|
|
97531
97576
|
})
|
|
97532
97577
|
);
|
|
97533
97578
|
}
|
|
@@ -97542,7 +97587,7 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97542
97587
|
sessionIdPromise.then(async (sid) => {
|
|
97543
97588
|
if (sid) await store.appendTranscript(sid, "assistant", text);
|
|
97544
97589
|
}).catch((err) => {
|
|
97545
|
-
|
|
97590
|
+
log35.warn("transcript write failed", { err: String(err) });
|
|
97546
97591
|
})
|
|
97547
97592
|
);
|
|
97548
97593
|
}
|
|
@@ -97614,10 +97659,10 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97614
97659
|
const MAX_PENDING_ACTIVATION_AUDIO = 100;
|
|
97615
97660
|
async function activateVoiceSession(wakeTranscript) {
|
|
97616
97661
|
if (connectionClosed || session) return;
|
|
97617
|
-
|
|
97662
|
+
log35.info("activating voice session", { wakeTranscript });
|
|
97618
97663
|
extractionTriggered = false;
|
|
97619
97664
|
let systemPromptPrefix = memoryManager ? await memoryManager.buildSystemPrompt().catch((err) => {
|
|
97620
|
-
|
|
97665
|
+
log35.warn("memory prompt build failed", { err: String(err) });
|
|
97621
97666
|
return void 0;
|
|
97622
97667
|
}) : void 0;
|
|
97623
97668
|
if (store) {
|
|
@@ -97660,7 +97705,7 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97660
97705
|
}
|
|
97661
97706
|
}
|
|
97662
97707
|
function deactivateVoiceSession() {
|
|
97663
|
-
|
|
97708
|
+
log35.info("deactivating voice session");
|
|
97664
97709
|
pendingWakeAudio = null;
|
|
97665
97710
|
pendingActivationAudio = [];
|
|
97666
97711
|
pendingText = [];
|
|
@@ -97678,12 +97723,12 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97678
97723
|
const embPath = join6(modelsDir, "embedding_model.onnx");
|
|
97679
97724
|
const classifierPath = join6(modelsDir, `${config2.assistantName}.onnx`);
|
|
97680
97725
|
if (!existsSync8(melPath) || !existsSync8(embPath)) {
|
|
97681
|
-
|
|
97726
|
+
log35.warn("ONNX base models not found, wake detection disabled", { modelsDir });
|
|
97682
97727
|
return;
|
|
97683
97728
|
}
|
|
97684
97729
|
if (!existsSync8(classifierPath)) {
|
|
97685
97730
|
const available = getAvailableWakeWords(modelsDir);
|
|
97686
|
-
|
|
97731
|
+
log35.warn("no wake word model for configured name", {
|
|
97687
97732
|
assistantName: config2.assistantName,
|
|
97688
97733
|
available
|
|
97689
97734
|
});
|
|
@@ -97698,12 +97743,12 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97698
97743
|
presence.wake("(detected via onnx)");
|
|
97699
97744
|
},
|
|
97700
97745
|
onDebug: (info) => {
|
|
97701
|
-
|
|
97746
|
+
log35.debug("onnx wake check", info);
|
|
97702
97747
|
}
|
|
97703
97748
|
});
|
|
97704
|
-
|
|
97749
|
+
log35.info("wake word detection active", { assistantName: config2.assistantName });
|
|
97705
97750
|
} catch (err) {
|
|
97706
|
-
|
|
97751
|
+
log35.error("ONNX wake detector failed to start", { err: String(err) });
|
|
97707
97752
|
}
|
|
97708
97753
|
}
|
|
97709
97754
|
const presence = new PresenceManager({
|
|
@@ -97746,7 +97791,7 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97746
97791
|
if (wakeDetector) {
|
|
97747
97792
|
wakeDetector.feedAudio(msg.data);
|
|
97748
97793
|
} else {
|
|
97749
|
-
|
|
97794
|
+
log35.debug("audio received but no wake detector");
|
|
97750
97795
|
}
|
|
97751
97796
|
}
|
|
97752
97797
|
break;
|
|
@@ -97784,17 +97829,17 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97784
97829
|
break;
|
|
97785
97830
|
case "manualStart":
|
|
97786
97831
|
if (presence.state === "passive") {
|
|
97787
|
-
|
|
97832
|
+
log35.info("manual session start");
|
|
97788
97833
|
presence.enterMode("active");
|
|
97789
97834
|
}
|
|
97790
97835
|
break;
|
|
97791
97836
|
}
|
|
97792
97837
|
} catch (err) {
|
|
97793
|
-
|
|
97838
|
+
log35.error("bad message", { err: String(err) });
|
|
97794
97839
|
}
|
|
97795
97840
|
});
|
|
97796
97841
|
ws.on("close", () => {
|
|
97797
|
-
|
|
97842
|
+
log35.info("client disconnected");
|
|
97798
97843
|
connectionClosed = true;
|
|
97799
97844
|
connectedClients.delete(ws);
|
|
97800
97845
|
if (idleTimer) {
|
|
@@ -97823,7 +97868,7 @@ function attachWebSocket(httpServer2, services2) {
|
|
|
97823
97868
|
}
|
|
97824
97869
|
|
|
97825
97870
|
// src/server/server.ts
|
|
97826
|
-
var
|
|
97871
|
+
var log36 = new Logger("server");
|
|
97827
97872
|
var services = await initServices();
|
|
97828
97873
|
var actualPort = services.config.port;
|
|
97829
97874
|
var app = createApp(services, () => actualPort);
|
|
@@ -97837,14 +97882,14 @@ function startServer(port, maxRetries = 10) {
|
|
|
97837
97882
|
wss = attachWebSocket(httpServer, services);
|
|
97838
97883
|
process.stdout.write(`NEURA_PORT=${port}
|
|
97839
97884
|
`);
|
|
97840
|
-
|
|
97885
|
+
log36.info(`Neura core server at http://localhost:${port}`);
|
|
97841
97886
|
});
|
|
97842
97887
|
httpServer.once("error", (err) => {
|
|
97843
97888
|
if (err.code === "EADDRINUSE" && maxRetries > 0) {
|
|
97844
|
-
|
|
97889
|
+
log36.warn(`port ${port} in use, trying ${port + 1}`);
|
|
97845
97890
|
startServer(port + 1, maxRetries - 1);
|
|
97846
97891
|
} else {
|
|
97847
|
-
|
|
97892
|
+
log36.error("server failed to start", { err: err.message });
|
|
97848
97893
|
process.exit(1);
|
|
97849
97894
|
}
|
|
97850
97895
|
});
|
|
@@ -97855,11 +97900,11 @@ var doShutdown = () => void shutdown(services, httpServer, wss);
|
|
|
97855
97900
|
process.on("SIGTERM", doShutdown);
|
|
97856
97901
|
process.on("SIGINT", doShutdown);
|
|
97857
97902
|
process.on("uncaughtException", (err) => {
|
|
97858
|
-
|
|
97903
|
+
log36.error("uncaught exception, shutting down", { err: err.message });
|
|
97859
97904
|
doShutdown();
|
|
97860
97905
|
});
|
|
97861
97906
|
process.on("unhandledRejection", (reason) => {
|
|
97862
|
-
|
|
97907
|
+
log36.error("unhandled rejection, shutting down", { err: String(reason) });
|
|
97863
97908
|
doShutdown();
|
|
97864
97909
|
});
|
|
97865
97910
|
/*! Bundled license information:
|