@bogyie/opencode-kiro-plugin 0.2.11 → 0.2.12
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/auth.d.ts +1 -0
- package/dist/auth.js +31 -0
- package/dist/cli-transport.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin.js +2 -2
- package/package.json +1 -1
package/dist/auth.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare function regionFromProfileArn(profileArn: string | undefined): st
|
|
|
43
43
|
export declare function readKiroCliSessionCredential(options?: KiroCliSessionCredentialOptions, runner?: CommandRunner): Promise<KiroCliSessionCredential | undefined>;
|
|
44
44
|
export declare function extractKiroLoginUrl(output: string): string;
|
|
45
45
|
export declare function startKiroCliLogin(spawner?: ProcessSpawner): KiroLoginSession;
|
|
46
|
+
export declare function startKiroCliLoginOnce(spawner?: ProcessSpawner): KiroLoginSession;
|
|
46
47
|
export declare function redacted(value: string | undefined): string | undefined;
|
|
47
48
|
export declare function detectAuth(env?: NodeJS.ProcessEnv, runner?: CommandRunner): Promise<AuthDiagnostics>;
|
|
48
49
|
export declare function resolveApiKey(auth: () => Promise<{
|
package/dist/auth.js
CHANGED
|
@@ -8,6 +8,9 @@ const execFileAsync = promisify(execFile);
|
|
|
8
8
|
export const KIRO_LOGIN_URL = "https://view.awsapps.com/start";
|
|
9
9
|
export const DEFAULT_KIRO_CLI_DB_PATH = join(homedir(), "Library", "Application Support", "kiro-cli", "data.sqlite3");
|
|
10
10
|
export const DEFAULT_KIRO_CLI_TOKEN_KEYS = ["kirocli:odic:token", "codewhisperer:odic:token"];
|
|
11
|
+
const LOGIN_REUSE_WINDOW_MS = 2 * 60 * 1000;
|
|
12
|
+
let sharedLoginSession;
|
|
13
|
+
let sharedLoginStartedAt = 0;
|
|
11
14
|
export async function runCommand(command, args, options = {}) {
|
|
12
15
|
try {
|
|
13
16
|
const result = await execFileAsync(command, [...args], { timeout: options.timeoutMs ?? 5000 });
|
|
@@ -141,6 +144,34 @@ export function startKiroCliLogin(spawner = (command, args) => spawn(command, [.
|
|
|
141
144
|
},
|
|
142
145
|
};
|
|
143
146
|
}
|
|
147
|
+
export function startKiroCliLoginOnce(spawner = (command, args) => spawn(command, [...args], { stdio: ["ignore", "pipe", "pipe"] })) {
|
|
148
|
+
const now = Date.now();
|
|
149
|
+
if (sharedLoginSession && now - sharedLoginStartedAt < LOGIN_REUSE_WINDOW_MS)
|
|
150
|
+
return sharedLoginSession;
|
|
151
|
+
const session = startKiroCliLogin(spawner);
|
|
152
|
+
const wrapped = {
|
|
153
|
+
get url() {
|
|
154
|
+
return session.url;
|
|
155
|
+
},
|
|
156
|
+
get instructions() {
|
|
157
|
+
return session.instructions;
|
|
158
|
+
},
|
|
159
|
+
async waitForAuth(runner) {
|
|
160
|
+
try {
|
|
161
|
+
return await session.waitForAuth(runner);
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
if (sharedLoginSession === wrapped) {
|
|
165
|
+
sharedLoginSession = undefined;
|
|
166
|
+
sharedLoginStartedAt = 0;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
sharedLoginSession = wrapped;
|
|
172
|
+
sharedLoginStartedAt = now;
|
|
173
|
+
return wrapped;
|
|
174
|
+
}
|
|
144
175
|
export function redacted(value) {
|
|
145
176
|
if (!value)
|
|
146
177
|
return undefined;
|
package/dist/cli-transport.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { runCommand,
|
|
1
|
+
import { runCommand, startKiroCliLoginOnce as startSharedKiroCliLoginOnce } from "./auth.js";
|
|
2
2
|
import { KiroPluginError } from "./errors.js";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
let lastLoginStartAt = 0;
|
|
@@ -7,7 +7,7 @@ function startKiroCliLoginOnce() {
|
|
|
7
7
|
if (now - lastLoginStartAt < 30_000)
|
|
8
8
|
return;
|
|
9
9
|
lastLoginStartAt = now;
|
|
10
|
-
|
|
10
|
+
startSharedKiroCliLoginOnce();
|
|
11
11
|
}
|
|
12
12
|
export function promptForCli(request) {
|
|
13
13
|
const parts = [
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { AcpConnection, AcpNotificationHandler, AcpStdioClientOptions, Json
|
|
|
3
3
|
export { acpPermissionResponse, KiroAcpTransport } from "./acp-transport.js";
|
|
4
4
|
export type { AcpSessionClient, KiroAcpTransportOptions } from "./acp-transport.js";
|
|
5
5
|
export { createKiroPlugin, effectiveBackend, KiroPlugin } from "./plugin.js";
|
|
6
|
-
export { detectAuth, extractKiroLoginUrl, KIRO_LOGIN_URL, readKiroCliSessionCredential, redacted, regionFromProfileArn, resolveApiKey, startKiroCliLogin, } from "./auth.js";
|
|
6
|
+
export { detectAuth, extractKiroLoginUrl, KIRO_LOGIN_URL, readKiroCliSessionCredential, redacted, regionFromProfileArn, resolveApiKey, startKiroCliLogin, startKiroCliLoginOnce, } from "./auth.js";
|
|
7
7
|
export { cliChatArgs, KiroCliChatTransport, promptForCli } from "./cli-transport.js";
|
|
8
8
|
export { createKiroFetch } from "./fetch-adapter.js";
|
|
9
9
|
export { loadOptions } from "./config.js";
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { KiroPlugin } from "./plugin.js";
|
|
|
2
2
|
export { AcpJsonRpcClient, createAcpStdioClient, decodeJsonRpc, encodeJsonRpc } from "./acp-client.js";
|
|
3
3
|
export { acpPermissionResponse, KiroAcpTransport } from "./acp-transport.js";
|
|
4
4
|
export { createKiroPlugin, effectiveBackend, KiroPlugin } from "./plugin.js";
|
|
5
|
-
export { detectAuth, extractKiroLoginUrl, KIRO_LOGIN_URL, readKiroCliSessionCredential, redacted, regionFromProfileArn, resolveApiKey, startKiroCliLogin, } from "./auth.js";
|
|
5
|
+
export { detectAuth, extractKiroLoginUrl, KIRO_LOGIN_URL, readKiroCliSessionCredential, redacted, regionFromProfileArn, resolveApiKey, startKiroCliLogin, startKiroCliLoginOnce, } from "./auth.js";
|
|
6
6
|
export { cliChatArgs, KiroCliChatTransport, promptForCli } from "./cli-transport.js";
|
|
7
7
|
export { createKiroFetch } from "./fetch-adapter.js";
|
|
8
8
|
export { loadOptions } from "./config.js";
|
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tool } from "@opencode-ai/plugin";
|
|
2
2
|
import { KiroAcpTransport } from "./acp-transport.js";
|
|
3
|
-
import { detectAuth, resolveApiKey,
|
|
3
|
+
import { detectAuth, resolveApiKey, startKiroCliLoginOnce } from "./auth.js";
|
|
4
4
|
import { KiroCliChatTransport } from "./cli-transport.js";
|
|
5
5
|
import { loadOptions } from "./config.js";
|
|
6
6
|
import { createKiroFetch } from "./fetch-adapter.js";
|
|
@@ -170,7 +170,7 @@ export function createKiroPlugin() {
|
|
|
170
170
|
type: "oauth",
|
|
171
171
|
label: "Kiro CLI login",
|
|
172
172
|
authorize: async () => {
|
|
173
|
-
const session =
|
|
173
|
+
const session = startKiroCliLoginOnce();
|
|
174
174
|
return {
|
|
175
175
|
url: session.url,
|
|
176
176
|
instructions: session.instructions,
|