Broken AI server Part 1

its 5:30 in the morning
This commit is contained in:
2026-03-19 05:34:25 +02:00
parent 5c706a13b4
commit ba50c0fc08
43 changed files with 6726 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,27 @@
"use strict";
const jibo = require('jibo');
let rlog = null;
try {
rlog = require('./robot-logger');
} catch (e) {
// ignore
}
exports.postInit = function (err) {
this.log.debug('postInit !!');
try {
if (rlog && typeof rlog.raw === 'function') {
rlog.raw('[BE] postInit starting');
}
if (rlog) {
rlog.info('be', 'postInit starting');
}
} catch (e) {
// ignore
}
if (err) {
this.log.error(err);
this.initDoneCallback(err);
@@ -34,6 +53,31 @@ exports.postInit = function (err) {
catch (e) {
this.log.warn('Dynamic skills patch failed (non-fatal):', e.message || e);
}
// Optional: AI Bridge (modular; can run models off-robot for now)
try {
if (rlog && typeof rlog.raw === 'function') {
rlog.raw('[BE] initializing AI bridge');
}
require('./ai-bridge').initAIBridge(this, jibo);
this.log.info('AI bridge initialized');
if (rlog && typeof rlog.raw === 'function') {
rlog.raw('[BE] AI bridge initialized');
}
}
catch (e) {
this.log.warn('AI bridge init failed (non-fatal):', e.message || e);
try {
if (rlog && typeof rlog.raw === 'function') {
rlog.raw('[BE] AI bridge init failed: ' + String(e && (e.stack || e.message || e)));
}
if (rlog) {
rlog.warn('be', 'ai bridge init failed', { err: String(e && (e.stack || e.message || e)) });
}
} catch (e2) {
// ignore
}
}
jibo.face.views.changeView({ removeAll: true, leaveEmpty: true }, () => {
this.selectFirstSkill(this.launchFirstSkill.bind(this));

View File

@@ -684,6 +684,7 @@ const log = logs.listenLog;
const USE_CENTER_ROBOT = false;
const TIMEOUT = 3000;
const ENGAGE_HJ_FAILSAFE_TIMEOUT_MS = 6000;
const LISTENING_FAILSAFE_TIMEOUT_MS = 12000;
const ANIM_CLEAR_TIMEOUT = 'ANIM_CLEAR_TIMEOUT';
class EmbodiedListen extends jibo_state_machine_1.StateMachine {
constructor(_ed) {
@@ -781,6 +782,8 @@ class EmbodiedListen extends jibo_state_machine_1.StateMachine {
this._idle.onEntry = () => {
log.debug('Entering Idle');
this._jibo.performance.log('EmbodiedListenReturnedToIdleSkill');
// Safety: ensure we don't stay in a listening LED state indefinitely.
Utils_1.Utils.setLED(this._jibo, Assets_1.Led.OFF);
this.eventsOut.finished.emit();
this._jibo.timer.removeListener('update', updateBind);
if (this._pendingActiveMode) {
@@ -966,19 +969,59 @@ class EmbodiedListen extends jibo_state_machine_1.StateMachine {
this._listening.addTypedEventTransition(this.eventsIn.cloudFinished, this._offExpression);
this._listening.addTypedEventTransition(this.eventsIn.hjHeard, this._hjExpression);
let incrementalHandler = this._handleIncremental.bind(this);
let listeningFailsafe = null;
this._listening.onEntry = () => {
log.debug('Entering Listening');
this.eventsIn.sos.on(incrementalHandler);
if (listeningFailsafe) {
clearTimeout(listeningFailsafe);
}
listeningFailsafe = setTimeout(() => {
try {
if (this.current === this._listening) {
Utils_1.Utils.setLED(this._jibo, Assets_1.Led.OFF);
this._listening.transitionTo(this._idle);
}
}
catch (e) {
// ignore
}
}, LISTENING_FAILSAFE_TIMEOUT_MS);
};
this._listening.onExit = () => {
this.eventsIn.sos.removeListener(incrementalHandler);
if (listeningFailsafe) {
clearTimeout(listeningFailsafe);
listeningFailsafe = null;
}
};
this._thinking.addTypedEventTransition(this.eventsIn.cloudFinished, this._waitForAnimFinish);
this._thinking.addTypedEventTransition(this.eventsIn.hjHeard, this._hjExpression);
let thinkingFailsafe = null;
this._thinking.onEntry = () => __awaiter(this, void 0, void 0, function* () {
log.debug('Entering Thinking (+ Off Expression)');
Utils_1.Utils.setLED(jibo, Assets_1.Led.OFF);
if (thinkingFailsafe) {
clearTimeout(thinkingFailsafe);
}
thinkingFailsafe = setTimeout(() => {
try {
if (this.current === this._thinking) {
Utils_1.Utils.setLED(this._jibo, Assets_1.Led.OFF);
this._thinking.transitionTo(this._idle);
}
}
catch (e) {
// ignore
}
}, LISTENING_FAILSAFE_TIMEOUT_MS);
});
this._thinking.onExit = () => {
if (thinkingFailsafe) {
clearTimeout(thinkingFailsafe);
thinkingFailsafe = null;
}
};
});
}
dispose() {