mcp-codex-subagent 1.0.0 → 2.0.5
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/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +366 -4
- package/dist/server.js.map +1 -1
- package/dist/services/output-file.d.ts +38 -0
- package/dist/services/output-file.d.ts.map +1 -0
- package/dist/services/output-file.js +136 -0
- package/dist/services/output-file.js.map +1 -0
- package/dist/services/task-manager.d.ts +69 -0
- package/dist/services/task-manager.d.ts.map +1 -0
- package/dist/services/task-manager.js +171 -0
- package/dist/services/task-manager.js.map +1 -0
- package/dist/tools/definitions.d.ts.map +1 -1
- package/dist/tools/definitions.js +11 -2
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/handlers.d.ts +2 -1
- package/dist/tools/handlers.d.ts.map +1 -1
- package/dist/tools/handlers.js +287 -116
- package/dist/tools/handlers.js.map +1 -1
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/brief-validator.d.ts +34 -0
- package/dist/utils/brief-validator.d.ts.map +1 -0
- package/dist/utils/brief-validator.js +251 -0
- package/dist/utils/brief-validator.js.map +1 -0
- package/dist/utils/format.d.ts +34 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +40 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/task-id-generator.d.ts +15 -0
- package/dist/utils/task-id-generator.d.ts.map +1 -0
- package/dist/utils/task-id-generator.js +45 -0
- package/dist/utils/task-id-generator.js.map +1 -0
- package/package.json +15 -15
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { CodexMcpServer } from './server.js';
|
|
4
|
+
import { closeAllOutputHandles } from './services/output-file.js';
|
|
4
5
|
const SERVER_CONFIG = {
|
|
5
6
|
name: 'codex-mcp-server',
|
|
6
7
|
version: '0.0.6',
|
|
@@ -15,5 +16,17 @@ async function main() {
|
|
|
15
16
|
process.exit(1);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
19
|
+
// Graceful shutdown: close all output file handles
|
|
20
|
+
async function shutdown() {
|
|
21
|
+
try {
|
|
22
|
+
await closeAllOutputHandles();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Best-effort cleanup
|
|
26
|
+
}
|
|
27
|
+
process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
process.on('SIGINT', shutdown);
|
|
30
|
+
process.on('SIGTERM', shutdown);
|
|
18
31
|
main();
|
|
19
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,aAAa,GAAG;IACpB,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,OAAO;CACR,CAAC;AAEX,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,aAAa,CAAC,CAAC;QACjD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,mDAAmD;AACnD,KAAK,UAAU,QAAQ;IACrB,IAAI,CAAC;QACH,MAAM,qBAAqB,EAAE,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,sBAAsB;IACxB,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAEhC,IAAI,EAAE,CAAC"}
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,YAAY,EAKlB,MAAM,YAAY,CAAC;AAwLpB,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,YAAY;IA6BhC,OAAO,CAAC,aAAa;IA2SrB,OAAO,CAAC,eAAe;IAIjB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK7B"}
|
package/dist/server.js
CHANGED
|
@@ -1,11 +1,150 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { TOOLS, } from './types.js';
|
|
6
6
|
import { handleError } from './errors.js';
|
|
7
7
|
import { toolDefinitions } from './tools/definitions.js';
|
|
8
|
-
import { toolHandlers } from './tools/handlers.js';
|
|
8
|
+
import { toolHandlers, setNotificationSender } from './tools/handlers.js';
|
|
9
|
+
import { getTask, getAllTasks, getTaskCounts, } from './services/task-manager.js';
|
|
10
|
+
/**
|
|
11
|
+
* Parse JSONL output lines into structured events.
|
|
12
|
+
* Silently skips non-JSON lines (e.g. legacy output or header leftovers).
|
|
13
|
+
*/
|
|
14
|
+
function parseOutputLines(lines) {
|
|
15
|
+
const events = [];
|
|
16
|
+
for (const line of lines) {
|
|
17
|
+
const trimmed = line.trim();
|
|
18
|
+
if (!trimmed || trimmed.startsWith('#'))
|
|
19
|
+
continue;
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(trimmed);
|
|
22
|
+
if (parsed && typeof parsed === 'object' && parsed.type) {
|
|
23
|
+
events.push(parsed);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Skip non-JSON lines
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return events;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Build analytics dashboard from parsed JSONL events.
|
|
34
|
+
* Includes event counts, error summary, and context-aware jq suggestions.
|
|
35
|
+
*/
|
|
36
|
+
function buildAnalytics(events, outputFilePath) {
|
|
37
|
+
const eventCounts = {};
|
|
38
|
+
const errors = [];
|
|
39
|
+
let commandsRun = 0;
|
|
40
|
+
let commandsFailed = 0;
|
|
41
|
+
let filesChanged = 0;
|
|
42
|
+
let mcpCalls = 0;
|
|
43
|
+
let agentMessages = 0;
|
|
44
|
+
let reasoningSteps = 0;
|
|
45
|
+
for (const evt of events) {
|
|
46
|
+
eventCounts[evt.type] = (eventCounts[evt.type] || 0) + 1;
|
|
47
|
+
switch (evt.type) {
|
|
48
|
+
case 'command_execution':
|
|
49
|
+
commandsRun++;
|
|
50
|
+
if (evt.exit_code !== 0 && evt.exit_code !== undefined && evt.exit_code !== null) {
|
|
51
|
+
commandsFailed++;
|
|
52
|
+
errors.push({
|
|
53
|
+
type: 'command_failed',
|
|
54
|
+
command: String(evt.command ?? '').slice(0, 120),
|
|
55
|
+
message: `exit code ${evt.exit_code}`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case 'file_change':
|
|
60
|
+
if (Array.isArray(evt.changes)) {
|
|
61
|
+
filesChanged += evt.changes.length;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
filesChanged++;
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
case 'mcp_tool_call':
|
|
68
|
+
mcpCalls++;
|
|
69
|
+
if (evt.status === 'failed' || evt.error) {
|
|
70
|
+
errors.push({
|
|
71
|
+
type: 'mcp_tool_failed',
|
|
72
|
+
message: String(evt.error ?? `${evt.server}/${evt.tool} failed`).slice(0, 200),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case 'agent_message':
|
|
77
|
+
agentMessages++;
|
|
78
|
+
break;
|
|
79
|
+
case 'reasoning':
|
|
80
|
+
reasoningSteps++;
|
|
81
|
+
break;
|
|
82
|
+
case 'error':
|
|
83
|
+
errors.push({
|
|
84
|
+
type: 'error',
|
|
85
|
+
code: evt.code ?? null,
|
|
86
|
+
message: String(evt.message ?? 'Unknown error').slice(0, 200),
|
|
87
|
+
});
|
|
88
|
+
break;
|
|
89
|
+
case 'turn_failed':
|
|
90
|
+
errors.push({
|
|
91
|
+
type: 'turn_failed',
|
|
92
|
+
code: evt.code ?? null,
|
|
93
|
+
message: String(evt.message ?? 'Turn failed').slice(0, 200),
|
|
94
|
+
});
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
// Items with _failed marker
|
|
98
|
+
if (evt._failed) {
|
|
99
|
+
errors.push({
|
|
100
|
+
type: `${evt.type}_failed`,
|
|
101
|
+
message: String(evt.error ?? 'Item failed').slice(0, 200),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Build context-aware jq suggestions
|
|
108
|
+
const suggested = [];
|
|
109
|
+
const f = outputFilePath;
|
|
110
|
+
if (f) {
|
|
111
|
+
const jqPrefix = `cat ${f} | grep '^{'`;
|
|
112
|
+
// Always useful: agent responses
|
|
113
|
+
if (agentMessages > 0) {
|
|
114
|
+
suggested.push(`${jqPrefix} | jq -r 'select(.type=="agent_message") | .text'`);
|
|
115
|
+
}
|
|
116
|
+
// Commands: show if any were run
|
|
117
|
+
if (commandsRun > 0) {
|
|
118
|
+
suggested.push(`${jqPrefix} | jq 'select(.type=="command_execution") | {command,exit_code,status}'`);
|
|
119
|
+
}
|
|
120
|
+
// Errors: only if there are actual errors
|
|
121
|
+
if (errors.length > 0) {
|
|
122
|
+
suggested.push(`${jqPrefix} | jq 'select(._failed or .type=="error" or .type=="turn_failed" or (.type=="command_execution" and .exit_code!=0))'`);
|
|
123
|
+
}
|
|
124
|
+
// File changes: show if any
|
|
125
|
+
if (filesChanged > 0) {
|
|
126
|
+
suggested.push(`${jqPrefix} | jq 'select(.type=="file_change") | .changes'`);
|
|
127
|
+
}
|
|
128
|
+
// MCP calls: show if any
|
|
129
|
+
if (mcpCalls > 0) {
|
|
130
|
+
suggested.push(`${jqPrefix} | jq 'select(.type=="mcp_tool_call") | {server,tool,status}'`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
total_lines: events.length,
|
|
135
|
+
event_counts: eventCounts,
|
|
136
|
+
has_errors: errors.length > 0,
|
|
137
|
+
error_count: errors.length,
|
|
138
|
+
errors,
|
|
139
|
+
commands_run: commandsRun,
|
|
140
|
+
commands_failed: commandsFailed,
|
|
141
|
+
files_changed: filesChanged,
|
|
142
|
+
mcp_calls: mcpCalls,
|
|
143
|
+
agent_messages: agentMessages,
|
|
144
|
+
reasoning_steps: reasoningSteps,
|
|
145
|
+
suggested_commands: suggested,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
9
148
|
export class CodexMcpServer {
|
|
10
149
|
server;
|
|
11
150
|
config;
|
|
@@ -17,9 +156,21 @@ export class CodexMcpServer {
|
|
|
17
156
|
}, {
|
|
18
157
|
capabilities: {
|
|
19
158
|
tools: {},
|
|
159
|
+
resources: {},
|
|
20
160
|
},
|
|
21
161
|
});
|
|
22
162
|
this.setupHandlers();
|
|
163
|
+
// Wire notification sender so handlers can send resource-changed notifications
|
|
164
|
+
setNotificationSender({
|
|
165
|
+
sendNotification: async (notification) => {
|
|
166
|
+
try {
|
|
167
|
+
await this.server.sendResourceListChanged();
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// Non-fatal
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
});
|
|
23
174
|
}
|
|
24
175
|
setupHandlers() {
|
|
25
176
|
// List tools handler
|
|
@@ -30,7 +181,6 @@ export class CodexMcpServer {
|
|
|
30
181
|
this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
31
182
|
const { name, arguments: args } = request.params;
|
|
32
183
|
const progressToken = request.params._meta?.progressToken;
|
|
33
|
-
// Create progress sender that uses MCP notifications
|
|
34
184
|
const createProgressContext = () => {
|
|
35
185
|
let progressCount = 0;
|
|
36
186
|
return {
|
|
@@ -51,7 +201,6 @@ export class CodexMcpServer {
|
|
|
51
201
|
});
|
|
52
202
|
}
|
|
53
203
|
catch (err) {
|
|
54
|
-
// Log but don't fail the operation if progress notification fails
|
|
55
204
|
console.error(chalk.yellow('Failed to send progress notification:'), err);
|
|
56
205
|
}
|
|
57
206
|
},
|
|
@@ -77,6 +226,219 @@ export class CodexMcpServer {
|
|
|
77
226
|
};
|
|
78
227
|
}
|
|
79
228
|
});
|
|
229
|
+
// --- MCP Resources ---
|
|
230
|
+
// List resources
|
|
231
|
+
this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
232
|
+
const tasks = getAllTasks();
|
|
233
|
+
const counts = getTaskCounts();
|
|
234
|
+
const resources = [
|
|
235
|
+
{
|
|
236
|
+
uri: 'system:///status',
|
|
237
|
+
name: 'System Status',
|
|
238
|
+
description: `Server status — ${counts.total} tasks (${counts.running} running, ${counts.completed} completed, ${counts.failed} failed)`,
|
|
239
|
+
mimeType: 'application/json',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
uri: 'task:///all',
|
|
243
|
+
name: 'All Tasks',
|
|
244
|
+
description: `${counts.total} tasks total`,
|
|
245
|
+
mimeType: 'application/json',
|
|
246
|
+
},
|
|
247
|
+
];
|
|
248
|
+
// Add individual task resources
|
|
249
|
+
for (const task of tasks) {
|
|
250
|
+
resources.push({
|
|
251
|
+
uri: `task:///${task.id}`,
|
|
252
|
+
name: `Task: ${task.id}`,
|
|
253
|
+
description: `[${task.status}] ${task.prompt.slice(0, 80)}`,
|
|
254
|
+
mimeType: 'application/json',
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
return { resources };
|
|
258
|
+
});
|
|
259
|
+
// List resource templates
|
|
260
|
+
this.server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => {
|
|
261
|
+
return {
|
|
262
|
+
resourceTemplates: [
|
|
263
|
+
{
|
|
264
|
+
uriTemplate: 'task:///{task_id}',
|
|
265
|
+
name: 'Task Details',
|
|
266
|
+
description: 'Full task detail including output tail, metadata, and timing',
|
|
267
|
+
mimeType: 'application/json',
|
|
268
|
+
},
|
|
269
|
+
],
|
|
270
|
+
};
|
|
271
|
+
});
|
|
272
|
+
// Read resource
|
|
273
|
+
this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
274
|
+
const { uri } = request.params;
|
|
275
|
+
// system:///status
|
|
276
|
+
if (uri === 'system:///status') {
|
|
277
|
+
const counts = getTaskCounts();
|
|
278
|
+
const status = {
|
|
279
|
+
server: {
|
|
280
|
+
name: this.config.name,
|
|
281
|
+
version: this.config.version,
|
|
282
|
+
model: 'gpt-5.3-codex',
|
|
283
|
+
uptime_seconds: Math.floor(process.uptime()),
|
|
284
|
+
},
|
|
285
|
+
tasks: counts,
|
|
286
|
+
};
|
|
287
|
+
return {
|
|
288
|
+
contents: [
|
|
289
|
+
{
|
|
290
|
+
uri,
|
|
291
|
+
mimeType: 'application/json',
|
|
292
|
+
text: JSON.stringify(status, null, 2),
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
// task:///all
|
|
298
|
+
if (uri === 'task:///all') {
|
|
299
|
+
const tasks = getAllTasks();
|
|
300
|
+
const summary = {
|
|
301
|
+
count: tasks.length,
|
|
302
|
+
tasks: tasks.map(t => {
|
|
303
|
+
const events = parseOutputLines(t.output);
|
|
304
|
+
const analytics = buildAnalytics(events);
|
|
305
|
+
let durationMs = null;
|
|
306
|
+
if (t.startTime) {
|
|
307
|
+
const end = t.endTime ? new Date(t.endTime).getTime() : Date.now();
|
|
308
|
+
durationMs = end - new Date(t.startTime).getTime();
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
id: t.id,
|
|
312
|
+
status: t.status,
|
|
313
|
+
role: t.role,
|
|
314
|
+
specialization: t.specialization,
|
|
315
|
+
model: t.model,
|
|
316
|
+
started: t.startTime,
|
|
317
|
+
ended: t.endTime,
|
|
318
|
+
duration_ms: durationMs,
|
|
319
|
+
// Lightweight analytics summary
|
|
320
|
+
events: analytics.total_lines,
|
|
321
|
+
commands: analytics.commands_run,
|
|
322
|
+
commands_failed: analytics.commands_failed,
|
|
323
|
+
files_changed: analytics.files_changed,
|
|
324
|
+
mcp_calls: analytics.mcp_calls,
|
|
325
|
+
has_errors: analytics.has_errors,
|
|
326
|
+
error_count: analytics.error_count,
|
|
327
|
+
...(t.error && { error: t.error }),
|
|
328
|
+
cwd: t.cwd,
|
|
329
|
+
prompt: t.prompt,
|
|
330
|
+
};
|
|
331
|
+
}),
|
|
332
|
+
};
|
|
333
|
+
return {
|
|
334
|
+
contents: [
|
|
335
|
+
{
|
|
336
|
+
uri,
|
|
337
|
+
mimeType: 'application/json',
|
|
338
|
+
text: JSON.stringify(summary, null, 2),
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
// task:///{id}
|
|
344
|
+
const taskIdMatch = uri.match(/^task:\/\/\/(.+)$/);
|
|
345
|
+
if (taskIdMatch) {
|
|
346
|
+
const taskId = taskIdMatch[1];
|
|
347
|
+
const task = getTask(taskId);
|
|
348
|
+
if (!task) {
|
|
349
|
+
return {
|
|
350
|
+
contents: [
|
|
351
|
+
{
|
|
352
|
+
uri,
|
|
353
|
+
mimeType: 'application/json',
|
|
354
|
+
text: JSON.stringify({ error: `Task "${taskId}" not found` }),
|
|
355
|
+
},
|
|
356
|
+
],
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
// Parse JSONL output and build analytics dashboard
|
|
360
|
+
const events = parseOutputLines(task.output);
|
|
361
|
+
const analytics = buildAnalytics(events, task.outputFilePath);
|
|
362
|
+
// Duration
|
|
363
|
+
let durationMs = null;
|
|
364
|
+
if (task.startTime) {
|
|
365
|
+
const end = task.endTime ? new Date(task.endTime).getTime() : Date.now();
|
|
366
|
+
durationMs = end - new Date(task.startTime).getTime();
|
|
367
|
+
}
|
|
368
|
+
// Extract last agent message as the "result" preview
|
|
369
|
+
const lastAgentMsg = events
|
|
370
|
+
.filter(e => e.type === 'agent_message')
|
|
371
|
+
.pop();
|
|
372
|
+
// Build the output tail — only agent_message and command_execution
|
|
373
|
+
// (the stuff the caller actually cares about, not reasoning/stderr)
|
|
374
|
+
const meaningfulEvents = events.filter(e => e.type === 'agent_message' ||
|
|
375
|
+
e.type === 'command_execution' ||
|
|
376
|
+
e.type === 'file_change' ||
|
|
377
|
+
e.type === 'error' ||
|
|
378
|
+
e.type === 'turn_failed' ||
|
|
379
|
+
e._failed);
|
|
380
|
+
const outputTail = meaningfulEvents.slice(-30).map(e => JSON.stringify(e));
|
|
381
|
+
const detail = {
|
|
382
|
+
// — Dashboard / analytics (top-level summary) —
|
|
383
|
+
analytics: {
|
|
384
|
+
total_events: analytics.total_lines,
|
|
385
|
+
event_counts: analytics.event_counts,
|
|
386
|
+
commands_run: analytics.commands_run,
|
|
387
|
+
commands_failed: analytics.commands_failed,
|
|
388
|
+
files_changed: analytics.files_changed,
|
|
389
|
+
mcp_tool_calls: analytics.mcp_calls,
|
|
390
|
+
agent_messages: analytics.agent_messages,
|
|
391
|
+
reasoning_steps: analytics.reasoning_steps,
|
|
392
|
+
duration_ms: durationMs,
|
|
393
|
+
...(analytics.has_errors && {
|
|
394
|
+
errors: analytics.errors,
|
|
395
|
+
}),
|
|
396
|
+
},
|
|
397
|
+
// — Task metadata —
|
|
398
|
+
id: task.id,
|
|
399
|
+
status: task.status,
|
|
400
|
+
role: task.role,
|
|
401
|
+
specialization: task.specialization,
|
|
402
|
+
model: task.model,
|
|
403
|
+
started: task.startTime,
|
|
404
|
+
ended: task.endTime,
|
|
405
|
+
cwd: task.cwd,
|
|
406
|
+
output_file: task.outputFilePath,
|
|
407
|
+
prompt: task.prompt,
|
|
408
|
+
...(task.error && { error: task.error }),
|
|
409
|
+
// — Content —
|
|
410
|
+
...(lastAgentMsg && { last_agent_message: lastAgentMsg.text }),
|
|
411
|
+
output_tail: outputTail.join('\n'),
|
|
412
|
+
// — Suggested jq commands (only relevant ones) —
|
|
413
|
+
...(analytics.suggested_commands.length > 0 && {
|
|
414
|
+
suggested_commands: analytics.suggested_commands,
|
|
415
|
+
}),
|
|
416
|
+
};
|
|
417
|
+
// Include last_message from metadata if available
|
|
418
|
+
if (task.metadata?.lastMessage) {
|
|
419
|
+
detail.last_message = task.metadata.lastMessage;
|
|
420
|
+
}
|
|
421
|
+
return {
|
|
422
|
+
contents: [
|
|
423
|
+
{
|
|
424
|
+
uri,
|
|
425
|
+
mimeType: 'application/json',
|
|
426
|
+
text: JSON.stringify(detail, null, 2),
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
// Unknown URI
|
|
432
|
+
return {
|
|
433
|
+
contents: [
|
|
434
|
+
{
|
|
435
|
+
uri,
|
|
436
|
+
mimeType: 'text/plain',
|
|
437
|
+
text: `Unknown resource: ${uri}`,
|
|
438
|
+
},
|
|
439
|
+
],
|
|
440
|
+
};
|
|
441
|
+
});
|
|
80
442
|
}
|
|
81
443
|
isValidToolName(name) {
|
|
82
444
|
return Object.values(TOOLS).includes(name);
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAKL,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,OAAO,cAAc;IACR,MAAM,CAAS;IACf,MAAM,CAAe;IAEtC,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CACtB;YACE,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,EACD;YACE,YAAY,EAAE;gBACZ,KAAK,EAAE,EAAE;aACV;SACF,CACF,CAAC;QAEF,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAEO,a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AM,GAAG,CAAC,IAAI;wBAC7C,kBAAkB,EAAE,SAAS,CAAC,kBAAkB;qBACjD,CAAC;iBACH,CAAC;gBAEF,kDAAkD;gBAClD,IAAI,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;oBAC/B,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;gBAClD,CAAC;gBAED,OAAO;oBACL,QAAQ,EAAE;wBACR;4BACE,GAAG;4BACH,QAAQ,EAAE,kBAAkB;4BAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;yBACtC;qBACF;iBACF,CAAC;YACJ,CAAC;YAED,cAAc;YACd,OAAO;gBACL,QAAQ,EAAE;oBACR;wBACE,GAAG;wBACH,QAAQ,EAAE,YAAY;wBACtB,IAAI,EAAE,qBAAqB,GAAG,EAAE;qBACjC;iBACF;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,eAAe,CAAC,IAAY;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAgB,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,uBAAuB,CAAC,CAAC,CAAC;IACzE,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages task output file persistence with streaming.
|
|
3
|
+
* Ported from mcp-supersubagents/src/services/output-file.ts
|
|
4
|
+
* Uses .codex-agents/ directory (distinct from .super-agents/).
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Get the output directory path for a given cwd.
|
|
8
|
+
* Returns: {cwd}/.codex-agents/
|
|
9
|
+
*/
|
|
10
|
+
export declare function getOutputDir(cwd: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Get the output file path for a task.
|
|
13
|
+
* Returns: {cwd}/.codex-agents/{taskId}.output
|
|
14
|
+
*/
|
|
15
|
+
export declare function getOutputPath(cwd: string, taskId: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Get the last-message file path for a task.
|
|
18
|
+
* Returns: {cwd}/.codex-agents/{taskId}.last-message.txt
|
|
19
|
+
*/
|
|
20
|
+
export declare function getLastMessagePath(cwd: string, taskId: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Create an empty output file for a task.
|
|
23
|
+
* Returns the absolute path to the output file, or null on failure.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createOutputFile(cwd: string, taskId: string): Promise<string | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Append a line to the task's output file (async, uses persistent handle).
|
|
28
|
+
*/
|
|
29
|
+
export declare function appendToOutputFile(cwd: string, taskId: string, line: string): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Append completion footer to output file and close handle.
|
|
32
|
+
*/
|
|
33
|
+
export declare function finalizeOutputFile(cwd: string, taskId: string, status: string, error?: string): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Close all open file handles (called during shutdown).
|
|
36
|
+
*/
|
|
37
|
+
export declare function closeAllOutputHandles(): Promise<void>;
|
|
38
|
+
//# sourceMappingURL=output-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-file.d.ts","sourceRoot":"","sources":["../../src/services/output-file.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE;AAkBD;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmB1F;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBpG;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAuBtH;AAED;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAS3D"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages task output file persistence with streaming.
|
|
3
|
+
* Ported from mcp-supersubagents/src/services/output-file.ts
|
|
4
|
+
* Uses .codex-agents/ directory (distinct from .super-agents/).
|
|
5
|
+
*/
|
|
6
|
+
import { open, mkdir } from 'fs/promises';
|
|
7
|
+
import { join } from 'path';
|
|
8
|
+
const OUTPUT_DIR_NAME = '.codex-agents';
|
|
9
|
+
// Cache of directories known to exist — avoids stat syscall on every append
|
|
10
|
+
const knownDirs = new Set();
|
|
11
|
+
// Persistent file handles — one per task, closed on finalize
|
|
12
|
+
const openHandles = new Map();
|
|
13
|
+
/**
|
|
14
|
+
* Get the output directory path for a given cwd.
|
|
15
|
+
* Returns: {cwd}/.codex-agents/
|
|
16
|
+
*/
|
|
17
|
+
export function getOutputDir(cwd) {
|
|
18
|
+
return join(cwd, OUTPUT_DIR_NAME);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get the output file path for a task.
|
|
22
|
+
* Returns: {cwd}/.codex-agents/{taskId}.output
|
|
23
|
+
*/
|
|
24
|
+
export function getOutputPath(cwd, taskId) {
|
|
25
|
+
return join(getOutputDir(cwd), `${taskId}.output`);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the last-message file path for a task.
|
|
29
|
+
* Returns: {cwd}/.codex-agents/{taskId}.last-message.txt
|
|
30
|
+
*/
|
|
31
|
+
export function getLastMessagePath(cwd, taskId) {
|
|
32
|
+
return join(getOutputDir(cwd), `${taskId}.last-message.txt`);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Ensure output directory exists (async, cached).
|
|
36
|
+
*/
|
|
37
|
+
async function ensureOutputDir(cwd) {
|
|
38
|
+
const dir = getOutputDir(cwd);
|
|
39
|
+
if (knownDirs.has(dir))
|
|
40
|
+
return true;
|
|
41
|
+
try {
|
|
42
|
+
await mkdir(dir, { recursive: true });
|
|
43
|
+
knownDirs.add(dir);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error(`[output-file] Failed to create output directory: ${error}`);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create an empty output file for a task.
|
|
53
|
+
* Returns the absolute path to the output file, or null on failure.
|
|
54
|
+
*/
|
|
55
|
+
export async function createOutputFile(cwd, taskId) {
|
|
56
|
+
if (!(await ensureOutputDir(cwd))) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const outputPath = getOutputPath(cwd, taskId);
|
|
60
|
+
try {
|
|
61
|
+
const header = `# Task: ${taskId}\n# Started: ${new Date().toISOString()}\n# Working directory: ${cwd}\n${'─'.repeat(60)}\n\n`;
|
|
62
|
+
// Write header and close immediately — appendToOutputFile will open
|
|
63
|
+
// its own persistent handle on first call.
|
|
64
|
+
const handle = await open(outputPath, 'w');
|
|
65
|
+
await handle.write(header);
|
|
66
|
+
await handle.close();
|
|
67
|
+
return outputPath;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.error(`[output-file] Failed to create output file: ${error}`);
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Append a line to the task's output file (async, uses persistent handle).
|
|
76
|
+
*/
|
|
77
|
+
export async function appendToOutputFile(cwd, taskId, line) {
|
|
78
|
+
const key = `${cwd}:${taskId}`;
|
|
79
|
+
try {
|
|
80
|
+
let handle = openHandles.get(key);
|
|
81
|
+
if (!handle) {
|
|
82
|
+
await ensureOutputDir(cwd);
|
|
83
|
+
handle = await open(getOutputPath(cwd, taskId), 'a');
|
|
84
|
+
openHandles.set(key, handle);
|
|
85
|
+
}
|
|
86
|
+
await handle.write(line + '\n');
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Silent failure — don't break task execution for file I/O issues
|
|
91
|
+
openHandles.delete(key);
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Append completion footer to output file and close handle.
|
|
97
|
+
*/
|
|
98
|
+
export async function finalizeOutputFile(cwd, taskId, status, error) {
|
|
99
|
+
const key = `${cwd}:${taskId}`;
|
|
100
|
+
try {
|
|
101
|
+
const footer = [
|
|
102
|
+
'',
|
|
103
|
+
'─'.repeat(60),
|
|
104
|
+
`# Completed: ${new Date().toISOString()}`,
|
|
105
|
+
`# Status: ${status}`,
|
|
106
|
+
error ? `# Error: ${error}` : null,
|
|
107
|
+
].filter(Boolean).join('\n') + '\n';
|
|
108
|
+
let handle = openHandles.get(key);
|
|
109
|
+
if (!handle) {
|
|
110
|
+
handle = await open(getOutputPath(cwd, taskId), 'a');
|
|
111
|
+
}
|
|
112
|
+
await handle.write(footer);
|
|
113
|
+
await handle.close();
|
|
114
|
+
openHandles.delete(key);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
openHandles.delete(key);
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Close all open file handles (called during shutdown).
|
|
124
|
+
*/
|
|
125
|
+
export async function closeAllOutputHandles() {
|
|
126
|
+
for (const [key, handle] of openHandles) {
|
|
127
|
+
try {
|
|
128
|
+
await handle.close();
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
// Ignore close errors during shutdown
|
|
132
|
+
}
|
|
133
|
+
openHandles.delete(key);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=output-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-file.js","sourceRoot":"","sources":["../../src/services/output-file.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,eAAe,GAAG,eAAe,CAAC;AAExC,4EAA4E;AAC5E,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;AAEpC,6DAA6D;AAC7D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,MAAc;IACvD,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,SAAS,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,MAAc;IAC5D,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,GAAG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