opencode-copilot-account-switcher 0.12.0 → 0.12.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.
@@ -19,11 +19,12 @@ function pickNumber(value) {
19
19
  return typeof value === "number" && Number.isFinite(value) ? value : undefined;
20
20
  }
21
21
  async function showToast(input) {
22
+ const tui = input.client?.tui;
22
23
  const show = input.client?.tui?.showToast;
23
24
  if (!show)
24
25
  return;
25
26
  try {
26
- await show({
27
+ await show.call(tui, {
27
28
  body: {
28
29
  message: input.message,
29
30
  variant: input.variant,
@@ -77,11 +78,12 @@ function hasCachedStore(store) {
77
78
  || store.status?.premium?.remaining !== undefined);
78
79
  }
79
80
  async function defaultLoadAuth(client) {
81
+ const authClient = client?.auth;
80
82
  const getAuth = client?.auth?.get;
81
83
  if (!getAuth)
82
84
  return undefined;
83
85
  try {
84
- const result = await getAuth({ path: { id: "openai" }, throwOnError: true });
86
+ const result = await getAuth.call(authClient, { path: { id: "openai" }, throwOnError: true });
85
87
  const withData = asRecord(result)?.data;
86
88
  const payload = asRecord(withData) ?? asRecord(result);
87
89
  if (!payload)
@@ -95,13 +97,14 @@ async function defaultLoadAuth(client) {
95
97
  }
96
98
  }
97
99
  async function defaultPersistAuth(client, auth) {
100
+ const authClient = client?.auth;
98
101
  const setAuth = client?.auth?.set;
99
102
  if (!setAuth)
100
103
  return;
101
104
  const openai = asRecord(auth.openai);
102
105
  if (!openai)
103
106
  return;
104
- await setAuth({
107
+ await setAuth.call(authClient, {
105
108
  path: { id: "openai" },
106
109
  body: {
107
110
  type: "oauth",
@@ -662,6 +662,7 @@ export function buildPluginHooks(input) {
662
662
  let decisionTouchWriteError;
663
663
  let finalChosenAccount = resolved.name;
664
664
  let finalRequestHeaders = getFinalSentRequestHeadersRecord(selectionRequest, selectionInit);
665
+ let networkRequestHeaders;
665
666
  const previousBindingAccount = sessionID.length > 0 ? sessionAccountBindings.get(sessionID)?.accountName : undefined;
666
667
  if (sessionID.length > 0) {
667
668
  sessionAccountBindings.set(sessionID, {
@@ -733,6 +734,7 @@ export function buildPluginHooks(input) {
733
734
  const outbound = stripInternalSessionHeader(requestValue, initValue);
734
735
  return finalHeaderCapture.run((headers) => {
735
736
  finalRequestHeaders = headers;
737
+ networkRequestHeaders = headers;
736
738
  }, () => authOverride.run(candidateAuth, () => config.fetch(rewriteRequestForAccount(outbound.request, candidate.entry.enterpriseUrl), outbound.init)));
737
739
  };
738
740
  const response = await sendWithAccount(resolved, nextRequest, nextInit);
@@ -896,6 +898,7 @@ export function buildPluginHooks(input) {
896
898
  rateLimitMatched: decisionRateLimitMatched,
897
899
  retryAfterMs: decisionRetryAfterMs,
898
900
  finalRequestHeaders,
901
+ networkRequestHeaders,
899
902
  },
900
903
  }).catch(() => undefined);
901
904
  return sendWithAccount(replacement, retriedRequest, retriedInit);
@@ -928,6 +931,7 @@ export function buildPluginHooks(input) {
928
931
  rateLimitMatched: decisionRateLimitMatched,
929
932
  retryAfterMs: decisionRetryAfterMs,
930
933
  finalRequestHeaders,
934
+ networkRequestHeaders,
931
935
  },
932
936
  }).catch(() => undefined);
933
937
  if (shouldShowConsumptionToast({ reason: decisionReason, isFirstUse })) {
@@ -78,6 +78,7 @@ export type RouteDecisionEvent = {
78
78
  rateLimitMatched: boolean;
79
79
  retryAfterMs?: number;
80
80
  finalRequestHeaders?: Record<string, string>;
81
+ networkRequestHeaders?: Record<string, string>;
81
82
  };
82
83
  export type RoutingEvent = SessionTouchEvent | RateLimitFlaggedEvent;
83
84
  export declare function appendRouteDecisionEvent(input: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-copilot-account-switcher",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "GitHub Copilot account switcher plugin for OpenCode",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",