polydev-ai 1.9.20 → 1.9.22

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 CHANGED
@@ -1180,10 +1180,14 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
1180
1180
  const parseCodexOutput = (output) => {
1181
1181
  if (!output || !output.trim()) return null;
1182
1182
 
1183
+ // Strip ANSI escape codes first — Codex CLI wraps markers like 'codex' and
1184
+ // 'tokens used' in bold/color codes which break regex matching
1185
+ const cleanOutput = output.replace(/\x1b\[[0-9;]*m/g, '');
1186
+
1183
1187
  // First, try to extract the response between "codex" marker and "tokens used"
1184
1188
  // IMPORTANT: Use (?:^|\n) to match "codex" only at the start of a line
1185
1189
  // This prevents matching "codex" in model names like "gpt-5.2-codex"
1186
- const codexMarkerMatch = output.match(/(?:^|\n)codex\s*\n([\s\S]*?)(?:\n\s*tokens used|\n\s*$)/i);
1190
+ const codexMarkerMatch = cleanOutput.match(/(?:^|\n)codex\s*\n([\s\S]*?)(?:\n\s*tokens used|\n\s*$)/i);
1187
1191
  if (codexMarkerMatch && codexMarkerMatch[1]) {
1188
1192
  const extracted = codexMarkerMatch[1].trim();
1189
1193
  if (extracted.length > 0 && !extracted.startsWith('ERROR')) {
@@ -1192,7 +1196,7 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
1192
1196
  }
1193
1197
 
1194
1198
  // Fallback: Try to find bullet point responses
1195
- const bulletMatches = output.match(/•\s*(.+)/g);
1199
+ const bulletMatches = cleanOutput.match(/•\s*(.+)/g);
1196
1200
  if (bulletMatches && bulletMatches.length > 0) {
1197
1201
  const bulletContent = bulletMatches
1198
1202
  .map(m => m.replace(/^•\s*/, '').trim())
@@ -1204,8 +1208,9 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
1204
1208
  }
1205
1209
 
1206
1210
  // Last resort: Filter out known noise patterns line by line
1207
- const lines = output.split('\n');
1211
+ const lines = cleanOutput.split('\n');
1208
1212
  const contentLines = [];
1213
+ let seenTokensUsed = false;
1209
1214
 
1210
1215
  // Patterns to skip (Codex-specific noise)
1211
1216
  const noisePatterns = [
@@ -1225,7 +1230,6 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
1225
1230
  /^thinking$/i, // "thinking" marker
1226
1231
  /^codex$/i, // "codex" marker
1227
1232
  /^tokens used$/i, // Token count header
1228
- /^[\d,]+$/, // Just numbers (token counts)
1229
1233
  /^ERROR:\s*MCP/i, // MCP errors
1230
1234
  /MCP client for .* failed/i, // MCP client failures
1231
1235
  /handshake.*failed/i, // Handshake errors
@@ -1240,6 +1244,15 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
1240
1244
  for (const line of lines) {
1241
1245
  const trimmedLine = line.trim();
1242
1246
 
1247
+ // Track when we've passed the "tokens used" footer
1248
+ if (/^tokens used$/i.test(trimmedLine)) {
1249
+ seenTokensUsed = true;
1250
+ continue;
1251
+ }
1252
+
1253
+ // After "tokens used", skip pure numbers (token counts like "22")
1254
+ if (seenTokensUsed && /^[\d,]+$/.test(trimmedLine)) continue;
1255
+
1243
1256
  // Check if line matches any noise pattern
1244
1257
  const isNoise = noisePatterns.some(pattern => pattern.test(trimmedLine));
1245
1258
  if (isNoise) continue;
@@ -820,6 +820,28 @@ Dashboard: https://polydev.ai/dashboard`
820
820
  * @returns {object} JSON-RPC response
821
821
  */
822
822
  async triggerReAuth(id, reason = 'Token invalid or expired') {
823
+ // In sandboxed environments, browser login won't work — show token-paste instructions instead
824
+ if (this.isSandboxed()) {
825
+ console.error('[Polydev] Sandbox detected — skipping browser re-auth, showing token-paste instructions');
826
+ return {
827
+ jsonrpc: '2.0',
828
+ id,
829
+ result: {
830
+ content: [{
831
+ type: 'text',
832
+ text: `${reason}
833
+
834
+ Browser login is not available in this environment (Cowork/container).
835
+
836
+ To authenticate, pass your token directly:
837
+ 1. Get your token from https://polydev.ai/dashboard
838
+ 2. Call: mcp__plugin_polydev_mcp__get_auth_status({ user_token: "pd_your_token_here" })
839
+ 3. Or: mcp__plugin_polydev_mcp__login({ user_token: "pd_your_token_here" })`
840
+ }]
841
+ }
842
+ };
843
+ }
844
+
823
845
  const crypto = require('crypto');
824
846
  const sessionId = crypto.randomBytes(32).toString('hex');
825
847
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polydev-ai",
3
- "version": "1.9.20",
3
+ "version": "1.9.22",
4
4
  "engines": {
5
5
  "node": ">=20.x <=22.x"
6
6
  },