@nexus-cortex/server 4.26.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 (130) hide show
  1. package/.cortex/agents/AGENT_PROFILE_GUIDE.md +307 -0
  2. package/.cortex/agents/README.md +268 -0
  3. package/.cortex/agents/a-frontend-landing-page-designer.md +41 -0
  4. package/.cortex/agents/autoresearch-agent.md +49 -0
  5. package/.cortex/agents/code-reviewer.md +63 -0
  6. package/.cortex/agents/context-research.md +26 -0
  7. package/.cortex/agents/doc-writer.md +92 -0
  8. package/.cortex/agents/explore.md +63 -0
  9. package/.cortex/agents/new-model-api-integrator-analyst.md +41 -0
  10. package/.cortex/agents/plan.md +109 -0
  11. package/.cortex/agents/pr-architecture-reviewer.md +77 -0
  12. package/.cortex/agents/pr-code-quality.md +78 -0
  13. package/.cortex/agents/pr-implementer.md +50 -0
  14. package/.cortex/agents/pr-security-auditor.md +62 -0
  15. package/.cortex/agents/pr-test-writer.md +67 -0
  16. package/.cortex/agents/refactor.md +118 -0
  17. package/.cortex/agents/test-writer.md +72 -0
  18. package/.cortex/agents/web-researcher.md +72 -0
  19. package/.cortex/bench/tasks/sample-tasks.json +20 -0
  20. package/.cortex/commands/compare.md +14 -0
  21. package/.cortex/commands/deps.md +16 -0
  22. package/.cortex/commands/diff.md +14 -0
  23. package/.cortex/commands/explain.md +16 -0
  24. package/.cortex/commands/find-bug.md +13 -0
  25. package/.cortex/commands/profile.md +15 -0
  26. package/.cortex/commands/review.md +18 -0
  27. package/.cortex/commands/search.md +16 -0
  28. package/.cortex/commands/test.md +15 -0
  29. package/.cortex/permissions.dev.json +20 -0
  30. package/.cortex/permissions.example.json +71 -0
  31. package/.cortex/permissions.prod.json +63 -0
  32. package/.cortex/permissions.test.json +19 -0
  33. package/.cortex/skills/autoresearch/SKILL.md +77 -0
  34. package/.cortex/skills/autoresearch/personas/README.md +45 -0
  35. package/.cortex/skills/autoresearch/personas/aggressive-refactor.md +25 -0
  36. package/.cortex/skills/autoresearch/personas/creative.md +29 -0
  37. package/.cortex/skills/autoresearch/personas/perf-hunter.md +27 -0
  38. package/.cortex/skills/autoresearch/personas/precise.md +23 -0
  39. package/.cortex/skills/autoresearch/personas/root-cause.md +26 -0
  40. package/.cortex/skills/autoresearch/personas/security-auditor.md +29 -0
  41. package/.cortex/skills/autoresearch/personas/skeptic-reviewer.md +31 -0
  42. package/.cortex/skills/autoresearch/personas/test-first.md +25 -0
  43. package/.cortex/skills/best-of-n/SKILL.md +76 -0
  44. package/.cortex/skills/cortex/SKILL.md +834 -0
  45. package/.cortex/skills/cortex-bench/SKILL.md +354 -0
  46. package/.cortex/skills/docx/SKILL.md +83 -0
  47. package/.cortex/skills/pdf-documents/SKILL.md +297 -0
  48. package/.cortex/skills/pdf-documents/sections/01-image-acquisition.md +132 -0
  49. package/.cortex/skills/pdf-documents/sections/02-ai-image-generation.md +274 -0
  50. package/.cortex/skills/pdf-documents/sections/03-paper-sizes.md +89 -0
  51. package/.cortex/skills/pdf-documents/sections/04-design-system.md +549 -0
  52. package/.cortex/skills/pdf-documents/sections/05-css-print-rules.md +135 -0
  53. package/.cortex/skills/pdf-documents/sections/06-svg-charts.md +100 -0
  54. package/.cortex/skills/pdf-documents/sections/07-templates.md +224 -0
  55. package/.cortex/skills/pdf-documents/sections/08-scaled-output.md +164 -0
  56. package/.cortex/skills/pdf-documents/sections/09-preview-qa.md +66 -0
  57. package/.cortex/skills/pdf-documents/sections/10-reading-pdfs.md +499 -0
  58. package/.cortex/skills/pdf-documents/sections/11-form-filling.md +241 -0
  59. package/.cortex/skills/pptx/SKILL.md +90 -0
  60. package/.cortex/skills/resume-analyst/SKILL.md +373 -0
  61. package/.cortex/skills/verify-work/SKILL.md +74 -0
  62. package/.cortex/skills/xlsx/SKILL.md +101 -0
  63. package/.cortex/system-messages/messages/WORK_QUALITY.md +159 -0
  64. package/.cortex/system-messages/registry.json +18 -0
  65. package/LICENSE +202 -0
  66. package/NOTICE +2 -0
  67. package/README.md +13 -0
  68. package/bin/cortex-daemon.js +47 -0
  69. package/bin/cortex-server.js +15 -0
  70. package/dist/index.d.ts +30 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +513 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/middleware/cors.d.ts +10 -0
  75. package/dist/middleware/cors.d.ts.map +1 -0
  76. package/dist/middleware/cors.js +11 -0
  77. package/dist/middleware/cors.js.map +1 -0
  78. package/dist/middleware/errorHandler.d.ts +10 -0
  79. package/dist/middleware/errorHandler.d.ts.map +1 -0
  80. package/dist/middleware/errorHandler.js +15 -0
  81. package/dist/middleware/errorHandler.js.map +1 -0
  82. package/dist/routes/approval.d.ts +2 -0
  83. package/dist/routes/approval.d.ts.map +1 -0
  84. package/dist/routes/approval.js +96 -0
  85. package/dist/routes/approval.js.map +1 -0
  86. package/dist/routes/config.d.ts +2 -0
  87. package/dist/routes/config.d.ts.map +1 -0
  88. package/dist/routes/config.js +70 -0
  89. package/dist/routes/config.js.map +1 -0
  90. package/dist/routes/health.d.ts +2 -0
  91. package/dist/routes/health.d.ts.map +1 -0
  92. package/dist/routes/health.js +1031 -0
  93. package/dist/routes/health.js.map +1 -0
  94. package/dist/routes/mcp.d.ts +2 -0
  95. package/dist/routes/mcp.d.ts.map +1 -0
  96. package/dist/routes/mcp.js +251 -0
  97. package/dist/routes/mcp.js.map +1 -0
  98. package/dist/routes/messages.d.ts +5 -0
  99. package/dist/routes/messages.d.ts.map +1 -0
  100. package/dist/routes/messages.js +136 -0
  101. package/dist/routes/messages.js.map +1 -0
  102. package/dist/routes/middleware.d.ts +2 -0
  103. package/dist/routes/middleware.d.ts.map +1 -0
  104. package/dist/routes/middleware.js +146 -0
  105. package/dist/routes/middleware.js.map +1 -0
  106. package/dist/routes/models.d.ts +2 -0
  107. package/dist/routes/models.d.ts.map +1 -0
  108. package/dist/routes/models.js +29 -0
  109. package/dist/routes/models.js.map +1 -0
  110. package/dist/routes/permissions.d.ts +2 -0
  111. package/dist/routes/permissions.d.ts.map +1 -0
  112. package/dist/routes/permissions.js +253 -0
  113. package/dist/routes/permissions.js.map +1 -0
  114. package/dist/routes/pr.d.ts +2 -0
  115. package/dist/routes/pr.d.ts.map +1 -0
  116. package/dist/routes/pr.js +222 -0
  117. package/dist/routes/pr.js.map +1 -0
  118. package/dist/routes/sessions.d.ts +2 -0
  119. package/dist/routes/sessions.d.ts.map +1 -0
  120. package/dist/routes/sessions.js +628 -0
  121. package/dist/routes/sessions.js.map +1 -0
  122. package/dist/routes/system-messages.d.ts +2 -0
  123. package/dist/routes/system-messages.d.ts.map +1 -0
  124. package/dist/routes/system-messages.js +146 -0
  125. package/dist/routes/system-messages.js.map +1 -0
  126. package/dist/routes/tools.d.ts +2 -0
  127. package/dist/routes/tools.d.ts.map +1 -0
  128. package/dist/routes/tools.js +79 -0
  129. package/dist/routes/tools.js.map +1 -0
  130. package/package.json +63 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,EAAE,CAAC;AAErC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;IAC1D,MAAM,QAAQ,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC5C,MAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC;IAEvC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAChC,MAAM,eAAe,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,KA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;;iBAEd,CAAC;IACV,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwDX,CAAC;AACT,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const mcpRouter: import("express-serve-static-core").Router;
2
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/routes/mcp.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS,4CAAW,CAAC"}
@@ -0,0 +1,251 @@
1
+ /**
2
+ * MCP Management Routes
3
+ * Exposes MCP server management operations
4
+ */
5
+ import { Router } from 'express';
6
+ import { getServerOrchestrator } from './messages.js';
7
+ export const mcpRouter = Router();
8
+ /**
9
+ * GET /mcp/servers
10
+ * List all MCP servers with their status
11
+ */
12
+ mcpRouter.get('/mcp/servers', async (req, res) => {
13
+ try {
14
+ const orchestrator = getServerOrchestrator();
15
+ if (!orchestrator) {
16
+ return res.status(503).json({
17
+ error: { message: 'Server not initialized', type: 'server_error' }
18
+ });
19
+ }
20
+ // Check if MCP is enabled
21
+ const mcpEnabled = orchestrator.isMcpEnabled?.() ?? false;
22
+ if (!mcpEnabled) {
23
+ return res.json({
24
+ enabled: false,
25
+ servers: []
26
+ });
27
+ }
28
+ // Get server info
29
+ const serverInfo = orchestrator.getMcpServerInfo?.() ?? [];
30
+ res.json({
31
+ enabled: true,
32
+ servers: serverInfo
33
+ });
34
+ }
35
+ catch (error) {
36
+ res.status(500).json({
37
+ error: { message: error.message, type: 'server_error' }
38
+ });
39
+ }
40
+ });
41
+ /**
42
+ * GET /mcp/servers/:name
43
+ * Get specific MCP server details
44
+ */
45
+ mcpRouter.get('/mcp/servers/:name', async (req, res) => {
46
+ try {
47
+ const { name } = req.params;
48
+ const orchestrator = getServerOrchestrator();
49
+ if (!orchestrator) {
50
+ return res.status(503).json({
51
+ error: { message: 'Server not initialized', type: 'server_error' }
52
+ });
53
+ }
54
+ const mcpEnabled = orchestrator.isMcpEnabled?.() ?? false;
55
+ if (!mcpEnabled) {
56
+ return res.status(404).json({
57
+ error: { message: 'MCP not enabled', type: 'not_found' }
58
+ });
59
+ }
60
+ const serverInfo = orchestrator.getMcpServerInfo?.() ?? [];
61
+ const server = serverInfo.find((s) => s.name === name);
62
+ if (!server) {
63
+ return res.status(404).json({
64
+ error: { message: `MCP server ${name} not found`, type: 'not_found' }
65
+ });
66
+ }
67
+ res.json(server);
68
+ }
69
+ catch (error) {
70
+ res.status(500).json({
71
+ error: { message: error.message, type: 'server_error' }
72
+ });
73
+ }
74
+ });
75
+ /**
76
+ * GET /mcp/servers/:name/tools
77
+ * Get tools provided by a specific MCP server
78
+ */
79
+ mcpRouter.get('/mcp/servers/:name/tools', async (req, res) => {
80
+ try {
81
+ const { name } = req.params;
82
+ const orchestrator = getServerOrchestrator();
83
+ if (!orchestrator) {
84
+ return res.status(503).json({
85
+ error: { message: 'Server not initialized', type: 'server_error' }
86
+ });
87
+ }
88
+ const mcpEnabled = orchestrator.isMcpEnabled?.() ?? false;
89
+ if (!mcpEnabled) {
90
+ return res.status(404).json({
91
+ error: { message: 'MCP not enabled', type: 'not_found' }
92
+ });
93
+ }
94
+ // Get all MCP tools
95
+ const allMcpTools = orchestrator.getMcpTools?.() ?? [];
96
+ // Filter tools from this server
97
+ const serverTools = allMcpTools.filter((t) => t.serverName === name);
98
+ res.json({
99
+ serverName: name,
100
+ toolCount: serverTools.length,
101
+ tools: serverTools
102
+ });
103
+ }
104
+ catch (error) {
105
+ res.status(500).json({
106
+ error: { message: error.message, type: 'server_error' }
107
+ });
108
+ }
109
+ });
110
+ /**
111
+ * GET /mcp/tools
112
+ * Get all MCP tools across all servers
113
+ */
114
+ mcpRouter.get('/mcp/tools', async (req, res) => {
115
+ try {
116
+ const orchestrator = getServerOrchestrator();
117
+ if (!orchestrator) {
118
+ return res.status(503).json({
119
+ error: { message: 'Server not initialized', type: 'server_error' }
120
+ });
121
+ }
122
+ const mcpEnabled = orchestrator.isMcpEnabled?.() ?? false;
123
+ if (!mcpEnabled) {
124
+ return res.json({
125
+ enabled: false,
126
+ tools: []
127
+ });
128
+ }
129
+ const allMcpTools = orchestrator.getMcpTools?.() ?? [];
130
+ res.json({
131
+ enabled: true,
132
+ toolCount: allMcpTools.length,
133
+ tools: allMcpTools
134
+ });
135
+ }
136
+ catch (error) {
137
+ res.status(500).json({
138
+ error: { message: error.message, type: 'server_error' }
139
+ });
140
+ }
141
+ });
142
+ /**
143
+ * POST /mcp/servers/:name/connect
144
+ * Connect to an MCP server
145
+ */
146
+ mcpRouter.post('/mcp/servers/:name/connect', async (req, res) => {
147
+ try {
148
+ const { name } = req.params;
149
+ const orchestrator = getServerOrchestrator();
150
+ if (!orchestrator) {
151
+ return res.status(503).json({
152
+ error: { message: 'Server not initialized', type: 'server_error' }
153
+ });
154
+ }
155
+ const mcpManager = orchestrator.mcpManager;
156
+ if (!mcpManager) {
157
+ return res.status(503).json({
158
+ error: { message: 'MCP not enabled', type: 'server_error' }
159
+ });
160
+ }
161
+ // Connect to server
162
+ await mcpManager.connectToServer(name);
163
+ // Discover tools
164
+ await mcpManager.discoverAll();
165
+ res.json({
166
+ success: true,
167
+ message: `Connected to MCP server: ${name}`
168
+ });
169
+ }
170
+ catch (error) {
171
+ res.status(500).json({
172
+ error: { message: error.message, type: 'server_error' }
173
+ });
174
+ }
175
+ });
176
+ /**
177
+ * POST /mcp/servers/:name/disconnect
178
+ * Disconnect from an MCP server
179
+ */
180
+ mcpRouter.post('/mcp/servers/:name/disconnect', async (req, res) => {
181
+ try {
182
+ const { name } = req.params;
183
+ const orchestrator = getServerOrchestrator();
184
+ if (!orchestrator) {
185
+ return res.status(503).json({
186
+ error: { message: 'Server not initialized', type: 'server_error' }
187
+ });
188
+ }
189
+ const mcpManager = orchestrator.mcpManager;
190
+ if (!mcpManager) {
191
+ return res.status(503).json({
192
+ error: { message: 'MCP not enabled', type: 'server_error' }
193
+ });
194
+ }
195
+ // Disconnect from server
196
+ await mcpManager.disconnectFromServer(name);
197
+ res.json({
198
+ success: true,
199
+ message: `Disconnected from MCP server: ${name}`
200
+ });
201
+ }
202
+ catch (error) {
203
+ res.status(500).json({
204
+ error: { message: error.message, type: 'server_error' }
205
+ });
206
+ }
207
+ });
208
+ /**
209
+ * GET /mcp/status
210
+ * Get overall MCP status
211
+ */
212
+ mcpRouter.get('/mcp/status', async (req, res) => {
213
+ try {
214
+ const orchestrator = getServerOrchestrator();
215
+ if (!orchestrator) {
216
+ return res.status(503).json({
217
+ error: { message: 'Server not initialized', type: 'server_error' }
218
+ });
219
+ }
220
+ const mcpEnabled = orchestrator.isMcpEnabled?.() ?? false;
221
+ if (!mcpEnabled) {
222
+ return res.json({
223
+ enabled: false,
224
+ serverCount: 0,
225
+ connectedCount: 0,
226
+ toolCount: 0
227
+ });
228
+ }
229
+ const serverInfo = orchestrator.getMcpServerInfo?.() ?? [];
230
+ const connectedCount = serverInfo.filter((s) => s.status === 'connected').length;
231
+ const allMcpTools = orchestrator.getMcpTools?.() ?? [];
232
+ res.json({
233
+ enabled: true,
234
+ serverCount: serverInfo.length,
235
+ connectedCount,
236
+ toolCount: allMcpTools.length,
237
+ servers: serverInfo.map((s) => ({
238
+ name: s.name,
239
+ status: s.status,
240
+ toolCount: s.toolCount,
241
+ lastError: s.lastError
242
+ }))
243
+ });
244
+ }
245
+ catch (error) {
246
+ res.status(500).json({
247
+ error: { message: error.message, type: 'server_error' }
248
+ });
249
+ }
250
+ });
251
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/routes/mcp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,CAAC,MAAM,SAAS,GAA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@ -0,0 +1,5 @@
1
+ import { type CortexOrchestrator } from '@nexus-cortex/core';
2
+ export declare function setServerOrchestrator(orchestrator: CortexOrchestrator): void;
3
+ export declare function getServerOrchestrator(): CortexOrchestrator | null;
4
+ export declare const messagesRouter: import("express-serve-static-core").Router;
5
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/routes/messages.ts"],"names":[],"mappings":"AAKA,OAAO,EAA+C,KAAK,kBAAkB,EAAe,MAAM,oBAAoB,CAAC;AAUvH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,kBAAkB,GAAG,IAAI,CAE5E;AAED,wBAAgB,qBAAqB,IAAI,kBAAkB,GAAG,IAAI,CAEjE;AAED,eAAO,MAAM,cAAc,4CAAW,CAAC"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Main /v1/messages endpoint
3
+ * Thin wrapper around CortexOrchestrator
4
+ */
5
+ import { Router } from 'express';
6
+ import { createOrchestrator } from '@nexus-cortex/core';
7
+ // Read lazily — ESM hoists imports before index.ts sets process.env.PROJECT_ROOT
8
+ function getProjectRoot() {
9
+ return process.env.PROJECT_ROOT || process.cwd();
10
+ }
11
+ // Persistent orchestrator instance (set by server.ts on startup)
12
+ let serverOrchestrator = null;
13
+ export function setServerOrchestrator(orchestrator) {
14
+ serverOrchestrator = orchestrator;
15
+ }
16
+ export function getServerOrchestrator() {
17
+ return serverOrchestrator;
18
+ }
19
+ export const messagesRouter = Router();
20
+ messagesRouter.post('/v1/messages', async (req, res, next) => {
21
+ try {
22
+ const { model: requestModel, messages, system, tools, max_tokens, temperature, top_p, stream } = req.body;
23
+ // Model resolution order:
24
+ // 1. Explicit request.model (client override)
25
+ // 2. Persistent orchestrator's currentModelId (session's effective model
26
+ // after resume — this is what preserves the Responses API chain
27
+ // across restarts; if we fell through to DEFAULT_MODEL_ID here, the
28
+ // chain's modelMatches check would fail on the next turn)
29
+ // 3. .env DEFAULT_MODEL_ID
30
+ // 4. hard fallback
31
+ const sessionModel = serverOrchestrator?.getCurrentModelId?.();
32
+ const model = requestModel || sessionModel || process.env.DEFAULT_MODEL_ID || 'grok-code-fast-1';
33
+ // Validate required fields
34
+ if (!messages || !Array.isArray(messages)) {
35
+ return res.status(400).json({
36
+ error: {
37
+ message: 'Missing or invalid field: messages',
38
+ type: 'invalid_request_error'
39
+ }
40
+ });
41
+ }
42
+ // sendMessage/streamMessage take a SINGLE user turn's content (a string,
43
+ // or canonical content blocks for tool results) — every other caller
44
+ // passes a string, and the stateful orchestrator owns session history.
45
+ // Passing the whole `messages` array made the orchestrator wrap it as one
46
+ // message and JSON.stringify each {role,content} element into the user
47
+ // text (R27: garbled input → empty xAI Responses output; tolerated only
48
+ // because chat models could still read the JSON). Pass just the new turn.
49
+ const lastMessage = messages[messages.length - 1];
50
+ const turnContent = lastMessage?.content ?? '';
51
+ // Use provided tools, or empty array to enable built-in tools
52
+ // Empty array [] triggers: factoryTools + mcpTools + mcpManagementTools in orchestrator
53
+ const toolsToUse = tools !== undefined ? tools : [];
54
+ // Get orchestrator (persistent instance or create ephemeral for stateless mode)
55
+ let orchestrator;
56
+ if (serverOrchestrator) {
57
+ // Use persistent orchestrator (stateful mode)
58
+ // NOTE: Do NOT call switchModel() here — it mutates shared orchestrator state
59
+ // and creates race conditions with concurrent requests. Instead, pass modelId
60
+ // per-request via messageOptions (sendMessage/streamMessage support options.modelId).
61
+ orchestrator = serverOrchestrator;
62
+ }
63
+ else {
64
+ // Create ephemeral orchestrator (stateless mode)
65
+ const projectRoot = getProjectRoot();
66
+ const orchestratorConfig = {
67
+ defaultModelId: model,
68
+ projectPath: projectRoot,
69
+ workingDirectory: projectRoot,
70
+ enableTimeline: true,
71
+ debug: process.env.DEBUG === 'true'
72
+ };
73
+ // Use auto-approve if YOLO=true, otherwise disable permissions
74
+ const yolo = process.env.YOLO === 'true';
75
+ orchestrator = await createOrchestrator(orchestratorConfig, {
76
+ permissionMode: yolo ? 'auto' : 'disabled'
77
+ });
78
+ await orchestrator.createSession(projectRoot, model);
79
+ }
80
+ // Build message options.
81
+ // Sampling params MUST be nested under `parameters` — the orchestrator
82
+ // reads `options.parameters?.temperature` / `?.maxTokens` / `?.topP` and
83
+ // nothing remaps top-level keys, so a flat `temperature` was silently
84
+ // dropped (every request ran at the model-card default). Include each
85
+ // only when the client actually sent it: an omitted param falls through
86
+ // to the card default rather than being force-overridden.
87
+ const parameters = {};
88
+ if (temperature !== undefined)
89
+ parameters.temperature = temperature;
90
+ if (max_tokens !== undefined)
91
+ parameters.maxTokens = max_tokens;
92
+ if (top_p !== undefined)
93
+ parameters.topP = top_p;
94
+ const messageOptions = {
95
+ modelId: model,
96
+ system,
97
+ ...(toolsToUse !== undefined && { tools: toolsToUse }),
98
+ ...(Object.keys(parameters).length > 0 && { parameters })
99
+ };
100
+ // Handle streaming vs non-streaming
101
+ if (stream) {
102
+ // Set SSE headers
103
+ res.setHeader('Content-Type', 'text/event-stream');
104
+ res.setHeader('Cache-Control', 'no-cache');
105
+ res.setHeader('Connection', 'keep-alive');
106
+ res.setHeader('X-Accel-Buffering', 'no'); // Disable nginx buffering
107
+ try {
108
+ for await (const event of orchestrator.streamMessage(turnContent, messageOptions)) {
109
+ // Send SSE formatted events
110
+ res.write(`data: ${JSON.stringify(event)}\n\n`);
111
+ }
112
+ res.end();
113
+ }
114
+ catch (streamError) {
115
+ // Send error as SSE event
116
+ res.write(`data: ${JSON.stringify({
117
+ type: 'error',
118
+ error: {
119
+ message: streamError.message,
120
+ type: 'stream_error'
121
+ }
122
+ })}\n\n`);
123
+ res.end();
124
+ }
125
+ }
126
+ else {
127
+ // Non-streaming request
128
+ const response = await orchestrator.sendMessage(turnContent, messageOptions);
129
+ res.json(response);
130
+ }
131
+ }
132
+ catch (error) {
133
+ next(error);
134
+ }
135
+ });
136
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/rout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E,CAAC;YACZ,CAAC;YAAC,OAAO,WAAgB,EAAE,CAAC;gBAC1B,0BAA0B;gBAC1B,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC;oBAChC,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE;wBACL,OAAO,EAAE,WAAW,CAAC,OAAO;wBAC5B,IAAI,EAAE,cAAc;qBACrB;iBACF,CAAC,MAAM,CAAC,CAAC;gBACV,GAAG,CAAC,GAAG,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,wBAAwB;YACxB,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAC7E,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,KAAK,CAAC,CAAC;IACd,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const middlewareRouter: import("express-serve-static-core").Router;
2
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/routes/middleware.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,gBAAgB,4CAAW,CAAC"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Middleware Configuration Routes
3
+ * Exposes middleware configuration and management
4
+ */
5
+ import { Router } from 'express';
6
+ import { getServerOrchestrator } from './messages.js';
7
+ export const middlewareRouter = Router();
8
+ /**
9
+ * GET /middleware/config
10
+ * Get middleware configuration
11
+ */
12
+ middlewareRouter.get('/middleware/config', async (req, res) => {
13
+ try {
14
+ const orchestrator = getServerOrchestrator();
15
+ if (!orchestrator) {
16
+ return res.status(503).json({
17
+ error: { message: 'Server not initialized', type: 'server_error' }
18
+ });
19
+ }
20
+ // Collect middleware status
21
+ const middlewareStatus = {
22
+ errorClassifier: !!orchestrator.errorClassifier,
23
+ retry: !!orchestrator.retryMiddleware,
24
+ permissions: !!orchestrator.permissionsMiddleware,
25
+ systemMessage: !!orchestrator.systemMessageMiddleware,
26
+ mentorship: !!orchestrator.mentorshipMiddleware,
27
+ helper: !!orchestrator.helperMiddleware
28
+ };
29
+ // Get config from each middleware if available
30
+ const config = {};
31
+ if (orchestrator.retryMiddleware) {
32
+ config.retry = {
33
+ enabled: true,
34
+ maxRetries: orchestrator.retryMiddleware.maxRetries || 3
35
+ };
36
+ }
37
+ if (orchestrator.permissionsMiddleware) {
38
+ config.permissions = {
39
+ enabled: true,
40
+ mode: orchestrator.getApprovalMode()
41
+ };
42
+ }
43
+ if (orchestrator.mentorshipMiddleware) {
44
+ config.mentorship = {
45
+ enabled: !!orchestrator.config.reactiveMentorship?.enabled
46
+ };
47
+ }
48
+ res.json({
49
+ middleware: middlewareStatus,
50
+ config,
51
+ enabledCount: Object.values(middlewareStatus).filter(Boolean).length
52
+ });
53
+ }
54
+ catch (error) {
55
+ res.status(500).json({
56
+ error: { message: error.message, type: 'server_error' }
57
+ });
58
+ }
59
+ });
60
+ /**
61
+ * POST /middleware/:name/enable
62
+ * Enable a middleware component
63
+ */
64
+ middlewareRouter.post('/middleware/:name/enable', async (req, res) => {
65
+ try {
66
+ const { name } = req.params;
67
+ return res.status(501).json({
68
+ error: {
69
+ message: 'Middleware enable/disable requires server restart',
70
+ type: 'not_implemented',
71
+ details: 'Middleware components are configured at server startup and cannot be dynamically enabled'
72
+ }
73
+ });
74
+ }
75
+ catch (error) {
76
+ res.status(500).json({
77
+ error: { message: error.message, type: 'server_error' }
78
+ });
79
+ }
80
+ });
81
+ /**
82
+ * POST /middleware/:name/disable
83
+ * Disable a middleware component
84
+ */
85
+ middlewareRouter.post('/middleware/:name/disable', async (req, res) => {
86
+ try {
87
+ const { name } = req.params;
88
+ return res.status(501).json({
89
+ error: {
90
+ message: 'Middleware enable/disable requires server restart',
91
+ type: 'not_implemented',
92
+ details: 'Middleware components are configured at server startup and cannot be dynamically disabled'
93
+ }
94
+ });
95
+ }
96
+ catch (error) {
97
+ res.status(500).json({
98
+ error: { message: error.message, type: 'server_error' }
99
+ });
100
+ }
101
+ });
102
+ /**
103
+ * GET /middleware/:name/status
104
+ * Get status of a specific middleware
105
+ */
106
+ middlewareRouter.get('/middleware/:name/status', async (req, res) => {
107
+ try {
108
+ const { name } = req.params;
109
+ const orchestrator = getServerOrchestrator();
110
+ if (!orchestrator) {
111
+ return res.status(503).json({
112
+ error: { message: 'Server not initialized', type: 'server_error' }
113
+ });
114
+ }
115
+ // Map friendly names to internal properties
116
+ const middlewareMap = {
117
+ 'error-classifier': 'errorClassifier',
118
+ 'retry': 'retryMiddleware',
119
+ 'permissions': 'permissionsMiddleware',
120
+ 'system-message': 'systemMessageMiddleware',
121
+ 'mentorship': 'mentorshipMiddleware',
122
+ 'helper': 'helperMiddleware'
123
+ };
124
+ const internalName = middlewareMap[name] || name;
125
+ const middleware = orchestrator[internalName];
126
+ if (!middleware) {
127
+ return res.json({
128
+ name,
129
+ enabled: false,
130
+ message: `Middleware '${name}' is not enabled or does not exist`
131
+ });
132
+ }
133
+ res.json({
134
+ name,
135
+ enabled: true,
136
+ internalName,
137
+ config: middleware.getConfig?.() || {}
138
+ });
139
+ }
140
+ catch (error) {
141
+ res.status(500).json({
142
+ error: { message: error.message, type: 'server_error' }
143
+ });
144
+ }
145
+ });
146
+ //# sourceMappingURL=middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/routes/middleware.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,EAAE,CAAC;AAEzC;;;GAGG;AACH,gBAAgB,CAAC,GAAG,CAAC,oBAAoB,EAAE,KAAK,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,CAAC;YAChB,OAAO,GAAG,CAAC,IAAI,CAAC;gBACd,IAAI;gBACJ,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,eAAe,IAAI,oCAAoC;aACjE,CAAC,CAAC;QACL,CAAC;QAED,GAAG,CAAC,IAAI,CAAC;YACP,IAAI;YACJ,OAAO,EAAE,IAAI;YACb,YAAY;YACZ,MAAM,EAAE,UAAU,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE;SACvC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE;SACxD,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const modelsRouter: import("express-serve-static-core").Router;
2
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/routes/models.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,4CAAW,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * /models endpoint - list available models
3
+ */
4
+ import { Router } from 'express';
5
+ import { ModularModelRegistry } from '@nexus-cortex/core';
6
+ export const modelsRouter = Router();
7
+ modelsRouter.get('/models', (req, res) => {
8
+ const registry = new ModularModelRegistry();
9
+ const modelIds = registry.listModels();
10
+ res.json({
11
+ object: 'list',
12
+ data: modelIds.map(modelId => {
13
+ const model = registry.getModel(modelId);
14
+ return {
15
+ id: model.id,
16
+ object: 'model',
17
+ created: Date.now(),
18
+ owned_by: model.provider,
19
+ displayName: model.displayName,
20
+ apiPattern: model.api.pattern,
21
+ contextWindow: model.limits.contextWindow,
22
+ maxOutputTokens: model.limits.outputTokens,
23
+ inputCostPer1M: model.cost?.inputPerMillion || 0,
24
+ outputCostPer1M: model.cost?.outputPerMillion || 0
25
+ };
26
+ })
27
+ });
28
+ });
29
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/routes/models.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,EAAE,CAAC;AAErC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;IAC1D,MAAM,QAAQ,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC5C,MAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC;IAEvC,GAAG,CAAC,IAAI,CAAC;QACP,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YAC3B,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACzC,OAAO;gBACL,EAAE,EAAE,KAAK,CAAC,EAAE;gBACZ,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;gBACnB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO;gBAC7B,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,aAAa;gBACzC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,YAAY;gBAC1C,cAAc,EAAE,KAAK,CAAC,IAAI,EAAE,eAAe,IAAI,CAAC;gBAChD,eAAe,EAAE,KAAK,CAAC,IAAI,EAAE,gBAAgB,IAAI,CAAC;aACnD,CAAC;QACJ,CAAC,CAAC;KACH,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const permissionsRouter: import("express-serve-static-core").Router;
2
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/routes/permissions.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,iBAAiB,4CAAW,CAAC"}