Skip to content

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.

add xspace-agent/packages/core/src/db/repositories/agent-template.ts

overstepping0d5021f56094
diff --git a/xspace-agent/packages/core/src/db/repositories/agent-template.ts b/xspace-agent/packages/core/src/db/repositories/agent-template.ts
new file mode 100644
index 000000000..f1e0519d2
--- /dev/null
+++ b/xspace-agent/packages/core/src/db/repositories/agent-template.ts
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§72]
+
+// =============================================================================
+// Repository — Agent Templates (Reseller Syndication)
+// =============================================================================
+
+import { eq } from 'drizzle-orm'
+import { getDatabase } from '../connection'
+import { agentTemplates } from '../schema'
+
+export type AgentTemplateRow = typeof agentTemplates.$inferSelect
+export type NewAgentTemplate = typeof agentTemplates.$inferInsert
+
+export class AgentTemplateRepository {
+ private get db() {
+ return getDatabase()
+ }
+
+ async create(data: NewAgentTemplate): Promise<AgentTemplateRow> {
+ const [template] = await this.db.insert(agentTemplates).values(data).returning()
+ return template
+ }
+
+ async findById(id: string): Promise<AgentTemplateRow | undefined> {
+ return this.db.query.agentTemplates.findFirst({
+ where: eq(agentTemplates.id, id),
+ })
+ }
+
+ async findByResellerId(resellerId: string): Promise<AgentTemplateRow[]> {
+ return this.db.query.agentTemplates.findMany({
+ where: eq(agentTemplates.resellerId, resellerId),
+ orderBy: (t, { desc }) => [desc(t.createdAt)],
+ })
+ }
+
+ async update(id: string, data: Partial<NewAgentTemplate>): Promise<AgentTemplateRow | undefined> {
+ const [updated] = await this.db
+ .update(agentTemplates)
+ .set({ ...data, updatedAt: new Date() })
+ .where(eq(agentTemplates.id, id))
+ .returning()
+ return updated
+ }
+
+ async delete(id: string): Promise<void> {
+ await this.db.delete(agentTemplates).where(eq(agentTemplates.id, id))
+ }
+}
+
+