opencode-copilot-account-switcher 0.14.10 → 0.14.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.
@@ -88,6 +88,7 @@ export declare function buildPluginHooks(input: {
88
88
  };
89
89
  directory?: CopilotRetryContext["directory"];
90
90
  serverUrl?: CopilotRetryContext["serverUrl"];
91
+ ensureWechatBrokerStarted?: () => Promise<unknown>;
91
92
  createWechatBridgeLifecycleImpl?: (input: WechatBridgeLifecycleInput) => Promise<{
92
93
  close: () => Promise<void>;
93
94
  }>;
@@ -20,6 +20,7 @@ import { handleCodexStatusCommand } from "./codex-status-command.js";
20
20
  import { handleCompactCommand, handleStopToolCommand, } from "./session-control-command.js";
21
21
  import { appendRoutingEvent, appendRouteDecisionEvent, appendSessionTouchEvent, buildCandidateAccountLoads, isAccountRateLimitCooledDown, readRoutingState, routingStatePath, } from "./routing-state.js";
22
22
  import { createWechatBridgeLifecycle, } from "./wechat/bridge.js";
23
+ import { connectOrSpawnBroker } from "./wechat/broker-launcher.js";
23
24
  const SESSION_BINDING_IDLE_TTL_MS = 30 * 60 * 1000;
24
25
  const RATE_LIMIT_WINDOW_MS = 5 * 60 * 1000;
25
26
  const RATE_LIMIT_HIT_THRESHOLD = 3;
@@ -583,9 +584,23 @@ export function buildPluginHooks(input) {
583
584
  const appendRouteDecisionEventImpl = input.appendRouteDecisionEventImpl ?? appendRouteDecisionEvent;
584
585
  const readRoutingStateImpl = input.readRoutingStateImpl ?? readRoutingState;
585
586
  const triggerBillingCompensation = input.triggerBillingCompensation ?? (async () => { });
587
+ const ensureWechatBrokerStarted = input.ensureWechatBrokerStarted ?? (async () => connectOrSpawnBroker());
586
588
  const createWechatBridgeLifecycleImpl = input.createWechatBridgeLifecycleImpl ?? createWechatBridgeLifecycle;
587
- if (input.serverUrl && hasWechatBridgeClientShape(input.client)) {
588
- 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) {
589
604
  const lifecycleKey = buildWechatBridgeLifecycleKey({
590
605
  directory: input.directory,
591
606
  serverUrl: input.serverUrl,
@@ -594,13 +609,15 @@ export function buildPluginHooks(input) {
594
609
  attachWechatBridgeAutoClose();
595
610
  void ensureWechatBridgeLifecycle({
596
611
  key: lifecycleKey,
597
- create: () => createWechatBridgeLifecycleImpl({
598
- client: wechatBridgeClient,
599
- project: input.project,
600
- directory: input.directory,
601
- serverUrl: input.serverUrl,
602
- statusCollectionEnabled: true,
603
- }),
612
+ create: async () => {
613
+ return createWechatBridgeLifecycleImpl({
614
+ client: wechatBridgeClient,
615
+ project: input.project,
616
+ directory: input.directory,
617
+ serverUrl: input.serverUrl,
618
+ statusCollectionEnabled: true,
619
+ });
620
+ },
604
621
  }).catch(() => { });
605
622
  }
606
623
  const loadCandidateAccountLoads = input.loadCandidateAccountLoads ?? (async (ctx) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-copilot-account-switcher",
3
- "version": "0.14.10",
3
+ "version": "0.14.12",
4
4
  "description": "GitHub Copilot account switcher plugin for OpenCode",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",