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/xspace-agent/src/providers/llm/claude.ts
overstepping55aad2accb4b
diff --git a/xspace-agent/xspace-agent/xspace-agent/src/providers/llm/claude.ts b/xspace-agent/xspace-agent/xspace-agent/src/providers/llm/claude.tsnew file mode 100644index 000000000..0de0b181a--- /dev/null+++ b/xspace-agent/xspace-agent/xspace-agent/src/providers/llm/claude.ts@@ -0,0 +1,78 @@+// SPDX-License-Identifier: Apache-2.0+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§32]++import Anthropic from "@anthropic-ai/sdk";+import { config } from "../../config.js";+import { createChildLogger } from "../../utils/logger.js";+import type { LLMProvider } from "../../types.js";++const log = createChildLogger("llm:claude");++interface MessageParam {+ role: "user" | "assistant";+ content: string;+}++export class ClaudeLLM implements LLMProvider {+ readonly type = "socket" as const;+ private client: Anthropic;+ private model: string;+ private history: Record<number, MessageParam[]> = {};++ constructor() {+ if (!config.anthropicApiKey)+ throw new Error("ANTHROPIC_API_KEY is required for Claude provider");+ this.client = new Anthropic({ apiKey: config.anthropicApiKey });+ this.model = config.claudeModel;+ log.info("Initialized with model: %s", this.model);+ }++ private addToHistory(+ agentId: number,+ role: "user" | "assistant",+ content: string,+ ): void {+ if (!this.history[agentId]) this.history[agentId] = [];+ this.history[agentId]!.push({ role, content });+ if (this.history[agentId]!.length > 20) {+ this.history[agentId] = this.history[agentId]!.slice(-20);+ }+ }++ async *streamResponse(+ agentId: number,+ userText: string,+ systemPrompt: string,+ ): AsyncGenerator<string, void, unknown> {+ this.addToHistory(agentId, "user", userText);++ const stream = await this.client.messages.stream({+ model: this.model,+ max_tokens: config.maxTokens,+ system: systemPrompt,+ messages: this.history[agentId] ?? [],+ });++ let fullResponse = "";++ for await (const event of stream) {+ if (+ event.type === "content_block_delta" &&+ event.delta &&+ "text" in event.delta+ ) {+ const text = event.delta.text;+ fullResponse += text;+ yield text;+ }+ }++ this.addToHistory(agentId, "assistant", fullResponse);+ }++ clearHistory(agentId: number): void {+ this.history[agentId] = [];+ }+}++