@brightsideoy/kama 0.1.0-alpha.139 → 0.1.0-alpha.140

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/cli.js CHANGED
@@ -292,17 +292,20 @@ import customSchemas from './workspace-schemas.js';
292
292
 
293
293
  export default {
294
294
  async fetch(request, env, ctx) {
295
- const engineEnv = {
296
- ...env,
297
- BUNDLED_DEFINITIONS: customSchemas
298
- };
295
+ // 🎯 FIX: Mutate the Cloudflare env directly instead of spreading it!
296
+ // Spreading {...env} breaks Cloudflare D1/R2 proxy bindings.
297
+ env.BUNDLED_DEFINITIONS = customSchemas;
299
298
 
300
- if (typeof kamaWorker === 'function') {
301
- return kamaWorker(request, engineEnv, ctx);
302
- }
299
+ // Execute the Hono app fetch handler
303
300
  if (kamaWorker && typeof kamaWorker.fetch === 'function') {
304
- return kamaWorker.fetch(request, engineEnv, ctx);
301
+ return kamaWorker.fetch(request, env, ctx);
302
+ }
303
+
304
+ // Fallback just in case the export structure changes
305
+ if (kamaWorker && kamaWorker.app && typeof kamaWorker.app.fetch === 'function') {
306
+ return kamaWorker.app.fetch(request, env, ctx);
305
307
  }
308
+
306
309
  return new Response('Kama Engine Worker Ready', { status: 200 });
307
310
  }
308
311
  };