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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: enhance agent identity management with backend confirmation and action recording logic
nirholas880db377b975
diff --git a/src/agent-identity.js b/src/agent-identity.jsindex 5cc375ec2..015106d34 100644--- a/src/agent-identity.js+++ b/src/agent-identity.js@@ -36,6 +36,7 @@ export class AgentIdentity {this.userId = userId;this._record = null;this._loaded = false;+ this._backendConfirmed = false; // true only when backend returned a valid agentthis.memory = null;// Pre-seed agentId from arg or storage so callers can use it synchronously@@ -154,6 +155,7 @@ export class AgentIdentity {* @param {import('./agent-protocol.js').ActionPayload} action*/recordAction(action) {+ if (!this._backendConfirmed) return; // no session — skip to avoid 401 noisefetch('/api/agent-actions', {method: 'POST',headers: { 'content-type': 'application/json' },@@ -217,9 +219,12 @@ export class AgentIdentity {}// 2. Try backend (authoritative if user is signed in)+ // Only probe a specific agent ID if it was previously confirmed by the backend.+ // Locally-synthesised IDs will never exist in the DB, so use /me to avoid 404 noise.try {const agentId = this._agentId;- const url = agentId ? `/api/agents/${agentId}` : '/api/agents/me';+ const storedConfirmed = this._record?.backendConfirmed;+ const url = (agentId && storedConfirmed) ? `/api/agents/${agentId}` : '/api/agents/me';const resp = await fetch(url, { credentials: 'include' });if (resp.ok) {@@ -230,6 +235,7 @@ export class AgentIdentity {this._record = _normalise(agent);this._agentId = this._record.id;this._loaded = true;+ this._backendConfirmed = true;this._persist();if (!this.memory) {this.memory = new AgentMemory(this._record.id, { backendSync: true, embedFn: _makeEmbedFn(this._record.id) });@@ -343,5 +349,6 @@ function _normalise(apiRecord) {? new Date(apiRecord.created_at).getTime(): apiRecord.createdAt || Date.now(),isRegistered: Boolean(apiRecord.erc8004_agent_id || apiRecord.isRegistered),+ backendConfirmed: true,};}diff --git a/src/animation-manager.js b/src/animation-manager.jsindex dac5a47a5..bbdebd75a 100644--- a/src/animation-manager.js+++ b/src/animation-manager.js@@ -53,9 +53,11 @@ export class AnimationManager {this.actions.clear();this.currentAction = null;this.currentName = null;+ this._boneNames = _collectBoneNames(model);for (const [name, clip] of this.clips) {- const action = this.mixer.clipAction(clip);+ const filtered = _filterClip(clip, this._boneNames);+ const action = this.mixer.clipAction(filtered);action.enabled = true;this.actions.set(name, action);}@@ -124,7 +126,8 @@ export class AnimationManager {this.clips.set(name, clip);if (this.model && this.mixer) {- const action = this.mixer.clipAction(clip);+ const filtered = _filterClip(clip, this._boneNames);+ const action = this.mixer.clipAction(filtered);action.enabled = true;action.setLoop(opts.loop === false ? LoopOnce : LoopRepeat);if (opts.loop === false) action.clampWhenFinished = true;@@ -262,3 +265,22 @@ export class AnimationManager {this._failed.clear();}}++function _collectBoneNames(model) {+ const names = new Set();+ model.traverse((n) => { if (n.name) names.add(n.name); });+ return names;+}++function _filterClip(clip, boneNames) {+ if (!boneNames || boneNames.size === 0) return clip;+ const valid = clip.tracks.filter((t) => {+ const dot = t.name.indexOf('.');+ const bone = dot !== -1 ? t.name.slice(0, dot) : t.name;+ return boneNames.has(bone);+ });+ if (valid.length === clip.tracks.length) return clip;+ const copy = clip.clone();+ copy.tracks = valid;+ return copy;+}