@victor-software-house/pi-multicodex 2.1.0 → 2.1.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.
@@ -32,6 +32,7 @@ export class AccountManager {
32
32
  private warningHandler?: WarningHandler;
33
33
  private manualEmail?: string;
34
34
  private stateChangeHandlers = new Set<StateChangeHandler>();
35
+ private warnedAuthFailureEmails = new Set<string>();
35
36
 
36
37
  constructor() {
37
38
  this.data = loadStorage();
@@ -83,6 +84,23 @@ export class AccountManager {
83
84
  this.warningHandler = handler;
84
85
  }
85
86
 
87
+ resetSessionWarnings(): void {
88
+ this.warnedAuthFailureEmails.clear();
89
+ }
90
+
91
+ notifyRotationSkipForAuthFailure(account: Account, error: unknown): void {
92
+ if (this.warnedAuthFailureEmails.has(account.email)) {
93
+ return;
94
+ }
95
+ this.warnedAuthFailureEmails.add(account.email);
96
+ const hint = account.importSource
97
+ ? "/multicodex reauth"
98
+ : `/multicodex reauth ${account.email}`;
99
+ this.warningHandler?.(
100
+ `Multicodex skipped ${account.email} during rotation: ${normalizeUnknownError(error)}. Account is flagged in /multicodex accounts. Run ${hint} to repair it.`,
101
+ );
102
+ }
103
+
86
104
  private updateAccountEmail(account: Account, email: string): boolean {
87
105
  if (account.email === email) return false;
88
106
  const previousEmail = account.email;
@@ -173,6 +191,7 @@ export class AccountManager {
173
191
  }
174
192
  if (account.needsReauth) {
175
193
  account.needsReauth = undefined;
194
+ this.warnedAuthFailureEmails.delete(account.email);
176
195
  changed = true;
177
196
  }
178
197
  return changed;
package/extension.ts CHANGED
@@ -28,6 +28,7 @@ export default function multicodexExtension(pi: ExtensionAPI) {
28
28
 
29
29
  pi.on("session_start", (_event: unknown, ctx: ExtensionContext) => {
30
30
  lastContext = ctx;
31
+ accountManager.resetSessionWarnings();
31
32
  handleSessionStart(accountManager, (msg) => ctx.ui.notify(msg, "warning"));
32
33
  statusController.startAutoRefresh();
33
34
  void (async () => {
@@ -41,6 +42,7 @@ export default function multicodexExtension(pi: ExtensionAPI) {
41
42
  (event: { reason?: string }, ctx: ExtensionContext) => {
42
43
  lastContext = ctx;
43
44
  if (event.reason === "new") {
45
+ accountManager.resetSessionWarnings();
44
46
  handleNewSessionSwitch(accountManager, (msg) =>
45
47
  ctx.ui.notify(msg, "warning"),
46
48
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@victor-software-house/pi-multicodex",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Codex account rotation extension for pi",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/stream-wrapper.ts CHANGED
@@ -68,6 +68,7 @@ export function createStreamWrapper(
68
68
  try {
69
69
  token = await accountManager.ensureValidToken(account);
70
70
  } catch (error) {
71
+ accountManager.notifyRotationSkipForAuthFailure(account, error);
71
72
  if (usingManual) {
72
73
  accountManager.clearManualAccount();
73
74
  }