opencode-copilot-account-switcher 0.11.0 → 0.11.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.
@@ -75,7 +75,9 @@ export function rewriteModelAccountAssignments(store, rename) {
75
75
  const seen = new Set();
76
76
  const resolvedNames = [];
77
77
  for (const originalName of accountNames) {
78
- const mappedName = rename[originalName] ?? originalName;
78
+ const mappedName = Object.prototype.hasOwnProperty.call(rename, originalName)
79
+ ? rename[originalName]
80
+ : originalName;
79
81
  if (typeof mappedName !== "string" || !store.accounts[mappedName] || seen.has(mappedName))
80
82
  continue;
81
83
  seen.add(mappedName);
@@ -559,7 +559,7 @@ export function buildPluginHooks(input) {
559
559
  const initiator = getMergedRequestHeader(selectionRequest, selectionInit, "x-initiator");
560
560
  const candidates = latestStore ? resolveCopilotModelAccounts(latestStore, modelID) : [];
561
561
  if (candidates.length === 0) {
562
- const outbound = stripInternalSessionHeader(request, init);
562
+ const outbound = stripInternalSessionHeader(selectionRequest, selectionInit);
563
563
  return config.fetch(outbound.request, outbound.init);
564
564
  }
565
565
  const hasExistingBinding = sessionID.length > 0 && sessionAccountBindings.has(sessionID);
@@ -603,7 +603,7 @@ export function buildPluginHooks(input) {
603
603
  })
604
604
  : undefined;
605
605
  if (!resolved) {
606
- const outbound = stripInternalSessionHeader(request, init);
606
+ const outbound = stripInternalSessionHeader(selectionRequest, selectionInit);
607
607
  return config.fetch(outbound.request, outbound.init);
608
608
  }
609
609
  const candidateNames = candidates.map((item) => item.name);
@@ -642,13 +642,13 @@ export function buildPluginHooks(input) {
642
642
  if (isFirstUse) {
643
643
  modelAccountFirstUse.add(resolved.name);
644
644
  }
645
- let nextRequest = request;
646
- let nextInit = init;
647
- const currentInitiator = getMergedRequestHeader(request, init, "x-initiator");
645
+ let nextRequest = selectionRequest;
646
+ let nextInit = selectionInit;
647
+ const currentInitiator = getMergedRequestHeader(selectionRequest, selectionInit, "x-initiator");
648
648
  const shouldStripAgentInitiator = classification.reason === "unbound-fallback"
649
649
  || (isFirstUse && currentInitiator === "agent");
650
650
  if (shouldStripAgentInitiator && currentInitiator === "agent") {
651
- const rewritten = mergeAndRewriteRequestHeaders(request, init, (headers) => {
651
+ const rewritten = mergeAndRewriteRequestHeaders(selectionRequest, selectionInit, (headers) => {
652
652
  headers.delete("x-initiator");
653
653
  });
654
654
  nextRequest = rewritten.request;
@@ -59,25 +59,6 @@ function renderAccountGrid(cells) {
59
59
  }
60
60
  return rows;
61
61
  }
62
- function formatActiveGroup(store) {
63
- const names = Array.isArray(store.activeAccountNames) ? store.activeAccountNames : [];
64
- if (names.length > 0)
65
- return names.join(", ");
66
- return "none";
67
- }
68
- function formatRoutingGroup(store) {
69
- const assignments = store.modelAccountAssignments ?? {};
70
- const modelIDs = Object.keys(assignments).sort((a, b) => a.localeCompare(b));
71
- const mapped = modelIDs
72
- .map((modelID) => {
73
- const names = assignments[modelID] ?? [];
74
- if (names.length === 0)
75
- return undefined;
76
- return `${modelID} -> ${names.join(", ")}`;
77
- })
78
- .filter((line) => Boolean(line));
79
- return mapped.length > 0 ? mapped.join("; ") : "none";
80
- }
81
62
  function buildSuccessMessage(store, _name) {
82
63
  const defaultNames = Array.isArray(store.activeAccountNames) && store.activeAccountNames.length > 0
83
64
  ? store.activeAccountNames
@@ -110,8 +91,6 @@ function buildSuccessMessage(store, _name) {
110
91
  lines.push("[routes]");
111
92
  lines.push("(none)");
112
93
  }
113
- lines.push(`活跃组: ${formatActiveGroup(store)}`);
114
- lines.push(`路由组: ${formatRoutingGroup(store)}`);
115
94
  return lines.join("\n");
116
95
  }
117
96
  function buildMissingActiveMessage() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-copilot-account-switcher",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "GitHub Copilot account switcher plugin for OpenCode",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",