@sunerpy/opencode-kiro-auth 0.6.2 → 0.8.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.
- package/README.md +12 -4
- package/dist/core/auth/auth-handler.js +4 -2
- package/dist/core/auth/idc-auth-method.js +15 -3
- package/dist/core/auth/token-keepalive.d.ts +27 -0
- package/dist/core/auth/token-keepalive.js +137 -0
- package/dist/core/auth/token-refresher.d.ts +20 -1
- package/dist/core/auth/token-refresher.js +124 -22
- package/dist/core/request/error-handler.d.ts +6 -3
- package/dist/core/request/error-handler.js +50 -24
- package/dist/core/request/request-handler.d.ts +2 -0
- package/dist/core/request/request-handler.js +5 -2
- package/dist/infrastructure/transformers/event-stream-parser.js +1 -1
- package/dist/infrastructure/transformers/tool-call-parser.js +1 -1
- package/dist/kiro/oauth-idc.js +54 -59
- package/dist/plugin/accounts.js +13 -8
- package/dist/plugin/config/loader.js +49 -1
- package/dist/plugin/config/schema.d.ts +14 -0
- package/dist/plugin/config/schema.js +14 -2
- package/dist/plugin/health.d.ts +22 -0
- package/dist/plugin/health.js +56 -1
- package/dist/plugin/image-handler.js +1 -1
- package/dist/plugin/logger.js +2 -2
- package/dist/plugin/request.js +1 -1
- package/dist/plugin/response.js +1 -1
- package/dist/plugin/storage/locked-operations.d.ts +7 -0
- package/dist/plugin/storage/locked-operations.js +93 -1
- package/dist/plugin/storage/migrations.js +1 -1
- package/dist/plugin/storage/sqlite.d.ts +4 -0
- package/dist/plugin/storage/sqlite.js +65 -3
- package/dist/plugin/streaming/sdk-stream-transformer.js +233 -244
- package/dist/plugin/streaming/stream-transformer.js +1 -1
- package/dist/plugin/sync/kiro-cli.js +0 -2
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +28 -1
- package/package.json +1 -1
|
@@ -65,7 +65,6 @@ export async function syncFromKiroCli() {
|
|
|
65
65
|
let usedCount = 0;
|
|
66
66
|
let limitCount = 0;
|
|
67
67
|
let email;
|
|
68
|
-
let usageOk = false;
|
|
69
68
|
try {
|
|
70
69
|
const authForUsage = {
|
|
71
70
|
refresh: '',
|
|
@@ -83,7 +82,6 @@ export async function syncFromKiroCli() {
|
|
|
83
82
|
limitCount = u.limitCount || 0;
|
|
84
83
|
if (typeof u.email === 'string' && u.email) {
|
|
85
84
|
email = u.email;
|
|
86
|
-
usageOk = true;
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
catch (e) {
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { KeepAliveController } from './core/auth/token-keepalive.js';
|
|
2
|
+
export declare function __getActiveKeepAliveControllerForTest(): KeepAliveController | null;
|
|
1
3
|
export declare const createKiroPlugin: (id: string) => ({ client, directory }: any) => Promise<{
|
|
2
4
|
config: (input: any) => Promise<void>;
|
|
3
5
|
auth: {
|
package/dist/plugin.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { KIRO_CONSTANTS } from './constants.js';
|
|
2
2
|
import { AuthHandler } from './core/auth/auth-handler.js';
|
|
3
|
+
import { KeepAliveController } from './core/auth/token-keepalive.js';
|
|
3
4
|
import { RequestHandler } from './core/request/request-handler.js';
|
|
4
5
|
import { AccountCache } from './infrastructure/database/account-cache.js';
|
|
5
6
|
import { AccountRepository } from './infrastructure/database/account-repository.js';
|
|
@@ -7,6 +8,31 @@ import { AccountManager } from './plugin/accounts.js';
|
|
|
7
8
|
import { bootstrapAuthIfNeeded } from './plugin/auth-bootstrap.js';
|
|
8
9
|
import { loadConfig } from './plugin/config/index.js';
|
|
9
10
|
const KIRO_PROVIDER_ID = 'kiro-auth';
|
|
11
|
+
let activeKeepAliveController = null;
|
|
12
|
+
let keepAliveTeardownRegistered = false;
|
|
13
|
+
function disposeActiveKeepAliveController() {
|
|
14
|
+
activeKeepAliveController?.dispose();
|
|
15
|
+
activeKeepAliveController = null;
|
|
16
|
+
}
|
|
17
|
+
function registerKeepAliveTeardown() {
|
|
18
|
+
if (keepAliveTeardownRegistered) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
keepAliveTeardownRegistered = true;
|
|
22
|
+
process.once('beforeExit', disposeActiveKeepAliveController);
|
|
23
|
+
process.once('SIGTERM', disposeActiveKeepAliveController);
|
|
24
|
+
}
|
|
25
|
+
function installKeepAliveController(controller, enabled) {
|
|
26
|
+
disposeActiveKeepAliveController();
|
|
27
|
+
activeKeepAliveController = controller;
|
|
28
|
+
if (enabled) {
|
|
29
|
+
registerKeepAliveTeardown();
|
|
30
|
+
}
|
|
31
|
+
controller.start();
|
|
32
|
+
}
|
|
33
|
+
export function __getActiveKeepAliveControllerForTest() {
|
|
34
|
+
return activeKeepAliveController;
|
|
35
|
+
}
|
|
10
36
|
export const createKiroPlugin = (id) => async ({ client, directory }) => {
|
|
11
37
|
const config = loadConfig(directory);
|
|
12
38
|
const showToast = (message, variant) => {
|
|
@@ -21,6 +47,7 @@ export const createKiroPlugin = (id) => async ({ client, directory }) => {
|
|
|
21
47
|
});
|
|
22
48
|
authHandler.setAccountManager(accountManager);
|
|
23
49
|
const requestHandler = new RequestHandler(accountManager, config, repository, client);
|
|
50
|
+
installKeepAliveController(new KeepAliveController(config, accountManager, requestHandler.sharedTokenRefresher, repository), config.token_keepalive_enabled);
|
|
24
51
|
// Compute the base URL once so both the config hook and auth loader use the same value
|
|
25
52
|
const baseURL = KIRO_CONSTANTS.BASE_URL.replace('/generateAssistantResponse', '').replace('{{region}}', config.default_region || 'us-east-1');
|
|
26
53
|
return {
|
|
@@ -251,7 +278,7 @@ export const createKiroPlugin = (id) => async ({ client, directory }) => {
|
|
|
251
278
|
normalized[modelID] = {
|
|
252
279
|
...modelInfo,
|
|
253
280
|
api: {
|
|
254
|
-
...
|
|
281
|
+
...modelInfo.api,
|
|
255
282
|
npm: '@ai-sdk/openai-compatible',
|
|
256
283
|
// Ensure url is always set. modelInfo.api.url should already be
|
|
257
284
|
// populated from the config hook's provider.api field, but we
|