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/xspace-agent/src/server/turn-manager.ts
overstepping3efa42274207
diff --git a/xspace-agent/xspace-agent/src/server/turn-manager.ts b/xspace-agent/xspace-agent/src/server/turn-manager.tsnew file mode 100644index 000000000..b58eb56b1--- /dev/null+++ b/xspace-agent/xspace-agent/src/server/turn-manager.ts@@ -0,0 +1,55 @@+// SPDX-License-Identifier: Apache-2.0+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§84]++import type { Namespace } from "socket.io"+import type { SpaceState } from "./types"++export class TurnManager {+ constructor(+ private state: SpaceState,+ private namespace: Namespace,+ ) {}++ broadcastState(): void {+ this.namespace.emit("stateUpdate", {+ agents: this.state.agents,+ currentTurn: this.state.currentTurn,+ turnQueue: this.state.turnQueue,+ })+ }++ requestTurn(agentId: number): boolean {+ if (this.state.currentTurn === null && !this.state.isProcessing) {+ this.state.currentTurn = agentId+ this.state.isProcessing = true+ this.namespace.emit("turnGranted", { agentId })+ this.broadcastState()+ return true+ }+ if (!this.state.turnQueue.includes(agentId) && this.state.currentTurn !== agentId) {+ this.state.turnQueue.push(agentId)+ this.broadcastState()+ }+ return false+ }++ releaseTurn(agentId: number): void {+ if (this.state.currentTurn === agentId) {+ this.state.currentTurn = null+ this.state.isProcessing = false+ if (this.state.turnQueue.length > 0) {+ const nextAgent = this.state.turnQueue.shift()!+ setTimeout(() => {+ this.state.currentTurn = nextAgent+ this.state.isProcessing = true+ this.namespace.emit("turnGranted", { agentId: nextAgent })+ this.broadcastState()+ }, 500)+ } else {+ this.broadcastState()+ }+ }+ }+}++