claude-wec 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +675 -0
- package/README.md +371 -0
- package/dist/api-docs.html +879 -0
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/index-cIxJ4RXb.js +1226 -0
- package/dist/assets/index-oyEz69sP.css +32 -0
- package/dist/assets/vendor-codemirror-CJLzwpLB.js +39 -0
- package/dist/assets/vendor-react-DcyRfQm3.js +59 -0
- package/dist/assets/vendor-xterm-DfaPXD3y.js +66 -0
- package/dist/clear-cache.html +85 -0
- package/dist/convert-icons.md +53 -0
- package/dist/favicon.png +0 -0
- package/dist/favicon.svg +9 -0
- package/dist/generate-icons.js +49 -0
- package/dist/icons/claude-ai-icon.svg +1 -0
- package/dist/icons/codex-white.svg +3 -0
- package/dist/icons/codex.svg +3 -0
- package/dist/icons/cursor-white.svg +12 -0
- package/dist/icons/cursor.svg +1 -0
- package/dist/icons/generate-icons.md +19 -0
- package/dist/icons/icon-128x128.png +0 -0
- package/dist/icons/icon-128x128.svg +12 -0
- package/dist/icons/icon-144x144.png +0 -0
- package/dist/icons/icon-144x144.svg +12 -0
- package/dist/icons/icon-152x152.png +0 -0
- package/dist/icons/icon-152x152.svg +12 -0
- package/dist/icons/icon-192x192.png +0 -0
- package/dist/icons/icon-192x192.svg +12 -0
- package/dist/icons/icon-384x384.png +0 -0
- package/dist/icons/icon-384x384.svg +12 -0
- package/dist/icons/icon-512x512.png +0 -0
- package/dist/icons/icon-512x512.svg +12 -0
- package/dist/icons/icon-72x72.png +0 -0
- package/dist/icons/icon-72x72.svg +12 -0
- package/dist/icons/icon-96x96.png +0 -0
- package/dist/icons/icon-96x96.svg +12 -0
- package/dist/icons/icon-template.svg +12 -0
- package/dist/index.html +52 -0
- package/dist/logo-128.png +0 -0
- package/dist/logo-256.png +0 -0
- package/dist/logo-32.png +0 -0
- package/dist/logo-512.png +0 -0
- package/dist/logo-64.png +0 -0
- package/dist/logo.svg +17 -0
- package/dist/manifest.json +61 -0
- package/dist/screenshots/cli-selection.png +0 -0
- package/dist/screenshots/desktop-main.png +0 -0
- package/dist/screenshots/mobile-chat.png +0 -0
- package/dist/screenshots/tools-modal.png +0 -0
- package/dist/sw.js +49 -0
- package/package.json +109 -0
- package/server/claude-sdk.js +721 -0
- package/server/cli.js +327 -0
- package/server/cursor-cli.js +267 -0
- package/server/database/auth.db +0 -0
- package/server/database/db.js +361 -0
- package/server/database/init.sql +52 -0
- package/server/index.js +1747 -0
- package/server/middleware/auth.js +111 -0
- package/server/openai-codex.js +389 -0
- package/server/projects.js +1604 -0
- package/server/routes/agent.js +1230 -0
- package/server/routes/auth.js +135 -0
- package/server/routes/cli-auth.js +263 -0
- package/server/routes/codex.js +345 -0
- package/server/routes/commands.js +521 -0
- package/server/routes/cursor.js +795 -0
- package/server/routes/git.js +1128 -0
- package/server/routes/mcp-utils.js +48 -0
- package/server/routes/mcp.js +552 -0
- package/server/routes/projects.js +378 -0
- package/server/routes/settings.js +178 -0
- package/server/routes/taskmaster.js +1963 -0
- package/server/routes/user.js +106 -0
- package/server/utils/commandParser.js +303 -0
- package/server/utils/gitConfig.js +24 -0
- package/server/utils/mcp-detector.js +198 -0
- package/server/utils/taskmaster-websocket.js +129 -0
- package/shared/modelConstants.js +65 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import os from 'os';
|
|
6
|
+
import TOML from '@iarna/toml';
|
|
7
|
+
import { getCodexSessions, getCodexSessionMessages, deleteCodexSession } from '../projects.js';
|
|
8
|
+
|
|
9
|
+
const router = express.Router();
|
|
10
|
+
|
|
11
|
+
function createCliResponder(res) {
|
|
12
|
+
let responded = false;
|
|
13
|
+
return (status, payload) => {
|
|
14
|
+
if (responded || res.headersSent) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
responded = true;
|
|
18
|
+
res.status(status).json(payload);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
router.get('/config', async (req, res) => {
|
|
23
|
+
try {
|
|
24
|
+
const configPath = path.join(os.homedir(), '.codex', 'config.toml');
|
|
25
|
+
const content = await fs.readFile(configPath, 'utf8');
|
|
26
|
+
const config = TOML.parse(content);
|
|
27
|
+
|
|
28
|
+
res.json({
|
|
29
|
+
success: true,
|
|
30
|
+
config: {
|
|
31
|
+
model: config.model || null,
|
|
32
|
+
mcpServers: config.mcp_servers || {},
|
|
33
|
+
approvalMode: config.approval_mode || 'suggest'
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error.code === 'ENOENT') {
|
|
38
|
+
res.json({
|
|
39
|
+
success: true,
|
|
40
|
+
config: {
|
|
41
|
+
model: null,
|
|
42
|
+
mcpServers: {},
|
|
43
|
+
approvalMode: 'suggest'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
console.error('Error reading Codex config:', error);
|
|
48
|
+
res.status(500).json({ success: false, error: error.message });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
router.get('/sessions', async (req, res) => {
|
|
54
|
+
try {
|
|
55
|
+
const { projectPath } = req.query;
|
|
56
|
+
|
|
57
|
+
if (!projectPath) {
|
|
58
|
+
return res.status(400).json({ success: false, error: 'projectPath query parameter required' });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const sessions = await getCodexSessions(projectPath);
|
|
62
|
+
res.json({ success: true, sessions });
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('Error fetching Codex sessions:', error);
|
|
65
|
+
res.status(500).json({ success: false, error: error.message });
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
router.get('/sessions/:sessionId/messages', async (req, res) => {
|
|
70
|
+
try {
|
|
71
|
+
const { sessionId } = req.params;
|
|
72
|
+
const { limit, offset } = req.query;
|
|
73
|
+
|
|
74
|
+
const result = await getCodexSessionMessages(
|
|
75
|
+
sessionId,
|
|
76
|
+
limit ? parseInt(limit, 10) : null,
|
|
77
|
+
offset ? parseInt(offset, 10) : 0
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
res.json({ success: true, ...result });
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('Error fetching Codex session messages:', error);
|
|
83
|
+
res.status(500).json({ success: false, error: error.message });
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
router.delete('/sessions/:sessionId', async (req, res) => {
|
|
88
|
+
try {
|
|
89
|
+
const { sessionId } = req.params;
|
|
90
|
+
await deleteCodexSession(sessionId);
|
|
91
|
+
res.json({ success: true });
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error(`Error deleting Codex session ${req.params.sessionId}:`, error);
|
|
94
|
+
res.status(500).json({ success: false, error: error.message });
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// MCP Server Management Routes
|
|
99
|
+
|
|
100
|
+
router.get('/mcp/cli/list', async (req, res) => {
|
|
101
|
+
try {
|
|
102
|
+
const respond = createCliResponder(res);
|
|
103
|
+
const proc = spawn('codex', ['mcp', 'list'], { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
104
|
+
|
|
105
|
+
let stdout = '';
|
|
106
|
+
let stderr = '';
|
|
107
|
+
|
|
108
|
+
proc.stdout?.on('data', (data) => { stdout += data.toString(); });
|
|
109
|
+
proc.stderr?.on('data', (data) => { stderr += data.toString(); });
|
|
110
|
+
|
|
111
|
+
proc.on('close', (code) => {
|
|
112
|
+
if (code === 0) {
|
|
113
|
+
respond(200, { success: true, output: stdout, servers: parseCodexListOutput(stdout) });
|
|
114
|
+
} else {
|
|
115
|
+
respond(500, { error: 'Codex CLI command failed', details: stderr || `Exited with code ${code}` });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
proc.on('error', (error) => {
|
|
120
|
+
const isMissing = error?.code === 'ENOENT';
|
|
121
|
+
respond(isMissing ? 503 : 500, {
|
|
122
|
+
error: isMissing ? 'Codex CLI not installed' : 'Failed to run Codex CLI',
|
|
123
|
+
details: error.message,
|
|
124
|
+
code: error.code
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
} catch (error) {
|
|
128
|
+
res.status(500).json({ error: 'Failed to list MCP servers', details: error.message });
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
router.post('/mcp/cli/add', async (req, res) => {
|
|
133
|
+
try {
|
|
134
|
+
const { name, command, args = [], env = {} } = req.body;
|
|
135
|
+
|
|
136
|
+
if (!name || !command) {
|
|
137
|
+
return res.status(400).json({ error: 'name and command are required' });
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Build: codex mcp add <name> [-e KEY=VAL]... -- <command> [args...]
|
|
141
|
+
let cliArgs = ['mcp', 'add', name];
|
|
142
|
+
|
|
143
|
+
Object.entries(env).forEach(([key, value]) => {
|
|
144
|
+
cliArgs.push('-e', `${key}=${value}`);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
cliArgs.push('--', command);
|
|
148
|
+
|
|
149
|
+
if (args && args.length > 0) {
|
|
150
|
+
cliArgs.push(...args);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const respond = createCliResponder(res);
|
|
154
|
+
const proc = spawn('codex', cliArgs, { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
155
|
+
|
|
156
|
+
let stdout = '';
|
|
157
|
+
let stderr = '';
|
|
158
|
+
|
|
159
|
+
proc.stdout?.on('data', (data) => { stdout += data.toString(); });
|
|
160
|
+
proc.stderr?.on('data', (data) => { stderr += data.toString(); });
|
|
161
|
+
|
|
162
|
+
proc.on('close', (code) => {
|
|
163
|
+
if (code === 0) {
|
|
164
|
+
respond(200, { success: true, output: stdout, message: `MCP server "${name}" added successfully` });
|
|
165
|
+
} else {
|
|
166
|
+
respond(400, { error: 'Codex CLI command failed', details: stderr || `Exited with code ${code}` });
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
proc.on('error', (error) => {
|
|
171
|
+
const isMissing = error?.code === 'ENOENT';
|
|
172
|
+
respond(isMissing ? 503 : 500, {
|
|
173
|
+
error: isMissing ? 'Codex CLI not installed' : 'Failed to run Codex CLI',
|
|
174
|
+
details: error.message,
|
|
175
|
+
code: error.code
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
} catch (error) {
|
|
179
|
+
res.status(500).json({ error: 'Failed to add MCP server', details: error.message });
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
router.delete('/mcp/cli/remove/:name', async (req, res) => {
|
|
184
|
+
try {
|
|
185
|
+
const { name } = req.params;
|
|
186
|
+
|
|
187
|
+
const respond = createCliResponder(res);
|
|
188
|
+
const proc = spawn('codex', ['mcp', 'remove', name], { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
189
|
+
|
|
190
|
+
let stdout = '';
|
|
191
|
+
let stderr = '';
|
|
192
|
+
|
|
193
|
+
proc.stdout?.on('data', (data) => { stdout += data.toString(); });
|
|
194
|
+
proc.stderr?.on('data', (data) => { stderr += data.toString(); });
|
|
195
|
+
|
|
196
|
+
proc.on('close', (code) => {
|
|
197
|
+
if (code === 0) {
|
|
198
|
+
respond(200, { success: true, output: stdout, message: `MCP server "${name}" removed successfully` });
|
|
199
|
+
} else {
|
|
200
|
+
respond(400, { error: 'Codex CLI command failed', details: stderr || `Exited with code ${code}` });
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
proc.on('error', (error) => {
|
|
205
|
+
const isMissing = error?.code === 'ENOENT';
|
|
206
|
+
respond(isMissing ? 503 : 500, {
|
|
207
|
+
error: isMissing ? 'Codex CLI not installed' : 'Failed to run Codex CLI',
|
|
208
|
+
details: error.message,
|
|
209
|
+
code: error.code
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
} catch (error) {
|
|
213
|
+
res.status(500).json({ error: 'Failed to remove MCP server', details: error.message });
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
router.get('/mcp/cli/get/:name', async (req, res) => {
|
|
218
|
+
try {
|
|
219
|
+
const { name } = req.params;
|
|
220
|
+
|
|
221
|
+
const respond = createCliResponder(res);
|
|
222
|
+
const proc = spawn('codex', ['mcp', 'get', name], { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
223
|
+
|
|
224
|
+
let stdout = '';
|
|
225
|
+
let stderr = '';
|
|
226
|
+
|
|
227
|
+
proc.stdout?.on('data', (data) => { stdout += data.toString(); });
|
|
228
|
+
proc.stderr?.on('data', (data) => { stderr += data.toString(); });
|
|
229
|
+
|
|
230
|
+
proc.on('close', (code) => {
|
|
231
|
+
if (code === 0) {
|
|
232
|
+
respond(200, { success: true, output: stdout, server: parseCodexGetOutput(stdout) });
|
|
233
|
+
} else {
|
|
234
|
+
respond(404, { error: 'Codex CLI command failed', details: stderr || `Exited with code ${code}` });
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
proc.on('error', (error) => {
|
|
239
|
+
const isMissing = error?.code === 'ENOENT';
|
|
240
|
+
respond(isMissing ? 503 : 500, {
|
|
241
|
+
error: isMissing ? 'Codex CLI not installed' : 'Failed to run Codex CLI',
|
|
242
|
+
details: error.message,
|
|
243
|
+
code: error.code
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
} catch (error) {
|
|
247
|
+
res.status(500).json({ error: 'Failed to get MCP server details', details: error.message });
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
router.get('/mcp/config/read', async (req, res) => {
|
|
252
|
+
try {
|
|
253
|
+
const configPath = path.join(os.homedir(), '.codex', 'config.toml');
|
|
254
|
+
|
|
255
|
+
let configData = null;
|
|
256
|
+
|
|
257
|
+
try {
|
|
258
|
+
const fileContent = await fs.readFile(configPath, 'utf8');
|
|
259
|
+
configData = TOML.parse(fileContent);
|
|
260
|
+
} catch (error) {
|
|
261
|
+
// Config file doesn't exist
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (!configData) {
|
|
265
|
+
return res.json({ success: false, message: 'No Codex configuration file found', servers: [] });
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const servers = [];
|
|
269
|
+
|
|
270
|
+
if (configData.mcp_servers && typeof configData.mcp_servers === 'object') {
|
|
271
|
+
for (const [name, config] of Object.entries(configData.mcp_servers)) {
|
|
272
|
+
servers.push({
|
|
273
|
+
id: name,
|
|
274
|
+
name: name,
|
|
275
|
+
type: 'stdio',
|
|
276
|
+
scope: 'user',
|
|
277
|
+
config: {
|
|
278
|
+
command: config.command || '',
|
|
279
|
+
args: config.args || [],
|
|
280
|
+
env: config.env || {}
|
|
281
|
+
},
|
|
282
|
+
raw: config
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
res.json({ success: true, configPath, servers });
|
|
288
|
+
} catch (error) {
|
|
289
|
+
res.status(500).json({ error: 'Failed to read Codex configuration', details: error.message });
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
function parseCodexListOutput(output) {
|
|
294
|
+
const servers = [];
|
|
295
|
+
const lines = output.split('\n').filter(line => line.trim());
|
|
296
|
+
|
|
297
|
+
for (const line of lines) {
|
|
298
|
+
if (line.includes(':')) {
|
|
299
|
+
const colonIndex = line.indexOf(':');
|
|
300
|
+
const name = line.substring(0, colonIndex).trim();
|
|
301
|
+
|
|
302
|
+
if (!name) continue;
|
|
303
|
+
|
|
304
|
+
const rest = line.substring(colonIndex + 1).trim();
|
|
305
|
+
let description = rest;
|
|
306
|
+
let status = 'unknown';
|
|
307
|
+
|
|
308
|
+
if (rest.includes('✓') || rest.includes('✗')) {
|
|
309
|
+
const statusMatch = rest.match(/(.*?)\s*-\s*([✓✗].*)$/);
|
|
310
|
+
if (statusMatch) {
|
|
311
|
+
description = statusMatch[1].trim();
|
|
312
|
+
status = statusMatch[2].includes('✓') ? 'connected' : 'failed';
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
servers.push({ name, type: 'stdio', status, description });
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return servers;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function parseCodexGetOutput(output) {
|
|
324
|
+
try {
|
|
325
|
+
const jsonMatch = output.match(/\{[\s\S]*\}/);
|
|
326
|
+
if (jsonMatch) {
|
|
327
|
+
return JSON.parse(jsonMatch[0]);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const server = { raw_output: output };
|
|
331
|
+
const lines = output.split('\n');
|
|
332
|
+
|
|
333
|
+
for (const line of lines) {
|
|
334
|
+
if (line.includes('Name:')) server.name = line.split(':')[1]?.trim();
|
|
335
|
+
else if (line.includes('Type:')) server.type = line.split(':')[1]?.trim();
|
|
336
|
+
else if (line.includes('Command:')) server.command = line.split(':')[1]?.trim();
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return server;
|
|
340
|
+
} catch (error) {
|
|
341
|
+
return { raw_output: output, parse_error: error.message };
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export default router;
|