@bivy/bivy 0.10.1-staging.201 → 0.10.1-staging.202

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.
@@ -272,6 +272,11 @@ class PiSession {
272
272
  await runtime.getAvailable();
273
273
  return runtime.getModels().map((model) => toModelInfo(model, runtime.hasConfiguredAuth(model.provider)));
274
274
  }
275
+ /** Reload the projected models.json in-place so a live session immediately
276
+ * sees custom endpoints added after that session was created. */
277
+ async refreshModels() {
278
+ await this.session.modelRuntime.refresh({ allowNetwork: true });
279
+ }
275
280
  getCurrentModel() {
276
281
  const model = this.session.model;
277
282
  return model ? toModelInfo(model) : undefined;
package/dist/server.js CHANGED
@@ -5054,20 +5054,33 @@ function nativeLoginCommand() {
5054
5054
  return `cd ${shellQuote(repoRoot)} && BIVY_WORKSPACE=${shellQuote(active?.workspace ?? defaultWorkspace)} npm run bivy -- login`;
5055
5055
  }
5056
5056
  async function refreshSessionAfterAuth() {
5057
- // Model runtimes load the projected models.json when the session is created.
5058
- // Drop the per-runtime scratch sessions before rebuilding the active session;
5059
- // otherwise a models.list immediately after adding a custom endpoint can be
5060
- // answered by a runtime that still has the old catalog cached.
5061
- for (const record of modelQueryScratch.values()) {
5057
+ // Model runtimes load the projected models.json into memory. Scratch sessions
5058
+ // are disposable, so evict them and let the next picker read build a fresh
5059
+ // one. Live sessions are not disposable: replacing `active` with a brand-new
5060
+ // session left the client's original session (the one models.list names by
5061
+ // id) on its stale catalog, so custom providers never appeared there. Reload
5062
+ // capable runtimes in place instead.
5063
+ const scratchRecords = new Set(modelQueryScratch.values());
5064
+ for (const record of scratchRecords)
5062
5065
  closeSessionRecord(record);
5063
- }
5064
5066
  modelQueryScratch.clear();
5065
- try {
5066
- await createSession(active?.workspace ?? defaultWorkspace);
5067
- }
5068
- catch (error) {
5069
- broadcast({ type: "session.error", sessionId: active?.id, error: String(error instanceof Error ? error.stack ?? error.message : error) });
5070
- }
5067
+ const sessions = new Map();
5068
+ for (const record of openSessions.values())
5069
+ sessions.set(record.id, record);
5070
+ await Promise.all([...sessions.values()].map(async (record) => {
5071
+ if (typeof record.session.refreshModels !== "function")
5072
+ return;
5073
+ try {
5074
+ await record.session.refreshModels();
5075
+ }
5076
+ catch (error) {
5077
+ broadcast({
5078
+ type: "session.error",
5079
+ sessionId: record.id,
5080
+ error: `Could not refresh models: ${error instanceof Error ? error.message : String(error)}`,
5081
+ });
5082
+ }
5083
+ }));
5071
5084
  }
5072
5085
  /**
5073
5086
  * The "Models & providers" list. `base` is the node's per-provider auth status
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bivy/bivy",
3
- "version": "0.10.1-staging.201",
3
+ "version": "0.10.1-staging.202",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0-only",
6
6
  "description": "Run coding agents on machines you own. Open-source, self-hostable agent workspace.",