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/packages/core/src/queue/processors/usage-processor.ts
overstepping9e2b292d7125
diff --git a/xspace-agent/packages/core/src/queue/processors/usage-processor.ts b/xspace-agent/packages/core/src/queue/processors/usage-processor.tsnew file mode 100644index 000000000..c9f4507f9--- /dev/null+++ b/xspace-agent/packages/core/src/queue/processors/usage-processor.ts@@ -0,0 +1,52 @@+// SPDX-License-Identifier: Apache-2.0+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§72]++// =============================================================================+// Queue Processor — Usage Aggregation+// =============================================================================++import type { Job } from 'bullmq'+import type { UsageAggregationJob } from '../types'++/**+ * Aggregates raw usage records for a given org and time period,+ * then stores the aggregate for billing / Stripe reporting.+ */+export async function usageProcessor(job: Job<UsageAggregationJob>): Promise<{ recordsProcessed: number }> {+ const { orgId, periodStart, periodEnd, metrics } = job.data++ // Import lazily to avoid circular dependency at module load time+ const { UsageRepository } = await import('../../db')++ const repo = new UsageRepository()+ const start = new Date(periodStart)+ const end = new Date(periodEnd)++ const records = await repo.getByOrgAndPeriod(orgId, start, end)+ if (records.length === 0) {+ return { recordsProcessed: 0 }+ }++ // Build aggregates per metric+ const aggregates: Record<string, number> = {}+ for (const record of records) {+ const metric = record.metric+ if (metrics.length > 0 && !metrics.includes(metric)) continue+ aggregates[metric] = (aggregates[metric] ?? 0) + Number(record.quantity)+ }++ // Persist the aggregate+ for (const [metric, quantity] of Object.entries(aggregates)) {+ await repo.createAggregate({+ orgId,+ metric,+ quantity,+ periodStart: start,+ periodEnd: end,+ })+ }++ return { recordsProcessed: records.length }+}++