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/src/server/providers/claude.ts
oversteppingd5411c50390f
diff --git a/xspace-agent/src/server/providers/claude.ts b/xspace-agent/src/server/providers/claude.tsnew file mode 100644index 000000000..4fb95833e--- /dev/null+++ b/xspace-agent/src/server/providers/claude.ts@@ -0,0 +1,58 @@+// SPDX-License-Identifier: Apache-2.0+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§83]++import Anthropic from "@anthropic-ai/sdk"+import type { Provider } from "../types"++const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY })+const MODEL = process.env.CLAUDE_MODEL || "claude-sonnet-4-20250514"+const MAX_HISTORY = 20++const history: Record<number, Array<{ role: "user" | "assistant"; content: string }>> = {+ 0: [],+ 1: [],+}++function addToHistory(agentId: number, role: "user" | "assistant", content: string): void {+ if (!history[agentId]) history[agentId] = []+ history[agentId].push({ role, content })+ if (history[agentId].length > MAX_HISTORY) {+ history[agentId] = history[agentId].slice(-MAX_HISTORY)+ }+}++async function* streamResponse(+ agentId: number,+ userText: string,+ systemPrompt: string,+): AsyncGenerator<string, void, unknown> {+ addToHistory(agentId, "user", userText)++ const stream = await client.messages.stream({+ model: MODEL,+ max_tokens: 300,+ system: systemPrompt,+ messages: history[agentId],+ })++ let fullResponse = ""++ for await (const event of stream) {+ if (event.type === "content_block_delta" && event.delta?.type === "text_delta") {+ const text = event.delta.text+ fullResponse += text+ yield text+ }+ }++ addToHistory(agentId, "assistant", fullResponse)+}++function clearHistory(agentId: number): void {+ history[agentId] = []+}++const provider: Provider = { type: "socket", streamResponse, clearHistory }+module.exports = provider++