open-agents-ai 0.184.78 → 0.184.80

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 +62 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16303,20 +16303,51 @@ var init_desktop_click = __esm({
16303
16303
  const envModel = process.env["OLLAMA_VISION_MODEL"];
16304
16304
  const ollamaModel = envModel || (this._activeModelHasVision && this._activeModel ? this._activeModel : "moondream");
16305
16305
  const imageBase64 = readFileSync15(screenshotPath).toString("base64");
16306
- const res = await fetch(`${ollamaHost}/api/generate`, {
16306
+ let res = await fetch(`${ollamaHost}/api/generate`, {
16307
16307
  method: "POST",
16308
16308
  headers: { "Content-Type": "application/json" },
16309
- body: JSON.stringify({ model: ollamaModel, prompt: `Point to ${target}`, images: [imageBase64], stream: false }),
16309
+ body: JSON.stringify({ model: ollamaModel, prompt: `Locate the "${target}" in this image and give its x,y position as normalized coordinates.`, images: [imageBase64], stream: false }),
16310
16310
  signal: AbortSignal.timeout(6e4)
16311
16311
  });
16312
+ if (!res.ok && ollamaModel === "moondream") {
16313
+ const errText = await res.text().catch(() => "");
16314
+ if (res.status === 404 || /not found|does not exist/i.test(errText)) {
16315
+ try {
16316
+ const { execSync: es } = await import("node:child_process");
16317
+ es("ollama pull moondream", { timeout: 3e5, stdio: "pipe" });
16318
+ res = await fetch(`${ollamaHost}/api/generate`, {
16319
+ method: "POST",
16320
+ headers: { "Content-Type": "application/json" },
16321
+ body: JSON.stringify({ model: ollamaModel, prompt: `Locate the "${target}" in this image and give its x,y position as normalized coordinates.`, images: [imageBase64], stream: false }),
16322
+ signal: AbortSignal.timeout(6e4)
16323
+ });
16324
+ } catch {
16325
+ }
16326
+ }
16327
+ }
16312
16328
  if (res.ok) {
16313
16329
  const data = await res.json();
16314
16330
  const response = data.response || "";
16315
- const pointMatches = [...response.matchAll(/<point\s+x="([\d.]+)"\s+y="([\d.]+)"\s*\/?>/g)];
16316
- if (pointMatches.length > 0) {
16317
- points = pointMatches.map((m) => ({ x: parseFloat(m[1]), y: parseFloat(m[2]) }));
16331
+ const xmlMatches = [...response.matchAll(/<point\s+x="([\d.]+)"\s+y="([\d.]+)"\s*\/?>/g)];
16332
+ if (xmlMatches.length > 0) {
16333
+ points = xmlMatches.map((m) => ({ x: parseFloat(m[1]), y: parseFloat(m[2]) }));
16318
16334
  visionWorked = true;
16319
16335
  }
16336
+ if (!visionWorked) {
16337
+ const arrayMatch = response.match(/\[\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+)\s*,\s*([\d.]+))?\s*\]/);
16338
+ if (arrayMatch) {
16339
+ const x1 = parseFloat(arrayMatch[1]);
16340
+ const y1 = parseFloat(arrayMatch[2]);
16341
+ if (arrayMatch[3] && arrayMatch[4]) {
16342
+ const x2 = parseFloat(arrayMatch[3]);
16343
+ const y2 = parseFloat(arrayMatch[4]);
16344
+ points = [{ x: (x1 + x2) / 2, y: (y1 + y2) / 2 }];
16345
+ } else {
16346
+ points = [{ x: x1, y: y1 }];
16347
+ }
16348
+ visionWorked = true;
16349
+ }
16350
+ }
16320
16351
  }
16321
16352
  } catch {
16322
16353
  }
@@ -16480,12 +16511,28 @@ ${caption}`);
16480
16511
  const ollamaModel = envModel || (this._activeModelHasVision && this._activeModel ? this._activeModel : "moondream");
16481
16512
  const imageBase64 = imageBuffer.toString("base64");
16482
16513
  const ollamaPrompt = question || "Describe what you see on this desktop screenshot in detail. Include visible applications, windows, text, and UI elements.";
16483
- const res = await fetch(`${ollamaHost}/api/generate`, {
16514
+ let res = await fetch(`${ollamaHost}/api/generate`, {
16484
16515
  method: "POST",
16485
16516
  headers: { "Content-Type": "application/json" },
16486
16517
  body: JSON.stringify({ model: ollamaModel, prompt: ollamaPrompt, images: [imageBase64], stream: false }),
16487
16518
  signal: AbortSignal.timeout(6e4)
16488
16519
  });
16520
+ if (!res.ok && ollamaModel === "moondream") {
16521
+ const errText = await res.text().catch(() => "");
16522
+ if (res.status === 404 || /not found|does not exist/i.test(errText)) {
16523
+ try {
16524
+ const { execSync: es } = await import("node:child_process");
16525
+ es("ollama pull moondream", { timeout: 3e5, stdio: "pipe" });
16526
+ res = await fetch(`${ollamaHost}/api/generate`, {
16527
+ method: "POST",
16528
+ headers: { "Content-Type": "application/json" },
16529
+ body: JSON.stringify({ model: ollamaModel, prompt: ollamaPrompt, images: [imageBase64], stream: false }),
16530
+ signal: AbortSignal.timeout(6e4)
16531
+ });
16532
+ } catch {
16533
+ }
16534
+ }
16535
+ }
16489
16536
  if (res.ok) {
16490
16537
  const data = await res.json();
16491
16538
  if (data.response) {
@@ -51443,16 +51490,20 @@ async function handleUpdate(subcommand, ctx) {
51443
51490
  await new Promise((r) => setTimeout(r, 200));
51444
51491
  const { execPath, argv } = process;
51445
51492
  try {
51446
- const { execFileSync } = await import("node:child_process");
51493
+ const { spawn: spawnChild } = await import("node:child_process");
51447
51494
  if (process.stdout.isTTY) {
51448
51495
  process.stdout.write("\x1B[?1002l\x1B[?1003l\x1B[?1006l\x1B[?25h\x1B[?1049l\x1B[0m");
51449
51496
  }
51450
- process.env.__OA_RESUMED = resumeFlag;
51451
- execFileSync(execPath, argv.slice(1), {
51497
+ const child = spawnChild(execPath, argv.slice(1), {
51452
51498
  stdio: "inherit",
51453
- env: { ...process.env, __OA_RESUMED: resumeFlag }
51499
+ env: { ...process.env, __OA_RESUMED: resumeFlag },
51500
+ detached: false
51454
51501
  });
51455
- process.exit(0);
51502
+ child.on("exit", (code) => {
51503
+ process.exit(code ?? 0);
51504
+ });
51505
+ process.removeAllListeners("SIGINT");
51506
+ process.removeAllListeners("SIGTERM");
51456
51507
  } catch {
51457
51508
  process.stderr.write("\x1B[0m\nRestart oa manually to use the new version.\n");
51458
51509
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.184.78",
3
+ "version": "0.184.80",
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",