Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat: add re-entrancy guard for agent loading and initialize bone names in animation manager

nirholas86ede8102f79
diff --git a/.claude/state/build.last b/.claude/state/build.last
index 6c7ddb3db..61cfa35df 100644
--- a/.claude/state/build.last
+++ b/.claude/state/build.last
@@ -1 +1 @@
-2026-05-04T03:47:36Z
+2026-05-04T04:46:12Z
diff --git a/src/agent-identity.js b/src/agent-identity.js
index 015106d34..76f9ebff4 100644
--- a/src/agent-identity.js
+++ b/src/agent-identity.js
@@ -37,6 +37,7 @@ export class AgentIdentity {
this._record = null;
this._loaded = false;
this._backendConfirmed = false; // true only when backend returned a valid agent
+ this._loadPromise = null; // re-entrancy guard
this.memory = null;
// Pre-seed agentId from arg or storage so callers can use it synchronously
@@ -209,6 +210,14 @@ export class AgentIdentity {
// ── Internal ──────────────────────────────────────────────────────────────
async _loadAsync() {
+ if (this._loadPromise) return this._loadPromise;
+ this._loadPromise = this.__doLoad();
+ try { await this._loadPromise; } finally { this._loadPromise = null; }
+ }
+
+ async __doLoad() {
+ this._backendConfirmed = false;
+
// 1. Try localStorage first (instant) — backendSync disabled until confirmed
const local = this._readLocal();
if (local) {
diff --git a/src/animation-manager.js b/src/animation-manager.js
index bbdebd75a..eb30610c2 100644
--- a/src/animation-manager.js
+++ b/src/animation-manager.js
@@ -37,6 +37,8 @@ export class AnimationManager {
this._animationDefs = [];
/** @type {Set<string>} Clip names that failed to load — buttons grayed out in UI. */
this._failed = new Set();
+ /** @type {Set<string>|null} Bone/node names of the currently attached model. */
+ this._boneNames = null;
}
// ── Model binding ──────────────────────────────────────────────────────────
@@ -71,6 +73,7 @@ export class AnimationManager {
this.mixer = null;
}
this.model = null;
+ this._boneNames = null;
this.actions.clear();
this.currentAction = null;
this.currentName = null;