open-agents-ai 0.186.67 → 0.186.69

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 +223 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -261557,6 +261557,40 @@ var init_nexusBackend = __esm({
261557
261557
  this.lastSystemMetrics = responseData.system;
261558
261558
  this.lastSystemMetricsTs = Date.now();
261559
261559
  }
261560
+ const fallbackChoices = responseData?.choices;
261561
+ if (fallbackChoices && Array.isArray(fallbackChoices)) {
261562
+ const fbMsg = fallbackChoices[0]?.message || {};
261563
+ const fbToolCalls = fbMsg.tool_calls || [];
261564
+ const fbContent = typeof fbMsg.content === "string" ? fbMsg.content : null;
261565
+ if (fbContent) {
261566
+ const words = fbContent.split(/(\s+)/);
261567
+ for (const word2 of words) {
261568
+ if (word2)
261569
+ yield { type: "content", content: word2 };
261570
+ }
261571
+ }
261572
+ if (fbToolCalls.length > 0) {
261573
+ for (const tc of fbToolCalls) {
261574
+ const fn = tc.function || {};
261575
+ let args;
261576
+ try {
261577
+ args = typeof fn.arguments === "string" ? JSON.parse(fn.arguments) : fn.arguments ?? {};
261578
+ } catch {
261579
+ args = { _raw: fn.arguments };
261580
+ }
261581
+ yield {
261582
+ type: "tool_call_delta",
261583
+ toolCallId: tc.id || `call_${randomBytes14(8).toString("hex")}`,
261584
+ toolCallName: fn.name,
261585
+ toolCallArgs: JSON.stringify(args)
261586
+ };
261587
+ }
261588
+ yield { type: "finish", finishReason: "tool_calls" };
261589
+ } else {
261590
+ yield { type: "finish", finishReason: "stop" };
261591
+ }
261592
+ return;
261593
+ }
261560
261594
  const content = responseData ? responseData.response || "" : "";
261561
261595
  if (content) {
261562
261596
  const words = content.split(/(\s+)/);
@@ -261642,7 +261676,7 @@ var init_nexusBackend = __esm({
261642
261676
  yield {
261643
261677
  type: "tool_call_delta",
261644
261678
  toolCallIndex: i2,
261645
- toolCallId: tc.id || crypto.randomUUID(),
261679
+ toolCallId: tc.id || `call_${randomBytes14(8).toString("hex")}`,
261646
261680
  toolCallName: fn.name,
261647
261681
  toolCallArgs: JSON.stringify(args)
261648
261682
  };
@@ -274654,6 +274688,39 @@ var init_personaplex = __esm({
274654
274688
  });
274655
274689
 
274656
274690
  // packages/cli/dist/tui/setup.js
274691
+ var setup_exports = {};
274692
+ __export(setup_exports, {
274693
+ calculateContextWindow: () => calculateContextWindow,
274694
+ checkExpandedVariant: () => checkExpandedVariant,
274695
+ checkOllamaUpdate: () => checkOllamaUpdate,
274696
+ checkPythonVenv: () => checkPythonVenv,
274697
+ checkToolSupport: () => checkToolSupport,
274698
+ computeInferenceScore: () => computeInferenceScore,
274699
+ createExpandedVariant: () => createExpandedVariant,
274700
+ createExpandedVariantAsync: () => createExpandedVariantAsync,
274701
+ detectSystemSpecs: () => detectSystemSpecs,
274702
+ detectSystemSpecsAsync: () => detectSystemSpecsAsync,
274703
+ ensureCloudflaredBackground: () => ensureCloudflaredBackground,
274704
+ ensureExpandedContext: () => ensureExpandedContext,
274705
+ ensureNeovim: () => ensureNeovim,
274706
+ ensureOllamaRunning: () => ensureOllamaRunning,
274707
+ ensurePython3: () => ensurePython3,
274708
+ ensurePythonVenv: () => ensurePythonVenv,
274709
+ ensureVisionDeps: () => ensureVisionDeps,
274710
+ expandedModelName: () => expandedModelName,
274711
+ getLatestOllamaVersion: () => getLatestOllamaVersion,
274712
+ getOllamaVersion: () => getOllamaVersion,
274713
+ hasCmd: () => hasCmd,
274714
+ isCloudflaredReady: () => isCloudflaredReady,
274715
+ isFirstRun: () => isFirstRun,
274716
+ isModelAvailable: () => isModelAvailable,
274717
+ needsTextToolMode: () => needsTextToolMode,
274718
+ pullModelWithAutoUpdate: () => pullModelWithAutoUpdate,
274719
+ recommendModel: () => recommendModel,
274720
+ renderScoreBar: () => renderScoreBar,
274721
+ runSetupWizard: () => runSetupWizard,
274722
+ updateOllama: () => updateOllama
274723
+ });
274657
274724
  import * as readline from "node:readline";
274658
274725
  import { execSync as execSync29, spawn as spawn20, exec as exec2 } from "node:child_process";
274659
274726
  import { promisify as promisify7 } from "node:util";
@@ -274684,6 +274751,10 @@ async function checkToolSupport(modelName, backendUrl = "http://localhost:11434"
274684
274751
  return true;
274685
274752
  }
274686
274753
  }
274754
+ async function needsTextToolMode(modelName, backendUrl) {
274755
+ const hasTools = await checkToolSupport(modelName, backendUrl);
274756
+ return !hasTools;
274757
+ }
274687
274758
  function detectSystemSpecs() {
274688
274759
  let totalRamGB = 0;
274689
274760
  let availableRamGB = 0;
@@ -275097,6 +275168,68 @@ async function ensureOllamaRunning(backendUrl, rl) {
275097
275168
  `);
275098
275169
  return false;
275099
275170
  }
275171
+ function getOllamaVersion() {
275172
+ try {
275173
+ const out = execSync29("ollama --version", { encoding: "utf8", timeout: 5e3 });
275174
+ const match = out.match(/(\d+\.\d+\.\d+)/);
275175
+ return match ? match[1] : null;
275176
+ } catch {
275177
+ return null;
275178
+ }
275179
+ }
275180
+ async function getLatestOllamaVersion() {
275181
+ try {
275182
+ const resp = await fetch("https://api.github.com/repos/ollama/ollama/releases/latest", {
275183
+ signal: AbortSignal.timeout(5e3),
275184
+ headers: { "User-Agent": "open-agents" }
275185
+ });
275186
+ if (!resp.ok)
275187
+ return null;
275188
+ const data = await resp.json();
275189
+ const tag = data.tag_name || "";
275190
+ return tag.replace(/^v/, "") || null;
275191
+ } catch {
275192
+ return null;
275193
+ }
275194
+ }
275195
+ function compareSemver(a2, b) {
275196
+ const pa = a2.split(".").map(Number);
275197
+ const pb = b.split(".").map(Number);
275198
+ for (let i2 = 0; i2 < 3; i2++) {
275199
+ if ((pa[i2] ?? 0) < (pb[i2] ?? 0))
275200
+ return -1;
275201
+ if ((pa[i2] ?? 0) > (pb[i2] ?? 0))
275202
+ return 1;
275203
+ }
275204
+ return 0;
275205
+ }
275206
+ async function checkOllamaUpdate() {
275207
+ const current = getOllamaVersion();
275208
+ if (!current)
275209
+ return null;
275210
+ const latest = await getLatestOllamaVersion();
275211
+ if (!latest)
275212
+ return null;
275213
+ return {
275214
+ needsUpdate: compareSemver(current, latest) < 0,
275215
+ current,
275216
+ latest
275217
+ };
275218
+ }
275219
+ function updateOllama() {
275220
+ if (process.platform !== "linux" && process.platform !== "darwin") {
275221
+ return false;
275222
+ }
275223
+ try {
275224
+ execSync29("curl -fsSL https://ollama.com/install.sh | sh", {
275225
+ stdio: "inherit",
275226
+ timeout: 3e5
275227
+ });
275228
+ return true;
275229
+ } catch {
275230
+ return false;
275231
+ }
275232
+ }
275100
275233
  function pullModelWithAutoUpdate(tag) {
275101
275234
  try {
275102
275235
  execSync29(`ollama pull ${tag}`, {
@@ -276211,6 +276344,13 @@ function ensureCloudflaredBackground(onInfo) {
276211
276344
  return false;
276212
276345
  })();
276213
276346
  }
276347
+ async function isCloudflaredReady() {
276348
+ if (hasCmd("cloudflared"))
276349
+ return true;
276350
+ if (_cloudflaredInstallPromise)
276351
+ return _cloudflaredInstallPromise;
276352
+ return false;
276353
+ }
276214
276354
  function expandedModelName(baseModel) {
276215
276355
  return `open-agents-${baseModel.replace(":", "-").replace(/\./g, "")}`;
276216
276356
  }
@@ -276264,6 +276404,31 @@ async function queryModelKVInfo(backendUrl, modelName) {
276264
276404
  return null;
276265
276405
  }
276266
276406
  }
276407
+ function createExpandedVariant(baseModel, specs, sizeGB, kvBytesPerToken, archMax) {
276408
+ const customName = expandedModelName(baseModel);
276409
+ const ctx3 = calculateContextWindow(specs, sizeGB, kvBytesPerToken, archMax);
276410
+ try {
276411
+ const numPredict = Math.min(16384, Math.max(2048, Math.floor(ctx3.numCtx * 0.25)));
276412
+ const modelfileContent = [
276413
+ `FROM ${baseModel}`,
276414
+ `PARAMETER num_ctx ${ctx3.numCtx}`,
276415
+ `PARAMETER temperature 0`,
276416
+ `PARAMETER num_predict ${numPredict}`,
276417
+ `PARAMETER stop "<|endoftext|>"`
276418
+ ].join("\n");
276419
+ const modelDir2 = join57(homedir15(), ".open-agents", "models");
276420
+ mkdirSync17(modelDir2, { recursive: true });
276421
+ const modelfilePath = join57(modelDir2, `Modelfile.${customName}`);
276422
+ writeFileSync18(modelfilePath, modelfileContent + "\n", "utf8");
276423
+ execSync29(`ollama create ${customName} -f ${modelfilePath}`, {
276424
+ stdio: "pipe",
276425
+ timeout: 12e4
276426
+ });
276427
+ return customName;
276428
+ } catch {
276429
+ return null;
276430
+ }
276431
+ }
276267
276432
  async function createExpandedVariantAsync(baseModel, specs, sizeGB, kvBytesPerToken, archMax) {
276268
276433
  const customName = expandedModelName(baseModel);
276269
276434
  const ctx3 = calculateContextWindow(specs, sizeGB, kvBytesPerToken, archMax);
@@ -286016,6 +286181,17 @@ async function handleUpdate(subcommand, ctx3) {
286016
286181
  ]);
286017
286182
  const needsSudo = sudoInfo;
286018
286183
  renderInfo(`v${currentVersion} \u2014 ${info ? `update available \u2192 v${info.latestVersion}` : "up to date"}`);
286184
+ let ollamaUpdate = null;
286185
+ try {
286186
+ const { checkOllamaUpdate: checkOllamaUpdate2 } = await Promise.resolve().then(() => (init_setup(), setup_exports));
286187
+ ollamaUpdate = await checkOllamaUpdate2();
286188
+ if (ollamaUpdate?.needsUpdate) {
286189
+ renderInfo(`Ollama ${ollamaUpdate.current} \u2192 ${ollamaUpdate.latest} update available`);
286190
+ } else if (ollamaUpdate) {
286191
+ renderInfo(`Ollama ${ollamaUpdate.current} \u2014 up to date`);
286192
+ }
286193
+ } catch {
286194
+ }
286019
286195
  const items = [];
286020
286196
  const skipKeys = [];
286021
286197
  items.push({ key: "hdr_status", label: selectColors.dim(`\u2500\u2500\u2500 v${currentVersion} \u2500\u2500\u2500`), kind: "header" });
@@ -286079,6 +286255,16 @@ async function handleUpdate(subcommand, ctx3) {
286079
286255
  }
286080
286256
  } catch {
286081
286257
  }
286258
+ if (ollamaUpdate?.needsUpdate) {
286259
+ items.push({ key: "hdr_ollama", label: selectColors.dim("\u2500\u2500\u2500 Ollama \u2500\u2500\u2500"), kind: "header" });
286260
+ skipKeys.push("hdr_ollama");
286261
+ items.push({
286262
+ key: "ollama_update",
286263
+ label: `Update Ollama ${ollamaUpdate.current} \u2192 ${ollamaUpdate.latest}`,
286264
+ detail: "Run official install script to update Ollama backend",
286265
+ kind: "action"
286266
+ });
286267
+ }
286082
286268
  items.push({ key: "hdr_policy", label: selectColors.dim("\u2500\u2500\u2500 Policy \u2500\u2500\u2500"), kind: "header" });
286083
286269
  skipKeys.push("hdr_policy");
286084
286270
  items.push({ key: "policy_auto", label: "Auto-update mode", detail: "Install updates automatically after tasks", kind: "action" });
@@ -286124,11 +286310,31 @@ async function handleUpdate(subcommand, ctx3) {
286124
286310
  }
286125
286311
  return;
286126
286312
  }
286313
+ if (menuResult.key === "ollama_update") {
286314
+ renderInfo("Updating Ollama...");
286315
+ try {
286316
+ const { updateOllama: updateOllama2 } = await Promise.resolve().then(() => (init_setup(), setup_exports));
286317
+ if (updateOllama2()) {
286318
+ renderInfo(`Ollama updated successfully!`);
286319
+ try {
286320
+ const { execSync: es } = await import("node:child_process");
286321
+ es("sudo systemctl restart ollama 2>/dev/null || true", { timeout: 1e4, stdio: "pipe" });
286322
+ } catch {
286323
+ }
286324
+ } else {
286325
+ renderInfo("Ollama update failed. Try: curl -fsSL https://ollama.com/install.sh | sh");
286326
+ }
286327
+ } catch (e2) {
286328
+ renderInfo(`Ollama update error: ${e2 instanceof Error ? e2.message : String(e2)}`);
286329
+ }
286330
+ return;
286331
+ }
286127
286332
  const doPackage = menuResult.key === "quick" || menuResult.key === "full";
286128
286333
  const doDeps = menuResult.key === "deps_only" || menuResult.key === "full";
286129
286334
  const doRebuild = menuResult.key === "rebuild" || menuResult.key === "full";
286130
286335
  const doPython = menuResult.key === "python" || menuResult.key === "full";
286131
286336
  const doCloudflared = menuResult.key === "full";
286337
+ const doOllama = menuResult.key === "full" && ollamaUpdate?.needsUpdate;
286132
286338
  const targetVersion = info?.latestVersion ?? currentVersion;
286133
286339
  const installOverlay = startInstallOverlay(targetVersion);
286134
286340
  let installError = "";
@@ -286274,7 +286480,22 @@ async function handleUpdate(subcommand, ctx3) {
286274
286480
  }
286275
286481
  installOverlay.setStatus(depsUpdated ? "Dependencies updated" : "Dependencies OK");
286276
286482
  }
286277
- if (!primaryUpdated && !depsUpdated && !doRebuild && !doPython && !doCloudflared) {
286483
+ if (doOllama) {
286484
+ installOverlay.setStatus("Updating Ollama...");
286485
+ try {
286486
+ const { updateOllama: doOllamaUpgrade } = await Promise.resolve().then(() => (init_setup(), setup_exports));
286487
+ if (doOllamaUpgrade()) {
286488
+ installOverlay.setStatus(`Ollama updated to ${ollamaUpdate.latest}`);
286489
+ try {
286490
+ const { execSync: es22 } = await import("node:child_process");
286491
+ es22("sudo systemctl restart ollama 2>/dev/null || true", { timeout: 1e4, stdio: "pipe" });
286492
+ } catch {
286493
+ }
286494
+ }
286495
+ } catch {
286496
+ }
286497
+ }
286498
+ if (!primaryUpdated && !depsUpdated && !doRebuild && !doPython && !doCloudflared && !doOllama) {
286278
286499
  installOverlay.stop("No changes needed");
286279
286500
  await new Promise((r2) => setTimeout(r2, 2e3));
286280
286501
  installOverlay.dismiss();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.186.67",
3
+ "version": "0.186.69",
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",