@kervnet/opencode-kiro-auth 1.7.18 → 1.7.20

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/constants.js CHANGED
@@ -39,6 +39,8 @@ export const MODEL_MAPPING = {
39
39
  'claude-opus-4-5-thinking': 'CLAUDE_OPUS_4_5_20251101_V1_0',
40
40
  'claude-opus-4-6': 'claude-opus-4.6',
41
41
  'claude-opus-4-6-thinking': 'claude-opus-4.6',
42
+ 'claude-sonnet-4-6': 'claude-sonnet-4.6',
43
+ 'claude-sonnet-4-6-thinking': 'claude-sonnet-4.6',
42
44
  'claude-sonnet-4-20250514': 'CLAUDE_SONNET_4_20250514_V1_0',
43
45
  'claude-3-7-sonnet-20250219': 'CLAUDE_3_7_SONNET_20250219_V1_0',
44
46
  'qwen3-coder-480b': 'qwen3-coder-480b'
@@ -25,7 +25,19 @@ export class AuthHandler {
25
25
  try {
26
26
  const logger = await import('../../plugin/logger.js');
27
27
  logger.log('Background token refresh starting...');
28
- // Check if kiro-cli has valid tokens before syncing
28
+ const bufferMs = this.config.token_expiry_buffer_ms || 120000;
29
+ let needsRefresh = false;
30
+ // Check if any plugin account token is expiring within buffer
31
+ if (this.accountManager) {
32
+ const accounts = this.accountManager.getAccounts();
33
+ for (const acc of accounts) {
34
+ if (acc.expiresAt && Date.now() >= acc.expiresAt - bufferMs - 5 * 60 * 1000) {
35
+ logger.log(`Background token refresh: account ${acc.email} token expiring soon (${new Date(acc.expiresAt).toLocaleString()}), forcing refresh`);
36
+ needsRefresh = true;
37
+ break;
38
+ }
39
+ }
40
+ }
29
41
  try {
30
42
  const { existsSync } = await import('node:fs');
31
43
  const { Database } = await import('bun:sqlite');
@@ -41,24 +53,28 @@ export class AuthHandler {
41
53
  .prepare("SELECT json_extract(value, '$.expires_at') as expires FROM auth_kv WHERE key LIKE '%token' LIMIT 1")
42
54
  .get();
43
55
  cliDb.close();
44
- if (!tokenRow || !tokenRow.expires || tokenRow.expires < Date.now()) {
45
- logger.log('Background token refresh: kiro-cli token expired, forcing refresh via kiro-cli whoami...');
56
+ const cliExpires = tokenRow?.expires ? new Date(tokenRow.expires).getTime() : 0;
57
+ if (!cliExpires || Date.now() >= cliExpires - bufferMs - 5 * 60 * 1000) {
58
+ needsRefresh = true;
59
+ }
60
+ if (needsRefresh) {
61
+ logger.log('Background token refresh: forcing kiro-cli whoami...');
62
+ const { execSync } = await import('node:child_process');
46
63
  try {
47
- const { execSync } = await import('node:child_process');
48
64
  execSync('kiro-cli whoami', { timeout: 15000, stdio: 'pipe' });
49
- logger.log('Background token refresh: kiro-cli token refreshed successfully');
65
+ logger.log('Background token refresh: kiro-cli whoami succeeded');
50
66
  }
51
67
  catch {
52
- logger.log('Background token refresh: kiro-cli refresh failed, skipping');
68
+ logger.log('Background token refresh: kiro-cli whoami failed, skipping');
53
69
  return;
54
70
  }
55
71
  }
56
72
  else {
57
- logger.log(`Background token refresh: kiro-cli token valid until ${new Date(tokenRow.expires).toLocaleString()}`);
73
+ logger.log(`Background token refresh: tokens valid, syncing`);
58
74
  }
59
75
  }
60
76
  catch (e) {
61
- logger.warn('Background token refresh: failed to check kiro-cli token status', e);
77
+ logger.warn('Background token refresh: failed to check token status', e);
62
78
  return;
63
79
  }
64
80
  const { syncFromKiroCli } = await import('../../plugin/sync/kiro-cli.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kervnet/opencode-kiro-auth",
3
- "version": "1.7.18",
3
+ "version": "1.7.20",
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",