open-agents-ai 0.65.0 → 0.66.0

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 +50 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25471,14 +25471,39 @@ async function handleUpdate(subcommand, ctx) {
25471
25471
  async function switchModel(query, ctx, local = false) {
25472
25472
  try {
25473
25473
  const models = await fetchModels(ctx.config.backendUrl, ctx.config.apiKey);
25474
- const match = findModel(models, query);
25474
+ let match = findModel(models, query);
25475
25475
  if (!match) {
25476
- renderError(`Model not found: "${query}"`);
25477
- renderInfo("Available models:");
25478
- for (const m of models.slice(0, 10)) {
25479
- renderInfo(` ${m.name}`);
25476
+ if (ctx.config.backendType === "ollama") {
25477
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9._:/-]*$/.test(query)) {
25478
+ renderError(`Invalid model name: "${query}"`);
25479
+ return;
25480
+ }
25481
+ renderInfo(`Model "${query}" not found locally. Pulling from Ollama registry...`);
25482
+ try {
25483
+ pullModelWithAutoUpdate(query);
25484
+ const refreshedModels = await fetchModels(ctx.config.backendUrl, ctx.config.apiKey);
25485
+ match = findModel(refreshedModels, query);
25486
+ if (!match) {
25487
+ renderError(`Model "${query}" was pulled but could not be found.`);
25488
+ return;
25489
+ }
25490
+ } catch {
25491
+ renderError(`Model "${query}" could not be pulled from Ollama registry.`);
25492
+ renderInfo("Check that the model name is correct: https://ollama.com/library");
25493
+ renderInfo("Available local models:");
25494
+ for (const m of models.slice(0, 10)) {
25495
+ renderInfo(` ${m.name}`);
25496
+ }
25497
+ return;
25498
+ }
25499
+ } else {
25500
+ renderError(`Model not found: "${query}"`);
25501
+ renderInfo("Available models:");
25502
+ for (const m of models.slice(0, 10)) {
25503
+ renderInfo(` ${m.name}`);
25504
+ }
25505
+ return;
25480
25506
  }
25481
- return;
25482
25507
  }
25483
25508
  let finalModel = match.name;
25484
25509
  if (ctx.config.backendType === "ollama") {
@@ -25512,6 +25537,7 @@ async function switchModel(query, ctx, local = false) {
25512
25537
  const caps = await queryModelCapabilities(ctx.config.backendUrl, finalModel);
25513
25538
  ctx.setCapabilities(caps);
25514
25539
  }
25540
+ ctx.refreshModelCache?.();
25515
25541
  } catch (err) {
25516
25542
  renderError(`Failed to switch model: ${err instanceof Error ? err.message : String(err)}`);
25517
25543
  }
@@ -35290,9 +35316,26 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
35290
35316
  ];
35291
35317
  const discoveredSkillNames = discoverSkills(repoRoot).map((s) => `/${s.name}`);
35292
35318
  const allCompletions = [.../* @__PURE__ */ new Set([...BUILTIN_COMMANDS, ...discoveredSkillNames])].sort();
35319
+ let cachedModelNames = [];
35320
+ function refreshModelCache() {
35321
+ fetchModels(config.backendUrl, config.apiKey).then((models) => {
35322
+ cachedModelNames = models.map((m) => m.name);
35323
+ }).catch(() => {
35324
+ });
35325
+ }
35326
+ refreshModelCache();
35293
35327
  function completer(line) {
35294
35328
  if (!line.startsWith("/"))
35295
35329
  return [[], line];
35330
+ const modelMatch = line.match(/^\/model\s+(.*)$/i);
35331
+ if (modelMatch) {
35332
+ const partial = modelMatch[1].toLowerCase();
35333
+ const hits2 = cachedModelNames.filter((n) => n.toLowerCase().startsWith(partial));
35334
+ if (hits2.length === 0 && partial.length > 0) {
35335
+ return [[modelMatch[1]], modelMatch[1]];
35336
+ }
35337
+ return [hits2, modelMatch[1]];
35338
+ }
35296
35339
  const lower = line.toLowerCase();
35297
35340
  const hits = allCompletions.filter((c3) => c3.toLowerCase().startsWith(lower));
35298
35341
  return [hits, line];
@@ -35965,6 +36008,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
35965
36008
  resolvedCaps = caps;
35966
36009
  statusBar.setCapabilities(caps);
35967
36010
  },
36011
+ refreshModelCache,
35968
36012
  hasActiveTask: () => activeTask !== null,
35969
36013
  requestCompaction(strategy) {
35970
36014
  if (!activeTask)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.65.0",
3
+ "version": "0.66.0",
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",