@chrysb/alphaclaw 0.9.21 → 0.9.22

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.
@@ -110,7 +110,8 @@ export const Models = ({ onRestartRequired = () => {}, agentId, embedded = false
110
110
  () =>
111
111
  Object.keys(configuredModels).map((key) => {
112
112
  const catalogEntry =
113
- catalog.find((m) => m.key === key) || buildSyntheticModelEntry(key);
113
+ selectableCatalog.find((m) => m.key === key) ||
114
+ buildSyntheticModelEntry(key);
114
115
  const provider = getModelsTabAuthProvider(key);
115
116
  const hasAuth = !!providerHasAuth[provider];
116
117
  return {
@@ -121,7 +122,7 @@ export const Models = ({ onRestartRequired = () => {}, agentId, embedded = false
121
122
  hasAuth,
122
123
  };
123
124
  }),
124
- [configuredModels, catalog, primary, providerHasAuth],
125
+ [configuredModels, selectableCatalog, primary, providerHasAuth],
125
126
  );
126
127
 
127
128
  const headerActions = html`
@@ -343,15 +343,24 @@ export const useModels = (agentId) => {
343
343
  ]);
344
344
 
345
345
  const refreshCodexStatus = useCallback(async () => {
346
+ let codex;
346
347
  try {
347
- const codex = await fetchCodexStatus();
348
+ codex = await fetchCodexStatus();
348
349
  setCodexStatus(codex || { connected: false });
349
350
  updateCache({ codexStatus: codex || { connected: false } });
350
351
  } catch {
351
352
  setCodexStatus({ connected: false });
352
353
  updateCache({ codexStatus: { connected: false } });
354
+ return;
353
355
  }
354
- }, [updateCache]);
356
+ try {
357
+ invalidateCache(kModelCatalogCacheKey);
358
+ const catalogResult = await catalogFetchState.refresh({ force: true });
359
+ applyCatalogResult(catalogResult);
360
+ } catch {
361
+ // Keep the successful auth status; catalog polling will retry discovery.
362
+ }
363
+ }, [applyCatalogResult, catalogFetchState, updateCache]);
355
364
 
356
365
  return {
357
366
  catalog,
@@ -97,7 +97,7 @@ const registerServerRoutes = ({
97
97
  });
98
98
 
99
99
  registerPageRoutes({ app, requireAuth, isGatewayRunning });
100
- registerModelRoutes({
100
+ const modelCatalogCache = registerModelRoutes({
101
101
  app,
102
102
  shellCmd,
103
103
  gatewayEnv,
@@ -150,6 +150,7 @@ const registerServerRoutes = ({
150
150
  parseCodexAuthorizationInput,
151
151
  getCodexAccountId,
152
152
  authProfiles,
153
+ onAuthChanged: () => modelCatalogCache.markStale(),
153
154
  });
154
155
  registerGoogleRoutes({
155
156
  app,
@@ -29,6 +29,7 @@ const registerCodexRoutes = ({
29
29
  parseCodexAuthorizationInput,
30
30
  getCodexAccountId,
31
31
  authProfiles,
32
+ onAuthChanged = () => {},
32
33
  }) => {
33
34
  const { kCodexOauthStates, cleanupCodexOauthStates } = createCodexOauthState();
34
35
 
@@ -123,6 +124,7 @@ const registerCodexRoutes = ({
123
124
  const accountId = getCodexAccountId(access);
124
125
 
125
126
  authProfiles.upsertCodexProfile({ access, refresh, expires, accountId });
127
+ onAuthChanged();
126
128
 
127
129
  return res.send(`<!DOCTYPE html><html><body><script>
128
130
  window.opener?.postMessage({ codex: 'success' }, '*');
@@ -186,6 +188,7 @@ const registerCodexRoutes = ({
186
188
  const expires = Date.now() + Number(json.expires_in) * 1000;
187
189
  const accountId = getCodexAccountId(access);
188
190
  authProfiles.upsertCodexProfile({ access, refresh, expires, accountId });
191
+ onAuthChanged();
189
192
  return res.json({ ok: true });
190
193
  } catch (err) {
191
194
  console.error("[codex] Manual exchange error:", err);
@@ -197,6 +200,7 @@ const registerCodexRoutes = ({
197
200
 
198
201
  app.post("/api/codex/disconnect", (req, res) => {
199
202
  const changed = authProfiles.removeCodexProfiles();
203
+ if (changed) onAuthChanged();
200
204
  res.json({ ok: true, changed });
201
205
  });
202
206
  };
@@ -422,6 +422,8 @@ const registerModelRoutes = ({
422
422
  });
423
423
  }
424
424
  });
425
+
426
+ return modelCatalogCache;
425
427
  };
426
428
 
427
429
  module.exports = { registerModelRoutes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrysb/alphaclaw",
3
- "version": "0.9.21",
3
+ "version": "0.9.22",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },