polydev-ai 1.8.28 → 1.8.30
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/lib/cliManager.js +7 -0
- package/mcp/stdio-wrapper.js +22 -15
- package/package.json +1 -1
package/lib/cliManager.js
CHANGED
|
@@ -1069,14 +1069,21 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
1069
1069
|
const parseCodexOutput = (output) => {
|
|
1070
1070
|
if (!output || !output.trim()) return null;
|
|
1071
1071
|
|
|
1072
|
+
// DEBUG: Log raw output for troubleshooting
|
|
1073
|
+
console.log('[CLI Debug] parseCodexOutput raw input length:', output.length);
|
|
1074
|
+
console.log('[CLI Debug] parseCodexOutput raw input (first 500 chars):', output.substring(0, 500));
|
|
1075
|
+
|
|
1072
1076
|
// First, try to extract the response between "codex" marker and "tokens used"
|
|
1073
1077
|
// This is the most reliable pattern for Codex CLI output
|
|
1074
1078
|
const codexMarkerMatch = output.match(/\bcodex\s*\n([\s\S]*?)(?:\n\s*tokens used|\n\s*$)/i);
|
|
1075
1079
|
if (codexMarkerMatch && codexMarkerMatch[1]) {
|
|
1076
1080
|
const extracted = codexMarkerMatch[1].trim();
|
|
1081
|
+
console.log('[CLI Debug] codexMarkerMatch found:', JSON.stringify(extracted));
|
|
1077
1082
|
if (extracted.length > 0 && !extracted.startsWith('ERROR')) {
|
|
1078
1083
|
return extracted;
|
|
1079
1084
|
}
|
|
1085
|
+
} else {
|
|
1086
|
+
console.log('[CLI Debug] No codexMarkerMatch found');
|
|
1080
1087
|
}
|
|
1081
1088
|
|
|
1082
1089
|
// Fallback: Try to find bullet point responses
|
package/mcp/stdio-wrapper.js
CHANGED
|
@@ -105,7 +105,7 @@ if (writableTmp) {
|
|
|
105
105
|
* Strips: provider info, approval, sandbox, reasoning, session id, MCP errors, etc.
|
|
106
106
|
*
|
|
107
107
|
* Codex CLI output structure:
|
|
108
|
-
* [metadata] → user → [echoed prompt] → thinking → [status] → codex → [RESPONSE]
|
|
108
|
+
* [metadata] → user → [echoed prompt] → thinking → [status] → codex → [RESPONSE] → tokens used → [count]
|
|
109
109
|
*
|
|
110
110
|
* Claude Code output structure:
|
|
111
111
|
* [may include JSON or plain text response]
|
|
@@ -119,7 +119,7 @@ function cleanCliResponse(content) {
|
|
|
119
119
|
const cleanedLines = [];
|
|
120
120
|
|
|
121
121
|
// State machine for Codex CLI output parsing
|
|
122
|
-
// States: 'metadata' | 'user_section' | 'thinking_section' | 'response'
|
|
122
|
+
// States: 'metadata' | 'user_section' | 'thinking_section' | 'response' | 'footer'
|
|
123
123
|
let state = 'metadata';
|
|
124
124
|
let foundCodexMarker = false;
|
|
125
125
|
|
|
@@ -127,11 +127,16 @@ function cleanCliResponse(content) {
|
|
|
127
127
|
const line = lines[i];
|
|
128
128
|
const trimmed = line.trim();
|
|
129
129
|
|
|
130
|
-
// Always skip
|
|
130
|
+
// Always skip these patterns anywhere in the output
|
|
131
131
|
if (trimmed.startsWith('ERROR: MCP client for')) continue;
|
|
132
132
|
if (trimmed.includes('failed to start') && trimmed.includes('MCP')) continue;
|
|
133
133
|
if (trimmed.includes('handshake') && trimmed.includes('failed')) continue;
|
|
134
134
|
if (trimmed.includes('connection closed')) continue;
|
|
135
|
+
if (trimmed.startsWith('mcp:')) continue; // MCP startup logs
|
|
136
|
+
if (trimmed.startsWith('mcp startup:')) continue; // MCP startup summary
|
|
137
|
+
if (trimmed.includes('rmcp::transport')) continue; // RMCP transport errors
|
|
138
|
+
if (trimmed.includes('ERROR rmcp')) continue;
|
|
139
|
+
if (trimmed.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)) continue; // Timestamp logs
|
|
135
140
|
|
|
136
141
|
// State: metadata - skip until we hit a section marker
|
|
137
142
|
if (state === 'metadata') {
|
|
@@ -186,13 +191,7 @@ function cleanCliResponse(content) {
|
|
|
186
191
|
foundCodexMarker = true;
|
|
187
192
|
continue;
|
|
188
193
|
}
|
|
189
|
-
// Skip
|
|
190
|
-
if (trimmed.startsWith('mcp:')) continue;
|
|
191
|
-
if (trimmed.startsWith('mcp startup:')) continue;
|
|
192
|
-
// Skip RMCP transport errors
|
|
193
|
-
if (trimmed.includes('rmcp::transport')) continue;
|
|
194
|
-
if (trimmed.includes('ERROR rmcp')) continue;
|
|
195
|
-
// Skip everything in user section (echoed prompt, errors)
|
|
194
|
+
// Skip everything in user section (echoed prompt)
|
|
196
195
|
continue;
|
|
197
196
|
}
|
|
198
197
|
|
|
@@ -209,16 +208,24 @@ function cleanCliResponse(content) {
|
|
|
209
208
|
|
|
210
209
|
// State: response - keep actual response content
|
|
211
210
|
if (state === 'response') {
|
|
212
|
-
//
|
|
213
|
-
if (trimmed === 'tokens used')
|
|
214
|
-
|
|
211
|
+
// Transition to footer when we see "tokens used"
|
|
212
|
+
if (trimmed === 'tokens used') {
|
|
213
|
+
state = 'footer';
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
215
216
|
|
|
216
|
-
// Skip any
|
|
217
|
+
// Skip any bold status markers like **Processing...**
|
|
217
218
|
if (trimmed.match(/^\*\*.*\*\*$/)) continue;
|
|
218
219
|
|
|
219
|
-
// Keep this line
|
|
220
|
+
// Keep this line - it's the actual response
|
|
220
221
|
cleanedLines.push(line);
|
|
221
222
|
}
|
|
223
|
+
|
|
224
|
+
// State: footer - skip token count and anything after
|
|
225
|
+
if (state === 'footer') {
|
|
226
|
+
// Skip everything in footer (token counts, etc.)
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
222
229
|
}
|
|
223
230
|
|
|
224
231
|
// Trim leading/trailing empty lines
|
package/package.json
CHANGED