@composio/core
Version:

36 lines (34 loc) • 1.28 kB
JavaScript
//#region src/platform/workerd.ts
/**
* Cloudflare Workers / Edge runtime platform implementation.
* Provides stub implementations for file system operations that are unavailable in edge runtimes.
* All file system operations gracefully return null/empty values or throw descriptive errors.
*/
const platform = {
supportsFileSystem: false,
homedir() {
return null;
},
joinPath(...paths) {
return paths.map((segment, index) => {
if (index === 0) return segment.replace(/\/+$/, "");
return segment.replace(/^\/+|\/+$/g, "");
}).filter(Boolean).join("/");
},
basename(filePath) {
const segments = filePath.replace(/\/+$/, "").split("/");
return segments[segments.length - 1] || "";
},
existsSync(_filePath) {
return false;
},
mkdirSync(_dirPath) {},
readFileSync(_filePath, _encoding) {
throw new Error("File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). Use environment variables or external storage services instead.");
},
writeFileSync(_filePath, _content, _encoding) {
throw new Error("File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). Use environment variables or external storage services instead.");
}
};
//#endregion
exports.platform = platform;