@0xmaxma/claude-gateway 1.2.15 → 1.2.16
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/mcp/tools/browser/module.ts +18 -3
- package/package.json +1 -1
|
@@ -51,10 +51,25 @@ export class BrowserModule implements ToolModule {
|
|
|
51
51
|
let filePath: string;
|
|
52
52
|
if (mediaDir) {
|
|
53
53
|
fs.mkdirSync(mediaDir, { recursive: true });
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
filePath
|
|
54
|
+
const filename = `browser_shot_${sid}_${Date.now()}.${ext}`;
|
|
55
|
+
filePath = path.join(mediaDir, filename);
|
|
56
|
+
fs.writeFileSync(filePath, Buffer.from(b64, 'base64'));
|
|
57
|
+
const apiUrl = process.env.GATEWAY_API_URL;
|
|
58
|
+
const agentId = process.env.GATEWAY_AGENT_ID;
|
|
59
|
+
if (apiUrl && agentId) {
|
|
60
|
+
// mediaDir is <agentBase>/media/<subdir>; parent is the agent's media root
|
|
61
|
+
const agentMediaRoot = path.dirname(mediaDir);
|
|
62
|
+
const relPath = path.relative(agentMediaRoot, filePath)
|
|
63
|
+
.split(path.sep)
|
|
64
|
+
.map(encodeURIComponent)
|
|
65
|
+
.join('/');
|
|
66
|
+
return {
|
|
67
|
+
content: [{ type: 'text', text: `${apiUrl}/v1/agents/${encodeURIComponent(agentId)}/media/${relPath}` }],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return { content: [{ type: 'text', text: filePath }] };
|
|
57
71
|
}
|
|
72
|
+
filePath = path.join('/tmp', `browser_shot_${sid}.${ext}`);
|
|
58
73
|
fs.writeFileSync(filePath, Buffer.from(b64, 'base64'));
|
|
59
74
|
return { content: [{ type: 'text', text: filePath }] };
|
|
60
75
|
}
|