@bpinhosilva/agent-orchestrator 1.0.0-alpha.13 → 1.0.0-alpha.14
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/CHANGELOG.md +8 -0
- package/dist/agents/agents.module.js +3 -5
- package/dist/agents/agents.service.js +14 -8
- package/dist/agents/implementations/claude.agent.js +11 -5
- package/dist/agents/implementations/gemini.agent.js +15 -6
- package/dist/app.module.js +21 -8
- package/dist/config/env.validation.js +46 -0
- package/dist/src/agents/agents.module.d.ts +0 -2
- package/dist/src/agents/agents.module.js +3 -3
- package/dist/src/agents/agents.module.js.map +1 -1
- package/dist/src/agents/agents.service.d.ts +3 -1
- package/dist/src/agents/agents.service.js +13 -8
- package/dist/src/agents/agents.service.js.map +1 -1
- package/dist/src/agents/implementations/claude.agent.d.ts +4 -1
- package/dist/src/agents/implementations/claude.agent.js +12 -5
- package/dist/src/agents/implementations/claude.agent.js.map +1 -1
- package/dist/src/agents/implementations/gemini.agent.d.ts +4 -1
- package/dist/src/agents/implementations/gemini.agent.js +16 -7
- package/dist/src/agents/implementations/gemini.agent.js.map +1 -1
- package/dist/src/app.module.js +21 -8
- package/dist/src/app.module.js.map +1 -1
- package/dist/src/config/env.validation.d.ts +2 -0
- package/dist/src/config/env.validation.js +47 -0
- package/dist/src/config/env.validation.js.map +1 -0
- package/dist/src/main.js +5 -1
- package/dist/src/main.js.map +1 -1
- package/dist/src/tasks/dto/create-task.dto.js +1 -2
- package/dist/src/tasks/dto/create-task.dto.js.map +1 -1
- package/dist/tasks/dto/create-task.dto.js +1 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# [1.0.0-alpha.14](https://github.com/bpinhosilva/agent-orchestrator/compare/v1.0.0-alpha.13...v1.0.0-alpha.14) (2026-03-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add CreateTaskDto ([1604945](https://github.com/bpinhosilva/agent-orchestrator/commit/1604945737b5df5480c6c0814c369902f7cc9142))
|
|
7
|
+
* implement transient agent instances with dynamic configurationn ([5d57b08](https://github.com/bpinhosilva/agent-orchestrator/commit/5d57b0886edf4b14d93ab76f245f4311b6657f7d))
|
|
8
|
+
|
|
1
9
|
# [1.0.0-alpha.13](https://github.com/bpinhosilva/agent-orchestrator/compare/v1.0.0-alpha.12...v1.0.0-alpha.13) (2026-03-26)
|
|
2
10
|
|
|
3
11
|
|
|
@@ -12,10 +12,8 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
12
12
|
const agents_controller_1 = require("./agents.controller");
|
|
13
13
|
const agents_service_1 = require("./agents.service");
|
|
14
14
|
const agent_entity_1 = require("./entities/agent.entity");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
require("./implementations/gemini.agent");
|
|
18
|
-
require("./implementations/claude.agent");
|
|
15
|
+
const gemini_agent_1 = require("./implementations/gemini.agent");
|
|
16
|
+
const claude_agent_1 = require("./implementations/claude.agent");
|
|
19
17
|
let AgentsModule = class AgentsModule {
|
|
20
18
|
};
|
|
21
19
|
exports.AgentsModule = AgentsModule;
|
|
@@ -23,7 +21,7 @@ exports.AgentsModule = AgentsModule = __decorate([
|
|
|
23
21
|
(0, common_1.Module)({
|
|
24
22
|
imports: [typeorm_1.TypeOrmModule.forFeature([agent_entity_1.AgentEntity])],
|
|
25
23
|
controllers: [agents_controller_1.AgentsController],
|
|
26
|
-
providers: [agents_service_1.AgentsService],
|
|
24
|
+
providers: [agents_service_1.AgentsService, gemini_agent_1.GeminiAgent, claude_agent_1.ClaudeAgent],
|
|
27
25
|
exports: [agents_service_1.AgentsService],
|
|
28
26
|
})
|
|
29
27
|
], AgentsModule);
|
|
@@ -19,10 +19,12 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
19
19
|
const typeorm_2 = require("typeorm");
|
|
20
20
|
const agent_entity_1 = require("./entities/agent.entity");
|
|
21
21
|
const agent_registry_1 = require("./registry/agent.registry");
|
|
22
|
+
const core_1 = require("@nestjs/core");
|
|
22
23
|
const AGENT_RELATIONS = ['model', 'provider'];
|
|
23
24
|
let AgentsService = AgentsService_1 = class AgentsService {
|
|
24
|
-
constructor(agentRepository) {
|
|
25
|
+
constructor(agentRepository, moduleRef) {
|
|
25
26
|
this.agentRepository = agentRepository;
|
|
27
|
+
this.moduleRef = moduleRef;
|
|
26
28
|
this.logger = new common_1.Logger(AgentsService_1.name);
|
|
27
29
|
this.agentInstances = new Map();
|
|
28
30
|
}
|
|
@@ -34,7 +36,7 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
34
36
|
for (const agentEntity of agents) {
|
|
35
37
|
if (agentEntity.status !== 'inactive') {
|
|
36
38
|
try {
|
|
37
|
-
this.syncAgentInstance(agentEntity);
|
|
39
|
+
await this.syncAgentInstance(agentEntity);
|
|
38
40
|
}
|
|
39
41
|
catch (error) {
|
|
40
42
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -44,7 +46,7 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
44
46
|
}
|
|
45
47
|
this.logger.log(`Initialized ${this.agentInstances.size} agent instances.`);
|
|
46
48
|
}
|
|
47
|
-
syncAgentInstance(agentEntity) {
|
|
49
|
+
async syncAgentInstance(agentEntity) {
|
|
48
50
|
if (agentEntity.status === 'inactive') {
|
|
49
51
|
this.agentInstances.delete(agentEntity.id);
|
|
50
52
|
return;
|
|
@@ -60,13 +62,16 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
60
62
|
return;
|
|
61
63
|
}
|
|
62
64
|
try {
|
|
63
|
-
|
|
65
|
+
// Use resolve for TRANSIENT scoped providers. This ensures we get a fresh instance
|
|
66
|
+
// which we then configure and store in our Map (making it a singleton for this ID).
|
|
67
|
+
const instance = await this.moduleRef.resolve(AgentClass);
|
|
64
68
|
instance.updateConfig?.({
|
|
65
69
|
name: agentEntity.name,
|
|
66
70
|
description: agentEntity.description,
|
|
67
71
|
systemInstructions: agentEntity.systemInstructions,
|
|
68
72
|
role: agentEntity.role,
|
|
69
73
|
provider: providerName,
|
|
74
|
+
model: agentEntity.model?.name,
|
|
70
75
|
});
|
|
71
76
|
this.agentInstances.set(agentEntity.id, instance);
|
|
72
77
|
this.logger.debug(`Synchronized agent instance #${agentEntity.id}`);
|
|
@@ -98,7 +103,7 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
98
103
|
throw new Error(`Agent #${savedAgent.id} not found immediately after save`);
|
|
99
104
|
}
|
|
100
105
|
// This will throw BadRequestException if instantiation fails, rolling back the transaction
|
|
101
|
-
this.syncAgentInstance(fullyLoadedAgent);
|
|
106
|
+
await this.syncAgentInstance(fullyLoadedAgent);
|
|
102
107
|
return fullyLoadedAgent;
|
|
103
108
|
});
|
|
104
109
|
}
|
|
@@ -134,7 +139,7 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
134
139
|
throw new common_1.NotFoundException(`Agent #${id} not found`);
|
|
135
140
|
}
|
|
136
141
|
// This will throw BadRequestException if instantiation fails, rolling back the transaction
|
|
137
|
-
this.syncAgentInstance(updatedAgent);
|
|
142
|
+
await this.syncAgentInstance(updatedAgent);
|
|
138
143
|
return updatedAgent;
|
|
139
144
|
});
|
|
140
145
|
}
|
|
@@ -172,7 +177,7 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
172
177
|
if (agentEntity.status === 'inactive') {
|
|
173
178
|
throw new common_1.NotFoundException(`Agent #${agentId} is currently inactive and cannot be probed.`);
|
|
174
179
|
}
|
|
175
|
-
this.syncAgentInstance(agentEntity);
|
|
180
|
+
await this.syncAgentInstance(agentEntity);
|
|
176
181
|
agent = this.agentInstances.get(agentId);
|
|
177
182
|
if (!agent) {
|
|
178
183
|
throw new common_1.NotFoundException(`Failed to initialize agent #${agentId} after database fetch`);
|
|
@@ -185,5 +190,6 @@ exports.AgentsService = AgentsService;
|
|
|
185
190
|
exports.AgentsService = AgentsService = AgentsService_1 = __decorate([
|
|
186
191
|
(0, common_1.Injectable)(),
|
|
187
192
|
__param(0, (0, typeorm_1.InjectRepository)(agent_entity_1.AgentEntity)),
|
|
188
|
-
__metadata("design:paramtypes", [typeorm_2.Repository
|
|
193
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
194
|
+
core_1.ModuleRef])
|
|
189
195
|
], AgentsService);
|
|
@@ -16,18 +16,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.ClaudeAgent = void 0;
|
|
17
17
|
const claude_agent_sdk_1 = require("@anthropic-ai/claude-agent-sdk");
|
|
18
18
|
const common_1 = require("@nestjs/common");
|
|
19
|
+
const config_1 = require("@nestjs/config");
|
|
19
20
|
const agent_registry_1 = require("../registry/agent.registry");
|
|
20
21
|
let ClaudeAgent = ClaudeAgent_1 = class ClaudeAgent {
|
|
21
|
-
constructor(model = 'claude-opus-4-6') {
|
|
22
|
+
constructor(configService, model = 'claude-opus-4-6') {
|
|
23
|
+
this.configService = configService;
|
|
22
24
|
this.logger = new common_1.Logger(ClaudeAgent_1.name);
|
|
23
25
|
this.name = 'ClaudeAgent';
|
|
24
26
|
this.provider = 'anthropic';
|
|
25
27
|
this.model = model;
|
|
26
|
-
|
|
28
|
+
}
|
|
29
|
+
validateApiKey() {
|
|
30
|
+
const apiKey = this.configService.get('ANTHROPIC_API_KEY');
|
|
27
31
|
if (!apiKey) {
|
|
28
32
|
this.logger.error('ANTHROPIC_API_KEY environment variable is not set');
|
|
29
33
|
throw new Error('ANTHROPIC_API_KEY is required to initialize ClaudeAgent');
|
|
30
34
|
}
|
|
35
|
+
return apiKey;
|
|
31
36
|
}
|
|
32
37
|
getName() {
|
|
33
38
|
return this.name;
|
|
@@ -74,6 +79,7 @@ let ClaudeAgent = ClaudeAgent_1 = class ClaudeAgent {
|
|
|
74
79
|
.join('\n');
|
|
75
80
|
}
|
|
76
81
|
async processText(input) {
|
|
82
|
+
this.validateApiKey();
|
|
77
83
|
this.logger.debug(`Processing input with ClaudeAgent. Model: ${this.model}`);
|
|
78
84
|
try {
|
|
79
85
|
const systemPrompt = this.buildSystemPrompt();
|
|
@@ -129,8 +135,8 @@ Please perform the task and provide the output.
|
|
|
129
135
|
};
|
|
130
136
|
exports.ClaudeAgent = ClaudeAgent;
|
|
131
137
|
exports.ClaudeAgent = ClaudeAgent = ClaudeAgent_1 = __decorate([
|
|
132
|
-
(0, common_1.Injectable)(),
|
|
138
|
+
(0, common_1.Injectable)({ scope: common_1.Scope.TRANSIENT }),
|
|
133
139
|
(0, agent_registry_1.RegisterAgent)('anthropic'),
|
|
134
|
-
__param(
|
|
135
|
-
__metadata("design:paramtypes", [String])
|
|
140
|
+
__param(1, (0, common_1.Optional)()),
|
|
141
|
+
__metadata("design:paramtypes", [config_1.ConfigService, String])
|
|
136
142
|
], ClaudeAgent);
|
|
@@ -16,20 +16,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.GeminiAgent = void 0;
|
|
17
17
|
const genai_1 = require("@google/genai");
|
|
18
18
|
const common_1 = require("@nestjs/common");
|
|
19
|
+
const config_1 = require("@nestjs/config");
|
|
19
20
|
const agent_registry_1 = require("../registry/agent.registry");
|
|
20
21
|
let GeminiAgent = GeminiAgent_1 = class GeminiAgent {
|
|
21
|
-
constructor(model = 'gemini-2.5-flash-lite') {
|
|
22
|
+
constructor(configService, model = 'gemini-2.5-flash-lite') {
|
|
23
|
+
this.configService = configService;
|
|
22
24
|
this.logger = new common_1.Logger(GeminiAgent_1.name);
|
|
25
|
+
this.genAI = null;
|
|
23
26
|
this.name = 'GeminiAgent';
|
|
24
27
|
this.provider = 'google';
|
|
25
28
|
this.enableGrounding = true;
|
|
26
29
|
this.model = model;
|
|
27
|
-
|
|
30
|
+
}
|
|
31
|
+
getGenAI() {
|
|
32
|
+
if (this.genAI)
|
|
33
|
+
return this.genAI;
|
|
34
|
+
const apiKey = this.configService.get('GEMINI_API_KEY');
|
|
28
35
|
if (!apiKey) {
|
|
29
36
|
this.logger.error('GEMINI_API_KEY environment variable is not set');
|
|
30
37
|
throw new Error('GEMINI_API_KEY is required to initialize GeminiAgent');
|
|
31
38
|
}
|
|
32
39
|
this.genAI = new genai_1.GoogleGenAI({ apiKey });
|
|
40
|
+
return this.genAI;
|
|
33
41
|
}
|
|
34
42
|
getName() {
|
|
35
43
|
return this.name;
|
|
@@ -74,7 +82,8 @@ let GeminiAgent = GeminiAgent_1 = class GeminiAgent {
|
|
|
74
82
|
if (tools.length > 0) {
|
|
75
83
|
this.logger.debug(`Adding tools to request: ${JSON.stringify(tools)}`);
|
|
76
84
|
}
|
|
77
|
-
const
|
|
85
|
+
const genAI = this.getGenAI();
|
|
86
|
+
const response = await genAI.models.generateContent({
|
|
78
87
|
model: this.model,
|
|
79
88
|
contents,
|
|
80
89
|
config: {
|
|
@@ -172,8 +181,8 @@ Please perform the task and provide the output.
|
|
|
172
181
|
};
|
|
173
182
|
exports.GeminiAgent = GeminiAgent;
|
|
174
183
|
exports.GeminiAgent = GeminiAgent = GeminiAgent_1 = __decorate([
|
|
175
|
-
(0, common_1.Injectable)(),
|
|
184
|
+
(0, common_1.Injectable)({ scope: common_1.Scope.TRANSIENT }),
|
|
176
185
|
(0, agent_registry_1.RegisterAgent)('google'),
|
|
177
|
-
__param(
|
|
178
|
-
__metadata("design:paramtypes", [String])
|
|
186
|
+
__param(1, (0, common_1.Optional)()),
|
|
187
|
+
__metadata("design:paramtypes", [config_1.ConfigService, String])
|
|
179
188
|
], GeminiAgent);
|
package/dist/app.module.js
CHANGED
|
@@ -22,21 +22,34 @@ const users_module_1 = require("./users/users.module");
|
|
|
22
22
|
const common_module_1 = require("./common/common.module");
|
|
23
23
|
const uploads_module_1 = require("./uploads/uploads.module");
|
|
24
24
|
const schedule_1 = require("@nestjs/schedule");
|
|
25
|
+
const config_1 = require("@nestjs/config");
|
|
26
|
+
const env_validation_1 = require("./config/env.validation");
|
|
25
27
|
let AppModule = class AppModule {
|
|
26
28
|
};
|
|
27
29
|
exports.AppModule = AppModule;
|
|
28
30
|
exports.AppModule = AppModule = __decorate([
|
|
29
31
|
(0, common_1.Module)({
|
|
30
32
|
imports: [
|
|
33
|
+
config_1.ConfigModule.forRoot({
|
|
34
|
+
isGlobal: true,
|
|
35
|
+
validationSchema: env_validation_1.envValidationSchema,
|
|
36
|
+
}),
|
|
31
37
|
schedule_1.ScheduleModule.forRoot(),
|
|
32
|
-
typeorm_1.TypeOrmModule.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
typeorm_1.TypeOrmModule.forRootAsync({
|
|
39
|
+
imports: [config_1.ConfigModule],
|
|
40
|
+
inject: [config_1.ConfigService],
|
|
41
|
+
useFactory: (configService) => {
|
|
42
|
+
const databaseUrl = configService.get('DATABASE_URL');
|
|
43
|
+
return {
|
|
44
|
+
type: databaseUrl ? 'postgres' : 'sqlite',
|
|
45
|
+
database: databaseUrl
|
|
46
|
+
? undefined
|
|
47
|
+
: (0, path_1.join)(process.cwd(), 'local.sqlite'),
|
|
48
|
+
url: databaseUrl,
|
|
49
|
+
autoLoadEntities: true,
|
|
50
|
+
synchronize: configService.get('NODE_ENV') !== 'production',
|
|
51
|
+
};
|
|
52
|
+
},
|
|
40
53
|
}),
|
|
41
54
|
serve_static_1.ServeStaticModule.forRoot({
|
|
42
55
|
rootPath: (0, path_1.join)(__dirname, '..', '..', 'ui', 'dist'),
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.envValidationSchema = void 0;
|
|
37
|
+
const Joi = __importStar(require("joi"));
|
|
38
|
+
exports.envValidationSchema = Joi.object({
|
|
39
|
+
PORT: Joi.number().default(3000),
|
|
40
|
+
DATABASE_URL: Joi.string().optional(),
|
|
41
|
+
GEMINI_API_KEY: Joi.string().optional(),
|
|
42
|
+
ANTHROPIC_API_KEY: Joi.string().optional(),
|
|
43
|
+
NODE_ENV: Joi.string()
|
|
44
|
+
.valid('development', 'production', 'test', 'provision')
|
|
45
|
+
.default('development'),
|
|
46
|
+
});
|
|
@@ -12,8 +12,8 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
12
12
|
const agents_controller_1 = require("./agents.controller");
|
|
13
13
|
const agents_service_1 = require("./agents.service");
|
|
14
14
|
const agent_entity_1 = require("./entities/agent.entity");
|
|
15
|
-
require("./implementations/gemini.agent");
|
|
16
|
-
require("./implementations/claude.agent");
|
|
15
|
+
const gemini_agent_1 = require("./implementations/gemini.agent");
|
|
16
|
+
const claude_agent_1 = require("./implementations/claude.agent");
|
|
17
17
|
let AgentsModule = class AgentsModule {
|
|
18
18
|
};
|
|
19
19
|
exports.AgentsModule = AgentsModule;
|
|
@@ -21,7 +21,7 @@ exports.AgentsModule = AgentsModule = __decorate([
|
|
|
21
21
|
(0, common_1.Module)({
|
|
22
22
|
imports: [typeorm_1.TypeOrmModule.forFeature([agent_entity_1.AgentEntity])],
|
|
23
23
|
controllers: [agents_controller_1.AgentsController],
|
|
24
|
-
providers: [agents_service_1.AgentsService],
|
|
24
|
+
providers: [agents_service_1.AgentsService, gemini_agent_1.GeminiAgent, claude_agent_1.ClaudeAgent],
|
|
25
25
|
exports: [agents_service_1.AgentsService],
|
|
26
26
|
})
|
|
27
27
|
], AgentsModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.module.js","sourceRoot":"","sources":["../../../src/agents/agents.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,2DAAuD;AACvD,qDAAiD;AACjD,0DAAsD;
|
|
1
|
+
{"version":3,"file":"agents.module.js","sourceRoot":"","sources":["../../../src/agents/agents.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,2DAAuD;AACvD,qDAAiD;AACjD,0DAAsD;AACtD,iEAA6D;AAC7D,iEAA6D;AAQtD,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IANxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,0BAAW,CAAC,CAAC,CAAC;QAClD,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,8BAAa,EAAE,0BAAW,EAAE,0BAAW,CAAC;QACpD,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -4,11 +4,13 @@ import { AgentEntity } from './entities/agent.entity';
|
|
|
4
4
|
import { CreateAgentDto } from './dto/create-agent.dto';
|
|
5
5
|
import { UpdateAgentDto } from './dto/update-agent.dto';
|
|
6
6
|
import { AgentResponse } from './interfaces/agent.interface';
|
|
7
|
+
import { ModuleRef } from '@nestjs/core';
|
|
7
8
|
export declare class AgentsService implements OnModuleInit {
|
|
8
9
|
private readonly agentRepository;
|
|
10
|
+
private readonly moduleRef;
|
|
9
11
|
private readonly logger;
|
|
10
12
|
private agentInstances;
|
|
11
|
-
constructor(agentRepository: Repository<AgentEntity
|
|
13
|
+
constructor(agentRepository: Repository<AgentEntity>, moduleRef: ModuleRef);
|
|
12
14
|
onModuleInit(): Promise<void>;
|
|
13
15
|
private syncAgentInstance;
|
|
14
16
|
create(createAgentDto: CreateAgentDto): Promise<AgentEntity>;
|
|
@@ -19,13 +19,16 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
19
19
|
const typeorm_2 = require("typeorm");
|
|
20
20
|
const agent_entity_1 = require("./entities/agent.entity");
|
|
21
21
|
const agent_registry_1 = require("./registry/agent.registry");
|
|
22
|
+
const core_1 = require("@nestjs/core");
|
|
22
23
|
const AGENT_RELATIONS = ['model', 'provider'];
|
|
23
24
|
let AgentsService = AgentsService_1 = class AgentsService {
|
|
24
25
|
agentRepository;
|
|
26
|
+
moduleRef;
|
|
25
27
|
logger = new common_1.Logger(AgentsService_1.name);
|
|
26
28
|
agentInstances = new Map();
|
|
27
|
-
constructor(agentRepository) {
|
|
29
|
+
constructor(agentRepository, moduleRef) {
|
|
28
30
|
this.agentRepository = agentRepository;
|
|
31
|
+
this.moduleRef = moduleRef;
|
|
29
32
|
}
|
|
30
33
|
async onModuleInit() {
|
|
31
34
|
this.logger.log('Initializing Agent instances from database...');
|
|
@@ -35,7 +38,7 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
35
38
|
for (const agentEntity of agents) {
|
|
36
39
|
if (agentEntity.status !== 'inactive') {
|
|
37
40
|
try {
|
|
38
|
-
this.syncAgentInstance(agentEntity);
|
|
41
|
+
await this.syncAgentInstance(agentEntity);
|
|
39
42
|
}
|
|
40
43
|
catch (error) {
|
|
41
44
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -45,7 +48,7 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
45
48
|
}
|
|
46
49
|
this.logger.log(`Initialized ${this.agentInstances.size} agent instances.`);
|
|
47
50
|
}
|
|
48
|
-
syncAgentInstance(agentEntity) {
|
|
51
|
+
async syncAgentInstance(agentEntity) {
|
|
49
52
|
if (agentEntity.status === 'inactive') {
|
|
50
53
|
this.agentInstances.delete(agentEntity.id);
|
|
51
54
|
return;
|
|
@@ -61,13 +64,14 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
61
64
|
return;
|
|
62
65
|
}
|
|
63
66
|
try {
|
|
64
|
-
const instance =
|
|
67
|
+
const instance = await this.moduleRef.resolve(AgentClass);
|
|
65
68
|
instance.updateConfig?.({
|
|
66
69
|
name: agentEntity.name,
|
|
67
70
|
description: agentEntity.description,
|
|
68
71
|
systemInstructions: agentEntity.systemInstructions,
|
|
69
72
|
role: agentEntity.role,
|
|
70
73
|
provider: providerName,
|
|
74
|
+
model: agentEntity.model?.name,
|
|
71
75
|
});
|
|
72
76
|
this.agentInstances.set(agentEntity.id, instance);
|
|
73
77
|
this.logger.debug(`Synchronized agent instance #${agentEntity.id}`);
|
|
@@ -97,7 +101,7 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
97
101
|
if (!fullyLoadedAgent) {
|
|
98
102
|
throw new Error(`Agent #${savedAgent.id} not found immediately after save`);
|
|
99
103
|
}
|
|
100
|
-
this.syncAgentInstance(fullyLoadedAgent);
|
|
104
|
+
await this.syncAgentInstance(fullyLoadedAgent);
|
|
101
105
|
return fullyLoadedAgent;
|
|
102
106
|
});
|
|
103
107
|
}
|
|
@@ -132,7 +136,7 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
132
136
|
if (!updatedAgent) {
|
|
133
137
|
throw new common_1.NotFoundException(`Agent #${id} not found`);
|
|
134
138
|
}
|
|
135
|
-
this.syncAgentInstance(updatedAgent);
|
|
139
|
+
await this.syncAgentInstance(updatedAgent);
|
|
136
140
|
return updatedAgent;
|
|
137
141
|
});
|
|
138
142
|
}
|
|
@@ -170,7 +174,7 @@ let AgentsService = AgentsService_1 = class AgentsService {
|
|
|
170
174
|
if (agentEntity.status === 'inactive') {
|
|
171
175
|
throw new common_1.NotFoundException(`Agent #${agentId} is currently inactive and cannot be probed.`);
|
|
172
176
|
}
|
|
173
|
-
this.syncAgentInstance(agentEntity);
|
|
177
|
+
await this.syncAgentInstance(agentEntity);
|
|
174
178
|
agent = this.agentInstances.get(agentId);
|
|
175
179
|
if (!agent) {
|
|
176
180
|
throw new common_1.NotFoundException(`Failed to initialize agent #${agentId} after database fetch`);
|
|
@@ -183,6 +187,7 @@ exports.AgentsService = AgentsService;
|
|
|
183
187
|
exports.AgentsService = AgentsService = AgentsService_1 = __decorate([
|
|
184
188
|
(0, common_1.Injectable)(),
|
|
185
189
|
__param(0, (0, typeorm_1.InjectRepository)(agent_entity_1.AgentEntity)),
|
|
186
|
-
__metadata("design:paramtypes", [typeorm_2.Repository
|
|
190
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
191
|
+
core_1.ModuleRef])
|
|
187
192
|
], AgentsService);
|
|
188
193
|
//# sourceMappingURL=agents.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.service.js","sourceRoot":"","sources":["../../../src/agents/agents.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAMwB;AACxB,6CAAmD;AACnD,qCAAkD;AAClD,0DAAsD;AAItD,8DAAmE;
|
|
1
|
+
{"version":3,"file":"agents.service.js","sourceRoot":"","sources":["../../../src/agents/agents.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAMwB;AACxB,6CAAmD;AACnD,qCAAkD;AAClD,0DAAsD;AAItD,8DAAmE;AAGnE,uCAAyC;AAEzC,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAGvC,IAAM,aAAa,qBAAnB,MAAM,aAAa;IAML;IACA;IANF,MAAM,GAAG,IAAI,eAAM,CAAC,eAAa,CAAC,IAAI,CAAC,CAAC;IACjD,cAAc,GAAuB,IAAI,GAAG,EAAE,CAAC;IAEvD,YAEmB,eAAwC,EACxC,SAAoB;QADpB,oBAAe,GAAf,eAAe,CAAyB;QACxC,cAAS,GAAT,SAAS,CAAW;IACpC,CAAC;IAEJ,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;QACjE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;YAC7C,SAAS,EAAE,eAAe;SAC3B,CAAC,CAAC;QACH,KAAK,MAAM,WAAW,IAAI,MAAM,EAAE,CAAC;YACjC,IAAI,WAAW,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBACtC,IAAI,CAAC;oBACH,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;gBAC5C,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACzD,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,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AMR,WAAA,IAAA,0BAAgB,EAAC,0BAAW,CAAC,CAAA;qCACI,oBAAU;QAChB,gBAAS;GAP5B,aAAa,CAgOzB"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Agent, AgentResponse } from '../interfaces/agent.interface';
|
|
2
2
|
import { Task } from '../../tasks/entities/task.entity';
|
|
3
3
|
import { Project } from '../../projects/entities/project.entity';
|
|
4
|
+
import { ConfigService } from '@nestjs/config';
|
|
4
5
|
export declare class ClaudeAgent implements Agent {
|
|
6
|
+
private readonly configService;
|
|
5
7
|
private readonly logger;
|
|
6
8
|
private name;
|
|
7
9
|
private description?;
|
|
@@ -9,7 +11,8 @@ export declare class ClaudeAgent implements Agent {
|
|
|
9
11
|
private role?;
|
|
10
12
|
private provider;
|
|
11
13
|
private model;
|
|
12
|
-
constructor(model?: string);
|
|
14
|
+
constructor(configService: ConfigService, model?: string);
|
|
15
|
+
private validateApiKey;
|
|
13
16
|
getName(): string;
|
|
14
17
|
getDescription(): string;
|
|
15
18
|
getSystemInstructions(): string;
|
|
@@ -16,8 +16,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.ClaudeAgent = void 0;
|
|
17
17
|
const claude_agent_sdk_1 = require("@anthropic-ai/claude-agent-sdk");
|
|
18
18
|
const common_1 = require("@nestjs/common");
|
|
19
|
+
const config_1 = require("@nestjs/config");
|
|
19
20
|
const agent_registry_1 = require("../registry/agent.registry");
|
|
20
21
|
let ClaudeAgent = ClaudeAgent_1 = class ClaudeAgent {
|
|
22
|
+
configService;
|
|
21
23
|
logger = new common_1.Logger(ClaudeAgent_1.name);
|
|
22
24
|
name = 'ClaudeAgent';
|
|
23
25
|
description;
|
|
@@ -25,13 +27,17 @@ let ClaudeAgent = ClaudeAgent_1 = class ClaudeAgent {
|
|
|
25
27
|
role;
|
|
26
28
|
provider = 'anthropic';
|
|
27
29
|
model;
|
|
28
|
-
constructor(model = 'claude-opus-4-6') {
|
|
30
|
+
constructor(configService, model = 'claude-opus-4-6') {
|
|
31
|
+
this.configService = configService;
|
|
29
32
|
this.model = model;
|
|
30
|
-
|
|
33
|
+
}
|
|
34
|
+
validateApiKey() {
|
|
35
|
+
const apiKey = this.configService.get('ANTHROPIC_API_KEY');
|
|
31
36
|
if (!apiKey) {
|
|
32
37
|
this.logger.error('ANTHROPIC_API_KEY environment variable is not set');
|
|
33
38
|
throw new Error('ANTHROPIC_API_KEY is required to initialize ClaudeAgent');
|
|
34
39
|
}
|
|
40
|
+
return apiKey;
|
|
35
41
|
}
|
|
36
42
|
getName() {
|
|
37
43
|
return this.name;
|
|
@@ -78,6 +84,7 @@ let ClaudeAgent = ClaudeAgent_1 = class ClaudeAgent {
|
|
|
78
84
|
.join('\n');
|
|
79
85
|
}
|
|
80
86
|
async processText(input) {
|
|
87
|
+
this.validateApiKey();
|
|
81
88
|
this.logger.debug(`Processing input with ClaudeAgent. Model: ${this.model}`);
|
|
82
89
|
try {
|
|
83
90
|
const systemPrompt = this.buildSystemPrompt();
|
|
@@ -133,9 +140,9 @@ Please perform the task and provide the output.
|
|
|
133
140
|
};
|
|
134
141
|
exports.ClaudeAgent = ClaudeAgent;
|
|
135
142
|
exports.ClaudeAgent = ClaudeAgent = ClaudeAgent_1 = __decorate([
|
|
136
|
-
(0, common_1.Injectable)(),
|
|
143
|
+
(0, common_1.Injectable)({ scope: common_1.Scope.TRANSIENT }),
|
|
137
144
|
(0, agent_registry_1.RegisterAgent)('anthropic'),
|
|
138
|
-
__param(
|
|
139
|
-
__metadata("design:paramtypes", [String])
|
|
145
|
+
__param(1, (0, common_1.Optional)()),
|
|
146
|
+
__metadata("design:paramtypes", [config_1.ConfigService, String])
|
|
140
147
|
], ClaudeAgent);
|
|
141
148
|
//# sourceMappingURL=claude.agent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.agent.js","sourceRoot":"","sources":["../../../../src/agents/implementations/claude.agent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAAmE;AAEnE,
|
|
1
|
+
{"version":3,"file":"claude.agent.js","sourceRoot":"","sources":["../../../../src/agents/implementations/claude.agent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAAmE;AAEnE,2CAAqE;AAGrE,2CAA+C;AAE/C,+DAA2D;AAIpD,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAUH;IATF,MAAM,GAAG,IAAI,eAAM,CAAC,aAAW,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,GAAW,aAAa,CAAC;IAC7B,WAAW,CAAU;IACrB,kBAAkB,CAAU;IAC5B,IAAI,CAAU;IACd,QAAQ,GAAW,WAAW,CAAC;IAC/B,KAAK,CAAS;IAEtB,YACmB,aAA4B,EACjC,QAAgB,iBAAiB;QAD5B,kBAAa,GAAb,aAAa,CAAe;QAG7C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAEO,cAAc;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,mBAAmB,CAAC,CAAC;QACnE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;YACvE,MAAM,IAAI,KAAK,CACb,yDAAyD,CAC1D,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,qBAAqB;QACnB,OAAO,IAAI,CAAC,kBAAkB,IAAI,EAAE,CAAC;IACvC,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,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oB,IAAI,CAAC,KAAK,iBAAiB,OAAO,CAAC,KAAK,EAAE,CAC/D,CAAC;QACF,MAAM,MAAM,GAAG;QACX,IAAI,CAAC,KAAK;eACH,IAAI,CAAC,WAAW;WACpB,OAAO,CAAC,KAAK;uBACD,OAAO,CAAC,WAAW;;;CAGzC,CAAC;QACE,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CACF,CAAA;AAzIY,kCAAW;sBAAX,WAAW;IAFvB,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,SAAS,EAAE,CAAC;IACtC,IAAA,8BAAa,EAAC,WAAW,CAAC;IAYtB,WAAA,IAAA,iBAAQ,GAAE,CAAA;qCADqB,sBAAa;GAVpC,WAAW,CAyIvB"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Agent, AgentResponse } from '../interfaces/agent.interface';
|
|
2
2
|
import { Task } from '../../tasks/entities/task.entity';
|
|
3
3
|
import { Project } from '../../projects/entities/project.entity';
|
|
4
|
+
import { ConfigService } from '@nestjs/config';
|
|
4
5
|
export declare class GeminiAgent implements Agent {
|
|
6
|
+
private readonly configService;
|
|
5
7
|
private readonly logger;
|
|
6
8
|
private genAI;
|
|
7
9
|
private name;
|
|
@@ -11,7 +13,8 @@ export declare class GeminiAgent implements Agent {
|
|
|
11
13
|
private provider;
|
|
12
14
|
private model;
|
|
13
15
|
private enableGrounding;
|
|
14
|
-
constructor(model?: string);
|
|
16
|
+
constructor(configService: ConfigService, model?: string);
|
|
17
|
+
private getGenAI;
|
|
15
18
|
getName(): string;
|
|
16
19
|
getDescription(): string;
|
|
17
20
|
getSystemInstructions(): string;
|