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/packages/core/src/events/publisher.ts
overstepping2eb133ab8167
diff --git a/xspace-agent/xspace-agent/packages/core/src/events/publisher.ts b/xspace-agent/xspace-agent/packages/core/src/events/publisher.tsnew file mode 100644index 000000000..bfa02d4c9--- /dev/null+++ b/xspace-agent/xspace-agent/packages/core/src/events/publisher.ts@@ -0,0 +1,51 @@+// SPDX-License-Identifier: Apache-2.0+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§32]++// =============================================================================+// Event Streaming — Publisher (Redis Pub/Sub)+// =============================================================================++import { randomUUID } from 'crypto'+import type Redis from 'ioredis'+import type { StreamEvent, EventEnvelope } from './types'++/**+ * Publishes stream events to Redis Pub/Sub channels with tenant isolation.+ *+ * Channel naming:+ * - `xsevents:{orgId}` — all events for an org+ * - `xsevents:{orgId}:session:{sessionId}` — session-specific events+ */+export class EventPublisher {+ constructor(private readonly redis: Redis) {}++ /**+ * Publish a stream event for a given org.+ * Publishes to both the org-level and (when applicable) session-level channels.+ */+ async publish(orgId: string, event: StreamEvent): Promise<EventEnvelope> {+ const envelope: EventEnvelope = {+ id: `evt_${randomUUID().replace(/-/g, '').slice(0, 16)}`,+ timestamp: new Date().toISOString(),+ orgId,+ event,+ }++ const payload = JSON.stringify(envelope)+ const orgChannel = `xsevents:${orgId}`++ // Publish to org channel+ await this.redis.publish(orgChannel, payload)++ // Also publish to session-specific channel if the event data contains a sessionId+ const data = event.data as Record<string, unknown>+ if (typeof data.sessionId === 'string') {+ const sessionChannel = `xsevents:${orgId}:session:${data.sessionId}`+ await this.redis.publish(sessionChannel, payload)+ }++ return envelope+ }+}++