pub(super) const PLUGIN_SDK_MODULE: &str = "@theway-ai/plugin-sdk";
pub(super) fn generated_theway_module() -> String {
r#"
export function defineExtension(setup) {
if (typeof setup !== "function") {
throw new TypeError("defineExtension requires a setup function");
}
return Object.freeze({ setup });
}
export function register(setup, options) {
if (typeof setup !== "function") {
throw new TypeError("register requires a setup function");
}
if (options !== undefined && (options === null || typeof options !== "object")) {
throw new TypeError("register options must be an object");
}
globalThis.__thewayRegisteredExtension = Object.freeze({
setup,
inject: Array.isArray(options?.inject) ? options.inject : [],
});
return globalThis.__thewayRegisteredExtension;
}
"#
.to_string()
}
pub(super) const FORBIDDEN_DIRECT_GLOBALS: &[&str] = &[
"process",
"Deno",
"Bun",
"require",
"fetch",
"XMLHttpRequest",
"WebSocket",
"thewayFilesystem",
"thewayNetwork",
"thewayEnvironment",
"thewaySecrets",
"thewayProvider",
"thewayPersistence",
];