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/db/repositories/impersonation.ts
overstepping0e134ad173b1
diff --git a/xspace-agent/packages/core/src/db/repositories/impersonation.ts b/xspace-agent/packages/core/src/db/repositories/impersonation.tsnew file mode 100644index 000000000..35ed43fd0--- /dev/null+++ b/xspace-agent/packages/core/src/db/repositories/impersonation.ts@@ -0,0 +1,70 @@+// SPDX-License-Identifier: Apache-2.0+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§32]++// =============================================================================+// Repository — Impersonation Sessions+// =============================================================================++import { eq, and, gt } from 'drizzle-orm'+import { getDatabase } from '../connection'+import { impersonationSessions } from '../schema'++export type ImpersonationSessionRow = typeof impersonationSessions.$inferSelect+export type NewImpersonationSession = typeof impersonationSessions.$inferInsert++export class ImpersonationSessionRepository {+ private get db() {+ return getDatabase()+ }++ async create(data: NewImpersonationSession): Promise<ImpersonationSessionRow> {+ const [session] = await this.db.insert(impersonationSessions).values(data).returning()+ return session+ }++ async findById(id: string): Promise<ImpersonationSessionRow | undefined> {+ return this.db.query.impersonationSessions.findFirst({+ where: eq(impersonationSessions.id, id),+ })+ }++ async findActive(adminUserId: string, targetOrgId: string): Promise<ImpersonationSessionRow | undefined> {+ const results = await this.db+ .select()+ .from(impersonationSessions)+ .where(+ and(+ eq(impersonationSessions.adminUserId, adminUserId),+ eq(impersonationSessions.targetOrgId, targetOrgId),+ gt(impersonationSessions.expiresAt, new Date()),+ ),+ )+ .limit(1)+ return results[0]+ }++ async findByResellerId(resellerId: string): Promise<ImpersonationSessionRow[]> {+ return this.db.query.impersonationSessions.findMany({+ where: eq(impersonationSessions.resellerId, resellerId),+ orderBy: (s, { desc }) => [desc(s.createdAt)],+ })+ }++ async findActiveByAdmin(adminUserId: string): Promise<ImpersonationSessionRow[]> {+ return this.db+ .select()+ .from(impersonationSessions)+ .where(+ and(+ eq(impersonationSessions.adminUserId, adminUserId),+ gt(impersonationSessions.expiresAt, new Date()),+ ),+ )+ }++ async delete(id: string): Promise<void> {+ await this.db.delete(impersonationSessions).where(eq(impersonationSessions.id, id))+ }+}++