opencode-copilot-account-switcher 0.13.0 → 0.13.1
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/plugin.d.ts +1 -0
- package/dist/plugin.js +12 -4
- package/dist/ui/menu.d.ts +23 -1
- package/dist/ui/menu.js +14 -2
- package/package.json +1 -1
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -163,7 +163,7 @@ export async function activateAddedAccount(input) {
|
|
|
163
163
|
writeStore: input.writeStore,
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
async function createAccountSwitcherPlugin(input, provider) {
|
|
167
167
|
const client = input.client;
|
|
168
168
|
const directory = input.directory;
|
|
169
169
|
const serverUrl = input.serverUrl;
|
|
@@ -182,7 +182,7 @@ export const CopilotAccountSwitcher = async (input) => {
|
|
|
182
182
|
}),
|
|
183
183
|
},
|
|
184
184
|
};
|
|
185
|
-
const
|
|
185
|
+
const copilotMethods = [
|
|
186
186
|
{
|
|
187
187
|
type: "oauth",
|
|
188
188
|
label: "Manage GitHub Copilot accounts",
|
|
@@ -207,6 +207,8 @@ export const CopilotAccountSwitcher = async (input) => {
|
|
|
207
207
|
};
|
|
208
208
|
},
|
|
209
209
|
},
|
|
210
|
+
];
|
|
211
|
+
const codexMethods = [
|
|
210
212
|
{
|
|
211
213
|
type: "oauth",
|
|
212
214
|
label: "Manage OpenAI Codex accounts",
|
|
@@ -348,11 +350,17 @@ export const CopilotAccountSwitcher = async (input) => {
|
|
|
348
350
|
}
|
|
349
351
|
return buildPluginHooks({
|
|
350
352
|
auth: {
|
|
351
|
-
provider
|
|
352
|
-
methods,
|
|
353
|
+
provider,
|
|
354
|
+
methods: provider === "github-copilot" ? copilotMethods : codexMethods,
|
|
353
355
|
},
|
|
354
356
|
client,
|
|
355
357
|
directory,
|
|
356
358
|
serverUrl,
|
|
357
359
|
});
|
|
360
|
+
}
|
|
361
|
+
export const CopilotAccountSwitcher = async (input) => {
|
|
362
|
+
return createAccountSwitcherPlugin(input, "github-copilot");
|
|
363
|
+
};
|
|
364
|
+
export const OpenAICodexAccountSwitcher = async (input) => {
|
|
365
|
+
return createAccountSwitcherPlugin(input, "openai");
|
|
358
366
|
};
|
package/dist/ui/menu.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type MenuItem } from "./select.js";
|
|
1
|
+
import { select, type MenuItem } from "./select.js";
|
|
2
|
+
import { confirm } from "./confirm.js";
|
|
2
3
|
export type AccountStatus = "active" | "expired" | "unknown";
|
|
3
4
|
export interface AccountInfo {
|
|
4
5
|
name: string;
|
|
@@ -165,6 +166,27 @@ export declare function showMenu(accounts: AccountInfo[], input?: {
|
|
|
165
166
|
capabilities?: Partial<MenuCapabilities>;
|
|
166
167
|
language?: MenuLanguage;
|
|
167
168
|
}): Promise<MenuAction>;
|
|
169
|
+
export declare function showMenuWithDeps(accounts: AccountInfo[], input?: {
|
|
170
|
+
provider?: MenuProvider;
|
|
171
|
+
refresh?: {
|
|
172
|
+
enabled: boolean;
|
|
173
|
+
minutes: number;
|
|
174
|
+
};
|
|
175
|
+
lastQuotaRefresh?: number;
|
|
176
|
+
modelAccountAssignmentCount?: number;
|
|
177
|
+
defaultAccountGroupCount?: number;
|
|
178
|
+
loopSafetyEnabled?: boolean;
|
|
179
|
+
loopSafetyProviderScope?: "copilot-only" | "all-models";
|
|
180
|
+
networkRetryEnabled?: boolean;
|
|
181
|
+
syntheticAgentInitiatorEnabled?: boolean;
|
|
182
|
+
experimentalSlashCommandsEnabled?: boolean;
|
|
183
|
+
capabilities?: Partial<MenuCapabilities>;
|
|
184
|
+
language?: MenuLanguage;
|
|
185
|
+
}, deps?: {
|
|
186
|
+
select?: typeof select;
|
|
187
|
+
confirm?: typeof confirm;
|
|
188
|
+
showAccountActions?: typeof showAccountActions;
|
|
189
|
+
}): Promise<MenuAction>;
|
|
168
190
|
export declare function buildAccountActionItems(account: AccountInfo, input?: {
|
|
169
191
|
provider?: MenuProvider;
|
|
170
192
|
}): MenuItem<"switch" | "remove" | "back" | "models">[];
|
package/dist/ui/menu.js
CHANGED
|
@@ -336,6 +336,12 @@ export function buildMenuItems(input) {
|
|
|
336
336
|
];
|
|
337
337
|
}
|
|
338
338
|
export async function showMenu(accounts, input = {}) {
|
|
339
|
+
return showMenuWithDeps(accounts, input);
|
|
340
|
+
}
|
|
341
|
+
export async function showMenuWithDeps(accounts, input = {}, deps = {}) {
|
|
342
|
+
const selectMenu = deps.select ?? select;
|
|
343
|
+
const confirmAction = deps.confirm ?? confirm;
|
|
344
|
+
const showAccountActionMenu = deps.showAccountActions ?? showAccountActions;
|
|
339
345
|
let currentLanguage = input.language ?? "zh";
|
|
340
346
|
while (true) {
|
|
341
347
|
const provider = input.provider ?? "copilot";
|
|
@@ -355,7 +361,7 @@ export async function showMenu(accounts, input = {}) {
|
|
|
355
361
|
capabilities: input.capabilities,
|
|
356
362
|
language: currentLanguage,
|
|
357
363
|
});
|
|
358
|
-
const result = await
|
|
364
|
+
const result = await selectMenu(items, {
|
|
359
365
|
message: copy.menuTitle,
|
|
360
366
|
subtitle: copy.menuSubtitle,
|
|
361
367
|
clearScreen: true,
|
|
@@ -366,8 +372,14 @@ export async function showMenu(accounts, input = {}) {
|
|
|
366
372
|
currentLanguage = currentLanguage === "zh" ? "en" : "zh";
|
|
367
373
|
continue;
|
|
368
374
|
}
|
|
375
|
+
if (result.type === "switch") {
|
|
376
|
+
const next = await showAccountActionMenu(result.account, { provider });
|
|
377
|
+
if (next === "back")
|
|
378
|
+
continue;
|
|
379
|
+
return { type: next, account: result.account };
|
|
380
|
+
}
|
|
369
381
|
if (result.type === "remove-all") {
|
|
370
|
-
const ok = await
|
|
382
|
+
const ok = await confirmAction("Remove ALL accounts? This cannot be undone.");
|
|
371
383
|
if (!ok)
|
|
372
384
|
continue;
|
|
373
385
|
}
|