open-agents-ai 0.23.0 → 0.23.1

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 +86 -36
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6961,20 +6961,45 @@ var init_desktop_click = __esm({
6961
6961
  durationMs: performance.now() - start
6962
6962
  };
6963
6963
  }
6964
- const { vl } = await import("moondream");
6965
- const apiKey = process.env["MOONDREAM_API_KEY"];
6966
- const endpoint = process.env["MOONDREAM_ENDPOINT"];
6967
- let client;
6968
- if (apiKey) {
6969
- client = new vl({ apiKey });
6970
- } else if (endpoint) {
6971
- client = new vl({ endpoint });
6972
- } else {
6973
- client = new vl({ endpoint: "http://localhost:2020/v1" });
6964
+ let points = [];
6965
+ let visionWorked = false;
6966
+ try {
6967
+ const { vl } = await import("moondream");
6968
+ const apiKey = process.env["MOONDREAM_API_KEY"];
6969
+ const endpoint = process.env["MOONDREAM_ENDPOINT"];
6970
+ let client;
6971
+ if (apiKey) {
6972
+ client = new vl({ apiKey });
6973
+ } else if (endpoint) {
6974
+ client = new vl({ endpoint });
6975
+ } else {
6976
+ client = new vl({ endpoint: "http://localhost:2020/v1" });
6977
+ }
6978
+ const imageBuffer = readFileSync11(screenshotPath);
6979
+ const pointResult = await client.point({ image: imageBuffer, object: target });
6980
+ points = pointResult.points ?? [];
6981
+ visionWorked = true;
6982
+ } catch {
6983
+ }
6984
+ if (!visionWorked) {
6985
+ const hints = [
6986
+ `(Moondream vision not available \u2014 cannot locate "${target}" on screen)`,
6987
+ `Screenshot saved: ${screenshotPath}`,
6988
+ `Screen: ${dims.width}x${dims.height}`,
6989
+ "",
6990
+ "Use shell commands to interact with the desktop instead:",
6991
+ " xdotool search --name 'pattern' \u2014 find windows by title",
6992
+ " xdotool key 'ctrl+s' \u2014 send keyboard shortcuts",
6993
+ " xdotool mousemove X Y click 1 \u2014 click at known coordinates",
6994
+ " wmctrl -a 'window title' \u2014 activate a window by name",
6995
+ " xdg-open <url> \u2014 open a URL in the default browser"
6996
+ ];
6997
+ return {
6998
+ success: true,
6999
+ output: hints.join("\n"),
7000
+ durationMs: performance.now() - start
7001
+ };
6974
7002
  }
6975
- const imageBuffer = readFileSync11(screenshotPath);
6976
- const pointResult = await client.point({ image: imageBuffer, object: target });
6977
- const points = pointResult.points ?? [];
6978
7003
  if (points.length === 0) {
6979
7004
  return {
6980
7005
  success: false,
@@ -7066,37 +7091,62 @@ Screenshot: ${screenshotPath}`,
7066
7091
  captureScreenshot(screenshotPath);
7067
7092
  const dims = getImageDimensions2(screenshotPath);
7068
7093
  const imageBuffer = readFileSync11(screenshotPath);
7069
- const { vl } = await import("moondream");
7070
- const apiKey = process.env["MOONDREAM_API_KEY"];
7071
- const endpoint = process.env["MOONDREAM_ENDPOINT"];
7072
- let client;
7073
- if (apiKey) {
7074
- client = new vl({ apiKey });
7075
- } else if (endpoint) {
7076
- client = new vl({ endpoint });
7077
- } else {
7078
- client = new vl({ endpoint: "http://localhost:2020/v1" });
7079
- }
7080
7094
  const parts = [];
7081
- if (question) {
7082
- const result = await client.query({ image: imageBuffer, question });
7083
- const answer = typeof result.answer === "string" ? result.answer : "(streaming not supported)";
7084
- parts.push(`Q: ${question}`);
7085
- parts.push(`A: ${answer}`);
7086
- } else {
7087
- const result = await client.caption({ image: imageBuffer, length });
7088
- const caption = typeof result.caption === "string" ? result.caption : "(streaming not supported)";
7089
- parts.push(`Desktop description:
7095
+ let visionWorked = false;
7096
+ try {
7097
+ const { vl } = await import("moondream");
7098
+ const apiKey = process.env["MOONDREAM_API_KEY"];
7099
+ const endpoint = process.env["MOONDREAM_ENDPOINT"];
7100
+ let client;
7101
+ if (apiKey) {
7102
+ client = new vl({ apiKey });
7103
+ } else if (endpoint) {
7104
+ client = new vl({ endpoint });
7105
+ } else {
7106
+ client = new vl({ endpoint: "http://localhost:2020/v1" });
7107
+ }
7108
+ if (question) {
7109
+ const result = await client.query({ image: imageBuffer, question });
7110
+ const answer = typeof result.answer === "string" ? result.answer : "(streaming not supported)";
7111
+ parts.push(`Q: ${question}`);
7112
+ parts.push(`A: ${answer}`);
7113
+ } else {
7114
+ const result = await client.caption({ image: imageBuffer, length });
7115
+ const caption = typeof result.caption === "string" ? result.caption : "(streaming not supported)";
7116
+ parts.push(`Desktop description:
7090
7117
  ${caption}`);
7118
+ }
7119
+ visionWorked = true;
7120
+ } catch {
7121
+ }
7122
+ if (!visionWorked) {
7123
+ let ocrText = "";
7124
+ try {
7125
+ ocrText = execSync11(`tesseract ${JSON.stringify(screenshotPath)} stdout 2>/dev/null`, {
7126
+ encoding: "utf8",
7127
+ timeout: 15e3
7128
+ }).trim();
7129
+ } catch {
7130
+ }
7131
+ if (ocrText) {
7132
+ parts.push("(Moondream vision not available \u2014 using OCR text extraction)");
7133
+ parts.push(`
7134
+ Visible text on screen:
7135
+ ${ocrText}`);
7136
+ } else {
7137
+ parts.push("(Moondream vision not available, OCR failed)");
7138
+ parts.push("Screenshot captured but cannot describe contents.");
7139
+ parts.push("Use shell commands to check window state instead:");
7140
+ parts.push(" xdotool getactivewindow getwindowname \u2014 get active window title");
7141
+ parts.push(" wmctrl -l \u2014 list all open windows");
7142
+ parts.push(" xdg-open <url> \u2014 open a URL in the default browser");
7143
+ }
7091
7144
  }
7092
7145
  if (dims) {
7093
7146
  parts.push(`
7094
7147
  Screen: ${dims.width}x${dims.height}`);
7095
7148
  }
7096
7149
  parts.push(`Screenshot: ${screenshotPath}`);
7097
- const base64 = imageBuffer.toString("base64");
7098
- parts.push(`
7099
- [IMAGE_BASE64:image/png:${base64}]`);
7100
7150
  return {
7101
7151
  success: true,
7102
7152
  output: parts.join("\n"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
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",