open-agents-ai 0.103.26 → 0.103.28

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.
Files changed (2) hide show
  1. package/dist/index.js +73 -40
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -26272,25 +26272,6 @@ function renderSlashHelp() {
26272
26272
  `);
26273
26273
  process.stdout.write("\n");
26274
26274
  }
26275
- function renderModelList(models, current) {
26276
- process.stdout.write(`
26277
- ${c2.bold("Available models:")}
26278
-
26279
- `);
26280
- for (const m of models) {
26281
- const isCurrent = m.name === current;
26282
- const marker = isCurrent ? c2.green("\u25CF") : c2.dim("\u25CB");
26283
- const name = isCurrent ? c2.bold(c2.green(m.name)) : m.name;
26284
- const size = c2.dim(m.size);
26285
- const modified = c2.dim(m.modified);
26286
- process.stdout.write(` ${marker} ${name.padEnd(50)} ${size.padEnd(12)} ${modified}
26287
- `);
26288
- }
26289
- process.stdout.write(`
26290
- ${c2.dim("Use /model <name> to switch models.")}
26291
-
26292
- `);
26293
- }
26294
26275
  function renderModelSwitch(oldModel, newModel) {
26295
26276
  process.stdout.write(`
26296
26277
  ${c2.green("\u2714")} Switched model: ${c2.dim(oldModel)} \u2192 ${c2.bold(c2.green(newModel))}
@@ -29816,19 +29797,51 @@ async function fetchPeerModels(peerId) {
29816
29797
  const { join: join55 } = await import("node:path");
29817
29798
  const cwd4 = process.cwd();
29818
29799
  const nexusTool = new NexusTool2(cwd4);
29819
- const pricingPath = join55(nexusTool.getNexusDir(), "pricing.json");
29820
- if (existsSync42(pricingPath)) {
29800
+ const nexusDir = nexusTool.getNexusDir();
29801
+ let isLocalPeer = false;
29802
+ try {
29803
+ const statusPath = join55(nexusDir, "status.json");
29804
+ if (existsSync42(statusPath)) {
29805
+ const status = JSON.parse(readFileSync31(statusPath, "utf8"));
29806
+ if (status.peerId === peerId)
29807
+ isLocalPeer = true;
29808
+ }
29809
+ } catch {
29810
+ }
29811
+ if (isLocalPeer) {
29812
+ const pricingPath = join55(nexusDir, "pricing.json");
29813
+ if (existsSync42(pricingPath)) {
29814
+ try {
29815
+ const pricing = JSON.parse(readFileSync31(pricingPath, "utf8"));
29816
+ const localModels = (pricing.models || []).map((m) => ({
29817
+ name: m.model || "unknown",
29818
+ size: m.parameterSize || "",
29819
+ modified: "",
29820
+ sizeBytes: 0,
29821
+ parameterSize: m.parameterSize || "remote"
29822
+ }));
29823
+ if (localModels.length > 0)
29824
+ return localModels;
29825
+ } catch {
29826
+ }
29827
+ }
29828
+ }
29829
+ const cachePath = join55(nexusDir, "peer-models-cache.json");
29830
+ if (existsSync42(cachePath)) {
29821
29831
  try {
29822
- const pricing = JSON.parse(readFileSync31(pricingPath, "utf8"));
29823
- const localModels = (pricing.models || []).map((m) => ({
29824
- name: m.model || "unknown",
29825
- size: m.parameterSize || "",
29826
- modified: "",
29827
- sizeBytes: 0,
29828
- parameterSize: m.parameterSize || "remote"
29829
- }));
29830
- if (localModels.length > 0)
29831
- return localModels;
29832
+ const cache4 = JSON.parse(readFileSync31(cachePath, "utf8"));
29833
+ if (cache4.peerId === peerId && cache4.models?.length > 0) {
29834
+ const age = Date.now() - new Date(cache4.cachedAt).getTime();
29835
+ if (age < 5 * 60 * 1e3) {
29836
+ return cache4.models.map((m) => ({
29837
+ name: m.name || "unknown",
29838
+ size: m.size || m.parameterSize || "",
29839
+ modified: "",
29840
+ sizeBytes: 0,
29841
+ parameterSize: m.parameterSize || "remote"
29842
+ }));
29843
+ }
29844
+ }
29832
29845
  } catch {
29833
29846
  }
29834
29847
  }
@@ -29853,6 +29866,22 @@ async function fetchPeerModels(peerId) {
29853
29866
  if (models.length > 0)
29854
29867
  return models;
29855
29868
  }
29869
+ if (isLocalPeer) {
29870
+ const pricingPath = join55(nexusDir, "pricing.json");
29871
+ if (existsSync42(pricingPath)) {
29872
+ try {
29873
+ const pricing = JSON.parse(readFileSync31(pricingPath, "utf8"));
29874
+ return (pricing.models || []).map((m) => ({
29875
+ name: m.model || "unknown",
29876
+ size: m.parameterSize || "",
29877
+ modified: "",
29878
+ sizeBytes: 0,
29879
+ parameterSize: m.parameterSize || "remote"
29880
+ }));
29881
+ } catch {
29882
+ }
29883
+ }
29884
+ }
29856
29885
  return [];
29857
29886
  } catch {
29858
29887
  return [];
@@ -33019,7 +33048,7 @@ async function handleSlashCommand(input, ctx) {
33019
33048
  }
33020
33049
  return "handled";
33021
33050
  case "models":
33022
- await listModels(ctx);
33051
+ await showModelPicker(ctx, hasLocal);
33023
33052
  return "handled";
33024
33053
  case "endpoint":
33025
33054
  case "ep":
@@ -33919,14 +33948,6 @@ function applyConfigChanges(ctx, changes) {
33919
33948
  if (changes.commandsMode !== void 0)
33920
33949
  ctx.setCommandsMode?.(changes.commandsMode);
33921
33950
  }
33922
- async function listModels(ctx) {
33923
- try {
33924
- const models = await fetchModels(ctx.config.backendUrl, ctx.config.apiKey);
33925
- renderModelList(models.map((m) => ({ name: m.name, size: m.size, modified: m.modified })), ctx.config.model);
33926
- } catch (err) {
33927
- renderError(`Failed to fetch models: ${err instanceof Error ? err.message : String(err)}`);
33928
- }
33929
- }
33930
33951
  async function showModelPicker(ctx, local = false) {
33931
33952
  try {
33932
33953
  const models = await fetchModels(ctx.config.backendUrl, ctx.config.apiKey);
@@ -34273,6 +34294,18 @@ async function handlePeerEndpoint(peerId, authKey, ctx, local) {
34273
34294
  try {
34274
34295
  const models = await fetchModels(peerUrl, authKey);
34275
34296
  if (models.length > 0) {
34297
+ try {
34298
+ const { writeFileSync: writeFileSync19, mkdirSync: mkdirSync21 } = await import("node:fs");
34299
+ const { join: join55, dirname: dirname20 } = await import("node:path");
34300
+ const cachePath = join55(ctx.repoRoot || process.cwd(), ".oa", "nexus", "peer-models-cache.json");
34301
+ mkdirSync21(dirname20(cachePath), { recursive: true });
34302
+ writeFileSync19(cachePath, JSON.stringify({
34303
+ peerId,
34304
+ cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
34305
+ models: models.map((m) => ({ name: m.name, size: m.size, parameterSize: m.parameterSize }))
34306
+ }, null, 2));
34307
+ } catch {
34308
+ }
34276
34309
  process.stdout.write(` ${c2.green("\u2714")} Discovered ${models.length} model(s) on peer:
34277
34310
  `);
34278
34311
  for (const m of models.slice(0, 10)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.103.26",
3
+ "version": "0.103.28",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",