Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

sonianuj287
Copy link

Description

Cloudflare Workers example and documentation demonstrating a safe, supported way to use mem0 from edge runtimes (API-client approach), plus a short roadmap for producing a worker/browser-friendly build.
Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

(Reasoning: This PR adds an example and documentation to demonstrate a Worker-compatible integration pattern; it does not change runtime behavior of core SDK code.)

Summary of changes

Added a Cloudflare Worker example and a minimal fetch-based client that avoids Node-only APIs and native bindings:
[mem0-worker-client.ts]— a minimal fetch-based mem0 client suitable for edge runtimes.
[worker.ts] — example Cloudflare Worker routing /create and /query to the mem0 HTTP API.
[README.md]— instructions and quick-start notes for using the example in Cloudflare Workers (Wrangler).
[BUILD_FOR_WORKERS.md] — a concrete proposal with steps to produce a true worker/browser-friendly SDK build (entrypoint, WASM SQLite, bundler guidance, conditional exports, CI test ideas).
Purpose: help users run mem0 in edge environments in a safe, supported way by using the SDK as an HTTP API instead of attempting to run native-dependent parts of the SDK directly in Workers. Also provides a clear roadmap to create a full browser/worker build if desired.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Please delete options that are not relevant.

  • Unit Test
  • Test Script (please provide)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed

…pported way to use mem0 from edge runtimes (API-client approach), plus a short roadmap for producing a worker/browser-friendly build.
@CLAassistant
Copy link

CLAassistant commented Oct 13, 2025

CLA assistant check
All committers have signed the CLA.

@parshvadaftari
Copy link
Contributor

Hey @sonianuj287 thank you putting in the effort. But this PR doesn't address the core issue (OSS SDK compatibility) and solve the problem. This is more like an example we are expecting an extended support built on top of OSS. It provides a workaround (Platform API) instead of fixing the core issue for the OSS.

@sonianuj287
Copy link
Author

Hi @parshvadaftari , I understand - actual SDK compatibility for Workers rather than just an API client example. Let me implement the core OSS compatibility changes, then create the necessary files for a true Worker-compatible build.

`// 1. Add WASM SQLite (in src/storage/wasm-sqlite.ts)
import initSqlJs from 'sql.js';
// Implements BaseStorage with WASM SQLite instead of native bindings

// 2. Create Worker Entry (in src/worker-entry.ts)
export { Memory, MemoryConfig } from './memory';
export { WasmSQLiteStorage as default } from './storage/wasm-sqlite';
// Only export Worker-safe components

// 3. Update package.json
{
"exports": {
"./worker": {
"types": "./dist/worker/index.d.ts",
"import": "./dist/worker/index.mjs"
}
},
"dependencies": {
"sql.js": "^1.8.0" // WASM SQLite
}
}

// 4. Add tsup.config.ts changes
export default defineConfig({
entry: {
worker: 'src/worker-entry.ts'
},
format: ['esm'],
target: 'es2020',
platform: 'browser'
})`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.