@futuvara/connect 0.3.3 → 0.3.4
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.
- package/bin/connect.js +12 -1
- package/package.json +1 -1
package/bin/connect.js
CHANGED
|
@@ -10,7 +10,7 @@ import { join, dirname } from "node:path";
|
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
11
|
|
|
12
12
|
export const SERVER_NAME = "futuvara";
|
|
13
|
-
const DEFAULT_URL = "https://
|
|
13
|
+
const DEFAULT_URL = "https://app.futuvara.com";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* The environment variable holding one project's key: FUTUVARA_KEY_ + the project name upper-cased, every
|
|
@@ -145,6 +145,17 @@ export async function callTool(mcpUrl, key, name, args = {}, fetchImpl = fetch)
|
|
|
145
145
|
if (!res.ok) throw new Error(`Futuvara MCP server answered ${res.status} ${res.statusText} at ${mcpUrl}`);
|
|
146
146
|
const msg = readRpcResponse(res.headers.get("content-type"), await res.text(), id);
|
|
147
147
|
if (msg.error) throw new Error(`Futuvara MCP server error: ${msg.error.message}`);
|
|
148
|
+
// An image (get_image) has no text to print: save it and answer with where it is, so the agent can open it.
|
|
149
|
+
const images = (msg.result?.content ?? []).filter((c) => c.type === "image" && c.data);
|
|
150
|
+
if (images.length && !msg.result?.isError) {
|
|
151
|
+
const dir = join(tmpdir(), "futuvara-images");
|
|
152
|
+
mkdirSync(dir, { recursive: true });
|
|
153
|
+
return images.map((c, i) => {
|
|
154
|
+
const file = join(dir, `${name}-${Date.now()}-${i}.${(c.mimeType ?? "image/png").split("/")[1].replace("jpeg", "jpg")}`);
|
|
155
|
+
writeFileSync(file, Buffer.from(c.data, "base64"));
|
|
156
|
+
return { image: file, mimeType: c.mimeType };
|
|
157
|
+
});
|
|
158
|
+
}
|
|
148
159
|
const text = msg.result?.content?.[0]?.text ?? "";
|
|
149
160
|
if (msg.result?.isError) throw new Error(`Futuvara ${name}: ${text}`);
|
|
150
161
|
try {
|
package/package.json
CHANGED