@kervnet/opencode-kiro-auth 1.7.16 → 1.7.17

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.
@@ -42,10 +42,20 @@ export class AuthHandler {
42
42
  .get();
43
43
  cliDb.close();
44
44
  if (!tokenRow || !tokenRow.expires || tokenRow.expires < Date.now()) {
45
- logger.log('Background token refresh: kiro-cli token expired or missing, skipping');
46
- return;
45
+ logger.log('Background token refresh: kiro-cli token expired, forcing refresh via kiro-cli whoami...');
46
+ try {
47
+ const { execSync } = await import('node:child_process');
48
+ execSync('kiro-cli whoami', { timeout: 15000, stdio: 'pipe' });
49
+ logger.log('Background token refresh: kiro-cli token refreshed successfully');
50
+ }
51
+ catch {
52
+ logger.log('Background token refresh: kiro-cli refresh failed, skipping');
53
+ return;
54
+ }
55
+ }
56
+ else {
57
+ logger.log(`Background token refresh: kiro-cli token valid until ${new Date(tokenRow.expires).toLocaleString()}`);
47
58
  }
48
- logger.log(`Background token refresh: kiro-cli token valid until ${new Date(tokenRow.expires).toLocaleString()}`);
49
59
  }
50
60
  catch (e) {
51
61
  logger.warn('Background token refresh: failed to check kiro-cli token status', e);
@@ -33,17 +33,13 @@ export class TokenRefresher {
33
33
  const now = Date.now();
34
34
  if (this.config.auto_sync_kiro_cli && now - this.lastSyncTime > this.SYNC_COOLDOWN_MS) {
35
35
  this.lastSyncTime = now;
36
- // Force kiro-cli to refresh its token first
36
+ // Force kiro-cli to refresh its token
37
37
  try {
38
- const { exec } = await import('node:child_process');
39
- await new Promise((resolve) => {
40
- exec('kiro-cli whoami', (error) => {
41
- resolve(); // Continue even if it fails
42
- });
43
- });
38
+ const { execSync } = await import('node:child_process');
39
+ execSync('kiro-cli whoami', { timeout: 15000, stdio: 'pipe' });
44
40
  }
45
- catch (e) {
46
- // Silent fail - continue with sync anyway
41
+ catch {
42
+ // Continue with sync anyway
47
43
  }
48
44
  await this.syncFromKiroCli();
49
45
  }
@@ -54,7 +54,14 @@ export class RequestHandler {
54
54
  if (this.allAccountsPermanentlyUnhealthy()) {
55
55
  // Try to recover by syncing from kiro-cli
56
56
  if (this.config.auto_sync_kiro_cli) {
57
- showToast('All accounts unhealthy. Attempting recovery from Kiro CLI...', 'warning');
57
+ showToast('All accounts unhealthy. Forcing kiro-cli token refresh...', 'warning');
58
+ try {
59
+ const { execSync } = await import('node:child_process');
60
+ execSync('kiro-cli chat --model claude-haiku-4.5 --no-interactive "hi"', { timeout: 30000, stdio: 'pipe' });
61
+ }
62
+ catch {
63
+ throw new Error('All accounts are unhealthy and kiro-cli token refresh failed. Please run: kiro-cli login');
64
+ }
58
65
  const { syncFromKiroCli } = await import('../../plugin/sync/kiro-cli.js');
59
66
  await syncFromKiroCli();
60
67
  // Reset all accounts to healthy and clear fail counts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kervnet/opencode-kiro-auth",
3
- "version": "1.7.16",
3
+ "version": "1.7.17",
4
4
  "description": "OpenCode plugin for AWS Kiro (CodeWhisperer) with IAM Identity Center profile support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",