@bogyie/opencode-kiro-plugin 0.3.19 → 0.3.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/auth.d.ts CHANGED
@@ -77,6 +77,7 @@ export interface KiroLoginFlowOptions {
77
77
  readonly login?: KiroCliLoginOptions;
78
78
  }
79
79
  export declare const KIRO_LOGIN_URL = "https://view.awsapps.com/start";
80
+ export declare const KIRO_LOCAL_TRANSPORT_KEY = "kiro-plugin-local-transport";
80
81
  export declare const DEFAULT_KIRO_CLI_DB_PATH: string;
81
82
  export declare const DEFAULT_KIRO_CLI_TOKEN_KEYS: readonly ["kirocli:odic:token", "codewhisperer:odic:token"];
82
83
  export declare function runCommand(command: string, args: ReadonlyArray<string>, options?: CommandRunOptions): Promise<CommandResult>;
package/dist/auth.js CHANGED
@@ -6,6 +6,7 @@ import { join } from "node:path";
6
6
  import { promisify } from "node:util";
7
7
  const execFileAsync = promisify(execFile);
8
8
  export const KIRO_LOGIN_URL = "https://view.awsapps.com/start";
9
+ export const KIRO_LOCAL_TRANSPORT_KEY = "kiro-plugin-local-transport";
9
10
  export const DEFAULT_KIRO_CLI_DB_PATH = join(homedir(), "Library", "Application Support", "kiro-cli", "data.sqlite3");
10
11
  export const DEFAULT_KIRO_CLI_TOKEN_KEYS = ["kirocli:odic:token", "codewhisperer:odic:token"];
11
12
  const KIRO_DEVICE_AUTH_KEY_PREFIX = "kiro-device:";
@@ -513,7 +514,7 @@ export function startKiroCliLogin(optionsOrSpawner, spawner) {
513
514
  const deadline = Date.now() + 10 * 60 * 1000;
514
515
  while (Date.now() < deadline) {
515
516
  const auth = await detectAuth(process.env, runner);
516
- if (auth.authenticated)
517
+ if (auth.authenticated && (!loginPromptReady(output) || exited))
517
518
  return true;
518
519
  if (exited && exitCode !== 0 && !loginPromptReady(output))
519
520
  return false;
@@ -630,7 +631,10 @@ export async function resolveApiKey(auth, env = process.env) {
630
631
  return env.KIRO_API_KEY;
631
632
  try {
632
633
  const credential = await auth();
633
- return credential.key || credential.access || "";
634
+ if (credential.type === "api")
635
+ return credential.key || credential.access || "";
636
+ const key = credential.key || credential.access || "";
637
+ return key === KIRO_LOCAL_TRANSPORT_KEY || isKiroDeviceAuthKey(key) ? key : "";
634
638
  }
635
639
  catch {
636
640
  return "";
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 { credentialFromKiroDeviceAuthKey, detectAuth, isKiroDeviceAuthKey, readKiroCliSessionCredential, resolveApiKey, startKiroCliLoginOnce, runKiroLoginFlowOnce, } from "./auth.js";
3
+ import { credentialFromKiroDeviceAuthKey, detectAuth, isKiroDeviceAuthKey, KIRO_LOCAL_TRANSPORT_KEY, readKiroCliSessionCredential, resolveApiKey, startKiroCliLoginOnce, runKiroLoginFlowOnce, } 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";
@@ -70,7 +70,7 @@ export function effectiveBackend(options, accessToken) {
70
70
  return "cli-chat";
71
71
  if (options.backend === "fetch")
72
72
  return "fetch";
73
- if (apiKey && apiKey !== "kiro-plugin-local-transport")
73
+ if (apiKey && apiKey !== KIRO_LOCAL_TRANSPORT_KEY)
74
74
  return "fetch";
75
75
  return "fetch";
76
76
  }
@@ -107,7 +107,7 @@ function localTransport(options, accessToken, behavior = {}) {
107
107
  login,
108
108
  });
109
109
  }
110
- return new KiroRestTransport(fetchTransportOptions(options, apiKey === "kiro-plugin-local-transport" ? undefined : apiKey), {
110
+ return new KiroRestTransport(fetchTransportOptions(options, apiKey === KIRO_LOCAL_TRANSPORT_KEY ? undefined : apiKey), {
111
111
  login,
112
112
  });
113
113
  }
@@ -238,7 +238,7 @@ export function createKiroPlugin() {
238
238
  await refreshModels(true).catch(() => []);
239
239
  return {
240
240
  type: "success",
241
- key: "kiro-plugin-local-transport",
241
+ key: KIRO_LOCAL_TRANSPORT_KEY,
242
242
  metadata: {
243
243
  source: "kiro-cli-device-flow",
244
244
  },
@@ -300,7 +300,7 @@ export function createKiroPlugin() {
300
300
  const apiKey = await resolveApiKey(auth);
301
301
  const server = await ensureLocalServer();
302
302
  return {
303
- apiKey: apiKey || "kiro-plugin-local-transport",
303
+ apiKey: apiKey || KIRO_LOCAL_TRANSPORT_KEY,
304
304
  baseURL: server.baseURL,
305
305
  };
306
306
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bogyie/opencode-kiro-plugin",
3
- "version": "0.3.19",
3
+ "version": "0.3.20",
4
4
  "description": "OpenCode plugin for using Kiro as a provider adapter",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",