@blackms/aistack 1.0.13 → 1.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.
Files changed (113) hide show
  1. package/README.md +16 -0
  2. package/dist/cli/commands/index.d.ts +1 -0
  3. package/dist/cli/commands/index.d.ts.map +1 -1
  4. package/dist/cli/commands/index.js +1 -0
  5. package/dist/cli/commands/index.js.map +1 -1
  6. package/dist/cli/commands/web.d.ts +6 -0
  7. package/dist/cli/commands/web.d.ts.map +1 -0
  8. package/dist/cli/commands/web.js +79 -0
  9. package/dist/cli/commands/web.js.map +1 -0
  10. package/dist/cli/index.js +2 -1
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +2 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/memory/index.d.ts +23 -1
  17. package/dist/memory/index.d.ts.map +1 -1
  18. package/dist/memory/index.js +54 -0
  19. package/dist/memory/index.js.map +1 -1
  20. package/dist/memory/sqlite-store.d.ts +26 -1
  21. package/dist/memory/sqlite-store.d.ts.map +1 -1
  22. package/dist/memory/sqlite-store.js +356 -0
  23. package/dist/memory/sqlite-store.js.map +1 -1
  24. package/dist/types.d.ts +56 -0
  25. package/dist/types.d.ts.map +1 -1
  26. package/dist/types.js +9 -0
  27. package/dist/types.js.map +1 -1
  28. package/dist/utils/validation.d.ts +2 -2
  29. package/dist/web/index.d.ts +8 -0
  30. package/dist/web/index.d.ts.map +1 -0
  31. package/dist/web/index.js +8 -0
  32. package/dist/web/index.js.map +1 -0
  33. package/dist/web/middleware/auth.d.ts +21 -0
  34. package/dist/web/middleware/auth.d.ts.map +1 -0
  35. package/dist/web/middleware/auth.js +31 -0
  36. package/dist/web/middleware/auth.js.map +1 -0
  37. package/dist/web/middleware/cors.d.ts +7 -0
  38. package/dist/web/middleware/cors.d.ts.map +1 -0
  39. package/dist/web/middleware/cors.js +28 -0
  40. package/dist/web/middleware/cors.js.map +1 -0
  41. package/dist/web/middleware/error.d.ts +16 -0
  42. package/dist/web/middleware/error.d.ts.map +1 -0
  43. package/dist/web/middleware/error.js +51 -0
  44. package/dist/web/middleware/error.js.map +1 -0
  45. package/dist/web/middleware/index.d.ts +7 -0
  46. package/dist/web/middleware/index.d.ts.map +1 -0
  47. package/dist/web/middleware/index.js +7 -0
  48. package/dist/web/middleware/index.js.map +1 -0
  49. package/dist/web/router.d.ts +40 -0
  50. package/dist/web/router.d.ts.map +1 -0
  51. package/dist/web/router.js +162 -0
  52. package/dist/web/router.js.map +1 -0
  53. package/dist/web/routes/agents.d.ts +7 -0
  54. package/dist/web/routes/agents.d.ts.map +1 -0
  55. package/dist/web/routes/agents.js +182 -0
  56. package/dist/web/routes/agents.js.map +1 -0
  57. package/dist/web/routes/filesystem.d.ts +7 -0
  58. package/dist/web/routes/filesystem.d.ts.map +1 -0
  59. package/dist/web/routes/filesystem.js +212 -0
  60. package/dist/web/routes/filesystem.js.map +1 -0
  61. package/dist/web/routes/index.d.ts +13 -0
  62. package/dist/web/routes/index.d.ts.map +1 -0
  63. package/dist/web/routes/index.js +13 -0
  64. package/dist/web/routes/index.js.map +1 -0
  65. package/dist/web/routes/memory.d.ts +7 -0
  66. package/dist/web/routes/memory.d.ts.map +1 -0
  67. package/dist/web/routes/memory.js +146 -0
  68. package/dist/web/routes/memory.js.map +1 -0
  69. package/dist/web/routes/projects.d.ts +7 -0
  70. package/dist/web/routes/projects.d.ts.map +1 -0
  71. package/dist/web/routes/projects.js +296 -0
  72. package/dist/web/routes/projects.js.map +1 -0
  73. package/dist/web/routes/sessions.d.ts +7 -0
  74. package/dist/web/routes/sessions.d.ts.map +1 -0
  75. package/dist/web/routes/sessions.js +75 -0
  76. package/dist/web/routes/sessions.js.map +1 -0
  77. package/dist/web/routes/specifications.d.ts +7 -0
  78. package/dist/web/routes/specifications.d.ts.map +1 -0
  79. package/dist/web/routes/specifications.js +267 -0
  80. package/dist/web/routes/specifications.js.map +1 -0
  81. package/dist/web/routes/system.d.ts +7 -0
  82. package/dist/web/routes/system.d.ts.map +1 -0
  83. package/dist/web/routes/system.js +147 -0
  84. package/dist/web/routes/system.js.map +1 -0
  85. package/dist/web/routes/tasks.d.ts +7 -0
  86. package/dist/web/routes/tasks.d.ts.map +1 -0
  87. package/dist/web/routes/tasks.js +188 -0
  88. package/dist/web/routes/tasks.js.map +1 -0
  89. package/dist/web/routes/workflows.d.ts +7 -0
  90. package/dist/web/routes/workflows.d.ts.map +1 -0
  91. package/dist/web/routes/workflows.js +132 -0
  92. package/dist/web/routes/workflows.js.map +1 -0
  93. package/dist/web/server.d.ts +49 -0
  94. package/dist/web/server.d.ts.map +1 -0
  95. package/dist/web/server.js +236 -0
  96. package/dist/web/server.js.map +1 -0
  97. package/dist/web/types.d.ts +191 -0
  98. package/dist/web/types.d.ts.map +1 -0
  99. package/dist/web/types.js +5 -0
  100. package/dist/web/types.js.map +1 -0
  101. package/dist/web/websocket/event-bridge.d.ts +115 -0
  102. package/dist/web/websocket/event-bridge.d.ts.map +1 -0
  103. package/dist/web/websocket/event-bridge.js +138 -0
  104. package/dist/web/websocket/event-bridge.js.map +1 -0
  105. package/dist/web/websocket/handler.d.ts +23 -0
  106. package/dist/web/websocket/handler.d.ts.map +1 -0
  107. package/dist/web/websocket/handler.js +282 -0
  108. package/dist/web/websocket/handler.js.map +1 -0
  109. package/dist/web/websocket/index.d.ts +6 -0
  110. package/dist/web/websocket/index.d.ts.map +1 -0
  111. package/dist/web/websocket/index.js +6 -0
  112. package/dist/web/websocket/index.js.map +1 -0
  113. package/package.json +6 -2
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Workflow routes
3
+ */
4
+ import type { AgentStackConfig } from '../../types.js';
5
+ import type { Router } from '../router.js';
6
+ export declare function registerWorkflowRoutes(router: Router, _config: AgentStackConfig): void;
7
+ //# sourceMappingURL=workflows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../../src/web/routes/workflows.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAgB3C,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CA8ItF"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Workflow routes
3
+ */
4
+ import { sendJson } from '../router.js';
5
+ import { badRequest, notFound } from '../middleware/error.js';
6
+ import { getWorkflowRunner, docSyncConfig } from '../../workflows/index.js';
7
+ import { agentEvents } from '../websocket/event-bridge.js';
8
+ // Track running workflows
9
+ const runningWorkflows = new Map();
10
+ export function registerWorkflowRoutes(router, _config) {
11
+ // GET /api/v1/workflows - List available workflows
12
+ router.get('/api/v1/workflows', (_req, res) => {
13
+ // List built-in workflows
14
+ const workflows = [
15
+ {
16
+ id: 'doc-sync',
17
+ name: 'Documentation Sync',
18
+ description: 'Synchronize documentation with codebase implementation',
19
+ phases: docSyncConfig.phases,
20
+ },
21
+ ];
22
+ sendJson(res, workflows);
23
+ });
24
+ // POST /api/v1/workflows - Launch workflow
25
+ router.post('/api/v1/workflows', async (_req, res, params) => {
26
+ const body = params.body;
27
+ if (!body?.workflow) {
28
+ throw badRequest('Workflow name is required');
29
+ }
30
+ const runner = getWorkflowRunner();
31
+ // Prepare workflow config based on name
32
+ let workflowConfig;
33
+ switch (body.workflow) {
34
+ case 'doc-sync':
35
+ workflowConfig = {
36
+ ...docSyncConfig,
37
+ ...body.config,
38
+ };
39
+ break;
40
+ default:
41
+ throw badRequest(`Unknown workflow: ${body.workflow}`);
42
+ }
43
+ const workflowId = `wf-${Date.now()}`;
44
+ // Track the workflow
45
+ runningWorkflows.set(workflowId, {
46
+ id: workflowId,
47
+ workflow: body.workflow,
48
+ startedAt: new Date(),
49
+ status: 'running',
50
+ });
51
+ // Emit start event
52
+ agentEvents.emit('workflow:start', {
53
+ workflowId,
54
+ config: workflowConfig,
55
+ });
56
+ // Wire up event handlers
57
+ runner.on('phase:start', (phase) => {
58
+ agentEvents.emit('workflow:phase', {
59
+ workflowId,
60
+ phase,
61
+ status: 'started',
62
+ });
63
+ });
64
+ runner.on('phase:complete', (result) => {
65
+ agentEvents.emit('workflow:phase', {
66
+ workflowId,
67
+ phase: result.phase,
68
+ status: 'completed',
69
+ });
70
+ });
71
+ runner.on('finding', (finding) => {
72
+ agentEvents.emit('workflow:finding', {
73
+ workflowId,
74
+ finding,
75
+ });
76
+ });
77
+ // Run workflow asynchronously
78
+ runner.run(workflowConfig)
79
+ .then((report) => {
80
+ const workflow = runningWorkflows.get(workflowId);
81
+ if (workflow) {
82
+ workflow.status = 'completed';
83
+ workflow.report = report;
84
+ }
85
+ agentEvents.emit('workflow:complete', {
86
+ workflowId,
87
+ report,
88
+ });
89
+ })
90
+ .catch((error) => {
91
+ const workflow = runningWorkflows.get(workflowId);
92
+ if (workflow) {
93
+ workflow.status = 'failed';
94
+ workflow.report = { error: error instanceof Error ? error.message : 'Unknown error' };
95
+ }
96
+ agentEvents.emit('workflow:error', {
97
+ workflowId,
98
+ error: error instanceof Error ? error.message : 'Unknown error',
99
+ });
100
+ });
101
+ sendJson(res, {
102
+ workflowId,
103
+ workflow: body.workflow,
104
+ status: 'running',
105
+ startedAt: new Date().toISOString(),
106
+ }, 202);
107
+ });
108
+ // GET /api/v1/workflows/running - List running workflows
109
+ router.get('/api/v1/workflows/running', (_req, res) => {
110
+ const workflows = Array.from(runningWorkflows.values()).map(w => ({
111
+ ...w,
112
+ startedAt: w.startedAt.toISOString(),
113
+ }));
114
+ sendJson(res, workflows);
115
+ });
116
+ // GET /api/v1/workflows/:id - Get workflow status/report
117
+ router.get('/api/v1/workflows/:id', (_req, res, params) => {
118
+ const workflowId = params.path[0];
119
+ if (!workflowId) {
120
+ throw badRequest('Workflow ID is required');
121
+ }
122
+ const workflow = runningWorkflows.get(workflowId);
123
+ if (!workflow) {
124
+ throw notFound('Workflow');
125
+ }
126
+ sendJson(res, {
127
+ ...workflow,
128
+ startedAt: workflow.startedAt.toISOString(),
129
+ });
130
+ });
131
+ }
132
+ //# sourceMappingURL=workflows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../../src/web/routes/workflows.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAA2C,MAAM,0BAA0B,CAAC;AACrH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,0BAA0B;AAC1B,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAM5B,CAAC;AAEL,MAAM,UAAU,sBAAsB,CAAC,MAAc,EAAE,OAAyB;IAC9E,mDAAmD;IACnD,MAAM,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QAC5C,0BAA0B;QAC1B,MAAM,SAAS,GAAG;YAChB;gBACE,EAAE,EAAE,UAAU;gBACd,IAAI,EAAE,oBAAoB;gBAC1B,WAAW,EAAE,wDAAwD;gBACrE,MAAM,EAAE,aAAa,CAAC,MAAM;aAC7B;SACF,CAAC;QAEF,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,2CAA2C;IAC3C,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;QAC3D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAyC,CAAC;QAE9D,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC;YACpB,MAAM,UAAU,CAAC,2BAA2B,CAAC,C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,CAAC;IACV,CAAC,CAAC,CAAC;IAEH,yDAAyD;IACzD,MAAM,CAAC,GAAG,CAAC,2BAA2B,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QACpD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAChE,GAAG,CAAC;YACJ,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE;SACrC,CAAC,CAAC,CAAC;QAEJ,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,yDAAyD;IACzD,MAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;QACxD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,UAAU,CAAC,yBAAyB,CAAC,CAAC;QAC9C,CAAC;QAED,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC7B,CAAC;QAED,QAAQ,CAAC,GAAG,EAAE;YACZ,GAAG,QAAQ;YACX,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Web server - HTTP + WebSocket server for AgentStack
3
+ */
4
+ import type { AgentStackConfig } from '../types.js';
5
+ import type { WebConfig } from './types.js';
6
+ export declare const defaultWebConfig: WebConfig;
7
+ export declare class WebServer {
8
+ private server;
9
+ private router;
10
+ private config;
11
+ private webConfig;
12
+ private corsMiddleware;
13
+ constructor(config: AgentStackConfig, webConfig?: Partial<WebConfig>);
14
+ private setupRoutes;
15
+ /**
16
+ * Start the server
17
+ */
18
+ start(): Promise<void>;
19
+ /**
20
+ * Stop the server
21
+ */
22
+ stop(): Promise<void>;
23
+ /**
24
+ * Serve static files from the frontend build
25
+ */
26
+ private serveStatic;
27
+ /**
28
+ * Get server status
29
+ */
30
+ getStatus(): {
31
+ running: boolean;
32
+ host: string;
33
+ port: number;
34
+ wsClients: number;
35
+ };
36
+ }
37
+ /**
38
+ * Start the web server
39
+ */
40
+ export declare function startWebServer(config: AgentStackConfig, webConfig?: Partial<WebConfig>): Promise<WebServer>;
41
+ /**
42
+ * Stop the web server
43
+ */
44
+ export declare function stopWebServer(): Promise<void>;
45
+ /**
46
+ * Get the web server instance
47
+ */
48
+ export declare function getWebServer(): WebServer | null;
49
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/web/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAiBpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C,eAAO,MAAM,gBAAgB,EAAE,SAO9B,CAAC;AAEF,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,cAAc,CAA0C;gBAEpD,MAAM,EAAE,gBAAgB,EAAE,SAAS,GAAE,OAAO,CAAC,SAAS,CAAM;IASxE,OAAO,CAAC,WAAW;IAgCnB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmD5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB3B;;OAEG;YACW,WAAW;IAqEzB;;OAEG;IACH,SAAS,IAAI;QACX,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB;CAQF;AAKD;;GAEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,gBAAgB,EACxB,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAC7B,OAAO,CAAC,SAAS,CAAC,CASpB;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAKnD;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAE/C"}
@@ -0,0 +1,236 @@
1
+ /**
2
+ * Web server - HTTP + WebSocket server for AgentStack
3
+ */
4
+ import * as http from 'node:http';
5
+ import * as fs from 'node:fs';
6
+ import * as path from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { logger } from '../utils/logger.js';
9
+ import { Router, sendJson, sendError } from './router.js';
10
+ import { createCorsMiddleware } from './middleware/cors.js';
11
+ import { handleError } from './middleware/error.js';
12
+ import { handleWebSocketUpgrade, closeAllConnections, getClientCount } from './websocket/handler.js';
13
+ import { registerAgentRoutes, registerMemoryRoutes, registerTaskRoutes, registerSessionRoutes, registerWorkflowRoutes, registerSystemRoutes, registerProjectRoutes, registerSpecificationRoutes, registerFilesystemRoutes, } from './routes/index.js';
14
+ const log = logger.child('web:server');
15
+ // Default web configuration
16
+ export const defaultWebConfig = {
17
+ enabled: true,
18
+ port: 3001,
19
+ host: 'localhost',
20
+ cors: {
21
+ origins: ['http://localhost:5174', 'http://localhost:5173', 'http://localhost:3000'],
22
+ },
23
+ };
24
+ export class WebServer {
25
+ server = null;
26
+ router;
27
+ config;
28
+ webConfig;
29
+ corsMiddleware;
30
+ constructor(config, webConfig = {}) {
31
+ this.config = config;
32
+ this.webConfig = { ...defaultWebConfig, ...webConfig };
33
+ this.router = new Router();
34
+ this.corsMiddleware = createCorsMiddleware(this.webConfig);
35
+ this.setupRoutes();
36
+ }
37
+ setupRoutes() {
38
+ // API routes
39
+ registerAgentRoutes(this.router, this.config);
40
+ registerMemoryRoutes(this.router, this.config);
41
+ registerTaskRoutes(this.router, this.config);
42
+ registerSessionRoutes(this.router, this.config);
43
+ registerWorkflowRoutes(this.router, this.config);
44
+ registerSystemRoutes(this.router, this.config);
45
+ registerProjectRoutes(this.router, this.config);
46
+ registerSpecificationRoutes(this.router, this.config);
47
+ registerFilesystemRoutes(this.router, this.config);
48
+ // Root endpoint
49
+ this.router.get('/api/v1', (_req, res) => {
50
+ sendJson(res, {
51
+ name: 'AgentStack Web API',
52
+ version: '1.0.0',
53
+ endpoints: [
54
+ '/api/v1/agents',
55
+ '/api/v1/memory',
56
+ '/api/v1/tasks',
57
+ '/api/v1/sessions',
58
+ '/api/v1/workflows',
59
+ '/api/v1/system',
60
+ '/api/v1/projects',
61
+ '/api/v1/specs',
62
+ '/api/v1/filesystem',
63
+ ],
64
+ });
65
+ });
66
+ }
67
+ /**
68
+ * Start the server
69
+ */
70
+ async start() {
71
+ return new Promise((resolve, reject) => {
72
+ this.server = http.createServer(async (req, res) => {
73
+ try {
74
+ // CORS handling
75
+ if (this.corsMiddleware(req, res)) {
76
+ return; // Preflight handled
77
+ }
78
+ // Try to handle with router
79
+ const handled = await this.router.handle(req, res);
80
+ if (!handled) {
81
+ // Try to serve static files for frontend
82
+ const staticServed = await this.serveStatic(req, res);
83
+ if (!staticServed) {
84
+ sendError(res, 404, 'Not found');
85
+ }
86
+ }
87
+ }
88
+ catch (error) {
89
+ handleError(res, error);
90
+ }
91
+ });
92
+ // Handle WebSocket upgrade
93
+ this.server.on('upgrade', (req, socket, head) => {
94
+ const url = req.url || '';
95
+ if (url === '/ws' || url.startsWith('/ws?')) {
96
+ handleWebSocketUpgrade(req, socket, head);
97
+ }
98
+ else {
99
+ socket.write('HTTP/1.1 404 Not Found\r\n\r\n');
100
+ socket.destroy();
101
+ }
102
+ });
103
+ this.server.on('error', (error) => {
104
+ log.error('Server error', { error: error.message });
105
+ reject(error);
106
+ });
107
+ this.server.listen(this.webConfig.port, this.webConfig.host, () => {
108
+ log.info('Web server started', {
109
+ host: this.webConfig.host,
110
+ port: this.webConfig.port,
111
+ url: `http://${this.webConfig.host}:${this.webConfig.port}`,
112
+ });
113
+ resolve();
114
+ });
115
+ });
116
+ }
117
+ /**
118
+ * Stop the server
119
+ */
120
+ async stop() {
121
+ return new Promise((resolve) => {
122
+ // Close WebSocket connections
123
+ closeAllConnections();
124
+ if (this.server) {
125
+ this.server.close(() => {
126
+ log.info('Web server stopped');
127
+ this.server = null;
128
+ resolve();
129
+ });
130
+ }
131
+ else {
132
+ resolve();
133
+ }
134
+ });
135
+ }
136
+ /**
137
+ * Serve static files from the frontend build
138
+ */
139
+ async serveStatic(req, res) {
140
+ const url = req.url || '/';
141
+ // Don't serve static for API routes
142
+ if (url.startsWith('/api/')) {
143
+ return false;
144
+ }
145
+ // Get the static directory
146
+ const __filename = fileURLToPath(import.meta.url);
147
+ const __dirname = path.dirname(__filename);
148
+ const staticDir = path.resolve(__dirname, '../../web/dist');
149
+ // Check if static directory exists
150
+ if (!fs.existsSync(staticDir)) {
151
+ return false;
152
+ }
153
+ // Determine file path
154
+ let filePath = path.join(staticDir, url);
155
+ // If it's a directory, try index.html
156
+ if (fs.existsSync(filePath) && fs.statSync(filePath).isDirectory()) {
157
+ filePath = path.join(filePath, 'index.html');
158
+ }
159
+ // If file doesn't exist, serve index.html for SPA routing
160
+ if (!fs.existsSync(filePath)) {
161
+ filePath = path.join(staticDir, 'index.html');
162
+ }
163
+ // Check if file exists
164
+ if (!fs.existsSync(filePath)) {
165
+ return false;
166
+ }
167
+ // Get content type
168
+ const ext = path.extname(filePath).toLowerCase();
169
+ const contentTypes = {
170
+ '.html': 'text/html',
171
+ '.js': 'application/javascript',
172
+ '.css': 'text/css',
173
+ '.json': 'application/json',
174
+ '.png': 'image/png',
175
+ '.jpg': 'image/jpeg',
176
+ '.gif': 'image/gif',
177
+ '.svg': 'image/svg+xml',
178
+ '.ico': 'image/x-icon',
179
+ '.woff': 'font/woff',
180
+ '.woff2': 'font/woff2',
181
+ '.ttf': 'font/ttf',
182
+ '.eot': 'application/vnd.ms-fontobject',
183
+ };
184
+ const contentType = contentTypes[ext] || 'application/octet-stream';
185
+ try {
186
+ const content = fs.readFileSync(filePath);
187
+ res.writeHead(200, { 'Content-Type': contentType });
188
+ res.end(content);
189
+ return true;
190
+ }
191
+ catch {
192
+ return false;
193
+ }
194
+ }
195
+ /**
196
+ * Get server status
197
+ */
198
+ getStatus() {
199
+ return {
200
+ running: this.server !== null,
201
+ host: this.webConfig.host,
202
+ port: this.webConfig.port,
203
+ wsClients: getClientCount(),
204
+ };
205
+ }
206
+ }
207
+ // Singleton instance
208
+ let serverInstance = null;
209
+ /**
210
+ * Start the web server
211
+ */
212
+ export async function startWebServer(config, webConfig) {
213
+ if (serverInstance) {
214
+ log.warn('Web server already running');
215
+ return serverInstance;
216
+ }
217
+ serverInstance = new WebServer(config, webConfig);
218
+ await serverInstance.start();
219
+ return serverInstance;
220
+ }
221
+ /**
222
+ * Stop the web server
223
+ */
224
+ export async function stopWebServer() {
225
+ if (serverInstance) {
226
+ await serverInstance.stop();
227
+ serverInstance = null;
228
+ }
229
+ }
230
+ /**
231
+ * Get the web server instance
232
+ */
233
+ export function getWebServer() {
234
+ return serverInstance;
235
+ }
236
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/web/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAA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AS,CAAC,CAAC;IAClD,MAAM,cAAc,CAAC,KAAK,EAAE,CAAC;IAC7B,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC;QAC5B,cAAc,GAAG,IAAI,CAAC;IACxB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,cAAc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Web server types
3
+ */
4
+ import type { IncomingMessage, ServerResponse } from 'node:http';
5
+ export interface WebConfig {
6
+ enabled: boolean;
7
+ port: number;
8
+ host: string;
9
+ cors: {
10
+ origins: string[];
11
+ };
12
+ }
13
+ export interface RouteHandler {
14
+ (req: IncomingMessage, res: ServerResponse, params: RouteParams): Promise<void> | void;
15
+ }
16
+ export interface RouteParams {
17
+ path: string[];
18
+ query: Record<string, string>;
19
+ body?: unknown;
20
+ }
21
+ export interface Route {
22
+ method: string;
23
+ pattern: RegExp;
24
+ handler: RouteHandler;
25
+ paramNames: string[];
26
+ }
27
+ export interface ApiResponse<T = unknown> {
28
+ success: boolean;
29
+ data?: T;
30
+ error?: string;
31
+ timestamp: string;
32
+ }
33
+ export interface PaginatedResponse<T> extends ApiResponse<T[]> {
34
+ pagination: {
35
+ limit: number;
36
+ offset: number;
37
+ total: number;
38
+ };
39
+ }
40
+ export interface WSMessage {
41
+ type: string;
42
+ payload: unknown;
43
+ timestamp: string;
44
+ }
45
+ export interface WSClientInfo {
46
+ id: string;
47
+ connectedAt: Date;
48
+ subscriptions: Set<string>;
49
+ }
50
+ export interface SpawnAgentRequest {
51
+ type: string;
52
+ name?: string;
53
+ sessionId?: string;
54
+ metadata?: Record<string, unknown>;
55
+ }
56
+ export interface ExecuteAgentRequest {
57
+ task: string;
58
+ provider?: string;
59
+ model?: string;
60
+ context?: string;
61
+ }
62
+ export interface ChatRequest {
63
+ message: string;
64
+ context?: string;
65
+ }
66
+ export interface MemoryStoreRequest {
67
+ key: string;
68
+ content: string;
69
+ namespace?: string;
70
+ metadata?: Record<string, unknown>;
71
+ generateEmbedding?: boolean;
72
+ }
73
+ export interface MemorySearchRequest {
74
+ query: string;
75
+ namespace?: string;
76
+ limit?: number;
77
+ threshold?: number;
78
+ useVector?: boolean;
79
+ }
80
+ export interface CreateTaskRequest {
81
+ agentType: string;
82
+ input?: string;
83
+ sessionId?: string;
84
+ priority?: number;
85
+ }
86
+ export interface AssignTaskRequest {
87
+ agentId: string;
88
+ }
89
+ export interface CompleteTaskRequest {
90
+ output?: string;
91
+ }
92
+ export interface LaunchWorkflowRequest {
93
+ workflow: string;
94
+ config?: Record<string, unknown>;
95
+ }
96
+ export interface CreateSessionRequest {
97
+ metadata?: Record<string, unknown>;
98
+ }
99
+ export interface CreateProjectRequest {
100
+ name: string;
101
+ path: string;
102
+ description?: string;
103
+ metadata?: Record<string, unknown>;
104
+ }
105
+ export interface UpdateProjectRequest {
106
+ name?: string;
107
+ description?: string;
108
+ status?: 'active' | 'archived';
109
+ metadata?: Record<string, unknown>;
110
+ }
111
+ export interface CreateProjectTaskRequest {
112
+ title: string;
113
+ description?: string;
114
+ priority?: number;
115
+ assignedAgents?: string[];
116
+ }
117
+ export interface UpdateProjectTaskRequest {
118
+ title?: string;
119
+ description?: string;
120
+ priority?: number;
121
+ assignedAgents?: string[];
122
+ }
123
+ export interface TransitionPhaseRequest {
124
+ phase: string;
125
+ }
126
+ export interface AssignAgentsRequest {
127
+ agents: string[];
128
+ }
129
+ export interface CreateSpecificationRequest {
130
+ type: 'architecture' | 'requirements' | 'design' | 'api' | 'other';
131
+ title: string;
132
+ content: string;
133
+ createdBy: string;
134
+ }
135
+ export interface UpdateSpecificationRequest {
136
+ title?: string;
137
+ content?: string;
138
+ type?: 'architecture' | 'requirements' | 'design' | 'api' | 'other';
139
+ }
140
+ export interface ApproveSpecificationRequest {
141
+ reviewedBy: string;
142
+ comments?: Array<{
143
+ id: string;
144
+ author: string;
145
+ content: string;
146
+ createdAt: string;
147
+ resolved?: boolean;
148
+ }>;
149
+ }
150
+ export interface RejectSpecificationRequest {
151
+ reviewedBy: string;
152
+ comments: Array<{
153
+ id: string;
154
+ author: string;
155
+ content: string;
156
+ createdAt: string;
157
+ resolved?: boolean;
158
+ }>;
159
+ }
160
+ export interface ValidatePathRequest {
161
+ path: string;
162
+ }
163
+ export interface SystemStatus {
164
+ version: string;
165
+ uptime: number;
166
+ memory: {
167
+ heapUsed: number;
168
+ heapTotal: number;
169
+ external: number;
170
+ };
171
+ agents: {
172
+ active: number;
173
+ byStatus: Record<string, number>;
174
+ };
175
+ tasks: {
176
+ queued: number;
177
+ processing: number;
178
+ };
179
+ sessions: {
180
+ active: number;
181
+ };
182
+ }
183
+ export interface HealthCheck {
184
+ status: 'healthy' | 'degraded' | 'unhealthy';
185
+ checks: {
186
+ database: boolean;
187
+ memory: boolean;
188
+ providers: boolean;
189
+ };
190
+ }
191
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/web/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACxF;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAA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
1
+ /**
2
+ * Web server types
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/web/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}