opencode-copilot-account-switcher 0.14.11 → 0.14.13

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.
@@ -586,8 +586,21 @@ export function buildPluginHooks(input) {
586
586
  const triggerBillingCompensation = input.triggerBillingCompensation ?? (async () => { });
587
587
  const ensureWechatBrokerStarted = input.ensureWechatBrokerStarted ?? (async () => connectOrSpawnBroker());
588
588
  const createWechatBridgeLifecycleImpl = input.createWechatBridgeLifecycleImpl ?? createWechatBridgeLifecycle;
589
- if (input.serverUrl && hasWechatBridgeClientShape(input.client)) {
590
- const wechatBridgeClient = input.client;
589
+ const wechatBridgeClient = hasWechatBridgeClientShape(input.client) ? input.client : undefined;
590
+ if (wechatBridgeClient) {
591
+ void showStatusToast({
592
+ client: input.client,
593
+ message: "正在尝试连接或拉起 WeChat broker...",
594
+ variant: "info",
595
+ warn: (scope, error) => {
596
+ console.warn(`[${scope}] failed to show toast`, error);
597
+ },
598
+ });
599
+ void Promise.resolve()
600
+ .then(() => ensureWechatBrokerStarted())
601
+ .catch(() => { });
602
+ }
603
+ if (input.serverUrl && wechatBridgeClient) {
591
604
  const lifecycleKey = buildWechatBridgeLifecycleKey({
592
605
  directory: input.directory,
593
606
  serverUrl: input.serverUrl,
@@ -597,9 +610,6 @@ export function buildPluginHooks(input) {
597
610
  void ensureWechatBridgeLifecycle({
598
611
  key: lifecycleKey,
599
612
  create: async () => {
600
- void Promise.resolve()
601
- .then(() => ensureWechatBrokerStarted())
602
- .catch(() => { });
603
613
  return createWechatBridgeLifecycleImpl({
604
614
  client: wechatBridgeClient,
605
615
  project: input.project,
package/dist/plugin.js CHANGED
@@ -4,6 +4,7 @@ import { runProviderMenu } from "./menu-runtime.js";
4
4
  import { persistAccountSwitch } from "./plugin-actions.js";
5
5
  import { buildPluginHooks } from "./plugin-hooks.js";
6
6
  import { readCommonSettingsStore, readCommonSettingsStoreSync, writeCommonSettingsStore, } from "./common-settings-store.js";
7
+ import { connectOrSpawnBroker } from "./wechat/broker-launcher.js";
7
8
  import { createCodexMenuAdapter } from "./providers/codex-menu-adapter.js";
8
9
  import { createCopilotMenuAdapter } from "./providers/copilot-menu-adapter.js";
9
10
  import { createProviderRegistry } from "./providers/registry.js";
@@ -194,6 +195,10 @@ async function createAccountSwitcherPlugin(input, provider) {
194
195
  const client = input.client;
195
196
  const directory = input.directory;
196
197
  const serverUrl = input.serverUrl;
198
+ const ensureWechatBrokerStarted = input.ensureWechatBrokerStarted ?? (async () => connectOrSpawnBroker());
199
+ void Promise.resolve()
200
+ .then(() => ensureWechatBrokerStarted())
201
+ .catch(() => { });
197
202
  const persistStore = (store, meta) => writeStore(store, { debug: meta });
198
203
  const codexClient = {
199
204
  auth: {
@@ -379,6 +384,7 @@ async function createAccountSwitcherPlugin(input, provider) {
379
384
  client,
380
385
  directory,
381
386
  serverUrl,
387
+ ensureWechatBrokerStarted: async () => { },
382
388
  loadCommonSettings: readCommonSettingsStore,
383
389
  loadCommonSettingsSync: readCommonSettingsStoreSync,
384
390
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-copilot-account-switcher",
3
- "version": "0.14.11",
3
+ "version": "0.14.13",
4
4
  "description": "GitHub Copilot account switcher plugin for OpenCode",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",