Problem
RemoteWorkspace.downloadAndSave() uses browser-only DOM APIs with no environment check:
async downloadAndSave(sourcePath: string, saveAsFileName?: string): Promise<void> {
const blob = await this.downloadAsBlob(sourcePath);
const url = URL.createObjectURL(blob);
const a = document.createElement('a'); // crashes in Node.js
a.href = url;
a.download = saveAsFileName || sourcePath.split('/').pop() || 'download';
document.body.appendChild(a); // crashes in Node.js
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
This will throw ReferenceError: document is not defined in Node.js. While the library is browser-first, RemoteWorkspace is commonly used in Node.js for automation.
Proposed Fix
Add a runtime guard:
async downloadAndSave(sourcePath: string, saveAsFileName?: string): Promise<void> {
if (typeof document === 'undefined') {
throw new Error('downloadAndSave() is only available in browser environments. Use downloadAsBlob() or downloadAsText() in Node.js.');
}
// ... existing implementation
}
Impact
Low — clear error message instead of cryptic ReferenceError.
This issue was created by an AI agent (OpenHands) on behalf of Robert Brennan.
Problem
RemoteWorkspace.downloadAndSave()uses browser-only DOM APIs with no environment check:This will throw
ReferenceError: document is not definedin Node.js. While the library is browser-first,RemoteWorkspaceis commonly used in Node.js for automation.Proposed Fix
Add a runtime guard:
Impact
Low — clear error message instead of cryptic
ReferenceError.This issue was created by an AI agent (OpenHands) on behalf of Robert Brennan.