Spaces:
Paused
Paused
Deploy from GitHub Actions 2025-12-16_02-53-01
Browse files
apps/backend/src/services/NudgeService.ts
CHANGED
|
@@ -57,7 +57,7 @@ class NudgeService {
|
|
| 57 |
|
| 58 |
// Initial nudge after 30 seconds
|
| 59 |
setTimeout(() => this.runNudgeCycle(), 30000);
|
| 60 |
-
|
| 61 |
// Also run a mini-nudge every 5 minutes for basic stats
|
| 62 |
cron.schedule('*/5 * * * *', async () => {
|
| 63 |
await this.miniNudge();
|
|
@@ -139,7 +139,7 @@ class NudgeService {
|
|
| 139 |
|
| 140 |
private async captureSystemMetrics() {
|
| 141 |
console.log('π [1/6] Capturing system metrics...');
|
| 142 |
-
|
| 143 |
try {
|
| 144 |
const [cpu, mem, osInfo, currentLoad, disk, network] = await Promise.all([
|
| 145 |
si.cpu(),
|
|
@@ -206,7 +206,7 @@ class NudgeService {
|
|
| 206 |
|
| 207 |
private async captureProcessSnapshot() {
|
| 208 |
console.log('π [2/6] Capturing process snapshot...');
|
| 209 |
-
|
| 210 |
try {
|
| 211 |
const data = await si.processes();
|
| 212 |
const topProcesses = data.list
|
|
@@ -246,7 +246,7 @@ class NudgeService {
|
|
| 246 |
|
| 247 |
private async triggerGraphEvolution() {
|
| 248 |
console.log('𧬠[3/6] Triggering graph evolution...');
|
| 249 |
-
|
| 250 |
try {
|
| 251 |
if (this.neo4jAdapter) {
|
| 252 |
// Get current graph stats
|
|
@@ -289,9 +289,9 @@ class NudgeService {
|
|
| 289 |
|
| 290 |
private async pingAgents() {
|
| 291 |
console.log('π€ [4/6] Pinging agents...');
|
| 292 |
-
|
| 293 |
const agents = ['HansPedder', 'GraphRAG', 'System', 'OmniHarvester'];
|
| 294 |
-
|
| 295 |
for (const agent of agents) {
|
| 296 |
eventBus.emitEvent({
|
| 297 |
type: 'agent.ping',
|
|
@@ -307,7 +307,7 @@ class NudgeService {
|
|
| 307 |
|
| 308 |
private async emitActivityEvents() {
|
| 309 |
console.log('π‘ [5/6] Emitting activity events...');
|
| 310 |
-
|
| 311 |
const events = [
|
| 312 |
{ type: 'nudge.cycle_complete', payload: { cycle: this.stats.totalRuns + 1 } },
|
| 313 |
{ type: 'system.activity', payload: { source: 'NudgeService', active: true } },
|
|
@@ -329,10 +329,11 @@ class NudgeService {
|
|
| 329 |
|
| 330 |
private async triggerKnowledgeCompilation() {
|
| 331 |
console.log('π§ [6/6] Triggering knowledge compilation...');
|
| 332 |
-
|
| 333 |
try {
|
| 334 |
// Trigger compilation via HTTP to self
|
| 335 |
-
const
|
|
|
|
| 336 |
method: 'POST',
|
| 337 |
headers: { 'Content-Type': 'application/json' }
|
| 338 |
}).catch(() => null);
|
|
|
|
| 57 |
|
| 58 |
// Initial nudge after 30 seconds
|
| 59 |
setTimeout(() => this.runNudgeCycle(), 30000);
|
| 60 |
+
|
| 61 |
// Also run a mini-nudge every 5 minutes for basic stats
|
| 62 |
cron.schedule('*/5 * * * *', async () => {
|
| 63 |
await this.miniNudge();
|
|
|
|
| 139 |
|
| 140 |
private async captureSystemMetrics() {
|
| 141 |
console.log('π [1/6] Capturing system metrics...');
|
| 142 |
+
|
| 143 |
try {
|
| 144 |
const [cpu, mem, osInfo, currentLoad, disk, network] = await Promise.all([
|
| 145 |
si.cpu(),
|
|
|
|
| 206 |
|
| 207 |
private async captureProcessSnapshot() {
|
| 208 |
console.log('π [2/6] Capturing process snapshot...');
|
| 209 |
+
|
| 210 |
try {
|
| 211 |
const data = await si.processes();
|
| 212 |
const topProcesses = data.list
|
|
|
|
| 246 |
|
| 247 |
private async triggerGraphEvolution() {
|
| 248 |
console.log('𧬠[3/6] Triggering graph evolution...');
|
| 249 |
+
|
| 250 |
try {
|
| 251 |
if (this.neo4jAdapter) {
|
| 252 |
// Get current graph stats
|
|
|
|
| 289 |
|
| 290 |
private async pingAgents() {
|
| 291 |
console.log('π€ [4/6] Pinging agents...');
|
| 292 |
+
|
| 293 |
const agents = ['HansPedder', 'GraphRAG', 'System', 'OmniHarvester'];
|
| 294 |
+
|
| 295 |
for (const agent of agents) {
|
| 296 |
eventBus.emitEvent({
|
| 297 |
type: 'agent.ping',
|
|
|
|
| 307 |
|
| 308 |
private async emitActivityEvents() {
|
| 309 |
console.log('π‘ [5/6] Emitting activity events...');
|
| 310 |
+
|
| 311 |
const events = [
|
| 312 |
{ type: 'nudge.cycle_complete', payload: { cycle: this.stats.totalRuns + 1 } },
|
| 313 |
{ type: 'system.activity', payload: { source: 'NudgeService', active: true } },
|
|
|
|
| 329 |
|
| 330 |
private async triggerKnowledgeCompilation() {
|
| 331 |
console.log('π§ [6/6] Triggering knowledge compilation...');
|
| 332 |
+
|
| 333 |
try {
|
| 334 |
// Trigger compilation via HTTP to self
|
| 335 |
+
const port = process.env.PORT || 3001;
|
| 336 |
+
const response = await fetch(`http://localhost:${port}/api/knowledge/compile`, {
|
| 337 |
method: 'POST',
|
| 338 |
headers: { 'Content-Type': 'application/json' }
|
| 339 |
}).catch(() => null);
|
apps/backend/src/services/agent/HansPedderAgentController.ts
CHANGED
|
@@ -240,7 +240,8 @@ export class HansPedderAgentController {
|
|
| 240 |
|
| 241 |
try {
|
| 242 |
// Check if MCP tools endpoint responds (indicates server is ready)
|
| 243 |
-
const
|
|
|
|
| 244 |
const response = await fetch(`${baseUrl}/api/mcp/tools`, {
|
| 245 |
method: 'GET',
|
| 246 |
signal: AbortSignal.timeout(3000),
|
|
@@ -275,7 +276,8 @@ export class HansPedderAgentController {
|
|
| 275 |
|
| 276 |
try {
|
| 277 |
// Test key API endpoints (use port 3001 where backend runs)
|
| 278 |
-
const
|
|
|
|
| 279 |
const endpoints = [
|
| 280 |
{ url: `${baseUrl}/health`, method: 'GET' },
|
| 281 |
{ url: `${baseUrl}/api/mcp/route`, method: 'POST', body: JSON.stringify({ tool: 'ping' }) },
|
|
|
|
| 240 |
|
| 241 |
try {
|
| 242 |
// Check if MCP tools endpoint responds (indicates server is ready)
|
| 243 |
+
const port = process.env.PORT || 3001;
|
| 244 |
+
const baseUrl = process.env.API_BASE_URL || `http://localhost:${port}`;
|
| 245 |
const response = await fetch(`${baseUrl}/api/mcp/tools`, {
|
| 246 |
method: 'GET',
|
| 247 |
signal: AbortSignal.timeout(3000),
|
|
|
|
| 276 |
|
| 277 |
try {
|
| 278 |
// Test key API endpoints (use port 3001 where backend runs)
|
| 279 |
+
const port = process.env.PORT || 3001;
|
| 280 |
+
const baseUrl = process.env.API_BASE_URL || `http://localhost:${port}`;
|
| 281 |
const endpoints = [
|
| 282 |
{ url: `${baseUrl}/health`, method: 'GET' },
|
| 283 |
{ url: `${baseUrl}/api/mcp/route`, method: 'POST', body: JSON.stringify({ tool: 'ping' }) },
|