@sunerpy/opencode-kiro-auth 0.1.0

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.
Files changed (113) hide show
  1. package/LICENSE +678 -0
  2. package/README.md +270 -0
  3. package/dist/constants.d.ts +28 -0
  4. package/dist/constants.js +108 -0
  5. package/dist/core/account/account-selector.d.ts +25 -0
  6. package/dist/core/account/account-selector.js +80 -0
  7. package/dist/core/account/usage-tracker.d.ts +20 -0
  8. package/dist/core/account/usage-tracker.js +56 -0
  9. package/dist/core/auth/auth-handler.d.ts +18 -0
  10. package/dist/core/auth/auth-handler.js +236 -0
  11. package/dist/core/auth/idc-auth-method.d.ts +9 -0
  12. package/dist/core/auth/idc-auth-method.js +169 -0
  13. package/dist/core/auth/token-refresher.d.ts +23 -0
  14. package/dist/core/auth/token-refresher.js +85 -0
  15. package/dist/core/index.d.ts +9 -0
  16. package/dist/core/index.js +9 -0
  17. package/dist/core/request/error-handler.d.ts +32 -0
  18. package/dist/core/request/error-handler.js +159 -0
  19. package/dist/core/request/request-handler.d.ts +35 -0
  20. package/dist/core/request/request-handler.js +296 -0
  21. package/dist/core/request/response-handler.d.ts +8 -0
  22. package/dist/core/request/response-handler.js +137 -0
  23. package/dist/core/request/retry-strategy.d.ts +18 -0
  24. package/dist/core/request/retry-strategy.js +28 -0
  25. package/dist/index.d.ts +94 -0
  26. package/dist/index.js +2 -0
  27. package/dist/infrastructure/database/account-cache.d.ts +14 -0
  28. package/dist/infrastructure/database/account-cache.js +44 -0
  29. package/dist/infrastructure/database/account-repository.d.ts +12 -0
  30. package/dist/infrastructure/database/account-repository.js +66 -0
  31. package/dist/infrastructure/index.d.ts +7 -0
  32. package/dist/infrastructure/index.js +7 -0
  33. package/dist/infrastructure/transformers/event-stream-parser.d.ts +7 -0
  34. package/dist/infrastructure/transformers/event-stream-parser.js +115 -0
  35. package/dist/infrastructure/transformers/history-builder.d.ts +16 -0
  36. package/dist/infrastructure/transformers/history-builder.js +226 -0
  37. package/dist/infrastructure/transformers/message-transformer.d.ts +5 -0
  38. package/dist/infrastructure/transformers/message-transformer.js +99 -0
  39. package/dist/infrastructure/transformers/tool-call-parser.d.ts +4 -0
  40. package/dist/infrastructure/transformers/tool-call-parser.js +45 -0
  41. package/dist/infrastructure/transformers/tool-transformer.d.ts +2 -0
  42. package/dist/infrastructure/transformers/tool-transformer.js +19 -0
  43. package/dist/kiro/auth.d.ts +4 -0
  44. package/dist/kiro/auth.js +25 -0
  45. package/dist/kiro/oauth-idc.d.ts +25 -0
  46. package/dist/kiro/oauth-idc.js +167 -0
  47. package/dist/plugin/accounts.d.ts +29 -0
  48. package/dist/plugin/accounts.js +266 -0
  49. package/dist/plugin/auth-bootstrap.d.ts +9 -0
  50. package/dist/plugin/auth-bootstrap.js +69 -0
  51. package/dist/plugin/auth-page.d.ts +4 -0
  52. package/dist/plugin/auth-page.js +721 -0
  53. package/dist/plugin/config/index.d.ts +3 -0
  54. package/dist/plugin/config/index.js +2 -0
  55. package/dist/plugin/config/loader.d.ts +6 -0
  56. package/dist/plugin/config/loader.js +129 -0
  57. package/dist/plugin/config/schema.d.ts +88 -0
  58. package/dist/plugin/config/schema.js +94 -0
  59. package/dist/plugin/effort.d.ts +46 -0
  60. package/dist/plugin/effort.js +113 -0
  61. package/dist/plugin/errors.d.ts +17 -0
  62. package/dist/plugin/errors.js +34 -0
  63. package/dist/plugin/health.d.ts +1 -0
  64. package/dist/plugin/health.js +13 -0
  65. package/dist/plugin/image-handler.d.ts +18 -0
  66. package/dist/plugin/image-handler.js +82 -0
  67. package/dist/plugin/logger.d.ts +8 -0
  68. package/dist/plugin/logger.js +84 -0
  69. package/dist/plugin/models.d.ts +2 -0
  70. package/dist/plugin/models.js +11 -0
  71. package/dist/plugin/request.d.ts +9 -0
  72. package/dist/plugin/request.js +287 -0
  73. package/dist/plugin/response.d.ts +3 -0
  74. package/dist/plugin/response.js +97 -0
  75. package/dist/plugin/sdk-client.d.ts +4 -0
  76. package/dist/plugin/sdk-client.js +55 -0
  77. package/dist/plugin/storage/locked-operations.d.ts +5 -0
  78. package/dist/plugin/storage/locked-operations.js +103 -0
  79. package/dist/plugin/storage/migrations.d.ts +4 -0
  80. package/dist/plugin/storage/migrations.js +155 -0
  81. package/dist/plugin/storage/sqlite.d.ts +18 -0
  82. package/dist/plugin/storage/sqlite.js +166 -0
  83. package/dist/plugin/streaming/index.d.ts +2 -0
  84. package/dist/plugin/streaming/index.js +2 -0
  85. package/dist/plugin/streaming/openai-converter.d.ts +2 -0
  86. package/dist/plugin/streaming/openai-converter.js +81 -0
  87. package/dist/plugin/streaming/sdk-stream-transformer.d.ts +1 -0
  88. package/dist/plugin/streaming/sdk-stream-transformer.js +274 -0
  89. package/dist/plugin/streaming/stream-parser.d.ts +5 -0
  90. package/dist/plugin/streaming/stream-parser.js +136 -0
  91. package/dist/plugin/streaming/stream-state.d.ts +5 -0
  92. package/dist/plugin/streaming/stream-state.js +59 -0
  93. package/dist/plugin/streaming/stream-transformer.d.ts +1 -0
  94. package/dist/plugin/streaming/stream-transformer.js +295 -0
  95. package/dist/plugin/streaming/types.d.ts +25 -0
  96. package/dist/plugin/streaming/types.js +2 -0
  97. package/dist/plugin/sync/kiro-cli-parser.d.ts +8 -0
  98. package/dist/plugin/sync/kiro-cli-parser.js +72 -0
  99. package/dist/plugin/sync/kiro-cli-profile.d.ts +1 -0
  100. package/dist/plugin/sync/kiro-cli-profile.js +30 -0
  101. package/dist/plugin/sync/kiro-cli.d.ts +2 -0
  102. package/dist/plugin/sync/kiro-cli.js +212 -0
  103. package/dist/plugin/sync/stale-accounts.d.ts +9 -0
  104. package/dist/plugin/sync/stale-accounts.js +31 -0
  105. package/dist/plugin/token.d.ts +2 -0
  106. package/dist/plugin/token.js +78 -0
  107. package/dist/plugin/types.d.ts +125 -0
  108. package/dist/plugin/types.js +0 -0
  109. package/dist/plugin/usage.d.ts +3 -0
  110. package/dist/plugin/usage.js +79 -0
  111. package/dist/plugin.d.ts +174 -0
  112. package/dist/plugin.js +170 -0
  113. package/package.json +74 -0
@@ -0,0 +1,99 @@
1
+ export function sanitizeHistory(history) {
2
+ const result = [];
3
+ for (let i = 0; i < history.length; i++) {
4
+ const m = history[i];
5
+ if (!m)
6
+ continue;
7
+ if (m.assistantResponseMessage?.toolUses) {
8
+ const next = history[i + 1];
9
+ if (next?.userInputMessage?.userInputMessageContext?.toolResults) {
10
+ result.push(m);
11
+ }
12
+ }
13
+ else if (m.userInputMessage?.userInputMessageContext?.toolResults) {
14
+ const prev = result[result.length - 1];
15
+ if (prev?.assistantResponseMessage?.toolUses) {
16
+ result.push(m);
17
+ }
18
+ }
19
+ else {
20
+ result.push(m);
21
+ }
22
+ }
23
+ while (result.length > 0) {
24
+ const first = result[0];
25
+ if (first?.userInputMessage && !first.userInputMessage.userInputMessageContext?.toolResults)
26
+ break;
27
+ result.shift();
28
+ }
29
+ if (result.length === 0)
30
+ return [];
31
+ while (result.length > 0 && result[result.length - 1]?.assistantResponseMessage) {
32
+ result.pop();
33
+ }
34
+ return result;
35
+ }
36
+ export function findOriginalToolCall(msgs, toolUseId) {
37
+ for (const m of msgs) {
38
+ if (m.role === 'assistant') {
39
+ if (m.tool_calls) {
40
+ for (const tc of m.tool_calls)
41
+ if (tc.id === toolUseId)
42
+ return tc;
43
+ }
44
+ if (Array.isArray(m.content)) {
45
+ for (const p of m.content)
46
+ if (p.type === 'tool_use' && p.id === toolUseId)
47
+ return p;
48
+ }
49
+ }
50
+ }
51
+ return null;
52
+ }
53
+ export function mergeAdjacentMessages(msgs) {
54
+ const merged = [];
55
+ for (const m of msgs) {
56
+ if (!merged.length)
57
+ merged.push({ ...m });
58
+ else {
59
+ const last = merged[merged.length - 1];
60
+ if (last && m.role === last.role) {
61
+ if (Array.isArray(last.content) && Array.isArray(m.content))
62
+ last.content.push(...m.content);
63
+ else if (typeof last.content === 'string' && typeof m.content === 'string')
64
+ last.content += '\n' + m.content;
65
+ else if (Array.isArray(last.content) && typeof m.content === 'string')
66
+ last.content.push({ type: 'text', text: m.content });
67
+ else if (typeof last.content === 'string' && Array.isArray(m.content))
68
+ last.content = [{ type: 'text', text: last.content }, ...m.content];
69
+ if (m.tool_calls) {
70
+ if (!last.tool_calls)
71
+ last.tool_calls = [];
72
+ last.tool_calls.push(...m.tool_calls);
73
+ }
74
+ if (m.role === 'tool') {
75
+ if (!last.tool_results)
76
+ last.tool_results = [{ content: last.content, tool_call_id: last.tool_call_id }];
77
+ last.tool_results.push({ content: m.content, tool_call_id: m.tool_call_id });
78
+ }
79
+ }
80
+ else
81
+ merged.push({ ...m });
82
+ }
83
+ }
84
+ return merged;
85
+ }
86
+ export function getContentText(m) {
87
+ if (!m)
88
+ return '';
89
+ if (typeof m === 'string')
90
+ return m;
91
+ if (typeof m.content === 'string')
92
+ return m.content;
93
+ if (Array.isArray(m.content))
94
+ return m.content
95
+ .filter((p) => p.type === 'text')
96
+ .map((p) => p.text || '')
97
+ .join('');
98
+ return m.text || '';
99
+ }
@@ -0,0 +1,4 @@
1
+ import type { ToolCall } from '../../plugin/types.js';
2
+ export declare function parseBracketToolCalls(text: string): ToolCall[];
3
+ export declare function deduplicateToolCalls(toolCalls: ToolCall[]): ToolCall[];
4
+ export declare function cleanToolCallsFromText(text: string, toolCalls: ToolCall[]): string;
@@ -0,0 +1,45 @@
1
+ export function parseBracketToolCalls(text) {
2
+ const toolCalls = [];
3
+ const pattern = /\[Called\s+(\w+)\s+with\s+args:\s*(\{[^}]*(?:\{[^}]*\}[^}]*)*\})\]/gs;
4
+ let match;
5
+ while ((match = pattern.exec(text)) !== null) {
6
+ const funcName = match[1];
7
+ const argsStr = match[2];
8
+ if (!funcName || !argsStr)
9
+ continue;
10
+ try {
11
+ const args = JSON.parse(argsStr);
12
+ toolCalls.push({
13
+ toolUseId: `tool_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
14
+ name: funcName,
15
+ input: args
16
+ });
17
+ }
18
+ catch (e) {
19
+ continue;
20
+ }
21
+ }
22
+ return toolCalls;
23
+ }
24
+ export function deduplicateToolCalls(toolCalls) {
25
+ const seen = new Set();
26
+ const unique = [];
27
+ for (const tc of toolCalls) {
28
+ if (!seen.has(tc.toolUseId)) {
29
+ seen.add(tc.toolUseId);
30
+ unique.push(tc);
31
+ }
32
+ }
33
+ return unique;
34
+ }
35
+ export function cleanToolCallsFromText(text, toolCalls) {
36
+ let cleaned = text;
37
+ for (const tc of toolCalls) {
38
+ const funcName = tc.name;
39
+ const escapedName = funcName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
40
+ const pattern = new RegExp(`\\[Called\\s+${escapedName}\\s+with\\s+args:\\s*\\{[^}]*(?:\\{[^}]*\\}[^}]*)*\\}\\]`, 'gs');
41
+ cleaned = cleaned.replace(pattern, '');
42
+ }
43
+ cleaned = cleaned.replace(/\s+/g, ' ').trim();
44
+ return cleaned;
45
+ }
@@ -0,0 +1,2 @@
1
+ export declare function convertToolsToCodeWhisperer(tools: any[]): any[];
2
+ export declare function deduplicateToolResults(trs: any[]): any[];
@@ -0,0 +1,19 @@
1
+ export function convertToolsToCodeWhisperer(tools) {
2
+ return tools.map((t) => ({
3
+ toolSpecification: {
4
+ name: t.name || t.function?.name,
5
+ description: (t.description || t.function?.description || '').substring(0, 9216),
6
+ inputSchema: { json: t.input_schema || t.function?.parameters || {} }
7
+ }
8
+ }));
9
+ }
10
+ export function deduplicateToolResults(trs) {
11
+ const u = [], s = new Set();
12
+ for (const t of trs) {
13
+ if (!s.has(t.toolUseId)) {
14
+ s.add(t.toolUseId);
15
+ u.push(t);
16
+ }
17
+ }
18
+ return u;
19
+ }
@@ -0,0 +1,4 @@
1
+ import type { KiroAuthDetails, RefreshParts } from '../plugin/types.js';
2
+ export declare function decodeRefreshToken(refresh: string): RefreshParts;
3
+ export declare function accessTokenExpired(auth: KiroAuthDetails, bufferMs?: number): boolean;
4
+ export declare function encodeRefreshToken(parts: RefreshParts): string;
@@ -0,0 +1,25 @@
1
+ export function decodeRefreshToken(refresh) {
2
+ const parts = refresh.split('|');
3
+ if (parts.length < 2)
4
+ return { refreshToken: parts[0], authMethod: 'desktop' };
5
+ const refreshToken = parts[0];
6
+ const authMethod = parts[parts.length - 1];
7
+ if (authMethod === 'idc')
8
+ return { refreshToken, clientId: parts[1], clientSecret: parts[2], authMethod: 'idc' };
9
+ if (authMethod === 'desktop')
10
+ return { refreshToken, authMethod: 'desktop' };
11
+ return { refreshToken, authMethod: 'desktop' };
12
+ }
13
+ export function accessTokenExpired(auth, bufferMs = 120000) {
14
+ if (!auth.access || !auth.expires)
15
+ return true;
16
+ return Date.now() >= auth.expires - bufferMs;
17
+ }
18
+ export function encodeRefreshToken(parts) {
19
+ if (parts.authMethod === 'idc') {
20
+ if (!parts.clientId || !parts.clientSecret)
21
+ throw new Error('Missing credentials');
22
+ return `${parts.refreshToken}|${parts.clientId}|${parts.clientSecret}|idc`;
23
+ }
24
+ return `${parts.refreshToken}|desktop`;
25
+ }
@@ -0,0 +1,25 @@
1
+ import type { KiroRegion } from '../plugin/types.js';
2
+ export interface KiroIDCAuthorization {
3
+ verificationUrl: string;
4
+ verificationUriComplete: string;
5
+ userCode: string;
6
+ deviceCode: string;
7
+ clientId: string;
8
+ clientSecret: string;
9
+ interval: number;
10
+ expiresIn: number;
11
+ region: KiroRegion;
12
+ startUrl: string;
13
+ }
14
+ export interface KiroIDCTokenResult {
15
+ refreshToken: string;
16
+ accessToken: string;
17
+ expiresAt: number;
18
+ email: string;
19
+ clientId: string;
20
+ clientSecret: string;
21
+ region: KiroRegion;
22
+ authMethod: 'idc';
23
+ }
24
+ export declare function authorizeKiroIDC(region?: KiroRegion, startUrl?: string): Promise<KiroIDCAuthorization>;
25
+ export declare function pollKiroIDCToken(clientId: string, clientSecret: string, deviceCode: string, interval: number, expiresIn: number, region: KiroRegion): Promise<KiroIDCTokenResult>;
@@ -0,0 +1,167 @@
1
+ import { KIRO_AUTH_SERVICE, KIRO_CONSTANTS, buildUrl, normalizeRegion } from '../constants.js';
2
+ export async function authorizeKiroIDC(region, startUrl) {
3
+ const effectiveRegion = normalizeRegion(region);
4
+ const ssoOIDCEndpoint = buildUrl(KIRO_AUTH_SERVICE.SSO_OIDC_ENDPOINT, effectiveRegion);
5
+ const effectiveStartUrl = startUrl || KIRO_AUTH_SERVICE.BUILDER_ID_START_URL;
6
+ try {
7
+ const registerResponse = await fetch(`${ssoOIDCEndpoint}/client/register`, {
8
+ method: 'POST',
9
+ headers: {
10
+ 'Content-Type': 'application/json',
11
+ 'User-Agent': KIRO_CONSTANTS.USER_AGENT
12
+ },
13
+ body: JSON.stringify({
14
+ clientName: 'Kiro IDE',
15
+ clientType: 'public',
16
+ scopes: KIRO_AUTH_SERVICE.SCOPES,
17
+ grantTypes: ['urn:ietf:params:oauth:grant-type:device_code', 'refresh_token']
18
+ })
19
+ });
20
+ if (!registerResponse.ok) {
21
+ const errorText = await registerResponse.text().catch(() => '');
22
+ const error = new Error(`Client registration failed: ${registerResponse.status} ${errorText}`);
23
+ throw error;
24
+ }
25
+ const registerData = await registerResponse.json();
26
+ const { clientId, clientSecret } = registerData;
27
+ if (!clientId || !clientSecret) {
28
+ const error = new Error('Client registration response missing clientId or clientSecret');
29
+ throw error;
30
+ }
31
+ const deviceAuthResponse = await fetch(`${ssoOIDCEndpoint}/device_authorization`, {
32
+ method: 'POST',
33
+ headers: {
34
+ 'Content-Type': 'application/json',
35
+ 'User-Agent': KIRO_CONSTANTS.USER_AGENT
36
+ },
37
+ body: JSON.stringify({
38
+ clientId,
39
+ clientSecret,
40
+ startUrl: effectiveStartUrl
41
+ })
42
+ });
43
+ if (!deviceAuthResponse.ok) {
44
+ const errorText = await deviceAuthResponse.text().catch(() => '');
45
+ const error = new Error(`Device authorization failed: ${deviceAuthResponse.status} ${errorText}`);
46
+ throw error;
47
+ }
48
+ const deviceAuthData = await deviceAuthResponse.json();
49
+ const { verificationUri, verificationUriComplete, userCode, deviceCode, interval = 5, expiresIn = 600 } = deviceAuthData;
50
+ if (!deviceCode || !userCode || !verificationUri || !verificationUriComplete) {
51
+ const error = new Error('Device authorization response missing required fields');
52
+ throw error;
53
+ }
54
+ return {
55
+ verificationUrl: verificationUri,
56
+ verificationUriComplete,
57
+ userCode,
58
+ deviceCode,
59
+ clientId,
60
+ clientSecret,
61
+ interval,
62
+ expiresIn,
63
+ region: effectiveRegion,
64
+ startUrl: effectiveStartUrl
65
+ };
66
+ }
67
+ catch (error) {
68
+ throw error;
69
+ }
70
+ }
71
+ export async function pollKiroIDCToken(clientId, clientSecret, deviceCode, interval, expiresIn, region) {
72
+ if (!clientId || !clientSecret || !deviceCode) {
73
+ const error = new Error('Missing required parameters for token polling');
74
+ throw error;
75
+ }
76
+ const effectiveRegion = normalizeRegion(region);
77
+ const ssoOIDCEndpoint = buildUrl(KIRO_AUTH_SERVICE.SSO_OIDC_ENDPOINT, effectiveRegion);
78
+ const maxAttempts = Math.floor(expiresIn / interval);
79
+ let currentInterval = interval * 1000;
80
+ let attempts = 0;
81
+ while (attempts < maxAttempts) {
82
+ attempts++;
83
+ await new Promise((resolve) => setTimeout(resolve, currentInterval));
84
+ try {
85
+ const tokenResponse = await fetch(`${ssoOIDCEndpoint}/token`, {
86
+ method: 'POST',
87
+ headers: {
88
+ 'Content-Type': 'application/json',
89
+ 'User-Agent': KIRO_CONSTANTS.USER_AGENT
90
+ },
91
+ body: JSON.stringify({
92
+ clientId,
93
+ clientSecret,
94
+ deviceCode,
95
+ grantType: 'urn:ietf:params:oauth:grant-type:device_code'
96
+ })
97
+ });
98
+ const responseText = await tokenResponse.text().catch(() => '');
99
+ let tokenData = {};
100
+ if (responseText) {
101
+ try {
102
+ tokenData = JSON.parse(responseText);
103
+ }
104
+ catch (parseError) {
105
+ throw new Error(`Token polling failed: invalid JSON response (HTTP ${tokenResponse.status}): ${responseText.slice(0, 300)}`);
106
+ }
107
+ }
108
+ if (tokenData.error) {
109
+ const errorType = tokenData.error;
110
+ if (errorType === 'authorization_pending') {
111
+ continue;
112
+ }
113
+ if (errorType === 'slow_down') {
114
+ currentInterval += 5000;
115
+ continue;
116
+ }
117
+ if (errorType === 'expired_token') {
118
+ const error = new Error('Device code has expired. Please restart the authorization process.');
119
+ throw error;
120
+ }
121
+ if (errorType === 'access_denied') {
122
+ const error = new Error('Authorization was denied by the user.');
123
+ throw error;
124
+ }
125
+ const error = new Error(`Token polling failed: ${errorType} - ${tokenData.error_description || ''}`);
126
+ throw error;
127
+ }
128
+ const accessToken = tokenData.access_token || tokenData.accessToken;
129
+ const refreshToken = tokenData.refresh_token || tokenData.refreshToken;
130
+ const tokenExpiresIn = tokenData.expires_in || tokenData.expiresIn;
131
+ if (accessToken && refreshToken) {
132
+ const expiresInSeconds = tokenExpiresIn || 3600;
133
+ const expiresAt = Date.now() + expiresInSeconds * 1000;
134
+ return {
135
+ refreshToken,
136
+ accessToken,
137
+ expiresAt,
138
+ email: 'builder-id@aws.amazon.com',
139
+ clientId,
140
+ clientSecret,
141
+ region: effectiveRegion,
142
+ authMethod: 'idc'
143
+ };
144
+ }
145
+ if (!tokenResponse.ok) {
146
+ const error = new Error(`Token request failed with status: ${tokenResponse.status} ${responseText ? `(${responseText.slice(0, 200)})` : ''}`);
147
+ throw error;
148
+ }
149
+ // If the service returned HTTP 200 but no tokens and no error, treat as invalid response.
150
+ throw new Error(`Token polling failed: missing tokens in response: ${responseText ? responseText.slice(0, 300) : '[empty]'}`);
151
+ }
152
+ catch (error) {
153
+ if (error instanceof Error &&
154
+ (error.message.includes('expired') ||
155
+ error.message.includes('denied') ||
156
+ error.message.includes('failed'))) {
157
+ throw error;
158
+ }
159
+ if (attempts >= maxAttempts) {
160
+ const finalError = new Error(`Token polling failed after ${attempts} attempts: ${error instanceof Error ? error.message : 'Unknown error'}`);
161
+ throw finalError;
162
+ }
163
+ }
164
+ }
165
+ const timeoutError = new Error('Token polling timed out. Authorization may have expired.');
166
+ throw timeoutError;
167
+ }
@@ -0,0 +1,29 @@
1
+ import type { AccountSelectionStrategy, KiroAuthDetails, ManagedAccount } from './types.js';
2
+ export declare function createDeterministicAccountId(email: string, method: string, clientId?: string, profileArn?: string): string;
3
+ export declare class AccountManager {
4
+ private accounts;
5
+ private cursor;
6
+ private strategy;
7
+ private lastToastTime;
8
+ private lastUsageToastTime;
9
+ constructor(accounts: ManagedAccount[], strategy?: AccountSelectionStrategy);
10
+ static loadFromDisk(strategy?: AccountSelectionStrategy): Promise<AccountManager>;
11
+ getAccountCount(): number;
12
+ getAccounts(): ManagedAccount[];
13
+ shouldShowToast(debounce?: number): boolean;
14
+ shouldShowUsageToast(debounce?: number): boolean;
15
+ getMinWaitTime(): number;
16
+ getCurrentOrNext(): ManagedAccount | null;
17
+ updateUsage(id: string, meta: {
18
+ usedCount: number;
19
+ limitCount: number;
20
+ email?: string;
21
+ }): void;
22
+ addAccount(a: ManagedAccount): void;
23
+ removeAccount(a: ManagedAccount): void;
24
+ updateFromAuth(a: ManagedAccount, auth: KiroAuthDetails): void;
25
+ markRateLimited(a: ManagedAccount, ms: number): void;
26
+ markUnhealthy(a: ManagedAccount, reason: string, recovery?: number): void;
27
+ saveToDisk(): Promise<void>;
28
+ toAuthDetails(a: ManagedAccount): KiroAuthDetails;
29
+ }