open-glean README

The project's README from github.com/hydra-db/open-glean. As one markdown file: README.md.

Open Glean, your second brain on Hydra DB

Open Glean is the AI workspace over Hydra DB. Ask a question across your memories, files, and connected apps. Open Glean retrieves the context, writes the answer, and cites its sources.

This is the open-source code for Open Glean. The Next.js server proxies requests to the official @hydradb/sdk. Keys are held in an encrypted, httpOnly session cookie and used server-side, never in the browser. You can also run it yourself with your own Hydra DB key.

Open Glean

Features

Getting started

npm ci
npm run dev

Copy .env.example to .env.local and set at least OPEN_GLEAN_SESSION_SECRET. Everything else is optional. Without a Hydra key, the app shows a connect screen and asks for one.

Open http://localhost:3000, then:

  1. Connect: paste your Hydra DB API key (create one at app.hydradb.com/keys) and pick a database.
  2. Add a model: in Settings, paste an OpenRouter (or other OpenAI-compatible) key and pick a model. It only writes answers; search works without it.
  3. Ask away, or add context first from the Context page (files, notes, URLs).

Running with Docker

docker build -t open-glean .
docker run -p 3000:3000 \
  -e OPEN_GLEAN_SESSION_SECRET=your-random-16-char-secret \
  -e HYDRA_API_KEY=your-hydra-key \
  -e OPENROUTER_API_KEY=your-openrouter-key \
  -e OPEN_GLEAN_LLM_MODEL=google/gemini-3.7-flash \
  -e MONGODB_URI=mongodb://your-mongo-host:27017 \
  open-glean

The image uses Next.js standalone output, so it ships only the runtime files and the dependencies the build uses. It runs as a non-root user.

How it works

Browser ──► Next.js proxy (/api/hydra/*) ──► @hydradb/sdk ──► api.hydradb.com
        └─► /api/llm/chat (streaming + web plugin) ─► your LLM provider

Environment & key security

API keys are not stored in the browser. When you connect in Settings, the key is verified server-side and stored in an AES-256-GCM-encrypted, httpOnly session cookie; every proxied request resolves it on the server. Nothing key-shaped is inlined into the JS bundle, localStorage, or any client state.

A stored key is also pinned to the endpoint it was stored with. A request may only choose the LLM base URL when it supplies its own API key. Otherwise a caller could pair an attacker-controlled URL with the server's key and have it sent there in an Authorization header.

Variable Purpose
OPEN_GLEAN_SESSION_SECRET Required in production. Any random 16+ char string. Encrypts the key session cookie.
HYDRA_API_KEY Optional deployment-level shared key: when set, no user key is needed at all
HYDRA_BASE_URL Optional default backend URL (defaults to https://api.hydradb.com)
HYDRA_DEFAULT_DATABASE Optional default tenant. Requests with no explicit database scope to this one.
MONGODB_URI Chat persistence. A MongoDB connection string, or a bare DocumentDB cluster endpoint (auto-detected via .docdb.*.amazonaws.com).
MONGODB_DB Database name for chats (defaults to open_glean).
OPENROUTER_API_KEY Optional server-level LLM key. When set, users need not enter their own.
OPEN_GLEAN_LLM_MODEL Default answer model id, e.g. openai/gpt-4o-mini. No built-in default. Without it (or a per-user model), answers are unavailable.
OPEN_GLEAN_LLM_BASE_URL Optional OpenAI-compatible endpoint for the server-level key (defaults to OpenRouter)
OPEN_GLEAN_ALLOW_PRIVATE_LLM_URL Allow an LLM base URL on a private or loopback address, for a local model such as Ollama or LM Studio. Off by default. It permits plaintext http: on a private address only. A public host still requires https:, and non-http schemes are rejected.
MONGODB_PROXY_KEY Shared secret for the Lambda proxy. The Lambda reads the same value as PROXY_KEY; the two names must match.
OPEN_GLEAN_MAX_CONCURRENT_RESEARCH Concurrent Deep Research runs per instance (default 3). Each run costs many LLM and retrieval calls

DocumentDB does not support IAM database authentication. The IAM token path in the code cannot authenticate against Amazon DocumentDB. AWS_REGION, AWS_IAM_USER_ARN and AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY are read by that path and are listed here only to describe what it expects. For DocumentDB, use a standard MongoDB connection string or the Lambda proxy.

Stack

Next.js 16, React 19, Tailwind CSS v4, and @hydradb/sdk. No other runtime dependency for data or AI.

License

Apache-2.0. See LICENSE and NOTICE.

Read NOTICE: connector logos are third-party trademarks and are not covered by the Apache grant.

open-glean (hydra-db/open-glean)

Searching Database…

这是什么?Open Glean 是一个基于 Hydra DB 构建的开源 AI 工作区:它像一个“第二大脑”,你可以就自己的记忆、文件和已连接的应用提问,它会基于检索到的上下文撰写答案,并标明引用来源。
它是一个完整的平台,还是需要搭配 Hydra DB 使用的前端?它是一个构建在 Hydra DB 之上的 Next.js 网页应用:检索和存储都在你的 Hydra 数据库里完成,应用的服务端通过官方的 @hydradb/sdk 代理所有调用——你需要把它连接到你自己的 Hydra。
我怎么把它跑起来?把 .env.example 复制为 .env.local 并设置 OPENGLEANSESSIONSECRET(其余配置都是可选的),然后运行应用即可——也提供 Docker 镜像;镜像只包含运行时所需的文件,并以非 root 用户运行。
要真正搜索我的数据,需要 Hydra DB API 密钥吗?需要——检索是在你的 Hydra 数据库上进行的。在 app.hydradb.com/keys 创建一个密钥,然后粘贴到连接页面;部署方也可以设置共享的 HYDRAAPIKEY,这样用户就完全不需要自己的密钥。
它开箱就能回答问题,还是我得先配置一个模型?回答问题需要大语言模型:它没有内置的默认模型,所以如果不设置 OPENGLEANLLMMODEL(或在“设置”里为当前用户选择一个模型),就无法获得答案。没有模型时,Hydra 检索本身仍然可以正常工作。
我的 API 密钥和聊天记录会保存在哪里?密钥绝不会经过浏览器:它们在服务端校验,并保存在用 AES-256-GCM 加密的 httpOnly 会话 Cookie 里。聊天记录在网络可用时持久化到 MongoDB,否则回退到 localStorage。
它可以自由使用和修改吗,许可证里有没有坑?Apache-2.0——可以自由使用和修改。NOTICE 里有一点需要注意:各连接器的徽标属于第三方商标,不在 Apache 授权范围之内。
Deep Research 是什么?这是一种应对单个查询无法回答的问题的模式:Open Glean 会规划一个由子问题组成的 DAG,对每一层并行查询 Hydra,为每个分支写出一条发现,把来源去重合并成一份带编号的引用列表,然后再写出最终答案。界面上有时间线展示规划和实时进度。
它能使用哪些 AI 模型?任何兼容 OpenAI 的接口都可以,用你自己的密钥——内置了可搜索的 OpenRouter 模型选择器,还支持收藏。如果启用了 OPENGLEANALLOWPRIVATELLMURL(默认关闭),Ollama、LM Studio 这类本地模型也能用。
我能限制查询的搜索范围吗?可以——通过顶栏选择某个查询要搜索的数据库和集合,检索会在所有选中的集合中同时展开。你也可以打开单个集合,只在其内部搜索。
它也能搜索实时网页吗?可选——网页搜索由你的大模型服务商的网页插件(OpenRouter)提供,其引用会和 Hydra 来源一起显示在来源面板里。
Creator
hydra-db
Size
1.4 MB
Stars
1.6K
Updated
CommitOct 17
Age
1mo
Commits · 90 Days