polydev-ai 1.8.85 → 1.8.87

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.
@@ -259,6 +259,11 @@ class StdioMCPWrapper {
259
259
  // Load manifest for tool definitions
260
260
  this.loadManifest();
261
261
 
262
+ // Try to reload token from files if not in env (hot-reload support)
263
+ if (!this.isAuthenticated) {
264
+ this.reloadTokenFromFiles();
265
+ }
266
+
262
267
  // Log startup status
263
268
  if (this.userToken) {
264
269
  console.error('[Polydev] Starting with authentication token');
@@ -345,6 +350,11 @@ class StdioMCPWrapper {
345
350
  }
346
351
 
347
352
  // All other tools require authentication
353
+ // Try hot-reload first if not authenticated
354
+ if (!this.isAuthenticated) {
355
+ this.reloadTokenFromFiles();
356
+ }
357
+
348
358
  if (!this.isAuthenticated) {
349
359
  return {
350
360
  jsonrpc: '2.0',
@@ -524,6 +534,11 @@ class StdioMCPWrapper {
524
534
  * Handle get_auth_status tool
525
535
  */
526
536
  async handleGetAuthStatus(params, id) {
537
+ // Try to hot-reload token if not authenticated
538
+ if (!this.isAuthenticated || !this.userToken) {
539
+ this.reloadTokenFromFiles();
540
+ }
541
+
527
542
  if (!this.isAuthenticated || !this.userToken) {
528
543
  return {
529
544
  jsonrpc: '2.0',
@@ -676,6 +691,37 @@ class StdioMCPWrapper {
676
691
  console.error(`[Polydev] Token saved to ${rcFile} and ${envFile}`);
677
692
  }
678
693
 
694
+ /**
695
+ * Reload token from config files (hot-reload support)
696
+ * Called when token is not in env or when auth fails
697
+ */
698
+ reloadTokenFromFiles() {
699
+ const locations = [
700
+ path.join(os.homedir(), '.polydev.env'),
701
+ path.join(os.homedir(), '.zshrc'),
702
+ path.join(os.homedir(), '.bashrc'),
703
+ path.join(os.homedir(), '.profile')
704
+ ];
705
+
706
+ for (const loc of locations) {
707
+ try {
708
+ if (!fs.existsSync(loc)) continue;
709
+ const content = fs.readFileSync(loc, 'utf8');
710
+ const match = content.match(/POLYDEV_USER_TOKEN[=\s]["']?([^"'\n]+)["']?/);
711
+ if (match && match[1] && (match[1].startsWith('pd_') || match[1].startsWith('polydev_'))) {
712
+ this.userToken = match[1];
713
+ this.isAuthenticated = true;
714
+ process.env.POLYDEV_USER_TOKEN = match[1]; // Update env for consistency
715
+ console.error(`[Polydev] Token hot-reloaded from ${loc}`);
716
+ return true;
717
+ }
718
+ } catch (e) {
719
+ // Ignore read errors
720
+ }
721
+ }
722
+ return false;
723
+ }
724
+
679
725
  /**
680
726
  * Get login success HTML page
681
727
  */
@@ -1121,7 +1167,11 @@ class StdioMCPWrapper {
1121
1167
  try {
1122
1168
  const model = modelPreferences[providerId] || null;
1123
1169
  const result = await this.cliManager.sendCliPrompt(providerId, prompt, mode, gracefulTimeout, model);
1124
- return { provider_id: providerId, ...result };
1170
+ return {
1171
+ provider_id: providerId,
1172
+ original_provider: providerId,
1173
+ ...result
1174
+ };
1125
1175
  } catch (error) {
1126
1176
  return { provider_id: providerId, success: false, error: error.message };
1127
1177
  }
@@ -1413,6 +1463,17 @@ class StdioMCPWrapper {
1413
1463
  return this.getModelPreferenceForCli(providerId);
1414
1464
  }
1415
1465
 
1466
+ /**
1467
+ * Get default model name for a CLI tool (used when model not specified in result)
1468
+ * These are just display labels - actual model selection is done by:
1469
+ * 1. User's configured default_model in dashboard API keys
1470
+ * 2. CLI tool's own default if no preference set
1471
+ */
1472
+ getDefaultModelForCli(providerId) {
1473
+ // Prefer user's model preference if available
1474
+ return this.getModelPreferenceForCli(providerId);
1475
+ }
1476
+
1416
1477
  /**
1417
1478
  * Call remote perspectives for CLI prompts
1418
1479
  * Only calls remote APIs for providers NOT covered by successful local CLIs
@@ -2272,7 +2333,7 @@ class StdioMCPWrapper {
2272
2333
 
2273
2334
  server.on('error', (err) => {
2274
2335
  console.error('[!] Could not start login server:', err.message);
2275
- console.error(' Use "login" tool or run: npx polydev-ai');
2336
+ console.error(' Use "login" tool or run: npx polydev-ai login');
2276
2337
  console.error('─'.repeat(50) + '\n');
2277
2338
  resolve(false);
2278
2339
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polydev-ai",
3
- "version": "1.8.85",
3
+ "version": "1.8.87",
4
4
  "engines": {
5
5
  "node": ">=20.x <=22.x"
6
6
  },