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
add xspace-agent/agent-voice-chat/lib/turn-manager.js
overstepping5960e48adefc
diff --git a/xspace-agent/agent-voice-chat/lib/turn-manager.js b/xspace-agent/agent-voice-chat/lib/turn-manager.jsnew file mode 100644index 000000000..efe704a10--- /dev/null+++ b/xspace-agent/agent-voice-chat/lib/turn-manager.js@@ -0,0 +1,64 @@+// SPDX-License-Identifier: Apache-2.0+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent)++class TurnManager {+ constructor({ onBroadcast, onTurnGranted } = {}) {+ this.currentTurn = null+ this.turnQueue = []+ this.isProcessing = false+ this.onBroadcast = onBroadcast || (() => {})+ this.onTurnGranted = onTurnGranted || (() => {})+ }++ requestTurn(agentId) {+ if (this.currentTurn === null && !this.isProcessing) {+ this.currentTurn = agentId+ this.isProcessing = true+ this.onTurnGranted(agentId)+ this.onBroadcast()+ return true+ }+ if (!this.turnQueue.includes(agentId) && this.currentTurn !== agentId) {+ this.turnQueue.push(agentId)+ this.onBroadcast()+ }+ return false+ }++ releaseTurn(agentId) {+ if (this.currentTurn !== agentId) return++ this.currentTurn = null+ this.isProcessing = false++ if (this.turnQueue.length > 0) {+ const nextAgent = this.turnQueue.shift()+ setTimeout(() => {+ this.currentTurn = nextAgent+ this.isProcessing = true+ this.onTurnGranted(nextAgent)+ this.onBroadcast()+ }, 500)+ } else {+ this.onBroadcast()+ }+ }++ getState() {+ return {+ currentTurn: this.currentTurn,+ turnQueue: [...this.turnQueue],+ isProcessing: this.isProcessing+ }+ }++ reset() {+ this.currentTurn = null+ this.turnQueue = []+ this.isProcessing = false+ }+}++module.exports = { TurnManager }++