@agentforge-io/nest 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +486 -0
- package/dist/agent-forge.module.d.ts +21 -0
- package/dist/agent-forge.module.js +144 -0
- package/dist/agent-forge.module.js.map +1 -0
- package/dist/auth/current-user.decorator.d.ts +8 -0
- package/dist/auth/current-user.decorator.js +9 -0
- package/dist/auth/current-user.decorator.js.map +1 -0
- package/dist/auth/public.decorator.d.ts +2 -0
- package/dist/auth/public.decorator.js +8 -0
- package/dist/auth/public.decorator.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +9 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/agent-runner.service.d.ts +1 -0
- package/dist/core/agent-runner.service.js +6 -0
- package/dist/core/agent-runner.service.js.map +1 -0
- package/dist/core/orchestrator.service.d.ts +2 -0
- package/dist/core/orchestrator.service.js +7 -0
- package/dist/core/orchestrator.service.js.map +1 -0
- package/dist/core/tool-registry.service.d.ts +1 -0
- package/dist/core/tool-registry.service.js +6 -0
- package/dist/core/tool-registry.service.js.map +1 -0
- package/dist/database/entities/auth-identity.entity.d.ts +1 -0
- package/dist/database/entities/auth-identity.entity.js +6 -0
- package/dist/database/entities/auth-identity.entity.js.map +1 -0
- package/dist/database/entities/conversation.entity.d.ts +1 -0
- package/dist/database/entities/conversation.entity.js +6 -0
- package/dist/database/entities/conversation.entity.js.map +1 -0
- package/dist/database/entities/email-token.entity.d.ts +1 -0
- package/dist/database/entities/email-token.entity.js +6 -0
- package/dist/database/entities/email-token.entity.js.map +1 -0
- package/dist/database/entities/index.d.ts +7 -0
- package/dist/database/entities/index.js +16 -0
- package/dist/database/entities/index.js.map +1 -0
- package/dist/database/entities/message.entity.d.ts +1 -0
- package/dist/database/entities/message.entity.js +6 -0
- package/dist/database/entities/message.entity.js.map +1 -0
- package/dist/database/entities/refresh-token.entity.d.ts +1 -0
- package/dist/database/entities/refresh-token.entity.js +6 -0
- package/dist/database/entities/refresh-token.entity.js.map +1 -0
- package/dist/database/entities/subscription.entity.d.ts +1 -0
- package/dist/database/entities/subscription.entity.js +6 -0
- package/dist/database/entities/subscription.entity.js.map +1 -0
- package/dist/database/entities/usage-record.entity.d.ts +1 -0
- package/dist/database/entities/usage-record.entity.js +6 -0
- package/dist/database/entities/usage-record.entity.js.map +1 -0
- package/dist/database/entities/user.entity.d.ts +1 -0
- package/dist/database/entities/user.entity.js +6 -0
- package/dist/database/entities/user.entity.js.map +1 -0
- package/dist/decorators/agent-tool.decorator.d.ts +21 -0
- package/dist/decorators/agent-tool.decorator.js +12 -0
- package/dist/decorators/agent-tool.decorator.js.map +1 -0
- package/dist/decorators/rate-limit.decorator.d.ts +9 -0
- package/dist/decorators/rate-limit.decorator.js +11 -0
- package/dist/decorators/rate-limit.decorator.js.map +1 -0
- package/dist/decorators/require-plan.decorator.d.ts +2 -0
- package/dist/decorators/require-plan.decorator.js +8 -0
- package/dist/decorators/require-plan.decorator.js.map +1 -0
- package/dist/filters/agentforge-exception.filter.d.ts +5 -0
- package/dist/filters/agentforge-exception.filter.js +40 -0
- package/dist/filters/agentforge-exception.filter.js.map +1 -0
- package/dist/guards/rate-limit.guard.d.ts +10 -0
- package/dist/guards/rate-limit.guard.js +73 -0
- package/dist/guards/rate-limit.guard.js.map +1 -0
- package/dist/guards/usage-limit.guard.d.ts +11 -0
- package/dist/guards/usage-limit.guard.js +57 -0
- package/dist/guards/usage-limit.guard.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors/usage-tracking.interceptor.d.ts +6 -0
- package/dist/interceptors/usage-tracking.interceptor.js +30 -0
- package/dist/interceptors/usage-tracking.interceptor.js.map +1 -0
- package/dist/modules/admin/admin-plans.controller.d.ts +11 -0
- package/dist/modules/admin/admin-plans.controller.js +97 -0
- package/dist/modules/admin/admin-plans.controller.js.map +1 -0
- package/dist/modules/admin/admin-tenant-agents.controller.d.ts +61 -0
- package/dist/modules/admin/admin-tenant-agents.controller.js +424 -0
- package/dist/modules/admin/admin-tenant-agents.controller.js.map +1 -0
- package/dist/modules/admin/admin-tenant-billing.controller.d.ts +51 -0
- package/dist/modules/admin/admin-tenant-billing.controller.js +119 -0
- package/dist/modules/admin/admin-tenant-billing.controller.js.map +1 -0
- package/dist/modules/admin/admin-tenants.controller.d.ts +43 -0
- package/dist/modules/admin/admin-tenants.controller.js +178 -0
- package/dist/modules/admin/admin-tenants.controller.js.map +1 -0
- package/dist/modules/admin/admin-users.controller.d.ts +41 -0
- package/dist/modules/admin/admin-users.controller.js +121 -0
- package/dist/modules/admin/admin-users.controller.js.map +1 -0
- package/dist/modules/admin/admin.module.d.ts +2 -0
- package/dist/modules/admin/admin.module.js +26 -0
- package/dist/modules/admin/admin.module.js.map +1 -0
- package/dist/modules/admin/platform-admin.guard.d.ts +7 -0
- package/dist/modules/admin/platform-admin.guard.js +52 -0
- package/dist/modules/admin/platform-admin.guard.js.map +1 -0
- package/dist/modules/agent/agent.controller.d.ts +34 -0
- package/dist/modules/agent/agent.controller.js +178 -0
- package/dist/modules/agent/agent.controller.js.map +1 -0
- package/dist/modules/agent/agent.module.d.ts +2 -0
- package/dist/modules/agent/agent.module.js +23 -0
- package/dist/modules/agent/agent.module.js.map +1 -0
- package/dist/modules/agent/agent.service.d.ts +2 -0
- package/dist/modules/agent/agent.service.js +7 -0
- package/dist/modules/agent/agent.service.js.map +1 -0
- package/dist/modules/agent/dto/create-conversation.dto.d.ts +8 -0
- package/dist/modules/agent/dto/create-conversation.dto.js +48 -0
- package/dist/modules/agent/dto/create-conversation.dto.js.map +1 -0
- package/dist/modules/agent/dto/send-message.dto.d.ts +12 -0
- package/dist/modules/agent/dto/send-message.dto.js +42 -0
- package/dist/modules/agent/dto/send-message.dto.js.map +1 -0
- package/dist/modules/agent/in-memory-prepared-stream.store.d.ts +1 -0
- package/dist/modules/agent/in-memory-prepared-stream.store.js +6 -0
- package/dist/modules/agent/in-memory-prepared-stream.store.js.map +1 -0
- package/dist/modules/agent/prepared-stream.service.d.ts +1 -0
- package/dist/modules/agent/prepared-stream.service.js +7 -0
- package/dist/modules/agent/prepared-stream.service.js.map +1 -0
- package/dist/modules/agent/prepared-stream.types.d.ts +1 -0
- package/dist/modules/agent/prepared-stream.types.js +6 -0
- package/dist/modules/agent/prepared-stream.types.js.map +1 -0
- package/dist/modules/agent/redis-prepared-stream.store.d.ts +9 -0
- package/dist/modules/agent/redis-prepared-stream.store.js +48 -0
- package/dist/modules/agent/redis-prepared-stream.store.js.map +1 -0
- package/dist/modules/auth/auth.controller.d.ts +63 -0
- package/dist/modules/auth/auth.controller.js +255 -0
- package/dist/modules/auth/auth.controller.js.map +1 -0
- package/dist/modules/auth/auth.module.d.ts +4 -0
- package/dist/modules/auth/auth.module.js +71 -0
- package/dist/modules/auth/auth.module.js.map +1 -0
- package/dist/modules/auth/auth.service.d.ts +2 -0
- package/dist/modules/auth/auth.service.js +7 -0
- package/dist/modules/auth/auth.service.js.map +1 -0
- package/dist/modules/auth/decorators/current-user.decorator.d.ts +8 -0
- package/dist/modules/auth/decorators/current-user.decorator.js +12 -0
- package/dist/modules/auth/decorators/current-user.decorator.js.map +1 -0
- package/dist/modules/auth/decorators/public.decorator.d.ts +2 -0
- package/dist/modules/auth/decorators/public.decorator.js +8 -0
- package/dist/modules/auth/decorators/public.decorator.js.map +1 -0
- package/dist/modules/auth/dto/login.dto.d.ts +4 -0
- package/dist/modules/auth/dto/login.dto.js +29 -0
- package/dist/modules/auth/dto/login.dto.js.map +1 -0
- package/dist/modules/auth/dto/register.dto.d.ts +5 -0
- package/dist/modules/auth/dto/register.dto.js +36 -0
- package/dist/modules/auth/dto/register.dto.js.map +1 -0
- package/dist/modules/auth/guards/jwt-auth.guard.d.ts +9 -0
- package/dist/modules/auth/guards/jwt-auth.guard.js +37 -0
- package/dist/modules/auth/guards/jwt-auth.guard.js.map +1 -0
- package/dist/modules/auth/guards/local-auth.guard.d.ts +4 -0
- package/dist/modules/auth/guards/local-auth.guard.js +18 -0
- package/dist/modules/auth/guards/local-auth.guard.js.map +1 -0
- package/dist/modules/auth/guards/oauth-configured.guard.d.ts +11 -0
- package/dist/modules/auth/guards/oauth-configured.guard.js +51 -0
- package/dist/modules/auth/guards/oauth-configured.guard.js.map +1 -0
- package/dist/modules/auth/oauth.controller.d.ts +20 -0
- package/dist/modules/auth/oauth.controller.js +208 -0
- package/dist/modules/auth/oauth.controller.js.map +1 -0
- package/dist/modules/auth/refresh-token.service.d.ts +2 -0
- package/dist/modules/auth/refresh-token.service.js +7 -0
- package/dist/modules/auth/refresh-token.service.js.map +1 -0
- package/dist/modules/auth/strategies/github.strategy.d.ts +12 -0
- package/dist/modules/auth/strategies/github.strategy.js +57 -0
- package/dist/modules/auth/strategies/github.strategy.js.map +1 -0
- package/dist/modules/auth/strategies/google.strategy.d.ts +19 -0
- package/dist/modules/auth/strategies/google.strategy.js +56 -0
- package/dist/modules/auth/strategies/google.strategy.js.map +1 -0
- package/dist/modules/auth/strategies/jwt.strategy.d.ts +18 -0
- package/dist/modules/auth/strategies/jwt.strategy.js +49 -0
- package/dist/modules/auth/strategies/jwt.strategy.js.map +1 -0
- package/dist/modules/auth/strategies/local.strategy.d.ts +11 -0
- package/dist/modules/auth/strategies/local.strategy.js +31 -0
- package/dist/modules/auth/strategies/local.strategy.js.map +1 -0
- package/dist/modules/billing/adapters/billing-adapter.interface.d.ts +1 -0
- package/dist/modules/billing/adapters/billing-adapter.interface.js +6 -0
- package/dist/modules/billing/adapters/billing-adapter.interface.js.map +1 -0
- package/dist/modules/billing/adapters/stripe/stripe.adapter.d.ts +19 -0
- package/dist/modules/billing/adapters/stripe/stripe.adapter.js +118 -0
- package/dist/modules/billing/adapters/stripe/stripe.adapter.js.map +1 -0
- package/dist/modules/billing/billing.controller.d.ts +54 -0
- package/dist/modules/billing/billing.controller.js +180 -0
- package/dist/modules/billing/billing.controller.js.map +1 -0
- package/dist/modules/billing/billing.module.d.ts +2 -0
- package/dist/modules/billing/billing.module.js +57 -0
- package/dist/modules/billing/billing.module.js.map +1 -0
- package/dist/modules/billing/billing.service.d.ts +2 -0
- package/dist/modules/billing/billing.service.js +7 -0
- package/dist/modules/billing/billing.service.js.map +1 -0
- package/dist/modules/billing/usage.service.d.ts +2 -0
- package/dist/modules/billing/usage.service.js +6 -0
- package/dist/modules/billing/usage.service.js.map +1 -0
- package/dist/modules/connectors/connectors.controller.d.ts +16 -0
- package/dist/modules/connectors/connectors.controller.js +142 -0
- package/dist/modules/connectors/connectors.controller.js.map +1 -0
- package/dist/modules/connectors/connectors.module.d.ts +2 -0
- package/dist/modules/connectors/connectors.module.js +20 -0
- package/dist/modules/connectors/connectors.module.js.map +1 -0
- package/dist/modules/conversation/conversation.module.d.ts +2 -0
- package/dist/modules/conversation/conversation.module.js +17 -0
- package/dist/modules/conversation/conversation.module.js.map +1 -0
- package/dist/modules/conversation/conversation.service.d.ts +1 -0
- package/dist/modules/conversation/conversation.service.js +7 -0
- package/dist/modules/conversation/conversation.service.js.map +1 -0
- package/dist/modules/email/adapters/email-adapter.interface.d.ts +1 -0
- package/dist/modules/email/adapters/email-adapter.interface.js +6 -0
- package/dist/modules/email/adapters/email-adapter.interface.js.map +1 -0
- package/dist/modules/email/adapters/noop.adapter.d.ts +1 -0
- package/dist/modules/email/adapters/noop.adapter.js +6 -0
- package/dist/modules/email/adapters/noop.adapter.js.map +1 -0
- package/dist/modules/email/adapters/resend.adapter.d.ts +1 -0
- package/dist/modules/email/adapters/resend.adapter.js +6 -0
- package/dist/modules/email/adapters/resend.adapter.js.map +1 -0
- package/dist/modules/email/email.module.d.ts +2 -0
- package/dist/modules/email/email.module.js +17 -0
- package/dist/modules/email/email.module.js.map +1 -0
- package/dist/modules/email/email.service.d.ts +1 -0
- package/dist/modules/email/email.service.js +6 -0
- package/dist/modules/email/email.service.js.map +1 -0
- package/dist/modules/email/templates/transactional.template.d.ts +18 -0
- package/dist/modules/email/templates/transactional.template.js +43 -0
- package/dist/modules/email/templates/transactional.template.js.map +1 -0
- package/dist/modules/mcp/mcp-admin.controller.d.ts +35 -0
- package/dist/modules/mcp/mcp-admin.controller.js +111 -0
- package/dist/modules/mcp/mcp-admin.controller.js.map +1 -0
- package/dist/modules/mcp/mcp.module.d.ts +8 -0
- package/dist/modules/mcp/mcp.module.js +38 -0
- package/dist/modules/mcp/mcp.module.js.map +1 -0
- package/dist/modules/public-chat/public-chat.controller.d.ts +54 -0
- package/dist/modules/public-chat/public-chat.controller.js +279 -0
- package/dist/modules/public-chat/public-chat.controller.js.map +1 -0
- package/dist/modules/public-chat/public-chat.module.d.ts +2 -0
- package/dist/modules/public-chat/public-chat.module.js +20 -0
- package/dist/modules/public-chat/public-chat.module.js.map +1 -0
- package/dist/modules/queue/jobs.controller.d.ts +23 -0
- package/dist/modules/queue/jobs.controller.js +98 -0
- package/dist/modules/queue/jobs.controller.js.map +1 -0
- package/dist/modules/queue/processors/agent.processor.d.ts +12 -0
- package/dist/modules/queue/processors/agent.processor.js +65 -0
- package/dist/modules/queue/processors/agent.processor.js.map +1 -0
- package/dist/modules/queue/queue.module.d.ts +5 -0
- package/dist/modules/queue/queue.module.js +55 -0
- package/dist/modules/queue/queue.module.js.map +1 -0
- package/dist/modules/queue/queue.service.d.ts +15 -0
- package/dist/modules/queue/queue.service.js +86 -0
- package/dist/modules/queue/queue.service.js.map +1 -0
- package/dist/providers/repositories.providers.d.ts +3 -0
- package/dist/providers/repositories.providers.js +35 -0
- package/dist/providers/repositories.providers.js.map +1 -0
- package/dist/providers/services.providers.d.ts +4 -0
- package/dist/providers/services.providers.js +142 -0
- package/dist/providers/services.providers.js.map +1 -0
- package/dist/redis/redis.provider.d.ts +3 -0
- package/dist/redis/redis.provider.js +48 -0
- package/dist/redis/redis.provider.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
# AgentForge
|
|
2
|
+
|
|
3
|
+
**Framework NestJS para construir micro-SaaS de Agents as a Service usando Claude Agent SDK.**
|
|
4
|
+
|
|
5
|
+
AgentForge abstrae toda la complejidad de crear un sistema multi-agente con monetización, persistencia de conversaciones, procesamiento en background y billing con Stripe — para que te puedas enfocar solo en definir tus agentes y herramientas.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Características
|
|
10
|
+
|
|
11
|
+
- **Multi-agente con orquestación automática** — Un agente orquestador puede delegar tareas a subagentes especializados. Claude decide cuándo y cómo delegar.
|
|
12
|
+
- **Persistencia de conversaciones en Postgres** — Historial completo con TypeORM, incluyendo tool calls y uso de tokens.
|
|
13
|
+
- **Queue de tareas async con BullMQ + Redis** — Procesa conversaciones largas en background, el cliente hace polling o recibe el resultado cuando está listo.
|
|
14
|
+
- **Billing con Stripe incluido** — Planes freemium, suscripciones mensuales/anuales, pay-per-use y créditos. Un adaptador para cambiar de proveedor de pagos.
|
|
15
|
+
- **Tracking de uso por usuario** — Límites de requests y tokens por plan, aplicados automáticamente.
|
|
16
|
+
- **Framework HTTP: NestJS** — DI, decoradores, guards, SSE streaming, Swagger.
|
|
17
|
+
- **TypeScript nativo** — Tipado completo, autocompletado total.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Instalación
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install agentforge @nestjs/common @nestjs/core @nestjs/platform-express reflect-metadata rxjs
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Requerimientos:
|
|
28
|
+
- **Node.js** ≥ 18
|
|
29
|
+
- **PostgreSQL** ≥ 14
|
|
30
|
+
- **Redis** ≥ 6 (solo si usas queue)
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Quickstart (5 minutos)
|
|
35
|
+
|
|
36
|
+
### 1. Configurar el módulo raíz
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// app.module.ts
|
|
40
|
+
import { Module } from '@nestjs/common';
|
|
41
|
+
import { AgentForgeModule } from 'agentforge';
|
|
42
|
+
|
|
43
|
+
@Module({
|
|
44
|
+
imports: [
|
|
45
|
+
AgentForgeModule.forRoot({
|
|
46
|
+
anthropic: {
|
|
47
|
+
apiKey: process.env.ANTHROPIC_API_KEY!,
|
|
48
|
+
},
|
|
49
|
+
database: {
|
|
50
|
+
url: process.env.DATABASE_URL!,
|
|
51
|
+
},
|
|
52
|
+
agents: [
|
|
53
|
+
{
|
|
54
|
+
id: 'assistant',
|
|
55
|
+
name: 'Assistant',
|
|
56
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
}),
|
|
60
|
+
],
|
|
61
|
+
})
|
|
62
|
+
export class AppModule {}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Arrancar la app
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// main.ts
|
|
69
|
+
import { NestFactory } from '@nestjs/core';
|
|
70
|
+
import { AppModule } from './app.module';
|
|
71
|
+
|
|
72
|
+
async function bootstrap() {
|
|
73
|
+
const app = await NestFactory.create(AppModule, { rawBody: true });
|
|
74
|
+
await app.listen(3000);
|
|
75
|
+
}
|
|
76
|
+
bootstrap();
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 3. Usar la API REST
|
|
80
|
+
|
|
81
|
+
AgentForge registra automáticamente las rutas:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Crear una conversación
|
|
85
|
+
POST /conversations
|
|
86
|
+
{ "userId": "user_123", "agentId": "assistant" }
|
|
87
|
+
|
|
88
|
+
# Enviar un mensaje
|
|
89
|
+
POST /conversations/:id/messages
|
|
90
|
+
{ "userId": "user_123", "content": "Hello!" }
|
|
91
|
+
|
|
92
|
+
# Ver el historial
|
|
93
|
+
GET /conversations/:id?userId=user_123
|
|
94
|
+
|
|
95
|
+
# Listar conversaciones
|
|
96
|
+
GET /conversations?userId=user_123
|
|
97
|
+
|
|
98
|
+
# Stream de respuesta (Server-Sent Events)
|
|
99
|
+
GET /conversations/:id/stream?userId=user_123&content=Hello
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Configuración completa
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
AgentForgeModule.forRoot({
|
|
108
|
+
// ─── Anthropic ─────────────────────────────────────────────────────────
|
|
109
|
+
anthropic: {
|
|
110
|
+
apiKey: 'sk-ant-...',
|
|
111
|
+
defaultModel: 'claude-opus-4-6', // Modelo por defecto para todos los agentes
|
|
112
|
+
defaultMaxTokens: 4096,
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
// ─── Base de datos ─────────────────────────────────────────────────────
|
|
116
|
+
database: {
|
|
117
|
+
url: 'postgresql://user:pass@localhost:5432/myapp',
|
|
118
|
+
autoMigrate: true, // Sincroniza el schema automáticamente (usa false en prod)
|
|
119
|
+
logging: false,
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
// ─── Redis (necesario para queue) ──────────────────────────────────────
|
|
123
|
+
redis: {
|
|
124
|
+
host: 'localhost',
|
|
125
|
+
port: 6379,
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
// ─── Queue async ───────────────────────────────────────────────────────
|
|
129
|
+
queue: {
|
|
130
|
+
enabled: true,
|
|
131
|
+
concurrency: 5,
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
// ─── Billing ───────────────────────────────────────────────────────────
|
|
135
|
+
billing: {
|
|
136
|
+
provider: 'stripe',
|
|
137
|
+
models: ['subscription', 'freemium'],
|
|
138
|
+
appUrl: 'https://myapp.com',
|
|
139
|
+
stripe: {
|
|
140
|
+
secretKey: 'sk_live_...',
|
|
141
|
+
webhookSecret: 'whsec_...',
|
|
142
|
+
},
|
|
143
|
+
plans: [
|
|
144
|
+
{
|
|
145
|
+
id: 'free',
|
|
146
|
+
name: 'Free',
|
|
147
|
+
isDefault: true,
|
|
148
|
+
limits: { requestsPerMonth: 50, tokensPerMonth: 25_000 },
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: 'pro',
|
|
152
|
+
name: 'Pro',
|
|
153
|
+
stripePriceId: 'price_xxx',
|
|
154
|
+
priceInCents: 1900,
|
|
155
|
+
interval: 'month',
|
|
156
|
+
limits: { requestsPerMonth: 1000, tokensPerMonth: 1_000_000 },
|
|
157
|
+
features: ['All agents', 'Priority support'],
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
// ─── Agentes ───────────────────────────────────────────────────────────
|
|
163
|
+
agents: [
|
|
164
|
+
{
|
|
165
|
+
id: 'assistant',
|
|
166
|
+
name: 'General Assistant',
|
|
167
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
168
|
+
model: 'claude-opus-4-6',
|
|
169
|
+
tools: ['calculator', 'web_search'],
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
})
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Multi-Agente con Orquestación
|
|
178
|
+
|
|
179
|
+
Define un agente orquestador con `canOrchestrate: true` y lista sus subagentes. AgentForge inyecta automáticamente herramientas de delegación para que Claude sepa cuándo llamar a cada especialista.
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
agents: [
|
|
183
|
+
// Especialistas
|
|
184
|
+
{
|
|
185
|
+
id: 'researcher',
|
|
186
|
+
name: 'Research Specialist',
|
|
187
|
+
systemPrompt: 'You are an expert researcher. Find and summarize information.',
|
|
188
|
+
tools: ['web_search'],
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: 'writer',
|
|
192
|
+
name: 'Content Writer',
|
|
193
|
+
systemPrompt: 'You are a professional writer. Create high-quality content.',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
id: 'analyst',
|
|
197
|
+
name: 'Data Analyst',
|
|
198
|
+
systemPrompt: 'You analyze data and provide insights.',
|
|
199
|
+
tools: ['calculator', 'query_data'],
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
// Orquestador — coordina a los especialistas
|
|
203
|
+
{
|
|
204
|
+
id: 'orchestrator',
|
|
205
|
+
name: 'AI Director',
|
|
206
|
+
systemPrompt: `You coordinate specialist agents for complex tasks.
|
|
207
|
+
Delegate research to the researcher, writing to the writer, and analysis to the analyst.
|
|
208
|
+
Synthesize all results into a final comprehensive answer.`,
|
|
209
|
+
canOrchestrate: true,
|
|
210
|
+
subAgents: ['researcher', 'writer', 'analyst'],
|
|
211
|
+
},
|
|
212
|
+
]
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Cuando el usuario envía un mensaje al orquestador, Claude puede llamar a `delegate_to_researcher`, `delegate_to_writer`, etc. automáticamente.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Definir Tools
|
|
220
|
+
|
|
221
|
+
### Opción 1: Función `defineTool` (recomendada)
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { defineTool, AgentForgeModule } from 'agentforge';
|
|
225
|
+
|
|
226
|
+
const weatherTool = defineTool({
|
|
227
|
+
name: 'get_weather',
|
|
228
|
+
description: 'Get current weather for a city',
|
|
229
|
+
inputSchema: {
|
|
230
|
+
type: 'object',
|
|
231
|
+
properties: {
|
|
232
|
+
city: { type: 'string', description: 'City name' },
|
|
233
|
+
},
|
|
234
|
+
required: ['city'],
|
|
235
|
+
},
|
|
236
|
+
// Opcional: restringir a agentes específicos
|
|
237
|
+
agents: ['assistant', 'orchestrator'],
|
|
238
|
+
execute: async ({ city }, context) => {
|
|
239
|
+
// context tiene: userId, conversationId, agentId, messageId
|
|
240
|
+
const data = await fetchWeatherAPI(city as string);
|
|
241
|
+
return `${city}: ${data.temp}°C, ${data.condition}`;
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// Registrar en el módulo
|
|
246
|
+
AgentForgeModule.forRootAsync({
|
|
247
|
+
useFactory: (config: ConfigService) => ({
|
|
248
|
+
agents: [...],
|
|
249
|
+
...
|
|
250
|
+
}),
|
|
251
|
+
options: {
|
|
252
|
+
tools: [weatherTool, calculatorTool, ...],
|
|
253
|
+
},
|
|
254
|
+
})
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Opción 2: Registro manual en tiempo de ejecución
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
import { ToolRegistryService } from 'agentforge';
|
|
261
|
+
|
|
262
|
+
@Injectable()
|
|
263
|
+
export class MyService {
|
|
264
|
+
constructor(private readonly toolRegistry: ToolRegistryService) {}
|
|
265
|
+
|
|
266
|
+
onModuleInit() {
|
|
267
|
+
this.toolRegistry.register({
|
|
268
|
+
name: 'my_tool',
|
|
269
|
+
description: '...',
|
|
270
|
+
inputSchema: { type: 'object', properties: {} },
|
|
271
|
+
execute: async (input) => 'result',
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Billing
|
|
280
|
+
|
|
281
|
+
### API de Billing
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
# Ver planes disponibles
|
|
285
|
+
GET /billing/plans
|
|
286
|
+
|
|
287
|
+
# Crear sesión de checkout (Stripe Checkout)
|
|
288
|
+
POST /billing/checkout
|
|
289
|
+
{ "userId": "user_123", "planId": "pro" }
|
|
290
|
+
→ { "url": "https://checkout.stripe.com/..." }
|
|
291
|
+
|
|
292
|
+
# Portal de cliente (gestionar suscripción)
|
|
293
|
+
POST /billing/portal
|
|
294
|
+
{ "userId": "user_123" }
|
|
295
|
+
→ { "url": "https://billing.stripe.com/..." }
|
|
296
|
+
|
|
297
|
+
# Ver estado de billing del usuario
|
|
298
|
+
GET /billing/overview/user_123
|
|
299
|
+
|
|
300
|
+
# Cancelar suscripción
|
|
301
|
+
DELETE /billing/subscription/user_123
|
|
302
|
+
|
|
303
|
+
# Webhook de Stripe
|
|
304
|
+
POST /billing/webhook (con header stripe-signature)
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Agregar créditos
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
billing: {
|
|
311
|
+
models: ['credits'],
|
|
312
|
+
credits: {
|
|
313
|
+
tokensPerCredit: 1000, // 1 crédito = 1000 tokens
|
|
314
|
+
creditsPerRequest: 1, // +1 crédito por request
|
|
315
|
+
initialCredits: 100, // Créditos iniciales al registrarse
|
|
316
|
+
},
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Adaptador personalizado (PayPal, Paddle, LemonSqueezy, etc.)
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
import { IBillingAdapter } from 'agentforge';
|
|
324
|
+
|
|
325
|
+
export class PaddleAdapter implements IBillingAdapter {
|
|
326
|
+
async createCheckoutSession(params) { ... }
|
|
327
|
+
async createSubscription(params) { ... }
|
|
328
|
+
async cancelSubscription(id, atPeriodEnd) { ... }
|
|
329
|
+
async handleWebhook(payload, signature) { ... }
|
|
330
|
+
async getPortalUrl(customerId, returnUrl) { ... }
|
|
331
|
+
async createCustomer(params) { ... }
|
|
332
|
+
async getSubscription(id) { ... }
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// En la config:
|
|
336
|
+
billing: {
|
|
337
|
+
provider: 'custom',
|
|
338
|
+
customAdapter: PaddleAdapter,
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## Queue asíncrona
|
|
345
|
+
|
|
346
|
+
Envía mensajes en background y haz polling del resultado:
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
// Enviar mensaje asíncrono
|
|
350
|
+
POST /conversations/:id/messages
|
|
351
|
+
{ "userId": "user_123", "content": "...", "async": true }
|
|
352
|
+
→ { "jobId": "abc123", "estimatedWait": 5000 }
|
|
353
|
+
|
|
354
|
+
// Hacer polling
|
|
355
|
+
GET /jobs/abc123
|
|
356
|
+
→ { "status": "active", "progress": 70 }
|
|
357
|
+
→ { "status": "completed", "result": { "content": "..." } }
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## Guards y decoradores
|
|
363
|
+
|
|
364
|
+
### `@RequirePlan()` — Restricciones por plan
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
import { RequirePlan, UsageLimitGuard } from 'agentforge';
|
|
368
|
+
|
|
369
|
+
@Controller('conversations')
|
|
370
|
+
@UseGuards(UsageLimitGuard) // Aplica límites de uso automáticamente
|
|
371
|
+
export class MyController {
|
|
372
|
+
|
|
373
|
+
@Post()
|
|
374
|
+
@RequirePlan('pro', 'enterprise') // Solo usuarios en plan pro o enterprise
|
|
375
|
+
async createConversation(@Body() dto: CreateConversationDto) {
|
|
376
|
+
return this.agentService.createConversation(dto);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### `UsageLimitGuard` — Límites automáticos
|
|
382
|
+
|
|
383
|
+
Aplica el guard globalmente en `main.ts`:
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
import { UsageLimitGuard } from 'agentforge';
|
|
387
|
+
|
|
388
|
+
app.useGlobalGuards(app.get(UsageLimitGuard));
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Acceso a servicios internos
|
|
394
|
+
|
|
395
|
+
Todos los servicios se exportan para que puedas inyectarlos en tu propia lógica:
|
|
396
|
+
|
|
397
|
+
```typescript
|
|
398
|
+
import {
|
|
399
|
+
AgentService,
|
|
400
|
+
BillingService,
|
|
401
|
+
ConversationService,
|
|
402
|
+
UsageService,
|
|
403
|
+
ToolRegistryService,
|
|
404
|
+
OrchestratorService,
|
|
405
|
+
} from 'agentforge';
|
|
406
|
+
|
|
407
|
+
@Injectable()
|
|
408
|
+
export class MyCustomService {
|
|
409
|
+
constructor(
|
|
410
|
+
private readonly agents: AgentService,
|
|
411
|
+
private readonly billing: BillingService,
|
|
412
|
+
private readonly usage: UsageService,
|
|
413
|
+
) {}
|
|
414
|
+
|
|
415
|
+
async onboardUser(userId: string, email: string) {
|
|
416
|
+
// Crear conversación de bienvenida
|
|
417
|
+
const { conversation } = await this.agents.createConversation({
|
|
418
|
+
userId,
|
|
419
|
+
agentId: 'assistant',
|
|
420
|
+
title: 'Welcome',
|
|
421
|
+
initialMessage: 'Hello! I am your AI assistant. How can I help you today?',
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// Ver el uso
|
|
425
|
+
const summary = await this.usage.getSummary(userId);
|
|
426
|
+
console.log(`User ${userId}: ${summary.requestsUsed}/${summary.requestsLimit} requests used`);
|
|
427
|
+
|
|
428
|
+
return conversation;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## Variables de entorno
|
|
436
|
+
|
|
437
|
+
```env
|
|
438
|
+
# Anthropic
|
|
439
|
+
ANTHROPIC_API_KEY=sk-ant-api03-...
|
|
440
|
+
|
|
441
|
+
# PostgreSQL
|
|
442
|
+
DATABASE_URL=postgresql://user:password@localhost:5432/myapp
|
|
443
|
+
|
|
444
|
+
# Redis
|
|
445
|
+
REDIS_HOST=localhost
|
|
446
|
+
REDIS_PORT=6379
|
|
447
|
+
|
|
448
|
+
# Stripe
|
|
449
|
+
STRIPE_SECRET_KEY=sk_test_...
|
|
450
|
+
STRIPE_WEBHOOK_SECRET=whsec_...
|
|
451
|
+
|
|
452
|
+
# App
|
|
453
|
+
APP_URL=http://localhost:3000
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## Estructura de la base de datos
|
|
459
|
+
|
|
460
|
+
AgentForge crea automáticamente las siguientes tablas (prefijo `af_`):
|
|
461
|
+
|
|
462
|
+
| Tabla | Descripción |
|
|
463
|
+
|---|---|
|
|
464
|
+
| `af_users` | Usuarios con plan actual y balance de créditos |
|
|
465
|
+
| `af_conversations` | Sesiones de conversación con agentes |
|
|
466
|
+
| `af_messages` | Historial de mensajes con tool calls y uso de tokens |
|
|
467
|
+
| `af_subscriptions` | Suscripciones de Stripe por usuario |
|
|
468
|
+
| `af_usage_records` | Registro detallado de uso para billing |
|
|
469
|
+
|
|
470
|
+
---
|
|
471
|
+
|
|
472
|
+
## Roadmap
|
|
473
|
+
|
|
474
|
+
- [ ] Soporte para MCP servers (Model Context Protocol)
|
|
475
|
+
- [ ] Adapter para LemonSqueezy y Paddle
|
|
476
|
+
- [ ] Panel de administración (React)
|
|
477
|
+
- [ ] Rate limiting por IP
|
|
478
|
+
- [ ] Webhooks de eventos para tu sistema (conversación iniciada, límite alcanzado, etc.)
|
|
479
|
+
- [ ] Soporte para archivos adjuntos en mensajes
|
|
480
|
+
- [ ] Streaming con WebSockets (además de SSE)
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
## Licencia
|
|
485
|
+
|
|
486
|
+
MIT
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DynamicModule, Type } from '@nestjs/common';
|
|
2
|
+
import type { AgentForgeConfig, AgentToolDefinition, SdkHooks } from '@agentforge-io/core';
|
|
3
|
+
export interface AgentForgeModuleOptions {
|
|
4
|
+
tools?: AgentToolDefinition[];
|
|
5
|
+
swagger?: boolean;
|
|
6
|
+
extraEntities?: Function[];
|
|
7
|
+
hooks?: SdkHooks;
|
|
8
|
+
hooksFactory?: {
|
|
9
|
+
inject?: Type<any>[];
|
|
10
|
+
useFactory: (...args: any[]) => SdkHooks | Promise<SdkHooks>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare class AgentForgeModule {
|
|
14
|
+
static forRoot(config: AgentForgeConfig, options?: AgentForgeModuleOptions): DynamicModule;
|
|
15
|
+
static forRootAsync(asyncOptions: {
|
|
16
|
+
imports?: Type<any>[];
|
|
17
|
+
inject?: Type<any>[];
|
|
18
|
+
useFactory: (...args: any[]) => AgentForgeConfig | Promise<AgentForgeConfig>;
|
|
19
|
+
options?: AgentForgeModuleOptions;
|
|
20
|
+
}): DynamicModule;
|
|
21
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AgentForgeModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const core_1 = require("@nestjs/core");
|
|
12
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
13
|
+
const rate_limit_guard_1 = require("./guards/rate-limit.guard");
|
|
14
|
+
const agentforge_exception_filter_1 = require("./filters/agentforge-exception.filter");
|
|
15
|
+
const agent_module_1 = require("./modules/agent/agent.module");
|
|
16
|
+
const conversation_module_1 = require("./modules/conversation/conversation.module");
|
|
17
|
+
const queue_module_1 = require("./modules/queue/queue.module");
|
|
18
|
+
const public_chat_module_1 = require("./modules/public-chat/public-chat.module");
|
|
19
|
+
const mcp_module_1 = require("./modules/mcp/mcp.module");
|
|
20
|
+
const connectors_module_1 = require("./modules/connectors/connectors.module");
|
|
21
|
+
const constants_1 = require("./constants");
|
|
22
|
+
const constants_2 = require("./constants");
|
|
23
|
+
const redis_provider_1 = require("./redis/redis.provider");
|
|
24
|
+
const repositories_providers_1 = require("./providers/repositories.providers");
|
|
25
|
+
const services_providers_1 = require("./providers/services.providers");
|
|
26
|
+
const typeorm_2 = require("@agentforge-io/typeorm");
|
|
27
|
+
const core_2 = require("@agentforge-io/core");
|
|
28
|
+
let AgentForgeModule = class AgentForgeModule {
|
|
29
|
+
static forRoot(config, options = {}) {
|
|
30
|
+
const configProvider = { provide: constants_1.AGENT_FORGE_CONFIG, useValue: config };
|
|
31
|
+
return buildModule({
|
|
32
|
+
configProviders: [configProvider],
|
|
33
|
+
typeOrm: typeorm_1.TypeOrmModule.forRoot({
|
|
34
|
+
type: 'postgres',
|
|
35
|
+
url: config.database.url,
|
|
36
|
+
entities: [...typeorm_2.AGENTFORGE_TYPEORM_ENTITIES, ...(options.extraEntities ?? [])],
|
|
37
|
+
synchronize: config.database.autoMigrate ?? true,
|
|
38
|
+
ssl: config.database.ssl,
|
|
39
|
+
poolSize: config.database.poolSize ?? 10,
|
|
40
|
+
logging: config.database.logging ?? false,
|
|
41
|
+
}),
|
|
42
|
+
tools: options.tools,
|
|
43
|
+
hooks: options.hooks,
|
|
44
|
+
hooksFactory: options.hooksFactory,
|
|
45
|
+
withQueue: () => queue_module_1.QueueModule.forRoot(config),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
static forRootAsync(asyncOptions) {
|
|
49
|
+
const configProvider = {
|
|
50
|
+
provide: constants_1.AGENT_FORGE_CONFIG,
|
|
51
|
+
inject: asyncOptions.inject ?? [],
|
|
52
|
+
useFactory: asyncOptions.useFactory,
|
|
53
|
+
};
|
|
54
|
+
return buildModule({
|
|
55
|
+
configProviders: [configProvider],
|
|
56
|
+
extraImports: asyncOptions.imports ?? [],
|
|
57
|
+
typeOrm: typeorm_1.TypeOrmModule.forRootAsync({
|
|
58
|
+
inject: [constants_1.AGENT_FORGE_CONFIG],
|
|
59
|
+
useFactory: (config) => ({
|
|
60
|
+
type: 'postgres',
|
|
61
|
+
url: config.database.url,
|
|
62
|
+
entities: [
|
|
63
|
+
...typeorm_2.AGENTFORGE_TYPEORM_ENTITIES,
|
|
64
|
+
...(asyncOptions.options?.extraEntities ?? []),
|
|
65
|
+
],
|
|
66
|
+
synchronize: config.database.autoMigrate ?? true,
|
|
67
|
+
ssl: config.database.ssl,
|
|
68
|
+
poolSize: config.database.poolSize ?? 10,
|
|
69
|
+
logging: config.database.logging ?? false,
|
|
70
|
+
}),
|
|
71
|
+
}),
|
|
72
|
+
tools: asyncOptions.options?.tools,
|
|
73
|
+
hooks: asyncOptions.options?.hooks,
|
|
74
|
+
hooksFactory: asyncOptions.options?.hooksFactory,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
exports.AgentForgeModule = AgentForgeModule;
|
|
79
|
+
exports.AgentForgeModule = AgentForgeModule = __decorate([
|
|
80
|
+
(0, common_1.Module)({})
|
|
81
|
+
], AgentForgeModule);
|
|
82
|
+
function buildModule(opts) {
|
|
83
|
+
const toolsProvider = {
|
|
84
|
+
provide: services_providers_1.TOOLS_TOKEN,
|
|
85
|
+
useValue: opts.tools ?? [],
|
|
86
|
+
};
|
|
87
|
+
const hooksProvider = opts.hooksFactory
|
|
88
|
+
? {
|
|
89
|
+
provide: constants_2.AGENT_FORGE_HOOKS,
|
|
90
|
+
inject: opts.hooksFactory.inject ?? [],
|
|
91
|
+
useFactory: opts.hooksFactory.useFactory,
|
|
92
|
+
}
|
|
93
|
+
: opts.hooks !== undefined
|
|
94
|
+
? {
|
|
95
|
+
provide: constants_2.AGENT_FORGE_HOOKS,
|
|
96
|
+
useValue: opts.hooks,
|
|
97
|
+
}
|
|
98
|
+
: null;
|
|
99
|
+
return {
|
|
100
|
+
module: AgentForgeModule,
|
|
101
|
+
global: true,
|
|
102
|
+
imports: [
|
|
103
|
+
...(opts.extraImports ?? []),
|
|
104
|
+
opts.typeOrm,
|
|
105
|
+
conversation_module_1.ConversationModule,
|
|
106
|
+
agent_module_1.AgentModule,
|
|
107
|
+
public_chat_module_1.PublicChatModule,
|
|
108
|
+
mcp_module_1.McpModule,
|
|
109
|
+
connectors_module_1.ConnectorsModule,
|
|
110
|
+
...(opts.withQueue ? [opts.withQueue()] : []),
|
|
111
|
+
],
|
|
112
|
+
providers: [
|
|
113
|
+
...opts.configProviders,
|
|
114
|
+
toolsProvider,
|
|
115
|
+
...(hooksProvider ? [hooksProvider] : []),
|
|
116
|
+
redis_provider_1.redisClientProvider,
|
|
117
|
+
...repositories_providers_1.repositoryProviders,
|
|
118
|
+
...(0, services_providers_1.createServiceProviders)(),
|
|
119
|
+
{ provide: core_1.APP_GUARD, useClass: rate_limit_guard_1.AgentForgeRateLimitGuard },
|
|
120
|
+
{ provide: core_1.APP_FILTER, useClass: agentforge_exception_filter_1.AgentForgeExceptionFilter },
|
|
121
|
+
],
|
|
122
|
+
exports: [
|
|
123
|
+
constants_1.AGENT_FORGE_CONFIG,
|
|
124
|
+
redis_provider_1.AGENTFORGE_REDIS_CLIENT,
|
|
125
|
+
core_2.ToolRegistryService,
|
|
126
|
+
core_2.AgentRunnerService,
|
|
127
|
+
core_2.PreparedStreamService,
|
|
128
|
+
core_2.OrchestratorService,
|
|
129
|
+
core_2.ConversationService,
|
|
130
|
+
core_2.AgentService,
|
|
131
|
+
core_2.AgentJobWorker,
|
|
132
|
+
core_2.ChatTokenService,
|
|
133
|
+
core_2.McpClientService,
|
|
134
|
+
core_2.McpServerService,
|
|
135
|
+
core_2.JOB_QUEUE,
|
|
136
|
+
conversation_module_1.ConversationModule,
|
|
137
|
+
agent_module_1.AgentModule,
|
|
138
|
+
public_chat_module_1.PublicChatModule,
|
|
139
|
+
mcp_module_1.McpModule,
|
|
140
|
+
connectors_module_1.ConnectorsModule,
|
|
141
|
+
],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=agent-forge.module.js.map
|
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7D;QACD,OAAO,EAAE;YACP,8BAAkB;YAClB,wCAAuB;YACvB,0BAAmB;YACnB,yBAAkB;YAClB,4BAAqB;YACrB,0BAAmB;YACnB,0BAAmB;YACnB,mBAAY;YACZ,qBAAc;YACd,uBAAgB;YAChB,uBAAgB;YAChB,uBAAgB;YAChB,gBAAS;YACT,wCAAkB;YAClB,0BAAW;YACX,qCAAgB;YAChB,sBAAS;YACT,oCAAgB;SACjB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface AuthUser {
|
|
2
|
+
userId: string;
|
|
3
|
+
tenantId?: string;
|
|
4
|
+
isPlatformAdmin?: boolean;
|
|
5
|
+
isApiKey?: boolean;
|
|
6
|
+
email?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const CurrentUser: (...dataOrPipes: (keyof AuthUser | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>> | undefined)[]) => ParameterDecorator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CurrentUser = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.CurrentUser = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
6
|
+
const req = ctx.switchToHttp().getRequest();
|
|
7
|
+
return data ? req.user?.[data] : req.user;
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=current-user.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../src/auth/current-user.decorator.ts"],"names":[],"mappings":";;;AAQA,2CAAwE;AAc3D,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAC7C,CAAC,IAAgC,EAAE,GAAqB,EAAE,EAAE;IAC1D,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAuB,CAAC;IACjE,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;AAC5C,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Public = exports.IS_PUBLIC_KEY = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.IS_PUBLIC_KEY = 'agentforge:isPublic';
|
|
6
|
+
const Public = () => (0, common_1.SetMetadata)(exports.IS_PUBLIC_KEY, true);
|
|
7
|
+
exports.Public = Public;
|
|
8
|
+
//# sourceMappingURL=public.decorator.js.map
|