# Cabinet
**Repository Path**: wanghuachen/cabinet
## Basic Information
- **Project Name**: Cabinet
- **Description**: 自主搭建的深度结合openClaw的nodejs全栈应用
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-04-13
- **Last Updated**: 2026-05-06
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Project
✨ Your new, shiny [Nx workspace](https://nx.dev) is ready ✨.
[Learn more about this workspace setup and its capabilities](https://nx.dev/nx-api/nest?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or run `npx nx graph` to visually explore what was created. Now, let's get you up to speed!
## Run tasks
To run the dev server for your app, use:
```sh
npx nx serve api
```
To create a production bundle:
```sh
npx nx build api
```
To see all available targets to run for a project, run:
```sh
npx nx show project api
```
These targets are either [inferred automatically](https://nx.dev/concepts/inferred-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or defined in the `project.json` or `package.json` files.
[More about running tasks in the docs »](https://nx.dev/features/run-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
## Add new projects
While you could add new projects to your workspace manually, you might want to leverage [Nx plugins](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) and their [code generation](https://nx.dev/features/generate-code?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) feature.
Use the plugin's generator to create new projects.
To generate a new application, use:
```sh
npx nx g @nx/nest:app demo
```
To generate a new library, use:
```sh
npx nx g @nx/node:lib mylib
```
You can use `npx nx list` to get a list of installed plugins. Then, run `npx nx list ` to learn about more specific capabilities of a particular plugin. Alternatively, [install Nx Console](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) to browse plugins and generators in your IDE.
[Learn more about Nx plugins »](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | [Browse the plugin registry »](https://nx.dev/plugin-registry?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
## Set up CI!
### Step 1
To connect to Nx Cloud, run the following command:
```sh
npx nx connect
```
Connecting to Nx Cloud ensures a [fast and scalable CI](https://nx.dev/ci/intro/why-nx-cloud?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) pipeline. It includes features such as:
- [Remote caching](https://nx.dev/ci/features/remote-cache?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
- [Task distribution across multiple machines](https://nx.dev/ci/features/distribute-task-execution?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
- [Automated e2e test splitting](https://nx.dev/ci/features/split-e2e-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
- [Task flakiness detection and rerunning](https://nx.dev/ci/features/flaky-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
### Step 2
Use the following command to configure a CI workflow for your workspace:
```sh
npx nx g ci-workflow
```
[Learn more about Nx on CI](https://nx.dev/ci/intro/ci-with-nx#ready-get-started-with-your-provider?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
## Install Nx Console
Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
[Install Nx Console »](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
## Useful links
Learn more:
- [Learn more about this workspace setup](https://nx.dev/nx-api/nest?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
- [Learn about Nx on CI](https://nx.dev/ci/intro/ci-with-nx?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
- [Releasing Packages with Nx release](https://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
- [What are Nx plugins?](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
And join the Nx community:
- [Discord](https://go.nx.dev/community)
- [Follow us on X](https://twitter.com/nxdevtools) or [LinkedIn](https://www.linkedin.com/company/nrwl)
- [Our Youtube channel](https://www.youtube.com/@nxdevtools)
- [Our blog](https://nx.dev/blog?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
---
## 内阁-议会系统(本仓库)
### 本地运行
1. 复制 [`.env.example`](./.env.example) 为项目根目录 `.env`,按需填写 `DB_*`、`REDIS_*`、`JWT_SECRET`、`CREDENTIALS_MASTER_KEY`(用于加密保存 LLM API Key,可选)。
2. `docker compose up -d` 启动 PostgreSQL 与 Redis(见 [`docker-compose.yml`](./docker-compose.yml))。
3. `pnpm dev` 或分别 `pnpm dev:api`(3000)、`pnpm dev:web`(4200)。前端通过 Vite 将 `/api` 代理到后端;也可设置 `VITE_API_BASE_URL` 直连。
4. 浏览器访问 `http://localhost:4200`。写操作(创建任务、议会发言等)需先在 `/login` 注册并登录以获取 JWT。
### 知识检索(MVP)
当前知识库搜索已接入 **pgvector 向量相似度检索**(RAG MVP:chunk 切分 + embedding + 向量召回)。
### OpenClaw
Agent 执行依赖 **OpenClaw CLI**(可选)。未安装时相关接口会返回友好提示,**不阻塞** API 启动。
本项目支持 **启动时自动检测**:
- **本机存在 `openclaw` CLI**:走 `local-cli`
- **本机不存在**:自动尝试走 `docker-cli`(通过本仓库 `docker-compose` 的 `openclaw-gateway/openclaw-cli`)
- 两者都不可用:标记为 `unavailable`
#### 1) 推荐(auto):本机 CLI 优先,缺失则 Docker 兜底
`.env` 增加(或使用 `.env.example` 中的示例):
```ini
OPENCLAW_RUNTIME_MODE=auto
OPENCLAW_BIN=openclaw
OPENCLAW_DOCKER_IMAGE=ghcr.io/openclaw/openclaw:2026.4.14-slim
OPENCLAW_DOCKER_CONTAINER_GATEWAY=cabinet_openclaw_gateway
OPENCLAW_DOCKER_CONTAINER_CLI=cabinet_openclaw_cli
OPENCLAW_DOCKER_GATEWAY_PORT=18789
# Gateway token(必须设置,用于 CLI 配对授权)
# 生成方法: node -e "console.log(require('crypto').randomBytes(20).toString('hex'))"
OPENCLAW_GATEWAY_TOKEN=your-secure-token-here
OPENCLAW_TZ=UTC
```
**首次配置步骤:**
1. **初始化 Gateway**(自动配置配对并重启):
```bash
node scripts/setup-openclaw-gateway.mjs
```
2. **注入内阁部门配置**:
```bash
node scripts/inject-openclaw-cabinet-agents.mjs
```
3. **验证配置**:
```bash
node scripts/verify-openclaw-config.mjs
```
详细配置说明请参考:[OpenClaw配对配置指南](docs/OpenClaw配对配置指南.md)
启动 OpenClaw(可选):
```sh
docker compose up -d openclaw-gateway openclaw-cli
```
> 注意:是 `docker compose up -d ...`,不是 `docker compose -d`。
#### 2) 强制模式(用于排查)
- 强制走本机 CLI:
```ini
OPENCLAW_RUNTIME_MODE=local-cli
# 可选:指定本机 openclaw 可执行文件路径
# OPENCLAW_BIN=C:\path\to\openclaw.exe
```
- 强制走 Docker:
```ini
OPENCLAW_RUNTIME_MODE=docker-cli
```
#### 3) LLM Key 注入(可选)
`OpenClawService` 子进程会合并数据库中解密后的 `OPENAI_API_KEY` / `ANTHROPIC_API_KEY` / `GOOGLE_API_KEY`(通过 `POST /api/credentials` 配置;需要 `CREDENTIALS_MASTER_KEY` 才能解密注入)。