mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-12 17:12:06 +08:00
Compare commits
72 Commits
feature/un
...
refactor/b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9d778e3fb | ||
|
|
89b0067478 | ||
|
|
3e43431cdb | ||
|
|
d4366e3ad2 | ||
|
|
e297921d31 | ||
|
|
150642097a | ||
|
|
db39eda18a | ||
|
|
8f668d2c8a | ||
|
|
8ed530d7cb | ||
|
|
4a4a1e1803 | ||
|
|
7c8819cf34 | ||
|
|
bdf24092ff | ||
|
|
b62373f9b0 | ||
|
|
4765deede0 | ||
|
|
582508424b | ||
|
|
74336037bf | ||
|
|
d328ad38dd | ||
|
|
783cba4792 | ||
|
|
7200533dda | ||
|
|
8e6fc15a1d | ||
|
|
6589867d78 | ||
|
|
b54a2839e3 | ||
|
|
664713776a | ||
|
|
779bc63556 | ||
|
|
b09ce9dc60 | ||
|
|
cb3304b60c | ||
|
|
2161752a5b | ||
|
|
995a8cadb7 | ||
|
|
ed0a895d75 | ||
|
|
5a1bcb4931 | ||
|
|
5b69af528a | ||
|
|
db9ab26c3c | ||
|
|
7cd429697b | ||
|
|
f576b8e6d2 | ||
|
|
28aa5a3902 | ||
|
|
28a523b7a3 | ||
|
|
bdab5a806f | ||
|
|
8354cb65fd | ||
|
|
6d00c17137 | ||
|
|
753c58fc1a | ||
|
|
958a3c10eb | ||
|
|
49de006313 | ||
|
|
6b4c435cd3 | ||
|
|
dfe9c75cfd | ||
|
|
e165d2ca24 | ||
|
|
ce0dfad638 | ||
|
|
6cfe617711 | ||
|
|
ec70bfe7c7 | ||
|
|
fa05683861 | ||
|
|
ab72270ada | ||
|
|
90d234d9f3 | ||
|
|
33cea381c4 | ||
|
|
f77301e844 | ||
|
|
8986bc10a5 | ||
|
|
b57fec9d66 | ||
|
|
186dbcde63 | ||
|
|
9a8178e9ca | ||
|
|
1abdb95207 | ||
|
|
45bc53c68f | ||
|
|
24abcef110 | ||
|
|
fdad9acc2e | ||
|
|
85364e0234 | ||
|
|
63c4bbd2b8 | ||
|
|
57d6ae59de | ||
|
|
3b7a9d35c2 | ||
|
|
3e268e201a | ||
|
|
f187e22976 | ||
|
|
bbb461f7c2 | ||
|
|
7df21556dd | ||
|
|
23c39a42b1 | ||
|
|
695da128f3 | ||
|
|
e67738c9fc |
47
.github/workflows/cross-platform-server.yml
vendored
Normal file
47
.github/workflows/cross-platform-server.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
name: Cross Platform Server Verification
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
verify:
|
||||||
|
name: Verify on ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
node:
|
||||||
|
- 22
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# This step checks out the repository so the matrix job can build and test it.
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# This step installs the Node.js version the README already declares as the project baseline.
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node }}
|
||||||
|
cache: npm
|
||||||
|
|
||||||
|
# This step installs dependencies exactly as locked so native and shell behavior stays reproducible.
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
# This step verifies the TypeScript server code before runtime checks.
|
||||||
|
- name: Typecheck server
|
||||||
|
run: npm run typecheck:server
|
||||||
|
|
||||||
|
# This step runs the built-in Node tests that exercise the OS adapter layer directly.
|
||||||
|
- name: Test server adapters
|
||||||
|
run: npm run test:server
|
||||||
|
|
||||||
|
# This step ensures the in-progress TypeScript backend still compiles in each OS environment.
|
||||||
|
- name: Build server
|
||||||
|
run: npm run server:build
|
||||||
9
.github/workflows/release.yml
vendored
9
.github/workflows/release.yml
vendored
@@ -20,14 +20,13 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
id-token: write
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
token: ${{ secrets.RELEASE_PAT }}
|
|
||||||
|
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 20
|
||||||
registry-url: https://registry.npmjs.org
|
registry-url: https://registry.npmjs.org
|
||||||
|
|
||||||
- name: git config
|
- name: git config
|
||||||
@@ -45,6 +44,6 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
npx release-it $ARGS
|
npx release-it $ARGS
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -8,7 +8,7 @@ lerna-debug.log*
|
|||||||
|
|
||||||
# Build outputs
|
# Build outputs
|
||||||
dist/
|
dist/
|
||||||
dist-server/
|
server/dist/
|
||||||
dist-ssr/
|
dist-ssr/
|
||||||
build/
|
build/
|
||||||
out/
|
out/
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
"requireCleanWorkingDir": true
|
"requireCleanWorkingDir": true
|
||||||
},
|
},
|
||||||
"npm": {
|
"npm": {
|
||||||
"publish": true,
|
"publish": true
|
||||||
"publishArgs": ["--access public"]
|
|
||||||
},
|
},
|
||||||
"github": {
|
"github": {
|
||||||
"release": true,
|
"release": true,
|
||||||
|
|||||||
65
CHANGELOG.md
65
CHANGELOG.md
@@ -3,71 +3,6 @@
|
|||||||
All notable changes to CloudCLI UI will be documented in this file.
|
All notable changes to CloudCLI UI will be documented in this file.
|
||||||
|
|
||||||
|
|
||||||
## [1.29.2](https://github.com/siteboon/claudecodeui/compare/v1.29.1...v1.29.2) (2026-04-14)
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **sandbox:** use backgrounded sbx run to keep sandbox alive ([9b11c03](https://github.com/siteboon/claudecodeui/commit/9b11c034d9a19710a23b56c62dcf07c21a17bd97))
|
|
||||||
|
|
||||||
## [1.29.1](https://github.com/siteboon/claudecodeui/compare/v1.29.0...v1.29.1) (2026-04-14)
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* add latest tag to docker npx command and change the detach mode to work without spawn ([4a56972](https://github.com/siteboon/claudecodeui/commit/4a569725dae320a505753359d8edfd8ca79f0fd7))
|
|
||||||
|
|
||||||
## [1.29.0](https://github.com/siteboon/claudecodeui/compare/v1.28.1...v1.29.0) (2026-04-14)
|
|
||||||
|
|
||||||
### New Features
|
|
||||||
|
|
||||||
* adding docker sandbox environments ([13e97e2](https://github.com/siteboon/claudecodeui/commit/13e97e2c71254de7a60afb5495b21064c4bc4241))
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **thinking-mode:** fix dropdown positioning ([#646](https://github.com/siteboon/claudecodeui/issues/646)) ([c7a5baf](https://github.com/siteboon/claudecodeui/commit/c7a5baf1479404bd40e23aa58bd9f677df9a04c6))
|
|
||||||
|
|
||||||
### Maintenance
|
|
||||||
|
|
||||||
* update release flow node version ([e2459cb](https://github.com/siteboon/claudecodeui/commit/e2459cb0f8b35f54827778a7b444e6c3ca326506))
|
|
||||||
|
|
||||||
## [1.28.1](https://github.com/siteboon/claudecodeui/compare/v1.28.0...v1.28.1) (2026-04-10)
|
|
||||||
|
|
||||||
### New Features
|
|
||||||
|
|
||||||
* add branding, community links, GitHub star badge, and About settings tab ([2207d05](https://github.com/siteboon/claudecodeui/commit/2207d05c1ca229214aa9c2e2c9f4d0827d421574))
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* corrupted binary downloads ([#634](https://github.com/siteboon/claudecodeui/issues/634)) ([e61f8a5](https://github.com/siteboon/claudecodeui/commit/e61f8a543d63fe7c24a04b3d2186085a06dcbcdb))
|
|
||||||
* **ui:** remove mobile bottom nav, unify processing indicator, and improve tooltip behavior on mobile ([#632](https://github.com/siteboon/claudecodeui/issues/632)) ([a8dab0e](https://github.com/siteboon/claudecodeui/commit/a8dab0edcf949ae610820bae9500c433781f7c73))
|
|
||||||
|
|
||||||
### Refactoring
|
|
||||||
|
|
||||||
* remove unused whispher transcribe logic ([#637](https://github.com/siteboon/claudecodeui/issues/637)) ([590dd42](https://github.com/siteboon/claudecodeui/commit/590dd42649424ab990353fcf59ce0965036d3d25))
|
|
||||||
|
|
||||||
## [1.28.0](https://github.com/siteboon/claudecodeui/compare/v1.27.1...v1.28.0) (2026-04-03)
|
|
||||||
|
|
||||||
### New Features
|
|
||||||
|
|
||||||
* adding session resume in the api ([8f1042c](https://github.com/siteboon/claudecodeui/commit/8f1042cf256be282f009adcceeb55ab2dddf3fba))
|
|
||||||
* moving new session button higher ([1628868](https://github.com/siteboon/claudecodeui/commit/16288684702dec894cf054291ca3d545ddb8214b))
|
|
||||||
|
|
||||||
### Maintenance
|
|
||||||
|
|
||||||
* changing package name to @cloudcli-ai/cloudcli ([ef51de2](https://github.com/siteboon/claudecodeui/commit/ef51de259ea2b963bc15f058b084e11220bc216a))
|
|
||||||
|
|
||||||
## [1.27.1](https://github.com/siteboon/claudecodeui/compare/v1.26.3...v1.27.1) (2026-03-29)
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* prevent split on undefined([#491](https://github.com/siteboon/claudecodeui/issues/491)) ([#563](https://github.com/siteboon/claudecodeui/issues/563)) ([b54cdf8](https://github.com/siteboon/claudecodeui/commit/b54cdf8168fc224e9907796e4229ae8ed34e6885))
|
|
||||||
|
|
||||||
### Maintenance
|
|
||||||
|
|
||||||
* add release-it github action ([42a1313](https://github.com/siteboon/claudecodeui/commit/42a131389a6954df0d2c3bedd2cb6d3406c5ebc1))
|
|
||||||
* add terminal plugin in the plugins list ([004135e](https://github.com/siteboon/claudecodeui/commit/004135ef0187023e1da29c4a7137a28a42ebf9af))
|
|
||||||
* release tokens ([f1063fd](https://github.com/siteboon/claudecodeui/commit/f1063fd33964ccb517f5ebcdd14526ed162e1138))
|
|
||||||
* relicense to AGPL-3.0-or-later ([27cd124](https://github.com/siteboon/claudecodeui/commit/27cd12432b7d3237981f86acd9cc99532d843d4a))
|
|
||||||
|
|
||||||
## [1.26.3](https://github.com/siteboon/claudecodeui/compare/v1.26.2...v1.26.3) (2026-03-22)
|
## [1.26.3](https://github.com/siteboon/claudecodeui/compare/v1.26.2...v1.26.3) (2026-03-22)
|
||||||
|
|
||||||
## [1.26.2](https://github.com/siteboon/claudecodeui/compare/v1.26.0...v1.26.2) (2026-03-21)
|
## [1.26.2](https://github.com/siteboon/claudecodeui/compare/v1.26.0...v1.26.2) (2026-03-21)
|
||||||
|
|||||||
@@ -153,4 +153,4 @@ This automatically:
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
By contributing, you agree that your contributions will be licensed under the [AGPL-3.0-or-later License](LICENSE), including the additional terms specified in Section 7 of the LICENSE file.
|
By contributing, you agree that your contributions will be licensed under the [GPL-3.0 License](LICENSE).
|
||||||
13
NOTICE
13
NOTICE
@@ -1,13 +0,0 @@
|
|||||||
CloudCLI UI
|
|
||||||
Copyright 2025-2026 Siteboon AI B.V. and contributors
|
|
||||||
|
|
||||||
This software is licensed under the GNU Affero General Public License v3.0
|
|
||||||
or later (AGPL-3.0-or-later). See the LICENSE file for the full license text,
|
|
||||||
including additional terms under Section 7.
|
|
||||||
|
|
||||||
Originally developed by Siteboon AI B.V. (https://github.com/siteboon/claudecodeui).
|
|
||||||
|
|
||||||
Contributions by Siteboon AI B.V. prior to commit 004135ef were originally
|
|
||||||
published under GPL-3.0 and are hereby relicensed to AGPL-3.0-or-later.
|
|
||||||
Contributions by other authors prior to that commit remain under GPL-3.0
|
|
||||||
and are incorporated into this work as permitted by GPL-3.0 Section 13.
|
|
||||||
17
README.de.md
17
README.de.md
@@ -76,18 +76,16 @@ Der schnellste Einstieg – keine lokale Einrichtung erforderlich. Erhalte eine
|
|||||||
|
|
||||||
### Self-Hosted (Open Source)
|
### Self-Hosted (Open Source)
|
||||||
|
|
||||||
#### npm
|
|
||||||
|
|
||||||
CloudCLI UI sofort mit **npx** ausprobieren (erfordert **Node.js** v22+):
|
CloudCLI UI sofort mit **npx** ausprobieren (erfordert **Node.js** v22+):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx @cloudcli-ai/cloudcli
|
npx @siteboon/claude-code-ui
|
||||||
```
|
```
|
||||||
|
|
||||||
Oder **global** installieren für regelmäßige Nutzung:
|
Oder **global** installieren für regelmäßige Nutzung:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @cloudcli-ai/cloudcli
|
npm install -g @siteboon/claude-code-ui
|
||||||
cloudcli
|
cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -95,15 +93,6 @@ cloudcli
|
|||||||
|
|
||||||
Die **[Dokumentation →](https://cloudcli.ai/docs)** enthält weitere Konfigurationsoptionen, PM2, Remote-Server-Einrichtung und mehr.
|
Die **[Dokumentation →](https://cloudcli.ai/docs)** enthält weitere Konfigurationsoptionen, PM2, Remote-Server-Einrichtung und mehr.
|
||||||
|
|
||||||
#### Docker Sandboxes (Experimentell)
|
|
||||||
|
|
||||||
Agents in isolierten Sandboxes mit Hypervisor-Isolation ausführen. Standardmäßig wird Claude Code gestartet. Erfordert die [`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/).
|
|
||||||
|
|
||||||
```
|
|
||||||
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
|
||||||
```
|
|
||||||
|
|
||||||
Unterstützt Claude Code, Codex und Gemini CLI. Weitere Details in der [Sandbox-Dokumentation](docker/).
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -115,7 +104,7 @@ CloudCLI UI ist die Open-Source-UI-Schicht, die CloudCLI Cloud antreibt. Du kann
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| **Am besten für** | Entwickler:innen, die eine vollständige UI für lokale Agent-Sitzungen auf ihrem eigenen Rechner möchten | Teams und Entwickler:innen, die Agents in der Cloud betreiben möchten, überall erreichbar |
|
| **Am besten für** | Entwickler:innen, die eine vollständige UI für lokale Agent-Sitzungen auf ihrem eigenen Rechner möchten | Teams und Entwickler:innen, die Agents in der Cloud betreiben möchten, überall erreichbar |
|
||||||
| **Zugriff** | Browser via `[deineIP]:port` | Browser, jede IDE, REST API, n8n |
|
| **Zugriff** | Browser via `[deineIP]:port` | Browser, jede IDE, REST API, n8n |
|
||||||
| **Einrichtung** | `npx @cloudcli-ai/cloudcli` | Keine Einrichtung erforderlich |
|
| **Einrichtung** | `npx @siteboon/claude-code-ui` | Keine Einrichtung erforderlich |
|
||||||
| **Rechner muss laufen** | Ja | Nein |
|
| **Rechner muss laufen** | Ja | Nein |
|
||||||
| **Mobiler Zugriff** | Jeder Browser im Netzwerk | Jedes Gerät, native App in Entwicklung |
|
| **Mobiler Zugriff** | Jeder Browser im Netzwerk | Jedes Gerät, native App in Entwicklung |
|
||||||
| **Verfügbare Sitzungen** | Alle Sitzungen automatisch aus `~/.claude` erkannt | Alle Sitzungen in deiner Cloud-Umgebung |
|
| **Verfügbare Sitzungen** | Alle Sitzungen automatisch aus `~/.claude` erkannt | Alle Sitzungen in deiner Cloud-Umgebung |
|
||||||
|
|||||||
17
README.ja.md
17
README.ja.md
@@ -72,18 +72,16 @@
|
|||||||
|
|
||||||
### セルフホスト(オープンソース)
|
### セルフホスト(オープンソース)
|
||||||
|
|
||||||
#### npm
|
|
||||||
|
|
||||||
**npx** で今すぐ CloudCLI UI を試せます(**Node.js** v22+ が必要):
|
**npx** で今すぐ CloudCLI UI を試せます(**Node.js** v22+ が必要):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx @cloudcli-ai/cloudcli
|
npx @siteboon/claude-code-ui
|
||||||
```
|
```
|
||||||
|
|
||||||
または、普段使いするなら **グローバル** にインストール:
|
または、普段使いするなら **グローバル** にインストール:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @cloudcli-ai/cloudcli
|
npm install -g @siteboon/claude-code-ui
|
||||||
cloudcli
|
cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -91,15 +89,6 @@ cloudcli
|
|||||||
|
|
||||||
より詳細な設定オプション、PM2、リモートサーバー設定などについては **[ドキュメントはこちら →](https://cloudcli.ai/docs)** を参照してください。
|
より詳細な設定オプション、PM2、リモートサーバー設定などについては **[ドキュメントはこちら →](https://cloudcli.ai/docs)** を参照してください。
|
||||||
|
|
||||||
#### Docker Sandboxes(実験的)
|
|
||||||
|
|
||||||
ハイパーバイザーレベルの分離でエージェントをサンドボックスで実行します。デフォルトでは Claude Code が起動します。[`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/) が必要です。
|
|
||||||
|
|
||||||
```
|
|
||||||
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
|
||||||
```
|
|
||||||
|
|
||||||
Claude Code、Codex、Gemini CLI に対応。詳細は[サンドボックスのドキュメント](docker/)をご覧ください。
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -111,7 +100,7 @@ CloudCLI UI は、CloudCLI Cloud を支えるオープンソースの UI レイ
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| **対象ユーザー** | 自分のマシン上でローカルの agent セッションに対してフル UI を使いたい開発者 | クラウド上で動く agents をどこからでも利用したいチーム/開発者 |
|
| **対象ユーザー** | 自分のマシン上でローカルの agent セッションに対してフル UI を使いたい開発者 | クラウド上で動く agents をどこからでも利用したいチーム/開発者 |
|
||||||
| **アクセス方法** | ブラウザ(`[yourip]:port`) | ブラウザ、任意の IDE、REST API、n8n |
|
| **アクセス方法** | ブラウザ(`[yourip]:port`) | ブラウザ、任意の IDE、REST API、n8n |
|
||||||
| **セットアップ** | `npx @cloudcli-ai/cloudcli` | セットアップ不要 |
|
| **セットアップ** | `npx @siteboon/claude-code-ui` | セットアップ不要 |
|
||||||
| **マシンの稼働継続** | はい | いいえ |
|
| **マシンの稼働継続** | はい | いいえ |
|
||||||
| **モバイルアクセス** | 同一ネットワーク内の任意のブラウザ | 任意のデバイス(ネイティブアプリも準備中) |
|
| **モバイルアクセス** | 同一ネットワーク内の任意のブラウザ | 任意のデバイス(ネイティブアプリも準備中) |
|
||||||
| **利用可能なセッション** | `~/.claude` から全セッションを自動検出 | クラウド環境内の全セッション |
|
| **利用可能なセッション** | `~/.claude` から全セッションを自動検出 | クラウド環境内の全セッション |
|
||||||
|
|||||||
20
README.ko.md
20
README.ko.md
@@ -72,34 +72,22 @@
|
|||||||
|
|
||||||
### 셀프 호스트 (오픈 소스)
|
### 셀프 호스트 (오픈 소스)
|
||||||
|
|
||||||
#### npm
|
|
||||||
|
|
||||||
**npx**로 즉시 CloudCLI UI를 실행하세요 (Node.js v22+ 필요):
|
**npx**로 즉시 CloudCLI UI를 실행하세요 (Node.js v22+ 필요):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx @cloudcli-ai/cloudcli
|
npx @siteboon/claude-code-ui
|
||||||
```
|
```
|
||||||
|
|
||||||
**정기적으로 사용한다면 전역 설치:**
|
**정기적으로 사용한다면 전역 설치:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @cloudcli-ai/cloudcli
|
npm install -g @siteboon/claude-code-ui
|
||||||
cloudcli
|
cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
`http://localhost:3001`을 열면 기존 세션이 자동으로 발견됩니다.
|
`http://localhost:3001`을 열면 기존 세션이 자동으로 발견됩니다.
|
||||||
|
|
||||||
자세한 구성 옵션, PM2, 원격 서버 설정 등은 **[문서 →](https://cloudcli.ai/docs)**를 참고하세요.
|
자세한 구성 옵션, PM2, 원격 서버 설정 등은 **[문서 →](https://cloudcli.ai/docs)**를 참고하세요
|
||||||
|
|
||||||
#### Docker Sandboxes (실험적)
|
|
||||||
|
|
||||||
하이퍼바이저 수준 격리로 에이전트를 샌드박스에서 실행합니다. 기본 에이전트는 Claude Code입니다. [`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/)가 필요합니다.
|
|
||||||
|
|
||||||
```
|
|
||||||
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
|
||||||
```
|
|
||||||
|
|
||||||
Claude Code, Codex, Gemini CLI를 지원합니다. 자세한 내용은 [샌드박스 문서](docker/)를 참고하세요.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -111,7 +99,7 @@ CloudCLI UI는 CloudCLI Cloud를 구동하는 오픈 소스 UI 계층입니다.
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| **적합한 대상** | 로컬 에이전트 세션을 위한 전체 UI가 필요한 개발자 | 어디서든 접근 가능한 클라우드에서 에이전트를 운영하고자 하는 팀 및 개발자 |
|
| **적합한 대상** | 로컬 에이전트 세션을 위한 전체 UI가 필요한 개발자 | 어디서든 접근 가능한 클라우드에서 에이전트를 운영하고자 하는 팀 및 개발자 |
|
||||||
| **접근 방법** | `[yourip]:port`를 통해 브라우저 접속 | 브라우저, IDE, REST API, n8n |
|
| **접근 방법** | `[yourip]:port`를 통해 브라우저 접속 | 브라우저, IDE, REST API, n8n |
|
||||||
| **설정** | `npx @cloudcli-ai/cloudcli` | 설정 불필요 |
|
| **설정** | `npx @siteboon/claude-code-ui` | 설정 불필요 |
|
||||||
| **기기 유지 필요 여부** | 예 (머신 켜둬야 함) | 아니오 |
|
| **기기 유지 필요 여부** | 예 (머신 켜둬야 함) | 아니오 |
|
||||||
| **모바일 접근** | 네트워크 내 브라우저 | 모든 기기 (네이티브 앱 예정) |
|
| **모바일 접근** | 네트워크 내 브라우저 | 모든 기기 (네이티브 앱 예정) |
|
||||||
| **세션 접근** | `~/.claude`에서 자동 발견 | 클라우드 환경 내 세션 |
|
| **세션 접근** | `~/.claude`에서 자동 발견 | 클라우드 환경 내 세션 |
|
||||||
|
|||||||
58
README.md
58
README.md
@@ -76,58 +76,48 @@ The fastest way to get started — no local setup required. Get a fully managed,
|
|||||||
|
|
||||||
### Self-Hosted (Open source)
|
### Self-Hosted (Open source)
|
||||||
|
|
||||||
#### npm
|
|
||||||
|
|
||||||
Try CloudCLI UI instantly with **npx** (requires **Node.js** v22+):
|
Try CloudCLI UI instantly with **npx** (requires **Node.js** v22+):
|
||||||
|
|
||||||
```
|
```
|
||||||
npx @cloudcli-ai/cloudcli
|
npx @siteboon/claude-code-ui
|
||||||
```
|
```
|
||||||
|
|
||||||
Or install **globally** for regular use:
|
Or install **globally** for regular use:
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install -g @cloudcli-ai/cloudcli
|
npm install -g @siteboon/claude-code-ui
|
||||||
cloudcli
|
cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
Open `http://localhost:3001` — all your existing sessions are discovered automatically.
|
Open `http://localhost:3001` — all your existing sessions are discovered automatically.
|
||||||
|
|
||||||
Visit the **[documentation →](https://cloudcli.ai/docs)** for full configuration options, PM2, remote server setup and more.
|
Visit the **[documentation →](https://cloudcli.ai/docs)** for more full configuration options, PM2, remote server setup and more
|
||||||
|
|
||||||
#### Docker Sandboxes (Experimental)
|
|
||||||
|
|
||||||
Run agents in isolated sandboxes with hypervisor-level isolation. Starts Claude Code by default. Requires the [`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/).
|
|
||||||
|
|
||||||
```
|
|
||||||
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
|
||||||
```
|
|
||||||
|
|
||||||
Supports Claude Code, Codex, and Gemini CLI. See the [sandbox docs](docker/) for setup and advanced options.
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Which option is right for you?
|
## Which option is right for you?
|
||||||
|
|
||||||
CloudCLI UI is the open source UI layer that powers CloudCLI Cloud. You can self-host it on your own machine, run it in a Docker sandbox for isolation, or use CloudCLI Cloud for a fully managed environment.
|
CloudCLI UI is the open source UI layer that powers CloudCLI Cloud. You can self-host it on your own machine, or use CloudCLI Cloud which builds on top of it with a full managed cloud environment, team features, and deeper integrations.
|
||||||
|
|
||||||
| | Self-Hosted (npm) | Self-Hosted (Docker Sandbox) *(Experimental)* | CloudCLI Cloud |
|
| | CloudCLI UI (Self-hosted) | CloudCLI Cloud |
|
||||||
|---|---|---|---|
|
|---|---|---|
|
||||||
| **Best for** | Local agent sessions on your own machine | Isolated agents with web/mobile IDE | Teams who want agents in the cloud |
|
| **Best for** | Developers who want a full UI for local agent sessions on their own machine | Teams and developers who want agents running in the cloud, accessible from anywhere |
|
||||||
| **How you access it** | Browser via `[yourip]:port` | Browser via `localhost:port` | Browser, any IDE, REST API, n8n |
|
| **How you access it** | Browser via `[yourip]:port` | Browser, any IDE, REST API, n8n |
|
||||||
| **Setup** | `npx @cloudcli-ai/cloudcli` | `npx @cloudcli-ai/cloudcli@latest sandbox ~/project` | No setup required |
|
| **Setup** | `npx @siteboon/claude-code-ui` | No setup required |
|
||||||
| **Isolation** | Runs on your host | Hypervisor-level sandbox (microVM) | Full cloud isolation |
|
| **Machine needs to stay on** | Yes | No |
|
||||||
| **Machine needs to stay on** | Yes | Yes | No |
|
| **Mobile access** | Any browser on your network | Any device, native app coming |
|
||||||
| **Mobile access** | Any browser on your network | Any browser on your network | Any device, native app coming |
|
| **Sessions available** | All sessions auto-discovered from `~/.claude` | All sessions within your cloud environment |
|
||||||
| **Agents supported** | Claude Code, Cursor CLI, Codex, Gemini CLI | Claude Code, Codex, Gemini CLI | Claude Code, Cursor CLI, Codex, Gemini CLI |
|
| **Agents supported** | Claude Code, Cursor CLI, Codex, Gemini CLI | Claude Code, Cursor CLI, Codex, Gemini CLI |
|
||||||
| **File explorer and Git** | Yes | Yes | Yes |
|
| **File explorer and Git** | Yes, built into the UI | Yes, built into the UI |
|
||||||
| **MCP configuration** | Synced with `~/.claude` | Managed via UI | Managed via UI |
|
| **MCP configuration** | Managed via UI, synced with your local `~/.claude` config | Managed via UI |
|
||||||
| **REST API** | Yes | Yes | Yes |
|
| **IDE access** | Your local IDE | Any IDE connected to your cloud environment |
|
||||||
| **Team sharing** | No | No | Yes |
|
| **REST API** | Yes | Yes |
|
||||||
| **Platform cost** | Free, open source | Free, open source | Starts at $7/month |
|
| **n8n node** | No | Yes |
|
||||||
|
| **Team sharing** | No | Yes |
|
||||||
|
| **Platform cost** | Free, open source | Starts at $7/month |
|
||||||
|
|
||||||
> All options use your own AI subscriptions (Claude, Cursor, etc.) — CloudCLI provides the environment, not the AI.
|
> Both options use your own AI subscriptions (Claude, Cursor, etc.) — CloudCLI provides the environment, not the AI.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -223,11 +213,9 @@ Yes, for self-hosted. CloudCLI UI reads from and writes to the same `~/.claude`
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later) — see [LICENSE](LICENSE) for the full text, including additional terms under Section 7.
|
GNU General Public License v3.0 - see [LICENSE](LICENSE) file for details.
|
||||||
|
|
||||||
This project is open source and free to use, modify, and distribute under the AGPL-3.0-or-later license. If you modify this software and run it as a network service, you must make your modified source code available to users of that service.
|
This project is open source and free to use, modify, and distribute under the GPL v3 license.
|
||||||
|
|
||||||
CloudCLI UI - (https://cloudcli.ai).
|
|
||||||
|
|
||||||
## Acknowledgments
|
## Acknowledgments
|
||||||
|
|
||||||
|
|||||||
19
README.ru.md
19
README.ru.md
@@ -76,34 +76,23 @@
|
|||||||
|
|
||||||
### Self-Hosted (Open source)
|
### Self-Hosted (Open source)
|
||||||
|
|
||||||
#### npm
|
|
||||||
|
|
||||||
Попробовать CloudCLI UI можно сразу через **npx** (требуется **Node.js** v22+):
|
Попробовать CloudCLI UI можно сразу через **npx** (требуется **Node.js** v22+):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx @cloudcli-ai/cloudcli
|
npx @siteboon/claude-code-ui
|
||||||
```
|
```
|
||||||
|
|
||||||
Или установить **глобально** для регулярного использования:
|
Или установить **глобально** для регулярного использования:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @cloudcli-ai/cloudcli
|
npm install -g @siteboon/claude-code-ui
|
||||||
cloudcli
|
cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
Откройте `http://localhost:3001` — все ваши существующие сессии будут обнаружены автоматически.
|
Откройте `http://localhost:3001` — все ваши существующие сессии будут обнаружены автоматически.
|
||||||
|
|
||||||
Посетите **[документацию →](https://cloudcli.ai/docs)**, чтобы узнать про дополнительные варианты конфигурации, PM2, настройку удалённого сервера и многое другое.
|
Посетите **[документацию →](https://cloudcli.ai/docs)**, чтобы узнать про дополнительные варианты конфигурации, PM2, настройку удалённого сервера и многое другое
|
||||||
|
|
||||||
#### Docker Sandboxes (Экспериментально)
|
|
||||||
|
|
||||||
Запускайте агентов в изолированных песочницах с гипервизорной изоляцией. По умолчанию запускается Claude Code. Требуется [`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/).
|
|
||||||
|
|
||||||
```
|
|
||||||
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
|
||||||
```
|
|
||||||
|
|
||||||
Поддерживаются Claude Code, Codex и Gemini CLI. Подробнее в [документации sandbox](docker/).
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -115,7 +104,7 @@ CloudCLI UI — это open source UI-слой, на котором постро
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| **Лучше всего подходит для** | Разработчиков, которым нужен полноценный UI для локальных агентских сессий на своей машине | Команд и разработчиков, которым нужны агенты в облаке с доступом откуда угодно |
|
| **Лучше всего подходит для** | Разработчиков, которым нужен полноценный UI для локальных агентских сессий на своей машине | Команд и разработчиков, которым нужны агенты в облаке с доступом откуда угодно |
|
||||||
| **Как вы получаете доступ** | Браузер через `[yourip]:port` | Браузер, любая IDE, REST API, n8n |
|
| **Как вы получаете доступ** | Браузер через `[yourip]:port` | Браузер, любая IDE, REST API, n8n |
|
||||||
| **Настройка** | `npx @cloudcli-ai/cloudcli` | Настройка не требуется |
|
| **Настройка** | `npx @siteboon/claude-code-ui` | Настройка не требуется |
|
||||||
| **Машина должна оставаться включённой** | Да | Нет |
|
| **Машина должна оставаться включённой** | Да | Нет |
|
||||||
| **Доступ с мобильных устройств** | Любой браузер в вашей сети | Любое устройство, нативное приложение в разработке |
|
| **Доступ с мобильных устройств** | Любой браузер в вашей сети | Любое устройство, нативное приложение в разработке |
|
||||||
| **Доступные сессии** | Все сессии автоматически обнаруживаются из `~/.claude` | Все сессии внутри вашей облачной среды |
|
| **Доступные сессии** | Все сессии автоматически обнаруживаются из `~/.claude` | Все сессии внутри вашей облачной среды |
|
||||||
|
|||||||
@@ -72,34 +72,22 @@
|
|||||||
|
|
||||||
### 自托管(开源)
|
### 自托管(开源)
|
||||||
|
|
||||||
#### npm
|
|
||||||
|
|
||||||
启动 CloudCLI UI,只需一行 `npx`(需要 Node.js v22+):
|
启动 CloudCLI UI,只需一行 `npx`(需要 Node.js v22+):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx @cloudcli-ai/cloudcli
|
npx @siteboon/claude-code-ui
|
||||||
```
|
```
|
||||||
|
|
||||||
或进行全局安装,便于日常使用:
|
或进行全局安装,便于日常使用:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @cloudcli-ai/cloudcli
|
npm install -g @siteboon/claude-code-ui
|
||||||
cloudcli
|
cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
打开 `http://localhost:3001`,系统会自动发现所有现有会话。
|
打开 `http://localhost:3001`,系统会自动发现所有现有会话。
|
||||||
|
|
||||||
更多配置选项、PM2、远程服务器设置等,请参阅 **[文档 →](https://cloudcli.ai/docs)**。
|
更多配置选项、PM2、远程服务器设置等,请参阅 **[文档 →](https://cloudcli.ai/docs)**
|
||||||
|
|
||||||
#### Docker Sandboxes(实验性)
|
|
||||||
|
|
||||||
在隔离的沙箱中运行代理,具有虚拟机管理程序级别的隔离。默认启动 Claude Code。需要 [`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/)。
|
|
||||||
|
|
||||||
```
|
|
||||||
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
|
||||||
```
|
|
||||||
|
|
||||||
支持 Claude Code、Codex 和 Gemini CLI。详情请参阅 [沙箱文档](docker/)。
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -111,7 +99,7 @@ CloudCLI UI 是 CloudCLI Cloud 的开源 UI 层。你可以在本地机器上自
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| **适合对象** | 需要为本地代理会话提供完整 UI 的开发者 | 需要部署在云端,随时从任何地方访问代理的团队与开发者 |
|
| **适合对象** | 需要为本地代理会话提供完整 UI 的开发者 | 需要部署在云端,随时从任何地方访问代理的团队与开发者 |
|
||||||
| **访问方式** | 通过 `[yourip]:port` 在浏览器中访问 | 浏览器、任意 IDE、REST API、n8n |
|
| **访问方式** | 通过 `[yourip]:port` 在浏览器中访问 | 浏览器、任意 IDE、REST API、n8n |
|
||||||
| **设置** | `npx @cloudcli-ai/cloudcli` | 无需设置 |
|
| **设置** | `npx @siteboon/claude-code-ui` | 无需设置 |
|
||||||
| **机器需保持开机吗** | 是 | 否 |
|
| **机器需保持开机吗** | 是 | 否 |
|
||||||
| **移动端访问** | 网络内任意浏览器 | 任意设备(原生应用即将推出) |
|
| **移动端访问** | 网络内任意浏览器 | 任意设备(原生应用即将推出) |
|
||||||
| **可用会话** | 自动发现 `~/.claude` 中的所有会话 | 云端环境内的会话 |
|
| **可用会话** | 自动发现 `~/.claude` 中的所有会话 | 云端环境内的会话 |
|
||||||
|
|||||||
160
docker/README.md
160
docker/README.md
@@ -1,160 +0,0 @@
|
|||||||
<!-- Docker Hub short description (100 chars max): -->
|
|
||||||
<!-- Sandbox templates for running AI coding agents with a web & mobile IDE (Claude Code, Codex, Gemini) -->
|
|
||||||
|
|
||||||
# Sandboxed coding agents with a web & mobile IDE (CloudCLI)
|
|
||||||
|
|
||||||
[Docker Sandbox](https://docs.docker.com/ai/sandboxes/) templates that add [CloudCLI](https://cloudcli.ai) on top of Claude Code, Codex, and Gemini CLI. You get a full web and mobile IDE accessible from any browser on any device.
|
|
||||||
|
|
||||||
## Get started
|
|
||||||
|
|
||||||
### 1. Install the sbx CLI
|
|
||||||
|
|
||||||
Docker Sandboxes run agents in isolated microVMs. Install the `sbx` CLI:
|
|
||||||
|
|
||||||
- **macOS**: `brew install docker/tap/sbx`
|
|
||||||
- **Windows**: `winget install -h Docker.sbx`
|
|
||||||
- **Linux**: `sudo apt-get install docker-sbx`
|
|
||||||
|
|
||||||
Full instructions: [docs.docker.com/ai/sandboxes/get-started](https://docs.docker.com/ai/sandboxes/get-started/)
|
|
||||||
|
|
||||||
### 2. Store your API key
|
|
||||||
|
|
||||||
`sbx` manages credentials securely — your API key never enters the sandbox. Store it once:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sbx login
|
|
||||||
sbx secret set -g anthropic
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Launch Claude Code
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
|
||||||
```
|
|
||||||
|
|
||||||
Open **http://localhost:3001**. Set a password on first visit. Start building.
|
|
||||||
|
|
||||||
### Using a different agent
|
|
||||||
|
|
||||||
Store the matching API key and pass `--agent`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# OpenAI Codex
|
|
||||||
sbx secret set -g openai
|
|
||||||
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project --agent codex
|
|
||||||
|
|
||||||
# Gemini CLI
|
|
||||||
sbx secret set -g google
|
|
||||||
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project --agent gemini
|
|
||||||
```
|
|
||||||
|
|
||||||
### Available templates
|
|
||||||
|
|
||||||
| Agent | Template |
|
|
||||||
|-------|----------|
|
|
||||||
| **Claude Code** (default) | `docker.io/cloudcliai/sandbox:claude-code` |
|
|
||||||
| OpenAI Codex | `docker.io/cloudcliai/sandbox:codex` |
|
|
||||||
| Gemini CLI | `docker.io/cloudcliai/sandbox:gemini` |
|
|
||||||
|
|
||||||
These are used with `--template` when running `sbx` directly (see [Advanced usage](#advanced-usage)).
|
|
||||||
|
|
||||||
## Managing sandboxes
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sbx ls # List all sandboxes
|
|
||||||
sbx stop my-project # Stop (preserves state)
|
|
||||||
sbx start my-project # Restart a stopped sandbox
|
|
||||||
sbx rm my-project # Remove everything
|
|
||||||
sbx exec my-project bash # Open a shell inside the sandbox
|
|
||||||
```
|
|
||||||
|
|
||||||
If you install CloudCLI globally (`npm install -g @cloudcli-ai/cloudcli`), you can also use:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cloudcli sandbox ls
|
|
||||||
cloudcli sandbox start my-project # Restart and re-launch web UI
|
|
||||||
cloudcli sandbox logs my-project # View server logs
|
|
||||||
```
|
|
||||||
|
|
||||||
## What you get
|
|
||||||
|
|
||||||
- **Chat** — Markdown rendering, code blocks, message history
|
|
||||||
- **Files** — File tree with syntax-highlighted editor
|
|
||||||
- **Git** — Diff viewer, staging, branch switching, commits
|
|
||||||
- **Shell** — Built-in terminal emulator
|
|
||||||
- **MCP** — Configure Model Context Protocol servers visually
|
|
||||||
- **Mobile** — Works on tablet and phone browsers
|
|
||||||
|
|
||||||
Your project directory is mounted bidirectionally — edits propagate in real time, both ways.
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
Set variables at creation time with `--env`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project --env SERVER_PORT=8080
|
|
||||||
```
|
|
||||||
|
|
||||||
Or inside a running sandbox:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sbx exec my-project bash -c 'echo "export SERVER_PORT=8080" >> /etc/sandbox-persistent.sh'
|
|
||||||
```
|
|
||||||
|
|
||||||
Restart CloudCLI for changes to take effect:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sbx exec my-project bash -c 'pkill -f "server/index.js"'
|
|
||||||
sbx exec -d my-project cloudcli start --port 3001
|
|
||||||
```
|
|
||||||
|
|
||||||
| Variable | Default | Description |
|
|
||||||
|----------|---------|-------------|
|
|
||||||
| `SERVER_PORT` | `3001` | Web UI port |
|
|
||||||
| `HOST` | `0.0.0.0` | Bind address (must be `0.0.0.0` for `sbx ports`) |
|
|
||||||
| `DATABASE_PATH` | `~/.cloudcli/auth.db` | SQLite database location |
|
|
||||||
|
|
||||||
## Advanced usage
|
|
||||||
|
|
||||||
For branch mode, multiple workspaces, memory limits, or the terminal agent experience, use `sbx` with the template:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Terminal agent + web UI
|
|
||||||
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/my-project --name my-project
|
|
||||||
sbx ports my-project --publish 3001:3001
|
|
||||||
|
|
||||||
# Branch mode (Git worktree isolation)
|
|
||||||
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/my-project --branch my-feature
|
|
||||||
|
|
||||||
# Multiple workspaces
|
|
||||||
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/project ~/shared-libs:ro
|
|
||||||
|
|
||||||
# Pass a prompt directly
|
|
||||||
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/my-project -- "Fix the auth bug"
|
|
||||||
```
|
|
||||||
|
|
||||||
CloudCLI auto-starts via `.bashrc` when using `sbx run`.
|
|
||||||
|
|
||||||
Full options in the [Docker Sandboxes usage guide](https://docs.docker.com/ai/sandboxes/usage/).
|
|
||||||
|
|
||||||
## Network policies
|
|
||||||
|
|
||||||
Sandboxes restrict outbound access by default. To reach host services from inside the sandbox:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sbx policy allow network localhost:11434
|
|
||||||
# Inside the sandbox: curl http://host.docker.internal:11434
|
|
||||||
```
|
|
||||||
|
|
||||||
The web UI itself doesn't need a policy — access it via `sbx ports`.
|
|
||||||
|
|
||||||
## Links
|
|
||||||
|
|
||||||
- [CloudCLI Cloud](https://cloudcli.ai) — fully managed, no setup required
|
|
||||||
- [Documentation](https://cloudcli.ai/docs) — full configuration guide
|
|
||||||
- [Discord](https://discord.gg/buxwujPNRE) — community support
|
|
||||||
- [GitHub](https://github.com/siteboon/claudecodeui) — source code and issues
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
AGPL-3.0-or-later
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
FROM docker/sandbox-templates:claude-code
|
|
||||||
|
|
||||||
USER root
|
|
||||||
COPY shared/install-cloudcli.sh /tmp/install-cloudcli.sh
|
|
||||||
RUN chmod +x /tmp/install-cloudcli.sh && /tmp/install-cloudcli.sh
|
|
||||||
|
|
||||||
USER agent
|
|
||||||
RUN npm install -g @cloudcli-ai/cloudcli && cloudcli --version
|
|
||||||
|
|
||||||
COPY --chown=agent:agent shared/start-cloudcli.sh /home/agent/.cloudcli-start.sh
|
|
||||||
RUN echo '. ~/.cloudcli-start.sh' >> /home/agent/.bashrc
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
FROM docker/sandbox-templates:codex
|
|
||||||
|
|
||||||
USER root
|
|
||||||
COPY shared/install-cloudcli.sh /tmp/install-cloudcli.sh
|
|
||||||
RUN chmod +x /tmp/install-cloudcli.sh && /tmp/install-cloudcli.sh
|
|
||||||
|
|
||||||
USER agent
|
|
||||||
RUN npm install -g @cloudcli-ai/cloudcli && cloudcli --version
|
|
||||||
|
|
||||||
COPY --chown=agent:agent shared/start-cloudcli.sh /home/agent/.cloudcli-start.sh
|
|
||||||
RUN echo '. ~/.cloudcli-start.sh' >> /home/agent/.bashrc
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
FROM docker/sandbox-templates:gemini
|
|
||||||
|
|
||||||
USER root
|
|
||||||
COPY shared/install-cloudcli.sh /tmp/install-cloudcli.sh
|
|
||||||
RUN chmod +x /tmp/install-cloudcli.sh && /tmp/install-cloudcli.sh
|
|
||||||
|
|
||||||
USER agent
|
|
||||||
RUN npm install -g @cloudcli-ai/cloudcli && cloudcli --version
|
|
||||||
|
|
||||||
COPY --chown=agent:agent shared/start-cloudcli.sh /home/agent/.cloudcli-start.sh
|
|
||||||
RUN echo '. ~/.cloudcli-start.sh' >> /home/agent/.bashrc
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Install build tools needed for native modules (node-pty, better-sqlite3, bcrypt)
|
|
||||||
# Node.js is already provided by the sandbox base image
|
|
||||||
apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
build-essential python3 python3-setuptools \
|
|
||||||
jq ripgrep sqlite3 zip unzip tree vim-tiny
|
|
||||||
|
|
||||||
# Clean up apt cache to reduce image size
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Auto-start CloudCLI server in background if not already running.
|
|
||||||
# This script is sourced from ~/.bashrc on sandbox shell open.
|
|
||||||
|
|
||||||
if ! pgrep -f "server/index.js" > /dev/null 2>&1; then
|
|
||||||
nohup cloudcli start --port 3001 > /tmp/cloudcli-ui.log 2>&1 &
|
|
||||||
disown
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo " CloudCLI is starting on port 3001..."
|
|
||||||
echo ""
|
|
||||||
echo " Forward the port from another terminal:"
|
|
||||||
echo " sbx ports <sandbox-name> --publish 3001:3001"
|
|
||||||
echo ""
|
|
||||||
echo " Then open: http://localhost:3001"
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
144
docs/backend/endpoint-inventory.csv
Normal file
144
docs/backend/endpoint-inventory.csv
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
transport,method,path,tag,authMode,sourceFile,sourceLine,purpose,consumerFiles,pathParams,queryParams,bodyHints,successShape,errorShape,sideEffects,priority
|
||||||
|
"http","GET","/health","System","public","server/index.js","345","Expose server health, timestamp, and install mode for diagnostics.","src/hooks/useVersionCheck.ts","","","","Structured JSON object response.","Handler-specific error behavior.","Read-only backend query.","low"
|
||||||
|
"http","POST","/api/system/update","System","bearer_token","server/index.js","425","Run the application update workflow on the host machine.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.","low"
|
||||||
|
"http","GET","/api/projects","Projects","bearer_token","server/index.js","491","List detected projects and workspaces.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON payload returned directly from service logic.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||||
|
"http","GET","/api/projects/:projectName/sessions","Sessions","bearer_token","server/index.js","500","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","offset; try {
|
||||||
|
const { limit","","JSON payload returned directly from service logic.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||||
|
"http","GET","/api/projects/:projectName/sessions/:sessionId/messages","Sessions","bearer_token","server/index.js","512","Return paginated messages for a stored session.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; sessionId","limit; offset","","Structured JSON object response.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||||
|
"http","PUT","/api/projects/:projectName/rename","Projects","bearer_token","server/index.js","537","PUT /api/projects/:projectName/rename for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","try {
|
||||||
|
const { displayName","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||||
|
"http","DELETE","/api/projects/:projectName/sessions/:sessionId","Sessions","bearer_token","server/index.js","548","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; sessionId","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||||
|
"http","PUT","/api/sessions/:sessionId/rename","Sessions","bearer_token","server/index.js","563","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","","provider; summary","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.","low"
|
||||||
|
"http","DELETE","/api/projects/:projectName","Projects","bearer_token","server/index.js","589","DELETE /api/projects/:projectName for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","force","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||||
|
"http","POST","/api/projects/create","Projects","bearer_token","server/index.js","601","Manually add a project path to the workspace list.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","try {
|
||||||
|
const { path","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||||
|
"sse","GET","/api/search/conversations","Sessions","bearer_token","server/index.js","618","Search conversation history across stored projects and stream results.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","limit; q","","Server-sent events stream with progress/result/error events.","Streamed error event or JSON error fallback.","Read-only backend query.","high"
|
||||||
|
"http","GET","/api/browse-filesystem","Realtime","bearer_token","server/index.js","674","Browse local directories so the UI can suggest workspace locations.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","try {
|
||||||
|
const { path","","Structured JSON object response.","JSON object with error message and optional details.","Read-only backend query.","low"
|
||||||
|
"http","POST","/api/create-folder","Projects","bearer_token","server/index.js","754","Create a new directory on the local filesystem.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","try {
|
||||||
|
const { path","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.","low"
|
||||||
|
"http","GET","/api/projects/:projectName/file","Files","bearer_token","server/index.js","795","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","filePath","","Structured JSON object response.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||||
|
"http","GET","/api/projects/:projectName/files/content","Files","bearer_token","server/index.js","835","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","path","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||||
|
"http","PUT","/api/projects/:projectName/file","Files","bearer_token","server/index.js","888","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","content; filePath","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||||
|
"http","GET","/api/projects/:projectName/files","Files","bearer_token","server/index.js","937","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","JSON payload returned directly from service logic.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||||
|
"http","POST","/api/projects/:projectName/files/create","Files","bearer_token","server/index.js","1016","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","name; path; type","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||||
|
"http","PUT","/api/projects/:projectName/files/rename","Files","bearer_token","server/index.js","1093","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","newName; oldPath","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||||
|
"http","DELETE","/api/projects/:projectName/files","Files","bearer_token","server/index.js","1170","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","path; relativePaths; targetPath; type","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||||
|
"http","POST","/api/projects/:projectName/files/upload","Files","bearer_token","server/index.js","1396","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Mixed response shape; inspect handler during refactor.","Handler-specific error behavior.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||||
|
"http","POST","/api/transcribe","Realtime","bearer_token","server/index.js","1964","Transcribe uploaded audio and optionally enhance the result for prompts or tasks.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","mode","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Processes uploaded files and external model responses.","low"
|
||||||
|
"http","POST","/api/projects/:projectName/upload-images","Files","bearer_token","server/index.js","2113","Upload images for chat use and return browser-safe data URLs.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||||
|
"http","GET","/api/projects/:projectName/sessions/:sessionId/token-usage","Sessions","bearer_token","server/index.js","2198","Report token usage for a stored provider session.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; sessionId","provider","","Structured JSON object response.","JSON object with error message and optional details.","Touches local workspace files or directories.","high"
|
||||||
|
"http","GET","*","System","public","server/index.js","2386","Serve the React application fallback for non-API routes.","","","","","Static file or HTML response.","JSON error response with HTTP status code.","Read-only backend query.","low"
|
||||||
|
"http","GET","/api/auth/status","Auth","public","server/routes/auth.js","9","Report whether authentication is configured.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","POST","/api/auth/register","Auth","public","server/routes/auth.js","23","Create the first local user account.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","password; try {
|
||||||
|
const { username","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","POST","/api/auth/login","Auth","public","server/routes/auth.js","82","Authenticate a local user and issue a token.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","password; try {
|
||||||
|
const { username","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","GET","/api/auth/user","Auth","bearer_token","server/routes/auth.js","122","Return the currently authenticated user.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","Handler-specific error behavior.","Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","POST","/api/auth/logout","Auth","bearer_token","server/routes/auth.js","129","Invalidate the current authenticated session.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON object with an explicit success flag and payload.","Handler-specific error behavior.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","POST","/api/projects/create-workspace","Projects","bearer_token","server/routes/projects.js","175","Create or register a workspace and optionally clone a GitHub repository into it.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","githubTokenId; githubUrl; newGithubToken; path; try {
|
||||||
|
const { workspaceType","Structured JSON object response.","JSON validation error response.","Mutates backend or external state.; Touches local workspace files or directories.","high"
|
||||||
|
"sse","GET","/api/projects/clone-progress","Projects","bearer_token","server/routes/projects.js","335","Stream workspace cloning progress events to the frontend.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { path; githubTokenId; githubUrl; newGithubToken","","Server-sent events stream with progress/result/error events.","Streamed error event or JSON error fallback.","Touches local workspace files or directories.","high"
|
||||||
|
"http","GET","/api/git/status","Git","bearer_token","server/routes/git.js","291","Read git status information for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||||
|
"http","GET","/api/git/diff","Git","bearer_token","server/routes/git.js","354","Return git diff output for a project or file.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project; file","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||||
|
"http","GET","/api/git/file-with-diff","Git","bearer_token","server/routes/git.js","437","Read, write, create, rename, delete, or upload project files.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project; file","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.; Touches local workspace files or directories.","high"
|
||||||
|
"http","POST","/api/git/initial-commit","Git","bearer_token","server/routes/git.js","517","POST /api/git/initial-commit for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","POST","/api/git/commit","Git","bearer_token","server/routes/git.js","561","POST /api/git/commit for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project; files; message","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","POST","/api/git/revert-local-commit","Git","bearer_token","server/routes/git.js","592","POST /api/git/revert-local-commit for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","GET","/api/git/branches","Git","bearer_token","server/routes/git.js","639","List git branches for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||||
|
"http","POST","/api/git/checkout","Git","bearer_token","server/routes/git.js","681","POST /api/git/checkout for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","branch; const { project","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","POST","/api/git/create-branch","Git","bearer_token","server/routes/git.js","703","POST /api/git/create-branch for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","branch; const { project","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","GET","/api/git/commits","Git","bearer_token","server/routes/git.js","725","List recent commits for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project; limit","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||||
|
"http","GET","/api/git/commit-diff","Git","bearer_token","server/routes/git.js","782","Return diff details for a specific commit.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","commit; const { project","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||||
|
"http","POST","/api/git/generate-commit-message","Git","bearer_token","server/routes/git.js","814","Generate an AI-assisted commit message from the current diff.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project; files; provider","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","GET","/api/git/remote-status","Git","bearer_token","server/routes/git.js","1019","Report remote sync status for a project repository.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","const { project","","Structured JSON object response.","JSON validation error response.","Touches git repositories or local git config.","high"
|
||||||
|
"http","POST","/api/git/fetch","Git","bearer_token","server/routes/git.js","1097","POST /api/git/fetch for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project","JSON object with an explicit success flag and payload.","JSON validation error response.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","POST","/api/git/pull","Git","bearer_token","server/routes/git.js","1138","POST /api/git/pull for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project","Structured JSON object response.","JSON validation error response.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","POST","/api/git/push","Git","bearer_token","server/routes/git.js","1206","POST /api/git/push for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project","Structured JSON object response.","JSON validation error response.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","POST","/api/git/publish","Git","bearer_token","server/routes/git.js","1277","POST /api/git/publish for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","branch; const { project","Structured JSON object response.","JSON validation error response.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","POST","/api/git/discard","Git","bearer_token","server/routes/git.js","1356","POST /api/git/discard for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project; file","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","POST","/api/git/delete-untracked","Git","bearer_token","server/routes/git.js","1410","POST /api/git/delete-untracked for backend runtime support.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","const { project; file","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","high"
|
||||||
|
"http","GET","/api/mcp/cli/list","MCP","bearer_token","server/routes/mcp.js","16","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","POST","/api/mcp/cli/add","MCP","bearer_token","server/routes/mcp.js","59","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","POST","/api/mcp/cli/add-json","MCP","bearer_token","server/routes/mcp.js","142","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","jsonConfig; projectPath; scope; try {
|
||||||
|
const { name","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","DELETE","/api/mcp/cli/remove/:name","MCP","bearer_token","server/routes/mcp.js","235","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","scope","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","GET","/api/mcp/cli/get/:name","MCP","bearer_token","server/routes/mcp.js","305","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","GET","/api/mcp/config/read","MCP","bearer_token","server/routes/mcp.js","348","Manage Claude MCP CLI and configuration state.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","GET","/api/cursor/config","Providers","bearer_token","server/routes/cursor.js","15","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||||
|
"http","POST","/api/cursor/config","Providers","bearer_token","server/routes/cursor.js","59","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","model; try {
|
||||||
|
const { permissions","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||||
|
"http","GET","/api/cursor/mcp","Providers","bearer_token","server/routes/cursor.js","122","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","POST","/api/cursor/mcp/add","Providers","bearer_token","server/routes/cursor.js","183","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","DELETE","/api/cursor/mcp/:name","Providers","bearer_token","server/routes/cursor.js","245","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","POST","/api/cursor/mcp/add-json","Providers","bearer_token","server/routes/cursor.js","292","Manage Cursor configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","jsonConfig; try {
|
||||||
|
const { name","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","GET","/api/cursor/sessions","Providers","bearer_token","server/routes/cursor.js","348","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","try {
|
||||||
|
const { projectPath","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||||
|
"http","GET","/api/cursor/sessions/:sessionId","Providers","bearer_token","server/routes/cursor.js","583","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","projectPath","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||||
|
"http","GET","/api/taskmaster/installation-status","TaskMaster","bearer_token","server/routes/taskmaster.js","243","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","GET","/api/taskmaster/detect/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","278","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","JSON payload returned directly from service logic.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","GET","/api/taskmaster/detect-all","TaskMaster","bearer_token","server/routes/taskmaster.js","350","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","POST","/api/taskmaster/initialize/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","434","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","rules","Mixed response shape; inspect handler during refactor.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","GET","/api/taskmaster/next/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","460","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","GET","/api/taskmaster/tasks/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","570","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","GET","/api/taskmaster/prd/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","685","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","POST","/api/taskmaster/prd/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","761","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","content; fileName","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","GET","/api/taskmaster/prd/:projectName/:fileName","TaskMaster","bearer_token","server/routes/taskmaster.js","846","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; fileName","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","DELETE","/api/taskmaster/prd/:projectName/:fileName","TaskMaster","bearer_token","server/routes/taskmaster.js","911","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; fileName","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","POST","/api/taskmaster/init/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","971","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","POST","/api/taskmaster/add-task/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","1060","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","dependencies; description; priority; prompt; title","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","PUT","/api/taskmaster/update-task/:projectName/:taskId","TaskMaster","bearer_token","server/routes/taskmaster.js","1164","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName; taskId","","description; details; priority; status; title","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","POST","/api/taskmaster/parse-prd/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","1291","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","append; fileName; numTasks","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","GET","/api/taskmaster/prd-templates","TaskMaster","bearer_token","server/routes/taskmaster.js","1392","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","POST","/api/taskmaster/apply-template/:projectName","TaskMaster","bearer_token","server/routes/taskmaster.js","1838","Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","projectName","","","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.; Reads or writes TaskMaster project assets.","high"
|
||||||
|
"http","GET","/api/mcp-utils/taskmaster-server","MCP","bearer_token","server/routes/mcp-utils.js","18","Return MCP helper information used by setup flows.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON payload returned directly from service logic.","JSON error response with HTTP status code.","Reads or writes TaskMaster project assets.; Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","GET","/api/mcp-utils/all-servers","MCP","bearer_token","server/routes/mcp-utils.js","35","Return MCP helper information used by setup flows.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON payload returned directly from service logic.","JSON error response with HTTP status code.","Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","POST","/api/commands/list","Commands","bearer_token","server/routes/commands.js","406","List, load, or execute slash commands available to the chat experience.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","try {
|
||||||
|
const { projectPath","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||||
|
"http","POST","/api/commands/load","Commands","bearer_token","server/routes/commands.js","456","List, load, or execute slash commands available to the chat experience.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","commandPath; try {
|
||||||
|
const { commandPath","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||||
|
"http","POST","/api/commands/execute","Commands","bearer_token","server/routes/commands.js","507","List, load, or execute slash commands available to the chat experience.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","commandPath","Structured JSON object response.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||||
|
"http","GET","/api/settings/api-keys","Settings","bearer_token","server/routes/settings.js","11","Manage local API keys used to access the backend.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","POST","/api/settings/api-keys","Settings","bearer_token","server/routes/settings.js","27","Manage local API keys used to access the backend.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","try {
|
||||||
|
const { keyName","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","DELETE","/api/settings/api-keys/:keyId","Settings","bearer_token","server/routes/settings.js","47","Manage local API keys used to access the backend.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","keyId","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","PATCH","/api/settings/api-keys/:keyId/toggle","Settings","bearer_token","server/routes/settings.js","64","Manage local API keys used to access the backend.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","keyId","","isActive","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","GET","/api/settings/credentials","Settings","bearer_token","server/routes/settings.js","91","Manage stored provider and GitHub credentials.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","try {
|
||||||
|
const { type","","Structured JSON object response.","JSON object with error message and optional details.","Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","POST","/api/settings/credentials","Settings","bearer_token","server/routes/settings.js","104","Manage stored provider and GitHub credentials.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","credentialType; credentialValue; description; try {
|
||||||
|
const { credentialName","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","DELETE","/api/settings/credentials/:credentialId","Settings","bearer_token","server/routes/settings.js","139","Manage stored provider and GitHub credentials.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","credentialId","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","PATCH","/api/settings/credentials/:credentialId/toggle","Settings","bearer_token","server/routes/settings.js","156","Manage stored provider and GitHub credentials.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","credentialId","","isActive","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes local authentication or credential state.","medium"
|
||||||
|
"http","GET","/api/cli/claude/status","CLI Auth","bearer_token","server/routes/cli-auth.js","9","Report local authentication status for provider CLIs.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","low"
|
||||||
|
"http","GET","/api/cli/cursor/status","CLI Auth","bearer_token","server/routes/cli-auth.js","39","Report local authentication status for provider CLIs.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","low"
|
||||||
|
"http","GET","/api/cli/codex/status","CLI Auth","bearer_token","server/routes/cli-auth.js","59","Report local authentication status for provider CLIs.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","low"
|
||||||
|
"http","GET","/api/cli/gemini/status","CLI Auth","bearer_token","server/routes/cli-auth.js","79","Report local authentication status for provider CLIs.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","low"
|
||||||
|
"http","GET","/api/user/git-config","User","bearer_token","server/routes/user.js","28","Read or update stored git identity settings.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Touches git repositories or local git config.","medium"
|
||||||
|
"http","POST","/api/user/git-config","User","bearer_token","server/routes/user.js","57","Read or update stored git identity settings.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","gitEmail; try {
|
||||||
|
const userId = req.user.id;
|
||||||
|
const { gitName","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.; Touches git repositories or local git config.","medium"
|
||||||
|
"http","POST","/api/user/complete-onboarding","User","bearer_token","server/routes/user.js","93","Mark onboarding as completed for the current user.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Mutates backend or external state.","medium"
|
||||||
|
"http","GET","/api/user/onboarding-status","User","bearer_token","server/routes/user.js","108","Return onboarding completion status for the current user.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Read-only backend query.","medium"
|
||||||
|
"http","GET","/api/codex/config","Providers","bearer_token","server/routes/codex.js","23","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||||
|
"http","GET","/api/codex/sessions","Providers","bearer_token","server/routes/codex.js","54","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","try {
|
||||||
|
const { projectPath","","JSON object with an explicit success flag and payload.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||||
|
"http","GET","/api/codex/sessions/:sessionId/messages","Providers","bearer_token","server/routes/codex.js","71","Return paginated messages for a stored session.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","limit; offset","","JSON object with an explicit success flag and payload.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||||
|
"http","DELETE","/api/codex/sessions/:sessionId","Providers","bearer_token","server/routes/codex.js","89","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","","","JSON object with an explicit success flag and payload.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||||
|
"http","GET","/api/codex/mcp/cli/list","Providers","bearer_token","server/routes/codex.js","103","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","POST","/api/codex/mcp/cli/add","Providers","bearer_token","server/routes/codex.js","135","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","DELETE","/api/codex/mcp/cli/remove/:name","Providers","bearer_token","server/routes/codex.js","186","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Mutates backend or external state.; Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","GET","/api/codex/mcp/cli/get/:name","Providers","bearer_token","server/routes/codex.js","220","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","GET","/api/codex/mcp/config/read","Providers","bearer_token","server/routes/codex.js","254","Manage Codex configuration, MCP settings, and stored sessions.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Reads or writes MCP CLI configuration.","medium"
|
||||||
|
"http","GET","/api/gemini/sessions/:sessionId/messages","Providers","bearer_token","server/routes/gemini.js","8","Return paginated messages for a stored session.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","","","Structured JSON object response.","JSON error response with HTTP status code.","Read-only backend query.","medium"
|
||||||
|
"http","DELETE","/api/gemini/sessions/:sessionId","Providers","bearer_token","server/routes/gemini.js","37","List or manage sessions associated with a project or provider.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","sessionId","","","JSON object with an explicit success flag and payload.","JSON error response with HTTP status code.","Mutates backend or external state.","medium"
|
||||||
|
"http","GET","/api/plugins","Plugins","bearer_token","server/routes/plugins.js","27","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","","Structured JSON object response.","JSON object with error message and optional details.","Installs, updates, or serves plugin assets/processes.","medium"
|
||||||
|
"http","GET","/api/plugins/:name/manifest","Plugins","bearer_token","server/routes/plugins.js","40","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","JSON payload returned directly from service logic.","JSON object with error message and optional details.","Installs, updates, or serves plugin assets/processes.","medium"
|
||||||
|
"http","GET","/api/plugins/:name/assets/*","Plugins","bearer_token","server/routes/plugins.js","57","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","Mixed response shape; inspect handler during refactor.","JSON object with error message and optional details.","Installs, updates, or serves plugin assets/processes.","medium"
|
||||||
|
"http","PUT","/api/plugins/:name/enable","Plugins","bearer_token","server/routes/plugins.js","96","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","try {
|
||||||
|
const { enabled","JSON object with an explicit success flag and payload.","JSON object with error message and optional details.","Mutates backend or external state.; Installs, updates, or serves plugin assets/processes.","medium"
|
||||||
|
"http","POST","/api/plugins/install","Plugins","bearer_token","server/routes/plugins.js","136","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","try {
|
||||||
|
const { url","JSON object with an explicit success flag and payload.","JSON validation error response.","Mutates backend or external state.; Installs, updates, or serves plugin assets/processes.","medium"
|
||||||
|
"http","POST","/api/plugins/:name/update","Plugins","bearer_token","server/routes/plugins.js","169","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","JSON object with an explicit success flag and payload.","JSON validation error response.","Mutates backend or external state.; Installs, updates, or serves plugin assets/processes.","medium"
|
||||||
|
"http","DELETE","/api/plugins/:name","Plugins","bearer_token","server/routes/plugins.js","282","List, install, update, serve, enable, or remove plugins.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","name","","","JSON object with an explicit success flag and payload.","JSON validation error response.","Mutates backend or external state.; Installs, updates, or serves plugin assets/processes.","medium"
|
||||||
|
"sse","POST","/api/agent","Agent","api_key_or_platform","server/routes/agent.js","839","Accept external agent jobs that run a provider against a local or cloned project.","src/components/chat/hooks/useChatComposerState.ts; src/components/chat/hooks/useChatProviderState.ts; src/components/chat/hooks/useChatSessionState.ts; src/components/chat/hooks/useSlashCommands.ts; src/components/file-tree/view/ImageViewer.tsx; src/components/git-panel/hooks/useGitPanelController.ts; src/components/git-panel/hooks/useRevertLocalCommit.ts; src/components/onboarding/view/Onboarding.tsx; src/components/plugins/view/PluginIcon.tsx; src/components/plugins/view/PluginTabContent.tsx; src/components/prd-editor/hooks/usePrdSave.ts; src/components/project-creation-wizard/data/workspaceApi.ts; src/components/settings/constants/constants.ts; src/components/settings/hooks/useCredentialsSettings.ts; src/components/settings/hooks/useGitSettings.ts; src/components/settings/hooks/useSettingsController.ts; src/components/version-upgrade/view/VersionUpgradeModal.tsx; src/contexts/PluginsContext.tsx; src/utils/api.js","","","branchName; cleanup; const { githubUrl; createBranch; createPR; githubToken; message; model; projectPath; provider; stream","Server-sent events stream with progress/result/error events.","Streamed error event or JSON error fallback.","Mutates backend or external state.; Invokes external AI providers and may modify project files.","high"
|
||||||
|
5437
docs/backend/endpoint-inventory.json
Normal file
5437
docs/backend/endpoint-inventory.json
Normal file
File diff suppressed because it is too large
Load Diff
217
docs/backend/endpoint-inventory.md
Normal file
217
docs/backend/endpoint-inventory.md
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
# Backend Inventory
|
||||||
|
|
||||||
|
Generated on 2026-03-11T17:31:18.119Z.
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
- HTTP routes: 118
|
||||||
|
- SSE routes: 3
|
||||||
|
- Modular routes: 96
|
||||||
|
- Inline routes: 25
|
||||||
|
- Route files scanned: 16
|
||||||
|
|
||||||
|
## Realtime Contracts
|
||||||
|
|
||||||
|
- Incoming websocket message types (14): abort-session, check-session-status, claude-command, claude-permission-response, codex-command, cursor-abort, cursor-command, cursor-resume, gemini-command, get-active-sessions, get-pending-permissions, init, input, resize
|
||||||
|
- Outgoing websocket message types (7): active-sessions, auth_url, error, output, pending-permissions-response, session-aborted, session-status
|
||||||
|
|
||||||
|
## Agent
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| POST | `/api/agent` | api_key_or_platform | Accept external agent jobs that run a provider against a local or cloned project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/agent.js:839 |
|
||||||
|
|
||||||
|
## Auth
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| POST | `/api/auth/login` | public | Authenticate a local user and issue a token. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/auth.js:82 |
|
||||||
|
| POST | `/api/auth/logout` | bearer_token | Invalidate the current authenticated session. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/auth.js:129 |
|
||||||
|
| POST | `/api/auth/register` | public | Create the first local user account. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/auth.js:23 |
|
||||||
|
| GET | `/api/auth/status` | public | Report whether authentication is configured. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/auth.js:9 |
|
||||||
|
| GET | `/api/auth/user` | bearer_token | Return the currently authenticated user. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/auth.js:122 |
|
||||||
|
|
||||||
|
## CLI Auth
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| GET | `/api/cli/claude/status` | bearer_token | Report local authentication status for provider CLIs. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cli-auth.js:9 |
|
||||||
|
| GET | `/api/cli/codex/status` | bearer_token | Report local authentication status for provider CLIs. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cli-auth.js:59 |
|
||||||
|
| GET | `/api/cli/cursor/status` | bearer_token | Report local authentication status for provider CLIs. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cli-auth.js:39 |
|
||||||
|
| GET | `/api/cli/gemini/status` | bearer_token | Report local authentication status for provider CLIs. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cli-auth.js:79 |
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| POST | `/api/commands/execute` | bearer_token | List, load, or execute slash commands available to the chat experience. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/commands.js:507 |
|
||||||
|
| POST | `/api/commands/list` | bearer_token | List, load, or execute slash commands available to the chat experience. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/commands.js:406 |
|
||||||
|
| POST | `/api/commands/load` | bearer_token | List, load, or execute slash commands available to the chat experience. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/commands.js:456 |
|
||||||
|
|
||||||
|
## Files
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| GET | `/api/projects/:projectName/file` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:795 |
|
||||||
|
| PUT | `/api/projects/:projectName/file` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:888 |
|
||||||
|
| GET | `/api/projects/:projectName/files` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:937 |
|
||||||
|
| DELETE | `/api/projects/:projectName/files` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:1170 |
|
||||||
|
| GET | `/api/projects/:projectName/files/content` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:835 |
|
||||||
|
| POST | `/api/projects/:projectName/files/create` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:1016 |
|
||||||
|
| PUT | `/api/projects/:projectName/files/rename` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:1093 |
|
||||||
|
| POST | `/api/projects/:projectName/files/upload` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:1396 |
|
||||||
|
| POST | `/api/projects/:projectName/upload-images` | bearer_token | Upload images for chat use and return browser-safe data URLs. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:2113 |
|
||||||
|
|
||||||
|
## Git
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| GET | `/api/git/branches` | bearer_token | List git branches for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:639 |
|
||||||
|
| POST | `/api/git/checkout` | bearer_token | POST /api/git/checkout for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:681 |
|
||||||
|
| POST | `/api/git/commit` | bearer_token | POST /api/git/commit for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:561 |
|
||||||
|
| GET | `/api/git/commit-diff` | bearer_token | Return diff details for a specific commit. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:782 |
|
||||||
|
| GET | `/api/git/commits` | bearer_token | List recent commits for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:725 |
|
||||||
|
| POST | `/api/git/create-branch` | bearer_token | POST /api/git/create-branch for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:703 |
|
||||||
|
| POST | `/api/git/delete-untracked` | bearer_token | POST /api/git/delete-untracked for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1410 |
|
||||||
|
| GET | `/api/git/diff` | bearer_token | Return git diff output for a project or file. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:354 |
|
||||||
|
| POST | `/api/git/discard` | bearer_token | POST /api/git/discard for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1356 |
|
||||||
|
| POST | `/api/git/fetch` | bearer_token | POST /api/git/fetch for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1097 |
|
||||||
|
| GET | `/api/git/file-with-diff` | bearer_token | Read, write, create, rename, delete, or upload project files. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:437 |
|
||||||
|
| POST | `/api/git/generate-commit-message` | bearer_token | Generate an AI-assisted commit message from the current diff. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:814 |
|
||||||
|
| POST | `/api/git/initial-commit` | bearer_token | POST /api/git/initial-commit for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:517 |
|
||||||
|
| POST | `/api/git/publish` | bearer_token | POST /api/git/publish for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1277 |
|
||||||
|
| POST | `/api/git/pull` | bearer_token | POST /api/git/pull for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1138 |
|
||||||
|
| POST | `/api/git/push` | bearer_token | POST /api/git/push for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1206 |
|
||||||
|
| GET | `/api/git/remote-status` | bearer_token | Report remote sync status for a project repository. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:1019 |
|
||||||
|
| POST | `/api/git/revert-local-commit` | bearer_token | POST /api/git/revert-local-commit for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:592 |
|
||||||
|
| GET | `/api/git/status` | bearer_token | Read git status information for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/git.js:291 |
|
||||||
|
|
||||||
|
## MCP
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| GET | `/api/mcp-utils/all-servers` | bearer_token | Return MCP helper information used by setup flows. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp-utils.js:35 |
|
||||||
|
| GET | `/api/mcp-utils/taskmaster-server` | bearer_token | Return MCP helper information used by setup flows. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp-utils.js:18 |
|
||||||
|
| POST | `/api/mcp/cli/add` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:59 |
|
||||||
|
| POST | `/api/mcp/cli/add-json` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:142 |
|
||||||
|
| GET | `/api/mcp/cli/get/:name` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:305 |
|
||||||
|
| GET | `/api/mcp/cli/list` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:16 |
|
||||||
|
| DELETE | `/api/mcp/cli/remove/:name` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:235 |
|
||||||
|
| GET | `/api/mcp/config/read` | bearer_token | Manage Claude MCP CLI and configuration state. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/mcp.js:348 |
|
||||||
|
|
||||||
|
## Plugins
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| GET | `/api/plugins` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:27 |
|
||||||
|
| DELETE | `/api/plugins/:name` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:282 |
|
||||||
|
| GET | `/api/plugins/:name/assets/*` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:57 |
|
||||||
|
| PUT | `/api/plugins/:name/enable` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:96 |
|
||||||
|
| GET | `/api/plugins/:name/manifest` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:40 |
|
||||||
|
| POST | `/api/plugins/:name/update` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:169 |
|
||||||
|
| POST | `/api/plugins/install` | bearer_token | List, install, update, serve, enable, or remove plugins. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/plugins.js:136 |
|
||||||
|
|
||||||
|
## Projects
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| POST | `/api/create-folder` | bearer_token | Create a new directory on the local filesystem. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:754 |
|
||||||
|
| GET | `/api/projects` | bearer_token | List detected projects and workspaces. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:491 |
|
||||||
|
| DELETE | `/api/projects/:projectName` | bearer_token | DELETE /api/projects/:projectName for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:589 |
|
||||||
|
| PUT | `/api/projects/:projectName/rename` | bearer_token | PUT /api/projects/:projectName/rename for backend runtime support. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:537 |
|
||||||
|
| GET | `/api/projects/clone-progress` | bearer_token | Stream workspace cloning progress events to the frontend. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/projects.js:335 |
|
||||||
|
| POST | `/api/projects/create` | bearer_token | Manually add a project path to the workspace list. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:601 |
|
||||||
|
| POST | `/api/projects/create-workspace` | bearer_token | Create or register a workspace and optionally clone a GitHub repository into it. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/projects.js:175 |
|
||||||
|
|
||||||
|
## Providers
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| GET | `/api/codex/config` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:23 |
|
||||||
|
| POST | `/api/codex/mcp/cli/add` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:135 |
|
||||||
|
| GET | `/api/codex/mcp/cli/get/:name` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:220 |
|
||||||
|
| GET | `/api/codex/mcp/cli/list` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:103 |
|
||||||
|
| DELETE | `/api/codex/mcp/cli/remove/:name` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:186 |
|
||||||
|
| GET | `/api/codex/mcp/config/read` | bearer_token | Manage Codex configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:254 |
|
||||||
|
| GET | `/api/codex/sessions` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:54 |
|
||||||
|
| DELETE | `/api/codex/sessions/:sessionId` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:89 |
|
||||||
|
| GET | `/api/codex/sessions/:sessionId/messages` | bearer_token | Return paginated messages for a stored session. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/codex.js:71 |
|
||||||
|
| GET | `/api/cursor/config` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:15 |
|
||||||
|
| POST | `/api/cursor/config` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:59 |
|
||||||
|
| GET | `/api/cursor/mcp` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:122 |
|
||||||
|
| DELETE | `/api/cursor/mcp/:name` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:245 |
|
||||||
|
| POST | `/api/cursor/mcp/add` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:183 |
|
||||||
|
| POST | `/api/cursor/mcp/add-json` | bearer_token | Manage Cursor configuration, MCP settings, and stored sessions. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:292 |
|
||||||
|
| GET | `/api/cursor/sessions` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:348 |
|
||||||
|
| GET | `/api/cursor/sessions/:sessionId` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/cursor.js:583 |
|
||||||
|
| DELETE | `/api/gemini/sessions/:sessionId` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/gemini.js:37 |
|
||||||
|
| GET | `/api/gemini/sessions/:sessionId/messages` | bearer_token | Return paginated messages for a stored session. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/gemini.js:8 |
|
||||||
|
|
||||||
|
## Realtime
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| GET | `/api/browse-filesystem` | bearer_token | Browse local directories so the UI can suggest workspace locations. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:674 |
|
||||||
|
| POST | `/api/transcribe` | bearer_token | Transcribe uploaded audio and optionally enhance the result for prompts or tasks. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:1964 |
|
||||||
|
|
||||||
|
## Sessions
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| GET | `/api/projects/:projectName/sessions` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:500 |
|
||||||
|
| DELETE | `/api/projects/:projectName/sessions/:sessionId` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:548 |
|
||||||
|
| GET | `/api/projects/:projectName/sessions/:sessionId/messages` | bearer_token | Return paginated messages for a stored session. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:512 |
|
||||||
|
| GET | `/api/projects/:projectName/sessions/:sessionId/token-usage` | bearer_token | Report token usage for a stored provider session. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:2198 |
|
||||||
|
| GET | `/api/search/conversations` | bearer_token | Search conversation history across stored projects and stream results. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:618 |
|
||||||
|
| PUT | `/api/sessions/:sessionId/rename` | bearer_token | List or manage sessions associated with a project or provider. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:563 |
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| GET | `/api/settings/api-keys` | bearer_token | Manage local API keys used to access the backend. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:11 |
|
||||||
|
| POST | `/api/settings/api-keys` | bearer_token | Manage local API keys used to access the backend. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:27 |
|
||||||
|
| DELETE | `/api/settings/api-keys/:keyId` | bearer_token | Manage local API keys used to access the backend. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:47 |
|
||||||
|
| PATCH | `/api/settings/api-keys/:keyId/toggle` | bearer_token | Manage local API keys used to access the backend. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:64 |
|
||||||
|
| GET | `/api/settings/credentials` | bearer_token | Manage stored provider and GitHub credentials. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:91 |
|
||||||
|
| POST | `/api/settings/credentials` | bearer_token | Manage stored provider and GitHub credentials. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:104 |
|
||||||
|
| DELETE | `/api/settings/credentials/:credentialId` | bearer_token | Manage stored provider and GitHub credentials. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:139 |
|
||||||
|
| PATCH | `/api/settings/credentials/:credentialId/toggle` | bearer_token | Manage stored provider and GitHub credentials. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/settings.js:156 |
|
||||||
|
|
||||||
|
## System
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| GET | `*` | public | Serve the React application fallback for non-API routes. | - | server/index.js:2386 |
|
||||||
|
| POST | `/api/system/update` | bearer_token | Run the application update workflow on the host machine. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/index.js:425 |
|
||||||
|
| GET | `/health` | public | Expose server health, timestamp, and install mode for diagnostics. | src/hooks/useVersionCheck.ts | server/index.js:345 |
|
||||||
|
|
||||||
|
## TaskMaster
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| POST | `/api/taskmaster/add-task/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:1060 |
|
||||||
|
| POST | `/api/taskmaster/apply-template/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:1838 |
|
||||||
|
| GET | `/api/taskmaster/detect-all` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:350 |
|
||||||
|
| GET | `/api/taskmaster/detect/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:278 |
|
||||||
|
| POST | `/api/taskmaster/init/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:971 |
|
||||||
|
| POST | `/api/taskmaster/initialize/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:434 |
|
||||||
|
| GET | `/api/taskmaster/installation-status` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:243 |
|
||||||
|
| GET | `/api/taskmaster/next/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:460 |
|
||||||
|
| POST | `/api/taskmaster/parse-prd/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:1291 |
|
||||||
|
| GET | `/api/taskmaster/prd-templates` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:1392 |
|
||||||
|
| GET | `/api/taskmaster/prd/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:685 |
|
||||||
|
| POST | `/api/taskmaster/prd/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:761 |
|
||||||
|
| GET | `/api/taskmaster/prd/:projectName/:fileName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:846 |
|
||||||
|
| DELETE | `/api/taskmaster/prd/:projectName/:fileName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:911 |
|
||||||
|
| GET | `/api/taskmaster/tasks/:projectName` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:570 |
|
||||||
|
| PUT | `/api/taskmaster/update-task/:projectName/:taskId` | bearer_token | Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/taskmaster.js:1164 |
|
||||||
|
|
||||||
|
## User
|
||||||
|
|
||||||
|
| Method | Path | Auth | Purpose | Consumers | Source |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| POST | `/api/user/complete-onboarding` | bearer_token | Mark onboarding as completed for the current user. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/user.js:93 |
|
||||||
|
| GET | `/api/user/git-config` | bearer_token | Read or update stored git identity settings. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/user.js:28 |
|
||||||
|
| POST | `/api/user/git-config` | bearer_token | Read or update stored git identity settings. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/user.js:57 |
|
||||||
|
| GET | `/api/user/onboarding-status` | bearer_token | Return onboarding completion status for the current user. | src/components/chat/hooks/useChatComposerState.ts<br>src/components/chat/hooks/useChatProviderState.ts<br>src/components/chat/hooks/useChatSessionState.ts<br>src/components/chat/hooks/useSlashCommands.ts<br>src/components/file-tree/view/ImageViewer.tsx<br>src/components/git-panel/hooks/useGitPanelController.ts<br>src/components/git-panel/hooks/useRevertLocalCommit.ts<br>src/components/onboarding/view/Onboarding.tsx<br>src/components/plugins/view/PluginIcon.tsx<br>src/components/plugins/view/PluginTabContent.tsx<br>src/components/prd-editor/hooks/usePrdSave.ts<br>src/components/project-creation-wizard/data/workspaceApi.ts<br>src/components/settings/constants/constants.ts<br>src/components/settings/hooks/useCredentialsSettings.ts<br>src/components/settings/hooks/useGitSettings.ts<br>src/components/settings/hooks/useSettingsController.ts<br>src/components/version-upgrade/view/VersionUpgradeModal.tsx<br>src/contexts/PluginsContext.tsx<br>src/utils/api.js | server/routes/user.js:108 |
|
||||||
314
docs/backend/input-parsing-cross-platform.md
Normal file
314
docs/backend/input-parsing-cross-platform.md
Normal file
@@ -0,0 +1,314 @@
|
|||||||
|
# Cross-Platform Input Parsing Notes
|
||||||
|
## Why This Matters In This Repo
|
||||||
|
CloudCLI is not only an HTTP API plus React UI. From the README and current backend layout, it also launches CLIs, keeps interactive terminal sessions alive, reads and writes local files, parses process output, and forwards terminal input from the browser into local shells. That puts the backend on the boundary between browser input, terminal behavior, child process behavior, and filesystem behavior. Linux and Windows differ at each of those boundaries.
|
||||||
|
|
||||||
|
For the TypeScript migration, the OS adapter layer now lives in:
|
||||||
|
- [server/src/shared/platform/index.ts](/c:/Users/OMEN6/Desktop/Projects/Paid/ClaudeCodeUI%20-%20Siteboon/claudecodeui/server/src/shared/platform/index.ts)
|
||||||
|
|
||||||
|
Use those helpers in new `server/src` code so feature modules do not branch on the operating system.
|
||||||
|
|
||||||
|
## Assumptions
|
||||||
|
- The legacy runtime in `server/index.js` stays untouched for now.
|
||||||
|
- New backend code will be added under `server/src`.
|
||||||
|
- Node.js 22 is the baseline because the README already requires Node 22+.
|
||||||
|
- The main instability is text handling around shells, streams, and files, not business logic.
|
||||||
|
|
||||||
|
## Where Parsing Happens In This Repo
|
||||||
|
- `server/index.js`: PTY shell input/output and session reuse
|
||||||
|
- `server/cursor-cli.js`: streaming line-delimited JSON from `cursor-agent`
|
||||||
|
- `server/gemini-response-handler.js`: incremental parsing of Gemini JSON lines
|
||||||
|
- `server/routes/mcp.js` and `server/routes/codex.js`: parsing human-readable CLI output
|
||||||
|
- `server/cli.js` and `server/load-env.js`: parsing command-line args and `.env` text
|
||||||
|
- `server/routes/git.js` and related routes: parsing Git stdout line by line
|
||||||
|
|
||||||
|
Those are not all the same problem. In this repo, "input parsing" means terminal input parsing, stream parsing, file parsing, shell command construction, and path normalization.
|
||||||
|
|
||||||
|
## Core Terms
|
||||||
|
### Process
|
||||||
|
A process is a running program such as `node server/start.js`, `git`, `codex`, or `cursor-agent`. When your backend launches one of these, the backend is the parent process and the launched program is the child process.
|
||||||
|
|
||||||
|
### Child Process
|
||||||
|
A child process is a process started by another process. Examples:
|
||||||
|
- CloudCLI launches `git status`
|
||||||
|
- CloudCLI launches `codex mcp list`
|
||||||
|
- CloudCLI launches `cursor-agent --output-format stream-json`
|
||||||
|
|
||||||
|
Important point: a child process usually does not hand you one final string. It emits output over time.
|
||||||
|
|
||||||
|
### stdin, stdout, stderr
|
||||||
|
These are the three standard streams:
|
||||||
|
- `stdin`: data going into the process
|
||||||
|
- `stdout`: normal output coming out
|
||||||
|
- `stderr`: diagnostics, warnings, and errors
|
||||||
|
|
||||||
|
Node example:
|
||||||
|
```ts
|
||||||
|
const child = spawn('git', ['status']);
|
||||||
|
child.stdout.on('data', (chunk) => {
|
||||||
|
// normal output from git
|
||||||
|
});
|
||||||
|
child.stderr.on('data', (chunk) => {
|
||||||
|
// warnings or errors
|
||||||
|
});
|
||||||
|
child.stdin.write('yes\n');
|
||||||
|
child.stdin.end();
|
||||||
|
```
|
||||||
|
|
||||||
|
Repo examples:
|
||||||
|
- terminal keystrokes go to `stdin`
|
||||||
|
- `cursor-agent` JSON events arrive on `stdout`
|
||||||
|
- many CLI failures appear on `stderr`
|
||||||
|
|
||||||
|
### TTY and PTY
|
||||||
|
- `TTY`: a terminal device
|
||||||
|
- `PTY`: a pseudo-terminal, meaning software that behaves like a terminal
|
||||||
|
|
||||||
|
Why it matters:
|
||||||
|
- `spawn()` is best for non-interactive commands like `git status`
|
||||||
|
- `node-pty` is best for interactive shells like PowerShell or bash sessions
|
||||||
|
|
||||||
|
Repo example: `server/index.js` uses `node-pty` for the integrated shell because agents and shells expect terminal behavior, not just plain pipes.
|
||||||
|
|
||||||
|
### argv
|
||||||
|
`argv` means argument vector: the list of command-line arguments passed to a program.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```ts
|
||||||
|
spawn('git', ['log', '--oneline', '-5']);
|
||||||
|
```
|
||||||
|
|
||||||
|
Here the executable is `git` and the argv is `['log', '--oneline', '-5']`. This is safer than building one big shell string because Node passes arguments directly instead of asking a shell to reinterpret them.
|
||||||
|
|
||||||
|
### cwd
|
||||||
|
`cwd` means current working directory. Examples:
|
||||||
|
- run `git status` in the project root
|
||||||
|
- run `claude mcp add --scope local` inside the current project
|
||||||
|
- run a terminal session inside a selected workspace
|
||||||
|
|
||||||
|
If `cwd` is wrong, parsing may look broken even when the parser is correct, because the command itself is operating in the wrong place.
|
||||||
|
|
||||||
|
### Buffer, String, and Decoding
|
||||||
|
A `Buffer` is raw bytes. A string is decoded text. Processes emit bytes first, then you decode them, and only after that should you parse lines, JSON, or tokens.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```ts
|
||||||
|
child.stdout.on('data', (chunk: Buffer) => {
|
||||||
|
const text = chunk.toString('utf8');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Line Ending
|
||||||
|
A line ending marks the end of a text line:
|
||||||
|
- Linux/macOS usually use LF: `\n`
|
||||||
|
- Windows often uses CRLF: `\r\n`
|
||||||
|
- older tools sometimes emit CR alone: `\r`
|
||||||
|
|
||||||
|
Classic bug:
|
||||||
|
```ts
|
||||||
|
'a\r\nb\r\n'.split('\n');
|
||||||
|
// ['a\r', 'b\r', '']
|
||||||
|
```
|
||||||
|
|
||||||
|
That hidden trailing `\r` is one of the most common Windows parsing bugs.
|
||||||
|
|
||||||
|
### BOM
|
||||||
|
BOM means byte order mark. In UTF-8 text it appears as `\uFEFF` at the start. Typical failures:
|
||||||
|
- first key becomes `\uFEFFNAME` instead of `NAME`
|
||||||
|
- JSON parsing fails because the first character is not what the parser expected
|
||||||
|
- `.env` parsing silently produces the wrong first variable name
|
||||||
|
|
||||||
|
The adapter layer strips BOM explicitly for that reason.
|
||||||
|
|
||||||
|
### Chunk
|
||||||
|
A chunk is one partial piece of stream data. Chunks are transport boundaries, not logical message boundaries. Important rules:
|
||||||
|
- one line can arrive in multiple chunks
|
||||||
|
- one chunk can contain many lines
|
||||||
|
- one JSON object can be split across chunk boundaries
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```txt
|
||||||
|
Chunk 1: {"type":"message","text":"hel
|
||||||
|
Chunk 2: lo"}\r\n{"type":"message","text":"next"}\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
If you parse each chunk independently, you corrupt the first JSON object.
|
||||||
|
|
||||||
|
## The Backend Parsing Lifecycle
|
||||||
|
Most backend parsing problems in this repo can be viewed as a four-step pipeline:
|
||||||
|
1. Receive raw bytes or raw text.
|
||||||
|
2. Normalize transport details.
|
||||||
|
3. Parse business structure.
|
||||||
|
4. Return normalized data to the rest of the app.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
- file bytes -> UTF-8 string -> normalize line endings -> split lines -> parse fields
|
||||||
|
- stdout chunks -> accumulate partial lines -> parse JSON per line -> emit events
|
||||||
|
- browser terminal input -> normalize Enter/newlines -> write to PTY
|
||||||
|
|
||||||
|
The operating system mainly affects step 2. That is why the new adapter layer exists.
|
||||||
|
|
||||||
|
## Linux vs Windows Differences That Usually Matter
|
||||||
|
### 1. Newlines In Files And Process Output
|
||||||
|
Linux usually gives LF. Windows often gives CRLF. Some tools mix them.
|
||||||
|
|
||||||
|
Bad pattern:
|
||||||
|
```ts
|
||||||
|
const lines = output.split('\n');
|
||||||
|
```
|
||||||
|
|
||||||
|
Safer pattern:
|
||||||
|
```ts
|
||||||
|
import { splitLines } from '@/shared/platform/index.js';
|
||||||
|
|
||||||
|
const lines = splitLines(output, {
|
||||||
|
preserveEmptyLines: false,
|
||||||
|
trimTrailingEmptyLine: true,
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `splitLines()` when you already have the whole string in memory.
|
||||||
|
|
||||||
|
### 2. Chunked Streams
|
||||||
|
A process stream is not line-oriented by default.
|
||||||
|
|
||||||
|
Bad pattern:
|
||||||
|
```ts
|
||||||
|
child.stdout.on('data', (chunk) => {
|
||||||
|
const event = JSON.parse(chunk.toString());
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
This fails when one JSON object is split across chunks.
|
||||||
|
|
||||||
|
Safer pattern:
|
||||||
|
```ts
|
||||||
|
import { createStreamLineAccumulator } from '@/shared/platform/index.js';
|
||||||
|
|
||||||
|
const lines = createStreamLineAccumulator({ preserveEmptyLines: false });
|
||||||
|
child.stdout.on('data', (chunk) => {
|
||||||
|
for (const line of lines.push(chunk)) {
|
||||||
|
const event = JSON.parse(line);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
child.on('close', () => {
|
||||||
|
for (const line of lines.flush()) {
|
||||||
|
const event = JSON.parse(line);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Use this for Cursor, Gemini, JSONL, NDJSON, or any line-based CLI protocol.
|
||||||
|
|
||||||
|
### 3. Shell Syntax And Fallback Logic
|
||||||
|
POSIX shells and PowerShell do not use the same syntax.
|
||||||
|
- POSIX fallback: `cmd1 || cmd2`
|
||||||
|
- PowerShell fallback: `cmd1; if ($LASTEXITCODE -ne 0) { cmd2 }`
|
||||||
|
|
||||||
|
Use:
|
||||||
|
```ts
|
||||||
|
import { buildFallbackCommand, createShellSpawnPlan } from '@/shared/platform/index.js';
|
||||||
|
|
||||||
|
const shellCommand = buildFallbackCommand('codex resume 123', 'codex', 'windows');
|
||||||
|
const spawnPlan = createShellSpawnPlan(shellCommand, 'windows');
|
||||||
|
```
|
||||||
|
|
||||||
|
This keeps feature code from hardcoding bash rules into Windows paths or PowerShell rules into Linux code.
|
||||||
|
|
||||||
|
### 4. Quoting Rules
|
||||||
|
Even when two shells both support quotes, they do not escape them the same way.
|
||||||
|
- POSIX single quote escape is awkward: `'it'"'"'s'`
|
||||||
|
- PowerShell single quote escape doubles the quote: `'it''s'`
|
||||||
|
|
||||||
|
Use:
|
||||||
|
```ts
|
||||||
|
import { quoteShellArgument } from '@/shared/platform/index.js';
|
||||||
|
|
||||||
|
const safe = quoteShellArgument("it's", 'windows');
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Path Separators And Case
|
||||||
|
- Linux paths use `/`
|
||||||
|
- Windows paths typically use `\`
|
||||||
|
- Linux is usually case-sensitive
|
||||||
|
- Windows is usually case-insensitive
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
- `/repo/File.ts` and `/repo/file.ts` are different on Linux
|
||||||
|
- `C:\Repo\File.ts` and `c:\repo\file.ts` usually refer to the same file on Windows
|
||||||
|
|
||||||
|
Use:
|
||||||
|
```ts
|
||||||
|
import { arePathsEquivalent, normalizePathForPlatform, toPortablePath } from '@/shared/platform/index.js';
|
||||||
|
```
|
||||||
|
|
||||||
|
Guideline:
|
||||||
|
- use platform-specific paths when calling the OS
|
||||||
|
- use portable slash paths for logs, keys, and serialized payloads
|
||||||
|
|
||||||
|
### 6. Terminal Input
|
||||||
|
Terminal input is not the same as a normal HTML form submission.
|
||||||
|
- pressing Enter may arrive as `\r`
|
||||||
|
- pasted text may contain `\n` or `\r\n`
|
||||||
|
- terminal apps often expect carriage return behavior
|
||||||
|
|
||||||
|
Use:
|
||||||
|
```ts
|
||||||
|
import { normalizeTerminalInput } from '@/shared/platform/index.js';
|
||||||
|
```
|
||||||
|
|
||||||
|
This matters for PTY writes because terminal software often treats `\r` as the real Enter key behavior.
|
||||||
|
|
||||||
|
## The New Adapter Functions
|
||||||
|
- `normalizeTextForParsing()`: use when your goal is parsing text consistently, not preserving original file style; good for `.env`, JSONL, human-readable CLI output, and buffered command output.
|
||||||
|
- `splitLines()`: use when the full text is already in memory and you want clean logical lines; good for config files, buffered Git output, and fully collected CLI output.
|
||||||
|
- `createStreamLineAccumulator()`: use when text arrives incrementally over time; good for `stdout`, `stderr`, line-based streaming JSON, and long-lived child processes.
|
||||||
|
- `createShellSpawnPlan()`: use when the command must go through a shell because shell syntax is required; good for fallback commands, resume-or-start command chains, and interactive shell launch plans.
|
||||||
|
- `quoteShellArgument()`: use before interpolating dynamic values into shell command strings; good for session IDs, file paths, branch names, and user-provided subcommands.
|
||||||
|
- `buildFallbackCommand()`: use when the same logic must work in bash and PowerShell; a repo-shaped example is "resume Codex session if it exists, otherwise start a fresh one."
|
||||||
|
- `preserveExistingLineEndings()`: use when writing text files back to disk and you want to avoid noisy diffs; good for markdown files, config files, and user-managed text artifacts.
|
||||||
|
|
||||||
|
## Practical Backend Rules For This Repo
|
||||||
|
1. If you already have the full text, normalize once and then parse.
|
||||||
|
2. If the source is a stream, use an accumulator and never parse per chunk.
|
||||||
|
3. Prefer `spawn(executable, argv, { shell: false })` whenever possible.
|
||||||
|
4. Only use a shell when shell syntax is actually needed.
|
||||||
|
5. When you must use a shell, push all shell-specific behavior into the adapter layer.
|
||||||
|
6. Preserve existing line endings on user files unless you intentionally want normalization.
|
||||||
|
7. Separate transport normalization from business parsing.
|
||||||
|
|
||||||
|
## Common Mistakes To Avoid
|
||||||
|
- Parsing stdout chunk-by-chunk. Symptom: random JSON parse failures or truncated events. Fix: accumulate complete lines first.
|
||||||
|
- Using `split('\n')` on Windows text. Symptom: values end with `\r` and equality checks fail. Fix: normalize line endings or use `splitLines()`.
|
||||||
|
- Building one huge shell string for everything. Symptom: quoting bugs, OS-specific failures, and injection risk. Fix: prefer `spawn()` with argv; if shell is required, use `quoteShellArgument()` and `createShellSpawnPlan()`.
|
||||||
|
- Rewriting files with a different line-ending style. Symptom: huge git diffs and noisy file changes. Fix: use `preserveExistingLineEndings()`.
|
||||||
|
|
||||||
|
## Testing Strategy Implemented Here
|
||||||
|
This strategy intentionally does not add Jest, Vitest, or another test framework.
|
||||||
|
|
||||||
|
It uses:
|
||||||
|
- Node's built-in `node:test`
|
||||||
|
- `tsx` only to execute TypeScript tests
|
||||||
|
- a GitHub Actions matrix on Ubuntu and Windows
|
||||||
|
|
||||||
|
Local verification:
|
||||||
|
```bash
|
||||||
|
npm run test:server
|
||||||
|
npm run verify:server
|
||||||
|
```
|
||||||
|
|
||||||
|
CI verification:
|
||||||
|
- `npm run typecheck:server`
|
||||||
|
- `npm run test:server`
|
||||||
|
- `npm run server:build`
|
||||||
|
|
||||||
|
This gives you two kinds of confidence:
|
||||||
|
- contract confidence: the adapter functions behave as designed
|
||||||
|
- environment confidence: the same checks pass on real Linux and Windows runners
|
||||||
|
|
||||||
|
## Final Mental Model
|
||||||
|
Think in three layers:
|
||||||
|
1. Raw transport layer. Examples: chunks, bytes, terminal keystrokes, raw file text.
|
||||||
|
2. Normalization layer. Examples: strip BOM, normalize line endings, normalize terminal input, normalize shell behavior.
|
||||||
|
3. Business parsing layer. Examples: parse JSON, parse CLI output, parse `.env`, parse Git status, parse session files.
|
||||||
|
|
||||||
|
If you keep layer 2 in shared adapters, layer 3 stops caring about Linux vs Windows.
|
||||||
190
docs/backend/llm-module-structure.md
Normal file
190
docs/backend/llm-module-structure.md
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
# LLM Module Structure (Refactor Runtime)
|
||||||
|
|
||||||
|
This document describes the current backend structure under `server/src/modules/llm`, how execution/session state works, and how the provider abstraction is designed.
|
||||||
|
|
||||||
|
## High-Level Layout
|
||||||
|
|
||||||
|
```text
|
||||||
|
server/src/modules/llm/
|
||||||
|
llm.routes.ts
|
||||||
|
llm.registry.ts
|
||||||
|
providers/
|
||||||
|
provider.interface.ts
|
||||||
|
abstract.provider.ts
|
||||||
|
base-sdk.provider.ts
|
||||||
|
base-cli.provider.ts
|
||||||
|
claude.provider.ts
|
||||||
|
codex.provider.ts
|
||||||
|
cursor.provider.ts
|
||||||
|
gemini.provider.ts
|
||||||
|
services/
|
||||||
|
llm.service.ts
|
||||||
|
sessions.service.ts
|
||||||
|
sessions-watcher.service.ts
|
||||||
|
messages-unifier.service.ts
|
||||||
|
assets.service.ts
|
||||||
|
mcp.service.ts
|
||||||
|
skills.service.ts
|
||||||
|
session-indexers/
|
||||||
|
session-indexer.interface.ts
|
||||||
|
session-indexer.utils.ts
|
||||||
|
claude.session-indexer.ts
|
||||||
|
codex.session-indexer.ts
|
||||||
|
cursor.session-indexer.ts
|
||||||
|
gemini.session-indexer.ts
|
||||||
|
index.ts
|
||||||
|
tests/
|
||||||
|
llm-unifier.providers.test.ts
|
||||||
|
llm-unifier.sessions.test.ts
|
||||||
|
llm-unifier.images.test.ts
|
||||||
|
llm-unifier.mcp.test.ts
|
||||||
|
llm-unifier.skills.test.ts
|
||||||
|
llm-unifier.messages.test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
## Responsibilities By File Group
|
||||||
|
|
||||||
|
- `llm.routes.ts`
|
||||||
|
- HTTP API for provider runtime sessions (start/resume/stop/model/thinking), normalized session/history messages, assets upload, MCP config/probe, skills listing, indexed session CRUD/sync.
|
||||||
|
- `llm.registry.ts`
|
||||||
|
- Singleton provider registry. Instantiates one provider class per provider id.
|
||||||
|
- `providers/*`
|
||||||
|
- Runtime execution and live event collection.
|
||||||
|
- SDK family (`BaseSdkProvider`) for Claude/Codex.
|
||||||
|
- CLI family (`BaseCliProvider`) for Cursor/Gemini.
|
||||||
|
- `services/llm.service.ts`
|
||||||
|
- Input validation + capability gating + facade over provider registry.
|
||||||
|
- `services/sessions.service.ts`
|
||||||
|
- DB-backed indexed sessions and history file parsing.
|
||||||
|
- Returns normalized message history via `messages-unifier.service.ts`.
|
||||||
|
- `services/sessions-watcher.service.ts`
|
||||||
|
- `chokidar` watchers for provider artifact folders.
|
||||||
|
- On filesystem update, triggers `synchronizeProviderFile(provider, filePath)`.
|
||||||
|
- `services/messages-unifier.service.ts`
|
||||||
|
- Provider-specific raw event/history -> unified message contract for frontend.
|
||||||
|
- `services/assets.service.ts`
|
||||||
|
- Stores uploaded images in `.cloudcli/assets`.
|
||||||
|
- `services/mcp.service.ts`
|
||||||
|
- Unified MCP CRUD/probe across provider-native config formats/scopes/transports.
|
||||||
|
- `services/skills.service.ts`
|
||||||
|
- Provider-specific skill directory discovery and metadata extraction.
|
||||||
|
- `session-indexers/*`
|
||||||
|
- Scans provider artifacts from disk and upserts indexed sessions into `sessions` DB table.
|
||||||
|
|
||||||
|
## Runtime Flow (Provider Sessions)
|
||||||
|
|
||||||
|
1. `POST /api/llm/providers/:provider/sessions/start` hits `llm.routes.ts`.
|
||||||
|
2. Route calls `llmService.startSession(...)`.
|
||||||
|
3. `llm.service.ts` validates payload and capability constraints.
|
||||||
|
4. `llm.registry.ts` resolves provider instance.
|
||||||
|
5. Provider (`BaseSdkProvider` or `BaseCliProvider`) creates an in-memory session record and starts execution.
|
||||||
|
6. Stream/process output is appended as in-memory `ProviderSessionEvent[]`.
|
||||||
|
7. Route can either:
|
||||||
|
- return `202` immediately with snapshot, or
|
||||||
|
- await completion via `waitForSession`.
|
||||||
|
8. Snapshots are enriched with unified `messages` via `llmMessagesUnifier.normalizeSessionEvents(...)`.
|
||||||
|
|
||||||
|
## Indexed History Flow (Disk/DB)
|
||||||
|
|
||||||
|
1. Watcher or manual sync scans provider folders.
|
||||||
|
2. Provider-specific indexer extracts minimal metadata and upserts `sessionsDb`.
|
||||||
|
3. History endpoints (`/sessions/:sessionId/history`, `/sessions/:sessionId/messages`) read transcript path from DB.
|
||||||
|
4. JSON/JSONL is parsed and transformed via `llmMessagesUnifier.normalizeHistoryEntries(...)`.
|
||||||
|
|
||||||
|
## Interface + Abstract + Base-Class Design
|
||||||
|
|
||||||
|
### `IProvider` (interface)
|
||||||
|
`providers/provider.interface.ts`
|
||||||
|
|
||||||
|
- Consumer contract used by registry/service layer.
|
||||||
|
- Exposes:
|
||||||
|
- `launchSession`, `resumeSession`, `stopSession`, `waitForSession`
|
||||||
|
- `setSessionModel`, `setSessionThinkingMode`
|
||||||
|
- `getSession`, `listSessions`
|
||||||
|
- `listModels`
|
||||||
|
- Exposes `capabilities` so callers can gate unsupported features before calling provider-specific logic.
|
||||||
|
|
||||||
|
### `AbstractProvider` (abstract class)
|
||||||
|
`providers/abstract.provider.ts`
|
||||||
|
|
||||||
|
- Shared lifecycle state and rules:
|
||||||
|
- `sessions: Map<string, MutableProviderSession>`
|
||||||
|
- `sessionPreferences: Map<string, { model?, thinkingMode? }>`
|
||||||
|
- Implements:
|
||||||
|
- in-memory session reads (`getSession`, `listSessions`, `waitForSession`)
|
||||||
|
- stop handling + session status events
|
||||||
|
- model/thinking updates with capability checks
|
||||||
|
- event ring-buffer logic (`MAX_EVENT_BUFFER_SIZE`)
|
||||||
|
- Leaves provider execution specifics abstract (`listModels`, `launchSession`, `resumeSession`).
|
||||||
|
|
||||||
|
### `BaseSdkProvider` and `BaseCliProvider`
|
||||||
|
|
||||||
|
- `BaseSdkProvider`
|
||||||
|
- shared async iterable stream consumption.
|
||||||
|
- handles completion/error transitions and completion system event emission.
|
||||||
|
- `BaseCliProvider`
|
||||||
|
- shared child-process spawn + stdout/stderr line accumulation + JSON line parsing.
|
||||||
|
- graceful stop (`SIGTERM` then `SIGKILL`) and completion/error transitions.
|
||||||
|
|
||||||
|
### Concrete provider classes
|
||||||
|
|
||||||
|
- `ClaudeProvider` (SDK)
|
||||||
|
- uses `@anthropic-ai/claude-agent-sdk`.
|
||||||
|
- supports runtime permission requests and emits permission events.
|
||||||
|
- image payload support via base64 content blocks.
|
||||||
|
- `CodexProvider` (SDK)
|
||||||
|
- dynamic import of `@openai/codex-sdk`.
|
||||||
|
- supports text + `local_image` prompt items.
|
||||||
|
- `CursorProvider` (CLI)
|
||||||
|
- `cursor-agent` invocation builder + model list parsing.
|
||||||
|
- `GeminiProvider` (CLI)
|
||||||
|
- `gemini` invocation builder + curated model catalog.
|
||||||
|
|
||||||
|
## In-Memory Session Setup: How It Works
|
||||||
|
|
||||||
|
The in-memory part is inside `AbstractProvider` + base classes:
|
||||||
|
|
||||||
|
- Session record is created at launch/resume in memory (`Map`).
|
||||||
|
- Events are appended in real-time while stream/process runs.
|
||||||
|
- Snapshot endpoints read this map directly (`/providers/:provider/sessions...`).
|
||||||
|
- Stop/wait/model/thinking controls operate on this same in-memory handle.
|
||||||
|
- Completed sessions currently remain in map (bounded event history per session, but no map eviction).
|
||||||
|
|
||||||
|
Key characteristics:
|
||||||
|
|
||||||
|
- Process-local only (not shared across instances).
|
||||||
|
- Lost on server restart.
|
||||||
|
- Good for immediate live control and progress.
|
||||||
|
- Not the source of truth for historical transcripts (disk/DB is).
|
||||||
|
|
||||||
|
## Is In-Memory Session State Necessary, Or Useless?
|
||||||
|
|
||||||
|
Short answer: **not useless**, but **not sufficient as a durable architecture**.
|
||||||
|
|
||||||
|
### Why it is necessary in the current design
|
||||||
|
|
||||||
|
- You need live handles for:
|
||||||
|
- `stopSession` (abort process/stream now),
|
||||||
|
- `waitForSession`,
|
||||||
|
- real-time event buffering for immediate API responses.
|
||||||
|
- These are runtime concerns and cannot be satisfied by session-index DB rows alone.
|
||||||
|
|
||||||
|
### Where it is weak
|
||||||
|
|
||||||
|
- No eviction/pruning for completed session map entries.
|
||||||
|
- No persistence across restart.
|
||||||
|
- No cross-instance coordination (if horizontally scaled, only the owning instance can control that session).
|
||||||
|
|
||||||
|
### Practical conclusion
|
||||||
|
|
||||||
|
- Keep in-memory runtime state for **active execution control**.
|
||||||
|
- Treat DB/indexed history as the durable read model.
|
||||||
|
- If you need reliability across restarts/instances, move execution ownership to a durable worker/orchestrator and store live session metadata in a shared store.
|
||||||
|
|
||||||
|
## Suggested Hardening (Incremental)
|
||||||
|
|
||||||
|
1. Add session map eviction policy (TTL/LRU for completed/failed/stopped sessions).
|
||||||
|
2. Add ownership metadata (`instanceId`) if multiple backend instances will run.
|
||||||
|
3. Add explicit `activeSessions` metric endpoint.
|
||||||
|
4. Optionally persist minimal runtime state (status transitions + timestamps) to DB for auditability.
|
||||||
|
|
||||||
456
docs/backend/llm-unifier-helper-2.md
Normal file
456
docs/backend/llm-unifier-helper-2.md
Normal file
@@ -0,0 +1,456 @@
|
|||||||
|
# How each provider supports image uploading
|
||||||
|
|
||||||
|
Universally: First, we should upload the images in `.cloudcli/assets` folder. Then, it should just reference that path later on.
|
||||||
|
|
||||||
|
## Claude
|
||||||
|
- When clicking send, attach the images in the content list with the type of 'image'.
|
||||||
|
- https://platform.claude.com/docs/en/api/messages#message_param
|
||||||
|
```js
|
||||||
|
const imageBytes = await fs.readFile(imagePath);
|
||||||
|
const sdkPrompt = (async function*: AsyncIterable<SDKUserMessage> () {
|
||||||
|
yield {
|
||||||
|
type: 'user',
|
||||||
|
message: {
|
||||||
|
role: 'user',
|
||||||
|
content: [
|
||||||
|
{ type: 'text', text: prompt },
|
||||||
|
{
|
||||||
|
type: 'image',
|
||||||
|
source: {
|
||||||
|
type: 'base64',
|
||||||
|
media_type: 'image/jpeg',
|
||||||
|
data: imageBytes.toString('base64'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
parent_tool_use_id: null,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
})(); // automatically executed because of the `()` in the end.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Some useful types
|
||||||
|
```ts
|
||||||
|
export interface MessageParam {
|
||||||
|
content: string | Array<ContentBlockParam>;
|
||||||
|
|
||||||
|
role: 'user' | 'assistant'; // when we send the message for prompting, the role will be 'user'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regular text content.
|
||||||
|
*/
|
||||||
|
export type ContentBlockParam =
|
||||||
|
| TextBlockParam
|
||||||
|
| ImageBlockParam
|
||||||
|
| DocumentBlockParam
|
||||||
|
| SearchResultBlockParam
|
||||||
|
| ThinkingBlockParam
|
||||||
|
| RedactedThinkingBlockParam
|
||||||
|
| ToolUseBlockParam
|
||||||
|
| ToolResultBlockParam
|
||||||
|
| ServerToolUseBlockParam
|
||||||
|
| WebSearchToolResultBlockParam;
|
||||||
|
|
||||||
|
|
||||||
|
export interface TextBlockParam {
|
||||||
|
text: string;
|
||||||
|
type: 'text';
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ImageBlockParam {
|
||||||
|
source: Base64ImageSource | URLImageSource; // I'll be using only base 64 for now.
|
||||||
|
type: 'image';
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Base64ImageSource {
|
||||||
|
data: string;
|
||||||
|
media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
||||||
|
type: 'base64';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Explanations about async generators and yield
|
||||||
|
To understand why `async function*` is used, it helps to stop thinking of functions as "machines that run and finish" and start thinking of them as **"factories that stay open."**
|
||||||
|
```ts
|
||||||
|
async function* getTaskStatus(): AsyncIterable<string> {
|
||||||
|
yield "Checking permissions...";
|
||||||
|
await new Promise(r => setTimeout(r, 500)); // Simulate work
|
||||||
|
|
||||||
|
yield "Searching database...";
|
||||||
|
await new Promise(r => setTimeout(r, 500));
|
||||||
|
|
||||||
|
yield "Formatting prompt...";
|
||||||
|
}
|
||||||
|
|
||||||
|
// CONSUMPTION
|
||||||
|
async function run() {
|
||||||
|
const statusGenerator = getTaskStatus();
|
||||||
|
|
||||||
|
for await (const status of statusGenerator) {
|
||||||
|
console.log(`Current Status: ${status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Done!");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Codex
|
||||||
|
```ts
|
||||||
|
const streamed = await thread.runStreamed([ {type: "text", text: "Describe this image:"}, {type: "local_image", path: "scripts/pic.jpg"}
|
||||||
|
```
|
||||||
|
- Don't add the above query lines for codex. We can directly use the `sdk`.
|
||||||
|
|
||||||
|
## Gemini and Cursor
|
||||||
|
- Just add the path to the end of the prompt when clicking send for paths including images. For e.g.
|
||||||
|
```
|
||||||
|
<some-user-prompt>
|
||||||
|
|
||||||
|
<images_input>
|
||||||
|
---- IGNORE THE <images_input> QUERY LINES. Just use the attached list of an array of paths for images below and use it with the above prompt.
|
||||||
|
|
||||||
|
["scripts\pic.jpg", "<path-for-second-image>", ...]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# MCP servers (how to add/remove one and run it)
|
||||||
|
|
||||||
|
**What is the Model Context Protocol (MCP)?**
|
||||||
|
Think of MCP as the USB-C cable for AI.
|
||||||
|
- Historically, if you wanted an AI model to read your GitHub repository, query your database, or search your company's Notion workspace, developers had to write custom, one-off integrations for every single AI tool.
|
||||||
|
- Created by Anthropic as an open-source standard, the Model Context Protocol fixes this. It is a universal language that allows AI applications (the "clients") to securely connect to external data sources and tools (the "servers") using a single, unified protocol.
|
||||||
|
|
||||||
|
**What is an MCP Server?**
|
||||||
|
- If MCP is the USB-C cable, an **MCP Server** is the hard drive or webcam you are plugging in.
|
||||||
|
- It is a lightweight program that acts as a secure bridge between your specific data and the AI. When the AI needs context—like checking the current state of a file or executing a search—it asks the MCP server. The server translates the AI's request, securely fetches the data or performs the action, and hands the result back to the AI.
|
||||||
|
|
||||||
|
**Different transport mechanisms for MCP servers**
|
||||||
|
1. `stdio` - This is the default and most common transport for local development. When using `stdio`, the AI client directly launches the MCP server as a background "child process" on your machine. The client and server then talk to each other locally by writing to and reading from standard input (`stdin`) and standard output (`stdout`).
|
||||||
|
- **Clear Example:** A local **File System Server**. You want the AI to read your local `package.json` file. The AI client spawns the file system server via `stdio`. Because the server is running locally on your hardware, it inherently has access to your files without needing complex authentication. It reads the file and prints the contents back to the AI.
|
||||||
|
2. `https` (Streamable HTTP) - Streamable HTTP replaces older remote methods. It uses a single HTTP or HTTPS endpoint for bidirectional communication. The client sends standard `POST` requests, and the server can respond instantly or keep the connection open to stream data back. It behaves exactly like a modern web API. Because it runs over HTTP, it supports standard web security features like OAuth, Bearer tokens, and CORS.
|
||||||
|
- **Clear Example:** A **Cloud Database Server**. If you work on a team and want everyone's AI to be able to query a shared staging database, you would deploy an MCP server to the cloud. Your AI connects to `https://api.yourcompany.com/mcp` using Streamable HTTP and passes an API key in the headers to securely run queries.
|
||||||
|
3. `sse` (Server sent events) - SSE is the legacy transport mechanism for remote servers. While still widely supported, it is actively being phased out in favor of Streamable HTTP because it is slightly more cumbersome to build and maintain.
|
||||||
|
- **How it works:** Unlike Streamable HTTP which uses a single unified endpoint, SSE requires _two_ distinct network connections. The client connects to an SSE endpoint (via an HTTP `GET` request) strictly to listen for incoming messages from the server, and uses a separate HTTP `POST` endpoint to send messages to the server.
|
||||||
|
|
||||||
|
- **Clear Example:** An older **Slack Integration Server**. The AI client connects to the server's SSE stream to listen for real-time incoming messages from a Slack channel. When the AI wants to reply, it sends a payload to a separate `/message` POST endpoint.
|
||||||
|
|
||||||
|
**Frontend coordination**
|
||||||
|
- When listing the MCP servers for a provider, go to the appropriate files where the configuration is stored to fetch all of them. When listing, the User/Local/Project MCPs should be grouped separately.
|
||||||
|
- To add/remove an MCP server, go to the appropriate file and add/remove it there keeping in mind whether it is configured as User/Local/Project.
|
||||||
|
- To update the server, go to the appropriate file and update it from there.
|
||||||
|
- There should also be one big mcp adder that supports `http` and `stdio` only. When it's added from there, the server will automatically be added to every provider.
|
||||||
|
|
||||||
|
## Claude
|
||||||
|
Supports all 3 transports.
|
||||||
|
### `stdio`
|
||||||
|
- We can have arguments and env variables input when executing the command.
|
||||||
|
- `args` and `env` are optional.
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"local-weather": {
|
||||||
|
"type": "stdio",
|
||||||
|
"command": "/path/to/weather-cli",
|
||||||
|
"args": ["--api-key", "abc123"],
|
||||||
|
"env": {
|
||||||
|
"CACHE_DIR": "/tmp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `http`
|
||||||
|
- We don't pass `env` inputs for now. It's supported but we will add it only later.
|
||||||
|
- `headers` is optional.
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"weather-api": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "https://api.weather.com/mcp",
|
||||||
|
"headers": {
|
||||||
|
"Authorization": "Bearer token"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `sse`
|
||||||
|
- similar with `http` format.
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"private-api": {
|
||||||
|
"type": "sse",
|
||||||
|
"url": "https://api.company.com/sse",
|
||||||
|
"headers": {
|
||||||
|
"X-API-Key": "your-key-here"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Support for different modes (Local, user, project)
|
||||||
|
|
||||||
|
#### Local
|
||||||
|
- stored in `~/.claude.json` under the project’s path.
|
||||||
|
#### User
|
||||||
|
- stored in `~/.claude.json` under the main object with the key `"mcpServers"
|
||||||
|
#### Project specific
|
||||||
|
- add it in the `.mcp.json` file in the project root directory.
|
||||||
|
|
||||||
|
## Codex
|
||||||
|
|
||||||
|
### Configuration (Only `stdio` and `http` are supported.)
|
||||||
|
|
||||||
|
#### `stdio`
|
||||||
|
- `command` (required): The command that starts the server.
|
||||||
|
- `args` (optional): Arguments to pass to the server.
|
||||||
|
- `env` (optional): Environment variables to set for the server.
|
||||||
|
- `env_vars` (optional): Environment variables to allow and forward.
|
||||||
|
- `cwd` (optional): Working directory to start the server from.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[mcp_servers.my_stdio]
|
||||||
|
command = "npx"
|
||||||
|
args = ["-y", "@upstash/context7-mcp"]
|
||||||
|
|
||||||
|
[mcp_servers.my_stdio.env]
|
||||||
|
API_KEY = "your-key"
|
||||||
|
```
|
||||||
|
|
||||||
|
With forwarded host env vars.
|
||||||
|
```toml
|
||||||
|
[mcp_servers.my_stdio]
|
||||||
|
command = "python"
|
||||||
|
args = ["server.py"]
|
||||||
|
env_vars = ["API_KEY", "DEBUG"]
|
||||||
|
cwd = "/path/to/project"
|
||||||
|
```
|
||||||
|
#### `http`
|
||||||
|
- `url` (required): The server address.
|
||||||
|
- `bearer_token_env_var` (optional): Environment variable name for a bearer token to send in `Authorization`.
|
||||||
|
- `http_headers` (optional): Map of header names to static values.
|
||||||
|
- `env_http_headers` (optional): Map of header names to environment variable names (values pulled from the environment).
|
||||||
|
```toml
|
||||||
|
[mcp_servers.my_http]
|
||||||
|
url = "https://example.com/mcp"
|
||||||
|
bearer_token_env_var = "MY_API_TOKEN"
|
||||||
|
http_headers = { "X-Custom-Header" = "custom-value" }
|
||||||
|
env_http_headers = { "X-Api-Key" = "MY_API_KEY_ENV" }
|
||||||
|
```
|
||||||
|
|
||||||
|
### Support for different modes (user, project)
|
||||||
|
#### User
|
||||||
|
- add it to the global `~/.codex/config.toml` file.
|
||||||
|
|
||||||
|
#### Project specific
|
||||||
|
- add it in `.codex/config.toml` file in the project's root directory.
|
||||||
|
|
||||||
|
## Gemini
|
||||||
|
Supports all 3 transports.
|
||||||
|
### `stdio`
|
||||||
|
- We can have arguments and env variables as inputs when executing the command.
|
||||||
|
- `args` and `env` are optional.
|
||||||
|
- No `type` attribute like Claude for `stdio`. If there is no type, we can infer that it must be `stdio` since the rest have it.
|
||||||
|
```json
|
||||||
|
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"serverName": {
|
||||||
|
"command": "path/to/server",
|
||||||
|
"args": ["--arg1", "value1"],
|
||||||
|
"env": {
|
||||||
|
"API_KEY": "$MY_API_TOKEN"
|
||||||
|
},
|
||||||
|
"cwd": "./server-directory"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `http`
|
||||||
|
- We don't pass `env` inputs. Notice the type is set here like Claude.
|
||||||
|
- `headers` is optional.
|
||||||
|
- EXACTLY same as Claude `http`.
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"weather-api": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "https://api.weather.com/mcp",
|
||||||
|
"headers": {
|
||||||
|
"Authorization": "Bearer token"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `sse`
|
||||||
|
- similar with `http` format.
|
||||||
|
- EXACT with Claude `sse` format.
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"private-api": {
|
||||||
|
"type": "sse",
|
||||||
|
"url": "https://api.company.com/sse",
|
||||||
|
"headers": {
|
||||||
|
"X-API-Key": "your-key-here"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Support for different modes (user, project)
|
||||||
|
|
||||||
|
#### User
|
||||||
|
- stored in `~/.gemini/settings.json`.
|
||||||
|
|
||||||
|
#### Project specific
|
||||||
|
- add it in the `.gemini/settings.json` file in the project root directory.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Cursor
|
||||||
|
|
||||||
|
Supports all 3 transports. There is no `type` attribute for all 3. Here are the structures:
|
||||||
|
|
||||||
|
#### `stdio`
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"server-name": {
|
||||||
|
"command": "npx",
|
||||||
|
"args": ["-y", "mcp-server"],
|
||||||
|
"env": {
|
||||||
|
"API_KEY": "value"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `http` / `sse`
|
||||||
|
```json
|
||||||
|
// MCP server using HTTP or SSE - runs on a server
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"server-name": {
|
||||||
|
"url": "http://localhost:3000/mcp",
|
||||||
|
"headers": {
|
||||||
|
"API_KEY": "value"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Support for different modes (user, project)
|
||||||
|
|
||||||
|
#### User
|
||||||
|
- stored in `~/.cursor/mcp.json`.
|
||||||
|
|
||||||
|
#### Project specific
|
||||||
|
- add it in the `.cursor/mcp.json` file in the project root directory.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Skills management (ONLY Fetching support needed for now)
|
||||||
|
## Claude
|
||||||
|
- To get user skills, fetch all `~/.claude/skills/<skill-name>/SKILL.md`.
|
||||||
|
- To get project skills, fetch from `.claude/skills/<skill-name>/SKILL.md`.
|
||||||
|
- To get plugin skills:
|
||||||
|
- Find all the enabled plugins in `~/.claude/settings.json`.
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"apiKeyHelper": "...",
|
||||||
|
"enabledPlugins": {
|
||||||
|
"example-skills@anthropic-agent-skills": true
|
||||||
|
},
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- Then go to `~/.claude/plugins/installed_plugins.json` file to find where the plugin is installed.
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"plugins": {
|
||||||
|
"example-skills@anthropic-agent-skills": [
|
||||||
|
{
|
||||||
|
"scope": "user",
|
||||||
|
"installPath": "C:\\Users\\OMEN6\\.claude\\plugins\\cache\\anthropic-agent-skills\\example-skills\\3d5951151859",
|
||||||
|
"version": "3d5951151859",
|
||||||
|
"installedAt": "2026-03-03T12:52:08.024Z",
|
||||||
|
"lastUpdated": "2026-03-03T12:52:08.024Z",
|
||||||
|
"gitCommitSha": "3d59511518591fa82e6cfcf0438d68dd5dad3e76"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- Then go the `installPath` directory. If there is a `skills` folder there, go to each of the skills in `<install-path>/skills/<skill-name>/SKILL.md`.
|
||||||
|
|
||||||
|
Then, parse the name and description of the skills from the md for every `SKILL.md`.
|
||||||
|
|
||||||
|
- The command for invoking skills is `/<skill-name>` .
|
||||||
|
|
||||||
|
- Whenever a skill is from a plugin, doing `/skill-name` should automatically be updated with `/plugin-name:skill-name`. This is because plugin skills use a `plugin-name:skill-name` namespace, so they cannot conflict with other levels.
|
||||||
|
|
||||||
|
I have attached the first initial contents of a sample `SKILL.md` file below.
|
||||||
|
|
||||||
|
```md
|
||||||
|
---
|
||||||
|
|
||||||
|
name: mcp-builder
|
||||||
|
|
||||||
|
description: Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
|
||||||
|
|
||||||
|
license: Complete terms in LICENSE.txt
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
## Codex
|
||||||
|
|
||||||
|
|
||||||
|
Codex reads skills from repository, user, admin, and system locations.
|
||||||
|
|
||||||
|
|
||||||
|
| Skill Scope | Location | Suggested use |
|
||||||
|
| ----------- | ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| `REPO` | `$CWD/.agents/skills` <br>Current working directory: where you launch Codex. | If you’re in a repository or code environment, teams can check in skills relevant to a working folder. For example, skills only relevant to a microservice or a module. |
|
||||||
|
| `REPO` | ` $CWD/../.agents/skills` <br>A folder above CWD when you launch Codex inside a Git repository. | If you’re in a repository with nested folders, organizations can check in skills relevant to a shared area in a parent folder. |
|
||||||
|
| `REPO` | `$REPO_ROOT/.agents/skills` <br>The topmost root folder when you launch Codex inside a Git repository. | If you’re in a repository with nested folders, organizations can check in skills relevant to everyone using the repository. These serve as root skills available to any subfolder in the repository. |
|
||||||
|
| `USER` | `$HOME/.agents/skills` <br>Any skills checked into the user’s personal folder. | Use to curate skills relevant to a user that apply to any repository the user may work in. |
|
||||||
|
| `ADMIN` | `/etc/codex/skills` <br>Any skills checked into the machine or container in a shared, system location. | Use for SDK scripts, automation, and for checking in default admin skills available to each user on the machine. |
|
||||||
|
| `SYSTEM` | `~/.codex/skills/.system` | Useful skills relevant to a broad audience such as the skill-creator and plan skills. Available to everyone when they start Codex. |
|
||||||
|
|
||||||
|
Then, parse the name and description of the skills from the md for every `SKILL.md`.
|
||||||
|
|
||||||
|
- The command for invoking skills is `$<skill-name>`
|
||||||
|
## Gemini
|
||||||
|
- Gets all skills from `~/.gemini/skills`, `~/.agents/skills`, `.gemini/skills`, `.agents/skills`
|
||||||
|
- command for invoking skills is same as Claude.
|
||||||
|
|
||||||
|
|
||||||
|
## Cursor
|
||||||
|
[Skill directories](https://cursor.com/docs/skills?utm_source=chatgpt.com#skill-directories)
|
||||||
|
Skills are automatically loaded from these locations:
|
||||||
|
|
||||||
|
|Location|Scope|
|
||||||
|
|---|---|
|
||||||
|
|`.agents/skills/`|Project-level|
|
||||||
|
|`.cursor/skills/`|Project-level|
|
||||||
|
|`~/.cursor/skills/`|User-level (global)|
|
||||||
|
Then, parse the name and description of the skills from the md for every `SKILL.md`.
|
||||||
|
|
||||||
|
- command for invoking skills is same as Claude.
|
||||||
2803
docs/backend/llm-unifier-helper-3.md
Normal file
2803
docs/backend/llm-unifier-helper-3.md
Normal file
File diff suppressed because it is too large
Load Diff
461
docs/backend/llm-unifier-helper.md
Normal file
461
docs/backend/llm-unifier-helper.md
Normal file
@@ -0,0 +1,461 @@
|
|||||||
|
# How each session processes sessions
|
||||||
|
- The way each session processes the sessions is already setup in `server/src/modules/providers`. Port over the existing logic to the new classes if possible.
|
||||||
|
|
||||||
|
# How to start, resume, and stop a session
|
||||||
|
|
||||||
|
## Claude
|
||||||
|
A new session is created by calling `query({ prompt, options })` which yields an async stream of SDK messages. The session ID can be provided explicitly by using `resume` option and passing the session id (`sdkOptions.resume = sessionId;`).
|
||||||
|
|
||||||
|
https://platform.claude.com/docs/en/agent-sdk/typescript#types
|
||||||
|
|
||||||
|
Session can be stopped midway using `queryInstance.interrupt()`
|
||||||
|
https://platform.claude.com/docs/en/agent-sdk/typescript#methods
|
||||||
|
|
||||||
|
## Codex
|
||||||
|
- Starting - `const thread = codex.startThread(threadOptions)`
|
||||||
|
- Resuming - `codex.resumeThread(sessionId, threadOptions);`
|
||||||
|
- Stop a session
|
||||||
|
```
|
||||||
|
// Execute with streaming
|
||||||
|
|
||||||
|
const streamedTurn = await thread.runStreamed(command, {
|
||||||
|
|
||||||
|
signal: abortController.signal
|
||||||
|
|
||||||
|
});
|
||||||
|
```
|
||||||
|
### About Abort controllers
|
||||||
|
- Think of `AbortController` as a **cancel button for async work**.
|
||||||
|
- **Controller** = thing that sends the cancel command.
|
||||||
|
- **Signal** = thing that receives or carries the cancel state
|
||||||
|
|
||||||
|
```js
|
||||||
|
const controller = new AbortController();
|
||||||
|
|
||||||
|
fetch("https://api.example.com/data", {
|
||||||
|
signal: controller.signal
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log("Finished:", data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
if (error.name === "AbortError") {
|
||||||
|
console.log("The request was cancelled");
|
||||||
|
} else {
|
||||||
|
console.error("Real error:", error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Cancel it after 2 seconds
|
||||||
|
setTimeout(() => {
|
||||||
|
controller.abort();
|
||||||
|
}, 2000);
|
||||||
|
```
|
||||||
|
- `AbortController` does **not magically stop all JavaScript everywhere**. It only works if the API or function you are using actually supports cancellation via a signal. `fetch` does. Your own custom async functions can too, but you have to write that support yourself. In codex, the method `runStreamed` supports it as well.
|
||||||
|
```js
|
||||||
|
function wait(ms, { signal } = {}) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// if signal was aborted EVEN BEFORE the function started, return back.
|
||||||
|
// This catches the case where someone did this first:
|
||||||
|
// controller.abort("Cancelled already");
|
||||||
|
// wait(5000, { signal: controller.signal });
|
||||||
|
if (signal?.aborted) {
|
||||||
|
reject(signal.reason); // it supports custom reasoning as well.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeoutId = setTimeout(() => {
|
||||||
|
resolve("Done waiting");
|
||||||
|
}, ms);
|
||||||
|
|
||||||
|
// when the signal.abort event is fired (when controller.abort() is called somewhere else), it sends an `abort` event.
|
||||||
|
// When we get this, remove the timeoutId
|
||||||
|
signal?.addEventListener("abort", () => {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
reject(signal.reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------- USAGE --------------------
|
||||||
|
const controller = new AbortController();
|
||||||
|
|
||||||
|
wait(5000, { signal: controller.signal })
|
||||||
|
.then(result => {
|
||||||
|
console.log(result);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log("Cancelled:", error);
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
controller.abort("User cancelled the wait");
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Gemini
|
||||||
|
### Start
|
||||||
|
|
||||||
|
spawn `gemini --prompt "actualprompt" --model "actual model", --output-format 'stream-json'`
|
||||||
|
|
||||||
|
- Stream `json` output format send responses in terms of a series of `json` chunks. If we store it, we would use .`jsonl` format.
|
||||||
|
- Allowed tools aren't needed as it's depreciated.
|
||||||
|
```
|
||||||
|
--allowed-tools [DEPRECATED: Use Policy Engine instead See
|
||||||
|
https://geminicli.com/docs/core/policy-engine] Tools that are allowed
|
||||||
|
to run without confirmation
|
||||||
|
```
|
||||||
|
|
||||||
|
- `--prompt` allows us to run just one prompt in headless mode. It will automatically trust the workspace directory so it won't ask us whether we trust the workspace or not.
|
||||||
|
|
||||||
|
### Stop/Abort a session
|
||||||
|
```js
|
||||||
|
try {
|
||||||
|
geminiProc.kill('SIGTERM'); // gracefully terminates the process. It ASKS the process to shut down cleanly. The process can catch it, save state, close files, and exit
|
||||||
|
setTimeout(() => {
|
||||||
|
geminiProc.kill('SIGKILL'); // kills it immediately
|
||||||
|
}
|
||||||
|
}, 2000); // Wait 2 seconds before force kill
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### resume
|
||||||
|
- spawn `gemini <the above formats> --resume <sessionId>`
|
||||||
|
|
||||||
|
### To receive a response
|
||||||
|
```
|
||||||
|
child.stdout.on('data', (chunk) => {
|
||||||
|
const text = chunk.toString();
|
||||||
|
...
|
||||||
|
})
|
||||||
|
|
||||||
|
child.stderr.on('data', (chunk) => {
|
||||||
|
const text = chunk.toString();
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cursor
|
||||||
|
### Start
|
||||||
|
- spawn `cursor-agent --print --trust --output-format 'stream-json' <actual-prompt'>`
|
||||||
|
This won't be able to run shell commands like `git init`. To be able to run those, `--yolo` must be passed.
|
||||||
|
|
||||||
|
### Resume
|
||||||
|
- spawn `cursor-agent <above commands> --resume <sessionID>`
|
||||||
|
|
||||||
|
### abort
|
||||||
|
- same approach as gemini.
|
||||||
|
|
||||||
|
|
||||||
|
# How to fetch (list the model types supported for each model...find out if there is an easy way to fetch automatically from the files)
|
||||||
|
|
||||||
|
## Claude
|
||||||
|
|
||||||
|
`query.supportedModels()` returns `ModelInfo[]`.
|
||||||
|
```ts
|
||||||
|
/**
|
||||||
|
* Information about an available model.
|
||||||
|
*/
|
||||||
|
export declare type ModelInfo = {
|
||||||
|
/**
|
||||||
|
* Model identifier to use in API calls
|
||||||
|
*/
|
||||||
|
value: string;
|
||||||
|
/**
|
||||||
|
* Human-readable display name
|
||||||
|
*/
|
||||||
|
displayName: string;
|
||||||
|
/**
|
||||||
|
* Description of the model's capabilities
|
||||||
|
*/
|
||||||
|
description: string;
|
||||||
|
/**
|
||||||
|
* Whether this model supports effort levels
|
||||||
|
*/
|
||||||
|
supportsEffort?: boolean;
|
||||||
|
/**
|
||||||
|
* Available effort levels for this model
|
||||||
|
*/
|
||||||
|
supportedEffortLevels?: ('low' | 'medium' | 'high' | 'max')[];
|
||||||
|
/**
|
||||||
|
* Whether this model supports adaptive thinking (Claude decides when and how much to think)
|
||||||
|
*/
|
||||||
|
supportsAdaptiveThinking?: boolean;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
supported models = [
|
||||||
|
{
|
||||||
|
value: 'default',
|
||||||
|
displayName: 'Default (recommended)',
|
||||||
|
description: 'Use the default model (currently Sonnet 4.6) · $3/$15 per Mtok',
|
||||||
|
supportsEffort: true,
|
||||||
|
supportedEffortLevels: [ 'low', 'medium', 'high', 'max' ],
|
||||||
|
supportsAdaptiveThinking: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'sonnet[1m]',
|
||||||
|
displayName: 'Sonnet (1M context)',
|
||||||
|
description: 'Sonnet 4.6 for long sessions · $6/$22.50 per Mtok',
|
||||||
|
supportsEffort: true,
|
||||||
|
supportedEffortLevels: [ 'low', 'medium', 'high', 'max' ],
|
||||||
|
supportsAdaptiveThinking: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'opus',
|
||||||
|
displayName: 'Opus',
|
||||||
|
description: 'Opus 4.6 · Most capable for complex work · $5/$25 per Mtok',
|
||||||
|
supportsEffort: true,
|
||||||
|
supportedEffortLevels: [ 'low', 'medium', 'high', 'max' ],
|
||||||
|
supportsAdaptiveThinking: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'opus[1m]',
|
||||||
|
displayName: 'Opus (1M context)',
|
||||||
|
description: 'Opus 4.6 for long sessions · $10/$37.50 per Mtok',
|
||||||
|
supportsEffort: true,
|
||||||
|
supportedEffortLevels: [ 'low', 'medium', 'high', 'max' ],
|
||||||
|
supportsAdaptiveThinking: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'haiku',
|
||||||
|
displayName: 'Haiku',
|
||||||
|
description: 'Haiku 4.5 · Fastest for quick answers · $1/$5 per Mtok'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'sonnet',
|
||||||
|
displayName: 'sonnet',
|
||||||
|
description: 'Custom model',
|
||||||
|
supportsEffort: true,
|
||||||
|
supportedEffortLevels: [ 'low', 'medium', 'high', 'max' ],
|
||||||
|
supportsAdaptiveThinking: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Codex
|
||||||
|
|
||||||
|
- Found in `.codex/models_cache.json`. It's in the `models` attribute.
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
...,
|
||||||
|
"models": [
|
||||||
|
{
|
||||||
|
"slug": "gpt-5.4",
|
||||||
|
"display_name": "gpt-5.4",
|
||||||
|
"description": "Latest frontier agentic coding model.",
|
||||||
|
"default_reasoning_level": "medium",
|
||||||
|
"supported_reasoning_levels": [
|
||||||
|
{
|
||||||
|
"effort": "low",
|
||||||
|
"description": "Fast responses with lighter reasoning"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"effort": "medium",
|
||||||
|
"description": "Balances speed and reasoning depth for everyday tasks"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"effort": "high",
|
||||||
|
"description": "Greater reasoning depth for complex problems"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"effort": "xhigh",
|
||||||
|
"description": "Extra high reasoning depth for complex problems"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"shell_type": "shell_command",
|
||||||
|
"visibility": "list",
|
||||||
|
"supported_in_api": true,
|
||||||
|
"priority": 1,
|
||||||
|
"availability_nux": null,
|
||||||
|
"upgrade": null,
|
||||||
|
"base_instructions": "...",
|
||||||
|
"model_messages": {
|
||||||
|
"instructions_template": "...",
|
||||||
|
"instructions_variables": {
|
||||||
|
"personality_default": "",
|
||||||
|
"personality_friendly": "..."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"supports_reasoning_summaries": true,
|
||||||
|
"default_reasoning_summary": "none",
|
||||||
|
"support_verbosity": true,
|
||||||
|
"default_verbosity": "low",
|
||||||
|
"apply_patch_tool_type": "freeform",
|
||||||
|
"web_search_tool_type": "text_and_image",
|
||||||
|
"truncation_policy": {
|
||||||
|
"mode": "tokens",
|
||||||
|
"limit": 10000
|
||||||
|
},
|
||||||
|
"supports_parallel_tool_calls": true,
|
||||||
|
"supports_image_detail_original": true,
|
||||||
|
"context_window": 272000,
|
||||||
|
"effective_context_window_percent": 95,
|
||||||
|
"experimental_supported_tools": [],
|
||||||
|
"input_modalities": [
|
||||||
|
"text",
|
||||||
|
"image"
|
||||||
|
],
|
||||||
|
"supports_search_tool": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Gemini
|
||||||
|
- There is no way to automatically do this. So, use this
|
||||||
|
![[Pasted image 20260401124033.png]]
|
||||||
|
|
||||||
|
The above is for free one. The below contains for all.
|
||||||
|
|
||||||
|
```
|
||||||
|
OPTIONS: [
|
||||||
|
{ value: 'gemini-3.1-pro-preview', label: 'Gemini 3.1 Pro Preview' },
|
||||||
|
{ value: 'gemini-3-pro-preview', label: 'Gemini 3 Pro Preview' },
|
||||||
|
{ value: 'gemini-3-flash-preview', label: 'Gemini 3 Flash Preview' },
|
||||||
|
{ value: 'gemini-2.5-flash', label: 'Gemini 2.5 Flash' },
|
||||||
|
{ value: 'gemini-2.5-pro', label: 'Gemini 2.5 Pro' },
|
||||||
|
{ value: 'gemini-2.0-flash-lite', label: 'Gemini 2.0 Flash Lite' },
|
||||||
|
{ value: 'gemini-2.0-flash', label: 'Gemini 2.0 Flash' },
|
||||||
|
{ value: 'gemini-2.0-pro-exp', label: 'Gemini 2.0 Pro Experimental' },
|
||||||
|
{ value: 'gemini-2.0-flash-thinking-exp', label: 'Gemini 2.0 Flash Thinking' }
|
||||||
|
],
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cursor
|
||||||
|
- spawn `cursor-agent --list-models` and parse the ANSI output.
|
||||||
|
```js
|
||||||
|
function parseModelLine(line) {
|
||||||
|
const trimmed = line.trim();
|
||||||
|
|
||||||
|
if (!trimmed || trimmed === 'Available models' || trimmed.startsWith('Loading models') || trimmed.startsWith('Tip:')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = trimmed.match(/^(.+?)\s+-\s+(.+)$/);
|
||||||
|
if (!match) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = match[1].trim();
|
||||||
|
let description = match[2].trim();
|
||||||
|
const current = /\(current\)/i.test(description);
|
||||||
|
const defaultModel = /\(default\)/i.test(description);
|
||||||
|
|
||||||
|
description = description.replace(/\s*\((current|default)\)/gi, '').replace(/\s{2,}/g, ' ').trim();
|
||||||
|
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
current,
|
||||||
|
default: defaultModel,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseModelsOutput(text) {
|
||||||
|
const models = [];
|
||||||
|
|
||||||
|
for (const line of stripAnsi(text).split(/\r?\n/)) {
|
||||||
|
const parsed = parseModelLine(line);
|
||||||
|
if (parsed) {
|
||||||
|
models.push(parsed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ------------ tHE ABOVE RETURNS ------------
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "auto",
|
||||||
|
"description": "Auto",
|
||||||
|
"current": true,
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "composer-2-fast",
|
||||||
|
"description": "Composer 2 Fast",
|
||||||
|
"current": false,
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "composer-2",
|
||||||
|
"description": "Composer 2",
|
||||||
|
"current": false,
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
# How to fetch session history
|
||||||
|
- In the sessions table, there is a `jsonl_path` column. Go to directly that and parse the JSONLs from there. For `gemini`, the `jsonl_path` actually points to a gemini JSON file (since Gemini stores information in JSON rather than JSONL). DON'T use the LEGACY fetcher.
|
||||||
|
|
||||||
|
# How to search conversations for each provider
|
||||||
|
- Go to all the JSONL path directories from the database and use `@vscode/ripgrep` library for searching something.
|
||||||
|
|
||||||
|
|
||||||
|
# How to change thinking modes for each model
|
||||||
|
## Claude
|
||||||
|
- Passed through `query` options through `effort: <'low' | 'medium' | 'high' | 'max'>`
|
||||||
|
|
||||||
|
Default is high.
|
||||||
|
|
||||||
|
## Codex
|
||||||
|
- passed through `threadOptions`
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
type ModelReasoningEffort = "minimal" | "low" | "medium" | "high" | "xhigh";
|
||||||
|
|
||||||
|
type ThreadOptions = {
|
||||||
|
model?: string;
|
||||||
|
sandboxMode?: SandboxMode;
|
||||||
|
workingDirectory?: string;
|
||||||
|
skipGitRepoCheck?: boolean;
|
||||||
|
modelReasoningEffort?: ModelReasoningEffort;
|
||||||
|
networkAccessEnabled?: boolean;
|
||||||
|
webSearchMode?: WebSearchMode;
|
||||||
|
webSearchEnabled?: boolean;
|
||||||
|
approvalPolicy?: ApprovalMode;
|
||||||
|
additionalDirectories?: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
- `minimal` is supported only by `GPT-5`
|
||||||
|
|
||||||
|
## Gemini
|
||||||
|
- Not changeable. We can only select the different providers that have different thinking levels by themselves.
|
||||||
|
|
||||||
|
## Cursor
|
||||||
|
- Same as gemini.
|
||||||
|
|
||||||
|
|
||||||
|
# How to set/change models at start/after a session response respectively?
|
||||||
|
## Claude
|
||||||
|
- Initially can be set at start using `queryOptions.model`
|
||||||
|
- Just resume the session by updating the model in `threadoptions`
|
||||||
|
|
||||||
|
## Codex
|
||||||
|
- Same as claude
|
||||||
|
|
||||||
|
## Gemini
|
||||||
|
- Just add the `--model <model-name>` property in the new spawned command. If there is something to resume, add `--resume <sessionID>`
|
||||||
|
## Cursor
|
||||||
|
- Just add the `--model <model-name>` property in the new spawned command. If there is something to resume, add `--resume <sessionID>`. In other words, same as gemini.
|
||||||
|
|
||||||
41
docs/testing/llm-unifier-backend-testing.md
Normal file
41
docs/testing/llm-unifier-backend-testing.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# LLM Unifier Backend Testing Report
|
||||||
|
|
||||||
|
Date: 2026-04-06
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
This report validates the backend functionality checklist in `docs/backend/llm-unifier-helper.md`.
|
||||||
|
|
||||||
|
## Test Files Added
|
||||||
|
- `server/src/modules/llm/llm-unifier.providers.test.ts`
|
||||||
|
- `server/src/modules/llm/llm-unifier.sessions.test.ts`
|
||||||
|
|
||||||
|
Each test case includes an inline comment describing which helper requirement it covers.
|
||||||
|
|
||||||
|
## Command Used
|
||||||
|
```powershell
|
||||||
|
$env:TSX_TSCONFIG_PATH='server/tsconfig.json'; npm run test:server -- server/src/modules/llm/llm-unifier.providers.test.ts server/src/modules/llm/llm-unifier.sessions.test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
## Result
|
||||||
|
- Total tests: 32
|
||||||
|
- Passed: 32
|
||||||
|
- Failed: 0
|
||||||
|
|
||||||
|
## Requirement Coverage Matrix
|
||||||
|
| Helper requirement | Coverage |
|
||||||
|
| --- | --- |
|
||||||
|
| Session processing logic orchestration | `llmSessionsService.synchronizeSessions aggregates processed counts and failures`, `llmSessionsService.synchronizeProvider honors fullRescan option` |
|
||||||
|
| Start/resume behavior: Cursor | `cursor provider builds start/resume CLI invocations correctly` |
|
||||||
|
| Start/resume behavior: Gemini | `gemini provider builds start/resume CLI invocations and exposes curated models` |
|
||||||
|
| Start/resume/stop behavior: Codex (`startThread`, `resumeThread`, abort controller) | `codex provider start/resume use correct SDK thread methods and stop aborts signal` |
|
||||||
|
| Claude helper behavior (effort mapping, runtime permission handler, event normalization) | `claude provider helper mappings match unifier contract` |
|
||||||
|
| Model listing: Cursor (`--list-models` parsing) | `cursor provider parses model list output into normalized models` |
|
||||||
|
| Model listing: Gemini (curated options) | `gemini provider builds start/resume CLI invocations and exposes curated models` |
|
||||||
|
| Model listing: Codex (`~/.codex/models_cache.json`) | `codex provider reads models_cache.json and maps model metadata` |
|
||||||
|
| Runtime permission/thinking support constraints | `llmService rejects unsupported runtime permission and thinking mode combinations`, `providers enforce capability gates for model/thinking updates` |
|
||||||
|
| Thinking mode + model preference persistence across launches | `codex provider applies saved model/thinking preferences on subsequent launch` |
|
||||||
|
| Session history from DB `jsonl_path` (JSONL + Gemini JSON), no legacy fetcher path | `llmSessionsService.getSessionHistory parses JSONL and Gemini JSON correctly` |
|
||||||
|
| Session artifact deletion using processor path | `llmSessionsService.deleteSessionArtifacts validates ids and deletes disk/db artifacts` |
|
||||||
|
| Session rename/update path | `llmSessionsService.updateSessionCustomName validates existence before updating` |
|
||||||
|
| Conversation search over indexed transcript paths with provider/case filters | `conversationSearchService searches indexed transcripts with provider and case filters` |
|
||||||
|
|
||||||
56
docs/testing/llm-unifier-helper-2-backend-testing.md
Normal file
56
docs/testing/llm-unifier-helper-2-backend-testing.md
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# LLM Unifier Helper-2 Backend Testing Report
|
||||||
|
|
||||||
|
Date: 2026-04-06
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
This report validates every backend functionality listed in:
|
||||||
|
- `docs/backend/llm-unifier-helper-2.md`
|
||||||
|
|
||||||
|
All test cases include inline comments that describe which helper-2 requirement they cover.
|
||||||
|
|
||||||
|
## Test Files
|
||||||
|
- `server/src/modules/llm/llm-unifier.providers.test.ts`
|
||||||
|
- `server/src/modules/llm/llm-unifier.sessions.test.ts`
|
||||||
|
- `server/src/modules/llm/llm-unifier.images.test.ts`
|
||||||
|
- `server/src/modules/llm/llm-unifier.mcp.test.ts`
|
||||||
|
- `server/src/modules/llm/llm-unifier.skills.test.ts`
|
||||||
|
|
||||||
|
## package.json Scripts
|
||||||
|
- `test:server` now includes the full unifier suite.
|
||||||
|
- Added `test:server:llm-unifier-2` for running only helper-2 unifier coverage.
|
||||||
|
|
||||||
|
## Commands Used
|
||||||
|
```powershell
|
||||||
|
npm run typecheck:server
|
||||||
|
npm run test:server:llm-unifier-2
|
||||||
|
npm run test:server
|
||||||
|
```
|
||||||
|
|
||||||
|
## Results
|
||||||
|
- `typecheck:server`: pass
|
||||||
|
- `test:server:llm-unifier-2`: pass (`30/30`)
|
||||||
|
- `test:server`: pass (`30/30`)
|
||||||
|
|
||||||
|
## Requirement Coverage Matrix
|
||||||
|
| Helper-2 requirement | Test coverage |
|
||||||
|
| --- | --- |
|
||||||
|
| Universal image upload into `.cloudcli/assets` | `llmAssetsService stores uploaded images in .cloudcli/assets` |
|
||||||
|
| Image upload validation for supported image mime types | `llmAssetsService rejects unsupported image mime types` |
|
||||||
|
| Claude image prompt as content blocks with base64 images | `claude provider builds async prompt payload with base64 image blocks` |
|
||||||
|
| Codex image prompt via `local_image` entries | `codex provider sends local_image prompt items when image paths are provided` |
|
||||||
|
| Gemini/Cursor image handling by appending image path array to prompt | `gemini and cursor providers append image path arrays to prompts` |
|
||||||
|
| Start payload imagePaths validation | `llmService rejects invalid imagePaths payloads before provider execution` |
|
||||||
|
| MCP list grouped by User/Local/Project | `llmMcpService handles claude MCP scopes/transports with file-backed persistence` |
|
||||||
|
| MCP add/remove/update behavior backed by provider config files | `llmMcpService handles claude MCP scopes/transports with file-backed persistence`, `llmMcpService handles codex MCP TOML config and capability validation`, `llmMcpService handles gemini and cursor MCP JSON config formats` |
|
||||||
|
| Claude MCP transports: stdio/http/sse and scopes: user/local/project | `llmMcpService handles claude MCP scopes/transports with file-backed persistence` |
|
||||||
|
| Codex MCP transports: stdio/http and scopes: user/project | `llmMcpService handles codex MCP TOML config and capability validation` |
|
||||||
|
| Gemini MCP transports: stdio/http/sse and scopes: user/project | `llmMcpService handles gemini and cursor MCP JSON config formats` |
|
||||||
|
| Cursor MCP transports: stdio/http/sse and scopes: user/project | `llmMcpService handles gemini and cursor MCP JSON config formats` |
|
||||||
|
| Global MCP adder supports only `http` and `stdio` and applies to all providers | `llmMcpService global adder writes to all providers and rejects unsupported transports` |
|
||||||
|
| MCP run/connectivity checks (stdio and http) | `llmMcpService runProviderServer probes stdio and http MCP servers` |
|
||||||
|
| Claude skills fetch (user/project/plugin) and plugin namespacing | `llmSkillsService lists claude user/project/plugin skills with proper invocation names` |
|
||||||
|
| Codex skills fetch (repo/user/admin/system path model; tested repo/user/system paths) and `$` invocation | `llmSkillsService lists codex skills from repo/user/system locations with dollar invocation` |
|
||||||
|
| Gemini skills fetch from documented directories and `/` invocation | `llmSkillsService lists gemini skills from documented directories` |
|
||||||
|
| Cursor skills fetch from documented directories and `/` invocation | `llmSkillsService lists cursor skills from documented directories` |
|
||||||
|
| Existing unifier provider/session baseline behaviors remain passing | `llm-unifier.providers.test.ts`, `llm-unifier.sessions.test.ts` full suite |
|
||||||
|
|
||||||
150
eslint.config.js
150
eslint.config.js
@@ -3,9 +3,7 @@ import tseslint from "typescript-eslint";
|
|||||||
import react from "eslint-plugin-react";
|
import react from "eslint-plugin-react";
|
||||||
import reactHooks from "eslint-plugin-react-hooks";
|
import reactHooks from "eslint-plugin-react-hooks";
|
||||||
import reactRefresh from "eslint-plugin-react-refresh";
|
import reactRefresh from "eslint-plugin-react-refresh";
|
||||||
import { createNodeResolver, importX } from "eslint-plugin-import-x";
|
import importX from "eslint-plugin-import-x";
|
||||||
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
||||||
import boundaries from "eslint-plugin-boundaries";
|
|
||||||
import tailwindcss from "eslint-plugin-tailwindcss";
|
import tailwindcss from "eslint-plugin-tailwindcss";
|
||||||
import unusedImports from "eslint-plugin-unused-imports";
|
import unusedImports from "eslint-plugin-unused-imports";
|
||||||
import globals from "globals";
|
import globals from "globals";
|
||||||
@@ -84,7 +82,7 @@ export default tseslint.config(
|
|||||||
"sibling",
|
"sibling",
|
||||||
"index",
|
"index",
|
||||||
],
|
],
|
||||||
"newlines-between": "always",
|
"newlines-between": "never",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -100,149 +98,5 @@ export default tseslint.config(
|
|||||||
"no-control-regex": "off",
|
"no-control-regex": "off",
|
||||||
"no-useless-escape": "off",
|
"no-useless-escape": "off",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ["server/**/*.{js,ts}"], // apply this block only to backend source files
|
|
||||||
ignores: ["server/**/*.d.ts"], // skip generated declaration files in backend linting
|
|
||||||
plugins: {
|
|
||||||
boundaries, // enforce backend architecture boundaries (module-to-module contracts)
|
|
||||||
"import-x": importX, // keep import hygiene rules (duplicates, unresolved paths, etc.)
|
|
||||||
"unused-imports": unusedImports, // remove dead imports/variables from backend files
|
|
||||||
},
|
|
||||||
languageOptions: {
|
|
||||||
parser: tseslint.parser, // parse both JS and TS syntax in backend files
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: "latest", // support modern ECMAScript syntax in backend code
|
|
||||||
sourceType: "module", // treat backend files as ESM modules
|
|
||||||
},
|
|
||||||
globals: {
|
|
||||||
...globals.node, // expose Node.js globals such as process, Buffer, and __dirname equivalents
|
|
||||||
},
|
|
||||||
},
|
|
||||||
settings: {
|
|
||||||
"boundaries/include": ["server/**/*.{js,ts}"], // only analyze dependency boundaries inside backend files
|
|
||||||
"import/resolver": {
|
|
||||||
// boundaries resolves imports through eslint-module-utils, which reads the classic
|
|
||||||
// import/resolver setting instead of import-x/resolver-next.
|
|
||||||
typescript: {
|
|
||||||
project: ["server/tsconfig.json"], // resolve backend aliases using the canonical backend tsconfig
|
|
||||||
alwaysTryTypes: true, // keep normal TS package/type resolution working alongside aliases
|
|
||||||
},
|
|
||||||
node: {
|
|
||||||
extensions: [".mjs", ".cjs", ".js", ".json", ".node", ".ts", ".tsx"], // preserve Node-style fallback resolution for plain files
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"import-x/resolver-next": [
|
|
||||||
// ESLint's import plugin does not read tsconfig path aliases on its own.
|
|
||||||
// This resolver teaches import-x how to understand the backend-only "@/*"
|
|
||||||
// mapping defined in server/tsconfig.json, which fixes false no-unresolved errors in editors.
|
|
||||||
createTypeScriptImportResolver({
|
|
||||||
project: ["server/tsconfig.json"], // point the resolver at the canonical backend tsconfig instead of the frontend one
|
|
||||||
alwaysTryTypes: true, // keep standard TypeScript package resolution working while backend aliases are enabled
|
|
||||||
}),
|
|
||||||
// Keep Node-style resolution available for normal package imports and plain relative JS files.
|
|
||||||
// The TypeScript resolver handles aliases, while the Node resolver preserves the expected fallback behavior.
|
|
||||||
createNodeResolver({
|
|
||||||
extensions: [".mjs", ".cjs", ".js", ".json", ".node", ".ts", ".tsx"],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
"boundaries/elements": [
|
|
||||||
{
|
|
||||||
type: "backend-shared-type-contract", // shared backend type/interface contracts that modules may consume without creating runtime coupling
|
|
||||||
pattern: [
|
|
||||||
"server/shared/types.{js,ts}",
|
|
||||||
"server/shared/interfaces.{js,ts}",
|
|
||||||
], // keep backend modules on explicit shared contract files for erased imports only
|
|
||||||
mode: "file", // treat each shared contract file itself as the boundary element instead of the whole folder
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "backend-shared-utils", // shared backend runtime helpers that modules may import directly
|
|
||||||
pattern: ["server/shared/utils.{js,ts}"], // classify the shared utils file so modules can depend on it explicitly
|
|
||||||
mode: "file",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "backend-legacy-runtime", // legacy runtime persistence modules used while providers migrate into server/modules
|
|
||||||
pattern: [
|
|
||||||
"server/projects.js",
|
|
||||||
"server/sessionManager.js",
|
|
||||||
"server/database/*.{js,ts}",
|
|
||||||
"server/utils/runtime-paths.js",
|
|
||||||
], // provider history loading still resolves session data through these legacy runtime/database files
|
|
||||||
mode: "file",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "backend-module", // logical element name used by boundaries rules below
|
|
||||||
pattern: "server/modules/*", // each direct folder in server/modules is treated as one module boundary
|
|
||||||
mode: "folder", // classify dependencies at folder-module level (not per individual file)
|
|
||||||
capture: ["moduleName"], // capture the module folder name for messages/debugging/template use
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
// --- Unused imports/vars (backend) ---
|
|
||||||
"unused-imports/no-unused-imports": "warn", // warn when imports are not used so they can be cleaned up
|
|
||||||
"unused-imports/no-unused-vars": "off", // keep backend signal focused on dead imports instead of local unused variables
|
|
||||||
|
|
||||||
// --- Import hygiene (backend) ---
|
|
||||||
"import-x/no-duplicates": "warn", // prevent duplicate import lines from the same module
|
|
||||||
"import-x/order": [
|
|
||||||
"warn", // keep backend import grouping/order consistent with the frontend config
|
|
||||||
{
|
|
||||||
groups: [
|
|
||||||
"builtin", // Node built-ins such as fs, path, and url come first
|
|
||||||
"external", // third-party packages come after built-ins
|
|
||||||
"internal", // aliased internal imports such as @/... come next
|
|
||||||
"parent", // ../ imports come after aliased internal imports
|
|
||||||
"sibling", // ./foo imports come after parent imports
|
|
||||||
"index", // bare ./ imports stay last
|
|
||||||
],
|
|
||||||
"newlines-between": "always", // require a blank line between import groups in backend files too
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"import-x/no-unresolved": "error", // fail when an import path cannot be resolved
|
|
||||||
"import-x/no-useless-path-segments": "warn", // prefer cleaner paths (remove redundant ./ and ../ segments)
|
|
||||||
"import-x/no-absolute-path": "error", // disallow absolute filesystem imports in backend files
|
|
||||||
|
|
||||||
// --- General safety/style (backend) ---
|
|
||||||
eqeqeq: ["warn", "always", { null: "ignore" }], // avoid accidental coercion while still allowing x == null checks
|
|
||||||
|
|
||||||
// --- Architecture boundaries (backend modules) ---
|
|
||||||
"boundaries/dependencies": [
|
|
||||||
"error", // treat architecture violations as lint errors
|
|
||||||
{
|
|
||||||
default: "allow", // allow normal imports unless a rule below explicitly disallows them
|
|
||||||
checkInternals: false, // do not apply these cross-module rules to imports inside the same module
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
from: { type: "backend-module" }, // modules may depend on shared type/interface contracts only as erased type-only imports
|
|
||||||
to: { type: "backend-shared-type-contract" },
|
|
||||||
disallow: {
|
|
||||||
dependency: { kind: ["value", "typeof"] },
|
|
||||||
}, // block runtime imports so shared contracts stay compile-time only instead of becoming hidden shared modules
|
|
||||||
message:
|
|
||||||
"Backend modules may only use `import type` when importing from server/shared/types.ts or server/shared/interfaces.ts.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
to: { type: "backend-module" }, // when importing anything that belongs to another backend module
|
|
||||||
disallow: { to: { internalPath: "**" } }, // block all direct/deep imports into module internals by default
|
|
||||||
message:
|
|
||||||
"Cross-module imports must go through that module's barrel file (server/modules/<module>/index.ts or index.js).", // explicit error message for architecture violations
|
|
||||||
},
|
|
||||||
{
|
|
||||||
to: { type: "backend-module" }, // same target scope as the disallow rule above
|
|
||||||
allow: {
|
|
||||||
to: {
|
|
||||||
internalPath: [
|
|
||||||
"index", // allow extensionless barrel imports resolved as module root index
|
|
||||||
"index.{js,mjs,cjs,ts,tsx}", // allow explicit index.* barrel file imports
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}, // re-allow only public module entry points (barrel files)
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"boundaries/no-unknown": "error", // fail fast if boundaries cannot classify a dependency, which prevents silent rule bypasses
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
471
package-lock.json
generated
471
package-lock.json
generated
@@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "@cloudcli-ai/cloudcli",
|
"name": "@siteboon/claude-code-ui",
|
||||||
"version": "1.29.2",
|
"version": "1.26.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@cloudcli-ai/cloudcli",
|
"name": "@siteboon/claude-code-ui",
|
||||||
"version": "1.29.2",
|
"version": "1.26.3",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@anthropic-ai/claude-agent-sdk": "^0.2.59",
|
"@anthropic-ai/claude-agent-sdk": "^0.2.59",
|
||||||
"@codemirror/lang-css": "^6.3.1",
|
"@codemirror/lang-css": "^6.3.1",
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
"@openai/codex-sdk": "^0.101.0",
|
"@openai/codex-sdk": "^0.101.0",
|
||||||
"@replit/codemirror-minimap": "^0.5.2",
|
"@replit/codemirror-minimap": "^0.5.2",
|
||||||
"@tailwindcss/typography": "^0.5.16",
|
"@tailwindcss/typography": "^0.5.16",
|
||||||
|
"@types/multer": "^2.1.0",
|
||||||
"@uiw/react-codemirror": "^4.23.13",
|
"@uiw/react-codemirror": "^4.23.13",
|
||||||
"@xterm/addon-clipboard": "^0.1.0",
|
"@xterm/addon-clipboard": "^0.1.0",
|
||||||
"@xterm/addon-fit": "^0.10.0",
|
"@xterm/addon-fit": "^0.10.0",
|
||||||
@@ -69,25 +70,30 @@
|
|||||||
"ws": "^8.14.2"
|
"ws": "^8.14.2"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"cloudcli": "dist-server/server/cli.js"
|
"claude-code-ui": "server/cli.js",
|
||||||
|
"cloudcli": "server/cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^20.4.3",
|
"@commitlint/cli": "^20.4.3",
|
||||||
"@commitlint/config-conventional": "^20.4.3",
|
"@commitlint/config-conventional": "^20.4.3",
|
||||||
"@eslint/js": "^9.39.3",
|
"@eslint/js": "^9.39.3",
|
||||||
"@release-it/conventional-changelog": "^10.0.5",
|
"@release-it/conventional-changelog": "^10.0.5",
|
||||||
|
"@types/bcrypt": "^6.0.0",
|
||||||
|
"@types/better-sqlite3": "^7.6.13",
|
||||||
|
"@types/cors": "^2.8.19",
|
||||||
"@types/cross-spawn": "^6.0.6",
|
"@types/cross-spawn": "^6.0.6",
|
||||||
"@types/express": "^5.0.6",
|
"@types/express": "^5.0.3",
|
||||||
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
"@types/node": "^22.19.7",
|
"@types/node": "^22.19.7",
|
||||||
"@types/react": "^18.2.43",
|
"@types/react": "^18.2.43",
|
||||||
"@types/react-dom": "^18.2.17",
|
"@types/react-dom": "^18.2.17",
|
||||||
|
"@types/web-push": "^3.6.4",
|
||||||
|
"@types/ws": "^8.18.1",
|
||||||
"@vitejs/plugin-react": "^4.6.0",
|
"@vitejs/plugin-react": "^4.6.0",
|
||||||
"auto-changelog": "^2.5.0",
|
"auto-changelog": "^2.5.0",
|
||||||
"autoprefixer": "^10.4.16",
|
"autoprefixer": "^10.4.16",
|
||||||
"concurrently": "^8.2.2",
|
"concurrently": "^8.2.2",
|
||||||
"eslint": "^9.39.3",
|
"eslint": "^9.39.3",
|
||||||
"eslint-import-resolver-typescript": "^4.4.4",
|
|
||||||
"eslint-plugin-boundaries": "^6.0.2",
|
|
||||||
"eslint-plugin-import-x": "^4.16.1",
|
"eslint-plugin-import-x": "^4.16.1",
|
||||||
"eslint-plugin-react": "^7.37.5",
|
"eslint-plugin-react": "^7.37.5",
|
||||||
"eslint-plugin-react-hooks": "^7.0.1",
|
"eslint-plugin-react-hooks": "^7.0.1",
|
||||||
@@ -103,7 +109,7 @@
|
|||||||
"sharp": "^0.34.2",
|
"sharp": "^0.34.2",
|
||||||
"tailwindcss": "^3.4.0",
|
"tailwindcss": "^3.4.0",
|
||||||
"tsc-alias": "^1.8.16",
|
"tsc-alias": "^1.8.16",
|
||||||
"tsx": "^4.21.0",
|
"tsx": "^4.20.6",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"typescript-eslint": "^8.56.1",
|
"typescript-eslint": "^8.56.1",
|
||||||
"vite": "^7.0.4"
|
"vite": "^7.0.4"
|
||||||
@@ -449,23 +455,6 @@
|
|||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@boundaries/elements": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@boundaries/elements/-/elements-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-sAWO3D8PFP6pBXdxxW93SQi/KQqqhE2AAHo3AgWfdtJXwO6bfK6/wUN81XnOZk0qRC6vHzUEKhjwVD9dtDWvxg==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"eslint-import-resolver-node": "0.3.9",
|
|
||||||
"eslint-module-utils": "2.12.1",
|
|
||||||
"handlebars": "4.7.9",
|
|
||||||
"is-core-module": "2.16.1",
|
|
||||||
"micromatch": "4.0.8"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=18.18"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@codemirror/autocomplete": {
|
"node_modules/@codemirror/autocomplete": {
|
||||||
"version": "6.18.6",
|
"version": "6.18.6",
|
||||||
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.18.6.tgz",
|
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.18.6.tgz",
|
||||||
@@ -3754,11 +3743,30 @@
|
|||||||
"@babel/types": "^7.20.7"
|
"@babel/types": "^7.20.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/bcrypt": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/bcrypt/-/bcrypt-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-/oJGukuH3D2+D+3H4JWLaAsJ/ji86dhRidzZ/Od7H/i8g+aCmvkeCc6Ni/f9uxGLSQVCRZkX2/lqEFG2BvWtlQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/better-sqlite3": {
|
||||||
|
"version": "7.6.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.13.tgz",
|
||||||
|
"integrity": "sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/body-parser": {
|
"node_modules/@types/body-parser": {
|
||||||
"version": "1.19.6",
|
"version": "1.19.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.6.tgz",
|
||||||
"integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==",
|
"integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/connect": "*",
|
"@types/connect": "*",
|
||||||
@@ -3769,6 +3777,15 @@
|
|||||||
"version": "3.4.38",
|
"version": "3.4.38",
|
||||||
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz",
|
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz",
|
||||||
"integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==",
|
"integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/cors": {
|
||||||
|
"version": "2.8.19",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.19.tgz",
|
||||||
|
"integrity": "sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -3813,7 +3830,6 @@
|
|||||||
"version": "5.0.6",
|
"version": "5.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.6.tgz",
|
||||||
"integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==",
|
"integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/body-parser": "*",
|
"@types/body-parser": "*",
|
||||||
@@ -3825,7 +3841,6 @@
|
|||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.1.1.tgz",
|
||||||
"integrity": "sha512-v4zIMr/cX7/d2BpAEX3KNKL/JrT1s43s96lLvvdTmza1oEvDudCqK9aF/djc/SWgy8Yh0h30TZx5VpzqFCxk5A==",
|
"integrity": "sha512-v4zIMr/cX7/d2BpAEX3KNKL/JrT1s43s96lLvvdTmza1oEvDudCqK9aF/djc/SWgy8Yh0h30TZx5VpzqFCxk5A==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@@ -3847,7 +3862,6 @@
|
|||||||
"version": "2.0.5",
|
"version": "2.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz",
|
||||||
"integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==",
|
"integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/json-schema": {
|
"node_modules/@types/json-schema": {
|
||||||
@@ -3857,6 +3871,17 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/jsonwebtoken": {
|
||||||
|
"version": "9.0.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.10.tgz",
|
||||||
|
"integrity": "sha512-asx5hIG9Qmf/1oStypjanR7iKTv0gXQ1Ov/jfrX6kS/EO0OFni8orbmGCn0672NHR3kXHwpAwR+B368ZGN/2rA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/ms": "*",
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/katex": {
|
"node_modules/@types/katex": {
|
||||||
"version": "0.16.7",
|
"version": "0.16.7",
|
||||||
"resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz",
|
"resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz",
|
||||||
@@ -3878,11 +3903,19 @@
|
|||||||
"integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==",
|
"integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/multer": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/multer/-/multer-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-zYZb0+nJhOHtPpGDb3vqPjwpdeGlGC157VpkqNQL+UU2qwoacoQ7MpsAmUptI/0Oa127X32JzWDqQVEXp2RcIA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/express": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "22.19.7",
|
"version": "22.19.7",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.7.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.7.tgz",
|
||||||
"integrity": "sha512-MciR4AKGHWl7xwxkBa6xUGxQJ4VBOmPTF7sL+iGzuahOFaO0jHCsuEfS80pan1ef4gWId1oWOweIhrDEYLuaOw==",
|
"integrity": "sha512-MciR4AKGHWl7xwxkBa6xUGxQJ4VBOmPTF7sL+iGzuahOFaO0jHCsuEfS80pan1ef4gWId1oWOweIhrDEYLuaOw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~6.21.0"
|
"undici-types": "~6.21.0"
|
||||||
@@ -3912,14 +3945,12 @@
|
|||||||
"version": "6.15.0",
|
"version": "6.15.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.15.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.15.0.tgz",
|
||||||
"integrity": "sha512-JawvT8iBVWpzTrz3EGw9BTQFg3BQNmwERdKE22vlTxawwtbyUSlMppvZYKLZzB5zgACXdXxbD3m1bXaMqP/9ow==",
|
"integrity": "sha512-JawvT8iBVWpzTrz3EGw9BTQFg3BQNmwERdKE22vlTxawwtbyUSlMppvZYKLZzB5zgACXdXxbD3m1bXaMqP/9ow==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/range-parser": {
|
"node_modules/@types/range-parser": {
|
||||||
"version": "1.2.7",
|
"version": "1.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz",
|
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz",
|
||||||
"integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==",
|
"integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/react": {
|
"node_modules/@types/react": {
|
||||||
@@ -3946,7 +3977,6 @@
|
|||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.1.tgz",
|
||||||
"integrity": "sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==",
|
"integrity": "sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
@@ -3956,7 +3986,6 @@
|
|||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-2.2.0.tgz",
|
||||||
"integrity": "sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ==",
|
"integrity": "sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/http-errors": "*",
|
"@types/http-errors": "*",
|
||||||
@@ -3969,6 +3998,26 @@
|
|||||||
"integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==",
|
"integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/web-push": {
|
||||||
|
"version": "3.6.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/web-push/-/web-push-3.6.4.tgz",
|
||||||
|
"integrity": "sha512-GnJmSr40H3RAnj0s34FNTcJi1hmWFV5KXugE0mYWnYhgTAHLJ/dJKAwDmvPJYMke0RplY2XE9LnM4hqSqKIjhQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/ws": {
|
||||||
|
"version": "8.18.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz",
|
||||||
|
"integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||||
"version": "8.56.1",
|
"version": "8.56.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.56.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.56.1.tgz",
|
||||||
@@ -7361,112 +7410,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-import-resolver-node": {
|
|
||||||
"version": "0.3.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz",
|
|
||||||
"integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"debug": "^3.2.7",
|
|
||||||
"is-core-module": "^2.13.0",
|
|
||||||
"resolve": "^1.22.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/eslint-import-resolver-node/node_modules/debug": {
|
|
||||||
"version": "3.2.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
|
|
||||||
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"ms": "^2.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/eslint-import-resolver-typescript": {
|
|
||||||
"version": "4.4.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-4.4.4.tgz",
|
|
||||||
"integrity": "sha512-1iM2zeBvrYmUNTj2vSC/90JTHDth+dfOfiNKkxApWRsTJYNrc8rOdxxIf5vazX+BiAXTeOT0UvWpGI/7qIWQOw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"debug": "^4.4.1",
|
|
||||||
"eslint-import-context": "^0.1.8",
|
|
||||||
"get-tsconfig": "^4.10.1",
|
|
||||||
"is-bun-module": "^2.0.0",
|
|
||||||
"stable-hash-x": "^0.2.0",
|
|
||||||
"tinyglobby": "^0.2.14",
|
|
||||||
"unrs-resolver": "^1.7.11"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "^16.17.0 || >=18.6.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://opencollective.com/eslint-import-resolver-typescript"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"eslint": "*",
|
|
||||||
"eslint-plugin-import": "*",
|
|
||||||
"eslint-plugin-import-x": "*"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"eslint-plugin-import": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"eslint-plugin-import-x": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/eslint-module-utils": {
|
|
||||||
"version": "2.12.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.12.1.tgz",
|
|
||||||
"integrity": "sha512-L8jSWTze7K2mTg0vos/RuLRS5soomksDPoJLXIslC7c8Wmut3bx7CPpJijDcBZtxQ5lrbUdM+s0OlNbz0DCDNw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"debug": "^3.2.7"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"eslint": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/eslint-module-utils/node_modules/debug": {
|
|
||||||
"version": "3.2.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
|
|
||||||
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"ms": "^2.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/eslint-plugin-boundaries": {
|
|
||||||
"version": "6.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-boundaries/-/eslint-plugin-boundaries-6.0.2.tgz",
|
|
||||||
"integrity": "sha512-wSHgiYeMEbziP91lH0UQ9oslgF2djG1x+LV9z/qO19ggMKZaCB8pKIGePHAY91eLF4EAgpsxQk8MRSFGRPfPzw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"@boundaries/elements": "2.0.1",
|
|
||||||
"chalk": "4.1.2",
|
|
||||||
"eslint-import-resolver-node": "0.3.9",
|
|
||||||
"eslint-module-utils": "2.12.1",
|
|
||||||
"handlebars": "4.7.9",
|
|
||||||
"micromatch": "4.0.8"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=18.18"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"eslint": ">=6.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/eslint-plugin-import-x": {
|
"node_modules/eslint-plugin-import-x": {
|
||||||
"version": "4.16.1",
|
"version": "4.16.1",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-4.16.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-4.16.1.tgz",
|
||||||
@@ -8825,9 +8768,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/handlebars": {
|
"node_modules/handlebars": {
|
||||||
"version": "4.7.9",
|
"version": "4.7.8",
|
||||||
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.9.tgz",
|
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz",
|
||||||
"integrity": "sha512-4E71E0rpOaQuJR2A3xDZ+GM1HyWYv1clR58tC8emQNeQe3RH7MAzSbat+V0wG78LQBo6m6bzSG/L4pBuCsgnUQ==",
|
"integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -9717,29 +9660,6 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/is-bun-module": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-gNCGbnnnnFAUGKeZ9PdbyeGYJqewpmc2aKHUEMO5nQPWU9lOmv7jcmQIv+qHD8fXW6W7qfuCwX4rY9LNRjXrkQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"semver": "^7.7.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/is-bun-module/node_modules/semver": {
|
|
||||||
"version": "7.7.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
|
|
||||||
"integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
|
||||||
"bin": {
|
|
||||||
"semver": "bin/semver.js"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/is-callable": {
|
"node_modules/is-callable": {
|
||||||
"version": "1.2.7",
|
"version": "1.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
|
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
|
||||||
@@ -16940,9 +16860,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/aix-ppc64": {
|
"node_modules/tsx/node_modules/@esbuild/aix-ppc64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz",
|
||||||
"integrity": "sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg==",
|
"integrity": "sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
@@ -16957,9 +16877,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/android-arm": {
|
"node_modules/tsx/node_modules/@esbuild/android-arm": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.3.tgz",
|
||||||
"integrity": "sha512-jbPXvB4Yj2yBV7HUfE2KHe4GJX51QplCN1pGbYjvsyCZbQmies29EoJbkEc+vYuU5o45AfQn37vZlyXy4YJ8RQ==",
|
"integrity": "sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
@@ -16974,9 +16894,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/android-arm64": {
|
"node_modules/tsx/node_modules/@esbuild/android-arm64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-62dPZHpIXzvChfvfLJow3q5dDtiNMkwiRzPylSCfriLvZeq0a1bWChrGx/BbUbPwOrsWKMn8idSllklzBy+dgQ==",
|
"integrity": "sha512-YdghPYUmj/FX2SYKJ0OZxf+iaKgMsKHVPF1MAq/P8WirnSpCStzKJFjOjzsW0QQ7oIAiccHdcqjbHmJxRb/dmg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -16991,9 +16911,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/android-x64": {
|
"node_modules/tsx/node_modules/@esbuild/android-x64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-x5VpMODneVDb70PYV2VQOmIUUiBtY3D3mPBG8NxVk5CogneYhkR7MmM3yR/uMdITLrC1ml/NV1rj4bMJuy9MCg==",
|
"integrity": "sha512-IN/0BNTkHtk8lkOM8JWAYFg4ORxBkZQf9zXiEOfERX/CzxW3Vg1ewAhU7QSWQpVIzTW+b8Xy+lGzdYXV6UZObQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -17008,9 +16928,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/darwin-arm64": {
|
"node_modules/tsx/node_modules/@esbuild/darwin-arm64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-5lckdqeuBPlKUwvoCXIgI2D9/ABmPq3Rdp7IfL70393YgaASt7tbju3Ac+ePVi3KDH6N2RqePfHnXkaDtY9fkw==",
|
"integrity": "sha512-Re491k7ByTVRy0t3EKWajdLIr0gz2kKKfzafkth4Q8A5n1xTHrkqZgLLjFEHVD+AXdUGgQMq+Godfq45mGpCKg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -17025,9 +16945,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/darwin-x64": {
|
"node_modules/tsx/node_modules/@esbuild/darwin-x64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-rYnXrKcXuT7Z+WL5K980jVFdvVKhCHhUwid+dDYQpH+qu+TefcomiMAJpIiC2EM3Rjtq0sO3StMV/+3w3MyyqQ==",
|
"integrity": "sha512-vHk/hA7/1AckjGzRqi6wbo+jaShzRowYip6rt6q7VYEDX4LEy1pZfDpdxCBnGtl+A5zq8iXDcyuxwtv3hNtHFg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -17042,9 +16962,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/freebsd-arm64": {
|
"node_modules/tsx/node_modules/@esbuild/freebsd-arm64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-B48PqeCsEgOtzME2GbNM2roU29AMTuOIN91dsMO30t+Ydis3z/3Ngoj5hhnsOSSwNzS+6JppqWsuhTp6E82l2w==",
|
"integrity": "sha512-ipTYM2fjt3kQAYOvo6vcxJx3nBYAzPjgTCk7QEgZG8AUO3ydUhvelmhrbOheMnGOlaSFUoHXB6un+A7q4ygY9w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -17059,9 +16979,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/freebsd-x64": {
|
"node_modules/tsx/node_modules/@esbuild/freebsd-x64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-jOBDK5XEjA4m5IJK3bpAQF9/Lelu/Z9ZcdhTRLf4cajlB+8VEhFFRjWgfy3M1O4rO2GQ/b2dLwCUGpiF/eATNQ==",
|
"integrity": "sha512-dDk0X87T7mI6U3K9VjWtHOXqwAMJBNN2r7bejDsc+j03SEjtD9HrOl8gVFByeM0aJksoUuUVU9TBaZa2rgj0oA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -17076,9 +16996,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/linux-arm": {
|
"node_modules/tsx/node_modules/@esbuild/linux-arm": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.3.tgz",
|
||||||
"integrity": "sha512-RkT/YXYBTSULo3+af8Ib0ykH8u2MBh57o7q/DAs3lTJlyVQkgQvlrPTnjIzzRPQyavxtPtfg0EopvDyIt0j1rA==",
|
"integrity": "sha512-s6nPv2QkSupJwLYyfS+gwdirm0ukyTFNl3KTgZEAiJDd+iHZcbTPPcWCcRYH+WlNbwChgH2QkE9NSlNrMT8Gfw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
@@ -17093,9 +17013,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/linux-arm64": {
|
"node_modules/tsx/node_modules/@esbuild/linux-arm64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-RZPHBoxXuNnPQO9rvjh5jdkRmVizktkT7TCDkDmQ0W2SwHInKCAV95GRuvdSvA7w4VMwfCjUiPwDi0ZO6Nfe9A==",
|
"integrity": "sha512-sZOuFz/xWnZ4KH3YfFrKCf1WyPZHakVzTiqji3WDc0BCl2kBwiJLCXpzLzUBLgmp4veFZdvN5ChW4Eq/8Fc2Fg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -17110,9 +17030,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/linux-ia32": {
|
"node_modules/tsx/node_modules/@esbuild/linux-ia32": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.3.tgz",
|
||||||
"integrity": "sha512-GA48aKNkyQDbd3KtkplYWT102C5sn/EZTY4XROkxONgruHPU72l+gW+FfF8tf2cFjeHaRbWpOYa/uRBz/Xq1Pg==",
|
"integrity": "sha512-yGlQYjdxtLdh0a3jHjuwOrxQjOZYD/C9PfdbgJJF3TIZWnm/tMd/RcNiLngiu4iwcBAOezdnSLAwQDPqTmtTYg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@@ -17127,9 +17047,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/linux-loong64": {
|
"node_modules/tsx/node_modules/@esbuild/linux-loong64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.3.tgz",
|
||||||
"integrity": "sha512-a4POruNM2oWsD4WKvBSEKGIiWQF8fZOAsycHOt6JBpZ+JN2n2JH9WAv56SOyu9X5IqAjqSIPTaJkqN8F7XOQ5Q==",
|
"integrity": "sha512-WO60Sn8ly3gtzhyjATDgieJNet/KqsDlX5nRC5Y3oTFcS1l0KWba+SEa9Ja1GfDqSF1z6hif/SkpQJbL63cgOA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"loong64"
|
"loong64"
|
||||||
],
|
],
|
||||||
@@ -17144,9 +17064,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/linux-mips64el": {
|
"node_modules/tsx/node_modules/@esbuild/linux-mips64el": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.3.tgz",
|
||||||
"integrity": "sha512-KabT5I6StirGfIz0FMgl1I+R1H73Gp0ofL9A3nG3i/cYFJzKHhouBV5VWK1CSgKvVaG4q1RNpCTR2LuTVB3fIw==",
|
"integrity": "sha512-APsymYA6sGcZ4pD6k+UxbDjOFSvPWyZhjaiPyl/f79xKxwTnrn5QUnXR5prvetuaSMsb4jgeHewIDCIWljrSxw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"mips64el"
|
"mips64el"
|
||||||
],
|
],
|
||||||
@@ -17161,9 +17081,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/linux-ppc64": {
|
"node_modules/tsx/node_modules/@esbuild/linux-ppc64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.3.tgz",
|
||||||
"integrity": "sha512-gRsL4x6wsGHGRqhtI+ifpN/vpOFTQtnbsupUF5R5YTAg+y/lKelYR1hXbnBdzDjGbMYjVJLJTd2OFmMewAgwlQ==",
|
"integrity": "sha512-eizBnTeBefojtDb9nSh4vvVQ3V9Qf9Df01PfawPcRzJH4gFSgrObw+LveUyDoKU3kxi5+9RJTCWlj4FjYXVPEA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
@@ -17178,9 +17098,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/linux-riscv64": {
|
"node_modules/tsx/node_modules/@esbuild/linux-riscv64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.3.tgz",
|
||||||
"integrity": "sha512-hL25LbxO1QOngGzu2U5xeXtxXcW+/GvMN3ejANqXkxZ/opySAZMrc+9LY/WyjAan41unrR3YrmtTsUpwT66InQ==",
|
"integrity": "sha512-3Emwh0r5wmfm3ssTWRQSyVhbOHvqegUDRd0WhmXKX2mkHJe1SFCMJhagUleMq+Uci34wLSipf8Lagt4LlpRFWQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
@@ -17195,9 +17115,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/linux-s390x": {
|
"node_modules/tsx/node_modules/@esbuild/linux-s390x": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.3.tgz",
|
||||||
"integrity": "sha512-2k8go8Ycu1Kb46vEelhu1vqEP+UeRVj2zY1pSuPdgvbd5ykAw82Lrro28vXUrRmzEsUV0NzCf54yARIK8r0fdw==",
|
"integrity": "sha512-pBHUx9LzXWBc7MFIEEL0yD/ZVtNgLytvx60gES28GcWMqil8ElCYR4kvbV2BDqsHOvVDRrOxGySBM9Fcv744hw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"s390x"
|
"s390x"
|
||||||
],
|
],
|
||||||
@@ -17212,9 +17132,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/linux-x64": {
|
"node_modules/tsx/node_modules/@esbuild/linux-x64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-hzznmADPt+OmsYzw1EE33ccA+HPdIqiCRq7cQeL1Jlq2gb1+OyWBkMCrYGBJ+sxVzve2ZJEVeePbLM2iEIZSxA==",
|
"integrity": "sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -17229,9 +17149,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/netbsd-arm64": {
|
"node_modules/tsx/node_modules/@esbuild/netbsd-arm64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-b6pqtrQdigZBwZxAn1UpazEisvwaIDvdbMbmrly7cDTMFnw/+3lVxxCTGOrkPVnsYIosJJXAsILG9XcQS+Yu6w==",
|
"integrity": "sha512-sDpk0RgmTCR/5HguIZa9n9u+HVKf40fbEUt+iTzSnCaGvY9kFP0YKBWZtJaraonFnqef5SlJ8/TiPAxzyS+UoA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -17246,9 +17166,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/netbsd-x64": {
|
"node_modules/tsx/node_modules/@esbuild/netbsd-x64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-OfatkLojr6U+WN5EDYuoQhtM+1xco+/6FSzJJnuWiUw5eVcicbyK3dq5EeV/QHT1uy6GoDhGbFpprUiHUYggrw==",
|
"integrity": "sha512-P14lFKJl/DdaE00LItAukUdZO5iqNH7+PjoBm+fLQjtxfcfFE20Xf5CrLsmZdq5LFFZzb5JMZ9grUwvtVYzjiA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -17263,9 +17183,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/openbsd-arm64": {
|
"node_modules/tsx/node_modules/@esbuild/openbsd-arm64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-AFuojMQTxAz75Fo8idVcqoQWEHIXFRbOc1TrVcFSgCZtQfSdc1RXgB3tjOn/krRHENUB4j00bfGjyl2mJrU37A==",
|
"integrity": "sha512-AIcMP77AvirGbRl/UZFTq5hjXK+2wC7qFRGoHSDrZ5v5b8DK/GYpXW3CPRL53NkvDqb9D+alBiC/dV0Fb7eJcw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -17280,9 +17200,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/openbsd-x64": {
|
"node_modules/tsx/node_modules/@esbuild/openbsd-x64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-+A1NJmfM8WNDv5CLVQYJ5PshuRm/4cI6WMZRg1by1GwPIQPCTs1GLEUHwiiQGT5zDdyLiRM/l1G0Pv54gvtKIg==",
|
"integrity": "sha512-DnW2sRrBzA+YnE70LKqnM3P+z8vehfJWHXECbwBmH/CU51z6FiqTQTHFenPlHmo3a8UgpLyH3PT+87OViOh1AQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -17297,9 +17217,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/openharmony-arm64": {
|
"node_modules/tsx/node_modules/@esbuild/openharmony-arm64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-+KrvYb/C8zA9CU/g0sR6w2RBw7IGc5J2BPnc3dYc5VJxHCSF1yNMxTV5LQ7GuKteQXZtspjFbiuW5/dOj7H4Yw==",
|
"integrity": "sha512-NinAEgr/etERPTsZJ7aEZQvvg/A6IsZG/LgZy+81wON2huV7SrK3e63dU0XhyZP4RKGyTm7aOgmQk0bGp0fy2g==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -17314,9 +17234,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/sunos-x64": {
|
"node_modules/tsx/node_modules/@esbuild/sunos-x64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-ikktIhFBzQNt/QDyOL580ti9+5mL/YZeUPKU2ivGtGjdTYoqz6jObj6nOMfhASpS4GU4Q/Clh1QtxWAvcYKamA==",
|
"integrity": "sha512-PanZ+nEz+eWoBJ8/f8HKxTTD172SKwdXebZ0ndd953gt1HRBbhMsaNqjTyYLGLPdoWHy4zLU7bDVJztF5f3BHA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -17331,9 +17251,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/win32-arm64": {
|
"node_modules/tsx/node_modules/@esbuild/win32-arm64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.3.tgz",
|
||||||
"integrity": "sha512-7yRhbHvPqSpRUV7Q20VuDwbjW5kIMwTHpptuUzV+AA46kiPze5Z7qgt6CLCK3pWFrHeNfDd1VKgyP4O+ng17CA==",
|
"integrity": "sha512-B2t59lWWYrbRDw/tjiWOuzSsFh1Y/E95ofKz7rIVYSQkUYBjfSgf6oeYPNWHToFRr2zx52JKApIcAS/D5TUBnA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -17348,9 +17268,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/win32-ia32": {
|
"node_modules/tsx/node_modules/@esbuild/win32-ia32": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.3.tgz",
|
||||||
"integrity": "sha512-SmwKXe6VHIyZYbBLJrhOoCJRB/Z1tckzmgTLfFYOfpMAx63BJEaL9ExI8x7v0oAO3Zh6D/Oi1gVxEYr5oUCFhw==",
|
"integrity": "sha512-QLKSFeXNS8+tHW7tZpMtjlNb7HKau0QDpwm49u0vUp9y1WOF+PEzkU84y9GqYaAVW8aH8f3GcBck26jh54cX4Q==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@@ -17365,9 +17285,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/@esbuild/win32-x64": {
|
"node_modules/tsx/node_modules/@esbuild/win32-x64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.3.tgz",
|
||||||
"integrity": "sha512-56hiAJPhwQ1R4i+21FVF7V8kSD5zZTdHcVuRFMW0hn753vVfQN8xlx4uOPT4xoGH0Z/oVATuR82AiqSTDIpaHg==",
|
"integrity": "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -17382,9 +17302,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsx/node_modules/esbuild": {
|
"node_modules/tsx/node_modules/esbuild": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.3",
|
||||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.3.tgz",
|
||||||
"integrity": "sha512-IxpibTjyVnmrIQo5aqNpCgoACA/dTKLTlhMHihVHhdkxKyPO1uBBthumT0rdHmcsk9uMonIWS0m4FljWzILh3w==",
|
"integrity": "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -17395,32 +17315,32 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@esbuild/aix-ppc64": "0.27.7",
|
"@esbuild/aix-ppc64": "0.27.3",
|
||||||
"@esbuild/android-arm": "0.27.7",
|
"@esbuild/android-arm": "0.27.3",
|
||||||
"@esbuild/android-arm64": "0.27.7",
|
"@esbuild/android-arm64": "0.27.3",
|
||||||
"@esbuild/android-x64": "0.27.7",
|
"@esbuild/android-x64": "0.27.3",
|
||||||
"@esbuild/darwin-arm64": "0.27.7",
|
"@esbuild/darwin-arm64": "0.27.3",
|
||||||
"@esbuild/darwin-x64": "0.27.7",
|
"@esbuild/darwin-x64": "0.27.3",
|
||||||
"@esbuild/freebsd-arm64": "0.27.7",
|
"@esbuild/freebsd-arm64": "0.27.3",
|
||||||
"@esbuild/freebsd-x64": "0.27.7",
|
"@esbuild/freebsd-x64": "0.27.3",
|
||||||
"@esbuild/linux-arm": "0.27.7",
|
"@esbuild/linux-arm": "0.27.3",
|
||||||
"@esbuild/linux-arm64": "0.27.7",
|
"@esbuild/linux-arm64": "0.27.3",
|
||||||
"@esbuild/linux-ia32": "0.27.7",
|
"@esbuild/linux-ia32": "0.27.3",
|
||||||
"@esbuild/linux-loong64": "0.27.7",
|
"@esbuild/linux-loong64": "0.27.3",
|
||||||
"@esbuild/linux-mips64el": "0.27.7",
|
"@esbuild/linux-mips64el": "0.27.3",
|
||||||
"@esbuild/linux-ppc64": "0.27.7",
|
"@esbuild/linux-ppc64": "0.27.3",
|
||||||
"@esbuild/linux-riscv64": "0.27.7",
|
"@esbuild/linux-riscv64": "0.27.3",
|
||||||
"@esbuild/linux-s390x": "0.27.7",
|
"@esbuild/linux-s390x": "0.27.3",
|
||||||
"@esbuild/linux-x64": "0.27.7",
|
"@esbuild/linux-x64": "0.27.3",
|
||||||
"@esbuild/netbsd-arm64": "0.27.7",
|
"@esbuild/netbsd-arm64": "0.27.3",
|
||||||
"@esbuild/netbsd-x64": "0.27.7",
|
"@esbuild/netbsd-x64": "0.27.3",
|
||||||
"@esbuild/openbsd-arm64": "0.27.7",
|
"@esbuild/openbsd-arm64": "0.27.3",
|
||||||
"@esbuild/openbsd-x64": "0.27.7",
|
"@esbuild/openbsd-x64": "0.27.3",
|
||||||
"@esbuild/openharmony-arm64": "0.27.7",
|
"@esbuild/openharmony-arm64": "0.27.3",
|
||||||
"@esbuild/sunos-x64": "0.27.7",
|
"@esbuild/sunos-x64": "0.27.3",
|
||||||
"@esbuild/win32-arm64": "0.27.7",
|
"@esbuild/win32-arm64": "0.27.3",
|
||||||
"@esbuild/win32-ia32": "0.27.7",
|
"@esbuild/win32-ia32": "0.27.3",
|
||||||
"@esbuild/win32-x64": "0.27.7"
|
"@esbuild/win32-x64": "0.27.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tunnel-agent": {
|
"node_modules/tunnel-agent": {
|
||||||
@@ -17664,7 +17584,6 @@
|
|||||||
"version": "6.21.0",
|
"version": "6.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/unified": {
|
"node_modules/unified": {
|
||||||
|
|||||||
74
package.json
74
package.json
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "@cloudcli-ai/cloudcli",
|
"name": "@siteboon/claude-code-ui",
|
||||||
"version": "1.29.2",
|
"version": "1.26.3",
|
||||||
"description": "A web-based UI for Claude Code CLI",
|
"description": "A web-based UI for Claude Code CLI",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist-server/server/index.js",
|
"main": "server/start.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"cloudcli": "dist-server/server/cli.js"
|
"claude-code-ui": "server/cli.js",
|
||||||
|
"cloudcli": "server/cli.js"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"server/",
|
"server/",
|
||||||
"shared/",
|
"shared/",
|
||||||
"dist/",
|
"dist/",
|
||||||
"dist-server/",
|
|
||||||
"scripts/",
|
"scripts/",
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
@@ -24,46 +24,36 @@
|
|||||||
"url": "https://github.com/siteboon/claudecodeui/issues"
|
"url": "https://github.com/siteboon/claudecodeui/issues"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently --kill-others \"npm run server:dev\" \"npm run client\"",
|
"dev": "concurrently --kill-others \"npm run server\" \"npm run client\"",
|
||||||
"server": "node dist-server/server/index.js",
|
"server:dev": "tsx watch --tsconfig server/tsconfig.json server/src/bootstrap.ts",
|
||||||
"server:dev": "tsx --tsconfig server/tsconfig.json server/index.js",
|
"server": "tsx --tsconfig server/tsconfig.json server/src/bootstrap.ts",
|
||||||
"server:dev-watch": "tsx watch --tsconfig server/tsconfig.json server/index.js",
|
"server:build": "tsc -p server/tsconfig.json && tsc-alias -p server/tsconfig.json",
|
||||||
|
"server:start": "node server/start.js",
|
||||||
"client": "vite",
|
"client": "vite",
|
||||||
"build": "npm run build:client && npm run build:server",
|
"build": "vite build",
|
||||||
"build:client": "vite build",
|
|
||||||
"prebuild:server": "node -e \"require('node:fs').rmSync('dist-server', { recursive: true, force: true })\"",
|
|
||||||
"build:server": "tsc -p server/tsconfig.json && tsc-alias -p server/tsconfig.json",
|
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p server/tsconfig.json",
|
"typecheck:client": "tsc --noEmit -p tsconfig.json",
|
||||||
"lint": "eslint src/ server/",
|
"typecheck:server": "tsc --noEmit -p server/tsconfig.json",
|
||||||
"lint:fix": "eslint src/ server/ --fix",
|
"test:server": "tsx --tsconfig server/tsconfig.json --test server/src/modules/ai-runtime/tests/*.test.ts",
|
||||||
"start": "npm run build && npm run server",
|
"verify:server": "npm run typecheck:server && npm run test:server && npm run server:build",
|
||||||
|
"typecheck": "npm run typecheck:client && npm run typecheck:server",
|
||||||
|
"lint": "eslint src/",
|
||||||
|
"lint:fix": "eslint src/ --fix",
|
||||||
|
"start": "npm run build && npm run server:build && npm run server:start",
|
||||||
"release": "./release.sh",
|
"release": "./release.sh",
|
||||||
"prepublishOnly": "npm run build",
|
"prepublishOnly": "npm run build && npm run server:build",
|
||||||
"postinstall": "node scripts/fix-node-pty.js",
|
"postinstall": "node scripts/fix-node-pty.js",
|
||||||
"prepare": "husky",
|
"prepare": "husky"
|
||||||
"update:platform": "./update-platform.sh"
|
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"claude code",
|
"claude code",
|
||||||
"claude-code",
|
"ai",
|
||||||
"claude-code-ui",
|
|
||||||
"cloudcli",
|
|
||||||
"codex",
|
|
||||||
"gemini",
|
|
||||||
"gemini-cli",
|
|
||||||
"cursor",
|
|
||||||
"cursor-cli",
|
|
||||||
"anthropic",
|
"anthropic",
|
||||||
"openai",
|
|
||||||
"google",
|
|
||||||
"coding-agent",
|
|
||||||
"web-ui",
|
|
||||||
"ui",
|
"ui",
|
||||||
"mobile IDE"
|
"mobile"
|
||||||
],
|
],
|
||||||
"author": "CloudCLI UI Contributors",
|
"author": "CloudCLI UI Contributors",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@anthropic-ai/claude-agent-sdk": "^0.2.59",
|
"@anthropic-ai/claude-agent-sdk": "^0.2.59",
|
||||||
"@codemirror/lang-css": "^6.3.1",
|
"@codemirror/lang-css": "^6.3.1",
|
||||||
@@ -79,6 +69,7 @@
|
|||||||
"@openai/codex-sdk": "^0.101.0",
|
"@openai/codex-sdk": "^0.101.0",
|
||||||
"@replit/codemirror-minimap": "^0.5.2",
|
"@replit/codemirror-minimap": "^0.5.2",
|
||||||
"@tailwindcss/typography": "^0.5.16",
|
"@tailwindcss/typography": "^0.5.16",
|
||||||
|
"@types/multer": "^2.1.0",
|
||||||
"@uiw/react-codemirror": "^4.23.13",
|
"@uiw/react-codemirror": "^4.23.13",
|
||||||
"@xterm/addon-clipboard": "^0.1.0",
|
"@xterm/addon-clipboard": "^0.1.0",
|
||||||
"@xterm/addon-fit": "^0.10.0",
|
"@xterm/addon-fit": "^0.10.0",
|
||||||
@@ -128,18 +119,22 @@
|
|||||||
"@commitlint/config-conventional": "^20.4.3",
|
"@commitlint/config-conventional": "^20.4.3",
|
||||||
"@eslint/js": "^9.39.3",
|
"@eslint/js": "^9.39.3",
|
||||||
"@release-it/conventional-changelog": "^10.0.5",
|
"@release-it/conventional-changelog": "^10.0.5",
|
||||||
|
"@types/bcrypt": "^6.0.0",
|
||||||
|
"@types/better-sqlite3": "^7.6.13",
|
||||||
|
"@types/cors": "^2.8.19",
|
||||||
"@types/cross-spawn": "^6.0.6",
|
"@types/cross-spawn": "^6.0.6",
|
||||||
"@types/express": "^5.0.6",
|
"@types/express": "^5.0.3",
|
||||||
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
"@types/node": "^22.19.7",
|
"@types/node": "^22.19.7",
|
||||||
"@types/react": "^18.2.43",
|
"@types/react": "^18.2.43",
|
||||||
"@types/react-dom": "^18.2.17",
|
"@types/react-dom": "^18.2.17",
|
||||||
|
"@types/web-push": "^3.6.4",
|
||||||
|
"@types/ws": "^8.18.1",
|
||||||
"@vitejs/plugin-react": "^4.6.0",
|
"@vitejs/plugin-react": "^4.6.0",
|
||||||
"auto-changelog": "^2.5.0",
|
"auto-changelog": "^2.5.0",
|
||||||
"autoprefixer": "^10.4.16",
|
"autoprefixer": "^10.4.16",
|
||||||
"concurrently": "^8.2.2",
|
"concurrently": "^8.2.2",
|
||||||
"eslint": "^9.39.3",
|
"eslint": "^9.39.3",
|
||||||
"eslint-import-resolver-typescript": "^4.4.4",
|
|
||||||
"eslint-plugin-boundaries": "^6.0.2",
|
|
||||||
"eslint-plugin-import-x": "^4.16.1",
|
"eslint-plugin-import-x": "^4.16.1",
|
||||||
"eslint-plugin-react": "^7.37.5",
|
"eslint-plugin-react": "^7.37.5",
|
||||||
"eslint-plugin-react-hooks": "^7.0.1",
|
"eslint-plugin-react-hooks": "^7.0.1",
|
||||||
@@ -155,13 +150,12 @@
|
|||||||
"sharp": "^0.34.2",
|
"sharp": "^0.34.2",
|
||||||
"tailwindcss": "^3.4.0",
|
"tailwindcss": "^3.4.0",
|
||||||
"tsc-alias": "^1.8.16",
|
"tsc-alias": "^1.8.16",
|
||||||
"tsx": "^4.21.0",
|
"tsx": "^4.20.6",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"typescript-eslint": "^8.56.1",
|
"typescript-eslint": "^8.56.1",
|
||||||
"vite": "^7.0.4"
|
"vite": "^7.0.4"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"src/**/*.{ts,tsx,js,jsx}": "eslint",
|
"src/**/*.{ts,tsx,js,jsx}": "eslint"
|
||||||
"server/**/*.{js,ts}": "eslint"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>CloudCLI - API Documentation</title>
|
<title>Claude Code UI - API Documentation</title>
|
||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div class="brand-text">
|
<div class="brand-text">
|
||||||
<h1>CloudCLI</h1>
|
<h1>Claude Code UI</h1>
|
||||||
<div class="subtitle">API Documentation</div>
|
<div class="subtitle">API Documentation</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Service Worker for CloudCLI PWA
|
// Service Worker for Claude Code UI PWA
|
||||||
// Cache only manifest (needed for PWA install). HTML and JS are never pre-cached
|
// Cache only manifest (needed for PWA install). HTML and JS are never pre-cached
|
||||||
// so a rebuild + refresh always picks up the latest assets.
|
// so a rebuild + refresh always picks up the latest assets.
|
||||||
const CACHE_NAME = 'claude-ui-v2';
|
const CACHE_NAME = 'claude-ui-v2';
|
||||||
@@ -79,7 +79,7 @@ self.addEventListener('push', event => {
|
|||||||
try {
|
try {
|
||||||
payload = event.data.json();
|
payload = event.data.json();
|
||||||
} catch {
|
} catch {
|
||||||
payload = { title: 'CloudCLI', body: event.data.text() };
|
payload = { title: 'Claude Code UI', body: event.data.text() };
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
@@ -92,7 +92,7 @@ self.addEventListener('push', event => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
self.registration.showNotification(payload.title || 'CloudCLI', options)
|
self.registration.showNotification(payload.title || 'Claude Code UI', options)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,248 +0,0 @@
|
|||||||
<div align="center">
|
|
||||||
|
|
||||||
> ## This package has moved to [`@cloudcli-ai/cloudcli`](https://www.npmjs.com/package/@cloudcli-ai/cloudcli)
|
|
||||||
>
|
|
||||||
> ```bash
|
|
||||||
> npm install -g @cloudcli-ai/cloudcli
|
|
||||||
> ```
|
|
||||||
>
|
|
||||||
> This package (`@siteboon/claude-code-ui`) is now a thin wrapper that installs the new package automatically.
|
|
||||||
> For new installations, use `@cloudcli-ai/cloudcli` directly.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<div align="center">
|
|
||||||
<img src="https://raw.githubusercontent.com/siteboon/claudecodeui/main/public/logo.svg" alt="CloudCLI UI" width="64" height="64">
|
|
||||||
<h1>Cloud CLI (aka Claude Code UI)</h1>
|
|
||||||
<p>A desktop and mobile UI for <a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a>, <a href="https://docs.cursor.com/en/cli/overview">Cursor CLI</a>, <a href="https://developers.openai.com/codex">Codex</a>, and <a href="https://geminicli.com/">Gemini-CLI</a>.<br>Use it locally or remotely to view your active projects and sessions from everywhere.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<a href="https://cloudcli.ai">CloudCLI Cloud</a> · <a href="https://cloudcli.ai/docs">Documentation</a> · <a href="https://discord.gg/buxwujPNRE">Discord</a> · <a href="https://github.com/siteboon/claudecodeui/issues">Bug Reports</a> · <a href="https://github.com/siteboon/claudecodeui/blob/main/CONTRIBUTING.md">Contributing</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<a href="https://cloudcli.ai"><img src="https://img.shields.io/badge/☁️_CloudCLI_Cloud-Try_Now-0066FF?style=for-the-badge" alt="CloudCLI Cloud"></a>
|
|
||||||
<a href="https://discord.gg/buxwujPNRE"><img src="https://img.shields.io/badge/Discord-Join%20Community-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Join our Discord"></a>
|
|
||||||
<br><br>
|
|
||||||
<a href="https://trendshift.io/repositories/15586" target="_blank"><img src="https://trendshift.io/api/badge/repositories/15586" alt="siteboon%2Fclaudecodeui | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Screenshots
|
|
||||||
|
|
||||||
<div align="center">
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td align="center">
|
|
||||||
<h3>Desktop View</h3>
|
|
||||||
<img src="https://raw.githubusercontent.com/siteboon/claudecodeui/main/public/screenshots/desktop-main.png" alt="Desktop Interface" width="400">
|
|
||||||
<br>
|
|
||||||
<em>Main interface showing project overview and chat</em>
|
|
||||||
</td>
|
|
||||||
<td align="center">
|
|
||||||
<h3>Mobile Experience</h3>
|
|
||||||
<img src="https://raw.githubusercontent.com/siteboon/claudecodeui/main/public/screenshots/mobile-chat.png" alt="Mobile Interface" width="250">
|
|
||||||
<br>
|
|
||||||
<em>Responsive mobile design with touch navigation</em>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" colspan="2">
|
|
||||||
<h3>CLI Selection</h3>
|
|
||||||
<img src="https://raw.githubusercontent.com/siteboon/claudecodeui/main/public/screenshots/cli-selection.png" alt="CLI Selection" width="400">
|
|
||||||
<br>
|
|
||||||
<em>Select between Claude Code, Gemini, Cursor CLI and Codex</em>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- **Responsive Design** - Works seamlessly across desktop, tablet, and mobile so you can also use Agents from mobile
|
|
||||||
- **Interactive Chat Interface** - Built-in chat interface for seamless communication with the Agents
|
|
||||||
- **Integrated Shell Terminal** - Direct access to the Agents CLI through built-in shell functionality
|
|
||||||
- **File Explorer** - Interactive file tree with syntax highlighting and live editing
|
|
||||||
- **Git Explorer** - View, stage and commit your changes. You can also switch branches
|
|
||||||
- **Session Management** - Resume conversations, manage multiple sessions, and track history
|
|
||||||
- **Plugin System** - Extend CloudCLI with custom plugins — add new tabs, backend services, and integrations. [Build your own →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)
|
|
||||||
- **TaskMaster AI Integration** *(Optional)* - Advanced project management with AI-powered task planning, PRD parsing, and workflow automation
|
|
||||||
- **Model Compatibility** - Works with Claude, GPT, and Gemini model families (see [`shared/modelConstants.js`](https://github.com/siteboon/claudecodeui/blob/main/shared/modelConstants.js) for the full list of supported models)
|
|
||||||
|
|
||||||
|
|
||||||
## Quick Start
|
|
||||||
|
|
||||||
### CloudCLI Cloud (Recommended)
|
|
||||||
|
|
||||||
The fastest way to get started — no local setup required. Get a fully managed, containerized development environment accessible from the web, mobile app, API, or your favorite IDE.
|
|
||||||
|
|
||||||
**[Get started with CloudCLI Cloud](https://cloudcli.ai)**
|
|
||||||
|
|
||||||
|
|
||||||
### Self-Hosted (Open source)
|
|
||||||
|
|
||||||
Try CloudCLI UI instantly with **npx** (requires **Node.js** v22+):
|
|
||||||
|
|
||||||
```
|
|
||||||
npx @cloudcli-ai/cloudcli
|
|
||||||
```
|
|
||||||
|
|
||||||
Or install **globally** for regular use:
|
|
||||||
|
|
||||||
```
|
|
||||||
npm install -g @cloudcli-ai/cloudcli
|
|
||||||
cloudcli
|
|
||||||
```
|
|
||||||
|
|
||||||
Open `http://localhost:3001` — all your existing sessions are discovered automatically.
|
|
||||||
|
|
||||||
Visit the **[documentation →](https://cloudcli.ai/docs)** for more full configuration options, PM2, remote server setup and more
|
|
||||||
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Which option is right for you?
|
|
||||||
|
|
||||||
CloudCLI UI is the open source UI layer that powers CloudCLI Cloud. You can self-host it on your own machine, or use CloudCLI Cloud which builds on top of it with a full managed cloud environment, team features, and deeper integrations.
|
|
||||||
|
|
||||||
| | CloudCLI UI (Self-hosted) | CloudCLI Cloud |
|
|
||||||
|---|---|---|
|
|
||||||
| **Best for** | Developers who want a full UI for local agent sessions on their own machine | Teams and developers who want agents running in the cloud, accessible from anywhere |
|
|
||||||
| **How you access it** | Browser via `[yourip]:port` | Browser, any IDE, REST API, n8n |
|
|
||||||
| **Setup** | `npx @cloudcli-ai/cloudcli` | No setup required |
|
|
||||||
| **Machine needs to stay on** | Yes | No |
|
|
||||||
| **Mobile access** | Any browser on your network | Any device, native app coming |
|
|
||||||
| **Sessions available** | All sessions auto-discovered from `~/.claude` | All sessions within your cloud environment |
|
|
||||||
| **Agents supported** | Claude Code, Cursor CLI, Codex, Gemini CLI | Claude Code, Cursor CLI, Codex, Gemini CLI |
|
|
||||||
| **File explorer and Git** | Yes, built into the UI | Yes, built into the UI |
|
|
||||||
| **MCP configuration** | Managed via UI, synced with your local `~/.claude` config | Managed via UI |
|
|
||||||
| **IDE access** | Your local IDE | Any IDE connected to your cloud environment |
|
|
||||||
| **REST API** | Yes | Yes |
|
|
||||||
| **n8n node** | No | Yes |
|
|
||||||
| **Team sharing** | No | Yes |
|
|
||||||
| **Platform cost** | Free, open source | Starts at $7/month |
|
|
||||||
|
|
||||||
> Both options use your own AI subscriptions (Claude, Cursor, etc.) — CloudCLI provides the environment, not the AI.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Security & Tools Configuration
|
|
||||||
|
|
||||||
**Important Notice**: All Claude Code tools are **disabled by default**. This prevents potentially harmful operations from running automatically.
|
|
||||||
|
|
||||||
### Enabling Tools
|
|
||||||
|
|
||||||
To use Claude Code's full functionality, you'll need to manually enable tools:
|
|
||||||
|
|
||||||
1. **Open Tools Settings** - Click the gear icon in the sidebar
|
|
||||||
2. **Enable Selectively** - Turn on only the tools you need
|
|
||||||
3. **Apply Settings** - Your preferences are saved locally
|
|
||||||
|
|
||||||
**Recommended approach**: Start with basic tools enabled and add more as needed. You can always adjust these settings later.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Plugins
|
|
||||||
|
|
||||||
CloudCLI has a plugin system that lets you add custom tabs with their own frontend UI and optional Node.js backend. Install plugins from git repos directly in **Settings > Plugins**, or build your own.
|
|
||||||
|
|
||||||
### Available Plugins
|
|
||||||
|
|
||||||
| Plugin | Description |
|
|
||||||
|---|---|
|
|
||||||
| **[Project Stats](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** | Shows file counts, lines of code, file-type breakdown, largest files, and recently modified files for your current project |
|
|
||||||
| **[Web Terminal](https://github.com/cloudcli-ai/cloudcli-plugin-terminal)** | Full xterm.js terminal with multi-tab support|
|
|
||||||
|
|
||||||
### Build Your Own
|
|
||||||
|
|
||||||
**[Plugin Starter Template →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** — fork this repo to create your own plugin. It includes a working example with frontend rendering, live context updates, and RPC communication to a backend server.
|
|
||||||
|
|
||||||
**[Plugin Documentation →](https://cloudcli.ai/docs/plugin-overview)** — full guide to the plugin API, manifest format, security model, and more.
|
|
||||||
|
|
||||||
---
|
|
||||||
## FAQ
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>How is this different from Claude Code Remote Control?</summary>
|
|
||||||
|
|
||||||
Claude Code Remote Control lets you send messages to a session already running in your local terminal. Your machine has to stay on, your terminal has to stay open, and sessions time out after roughly 10 minutes without a network connection.
|
|
||||||
|
|
||||||
CloudCLI UI and CloudCLI Cloud extend Claude Code rather than sit alongside it — your MCP servers, permissions, settings, and sessions are the exact same ones Claude Code uses natively. Nothing is duplicated or managed separately.
|
|
||||||
|
|
||||||
Here's what that means in practice:
|
|
||||||
|
|
||||||
- **All your sessions, not just one** — CloudCLI UI auto-discovers every session from your `~/.claude` folder. Remote Control only exposes the single active session to make it available in the Claude mobile app.
|
|
||||||
- **Your settings are your settings** — MCP servers, tool permissions, and project config you change in CloudCLI UI are written directly to your Claude Code config and take effect immediately, and vice versa.
|
|
||||||
- **Works with more agents** — Claude Code, Cursor CLI, Codex, and Gemini CLI, not just Claude Code.
|
|
||||||
- **Full UI, not just a chat window** — file explorer, Git integration, MCP management, and a shell terminal are all built in.
|
|
||||||
- **CloudCLI Cloud runs in the cloud** — close your laptop, the agent keeps running. No terminal to babysit, no machine to keep awake.
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Do I need to pay for an AI subscription separately?</summary>
|
|
||||||
|
|
||||||
Yes. CloudCLI provides the environment, not the AI. You bring your own Claude, Cursor, Codex, or Gemini subscription. CloudCLI Cloud starts at $7/month for the hosted environment on top of that.
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Can I use CloudCLI UI on my phone?</summary>
|
|
||||||
|
|
||||||
Yes. For self-hosted, run the server on your machine and open `[yourip]:port` in any browser on your network. For CloudCLI Cloud, open it from any device — no VPN, no port forwarding, no setup. A native app is also in the works.
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Will changes I make in the UI affect my local Claude Code setup?</summary>
|
|
||||||
|
|
||||||
Yes, for self-hosted. CloudCLI UI reads from and writes to the same `~/.claude` config that Claude Code uses natively. MCP servers you add via the UI show up in Claude Code immediately and vice versa.
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Community & Support
|
|
||||||
|
|
||||||
- **[Documentation](https://cloudcli.ai/docs)** — installation, configuration, features, and troubleshooting
|
|
||||||
- **[Discord](https://discord.gg/buxwujPNRE)** — get help and connect with other users
|
|
||||||
- **[GitHub Issues](https://github.com/siteboon/claudecodeui/issues)** — bug reports and feature requests
|
|
||||||
- **[Contributing Guide](https://github.com/siteboon/claudecodeui/blob/main/CONTRIBUTING.md)** — how to contribute to the project
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later) — see [LICENSE](https://github.com/siteboon/claudecodeui/blob/main/LICENSE) for the full text, including additional terms under Section 7.
|
|
||||||
|
|
||||||
This project is open source and free to use, modify, and distribute under the AGPL-3.0-or-later license. If you modify this software and run it as a network service, you must make your modified source code available to users of that service.
|
|
||||||
|
|
||||||
CloudCLI UI - (https://cloudcli.ai).
|
|
||||||
|
|
||||||
## Acknowledgments
|
|
||||||
|
|
||||||
### Built With
|
|
||||||
- **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** - Anthropic's official CLI
|
|
||||||
- **[Cursor CLI](https://docs.cursor.com/en/cli/overview)** - Cursor's official CLI
|
|
||||||
- **[Codex](https://developers.openai.com/codex)** - OpenAI Codex
|
|
||||||
- **[Gemini-CLI](https://geminicli.com/)** - Google Gemini CLI
|
|
||||||
- **[React](https://react.dev/)** - User interface library
|
|
||||||
- **[Vite](https://vitejs.dev/)** - Fast build tool and dev server
|
|
||||||
- **[Tailwind CSS](https://tailwindcss.com/)** - Utility-first CSS framework
|
|
||||||
- **[CodeMirror](https://codemirror.net/)** - Advanced code editor
|
|
||||||
- **[TaskMaster AI](https://github.com/eyaltoledano/claude-task-master)** *(Optional)* - AI-powered project management and task planning
|
|
||||||
|
|
||||||
|
|
||||||
### Sponsors
|
|
||||||
- [Siteboon - AI powered website builder](https://siteboon.ai)
|
|
||||||
---
|
|
||||||
|
|
||||||
<div align="center">
|
|
||||||
<strong>Made with care for the Claude Code, Cursor and Codex community.</strong>
|
|
||||||
</div>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
import('@cloudcli-ai/cloudcli/dist-server/server/cli.js');
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
export * from '@cloudcli-ai/cloudcli';
|
|
||||||
export { default } from '@cloudcli-ai/cloudcli';
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@siteboon/claude-code-ui",
|
|
||||||
"version": "2.0.0",
|
|
||||||
"description": "This package has moved to @cloudcli-ai/cloudcli",
|
|
||||||
"type": "module",
|
|
||||||
"main": "index.js",
|
|
||||||
"bin": {
|
|
||||||
"claude-code-ui": "./bin.js",
|
|
||||||
"cloudcli": "./bin.js"
|
|
||||||
},
|
|
||||||
"homepage": "https://cloudcli.ai",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/siteboon/claudecodeui.git"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/siteboon/claudecodeui/issues"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"claude code",
|
|
||||||
"claude-code",
|
|
||||||
"claude-code-ui",
|
|
||||||
"cloudcli",
|
|
||||||
"codex",
|
|
||||||
"gemini",
|
|
||||||
"gemini-cli",
|
|
||||||
"cursor",
|
|
||||||
"cursor-cli",
|
|
||||||
"anthropic",
|
|
||||||
"openai",
|
|
||||||
"google",
|
|
||||||
"coding-agent",
|
|
||||||
"web-ui",
|
|
||||||
"ui",
|
|
||||||
"mobile IDE"
|
|
||||||
],
|
|
||||||
"author": "CloudCLI UI Contributors",
|
|
||||||
"dependencies": {
|
|
||||||
"@cloudcli-ai/cloudcli": "*"
|
|
||||||
},
|
|
||||||
"deprecated": "This package has been renamed to @cloudcli-ai/cloudcli. Please install @cloudcli-ai/cloudcli instead.",
|
|
||||||
"license": "AGPL-3.0-or-later"
|
|
||||||
}
|
|
||||||
657
scripts/generate-backend-inventory.mjs
Normal file
657
scripts/generate-backend-inventory.mjs
Normal file
@@ -0,0 +1,657 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
const projectRoot = path.resolve(__dirname, '..');
|
||||||
|
const serverRoot = path.join(projectRoot, 'server');
|
||||||
|
const clientRoot = path.join(projectRoot, 'src');
|
||||||
|
const docsRoot = path.join(projectRoot, 'docs', 'backend');
|
||||||
|
|
||||||
|
const HTTP_METHODS = ['get', 'post', 'put', 'delete', 'patch'];
|
||||||
|
const routeDefinitionPattern = /\b(app|router)\.(get|post|put|delete|patch)\(\s*(['"`])(.+?)\3/g;
|
||||||
|
const defaultImportPattern =
|
||||||
|
/^import\s+([A-Za-z0-9_$]+)(?:\s*,\s*\{[^}]+\})?\s+from\s+['"](.+?)['"];$/gm;
|
||||||
|
const incomingRealtimePattern = /data\.type === '([^']+)'/g;
|
||||||
|
const outgoingRealtimePattern = /type:\s*'([^']+)'/g;
|
||||||
|
|
||||||
|
fs.mkdirSync(docsRoot, { recursive: true });
|
||||||
|
|
||||||
|
function toPosix(value) {
|
||||||
|
return value.split(path.sep).join('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
function readText(filePath) {
|
||||||
|
return fs.readFileSync(filePath, 'utf8');
|
||||||
|
}
|
||||||
|
|
||||||
|
function walkFiles(dirPath, files = []) {
|
||||||
|
for (const entry of fs.readdirSync(dirPath, { withFileTypes: true })) {
|
||||||
|
if (entry.name === 'dist' || entry.name === 'node_modules') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fullPath = path.join(dirPath, entry.name);
|
||||||
|
if (entry.isDirectory()) {
|
||||||
|
walkFiles(fullPath, files);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
files.push(fullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLineNumber(content, index) {
|
||||||
|
return content.slice(0, index).split(/\r?\n/).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function splitArgs(argumentSource) {
|
||||||
|
return argumentSource
|
||||||
|
.split(',')
|
||||||
|
.map(part => part.trim())
|
||||||
|
.filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sanitizeObjectKey(key) {
|
||||||
|
return key
|
||||||
|
.replace(/^[\s{]+|[\s}]+$/g, '')
|
||||||
|
.replace(/=.*$/, '')
|
||||||
|
.replace(/:.+$/, '')
|
||||||
|
.replace(/\?/g, '')
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function collectObjectKeys(block, accessor) {
|
||||||
|
const keys = new Set();
|
||||||
|
const directPattern = new RegExp(`req\\.${accessor}\\.([A-Za-z0-9_]+)`, 'g');
|
||||||
|
const destructuringPattern = new RegExp(`\\{([^}]*)\\}\\s*=\\s*req\\.${accessor}`, 'gs');
|
||||||
|
|
||||||
|
for (const match of block.matchAll(directPattern)) {
|
||||||
|
keys.add(match[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const match of block.matchAll(destructuringPattern)) {
|
||||||
|
for (const rawKey of match[1].split(',')) {
|
||||||
|
const key = sanitizeObjectKey(rawKey);
|
||||||
|
if (key) {
|
||||||
|
keys.add(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...keys].sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeJoinedPath(basePath, routePath) {
|
||||||
|
const safeBase = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
|
||||||
|
if (!routePath || routePath === '/') {
|
||||||
|
return safeBase || '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath === '*') {
|
||||||
|
return routePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
const safeRoute = routePath.startsWith('/') ? routePath : `/${routePath}`;
|
||||||
|
return `${safeBase}${safeRoute}` || '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStaticSearchTokens(routePath) {
|
||||||
|
const cleaned = routePath.replace(/:[A-Za-z0-9_]+/g, '').replace(/\*/g, '');
|
||||||
|
const segments = cleaned.split('/').filter(Boolean);
|
||||||
|
const tokens = new Set();
|
||||||
|
|
||||||
|
if (cleaned && cleaned !== '/') {
|
||||||
|
tokens.add(cleaned.endsWith('/') ? cleaned : `${cleaned}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let index = segments.length; index >= 2; index -= 1) {
|
||||||
|
tokens.add(`/${segments.slice(0, index).join('/')}/`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (segments.length > 0) {
|
||||||
|
tokens.add(`/${segments.slice(0, 1).join('/')}/`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...tokens].filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
function classifyTag(routePath) {
|
||||||
|
if (routePath === '*' || routePath === '/health' || routePath.startsWith('/api/system')) {
|
||||||
|
return 'System';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/auth')) return 'Auth';
|
||||||
|
if (routePath.startsWith('/api/user')) return 'User';
|
||||||
|
if (routePath.startsWith('/api/settings')) return 'Settings';
|
||||||
|
if (routePath.startsWith('/api/git')) return 'Git';
|
||||||
|
if (routePath.startsWith('/api/taskmaster')) return 'TaskMaster';
|
||||||
|
if (routePath.startsWith('/api/plugins')) return 'Plugins';
|
||||||
|
if (routePath.startsWith('/api/agent')) return 'Agent';
|
||||||
|
if (routePath.startsWith('/api/commands')) return 'Commands';
|
||||||
|
if (routePath.startsWith('/api/mcp')) return 'MCP';
|
||||||
|
if (routePath.startsWith('/api/cli')) return 'CLI Auth';
|
||||||
|
if (
|
||||||
|
routePath.startsWith('/api/cursor') ||
|
||||||
|
routePath.startsWith('/api/codex') ||
|
||||||
|
routePath.startsWith('/api/gemini')
|
||||||
|
) {
|
||||||
|
return 'Providers';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/search') || routePath.includes('/sessions')) {
|
||||||
|
return 'Sessions';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.includes('/files') || routePath.includes('/file') || routePath.includes('/upload')) {
|
||||||
|
return 'Files';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/projects') || routePath.startsWith('/api/create-folder')) {
|
||||||
|
return 'Projects';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Realtime';
|
||||||
|
}
|
||||||
|
|
||||||
|
function classifyPriority(tag, routePath) {
|
||||||
|
if (
|
||||||
|
tag === 'Agent' ||
|
||||||
|
tag === 'TaskMaster' ||
|
||||||
|
tag === 'Git' ||
|
||||||
|
routePath.startsWith('/api/projects') ||
|
||||||
|
routePath.startsWith('/api/search')
|
||||||
|
) {
|
||||||
|
return 'high';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
tag === 'Providers' ||
|
||||||
|
tag === 'Commands' ||
|
||||||
|
tag === 'MCP' ||
|
||||||
|
tag === 'Plugins' ||
|
||||||
|
tag === 'Settings' ||
|
||||||
|
tag === 'Auth' ||
|
||||||
|
tag === 'User'
|
||||||
|
) {
|
||||||
|
return 'medium';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'low';
|
||||||
|
}
|
||||||
|
|
||||||
|
function describePurpose(method, routePath) {
|
||||||
|
const verb = method.toUpperCase();
|
||||||
|
|
||||||
|
if (routePath === '/health') {
|
||||||
|
return 'Expose server health, timestamp, and install mode for diagnostics.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath === '*') {
|
||||||
|
return 'Serve the React application fallback for non-API routes.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/system/update')) {
|
||||||
|
return 'Run the application update workflow on the host machine.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/auth/status')) return 'Report whether authentication is configured.';
|
||||||
|
if (routePath.startsWith('/api/auth/register')) return 'Create the first local user account.';
|
||||||
|
if (routePath.startsWith('/api/auth/login')) return 'Authenticate a local user and issue a token.';
|
||||||
|
if (routePath.startsWith('/api/auth/user')) return 'Return the currently authenticated user.';
|
||||||
|
if (routePath.startsWith('/api/auth/logout')) return 'Invalidate the current authenticated session.';
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/user/git-config')) return 'Read or update stored git identity settings.';
|
||||||
|
if (routePath.startsWith('/api/user/complete-onboarding')) return 'Mark onboarding as completed for the current user.';
|
||||||
|
if (routePath.startsWith('/api/user/onboarding-status')) return 'Return onboarding completion status for the current user.';
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/settings/api-keys')) return 'Manage local API keys used to access the backend.';
|
||||||
|
if (routePath.startsWith('/api/settings/credentials')) return 'Manage stored provider and GitHub credentials.';
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/projects/create-workspace')) {
|
||||||
|
return 'Create or register a workspace and optionally clone a GitHub repository into it.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/projects/clone-progress')) {
|
||||||
|
return 'Stream workspace cloning progress events to the frontend.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath === '/api/projects') return 'List detected projects and workspaces.';
|
||||||
|
if (routePath.startsWith('/api/projects/create')) return 'Manually add a project path to the workspace list.';
|
||||||
|
if (routePath.startsWith('/api/projects/:projectName/sessions/:sessionId/token-usage')) {
|
||||||
|
return 'Report token usage for a stored provider session.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.includes('/sessions/:sessionId/messages')) {
|
||||||
|
return 'Return paginated messages for a stored session.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.includes('/sessions')) {
|
||||||
|
return 'List or manage sessions associated with a project or provider.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.includes('/files') || routePath.includes('/file')) {
|
||||||
|
return 'Read, write, create, rename, delete, or upload project files.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/search/conversations')) {
|
||||||
|
return 'Search conversation history across stored projects and stream results.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/browse-filesystem')) {
|
||||||
|
return 'Browse local directories so the UI can suggest workspace locations.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/create-folder')) {
|
||||||
|
return 'Create a new directory on the local filesystem.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/transcribe')) {
|
||||||
|
return 'Transcribe uploaded audio and optionally enhance the result for prompts or tasks.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.includes('/upload-images')) {
|
||||||
|
return 'Upload images for chat use and return browser-safe data URLs.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/git/status')) return 'Read git status information for a project.';
|
||||||
|
if (routePath.startsWith('/api/git/diff')) return 'Return git diff output for a project or file.';
|
||||||
|
if (routePath.startsWith('/api/git/file-with-diff')) return 'Return file content together with diff context.';
|
||||||
|
if (routePath.startsWith('/api/git/branches')) return 'List git branches for a project.';
|
||||||
|
if (routePath.startsWith('/api/git/commits')) return 'List recent commits for a project.';
|
||||||
|
if (routePath.startsWith('/api/git/commit-diff')) return 'Return diff details for a specific commit.';
|
||||||
|
if (routePath.startsWith('/api/git/remote-status')) return 'Report remote sync status for a project repository.';
|
||||||
|
if (routePath.startsWith('/api/git/generate-commit-message')) return 'Generate an AI-assisted commit message from the current diff.';
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/taskmaster')) {
|
||||||
|
return 'Manage TaskMaster detection, PRDs, tasks, templates, and automation for a project.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/commands')) {
|
||||||
|
return 'List, load, or execute slash commands available to the chat experience.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/mcp-utils')) {
|
||||||
|
return 'Return MCP helper information used by setup flows.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/mcp')) {
|
||||||
|
return 'Manage Claude MCP CLI and configuration state.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/cursor')) {
|
||||||
|
return 'Manage Cursor configuration, MCP settings, and stored sessions.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/codex')) {
|
||||||
|
return 'Manage Codex configuration, MCP settings, and stored sessions.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/gemini')) {
|
||||||
|
return 'Manage Gemini session history for the UI.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/cli')) {
|
||||||
|
return 'Report local authentication status for provider CLIs.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/plugins')) {
|
||||||
|
return 'List, install, update, serve, enable, or remove plugins.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.startsWith('/api/agent')) {
|
||||||
|
return 'Accept external agent jobs that run a provider against a local or cloned project.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${verb} ${routePath} for backend runtime support.`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function describeSuccessShape(block, transport) {
|
||||||
|
if (transport === 'sse' || block.includes('text/event-stream')) {
|
||||||
|
return 'Server-sent events stream with progress/result/error events.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.includes('res.sendFile')) {
|
||||||
|
return 'Static file or HTML response.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.includes('res.redirect')) {
|
||||||
|
return 'HTTP redirect response.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.includes('res.json({ success: true')) {
|
||||||
|
return 'JSON object with an explicit success flag and payload.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.includes('res.json({')) {
|
||||||
|
return 'Structured JSON object response.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.includes('res.json(')) {
|
||||||
|
return 'JSON payload returned directly from service logic.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Mixed response shape; inspect handler during refactor.';
|
||||||
|
}
|
||||||
|
|
||||||
|
function describeErrorShape(block, transport) {
|
||||||
|
if (transport === 'sse' || block.includes('text/event-stream')) {
|
||||||
|
return 'Streamed error event or JSON error fallback.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.includes("res.status(500).json({ error:")) {
|
||||||
|
return 'JSON object with error message and optional details.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.includes("res.status(400).json({ error:")) {
|
||||||
|
return 'JSON validation error response.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.includes('res.status(')) {
|
||||||
|
return 'JSON error response with HTTP status code.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Handler-specific error behavior.';
|
||||||
|
}
|
||||||
|
|
||||||
|
function describeSideEffects(method, routePath) {
|
||||||
|
const effects = [];
|
||||||
|
|
||||||
|
if (method !== 'get') {
|
||||||
|
effects.push('Mutates backend or external state.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePath.includes('/git')) effects.push('Touches git repositories or local git config.');
|
||||||
|
if (routePath.includes('/projects') || routePath.includes('/file') || routePath.includes('/files')) {
|
||||||
|
effects.push('Touches local workspace files or directories.');
|
||||||
|
}
|
||||||
|
if (routePath.includes('/agent')) effects.push('Invokes external AI providers and may modify project files.');
|
||||||
|
if (routePath.includes('/taskmaster')) effects.push('Reads or writes TaskMaster project assets.');
|
||||||
|
if (routePath.includes('/plugins')) effects.push('Installs, updates, or serves plugin assets/processes.');
|
||||||
|
if (routePath.includes('/settings') || routePath.includes('/auth') || routePath.includes('/credentials')) {
|
||||||
|
effects.push('Reads or writes local authentication or credential state.');
|
||||||
|
}
|
||||||
|
if (routePath.includes('/mcp')) effects.push('Reads or writes MCP CLI configuration.');
|
||||||
|
if (routePath.includes('/transcribe')) effects.push('Processes uploaded files and external model responses.');
|
||||||
|
|
||||||
|
return effects.length > 0 ? effects : ['Read-only backend query.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function collectFrontendConsumers(routePath, clientFiles) {
|
||||||
|
const tokens = getStaticSearchTokens(routePath);
|
||||||
|
const consumers = new Set();
|
||||||
|
|
||||||
|
for (const file of clientFiles) {
|
||||||
|
const content = readText(file);
|
||||||
|
if (tokens.some(token => token && content.includes(token))) {
|
||||||
|
consumers.add(toPosix(path.relative(projectRoot, file)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...consumers].sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
function detectTransport(block) {
|
||||||
|
if (block.includes('text/event-stream')) {
|
||||||
|
return 'sse';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'http';
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseMounts(runtimeContent) {
|
||||||
|
const routeImports = new Map();
|
||||||
|
|
||||||
|
for (const match of runtimeContent.matchAll(defaultImportPattern)) {
|
||||||
|
if (match[2].includes('/routes/')) {
|
||||||
|
routeImports.set(match[1], match[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const mounts = new Map();
|
||||||
|
const mountPattern = /app\.use\(\s*(['"`])([^'"`]+)\1\s*,\s*([^)]+?)\);/g;
|
||||||
|
|
||||||
|
for (const match of runtimeContent.matchAll(mountPattern)) {
|
||||||
|
const basePath = match[2];
|
||||||
|
const args = splitArgs(match[3]);
|
||||||
|
const routeVariable = args.at(-1);
|
||||||
|
if (!routeVariable || !routeImports.has(routeVariable)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
mounts.set(routeVariable, {
|
||||||
|
basePath,
|
||||||
|
routeImport: routeImports.get(routeVariable),
|
||||||
|
authMode: args.includes('authenticateToken')
|
||||||
|
? 'bearer_token'
|
||||||
|
: args.includes('validateExternalApiKey')
|
||||||
|
? 'api_key_or_platform'
|
||||||
|
: 'public_or_optional_api_key',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return mounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseRoutes(filePath, fullPathPrefix, authMode, clientFiles) {
|
||||||
|
const content = readText(filePath);
|
||||||
|
const matches = [...content.matchAll(routeDefinitionPattern)];
|
||||||
|
const routes = [];
|
||||||
|
|
||||||
|
for (let index = 0; index < matches.length; index += 1) {
|
||||||
|
const match = matches[index];
|
||||||
|
const nextMatch = matches[index + 1];
|
||||||
|
const routeMethod = match[2].toUpperCase();
|
||||||
|
const routePath = match[4];
|
||||||
|
const startIndex = match.index ?? 0;
|
||||||
|
const endIndex = nextMatch?.index ?? content.length;
|
||||||
|
const block = content.slice(startIndex, endIndex);
|
||||||
|
const declarationEnd = block.indexOf('=>');
|
||||||
|
const declarationSnippet = declarationEnd === -1 ? block : block.slice(0, declarationEnd);
|
||||||
|
const fullPath = fullPathPrefix
|
||||||
|
? normalizeJoinedPath(fullPathPrefix, routePath)
|
||||||
|
: routePath;
|
||||||
|
const transport = detectTransport(block);
|
||||||
|
const tag = classifyTag(fullPath);
|
||||||
|
const pathParams = [...fullPath.matchAll(/:([A-Za-z0-9_]+)/g)].map(token => token[1]);
|
||||||
|
const queryParams = collectObjectKeys(block, 'query');
|
||||||
|
const bodyHints = collectObjectKeys(block, 'body');
|
||||||
|
const localAuthMode =
|
||||||
|
fullPath === '/health' ||
|
||||||
|
fullPath === '/api/auth/status' ||
|
||||||
|
fullPath === '/api/auth/register' ||
|
||||||
|
fullPath === '/api/auth/login' ||
|
||||||
|
fullPath === '*'
|
||||||
|
? 'public'
|
||||||
|
: declarationSnippet.includes('authenticateToken')
|
||||||
|
? 'bearer_token'
|
||||||
|
: declarationSnippet.includes('validateExternalApiKey')
|
||||||
|
? 'api_key_or_platform'
|
||||||
|
: authMode;
|
||||||
|
|
||||||
|
routes.push({
|
||||||
|
transport,
|
||||||
|
method: routeMethod,
|
||||||
|
path: fullPath,
|
||||||
|
tag,
|
||||||
|
authMode: localAuthMode,
|
||||||
|
sourceFile: toPosix(path.relative(projectRoot, filePath)),
|
||||||
|
sourceLine: getLineNumber(content, startIndex),
|
||||||
|
purpose: describePurpose(routeMethod, fullPath),
|
||||||
|
consumerFiles: collectFrontendConsumers(fullPath, clientFiles),
|
||||||
|
inputs: {
|
||||||
|
pathParams,
|
||||||
|
queryParams,
|
||||||
|
bodyHints,
|
||||||
|
},
|
||||||
|
successShape: describeSuccessShape(block, transport),
|
||||||
|
errorShape: describeErrorShape(block, transport),
|
||||||
|
sideEffects: describeSideEffects(routeMethod.toLowerCase(), fullPath),
|
||||||
|
priority: classifyPriority(tag, fullPath),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return routes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseRealtimeContracts(runtimeFile) {
|
||||||
|
const content = readText(runtimeFile);
|
||||||
|
const incoming = new Set();
|
||||||
|
const outgoing = new Set();
|
||||||
|
|
||||||
|
for (const match of content.matchAll(incomingRealtimePattern)) {
|
||||||
|
incoming.add(match[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const websocketSectionIndex = content.indexOf("wss.on('connection'");
|
||||||
|
const websocketSection = websocketSectionIndex === -1 ? content : content.slice(websocketSectionIndex);
|
||||||
|
|
||||||
|
for (const match of websocketSection.matchAll(outgoingRealtimePattern)) {
|
||||||
|
outgoing.add(match[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
incomingMessageTypes: [...incoming].sort(),
|
||||||
|
outgoingMessageTypes: [...outgoing].sort(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function escapeCsv(value) {
|
||||||
|
const stringValue = Array.isArray(value) ? value.join('; ') : String(value ?? '');
|
||||||
|
const escaped = stringValue.replace(/"/g, '""');
|
||||||
|
return `"${escaped}"`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeCsv(filePath, records) {
|
||||||
|
const header = [
|
||||||
|
'transport',
|
||||||
|
'method',
|
||||||
|
'path',
|
||||||
|
'tag',
|
||||||
|
'authMode',
|
||||||
|
'sourceFile',
|
||||||
|
'sourceLine',
|
||||||
|
'purpose',
|
||||||
|
'consumerFiles',
|
||||||
|
'pathParams',
|
||||||
|
'queryParams',
|
||||||
|
'bodyHints',
|
||||||
|
'successShape',
|
||||||
|
'errorShape',
|
||||||
|
'sideEffects',
|
||||||
|
'priority',
|
||||||
|
];
|
||||||
|
|
||||||
|
const rows = [
|
||||||
|
header.join(','),
|
||||||
|
...records.map(record => [
|
||||||
|
record.transport,
|
||||||
|
record.method,
|
||||||
|
record.path,
|
||||||
|
record.tag,
|
||||||
|
record.authMode,
|
||||||
|
record.sourceFile,
|
||||||
|
record.sourceLine,
|
||||||
|
record.purpose,
|
||||||
|
record.consumerFiles,
|
||||||
|
record.inputs.pathParams,
|
||||||
|
record.inputs.queryParams,
|
||||||
|
record.inputs.bodyHints,
|
||||||
|
record.successShape,
|
||||||
|
record.errorShape,
|
||||||
|
record.sideEffects,
|
||||||
|
record.priority,
|
||||||
|
].map(escapeCsv).join(',')),
|
||||||
|
];
|
||||||
|
|
||||||
|
fs.writeFileSync(filePath, `${rows.join('\n')}\n`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeMarkdown(filePath, summary, records, realtimeContracts) {
|
||||||
|
const grouped = new Map();
|
||||||
|
|
||||||
|
for (const record of records) {
|
||||||
|
if (!grouped.has(record.tag)) {
|
||||||
|
grouped.set(record.tag, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
grouped.get(record.tag).push(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
const lines = [
|
||||||
|
'# Backend Inventory',
|
||||||
|
'',
|
||||||
|
`Generated on ${summary.generatedAt}.`,
|
||||||
|
'',
|
||||||
|
'## Summary',
|
||||||
|
'',
|
||||||
|
`- HTTP routes: ${summary.httpRoutes}`,
|
||||||
|
`- SSE routes: ${summary.sseRoutes}`,
|
||||||
|
`- Modular routes: ${summary.modularRoutes}`,
|
||||||
|
`- Inline routes: ${summary.inlineRoutes}`,
|
||||||
|
`- Route files scanned: ${summary.routeFilesScanned}`,
|
||||||
|
'',
|
||||||
|
'## Realtime Contracts',
|
||||||
|
'',
|
||||||
|
`- Incoming websocket message types (${realtimeContracts.incomingMessageTypes.length}): ${realtimeContracts.incomingMessageTypes.join(', ')}`,
|
||||||
|
`- Outgoing websocket message types (${realtimeContracts.outgoingMessageTypes.length}): ${realtimeContracts.outgoingMessageTypes.join(', ')}`,
|
||||||
|
'',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const [tag, tagRecords] of [...grouped.entries()].sort(([left], [right]) => left.localeCompare(right))) {
|
||||||
|
lines.push(`## ${tag}`);
|
||||||
|
lines.push('');
|
||||||
|
lines.push('| Method | Path | Auth | Purpose | Consumers | Source |');
|
||||||
|
lines.push('| --- | --- | --- | --- | --- | --- |');
|
||||||
|
|
||||||
|
for (const record of tagRecords.sort((left, right) => left.path.localeCompare(right.path))) {
|
||||||
|
lines.push(
|
||||||
|
`| ${record.method} | \`${record.path}\` | ${record.authMode} | ${record.purpose} | ${record.consumerFiles.join('<br>') || '-'} | ${record.sourceFile}:${record.sourceLine} |`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.push('');
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(filePath, `${lines.join('\n')}\n`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const clientFiles = walkFiles(clientRoot).filter(filePath => /\.(js|jsx|ts|tsx)$/.test(filePath));
|
||||||
|
const legacyRuntimePath = path.join(serverRoot, 'index.js');
|
||||||
|
const runtimeContent = readText(legacyRuntimePath);
|
||||||
|
const mounts = parseMounts(runtimeContent);
|
||||||
|
const records = [];
|
||||||
|
|
||||||
|
records.push(...parseRoutes(legacyRuntimePath, '', 'mixed_or_inline', clientFiles));
|
||||||
|
|
||||||
|
for (const [routeVariable, mount] of mounts.entries()) {
|
||||||
|
const relativeImport = mount.routeImport.replace('./', '');
|
||||||
|
const routeFilePath = path.join(serverRoot, relativeImport);
|
||||||
|
records.push(...parseRoutes(routeFilePath, mount.basePath, mount.authMode, clientFiles));
|
||||||
|
}
|
||||||
|
|
||||||
|
const realtimeContracts = parseRealtimeContracts(legacyRuntimePath);
|
||||||
|
const summary = {
|
||||||
|
generatedAt: new Date().toISOString(),
|
||||||
|
httpRoutes: records.filter(record => record.transport === 'http').length,
|
||||||
|
sseRoutes: records.filter(record => record.transport === 'sse').length,
|
||||||
|
modularRoutes: records.filter(record => record.sourceFile.includes('/routes/')).length,
|
||||||
|
inlineRoutes: records.filter(record => record.sourceFile === 'server/index.js').length,
|
||||||
|
routeFilesScanned: new Set(records.map(record => record.sourceFile)).size,
|
||||||
|
};
|
||||||
|
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(docsRoot, 'endpoint-inventory.json'),
|
||||||
|
JSON.stringify({ summary, realtimeContracts, records }, null, 2)
|
||||||
|
);
|
||||||
|
|
||||||
|
writeCsv(path.join(docsRoot, 'endpoint-inventory.csv'), records);
|
||||||
|
writeMarkdown(path.join(docsRoot, 'endpoint-inventory.md'), summary, records, realtimeContracts);
|
||||||
|
|
||||||
|
console.log('[inventory] Generated docs/backend/endpoint-inventory.{json,csv,md}');
|
||||||
|
console.log(
|
||||||
|
`[inventory] HTTP=${summary.httpRoutes} SSE=${summary.sseRoutes} Modular=${summary.modularRoutes} Inline=${summary.inlineRoutes}`
|
||||||
|
);
|
||||||
@@ -24,8 +24,8 @@ import {
|
|||||||
notifyRunStopped,
|
notifyRunStopped,
|
||||||
notifyUserIfEnabled
|
notifyUserIfEnabled
|
||||||
} from './services/notification-orchestrator.js';
|
} from './services/notification-orchestrator.js';
|
||||||
import { sessionsService } from './modules/providers/services/sessions.service.js';
|
import { claudeAdapter } from './providers/claude/adapter.js';
|
||||||
import { createNormalizedMessage } from './shared/utils.js';
|
import { createNormalizedMessage } from './providers/types.js';
|
||||||
|
|
||||||
const activeSessions = new Map();
|
const activeSessions = new Map();
|
||||||
const pendingToolApprovals = new Map();
|
const pendingToolApprovals = new Map();
|
||||||
@@ -649,7 +649,7 @@ async function queryClaudeSDK(command, options = {}, ws) {
|
|||||||
const sid = capturedSessionId || sessionId || null;
|
const sid = capturedSessionId || sessionId || null;
|
||||||
|
|
||||||
// Use adapter to normalize SDK events into NormalizedMessage[]
|
// Use adapter to normalize SDK events into NormalizedMessage[]
|
||||||
const normalized = sessionsService.normalizeMessage('claude', transformedMessage, sid);
|
const normalized = claudeAdapter.normalizeMessage(transformedMessage, sid);
|
||||||
for (const msg of normalized) {
|
for (const msg of normalized) {
|
||||||
// Preserve parentToolUseId from SDK wrapper for subagent tool grouping
|
// Preserve parentToolUseId from SDK wrapper for subagent tool grouping
|
||||||
if (transformedMessage.parentToolUseId && !msg.parentToolUseId) {
|
if (transformedMessage.parentToolUseId && !msg.parentToolUseId) {
|
||||||
|
|||||||
399
server/cli.js
399
server/cli.js
@@ -1,13 +1,12 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
/**
|
/**
|
||||||
* CloudCLI CLI
|
* Claude Code UI CLI
|
||||||
*
|
*
|
||||||
* Provides command-line utilities for managing CloudCLI
|
* Provides command-line utilities for managing Claude Code UI
|
||||||
*
|
*
|
||||||
* Commands:
|
* Commands:
|
||||||
* (no args) - Start the server (default)
|
* (no args) - Start the server (default)
|
||||||
* start - Start the server
|
* start - Start the server
|
||||||
* sandbox - Manage Docker sandbox environments
|
|
||||||
* status - Show configuration and data locations
|
* status - Show configuration and data locations
|
||||||
* help - Show help information
|
* help - Show help information
|
||||||
* version - Show version information
|
* version - Show version information
|
||||||
@@ -16,12 +15,11 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import { findAppRoot, getModuleDir } from './utils/runtime-paths.js';
|
import { fileURLToPath } from 'url';
|
||||||
|
import { dirname } from 'path';
|
||||||
|
|
||||||
const __dirname = getModuleDir(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
// The CLI is compiled into dist-server/server, but it still needs to read the top-level
|
const __dirname = dirname(__filename);
|
||||||
// package.json and .env file. Resolving the app root once keeps those lookups stable.
|
|
||||||
const APP_ROOT = findAppRoot(__dirname);
|
|
||||||
|
|
||||||
// ANSI color codes for terminal output
|
// ANSI color codes for terminal output
|
||||||
const colors = {
|
const colors = {
|
||||||
@@ -51,16 +49,13 @@ const c = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Load package.json for version info
|
// Load package.json for version info
|
||||||
const packageJsonPath = path.join(APP_ROOT, 'package.json');
|
const packageJsonPath = path.join(__dirname, '../package.json');
|
||||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||||
// Match the runtime fallback in load-env.js so "cloudcli status" reports the same default
|
|
||||||
// database location that the backend will actually use when no DATABASE_PATH is configured.
|
|
||||||
const DEFAULT_DATABASE_PATH = path.join(os.homedir(), '.cloudcli', 'auth.db');
|
|
||||||
|
|
||||||
// Load environment variables from .env file if it exists
|
// Load environment variables from .env file if it exists
|
||||||
function loadEnvFile() {
|
function loadEnvFile() {
|
||||||
try {
|
try {
|
||||||
const envPath = path.join(APP_ROOT, '.env');
|
const envPath = path.join(__dirname, '../.env');
|
||||||
const envFile = fs.readFileSync(envPath, 'utf8');
|
const envFile = fs.readFileSync(envPath, 'utf8');
|
||||||
envFile.split('\n').forEach(line => {
|
envFile.split('\n').forEach(line => {
|
||||||
const trimmedLine = line.trim();
|
const trimmedLine = line.trim();
|
||||||
@@ -79,17 +74,17 @@ function loadEnvFile() {
|
|||||||
// Get the database path (same logic as db.js)
|
// Get the database path (same logic as db.js)
|
||||||
function getDatabasePath() {
|
function getDatabasePath() {
|
||||||
loadEnvFile();
|
loadEnvFile();
|
||||||
return process.env.DATABASE_PATH || DEFAULT_DATABASE_PATH;
|
return process.env.DATABASE_PATH || path.join(__dirname, 'database', 'auth.db');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the installation directory
|
// Get the installation directory
|
||||||
function getInstallDir() {
|
function getInstallDir() {
|
||||||
return APP_ROOT;
|
return path.join(__dirname, '..');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show status command
|
// Show status command
|
||||||
function showStatus() {
|
function showStatus() {
|
||||||
console.log(`\n${c.bright('CloudCLI UI - Status')}\n`);
|
console.log(`\n${c.bright('Claude Code UI - Status')}\n`);
|
||||||
console.log(c.dim('═'.repeat(60)));
|
console.log(c.dim('═'.repeat(60)));
|
||||||
|
|
||||||
// Version info
|
// Version info
|
||||||
@@ -128,7 +123,7 @@ function showStatus() {
|
|||||||
console.log(` Status: ${projectsExists ? c.ok('[OK] Exists') : c.warn('[WARN] Not found')}`);
|
console.log(` Status: ${projectsExists ? c.ok('[OK] Exists') : c.warn('[WARN] Not found')}`);
|
||||||
|
|
||||||
// Config file location
|
// Config file location
|
||||||
const envFilePath = path.join(APP_ROOT, '.env');
|
const envFilePath = path.join(__dirname, '../.env');
|
||||||
const envExists = fs.existsSync(envFilePath);
|
const envExists = fs.existsSync(envFilePath);
|
||||||
console.log(`\n${c.info('[INFO]')} Configuration File:`);
|
console.log(`\n${c.info('[INFO]')} Configuration File:`);
|
||||||
console.log(` ${c.dim(envFilePath)}`);
|
console.log(` ${c.dim(envFilePath)}`);
|
||||||
@@ -146,7 +141,7 @@ function showStatus() {
|
|||||||
function showHelp() {
|
function showHelp() {
|
||||||
console.log(`
|
console.log(`
|
||||||
╔═══════════════════════════════════════════════════════════════╗
|
╔═══════════════════════════════════════════════════════════════╗
|
||||||
║ CloudCLI - Command Line Tool ║
|
║ Claude Code UI - Command Line Tool ║
|
||||||
╚═══════════════════════════════════════════════════════════════╝
|
╚═══════════════════════════════════════════════════════════════╝
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
@@ -154,8 +149,7 @@ Usage:
|
|||||||
cloudcli [command] [options]
|
cloudcli [command] [options]
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
start Start the CloudCLI server (default)
|
start Start the Claude Code UI server (default)
|
||||||
sandbox Manage Docker sandbox environments
|
|
||||||
status Show configuration and data locations
|
status Show configuration and data locations
|
||||||
update Update to the latest version
|
update Update to the latest version
|
||||||
help Show this help information
|
help Show this help information
|
||||||
@@ -170,7 +164,8 @@ Options:
|
|||||||
Examples:
|
Examples:
|
||||||
$ cloudcli # Start with defaults
|
$ cloudcli # Start with defaults
|
||||||
$ cloudcli --port 8080 # Start on port 8080
|
$ cloudcli --port 8080 # Start on port 8080
|
||||||
$ cloudcli sandbox ~/my-project # Run in a Docker sandbox
|
$ cloudcli -p 3000 # Short form for port
|
||||||
|
$ cloudcli start --port 4000 # Explicit start command
|
||||||
$ cloudcli status # Show configuration
|
$ cloudcli status # Show configuration
|
||||||
|
|
||||||
Environment Variables:
|
Environment Variables:
|
||||||
@@ -208,7 +203,7 @@ function isNewerVersion(v1, v2) {
|
|||||||
async function checkForUpdates(silent = false) {
|
async function checkForUpdates(silent = false) {
|
||||||
try {
|
try {
|
||||||
const { execSync } = await import('child_process');
|
const { execSync } = await import('child_process');
|
||||||
const latestVersion = execSync('npm show @cloudcli-ai/cloudcli version', { encoding: 'utf8' }).trim();
|
const latestVersion = execSync('npm show @siteboon/claude-code-ui version', { encoding: 'utf8' }).trim();
|
||||||
const currentVersion = packageJson.version;
|
const currentVersion = packageJson.version;
|
||||||
|
|
||||||
if (isNewerVersion(latestVersion, currentVersion)) {
|
if (isNewerVersion(latestVersion, currentVersion)) {
|
||||||
@@ -241,361 +236,14 @@ async function updatePackage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(`${c.info('[INFO]')} Updating from ${currentVersion} to ${latestVersion}...`);
|
console.log(`${c.info('[INFO]')} Updating from ${currentVersion} to ${latestVersion}...`);
|
||||||
execSync('npm update -g @cloudcli-ai/cloudcli', { stdio: 'inherit' });
|
execSync('npm update -g @siteboon/claude-code-ui', { stdio: 'inherit' });
|
||||||
console.log(`${c.ok('[OK]')} Update complete! Restart cloudcli to use the new version.`);
|
console.log(`${c.ok('[OK]')} Update complete! Restart cloudcli to use the new version.`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`${c.error('[ERROR]')} Update failed: ${e.message}`);
|
console.error(`${c.error('[ERROR]')} Update failed: ${e.message}`);
|
||||||
console.log(`${c.tip('[TIP]')} Try running manually: npm update -g @cloudcli-ai/cloudcli`);
|
console.log(`${c.tip('[TIP]')} Try running manually: npm update -g @siteboon/claude-code-ui`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Sandbox command ─────────────────────────────────────────
|
|
||||||
|
|
||||||
const SANDBOX_TEMPLATES = {
|
|
||||||
claude: 'docker.io/cloudcliai/sandbox:claude-code',
|
|
||||||
codex: 'docker.io/cloudcliai/sandbox:codex',
|
|
||||||
gemini: 'docker.io/cloudcliai/sandbox:gemini',
|
|
||||||
};
|
|
||||||
|
|
||||||
const SANDBOX_SECRETS = {
|
|
||||||
claude: 'anthropic',
|
|
||||||
codex: 'openai',
|
|
||||||
gemini: 'google',
|
|
||||||
};
|
|
||||||
|
|
||||||
function parseSandboxArgs(args) {
|
|
||||||
const result = {
|
|
||||||
subcommand: null,
|
|
||||||
workspace: null,
|
|
||||||
agent: 'claude',
|
|
||||||
name: null,
|
|
||||||
port: 3001,
|
|
||||||
template: null,
|
|
||||||
env: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
const subcommands = ['ls', 'stop', 'start', 'rm', 'logs', 'help'];
|
|
||||||
|
|
||||||
for (let i = 0; i < args.length; i++) {
|
|
||||||
const arg = args[i];
|
|
||||||
|
|
||||||
if (i === 0 && subcommands.includes(arg)) {
|
|
||||||
result.subcommand = arg;
|
|
||||||
} else if (arg === '--agent' || arg === '-a') {
|
|
||||||
result.agent = args[++i];
|
|
||||||
} else if (arg === '--name' || arg === '-n') {
|
|
||||||
result.name = args[++i];
|
|
||||||
} else if (arg === '--port') {
|
|
||||||
result.port = parseInt(args[++i], 10);
|
|
||||||
} else if (arg === '--template' || arg === '-t') {
|
|
||||||
result.template = args[++i];
|
|
||||||
} else if (arg === '--env' || arg === '-e') {
|
|
||||||
result.env.push(args[++i]);
|
|
||||||
} else if (!arg.startsWith('-')) {
|
|
||||||
if (!result.subcommand) {
|
|
||||||
result.workspace = arg;
|
|
||||||
} else {
|
|
||||||
result.name = arg; // for stop/start/rm/logs <name>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default subcommand based on what we got
|
|
||||||
if (!result.subcommand) {
|
|
||||||
result.subcommand = 'create';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Derive name from workspace path if not set
|
|
||||||
if (!result.name && result.workspace) {
|
|
||||||
result.name = path.basename(path.resolve(result.workspace.replace(/^~/, os.homedir())));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default template from agent
|
|
||||||
if (!result.template) {
|
|
||||||
result.template = SANDBOX_TEMPLATES[result.agent] || SANDBOX_TEMPLATES.claude;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function showSandboxHelp() {
|
|
||||||
console.log(`
|
|
||||||
${c.bright('CloudCLI Sandbox')} — Run CloudCLI inside Docker Sandboxes
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
cloudcli sandbox <workspace> Create and start a sandbox
|
|
||||||
cloudcli sandbox <subcommand> [name] Manage sandboxes
|
|
||||||
|
|
||||||
Subcommands:
|
|
||||||
${c.bright('(default)')} Create a sandbox and start the web UI
|
|
||||||
${c.bright('ls')} List all sandboxes
|
|
||||||
${c.bright('start')} Restart a stopped sandbox and re-launch the web UI
|
|
||||||
${c.bright('stop')} Stop a sandbox (preserves state)
|
|
||||||
${c.bright('rm')} Remove a sandbox
|
|
||||||
${c.bright('logs')} Show CloudCLI server logs
|
|
||||||
${c.bright('help')} Show this help
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-a, --agent <agent> Agent to use: claude, codex, gemini (default: claude)
|
|
||||||
-n, --name <name> Sandbox name (default: derived from workspace folder)
|
|
||||||
-t, --template <image> Custom template image
|
|
||||||
-e, --env <KEY=VALUE> Set environment variable (repeatable)
|
|
||||||
--port <port> Host port for the web UI (default: 3001)
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
$ cloudcli sandbox ~/my-project
|
|
||||||
$ cloudcli sandbox ~/my-project --agent codex --port 8080
|
|
||||||
$ cloudcli sandbox ~/my-project --env SERVER_PORT=8080 --env HOST=0.0.0.0
|
|
||||||
$ cloudcli sandbox ls
|
|
||||||
$ cloudcli sandbox stop my-project
|
|
||||||
$ cloudcli sandbox start my-project
|
|
||||||
$ cloudcli sandbox rm my-project
|
|
||||||
|
|
||||||
Prerequisites:
|
|
||||||
1. Install sbx CLI: https://docs.docker.com/ai/sandboxes/get-started/
|
|
||||||
2. Authenticate and store your API key:
|
|
||||||
sbx login
|
|
||||||
sbx secret set -g anthropic # for Claude
|
|
||||||
sbx secret set -g openai # for Codex
|
|
||||||
sbx secret set -g google # for Gemini
|
|
||||||
|
|
||||||
Advanced usage:
|
|
||||||
For branch mode, multiple workspaces, memory limits, network policies,
|
|
||||||
or passing prompts to the agent, use sbx directly with the template:
|
|
||||||
|
|
||||||
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/my-project --branch my-feature
|
|
||||||
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/project ~/libs:ro --memory 8g
|
|
||||||
|
|
||||||
Full Docker Sandboxes docs: https://docs.docker.com/ai/sandboxes/usage/
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function sandboxCommand(args) {
|
|
||||||
const { execFileSync, spawn: spawnProcess } = await import('child_process');
|
|
||||||
|
|
||||||
// Safe execution — uses execFileSync (no shell) to prevent injection
|
|
||||||
const sbx = (subcmd, opts = {}) => {
|
|
||||||
const result = execFileSync('sbx', subcmd, {
|
|
||||||
encoding: 'utf8',
|
|
||||||
stdio: opts.inherit ? 'inherit' : 'pipe',
|
|
||||||
});
|
|
||||||
return result || '';
|
|
||||||
};
|
|
||||||
|
|
||||||
const opts = parseSandboxArgs(args);
|
|
||||||
|
|
||||||
if (opts.subcommand === 'help') {
|
|
||||||
showSandboxHelp();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate name (alphanumeric, hyphens, underscores only)
|
|
||||||
if (opts.name && !/^[\w-]+$/.test(opts.name)) {
|
|
||||||
console.error(`\n${c.error('❌')} Invalid sandbox name: ${opts.name}`);
|
|
||||||
console.log(` Names may only contain letters, numbers, hyphens, and underscores.\n`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check sbx is installed
|
|
||||||
try {
|
|
||||||
sbx(['version']);
|
|
||||||
} catch {
|
|
||||||
console.error(`\n${c.error('❌')} ${c.bright('sbx')} CLI not found.\n`);
|
|
||||||
console.log(` Install it from: ${c.info('https://docs.docker.com/ai/sandboxes/get-started/')}`);
|
|
||||||
console.log(` Then run: ${c.bright('sbx login')}`);
|
|
||||||
console.log(` And store your API key: ${c.bright('sbx secret set -g anthropic')}\n`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (opts.subcommand) {
|
|
||||||
|
|
||||||
case 'ls':
|
|
||||||
sbx(['ls'], { inherit: true });
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'stop':
|
|
||||||
if (!opts.name) {
|
|
||||||
console.error(`\n${c.error('❌')} Sandbox name required: cloudcli sandbox stop <name>\n`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
sbx(['stop', opts.name], { inherit: true });
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'rm':
|
|
||||||
if (!opts.name) {
|
|
||||||
console.error(`\n${c.error('❌')} Sandbox name required: cloudcli sandbox rm <name>\n`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
sbx(['rm', opts.name], { inherit: true });
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'logs':
|
|
||||||
if (!opts.name) {
|
|
||||||
console.error(`\n${c.error('❌')} Sandbox name required: cloudcli sandbox logs <name>\n`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
sbx(['exec', opts.name, 'bash', '-c', 'cat /tmp/cloudcli-ui.log'], { inherit: true });
|
|
||||||
} catch (e) {
|
|
||||||
console.error(`\n${c.error('❌')} Could not read logs: ${e.message || 'Is the sandbox running?'}\n`);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'start': {
|
|
||||||
if (!opts.name) {
|
|
||||||
console.error(`\n${c.error('❌')} Sandbox name required: cloudcli sandbox start <name>\n`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
console.log(`\n${c.info('▶')} Starting sandbox ${c.bright(opts.name)}...`);
|
|
||||||
const restartRun = spawnProcess('sbx', ['run', opts.name], {
|
|
||||||
detached: true,
|
|
||||||
stdio: ['ignore', 'ignore', 'ignore'],
|
|
||||||
});
|
|
||||||
restartRun.unref();
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
||||||
|
|
||||||
console.log(`${c.info('▶')} Launching CloudCLI web server...`);
|
|
||||||
sbx(['exec', opts.name, 'bash', '-c', 'cloudcli start --port 3001 &']);
|
|
||||||
|
|
||||||
console.log(`${c.info('▶')} Forwarding port ${opts.port} → 3001...`);
|
|
||||||
try {
|
|
||||||
sbx(['ports', opts.name, '--publish', `${opts.port}:3001`]);
|
|
||||||
} catch (e) {
|
|
||||||
const msg = e.stdout || e.stderr || e.message || '';
|
|
||||||
if (msg.includes('address already in use')) {
|
|
||||||
const altPort = opts.port + 1;
|
|
||||||
console.log(`${c.warn('⚠')} Port ${opts.port} in use, trying ${altPort}...`);
|
|
||||||
try {
|
|
||||||
sbx(['ports', opts.name, '--publish', `${altPort}:3001`]);
|
|
||||||
opts.port = altPort;
|
|
||||||
} catch {
|
|
||||||
console.error(`${c.error('❌')} Ports ${opts.port} and ${altPort} both in use. Use --port to specify a free port.`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`\n${c.ok('✔')} ${c.bright('CloudCLI is ready!')}`);
|
|
||||||
console.log(` ${c.info('→')} ${c.bright(`http://localhost:${opts.port}`)}\n`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'create': {
|
|
||||||
if (!opts.workspace) {
|
|
||||||
console.error(`\n${c.error('❌')} Workspace path required: cloudcli sandbox <path>\n`);
|
|
||||||
console.log(` Example: ${c.bright('cloudcli sandbox ~/my-project')}\n`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const workspace = opts.workspace.startsWith('~')
|
|
||||||
? opts.workspace.replace(/^~/, os.homedir())
|
|
||||||
: path.resolve(opts.workspace);
|
|
||||||
|
|
||||||
if (!fs.existsSync(workspace)) {
|
|
||||||
console.error(`\n${c.error('❌')} Workspace path not found: ${c.dim(workspace)}\n`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const secret = SANDBOX_SECRETS[opts.agent] || 'anthropic';
|
|
||||||
|
|
||||||
// Check if the required secret is stored
|
|
||||||
try {
|
|
||||||
const secretList = sbx(['secret', 'ls']);
|
|
||||||
if (!secretList.includes(secret)) {
|
|
||||||
console.error(`\n${c.error('❌')} No ${c.bright(secret)} API key found.\n`);
|
|
||||||
console.log(` Run: ${c.bright(`sbx secret set -g ${secret}`)}\n`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
} catch { /* sbx secret ls not available, skip check */ }
|
|
||||||
|
|
||||||
console.log(`\n${c.bright('CloudCLI Sandbox')}`);
|
|
||||||
console.log(c.dim('─'.repeat(50)));
|
|
||||||
console.log(` Agent: ${c.info(opts.agent)} ${c.dim(`(${secret} credentials)`)}`);
|
|
||||||
console.log(` Workspace: ${c.dim(workspace)}`);
|
|
||||||
console.log(` Name: ${c.dim(opts.name)}`);
|
|
||||||
console.log(` Template: ${c.dim(opts.template)}`);
|
|
||||||
console.log(` Port: ${c.dim(String(opts.port))}`);
|
|
||||||
if (opts.env.length > 0) {
|
|
||||||
console.log(` Env: ${c.dim(opts.env.join(', '))}`);
|
|
||||||
}
|
|
||||||
console.log(c.dim('─'.repeat(50)));
|
|
||||||
|
|
||||||
// Step 1: Launch sandbox with sbx run in background.
|
|
||||||
// sbx run creates the sandbox (or reconnects) AND holds an active session,
|
|
||||||
// which prevents the sandbox from auto-stopping.
|
|
||||||
console.log(`\n${c.info('▶')} Creating sandbox ${c.bright(opts.name)}...`);
|
|
||||||
const bgRun = spawnProcess('sbx', [
|
|
||||||
'run', '--template', opts.template, '--name', opts.name, opts.agent, workspace,
|
|
||||||
], {
|
|
||||||
detached: true,
|
|
||||||
stdio: ['ignore', 'ignore', 'ignore'],
|
|
||||||
});
|
|
||||||
bgRun.unref();
|
|
||||||
// Wait for sandbox to be ready
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
||||||
|
|
||||||
// Step 2: Inject environment variables
|
|
||||||
if (opts.env.length > 0) {
|
|
||||||
console.log(`${c.info('▶')} Setting environment variables...`);
|
|
||||||
const exports = opts.env
|
|
||||||
.filter(e => /^\w+=.+$/.test(e))
|
|
||||||
.map(e => `export ${e}`)
|
|
||||||
.join('\n');
|
|
||||||
if (exports) {
|
|
||||||
sbx(['exec', opts.name, 'bash', '-c', `echo '${exports}' >> /etc/sandbox-persistent.sh`]);
|
|
||||||
}
|
|
||||||
const invalid = opts.env.filter(e => !/^\w+=.+$/.test(e));
|
|
||||||
if (invalid.length > 0) {
|
|
||||||
console.log(`${c.warn('⚠')} Skipped invalid env vars: ${invalid.join(', ')} (expected KEY=VALUE)`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 3: Start CloudCLI inside the sandbox
|
|
||||||
console.log(`${c.info('▶')} Launching CloudCLI web server...`);
|
|
||||||
sbx(['exec', opts.name, 'bash', '-c', 'cloudcli start --port 3001 &']);
|
|
||||||
|
|
||||||
// Step 4: Forward port
|
|
||||||
console.log(`${c.info('▶')} Forwarding port ${opts.port} → 3001...`);
|
|
||||||
try {
|
|
||||||
sbx(['ports', opts.name, '--publish', `${opts.port}:3001`]);
|
|
||||||
} catch (e) {
|
|
||||||
const msg = e.stdout || e.stderr || e.message || '';
|
|
||||||
if (msg.includes('address already in use')) {
|
|
||||||
const altPort = opts.port + 1;
|
|
||||||
console.log(`${c.warn('⚠')} Port ${opts.port} in use, trying ${altPort}...`);
|
|
||||||
try {
|
|
||||||
sbx(['ports', opts.name, '--publish', `${altPort}:3001`]);
|
|
||||||
opts.port = altPort;
|
|
||||||
} catch {
|
|
||||||
console.error(`${c.error('❌')} Ports ${opts.port} and ${altPort} both in use. Use --port to specify a free port.`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Done
|
|
||||||
console.log(`\n${c.ok('✔')} ${c.bright('CloudCLI is ready!')}`);
|
|
||||||
console.log(` ${c.info('→')} Open ${c.bright(`http://localhost:${opts.port}`)}`);
|
|
||||||
console.log(`\n${c.dim(' Manage with:')}`);
|
|
||||||
console.log(` ${c.dim('$')} sbx ls`);
|
|
||||||
console.log(` ${c.dim('$')} sbx stop ${opts.name}`);
|
|
||||||
console.log(` ${c.dim('$')} sbx start ${opts.name}`);
|
|
||||||
console.log(` ${c.dim('$')} sbx rm ${opts.name}`);
|
|
||||||
console.log(`\n${c.dim(' Or install globally:')} npm install -g @cloudcli-ai/cloudcli\n`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
showSandboxHelp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Server ──────────────────────────────────────────────────
|
|
||||||
|
|
||||||
// Start the server
|
// Start the server
|
||||||
async function startServer() {
|
async function startServer() {
|
||||||
// Check for updates silently on startup
|
// Check for updates silently on startup
|
||||||
@@ -626,10 +274,6 @@ function parseArgs(args) {
|
|||||||
parsed.command = 'version';
|
parsed.command = 'version';
|
||||||
} else if (!arg.startsWith('-')) {
|
} else if (!arg.startsWith('-')) {
|
||||||
parsed.command = arg;
|
parsed.command = arg;
|
||||||
if (arg === 'sandbox') {
|
|
||||||
parsed.remainingArgs = args.slice(i + 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -639,7 +283,7 @@ function parseArgs(args) {
|
|||||||
// Main CLI handler
|
// Main CLI handler
|
||||||
async function main() {
|
async function main() {
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
const { command, options, remainingArgs } = parseArgs(args);
|
const { command, options } = parseArgs(args);
|
||||||
|
|
||||||
// Apply CLI options to environment variables
|
// Apply CLI options to environment variables
|
||||||
if (options.serverPort) {
|
if (options.serverPort) {
|
||||||
@@ -655,9 +299,6 @@ async function main() {
|
|||||||
case 'start':
|
case 'start':
|
||||||
await startServer();
|
await startServer();
|
||||||
break;
|
break;
|
||||||
case 'sandbox':
|
|
||||||
await sandboxCommand(remainingArgs || []);
|
|
||||||
break;
|
|
||||||
case 'status':
|
case 'status':
|
||||||
case 'info':
|
case 'info':
|
||||||
showStatus();
|
showStatus();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import crossSpawn from 'cross-spawn';
|
import crossSpawn from 'cross-spawn';
|
||||||
import { notifyRunFailed, notifyRunStopped } from './services/notification-orchestrator.js';
|
import { notifyRunFailed, notifyRunStopped } from './services/notification-orchestrator.js';
|
||||||
import { sessionsService } from './modules/providers/services/sessions.service.js';
|
import { cursorAdapter } from './providers/cursor/adapter.js';
|
||||||
import { createNormalizedMessage } from './shared/utils.js';
|
import { createNormalizedMessage } from './providers/types.js';
|
||||||
|
|
||||||
// Use cross-spawn on Windows for better command execution
|
// Use cross-spawn on Windows for better command execution
|
||||||
const spawnFunction = process.platform === 'win32' ? crossSpawn : spawn;
|
const spawnFunction = process.platform === 'win32' ? crossSpawn : spawn;
|
||||||
@@ -189,7 +189,7 @@ async function spawnCursor(command, options = {}, ws) {
|
|||||||
case 'assistant':
|
case 'assistant':
|
||||||
// Accumulate assistant message chunks
|
// Accumulate assistant message chunks
|
||||||
if (response.message && response.message.content && response.message.content.length > 0) {
|
if (response.message && response.message.content && response.message.content.length > 0) {
|
||||||
const normalized = sessionsService.normalizeMessage('cursor', response, capturedSessionId || sessionId || null);
|
const normalized = cursorAdapter.normalizeMessage(response, capturedSessionId || sessionId || null);
|
||||||
for (const msg of normalized) ws.send(msg);
|
for (const msg of normalized) ws.send(msg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -219,7 +219,7 @@ async function spawnCursor(command, options = {}, ws) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not JSON, send as stream delta via adapter
|
// If not JSON, send as stream delta via adapter
|
||||||
const normalized = sessionsService.normalizeMessage('cursor', line, capturedSessionId || sessionId || null);
|
const normalized = cursorAdapter.normalizeMessage(line, capturedSessionId || sessionId || null);
|
||||||
for (const msg of normalized) ws.send(msg);
|
for (const msg of normalized) ws.send(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,21 +2,11 @@ import Database from 'better-sqlite3';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { findAppRoot, getModuleDir } from '../utils/runtime-paths.js';
|
import { fileURLToPath } from 'url';
|
||||||
import {
|
import { dirname } from 'path';
|
||||||
APP_CONFIG_TABLE_SQL,
|
|
||||||
USER_NOTIFICATION_PREFERENCES_TABLE_SQL,
|
|
||||||
VAPID_KEYS_TABLE_SQL,
|
|
||||||
PUSH_SUBSCRIPTIONS_TABLE_SQL,
|
|
||||||
SESSION_NAMES_TABLE_SQL,
|
|
||||||
SESSION_NAMES_LOOKUP_INDEX_SQL,
|
|
||||||
DATABASE_SCHEMA_SQL
|
|
||||||
} from './schema.js';
|
|
||||||
|
|
||||||
const __dirname = getModuleDir(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
// The compiled backend lives under dist-server/server/database, but the install root we log
|
const __dirname = dirname(__filename);
|
||||||
// should still point at the project/app root. Resolving it here avoids build-layout drift.
|
|
||||||
const APP_ROOT = findAppRoot(__dirname);
|
|
||||||
|
|
||||||
// ANSI color codes for terminal output
|
// ANSI color codes for terminal output
|
||||||
const colors = {
|
const colors = {
|
||||||
@@ -34,6 +24,7 @@ const c = {
|
|||||||
|
|
||||||
// Use DATABASE_PATH environment variable if set, otherwise use default location
|
// Use DATABASE_PATH environment variable if set, otherwise use default location
|
||||||
const DB_PATH = process.env.DATABASE_PATH || path.join(__dirname, 'auth.db');
|
const DB_PATH = process.env.DATABASE_PATH || path.join(__dirname, 'auth.db');
|
||||||
|
const INIT_SQL_PATH = path.join(__dirname, 'init.sql');
|
||||||
|
|
||||||
// Ensure database directory exists if custom path is provided
|
// Ensure database directory exists if custom path is provided
|
||||||
if (process.env.DATABASE_PATH) {
|
if (process.env.DATABASE_PATH) {
|
||||||
@@ -71,10 +62,14 @@ const db = new Database(DB_PATH);
|
|||||||
// app_config must exist before any other module imports (auth.js reads the JWT secret at load time).
|
// app_config must exist before any other module imports (auth.js reads the JWT secret at load time).
|
||||||
// runMigrations() also creates this table, but it runs too late for existing installations
|
// runMigrations() also creates this table, but it runs too late for existing installations
|
||||||
// where auth.js is imported before initializeDatabase() is called.
|
// where auth.js is imported before initializeDatabase() is called.
|
||||||
db.exec(APP_CONFIG_TABLE_SQL);
|
db.exec(`CREATE TABLE IF NOT EXISTS app_config (
|
||||||
|
key TEXT PRIMARY KEY,
|
||||||
|
value TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)`);
|
||||||
|
|
||||||
// Show app installation path prominently
|
// Show app installation path prominently
|
||||||
const appInstallPath = APP_ROOT;
|
const appInstallPath = path.join(__dirname, '../..');
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log(c.dim('═'.repeat(60)));
|
console.log(c.dim('═'.repeat(60)));
|
||||||
console.log(`${c.info('[INFO]')} App Installation: ${c.bright(appInstallPath)}`);
|
console.log(`${c.info('[INFO]')} App Installation: ${c.bright(appInstallPath)}`);
|
||||||
@@ -105,12 +100,53 @@ const runMigrations = () => {
|
|||||||
db.exec('ALTER TABLE users ADD COLUMN has_completed_onboarding BOOLEAN DEFAULT 0');
|
db.exec('ALTER TABLE users ADD COLUMN has_completed_onboarding BOOLEAN DEFAULT 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
db.exec(USER_NOTIFICATION_PREFERENCES_TABLE_SQL);
|
db.exec(`
|
||||||
db.exec(VAPID_KEYS_TABLE_SQL);
|
CREATE TABLE IF NOT EXISTS user_notification_preferences (
|
||||||
db.exec(PUSH_SUBSCRIPTIONS_TABLE_SQL);
|
user_id INTEGER PRIMARY KEY,
|
||||||
db.exec(APP_CONFIG_TABLE_SQL);
|
preferences_json TEXT NOT NULL,
|
||||||
db.exec(SESSION_NAMES_TABLE_SQL);
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
db.exec(SESSION_NAMES_LOOKUP_INDEX_SQL);
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
)
|
||||||
|
`);
|
||||||
|
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS vapid_keys (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
public_key TEXT NOT NULL,
|
||||||
|
private_key TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
`);
|
||||||
|
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS push_subscriptions (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER NOT NULL,
|
||||||
|
endpoint TEXT NOT NULL UNIQUE,
|
||||||
|
keys_p256dh TEXT NOT NULL,
|
||||||
|
keys_auth TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
)
|
||||||
|
`);
|
||||||
|
// Create app_config table if it doesn't exist (for existing installations)
|
||||||
|
db.exec(`CREATE TABLE IF NOT EXISTS app_config (
|
||||||
|
key TEXT PRIMARY KEY,
|
||||||
|
value TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)`);
|
||||||
|
|
||||||
|
// Create session_names table if it doesn't exist (for existing installations)
|
||||||
|
db.exec(`CREATE TABLE IF NOT EXISTS session_names (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
session_id TEXT NOT NULL,
|
||||||
|
provider TEXT NOT NULL DEFAULT 'claude',
|
||||||
|
custom_name TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
UNIQUE(session_id, provider)
|
||||||
|
)`);
|
||||||
|
db.exec('CREATE INDEX IF NOT EXISTS idx_session_names_lookup ON session_names(session_id, provider)');
|
||||||
|
|
||||||
console.log('Database migrations completed successfully');
|
console.log('Database migrations completed successfully');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -122,7 +158,8 @@ const runMigrations = () => {
|
|||||||
// Initialize database with schema
|
// Initialize database with schema
|
||||||
const initializeDatabase = async () => {
|
const initializeDatabase = async () => {
|
||||||
try {
|
try {
|
||||||
db.exec(DATABASE_SCHEMA_SQL);
|
const initSQL = fs.readFileSync(INIT_SQL_PATH, 'utf8');
|
||||||
|
db.exec(initSQL);
|
||||||
console.log('Database initialized successfully');
|
console.log('Database initialized successfully');
|
||||||
runMigrations();
|
runMigrations();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
99
server/database/init.sql
Normal file
99
server/database/init.sql
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
-- Initialize authentication database
|
||||||
|
PRAGMA foreign_keys = ON;
|
||||||
|
|
||||||
|
-- Users table (single user system)
|
||||||
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
username TEXT UNIQUE NOT NULL,
|
||||||
|
password_hash TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
last_login DATETIME,
|
||||||
|
is_active BOOLEAN DEFAULT 1,
|
||||||
|
git_name TEXT,
|
||||||
|
git_email TEXT,
|
||||||
|
has_completed_onboarding BOOLEAN DEFAULT 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Indexes for performance
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_users_username ON users(username);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_users_active ON users(is_active);
|
||||||
|
|
||||||
|
-- API Keys table for external API access
|
||||||
|
CREATE TABLE IF NOT EXISTS api_keys (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER NOT NULL,
|
||||||
|
key_name TEXT NOT NULL,
|
||||||
|
api_key TEXT UNIQUE NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
last_used DATETIME,
|
||||||
|
is_active BOOLEAN DEFAULT 1,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_api_keys_key ON api_keys(api_key);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_api_keys_active ON api_keys(is_active);
|
||||||
|
|
||||||
|
-- User credentials table for storing various tokens/credentials (GitHub, GitLab, etc.)
|
||||||
|
CREATE TABLE IF NOT EXISTS user_credentials (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER NOT NULL,
|
||||||
|
credential_name TEXT NOT NULL,
|
||||||
|
credential_type TEXT NOT NULL, -- 'github_token', 'gitlab_token', 'bitbucket_token', etc.
|
||||||
|
credential_value TEXT NOT NULL,
|
||||||
|
description TEXT,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
is_active BOOLEAN DEFAULT 1,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_user_credentials_user_id ON user_credentials(user_id);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_user_credentials_type ON user_credentials(credential_type);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_user_credentials_active ON user_credentials(is_active);
|
||||||
|
|
||||||
|
-- User notification preferences (backend-owned, provider-agnostic)
|
||||||
|
CREATE TABLE IF NOT EXISTS user_notification_preferences (
|
||||||
|
user_id INTEGER PRIMARY KEY,
|
||||||
|
preferences_json TEXT NOT NULL,
|
||||||
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- VAPID key pair for Web Push notifications
|
||||||
|
CREATE TABLE IF NOT EXISTS vapid_keys (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
public_key TEXT NOT NULL,
|
||||||
|
private_key TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Browser push subscriptions
|
||||||
|
CREATE TABLE IF NOT EXISTS push_subscriptions (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER NOT NULL,
|
||||||
|
endpoint TEXT NOT NULL UNIQUE,
|
||||||
|
keys_p256dh TEXT NOT NULL,
|
||||||
|
keys_auth TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Session custom names (provider-agnostic display name overrides)
|
||||||
|
CREATE TABLE IF NOT EXISTS session_names (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
session_id TEXT NOT NULL,
|
||||||
|
provider TEXT NOT NULL DEFAULT 'claude',
|
||||||
|
custom_name TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
UNIQUE(session_id, provider)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_session_names_lookup ON session_names(session_id, provider);
|
||||||
|
|
||||||
|
-- App configuration table (auto-generated secrets, settings, etc.)
|
||||||
|
CREATE TABLE IF NOT EXISTS app_config (
|
||||||
|
key TEXT PRIMARY KEY,
|
||||||
|
value TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
export const APP_CONFIG_TABLE_SQL = `CREATE TABLE IF NOT EXISTS app_config (
|
|
||||||
key TEXT PRIMARY KEY,
|
|
||||||
value TEXT NOT NULL,
|
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
||||||
);`;
|
|
||||||
|
|
||||||
export const USER_NOTIFICATION_PREFERENCES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS user_notification_preferences (
|
|
||||||
user_id INTEGER PRIMARY KEY,
|
|
||||||
preferences_json TEXT NOT NULL,
|
|
||||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
||||||
);`;
|
|
||||||
|
|
||||||
export const VAPID_KEYS_TABLE_SQL = `CREATE TABLE IF NOT EXISTS vapid_keys (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
public_key TEXT NOT NULL,
|
|
||||||
private_key TEXT NOT NULL,
|
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
||||||
);`;
|
|
||||||
|
|
||||||
export const PUSH_SUBSCRIPTIONS_TABLE_SQL = `CREATE TABLE IF NOT EXISTS push_subscriptions (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
user_id INTEGER NOT NULL,
|
|
||||||
endpoint TEXT NOT NULL UNIQUE,
|
|
||||||
keys_p256dh TEXT NOT NULL,
|
|
||||||
keys_auth TEXT NOT NULL,
|
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
||||||
);`;
|
|
||||||
|
|
||||||
export const SESSION_NAMES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS session_names (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
session_id TEXT NOT NULL,
|
|
||||||
provider TEXT NOT NULL DEFAULT 'claude',
|
|
||||||
custom_name TEXT NOT NULL,
|
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
UNIQUE(session_id, provider)
|
|
||||||
);`;
|
|
||||||
|
|
||||||
export const SESSION_NAMES_LOOKUP_INDEX_SQL = `CREATE INDEX IF NOT EXISTS idx_session_names_lookup ON session_names(session_id, provider);`;
|
|
||||||
|
|
||||||
export const DATABASE_SCHEMA_SQL = `PRAGMA foreign_keys = ON;
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
username TEXT UNIQUE NOT NULL,
|
|
||||||
password_hash TEXT NOT NULL,
|
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
last_login DATETIME,
|
|
||||||
is_active BOOLEAN DEFAULT 1,
|
|
||||||
git_name TEXT,
|
|
||||||
git_email TEXT,
|
|
||||||
has_completed_onboarding BOOLEAN DEFAULT 0
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_users_username ON users(username);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_users_active ON users(is_active);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS api_keys (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
user_id INTEGER NOT NULL,
|
|
||||||
key_name TEXT NOT NULL,
|
|
||||||
api_key TEXT UNIQUE NOT NULL,
|
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
last_used DATETIME,
|
|
||||||
is_active BOOLEAN DEFAULT 1,
|
|
||||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_api_keys_key ON api_keys(api_key);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_api_keys_active ON api_keys(is_active);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS user_credentials (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
user_id INTEGER NOT NULL,
|
|
||||||
credential_name TEXT NOT NULL,
|
|
||||||
credential_type TEXT NOT NULL,
|
|
||||||
credential_value TEXT NOT NULL,
|
|
||||||
description TEXT,
|
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
is_active BOOLEAN DEFAULT 1,
|
|
||||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_user_credentials_user_id ON user_credentials(user_id);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_user_credentials_type ON user_credentials(credential_type);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_user_credentials_active ON user_credentials(is_active);
|
|
||||||
|
|
||||||
${USER_NOTIFICATION_PREFERENCES_TABLE_SQL}
|
|
||||||
|
|
||||||
${VAPID_KEYS_TABLE_SQL}
|
|
||||||
|
|
||||||
${PUSH_SUBSCRIPTIONS_TABLE_SQL}
|
|
||||||
|
|
||||||
${SESSION_NAMES_TABLE_SQL}
|
|
||||||
|
|
||||||
${SESSION_NAMES_LOOKUP_INDEX_SQL}
|
|
||||||
|
|
||||||
${APP_CONFIG_TABLE_SQL}
|
|
||||||
`;
|
|
||||||
@@ -9,7 +9,7 @@ import os from 'os';
|
|||||||
import sessionManager from './sessionManager.js';
|
import sessionManager from './sessionManager.js';
|
||||||
import GeminiResponseHandler from './gemini-response-handler.js';
|
import GeminiResponseHandler from './gemini-response-handler.js';
|
||||||
import { notifyRunFailed, notifyRunStopped } from './services/notification-orchestrator.js';
|
import { notifyRunFailed, notifyRunStopped } from './services/notification-orchestrator.js';
|
||||||
import { createNormalizedMessage } from './shared/utils.js';
|
import { createNormalizedMessage } from './providers/types.js';
|
||||||
|
|
||||||
let activeGeminiProcesses = new Map(); // Track active processes by session ID
|
let activeGeminiProcesses = new Map(); // Track active processes by session ID
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Gemini Response Handler - JSON Stream processing
|
// Gemini Response Handler - JSON Stream processing
|
||||||
import { sessionsService } from './modules/providers/services/sessions.service.js';
|
import { geminiAdapter } from './providers/gemini/adapter.js';
|
||||||
|
|
||||||
class GeminiResponseHandler {
|
class GeminiResponseHandler {
|
||||||
constructor(ws, options = {}) {
|
constructor(ws, options = {}) {
|
||||||
@@ -56,7 +56,7 @@ class GeminiResponseHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normalize via adapter and send all resulting messages
|
// Normalize via adapter and send all resulting messages
|
||||||
const normalized = sessionsService.normalizeMessage('gemini', event, sid);
|
const normalized = geminiAdapter.normalizeMessage(event, sid);
|
||||||
for (const msg of normalized) {
|
for (const msg of normalized) {
|
||||||
this.ws.send(msg);
|
this.ws.send(msg);
|
||||||
}
|
}
|
||||||
|
|||||||
260
server/index.js
260
server/index.js
@@ -3,16 +3,13 @@
|
|||||||
import './load-env.js';
|
import './load-env.js';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { findAppRoot, getModuleDir } from './utils/runtime-paths.js';
|
import { fileURLToPath } from 'url';
|
||||||
|
import { dirname } from 'path';
|
||||||
|
|
||||||
import { AppError, createNormalizedMessage } from '@/shared/utils.js';
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = dirname(__filename);
|
||||||
|
|
||||||
|
const installMode = fs.existsSync(path.join(__dirname, '..', '.git')) ? 'git' : 'npm';
|
||||||
const __dirname = getModuleDir(import.meta.url);
|
|
||||||
// The server source runs from /server, while the compiled output runs from /dist-server/server.
|
|
||||||
// Resolving the app root once keeps every repo-level lookup below aligned across both layouts.
|
|
||||||
const APP_ROOT = findAppRoot(__dirname);
|
|
||||||
const installMode = fs.existsSync(path.join(APP_ROOT, '.git')) ? 'git' : 'npm';
|
|
||||||
|
|
||||||
// ANSI color codes for terminal output
|
// ANSI color codes for terminal output
|
||||||
const colors = {
|
const colors = {
|
||||||
@@ -44,9 +41,10 @@ import cors from 'cors';
|
|||||||
import { promises as fsPromises } from 'fs';
|
import { promises as fsPromises } from 'fs';
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import pty from 'node-pty';
|
import pty from 'node-pty';
|
||||||
|
import fetch from 'node-fetch';
|
||||||
import mime from 'mime-types';
|
import mime from 'mime-types';
|
||||||
|
|
||||||
import { getProjects, getSessions, renameProject, deleteSession, deleteProject, extractProjectDirectory, clearProjectDirectoryCache, searchConversations } from './projects.js';
|
import { getProjects, getSessions, renameProject, deleteSession, deleteProject, addProjectManually, extractProjectDirectory, clearProjectDirectoryCache, searchConversations } from './projects.js';
|
||||||
import { queryClaudeSDK, abortClaudeSDKSession, isClaudeSDKSessionActive, getActiveClaudeSDKSessions, resolveToolApproval, getPendingApprovalsForSession, reconnectSessionWriter } from './claude-sdk.js';
|
import { queryClaudeSDK, abortClaudeSDKSession, isClaudeSDKSessionActive, getActiveClaudeSDKSessions, resolveToolApproval, getPendingApprovalsForSession, reconnectSessionWriter } from './claude-sdk.js';
|
||||||
import { spawnCursor, abortCursorSession, isCursorSessionActive, getActiveCursorSessions } from './cursor-cli.js';
|
import { spawnCursor, abortCursorSession, isCursorSessionActive, getActiveCursorSessions } from './cursor-cli.js';
|
||||||
import { queryCodex, abortCodexSession, isCodexSessionActive, getActiveCodexSessions } from './openai-codex.js';
|
import { queryCodex, abortCodexSession, isCodexSessionActive, getActiveCodexSessions } from './openai-codex.js';
|
||||||
@@ -54,6 +52,7 @@ import { spawnGemini, abortGeminiSession, isGeminiSessionActive, getActiveGemini
|
|||||||
import sessionManager from './sessionManager.js';
|
import sessionManager from './sessionManager.js';
|
||||||
import gitRoutes from './routes/git.js';
|
import gitRoutes from './routes/git.js';
|
||||||
import authRoutes from './routes/auth.js';
|
import authRoutes from './routes/auth.js';
|
||||||
|
import mcpRoutes from './routes/mcp.js';
|
||||||
import cursorRoutes from './routes/cursor.js';
|
import cursorRoutes from './routes/cursor.js';
|
||||||
import taskmasterRoutes from './routes/taskmaster.js';
|
import taskmasterRoutes from './routes/taskmaster.js';
|
||||||
import mcpUtilsRoutes from './routes/mcp-utils.js';
|
import mcpUtilsRoutes from './routes/mcp-utils.js';
|
||||||
@@ -61,12 +60,13 @@ import commandsRoutes from './routes/commands.js';
|
|||||||
import settingsRoutes from './routes/settings.js';
|
import settingsRoutes from './routes/settings.js';
|
||||||
import agentRoutes from './routes/agent.js';
|
import agentRoutes from './routes/agent.js';
|
||||||
import projectsRoutes, { WORKSPACES_ROOT, validateWorkspacePath } from './routes/projects.js';
|
import projectsRoutes, { WORKSPACES_ROOT, validateWorkspacePath } from './routes/projects.js';
|
||||||
|
import cliAuthRoutes from './routes/cli-auth.js';
|
||||||
import userRoutes from './routes/user.js';
|
import userRoutes from './routes/user.js';
|
||||||
import codexRoutes from './routes/codex.js';
|
import codexRoutes from './routes/codex.js';
|
||||||
import geminiRoutes from './routes/gemini.js';
|
import geminiRoutes from './routes/gemini.js';
|
||||||
import pluginsRoutes from './routes/plugins.js';
|
import pluginsRoutes from './routes/plugins.js';
|
||||||
import messagesRoutes from './routes/messages.js';
|
import messagesRoutes from './routes/messages.js';
|
||||||
import providerRoutes from './modules/providers/provider.routes.js';
|
import { createNormalizedMessage } from './providers/types.js';
|
||||||
import { startEnabledPluginServers, stopAllPlugins, getPluginPort } from './utils/plugin-process-manager.js';
|
import { startEnabledPluginServers, stopAllPlugins, getPluginPort } from './utils/plugin-process-manager.js';
|
||||||
import { initializeDatabase, sessionNamesDb, applyCustomSessionNames } from './database/db.js';
|
import { initializeDatabase, sessionNamesDb, applyCustomSessionNames } from './database/db.js';
|
||||||
import { configureWebPush } from './services/vapid-keys.js';
|
import { configureWebPush } from './services/vapid-keys.js';
|
||||||
@@ -365,6 +365,9 @@ app.use('/api/projects', authenticateToken, projectsRoutes);
|
|||||||
// Git API Routes (protected)
|
// Git API Routes (protected)
|
||||||
app.use('/api/git', authenticateToken, gitRoutes);
|
app.use('/api/git', authenticateToken, gitRoutes);
|
||||||
|
|
||||||
|
// MCP API Routes (protected)
|
||||||
|
app.use('/api/mcp', authenticateToken, mcpRoutes);
|
||||||
|
|
||||||
// Cursor API Routes (protected)
|
// Cursor API Routes (protected)
|
||||||
app.use('/api/cursor', authenticateToken, cursorRoutes);
|
app.use('/api/cursor', authenticateToken, cursorRoutes);
|
||||||
|
|
||||||
@@ -380,6 +383,9 @@ app.use('/api/commands', authenticateToken, commandsRoutes);
|
|||||||
// Settings API Routes (protected)
|
// Settings API Routes (protected)
|
||||||
app.use('/api/settings', authenticateToken, settingsRoutes);
|
app.use('/api/settings', authenticateToken, settingsRoutes);
|
||||||
|
|
||||||
|
// CLI Authentication API Routes (protected)
|
||||||
|
app.use('/api/cli', authenticateToken, cliAuthRoutes);
|
||||||
|
|
||||||
// User API Routes (protected)
|
// User API Routes (protected)
|
||||||
app.use('/api/user', authenticateToken, userRoutes);
|
app.use('/api/user', authenticateToken, userRoutes);
|
||||||
|
|
||||||
@@ -395,18 +401,15 @@ app.use('/api/plugins', authenticateToken, pluginsRoutes);
|
|||||||
// Unified session messages route (protected)
|
// Unified session messages route (protected)
|
||||||
app.use('/api/sessions', authenticateToken, messagesRoutes);
|
app.use('/api/sessions', authenticateToken, messagesRoutes);
|
||||||
|
|
||||||
// Unified provider MCP routes (protected)
|
|
||||||
app.use('/api/providers', authenticateToken, providerRoutes);
|
|
||||||
|
|
||||||
// Agent API Routes (uses API key authentication)
|
// Agent API Routes (uses API key authentication)
|
||||||
app.use('/api/agent', agentRoutes);
|
app.use('/api/agent', agentRoutes);
|
||||||
|
|
||||||
// Serve public files (like api-docs.html)
|
// Serve public files (like api-docs.html)
|
||||||
app.use(express.static(path.join(APP_ROOT, 'public')));
|
app.use(express.static(path.join(__dirname, '../public')));
|
||||||
|
|
||||||
// Static files served after API routes
|
// Static files served after API routes
|
||||||
// Add cache control: HTML files should not be cached, but assets can be cached
|
// Add cache control: HTML files should not be cached, but assets can be cached
|
||||||
app.use(express.static(path.join(APP_ROOT, 'dist'), {
|
app.use(express.static(path.join(__dirname, '../dist'), {
|
||||||
setHeaders: (res, filePath) => {
|
setHeaders: (res, filePath) => {
|
||||||
if (filePath.endsWith('.html')) {
|
if (filePath.endsWith('.html')) {
|
||||||
// Prevent HTML caching to avoid service worker issues after builds
|
// Prevent HTML caching to avoid service worker issues after builds
|
||||||
@@ -428,24 +431,17 @@ app.use(express.static(path.join(APP_ROOT, 'dist'), {
|
|||||||
app.post('/api/system/update', authenticateToken, async (req, res) => {
|
app.post('/api/system/update', authenticateToken, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// Get the project root directory (parent of server directory)
|
// Get the project root directory (parent of server directory)
|
||||||
const projectRoot = APP_ROOT;
|
const projectRoot = path.join(__dirname, '..');
|
||||||
|
|
||||||
console.log('Starting system update from directory:', projectRoot);
|
console.log('Starting system update from directory:', projectRoot);
|
||||||
|
|
||||||
// Platform deployments use their own update workflow from the project root.
|
// Run the update command based on install mode
|
||||||
const updateCommand = IS_PLATFORM
|
const updateCommand = installMode === 'git'
|
||||||
// In platform, husky and dev dependencies are not needed
|
? 'git checkout main && git pull && npm install'
|
||||||
? 'npm run update:platform'
|
: 'npm install -g @siteboon/claude-code-ui@latest';
|
||||||
: installMode === 'git'
|
|
||||||
? 'git checkout main && git pull && npm install'
|
|
||||||
: 'npm install -g @cloudcli-ai/cloudcli@latest';
|
|
||||||
|
|
||||||
const updateCwd = IS_PLATFORM || installMode === 'git'
|
|
||||||
? projectRoot
|
|
||||||
: os.homedir();
|
|
||||||
|
|
||||||
const child = spawn('sh', ['-c', updateCommand], {
|
const child = spawn('sh', ['-c', updateCommand], {
|
||||||
cwd: updateCwd,
|
cwd: installMode === 'git' ? projectRoot : os.homedir(),
|
||||||
env: process.env
|
env: process.env
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -582,6 +578,23 @@ app.delete('/api/projects/:projectName', authenticateToken, async (req, res) =>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Create project endpoint
|
||||||
|
app.post('/api/projects/create', authenticateToken, async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { path: projectPath } = req.body;
|
||||||
|
|
||||||
|
if (!projectPath || !projectPath.trim()) {
|
||||||
|
return res.status(400).json({ error: 'Project path is required' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const project = await addProjectManually(projectPath.trim());
|
||||||
|
res.json({ success: true, project });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error creating project:', error);
|
||||||
|
res.status(500).json({ error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Search conversations content (SSE streaming)
|
// Search conversations content (SSE streaming)
|
||||||
app.get('/api/search/conversations', authenticateToken, async (req, res) => {
|
app.get('/api/search/conversations', authenticateToken, async (req, res) => {
|
||||||
const query = typeof req.query.q === 'string' ? req.query.q.trim() : '';
|
const query = typeof req.query.q === 'string' ? req.query.q.trim() : '';
|
||||||
@@ -799,7 +812,7 @@ app.get('/api/projects/:projectName/file', authenticateToken, async (req, res) =
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serve raw file bytes for previews and downloads.
|
// Serve binary file content endpoint (for images, etc.)
|
||||||
app.get('/api/projects/:projectName/files/content', authenticateToken, async (req, res) => {
|
app.get('/api/projects/:projectName/files/content', authenticateToken, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { projectName } = req.params;
|
const { projectName } = req.params;
|
||||||
@@ -816,11 +829,7 @@ app.get('/api/projects/:projectName/files/content', authenticateToken, async (re
|
|||||||
return res.status(404).json({ error: 'Project not found' });
|
return res.status(404).json({ error: 'Project not found' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match the text reader endpoint so callers can pass either project-relative
|
const resolved = path.resolve(filePath);
|
||||||
// or absolute paths without changing how the bytes are served.
|
|
||||||
const resolved = path.isAbsolute(filePath)
|
|
||||||
? path.resolve(filePath)
|
|
||||||
: path.resolve(projectRoot, filePath);
|
|
||||||
const normalizedRoot = path.resolve(projectRoot) + path.sep;
|
const normalizedRoot = path.resolve(projectRoot) + path.sep;
|
||||||
if (!resolved.startsWith(normalizedRoot)) {
|
if (!resolved.startsWith(normalizedRoot)) {
|
||||||
return res.status(403).json({ error: 'Path must be under project root' });
|
return res.status(403).json({ error: 'Path must be under project root' });
|
||||||
@@ -1434,7 +1443,7 @@ wss.on('connection', (ws, request) => {
|
|||||||
/**
|
/**
|
||||||
* WebSocket Writer - Wrapper for WebSocket to match SSEStreamWriter interface
|
* WebSocket Writer - Wrapper for WebSocket to match SSEStreamWriter interface
|
||||||
*
|
*
|
||||||
* Provider files use `createNormalizedMessage()` from `shared/utils.js` and
|
* Provider files use `createNormalizedMessage()` from `providers/types.js` and
|
||||||
* adapter `normalizeMessage()` to produce unified NormalizedMessage events.
|
* adapter `normalizeMessage()` to produce unified NormalizedMessage events.
|
||||||
* The writer simply serialises and sends.
|
* The writer simply serialises and sends.
|
||||||
*/
|
*/
|
||||||
@@ -1971,6 +1980,155 @@ function handleShellConnection(ws) {
|
|||||||
console.error('[ERROR] Shell WebSocket error:', error);
|
console.error('[ERROR] Shell WebSocket error:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Audio transcription endpoint
|
||||||
|
app.post('/api/transcribe', authenticateToken, async (req, res) => {
|
||||||
|
try {
|
||||||
|
const multer = (await import('multer')).default;
|
||||||
|
const upload = multer({ storage: multer.memoryStorage() });
|
||||||
|
|
||||||
|
// Handle multipart form data
|
||||||
|
upload.single('audio')(req, res, async (err) => {
|
||||||
|
if (err) {
|
||||||
|
return res.status(400).json({ error: 'Failed to process audio file' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!req.file) {
|
||||||
|
return res.status(400).json({ error: 'No audio file provided' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const apiKey = process.env.OPENAI_API_KEY;
|
||||||
|
if (!apiKey) {
|
||||||
|
return res.status(500).json({ error: 'OpenAI API key not configured. Please set OPENAI_API_KEY in server environment.' });
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Create form data for OpenAI
|
||||||
|
const FormData = (await import('form-data')).default;
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', req.file.buffer, {
|
||||||
|
filename: req.file.originalname,
|
||||||
|
contentType: req.file.mimetype
|
||||||
|
});
|
||||||
|
formData.append('model', 'whisper-1');
|
||||||
|
formData.append('response_format', 'json');
|
||||||
|
formData.append('language', 'en');
|
||||||
|
|
||||||
|
// Make request to OpenAI
|
||||||
|
const response = await fetch('https://api.openai.com/v1/audio/transcriptions', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${apiKey}`,
|
||||||
|
...formData.getHeaders()
|
||||||
|
},
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorData = await response.json().catch(() => ({}));
|
||||||
|
throw new Error(errorData.error?.message || `Whisper API error: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
let transcribedText = data.text || '';
|
||||||
|
|
||||||
|
// Check if enhancement mode is enabled
|
||||||
|
const mode = req.body.mode || 'default';
|
||||||
|
|
||||||
|
// If no transcribed text, return empty
|
||||||
|
if (!transcribedText) {
|
||||||
|
return res.json({ text: '' });
|
||||||
|
}
|
||||||
|
|
||||||
|
// If default mode, return transcribed text without enhancement
|
||||||
|
if (mode === 'default') {
|
||||||
|
return res.json({ text: transcribedText });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle different enhancement modes
|
||||||
|
try {
|
||||||
|
const OpenAI = (await import('openai')).default;
|
||||||
|
const openai = new OpenAI({ apiKey });
|
||||||
|
|
||||||
|
let prompt, systemMessage, temperature = 0.7, maxTokens = 800;
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
|
case 'prompt':
|
||||||
|
systemMessage = 'You are an expert prompt engineer who creates clear, detailed, and effective prompts.';
|
||||||
|
prompt = `You are an expert prompt engineer. Transform the following rough instruction into a clear, detailed, and context-aware AI prompt.
|
||||||
|
|
||||||
|
Your enhanced prompt should:
|
||||||
|
1. Be specific and unambiguous
|
||||||
|
2. Include relevant context and constraints
|
||||||
|
3. Specify the desired output format
|
||||||
|
4. Use clear, actionable language
|
||||||
|
5. Include examples where helpful
|
||||||
|
6. Consider edge cases and potential ambiguities
|
||||||
|
|
||||||
|
Transform this rough instruction into a well-crafted prompt:
|
||||||
|
"${transcribedText}"
|
||||||
|
|
||||||
|
Enhanced prompt:`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'vibe':
|
||||||
|
case 'instructions':
|
||||||
|
case 'architect':
|
||||||
|
systemMessage = 'You are a helpful assistant that formats ideas into clear, actionable instructions for AI agents.';
|
||||||
|
temperature = 0.5; // Lower temperature for more controlled output
|
||||||
|
prompt = `Transform the following idea into clear, well-structured instructions that an AI agent can easily understand and execute.
|
||||||
|
|
||||||
|
IMPORTANT RULES:
|
||||||
|
- Format as clear, step-by-step instructions
|
||||||
|
- Add reasonable implementation details based on common patterns
|
||||||
|
- Only include details directly related to what was asked
|
||||||
|
- Do NOT add features or functionality not mentioned
|
||||||
|
- Keep the original intent and scope intact
|
||||||
|
- Use clear, actionable language an agent can follow
|
||||||
|
|
||||||
|
Transform this idea into agent-friendly instructions:
|
||||||
|
"${transcribedText}"
|
||||||
|
|
||||||
|
Agent instructions:`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// No enhancement needed
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only make GPT call if we have a prompt
|
||||||
|
if (prompt) {
|
||||||
|
const completion = await openai.chat.completions.create({
|
||||||
|
model: 'gpt-4o-mini',
|
||||||
|
messages: [
|
||||||
|
{ role: 'system', content: systemMessage },
|
||||||
|
{ role: 'user', content: prompt }
|
||||||
|
],
|
||||||
|
temperature: temperature,
|
||||||
|
max_tokens: maxTokens
|
||||||
|
});
|
||||||
|
|
||||||
|
transcribedText = completion.choices[0].message.content || transcribedText;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (gptError) {
|
||||||
|
console.error('GPT processing error:', gptError);
|
||||||
|
// Fall back to original transcription if GPT fails
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({ text: transcribedText });
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Transcription error:', error);
|
||||||
|
res.status(500).json({ error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Endpoint error:', error);
|
||||||
|
res.status(500).json({ error: 'Internal server error' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Image upload endpoint
|
// Image upload endpoint
|
||||||
app.post('/api/projects/:projectName/upload-images', authenticateToken, async (req, res) => {
|
app.post('/api/projects/:projectName/upload-images', authenticateToken, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
@@ -2253,7 +2411,7 @@ app.get('*', (req, res) => {
|
|||||||
|
|
||||||
// Only serve index.html for HTML routes, not for static assets
|
// Only serve index.html for HTML routes, not for static assets
|
||||||
// Static assets should already be handled by express.static middleware above
|
// Static assets should already be handled by express.static middleware above
|
||||||
const indexPath = path.join(APP_ROOT, 'dist', 'index.html');
|
const indexPath = path.join(__dirname, '../dist/index.html');
|
||||||
|
|
||||||
// Check if dist/index.html exists (production build available)
|
// Check if dist/index.html exists (production build available)
|
||||||
if (fs.existsSync(indexPath)) {
|
if (fs.existsSync(indexPath)) {
|
||||||
@@ -2269,30 +2427,6 @@ app.get('*', (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// global error middleware must be last
|
|
||||||
app.use((err, req, res, next) => {
|
|
||||||
if (err instanceof AppError) {
|
|
||||||
return res.status(err.statusCode).json({
|
|
||||||
success: false,
|
|
||||||
error: {
|
|
||||||
code: err.code,
|
|
||||||
message: err.message,
|
|
||||||
details: err.details,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
console.error(err);
|
|
||||||
|
|
||||||
return res.status(500).json({
|
|
||||||
success: false,
|
|
||||||
error: {
|
|
||||||
code: 'INTERNAL_ERROR',
|
|
||||||
message: 'Internal server error',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Helper function to convert permissions to rwx format
|
// Helper function to convert permissions to rwx format
|
||||||
function permToRwx(perm) {
|
function permToRwx(perm) {
|
||||||
const r = perm & 4 ? 'r' : '-';
|
const r = perm & 4 ? 'r' : '-';
|
||||||
@@ -2392,7 +2526,7 @@ async function startServer() {
|
|||||||
configureWebPush();
|
configureWebPush();
|
||||||
|
|
||||||
// Check if running in production mode (dist folder exists)
|
// Check if running in production mode (dist folder exists)
|
||||||
const distIndexPath = path.join(APP_ROOT, 'dist', 'index.html');
|
const distIndexPath = path.join(__dirname, '../dist/index.html');
|
||||||
const isProduction = fs.existsSync(distIndexPath);
|
const isProduction = fs.existsSync(distIndexPath);
|
||||||
|
|
||||||
// Log Claude implementation mode
|
// Log Claude implementation mode
|
||||||
@@ -2406,11 +2540,11 @@ async function startServer() {
|
|||||||
console.log(`${c.info('[INFO]')} To run in development mode with hot-module replacement, go to http://${DISPLAY_HOST}:${VITE_PORT}`);
|
console.log(`${c.info('[INFO]')} To run in development mode with hot-module replacement, go to http://${DISPLAY_HOST}:${VITE_PORT}`);
|
||||||
|
|
||||||
server.listen(SERVER_PORT, HOST, async () => {
|
server.listen(SERVER_PORT, HOST, async () => {
|
||||||
const appInstallPath = APP_ROOT;
|
const appInstallPath = path.join(__dirname, '..');
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log(c.dim('═'.repeat(63)));
|
console.log(c.dim('═'.repeat(63)));
|
||||||
console.log(` ${c.bright('CloudCLI Server - Ready')}`);
|
console.log(` ${c.bright('Claude Code UI Server - Ready')}`);
|
||||||
console.log(c.dim('═'.repeat(63)));
|
console.log(c.dim('═'.repeat(63)));
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log(`${c.info('[INFO]')} Server URL: ${c.bright('http://' + DISPLAY_HOST + ':' + SERVER_PORT)}`);
|
console.log(`${c.info('[INFO]')} Server URL: ${c.bright('http://' + DISPLAY_HOST + ':' + SERVER_PORT)}`);
|
||||||
|
|||||||
@@ -2,15 +2,14 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { findAppRoot, getModuleDir } from './utils/runtime-paths.js';
|
import { fileURLToPath } from 'url';
|
||||||
|
import { dirname } from 'path';
|
||||||
|
|
||||||
const __dirname = getModuleDir(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
// Resolve the repo/app root via the nearest /server folder so this file keeps finding the
|
const __dirname = dirname(__filename);
|
||||||
// same top-level .env file from both /server/load-env.js and /dist-server/server/load-env.js.
|
|
||||||
const APP_ROOT = findAppRoot(__dirname);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const envPath = path.join(APP_ROOT, '.env');
|
const envPath = path.join(__dirname, '../.env');
|
||||||
const envFile = fs.readFileSync(envPath, 'utf8');
|
const envFile = fs.readFileSync(envPath, 'utf8');
|
||||||
envFile.split('\n').forEach(line => {
|
envFile.split('\n').forEach(line => {
|
||||||
const trimmedLine = line.trim();
|
const trimmedLine = line.trim();
|
||||||
@@ -25,10 +24,6 @@ try {
|
|||||||
console.log('No .env file found or error reading it:', e.message);
|
console.log('No .env file found or error reading it:', e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep the default database in a stable user-level location so rebuilding dist-server
|
|
||||||
// never changes where the backend stores auth.db when DATABASE_PATH is not set explicitly.
|
|
||||||
const DEFAULT_DATABASE_PATH = path.join(os.homedir(), '.cloudcli', 'auth.db');
|
|
||||||
|
|
||||||
if (!process.env.DATABASE_PATH) {
|
if (!process.env.DATABASE_PATH) {
|
||||||
process.env.DATABASE_PATH = DEFAULT_DATABASE_PATH;
|
process.env.DATABASE_PATH = path.join(os.homedir(), '.cloudcli', 'auth.db');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
import { readFile } from 'node:fs/promises';
|
|
||||||
import os from 'node:os';
|
|
||||||
import path from 'node:path';
|
|
||||||
|
|
||||||
import spawn from 'cross-spawn';
|
|
||||||
|
|
||||||
import type { IProviderAuth } from '@/shared/interfaces.js';
|
|
||||||
import type { ProviderAuthStatus } from '@/shared/types.js';
|
|
||||||
import { readObjectRecord, readOptionalString } from '@/shared/utils.js';
|
|
||||||
|
|
||||||
type ClaudeCredentialsStatus = {
|
|
||||||
authenticated: boolean;
|
|
||||||
email: string | null;
|
|
||||||
method: string | null;
|
|
||||||
error?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class ClaudeProviderAuth implements IProviderAuth {
|
|
||||||
/**
|
|
||||||
* Checks whether the Claude Code CLI is available on this host.
|
|
||||||
*/
|
|
||||||
private checkInstalled(): boolean {
|
|
||||||
const cliPath = process.env.CLAUDE_CLI_PATH || 'claude';
|
|
||||||
try {
|
|
||||||
spawn.sync(cliPath, ['--version'], { stdio: 'ignore', timeout: 5000 });
|
|
||||||
return true;
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns Claude installation and credential status using Claude Code's auth priority.
|
|
||||||
*/
|
|
||||||
async getStatus(): Promise<ProviderAuthStatus> {
|
|
||||||
const installed = this.checkInstalled();
|
|
||||||
|
|
||||||
if (!installed) {
|
|
||||||
return {
|
|
||||||
installed,
|
|
||||||
provider: 'claude',
|
|
||||||
authenticated: false,
|
|
||||||
email: null,
|
|
||||||
method: null,
|
|
||||||
error: 'Claude Code CLI is not installed',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const credentials = await this.checkCredentials();
|
|
||||||
|
|
||||||
return {
|
|
||||||
installed,
|
|
||||||
provider: 'claude',
|
|
||||||
authenticated: credentials.authenticated,
|
|
||||||
email: credentials.authenticated ? credentials.email || 'Authenticated' : credentials.email,
|
|
||||||
method: credentials.method,
|
|
||||||
error: credentials.authenticated ? undefined : credentials.error || 'Not authenticated',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads Claude settings env values that the CLI can use even when the server process env is empty.
|
|
||||||
*/
|
|
||||||
private async loadSettingsEnv(): Promise<Record<string, unknown>> {
|
|
||||||
try {
|
|
||||||
const settingsPath = path.join(os.homedir(), '.claude', 'settings.json');
|
|
||||||
const content = await readFile(settingsPath, 'utf8');
|
|
||||||
const settings = readObjectRecord(JSON.parse(content));
|
|
||||||
return readObjectRecord(settings?.env) ?? {};
|
|
||||||
} catch {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks Claude credentials in the same priority order used by Claude Code.
|
|
||||||
*/
|
|
||||||
private async checkCredentials(): Promise<ClaudeCredentialsStatus> {
|
|
||||||
if (process.env.ANTHROPIC_API_KEY?.trim()) {
|
|
||||||
return { authenticated: true, email: 'API Key Auth', method: 'api_key' };
|
|
||||||
}
|
|
||||||
|
|
||||||
const settingsEnv = await this.loadSettingsEnv();
|
|
||||||
if (readOptionalString(settingsEnv.ANTHROPIC_API_KEY)) {
|
|
||||||
return { authenticated: true, email: 'API Key Auth', method: 'api_key' };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (readOptionalString(settingsEnv.ANTHROPIC_AUTH_TOKEN)) {
|
|
||||||
return { authenticated: true, email: 'Configured via settings.json', method: 'api_key' };
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const credPath = path.join(os.homedir(), '.claude', '.credentials.json');
|
|
||||||
const content = await readFile(credPath, 'utf8');
|
|
||||||
const creds = readObjectRecord(JSON.parse(content)) ?? {};
|
|
||||||
const oauth = readObjectRecord(creds.claudeAiOauth);
|
|
||||||
const accessToken = readOptionalString(oauth?.accessToken);
|
|
||||||
|
|
||||||
if (accessToken) {
|
|
||||||
const expiresAt = typeof oauth?.expiresAt === 'number' ? oauth.expiresAt : undefined;
|
|
||||||
const email = readOptionalString(creds.email) ?? readOptionalString(creds.user) ?? null;
|
|
||||||
if (!expiresAt || Date.now() < expiresAt) {
|
|
||||||
return {
|
|
||||||
authenticated: true,
|
|
||||||
email,
|
|
||||||
method: 'credentials_file',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
authenticated: false,
|
|
||||||
email,
|
|
||||||
method: 'credentials_file',
|
|
||||||
error: 'OAuth token has expired. Please re-authenticate with claude login',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return { authenticated: false, email: null, method: null };
|
|
||||||
} catch {
|
|
||||||
return { authenticated: false, email: null, method: null };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,321 +0,0 @@
|
|||||||
import { getSessionMessages } from '@/projects.js';
|
|
||||||
import { AbstractProvider } from '@/modules/providers/shared/base/abstract.provider.js';
|
|
||||||
import { ClaudeProviderAuth } from '@/modules/providers/list/claude/claude-auth.provider.js';
|
|
||||||
import { ClaudeMcpProvider } from '@/modules/providers/list/claude/claude-mcp.provider.js';
|
|
||||||
import type { IProviderAuth } from '@/shared/interfaces.js';
|
|
||||||
import type { FetchHistoryOptions, FetchHistoryResult, NormalizedMessage } from '@/shared/types.js';
|
|
||||||
import { createNormalizedMessage, generateMessageId, readObjectRecord } from '@/shared/utils.js';
|
|
||||||
|
|
||||||
const PROVIDER = 'claude';
|
|
||||||
|
|
||||||
type RawProviderMessage = Record<string, any>;
|
|
||||||
|
|
||||||
type ClaudeToolResult = {
|
|
||||||
content: unknown;
|
|
||||||
isError: boolean;
|
|
||||||
subagentTools?: unknown;
|
|
||||||
toolUseResult?: unknown;
|
|
||||||
};
|
|
||||||
|
|
||||||
type ClaudeHistoryResult =
|
|
||||||
| RawProviderMessage[]
|
|
||||||
| {
|
|
||||||
messages?: RawProviderMessage[];
|
|
||||||
total?: number;
|
|
||||||
hasMore?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const loadClaudeSessionMessages = getSessionMessages as unknown as (
|
|
||||||
projectName: string,
|
|
||||||
sessionId: string,
|
|
||||||
limit: number | null,
|
|
||||||
offset: number,
|
|
||||||
) => Promise<ClaudeHistoryResult>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Claude writes internal command and system reminder entries into history.
|
|
||||||
* Those are useful for the CLI but should not appear in the user-facing chat.
|
|
||||||
*/
|
|
||||||
const INTERNAL_CONTENT_PREFIXES = [
|
|
||||||
'<command-name>',
|
|
||||||
'<command-message>',
|
|
||||||
'<command-args>',
|
|
||||||
'<local-command-stdout>',
|
|
||||||
'<system-reminder>',
|
|
||||||
'Caveat:',
|
|
||||||
'This session is being continued from a previous',
|
|
||||||
'[Request interrupted',
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
function isInternalContent(content: string): boolean {
|
|
||||||
return INTERNAL_CONTENT_PREFIXES.some((prefix) => content.startsWith(prefix));
|
|
||||||
}
|
|
||||||
|
|
||||||
function readRawProviderMessage(raw: unknown): RawProviderMessage | null {
|
|
||||||
return readObjectRecord(raw) as RawProviderMessage | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ClaudeProvider extends AbstractProvider {
|
|
||||||
readonly mcp = new ClaudeMcpProvider();
|
|
||||||
readonly auth: IProviderAuth = new ClaudeProviderAuth();
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super('claude');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes one Claude JSONL entry or live SDK stream event into the shared
|
|
||||||
* message shape consumed by REST and WebSocket clients.
|
|
||||||
*/
|
|
||||||
normalizeMessage(rawMessage: unknown, sessionId: string | null): NormalizedMessage[] {
|
|
||||||
const raw = readRawProviderMessage(rawMessage);
|
|
||||||
if (!raw) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'content_block_delta' && raw.delta?.text) {
|
|
||||||
return [createNormalizedMessage({ kind: 'stream_delta', content: raw.delta.text, sessionId, provider: PROVIDER })];
|
|
||||||
}
|
|
||||||
if (raw.type === 'content_block_stop') {
|
|
||||||
return [createNormalizedMessage({ kind: 'stream_end', sessionId, provider: PROVIDER })];
|
|
||||||
}
|
|
||||||
|
|
||||||
const messages: NormalizedMessage[] = [];
|
|
||||||
const ts = raw.timestamp || new Date().toISOString();
|
|
||||||
const baseId = raw.uuid || generateMessageId('claude');
|
|
||||||
|
|
||||||
if (raw.message?.role === 'user' && raw.message?.content) {
|
|
||||||
if (Array.isArray(raw.message.content)) {
|
|
||||||
for (const part of raw.message.content) {
|
|
||||||
if (part.type === 'tool_result') {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_tr_${part.tool_use_id}`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_result',
|
|
||||||
toolId: part.tool_use_id,
|
|
||||||
content: typeof part.content === 'string' ? part.content : JSON.stringify(part.content),
|
|
||||||
isError: Boolean(part.is_error),
|
|
||||||
subagentTools: raw.subagentTools,
|
|
||||||
toolUseResult: raw.toolUseResult,
|
|
||||||
}));
|
|
||||||
} else if (part.type === 'text') {
|
|
||||||
const text = part.text || '';
|
|
||||||
if (text && !isInternalContent(text)) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_text`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role: 'user',
|
|
||||||
content: text,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messages.length === 0) {
|
|
||||||
const textParts = raw.message.content
|
|
||||||
.filter((part: RawProviderMessage) => part.type === 'text')
|
|
||||||
.map((part: RawProviderMessage) => part.text)
|
|
||||||
.filter(Boolean)
|
|
||||||
.join('\n');
|
|
||||||
if (textParts && !isInternalContent(textParts)) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_text`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role: 'user',
|
|
||||||
content: textParts,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (typeof raw.message.content === 'string') {
|
|
||||||
const text = raw.message.content;
|
|
||||||
if (text && !isInternalContent(text)) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role: 'user',
|
|
||||||
content: text,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'thinking' && raw.message?.content) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'thinking',
|
|
||||||
content: raw.message.content,
|
|
||||||
}));
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'tool_use' && raw.toolName) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName: raw.toolName,
|
|
||||||
toolInput: raw.toolInput,
|
|
||||||
toolId: raw.toolCallId || baseId,
|
|
||||||
}));
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'tool_result') {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_result',
|
|
||||||
toolId: raw.toolCallId || '',
|
|
||||||
content: raw.output || '',
|
|
||||||
isError: false,
|
|
||||||
}));
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.message?.role === 'assistant' && raw.message?.content) {
|
|
||||||
if (Array.isArray(raw.message.content)) {
|
|
||||||
let partIndex = 0;
|
|
||||||
for (const part of raw.message.content) {
|
|
||||||
if (part.type === 'text' && part.text) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_${partIndex}`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role: 'assistant',
|
|
||||||
content: part.text,
|
|
||||||
}));
|
|
||||||
} else if (part.type === 'tool_use') {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_${partIndex}`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName: part.name,
|
|
||||||
toolInput: part.input,
|
|
||||||
toolId: part.id,
|
|
||||||
}));
|
|
||||||
} else if (part.type === 'thinking' && part.thinking) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_${partIndex}`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'thinking',
|
|
||||||
content: part.thinking,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
partIndex++;
|
|
||||||
}
|
|
||||||
} else if (typeof raw.message.content === 'string') {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role: 'assistant',
|
|
||||||
content: raw.message.content,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads Claude JSONL history for a project/session and returns normalized
|
|
||||||
* messages, preserving the existing pagination behavior from projects.js.
|
|
||||||
*/
|
|
||||||
async fetchHistory(
|
|
||||||
sessionId: string,
|
|
||||||
options: FetchHistoryOptions = {},
|
|
||||||
): Promise<FetchHistoryResult> {
|
|
||||||
const { projectName, limit = null, offset = 0 } = options;
|
|
||||||
if (!projectName) {
|
|
||||||
return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
|
|
||||||
}
|
|
||||||
|
|
||||||
let result: ClaudeHistoryResult;
|
|
||||||
try {
|
|
||||||
result = await loadClaudeSessionMessages(projectName, sessionId, limit, offset);
|
|
||||||
} catch (error) {
|
|
||||||
const message = error instanceof Error ? error.message : String(error);
|
|
||||||
console.warn(`[ClaudeProvider] Failed to load session ${sessionId}:`, message);
|
|
||||||
return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
|
|
||||||
}
|
|
||||||
|
|
||||||
const rawMessages = Array.isArray(result) ? result : (result.messages || []);
|
|
||||||
const total = Array.isArray(result) ? rawMessages.length : (result.total || 0);
|
|
||||||
const hasMore = Array.isArray(result) ? false : Boolean(result.hasMore);
|
|
||||||
|
|
||||||
const toolResultMap = new Map<string, ClaudeToolResult>();
|
|
||||||
for (const raw of rawMessages) {
|
|
||||||
if (raw.message?.role === 'user' && Array.isArray(raw.message?.content)) {
|
|
||||||
for (const part of raw.message.content) {
|
|
||||||
if (part.type === 'tool_result' && part.tool_use_id) {
|
|
||||||
toolResultMap.set(part.tool_use_id, {
|
|
||||||
content: part.content,
|
|
||||||
isError: Boolean(part.is_error),
|
|
||||||
subagentTools: raw.subagentTools,
|
|
||||||
toolUseResult: raw.toolUseResult,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalized: NormalizedMessage[] = [];
|
|
||||||
for (const raw of rawMessages) {
|
|
||||||
normalized.push(...this.normalizeMessage(raw, sessionId));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const msg of normalized) {
|
|
||||||
if (msg.kind === 'tool_use' && msg.toolId && toolResultMap.has(msg.toolId)) {
|
|
||||||
const toolResult = toolResultMap.get(msg.toolId);
|
|
||||||
if (!toolResult) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg.toolResult = {
|
|
||||||
content: typeof toolResult.content === 'string'
|
|
||||||
? toolResult.content
|
|
||||||
: JSON.stringify(toolResult.content),
|
|
||||||
isError: toolResult.isError,
|
|
||||||
toolUseResult: toolResult.toolUseResult,
|
|
||||||
};
|
|
||||||
msg.subagentTools = toolResult.subagentTools;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
messages: normalized,
|
|
||||||
total,
|
|
||||||
hasMore,
|
|
||||||
offset,
|
|
||||||
limit,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
import { readFile } from 'node:fs/promises';
|
|
||||||
import os from 'node:os';
|
|
||||||
import path from 'node:path';
|
|
||||||
|
|
||||||
import spawn from 'cross-spawn';
|
|
||||||
|
|
||||||
import type { IProviderAuth } from '@/shared/interfaces.js';
|
|
||||||
import type { ProviderAuthStatus } from '@/shared/types.js';
|
|
||||||
import { readObjectRecord, readOptionalString } from '@/shared/utils.js';
|
|
||||||
|
|
||||||
type CodexCredentialsStatus = {
|
|
||||||
authenticated: boolean;
|
|
||||||
email: string | null;
|
|
||||||
method: string | null;
|
|
||||||
error?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class CodexProviderAuth implements IProviderAuth {
|
|
||||||
/**
|
|
||||||
* Checks whether Codex is available to the server runtime.
|
|
||||||
*/
|
|
||||||
private checkInstalled(): boolean {
|
|
||||||
try {
|
|
||||||
spawn.sync('codex', ['--version'], { stdio: 'ignore', timeout: 5000 });
|
|
||||||
return true;
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns Codex SDK availability and credential status.
|
|
||||||
*/
|
|
||||||
async getStatus(): Promise<ProviderAuthStatus> {
|
|
||||||
const installed = this.checkInstalled();
|
|
||||||
const credentials = await this.checkCredentials();
|
|
||||||
|
|
||||||
return {
|
|
||||||
installed,
|
|
||||||
provider: 'codex',
|
|
||||||
authenticated: credentials.authenticated,
|
|
||||||
email: credentials.email,
|
|
||||||
method: credentials.method,
|
|
||||||
error: credentials.authenticated ? undefined : credentials.error || 'Not authenticated',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads Codex auth.json and checks OAuth tokens or an API key fallback.
|
|
||||||
*/
|
|
||||||
private async checkCredentials(): Promise<CodexCredentialsStatus> {
|
|
||||||
try {
|
|
||||||
const authPath = path.join(os.homedir(), '.codex', 'auth.json');
|
|
||||||
const content = await readFile(authPath, 'utf8');
|
|
||||||
const auth = readObjectRecord(JSON.parse(content)) ?? {};
|
|
||||||
const tokens = readObjectRecord(auth.tokens) ?? {};
|
|
||||||
const idToken = readOptionalString(tokens.id_token);
|
|
||||||
const accessToken = readOptionalString(tokens.access_token);
|
|
||||||
|
|
||||||
if (idToken || accessToken) {
|
|
||||||
return {
|
|
||||||
authenticated: true,
|
|
||||||
email: idToken ? this.readEmailFromIdToken(idToken) : 'Authenticated',
|
|
||||||
method: 'credentials_file',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (readOptionalString(auth.OPENAI_API_KEY)) {
|
|
||||||
return { authenticated: true, email: 'API Key Auth', method: 'api_key' };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { authenticated: false, email: null, method: null, error: 'No valid tokens found' };
|
|
||||||
} catch (error) {
|
|
||||||
const code = (error as NodeJS.ErrnoException).code;
|
|
||||||
return {
|
|
||||||
authenticated: false,
|
|
||||||
email: null,
|
|
||||||
method: null,
|
|
||||||
error: code === 'ENOENT' ? 'Codex not configured' : error instanceof Error ? error.message : 'Failed to read Codex auth',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extracts the user email from a Codex id_token when a readable JWT payload exists.
|
|
||||||
*/
|
|
||||||
private readEmailFromIdToken(idToken: string): string {
|
|
||||||
try {
|
|
||||||
const parts = idToken.split('.');
|
|
||||||
if (parts.length >= 2) {
|
|
||||||
const payload = readObjectRecord(JSON.parse(Buffer.from(parts[1], 'base64url').toString('utf8')));
|
|
||||||
return readOptionalString(payload?.email) ?? readOptionalString(payload?.user) ?? 'Authenticated';
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// Fall back to a generic authenticated marker if the token payload is not readable.
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'Authenticated';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,335 +0,0 @@
|
|||||||
import { getCodexSessionMessages } from '@/projects.js';
|
|
||||||
import { AbstractProvider } from '@/modules/providers/shared/base/abstract.provider.js';
|
|
||||||
import { CodexProviderAuth } from '@/modules/providers/list/codex/codex-auth.provider.js';
|
|
||||||
import { CodexMcpProvider } from '@/modules/providers/list/codex/codex-mcp.provider.js';
|
|
||||||
import type { IProviderAuth } from '@/shared/interfaces.js';
|
|
||||||
import type { FetchHistoryOptions, FetchHistoryResult, NormalizedMessage } from '@/shared/types.js';
|
|
||||||
import { createNormalizedMessage, generateMessageId, readObjectRecord } from '@/shared/utils.js';
|
|
||||||
|
|
||||||
const PROVIDER = 'codex';
|
|
||||||
|
|
||||||
type RawProviderMessage = Record<string, any>;
|
|
||||||
|
|
||||||
type CodexHistoryResult =
|
|
||||||
| RawProviderMessage[]
|
|
||||||
| {
|
|
||||||
messages?: RawProviderMessage[];
|
|
||||||
total?: number;
|
|
||||||
hasMore?: boolean;
|
|
||||||
tokenUsage?: unknown;
|
|
||||||
};
|
|
||||||
|
|
||||||
const loadCodexSessionMessages = getCodexSessionMessages as unknown as (
|
|
||||||
sessionId: string,
|
|
||||||
limit: number | null,
|
|
||||||
offset: number,
|
|
||||||
) => Promise<CodexHistoryResult>;
|
|
||||||
|
|
||||||
function readRawProviderMessage(raw: unknown): RawProviderMessage | null {
|
|
||||||
return readObjectRecord(raw) as RawProviderMessage | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CodexProvider extends AbstractProvider {
|
|
||||||
readonly mcp = new CodexMcpProvider();
|
|
||||||
readonly auth: IProviderAuth = new CodexProviderAuth();
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super('codex');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes a persisted Codex JSONL entry.
|
|
||||||
*
|
|
||||||
* Live Codex SDK events are transformed before they reach normalizeMessage(),
|
|
||||||
* while history entries already use a compact message/tool shape from projects.js.
|
|
||||||
*/
|
|
||||||
private normalizeHistoryEntry(raw: RawProviderMessage, sessionId: string | null): NormalizedMessage[] {
|
|
||||||
const ts = raw.timestamp || new Date().toISOString();
|
|
||||||
const baseId = raw.uuid || generateMessageId('codex');
|
|
||||||
|
|
||||||
if (raw.message?.role === 'user') {
|
|
||||||
const content = typeof raw.message.content === 'string'
|
|
||||||
? raw.message.content
|
|
||||||
: Array.isArray(raw.message.content)
|
|
||||||
? raw.message.content
|
|
||||||
.map((part: string | RawProviderMessage) => typeof part === 'string' ? part : part?.text || '')
|
|
||||||
.filter(Boolean)
|
|
||||||
.join('\n')
|
|
||||||
: String(raw.message.content || '');
|
|
||||||
if (!content.trim()) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role: 'user',
|
|
||||||
content,
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.message?.role === 'assistant') {
|
|
||||||
const content = typeof raw.message.content === 'string'
|
|
||||||
? raw.message.content
|
|
||||||
: Array.isArray(raw.message.content)
|
|
||||||
? raw.message.content
|
|
||||||
.map((part: string | RawProviderMessage) => typeof part === 'string' ? part : part?.text || '')
|
|
||||||
.filter(Boolean)
|
|
||||||
.join('\n')
|
|
||||||
: '';
|
|
||||||
if (!content.trim()) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role: 'assistant',
|
|
||||||
content,
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'thinking' || raw.isReasoning) {
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'thinking',
|
|
||||||
content: raw.message?.content || '',
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'tool_use' || raw.toolName) {
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName: raw.toolName || 'Unknown',
|
|
||||||
toolInput: raw.toolInput,
|
|
||||||
toolId: raw.toolCallId || baseId,
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'tool_result') {
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_result',
|
|
||||||
toolId: raw.toolCallId || '',
|
|
||||||
content: raw.output || '',
|
|
||||||
isError: Boolean(raw.isError),
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes either a Codex history entry or a transformed live SDK event.
|
|
||||||
*/
|
|
||||||
normalizeMessage(rawMessage: unknown, sessionId: string | null): NormalizedMessage[] {
|
|
||||||
const raw = readRawProviderMessage(rawMessage);
|
|
||||||
if (!raw) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.message?.role) {
|
|
||||||
return this.normalizeHistoryEntry(raw, sessionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
const ts = raw.timestamp || new Date().toISOString();
|
|
||||||
const baseId = raw.uuid || generateMessageId('codex');
|
|
||||||
|
|
||||||
if (raw.type === 'item') {
|
|
||||||
switch (raw.itemType) {
|
|
||||||
case 'agent_message':
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role: 'assistant',
|
|
||||||
content: raw.message?.content || '',
|
|
||||||
})];
|
|
||||||
case 'reasoning':
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'thinking',
|
|
||||||
content: raw.message?.content || '',
|
|
||||||
})];
|
|
||||||
case 'command_execution':
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName: 'Bash',
|
|
||||||
toolInput: { command: raw.command },
|
|
||||||
toolId: baseId,
|
|
||||||
output: raw.output,
|
|
||||||
exitCode: raw.exitCode,
|
|
||||||
status: raw.status,
|
|
||||||
})];
|
|
||||||
case 'file_change':
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName: 'FileChanges',
|
|
||||||
toolInput: raw.changes,
|
|
||||||
toolId: baseId,
|
|
||||||
status: raw.status,
|
|
||||||
})];
|
|
||||||
case 'mcp_tool_call':
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName: raw.tool || 'MCP',
|
|
||||||
toolInput: raw.arguments,
|
|
||||||
toolId: baseId,
|
|
||||||
server: raw.server,
|
|
||||||
result: raw.result,
|
|
||||||
error: raw.error,
|
|
||||||
status: raw.status,
|
|
||||||
})];
|
|
||||||
case 'web_search':
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName: 'WebSearch',
|
|
||||||
toolInput: { query: raw.query },
|
|
||||||
toolId: baseId,
|
|
||||||
})];
|
|
||||||
case 'todo_list':
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName: 'TodoList',
|
|
||||||
toolInput: { items: raw.items },
|
|
||||||
toolId: baseId,
|
|
||||||
})];
|
|
||||||
case 'error':
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'error',
|
|
||||||
content: raw.message?.content || 'Unknown error',
|
|
||||||
})];
|
|
||||||
default:
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName: raw.itemType || 'Unknown',
|
|
||||||
toolInput: raw.item || raw,
|
|
||||||
toolId: baseId,
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'turn_complete') {
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'complete',
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
if (raw.type === 'turn_failed') {
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'error',
|
|
||||||
content: raw.error?.message || 'Turn failed',
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads Codex JSONL history and keeps token usage metadata when projects.js
|
|
||||||
* provides it.
|
|
||||||
*/
|
|
||||||
async fetchHistory(
|
|
||||||
sessionId: string,
|
|
||||||
options: FetchHistoryOptions = {},
|
|
||||||
): Promise<FetchHistoryResult> {
|
|
||||||
const { limit = null, offset = 0 } = options;
|
|
||||||
|
|
||||||
let result: CodexHistoryResult;
|
|
||||||
try {
|
|
||||||
result = await loadCodexSessionMessages(sessionId, limit, offset);
|
|
||||||
} catch (error) {
|
|
||||||
const message = error instanceof Error ? error.message : String(error);
|
|
||||||
console.warn(`[CodexProvider] Failed to load session ${sessionId}:`, message);
|
|
||||||
return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
|
|
||||||
}
|
|
||||||
|
|
||||||
const rawMessages = Array.isArray(result) ? result : (result.messages || []);
|
|
||||||
const total = Array.isArray(result) ? rawMessages.length : (result.total || 0);
|
|
||||||
const hasMore = Array.isArray(result) ? false : Boolean(result.hasMore);
|
|
||||||
const tokenUsage = Array.isArray(result) ? undefined : result.tokenUsage;
|
|
||||||
|
|
||||||
const normalized: NormalizedMessage[] = [];
|
|
||||||
for (const raw of rawMessages) {
|
|
||||||
normalized.push(...this.normalizeHistoryEntry(raw, sessionId));
|
|
||||||
}
|
|
||||||
|
|
||||||
const toolResultMap = new Map<string, NormalizedMessage>();
|
|
||||||
for (const msg of normalized) {
|
|
||||||
if (msg.kind === 'tool_result' && msg.toolId) {
|
|
||||||
toolResultMap.set(msg.toolId, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const msg of normalized) {
|
|
||||||
if (msg.kind === 'tool_use' && msg.toolId && toolResultMap.has(msg.toolId)) {
|
|
||||||
const toolResult = toolResultMap.get(msg.toolId);
|
|
||||||
if (toolResult) {
|
|
||||||
msg.toolResult = { content: toolResult.content, isError: toolResult.isError };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
messages: normalized,
|
|
||||||
total,
|
|
||||||
hasMore,
|
|
||||||
offset,
|
|
||||||
limit,
|
|
||||||
tokenUsage,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
import spawn from 'cross-spawn';
|
|
||||||
|
|
||||||
import type { IProviderAuth } from '@/shared/interfaces.js';
|
|
||||||
import type { ProviderAuthStatus } from '@/shared/types.js';
|
|
||||||
|
|
||||||
type CursorLoginStatus = {
|
|
||||||
authenticated: boolean;
|
|
||||||
email: string | null;
|
|
||||||
method: string | null;
|
|
||||||
error?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class CursorProviderAuth implements IProviderAuth {
|
|
||||||
/**
|
|
||||||
* Checks whether the cursor-agent CLI is available on this host.
|
|
||||||
*/
|
|
||||||
private checkInstalled(): boolean {
|
|
||||||
try {
|
|
||||||
spawn.sync('cursor-agent', ['--version'], { stdio: 'ignore', timeout: 5000 });
|
|
||||||
return true;
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns Cursor CLI installation and login status.
|
|
||||||
*/
|
|
||||||
async getStatus(): Promise<ProviderAuthStatus> {
|
|
||||||
const installed = this.checkInstalled();
|
|
||||||
|
|
||||||
if (!installed) {
|
|
||||||
return {
|
|
||||||
installed,
|
|
||||||
provider: 'cursor',
|
|
||||||
authenticated: false,
|
|
||||||
email: null,
|
|
||||||
method: null,
|
|
||||||
error: 'Cursor CLI is not installed',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const login = await this.checkCursorLogin();
|
|
||||||
|
|
||||||
return {
|
|
||||||
installed,
|
|
||||||
provider: 'cursor',
|
|
||||||
authenticated: login.authenticated,
|
|
||||||
email: login.email,
|
|
||||||
method: login.method,
|
|
||||||
error: login.authenticated ? undefined : login.error || 'Not logged in',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs cursor-agent status and parses the login marker from stdout.
|
|
||||||
*/
|
|
||||||
private checkCursorLogin(): Promise<CursorLoginStatus> {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
let processCompleted = false;
|
|
||||||
let childProcess: ReturnType<typeof spawn> | undefined;
|
|
||||||
|
|
||||||
const timeout = setTimeout(() => {
|
|
||||||
if (!processCompleted) {
|
|
||||||
processCompleted = true;
|
|
||||||
childProcess?.kill();
|
|
||||||
resolve({
|
|
||||||
authenticated: false,
|
|
||||||
email: null,
|
|
||||||
method: null,
|
|
||||||
error: 'Command timeout',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, 5000);
|
|
||||||
|
|
||||||
try {
|
|
||||||
childProcess = spawn('cursor-agent', ['status']);
|
|
||||||
} catch {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
processCompleted = true;
|
|
||||||
resolve({
|
|
||||||
authenticated: false,
|
|
||||||
email: null,
|
|
||||||
method: null,
|
|
||||||
error: 'Cursor CLI not found or not installed',
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let stdout = '';
|
|
||||||
let stderr = '';
|
|
||||||
|
|
||||||
childProcess.stdout?.on('data', (data: Buffer) => {
|
|
||||||
stdout += data.toString();
|
|
||||||
});
|
|
||||||
|
|
||||||
childProcess.stderr?.on('data', (data: Buffer) => {
|
|
||||||
stderr += data.toString();
|
|
||||||
});
|
|
||||||
|
|
||||||
childProcess.on('close', (code) => {
|
|
||||||
if (processCompleted) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
processCompleted = true;
|
|
||||||
clearTimeout(timeout);
|
|
||||||
|
|
||||||
if (code === 0) {
|
|
||||||
const emailMatch = stdout.match(/Logged in as ([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/i);
|
|
||||||
if (emailMatch?.[1]) {
|
|
||||||
resolve({ authenticated: true, email: emailMatch[1], method: 'cli' });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stdout.includes('Logged in')) {
|
|
||||||
resolve({ authenticated: true, email: 'Logged in', method: 'cli' });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve({ authenticated: false, email: null, method: null, error: 'Not logged in' });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve({ authenticated: false, email: null, method: null, error: stderr || 'Not logged in' });
|
|
||||||
});
|
|
||||||
|
|
||||||
childProcess.on('error', () => {
|
|
||||||
if (processCompleted) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
processCompleted = true;
|
|
||||||
clearTimeout(timeout);
|
|
||||||
|
|
||||||
resolve({
|
|
||||||
authenticated: false,
|
|
||||||
email: null,
|
|
||||||
method: null,
|
|
||||||
error: 'Cursor CLI not found or not installed',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,403 +0,0 @@
|
|||||||
import crypto from 'node:crypto';
|
|
||||||
import os from 'node:os';
|
|
||||||
import path from 'node:path';
|
|
||||||
|
|
||||||
import { AbstractProvider } from '@/modules/providers/shared/base/abstract.provider.js';
|
|
||||||
import { CursorProviderAuth } from '@/modules/providers/list/cursor/cursor-auth.provider.js';
|
|
||||||
import { CursorMcpProvider } from '@/modules/providers/list/cursor/cursor-mcp.provider.js';
|
|
||||||
import type { IProviderAuth } from '@/shared/interfaces.js';
|
|
||||||
import type { FetchHistoryOptions, FetchHistoryResult, NormalizedMessage } from '@/shared/types.js';
|
|
||||||
import { createNormalizedMessage, generateMessageId, readObjectRecord } from '@/shared/utils.js';
|
|
||||||
|
|
||||||
const PROVIDER = 'cursor';
|
|
||||||
|
|
||||||
type RawProviderMessage = Record<string, any>;
|
|
||||||
|
|
||||||
type CursorDbBlob = {
|
|
||||||
rowid: number;
|
|
||||||
id: string;
|
|
||||||
data?: Buffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
type CursorJsonBlob = CursorDbBlob & {
|
|
||||||
parsed: RawProviderMessage;
|
|
||||||
};
|
|
||||||
|
|
||||||
type CursorMessageBlob = {
|
|
||||||
id: string;
|
|
||||||
sequence: number;
|
|
||||||
rowid: number;
|
|
||||||
content: RawProviderMessage;
|
|
||||||
};
|
|
||||||
|
|
||||||
function readRawProviderMessage(raw: unknown): RawProviderMessage | null {
|
|
||||||
return readObjectRecord(raw) as RawProviderMessage | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CursorProvider extends AbstractProvider {
|
|
||||||
readonly mcp = new CursorMcpProvider();
|
|
||||||
readonly auth: IProviderAuth = new CursorProviderAuth();
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super('cursor');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads Cursor's SQLite blob DAG and returns message blobs in conversation
|
|
||||||
* order. Cursor history is stored as content-addressed blobs rather than JSONL.
|
|
||||||
*/
|
|
||||||
private async loadCursorBlobs(sessionId: string, projectPath: string): Promise<CursorMessageBlob[]> {
|
|
||||||
const sqlite3Module = await import('sqlite3');
|
|
||||||
const sqlite3 = sqlite3Module.default;
|
|
||||||
const { open } = await import('sqlite');
|
|
||||||
|
|
||||||
const cwdId = crypto.createHash('md5').update(projectPath || process.cwd()).digest('hex');
|
|
||||||
const storeDbPath = path.join(os.homedir(), '.cursor', 'chats', cwdId, sessionId, 'store.db');
|
|
||||||
|
|
||||||
const db = await open({
|
|
||||||
filename: storeDbPath,
|
|
||||||
driver: sqlite3.Database,
|
|
||||||
mode: sqlite3.OPEN_READONLY,
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const allBlobs = await db.all('SELECT rowid, id, data FROM blobs') as CursorDbBlob[];
|
|
||||||
|
|
||||||
const blobMap = new Map<string, CursorDbBlob>();
|
|
||||||
const parentRefs = new Map<string, string[]>();
|
|
||||||
const childRefs = new Map<string, string[]>();
|
|
||||||
const jsonBlobs: CursorJsonBlob[] = [];
|
|
||||||
|
|
||||||
for (const blob of allBlobs) {
|
|
||||||
blobMap.set(blob.id, blob);
|
|
||||||
|
|
||||||
if (blob.data && blob.data[0] === 0x7B) {
|
|
||||||
try {
|
|
||||||
const parsed = JSON.parse(blob.data.toString('utf8')) as RawProviderMessage;
|
|
||||||
jsonBlobs.push({ ...blob, parsed });
|
|
||||||
} catch {
|
|
||||||
// Cursor can include binary or partial blobs; only JSON blobs become messages.
|
|
||||||
}
|
|
||||||
} else if (blob.data) {
|
|
||||||
const parents: string[] = [];
|
|
||||||
let i = 0;
|
|
||||||
while (i < blob.data.length - 33) {
|
|
||||||
if (blob.data[i] === 0x0A && blob.data[i + 1] === 0x20) {
|
|
||||||
const parentHash = blob.data.slice(i + 2, i + 34).toString('hex');
|
|
||||||
if (blobMap.has(parentHash)) {
|
|
||||||
parents.push(parentHash);
|
|
||||||
}
|
|
||||||
i += 34;
|
|
||||||
} else {
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (parents.length > 0) {
|
|
||||||
parentRefs.set(blob.id, parents);
|
|
||||||
for (const parentId of parents) {
|
|
||||||
if (!childRefs.has(parentId)) {
|
|
||||||
childRefs.set(parentId, []);
|
|
||||||
}
|
|
||||||
childRefs.get(parentId)?.push(blob.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const visited = new Set<string>();
|
|
||||||
const sorted: CursorDbBlob[] = [];
|
|
||||||
const visit = (nodeId: string): void => {
|
|
||||||
if (visited.has(nodeId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
visited.add(nodeId);
|
|
||||||
for (const parentId of parentRefs.get(nodeId) || []) {
|
|
||||||
visit(parentId);
|
|
||||||
}
|
|
||||||
const blob = blobMap.get(nodeId);
|
|
||||||
if (blob) {
|
|
||||||
sorted.push(blob);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const blob of allBlobs) {
|
|
||||||
if (!parentRefs.has(blob.id)) {
|
|
||||||
visit(blob.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const blob of allBlobs) {
|
|
||||||
visit(blob.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const messageOrder = new Map<string, number>();
|
|
||||||
let orderIndex = 0;
|
|
||||||
for (const blob of sorted) {
|
|
||||||
if (blob.data && blob.data[0] !== 0x7B) {
|
|
||||||
for (const jsonBlob of jsonBlobs) {
|
|
||||||
try {
|
|
||||||
const idBytes = Buffer.from(jsonBlob.id, 'hex');
|
|
||||||
if (blob.data.includes(idBytes) && !messageOrder.has(jsonBlob.id)) {
|
|
||||||
messageOrder.set(jsonBlob.id, orderIndex++);
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// Ignore malformed blob ids that cannot be decoded as hex.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const sortedJsonBlobs = jsonBlobs.sort((a, b) => {
|
|
||||||
const aOrder = messageOrder.get(a.id) ?? Number.MAX_SAFE_INTEGER;
|
|
||||||
const bOrder = messageOrder.get(b.id) ?? Number.MAX_SAFE_INTEGER;
|
|
||||||
return aOrder !== bOrder ? aOrder - bOrder : a.rowid - b.rowid;
|
|
||||||
});
|
|
||||||
|
|
||||||
const messages: CursorMessageBlob[] = [];
|
|
||||||
for (let idx = 0; idx < sortedJsonBlobs.length; idx++) {
|
|
||||||
const blob = sortedJsonBlobs[idx];
|
|
||||||
const parsed = blob.parsed;
|
|
||||||
const role = parsed?.role || parsed?.message?.role;
|
|
||||||
if (role === 'system') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
messages.push({
|
|
||||||
id: blob.id,
|
|
||||||
sequence: idx + 1,
|
|
||||||
rowid: blob.rowid,
|
|
||||||
content: parsed,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return messages;
|
|
||||||
} finally {
|
|
||||||
await db.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes live Cursor CLI NDJSON events. Persisted Cursor history is
|
|
||||||
* normalized from SQLite blobs in fetchHistory().
|
|
||||||
*/
|
|
||||||
normalizeMessage(rawMessage: unknown, sessionId: string | null): NormalizedMessage[] {
|
|
||||||
const raw = readRawProviderMessage(rawMessage);
|
|
||||||
if (raw?.type === 'assistant' && raw.message?.content?.[0]?.text) {
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
kind: 'stream_delta',
|
|
||||||
content: raw.message.content[0].text,
|
|
||||||
sessionId,
|
|
||||||
provider: PROVIDER,
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof rawMessage === 'string' && rawMessage.trim()) {
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
kind: 'stream_delta',
|
|
||||||
content: rawMessage,
|
|
||||||
sessionId,
|
|
||||||
provider: PROVIDER,
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and paginates Cursor session history from its project-scoped store.db.
|
|
||||||
*/
|
|
||||||
async fetchHistory(
|
|
||||||
sessionId: string,
|
|
||||||
options: FetchHistoryOptions = {},
|
|
||||||
): Promise<FetchHistoryResult> {
|
|
||||||
const { projectPath = '', limit = null, offset = 0 } = options;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const blobs = await this.loadCursorBlobs(sessionId, projectPath);
|
|
||||||
const allNormalized = this.normalizeCursorBlobs(blobs, sessionId);
|
|
||||||
|
|
||||||
if (limit !== null && limit > 0) {
|
|
||||||
const start = offset;
|
|
||||||
const page = allNormalized.slice(start, start + limit);
|
|
||||||
return {
|
|
||||||
messages: page,
|
|
||||||
total: allNormalized.length,
|
|
||||||
hasMore: start + limit < allNormalized.length,
|
|
||||||
offset,
|
|
||||||
limit,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
messages: allNormalized,
|
|
||||||
total: allNormalized.length,
|
|
||||||
hasMore: false,
|
|
||||||
offset: 0,
|
|
||||||
limit: null,
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
const message = error instanceof Error ? error.message : String(error);
|
|
||||||
console.warn(`[CursorProvider] Failed to load session ${sessionId}:`, message);
|
|
||||||
return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts Cursor SQLite message blobs into normalized messages and attaches
|
|
||||||
* matching tool results to their tool_use entries.
|
|
||||||
*/
|
|
||||||
private normalizeCursorBlobs(blobs: CursorMessageBlob[], sessionId: string | null): NormalizedMessage[] {
|
|
||||||
const messages: NormalizedMessage[] = [];
|
|
||||||
const toolUseMap = new Map<string, NormalizedMessage>();
|
|
||||||
const baseTime = Date.now();
|
|
||||||
|
|
||||||
for (let i = 0; i < blobs.length; i++) {
|
|
||||||
const blob = blobs[i];
|
|
||||||
const content = blob.content;
|
|
||||||
const ts = new Date(baseTime + (blob.sequence ?? i) * 100).toISOString();
|
|
||||||
const baseId = blob.id || generateMessageId('cursor');
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (!content?.role || !content?.content) {
|
|
||||||
if (content?.message?.role && content?.message?.content) {
|
|
||||||
if (content.message.role === 'system') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const role = content.message.role === 'user' ? 'user' : 'assistant';
|
|
||||||
let text = '';
|
|
||||||
if (Array.isArray(content.message.content)) {
|
|
||||||
text = content.message.content
|
|
||||||
.map((part: string | RawProviderMessage) => typeof part === 'string' ? part : part?.text || '')
|
|
||||||
.filter(Boolean)
|
|
||||||
.join('\n');
|
|
||||||
} else if (typeof content.message.content === 'string') {
|
|
||||||
text = content.message.content;
|
|
||||||
}
|
|
||||||
if (text?.trim()) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role,
|
|
||||||
content: text,
|
|
||||||
sequence: blob.sequence,
|
|
||||||
rowid: blob.rowid,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content.role === 'system') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content.role === 'tool') {
|
|
||||||
const toolItems = Array.isArray(content.content) ? content.content : [];
|
|
||||||
for (const item of toolItems) {
|
|
||||||
if (item?.type !== 'tool-result') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const toolCallId = item.toolCallId || content.id;
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_tr`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_result',
|
|
||||||
toolId: toolCallId,
|
|
||||||
content: item.result || '',
|
|
||||||
isError: false,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const role = content.role === 'user' ? 'user' : 'assistant';
|
|
||||||
|
|
||||||
if (Array.isArray(content.content)) {
|
|
||||||
for (let partIdx = 0; partIdx < content.content.length; partIdx++) {
|
|
||||||
const part = content.content[partIdx];
|
|
||||||
|
|
||||||
if (part?.type === 'text' && part?.text) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_${partIdx}`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role,
|
|
||||||
content: part.text,
|
|
||||||
sequence: blob.sequence,
|
|
||||||
rowid: blob.rowid,
|
|
||||||
}));
|
|
||||||
} else if (part?.type === 'reasoning' && part?.text) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_${partIdx}`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'thinking',
|
|
||||||
content: part.text,
|
|
||||||
}));
|
|
||||||
} else if (part?.type === 'tool-call' || part?.type === 'tool_use') {
|
|
||||||
const rawToolName = part.toolName || part.name || 'Unknown Tool';
|
|
||||||
const toolName = rawToolName === 'ApplyPatch' ? 'Edit' : rawToolName;
|
|
||||||
const toolId = part.toolCallId || part.id || `tool_${i}_${partIdx}`;
|
|
||||||
const message = createNormalizedMessage({
|
|
||||||
id: `${baseId}_${partIdx}`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName,
|
|
||||||
toolInput: part.args || part.input,
|
|
||||||
toolId,
|
|
||||||
});
|
|
||||||
messages.push(message);
|
|
||||||
toolUseMap.set(toolId, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (typeof content.content === 'string' && content.content.trim()) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role,
|
|
||||||
content: content.content,
|
|
||||||
sequence: blob.sequence,
|
|
||||||
rowid: blob.rowid,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('Error normalizing cursor blob:', error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const msg of messages) {
|
|
||||||
if (msg.kind === 'tool_result' && msg.toolId && toolUseMap.has(msg.toolId)) {
|
|
||||||
const toolUse = toolUseMap.get(msg.toolId);
|
|
||||||
if (toolUse) {
|
|
||||||
toolUse.toolResult = {
|
|
||||||
content: msg.content,
|
|
||||||
isError: msg.isError,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
messages.sort((a, b) => {
|
|
||||||
if (a.sequence !== undefined && b.sequence !== undefined) {
|
|
||||||
return a.sequence - b.sequence;
|
|
||||||
}
|
|
||||||
if (a.rowid !== undefined && b.rowid !== undefined) {
|
|
||||||
return a.rowid - b.rowid;
|
|
||||||
}
|
|
||||||
return new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime();
|
|
||||||
});
|
|
||||||
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
import { readFile } from 'node:fs/promises';
|
|
||||||
import os from 'node:os';
|
|
||||||
import path from 'node:path';
|
|
||||||
|
|
||||||
import spawn from 'cross-spawn';
|
|
||||||
|
|
||||||
import type { IProviderAuth } from '@/shared/interfaces.js';
|
|
||||||
import type { ProviderAuthStatus } from '@/shared/types.js';
|
|
||||||
import { readObjectRecord, readOptionalString } from '@/shared/utils.js';
|
|
||||||
|
|
||||||
type GeminiCredentialsStatus = {
|
|
||||||
authenticated: boolean;
|
|
||||||
email: string | null;
|
|
||||||
method: string | null;
|
|
||||||
error?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class GeminiProviderAuth implements IProviderAuth {
|
|
||||||
/**
|
|
||||||
* Checks whether the Gemini CLI is available on this host.
|
|
||||||
*/
|
|
||||||
private checkInstalled(): boolean {
|
|
||||||
const cliPath = process.env.GEMINI_PATH || 'gemini';
|
|
||||||
try {
|
|
||||||
spawn.sync(cliPath, ['--version'], { stdio: 'ignore', timeout: 5000 });
|
|
||||||
return true;
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns Gemini CLI installation and credential status.
|
|
||||||
*/
|
|
||||||
async getStatus(): Promise<ProviderAuthStatus> {
|
|
||||||
const installed = this.checkInstalled();
|
|
||||||
|
|
||||||
if (!installed) {
|
|
||||||
return {
|
|
||||||
installed,
|
|
||||||
provider: 'gemini',
|
|
||||||
authenticated: false,
|
|
||||||
email: null,
|
|
||||||
method: null,
|
|
||||||
error: 'Gemini CLI is not installed',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const credentials = await this.checkCredentials();
|
|
||||||
|
|
||||||
return {
|
|
||||||
installed,
|
|
||||||
provider: 'gemini',
|
|
||||||
authenticated: credentials.authenticated,
|
|
||||||
email: credentials.email,
|
|
||||||
method: credentials.method,
|
|
||||||
error: credentials.authenticated ? undefined : credentials.error || 'Not authenticated',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks Gemini credentials from API key env vars or local OAuth credential files.
|
|
||||||
*/
|
|
||||||
private async checkCredentials(): Promise<GeminiCredentialsStatus> {
|
|
||||||
if (process.env.GEMINI_API_KEY?.trim()) {
|
|
||||||
return { authenticated: true, email: 'API Key Auth', method: 'api_key' };
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const credsPath = path.join(os.homedir(), '.gemini', 'oauth_creds.json');
|
|
||||||
const content = await readFile(credsPath, 'utf8');
|
|
||||||
const creds = readObjectRecord(JSON.parse(content)) ?? {};
|
|
||||||
const accessToken = readOptionalString(creds.access_token);
|
|
||||||
|
|
||||||
if (!accessToken) {
|
|
||||||
return {
|
|
||||||
authenticated: false,
|
|
||||||
email: null,
|
|
||||||
method: null,
|
|
||||||
error: 'No valid tokens found in oauth_creds',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const refreshToken = readOptionalString(creds.refresh_token);
|
|
||||||
const tokenInfo = await this.getTokenInfoEmail(accessToken);
|
|
||||||
if (tokenInfo.valid) {
|
|
||||||
return {
|
|
||||||
authenticated: true,
|
|
||||||
email: tokenInfo.email || 'OAuth Session',
|
|
||||||
method: 'credentials_file',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!refreshToken) {
|
|
||||||
return {
|
|
||||||
authenticated: false,
|
|
||||||
email: null,
|
|
||||||
method: 'credentials_file',
|
|
||||||
error: 'Access token invalid and no refresh token found',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
authenticated: true,
|
|
||||||
email: await this.getActiveAccountEmail() || 'OAuth Session',
|
|
||||||
method: 'credentials_file',
|
|
||||||
};
|
|
||||||
} catch {
|
|
||||||
return {
|
|
||||||
authenticated: false,
|
|
||||||
email: null,
|
|
||||||
method: null,
|
|
||||||
error: 'Gemini CLI not configured',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a Gemini OAuth access token and returns an email when Google reports one.
|
|
||||||
*/
|
|
||||||
private async getTokenInfoEmail(accessToken: string): Promise<{ valid: boolean; email: string | null }> {
|
|
||||||
try {
|
|
||||||
const tokenRes = await fetch(`https://oauth2.googleapis.com/tokeninfo?access_token=${accessToken}`);
|
|
||||||
if (!tokenRes.ok) {
|
|
||||||
return { valid: false, email: null };
|
|
||||||
}
|
|
||||||
|
|
||||||
const tokenInfo = readObjectRecord(await tokenRes.json());
|
|
||||||
return {
|
|
||||||
valid: true,
|
|
||||||
email: readOptionalString(tokenInfo?.email) ?? null,
|
|
||||||
};
|
|
||||||
} catch {
|
|
||||||
return { valid: false, email: null };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads Gemini's active local Google account as an offline fallback for display.
|
|
||||||
*/
|
|
||||||
private async getActiveAccountEmail(): Promise<string | null> {
|
|
||||||
try {
|
|
||||||
const accPath = path.join(os.homedir(), '.gemini', 'google_accounts.json');
|
|
||||||
const accContent = await readFile(accPath, 'utf8');
|
|
||||||
const accounts = readObjectRecord(JSON.parse(accContent));
|
|
||||||
return readOptionalString(accounts?.active) ?? null;
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
import sessionManager from '@/sessionManager.js';
|
|
||||||
import { getGeminiCliSessionMessages } from '@/projects.js';
|
|
||||||
import { AbstractProvider } from '@/modules/providers/shared/base/abstract.provider.js';
|
|
||||||
import { GeminiProviderAuth } from '@/modules/providers/list/gemini/gemini-auth.provider.js';
|
|
||||||
import { GeminiMcpProvider } from '@/modules/providers/list/gemini/gemini-mcp.provider.js';
|
|
||||||
import type { IProviderAuth } from '@/shared/interfaces.js';
|
|
||||||
import type { FetchHistoryOptions, FetchHistoryResult, NormalizedMessage } from '@/shared/types.js';
|
|
||||||
import { createNormalizedMessage, generateMessageId, readObjectRecord } from '@/shared/utils.js';
|
|
||||||
|
|
||||||
const PROVIDER = 'gemini';
|
|
||||||
|
|
||||||
type RawProviderMessage = Record<string, any>;
|
|
||||||
|
|
||||||
function readRawProviderMessage(raw: unknown): RawProviderMessage | null {
|
|
||||||
return readObjectRecord(raw) as RawProviderMessage | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class GeminiProvider extends AbstractProvider {
|
|
||||||
readonly mcp = new GeminiMcpProvider();
|
|
||||||
readonly auth: IProviderAuth = new GeminiProviderAuth();
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super('gemini');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes live Gemini stream-json events into the shared message shape.
|
|
||||||
*
|
|
||||||
* Gemini history uses a different session file shape, so fetchHistory handles
|
|
||||||
* that separately after loading raw persisted messages.
|
|
||||||
*/
|
|
||||||
normalizeMessage(rawMessage: unknown, sessionId: string | null): NormalizedMessage[] {
|
|
||||||
const raw = readRawProviderMessage(rawMessage);
|
|
||||||
if (!raw) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const ts = raw.timestamp || new Date().toISOString();
|
|
||||||
const baseId = raw.uuid || generateMessageId('gemini');
|
|
||||||
|
|
||||||
if (raw.type === 'message' && raw.role === 'assistant') {
|
|
||||||
const content = raw.content || '';
|
|
||||||
const messages: NormalizedMessage[] = [];
|
|
||||||
if (content) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'stream_delta',
|
|
||||||
content,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
if (raw.delta !== true) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'stream_end',
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'tool_use') {
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName: raw.tool_name,
|
|
||||||
toolInput: raw.parameters || {},
|
|
||||||
toolId: raw.tool_id || baseId,
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'tool_result') {
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_result',
|
|
||||||
toolId: raw.tool_id || '',
|
|
||||||
content: raw.output === undefined ? '' : String(raw.output),
|
|
||||||
isError: raw.status === 'error',
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'result') {
|
|
||||||
const messages = [createNormalizedMessage({
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'stream_end',
|
|
||||||
})];
|
|
||||||
if (raw.stats?.total_tokens) {
|
|
||||||
messages.push(createNormalizedMessage({
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'status',
|
|
||||||
text: 'Complete',
|
|
||||||
tokens: raw.stats.total_tokens,
|
|
||||||
canInterrupt: false,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (raw.type === 'error') {
|
|
||||||
return [createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'error',
|
|
||||||
content: raw.error || raw.message || 'Unknown Gemini streaming error',
|
|
||||||
})];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads Gemini history from the in-memory session manager first, then falls
|
|
||||||
* back to Gemini CLI session files on disk.
|
|
||||||
*/
|
|
||||||
async fetchHistory(
|
|
||||||
sessionId: string,
|
|
||||||
_options: FetchHistoryOptions = {},
|
|
||||||
): Promise<FetchHistoryResult> {
|
|
||||||
let rawMessages: RawProviderMessage[];
|
|
||||||
try {
|
|
||||||
rawMessages = sessionManager.getSessionMessages(sessionId) as RawProviderMessage[];
|
|
||||||
|
|
||||||
if (rawMessages.length === 0) {
|
|
||||||
rawMessages = await getGeminiCliSessionMessages(sessionId) as RawProviderMessage[];
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
const message = error instanceof Error ? error.message : String(error);
|
|
||||||
console.warn(`[GeminiProvider] Failed to load session ${sessionId}:`, message);
|
|
||||||
return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalized: NormalizedMessage[] = [];
|
|
||||||
for (let i = 0; i < rawMessages.length; i++) {
|
|
||||||
const raw = rawMessages[i];
|
|
||||||
const ts = raw.timestamp || new Date().toISOString();
|
|
||||||
const baseId = raw.uuid || generateMessageId('gemini');
|
|
||||||
|
|
||||||
const role = raw.message?.role || raw.role;
|
|
||||||
const content = raw.message?.content || raw.content;
|
|
||||||
|
|
||||||
if (!role || !content) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalizedRole = role === 'user' ? 'user' : 'assistant';
|
|
||||||
|
|
||||||
if (Array.isArray(content)) {
|
|
||||||
for (let partIdx = 0; partIdx < content.length; partIdx++) {
|
|
||||||
const part = content[partIdx];
|
|
||||||
if (part.type === 'text' && part.text) {
|
|
||||||
normalized.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_${partIdx}`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role: normalizedRole,
|
|
||||||
content: part.text,
|
|
||||||
}));
|
|
||||||
} else if (part.type === 'tool_use') {
|
|
||||||
normalized.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_${partIdx}`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_use',
|
|
||||||
toolName: part.name,
|
|
||||||
toolInput: part.input,
|
|
||||||
toolId: part.id || generateMessageId('gemini_tool'),
|
|
||||||
}));
|
|
||||||
} else if (part.type === 'tool_result') {
|
|
||||||
normalized.push(createNormalizedMessage({
|
|
||||||
id: `${baseId}_${partIdx}`,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'tool_result',
|
|
||||||
toolId: part.tool_use_id || '',
|
|
||||||
content: part.content === undefined ? '' : String(part.content),
|
|
||||||
isError: Boolean(part.is_error),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (typeof content === 'string' && content.trim()) {
|
|
||||||
normalized.push(createNormalizedMessage({
|
|
||||||
id: baseId,
|
|
||||||
sessionId,
|
|
||||||
timestamp: ts,
|
|
||||||
provider: PROVIDER,
|
|
||||||
kind: 'text',
|
|
||||||
role: normalizedRole,
|
|
||||||
content,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const toolResultMap = new Map<string, NormalizedMessage>();
|
|
||||||
for (const msg of normalized) {
|
|
||||||
if (msg.kind === 'tool_result' && msg.toolId) {
|
|
||||||
toolResultMap.set(msg.toolId, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const msg of normalized) {
|
|
||||||
if (msg.kind === 'tool_use' && msg.toolId && toolResultMap.has(msg.toolId)) {
|
|
||||||
const toolResult = toolResultMap.get(msg.toolId);
|
|
||||||
if (toolResult) {
|
|
||||||
msg.toolResult = { content: toolResult.content, isError: toolResult.isError };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
messages: normalized,
|
|
||||||
total: normalized.length,
|
|
||||||
hasMore: false,
|
|
||||||
offset: 0,
|
|
||||||
limit: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import { ClaudeProvider } from '@/modules/providers/list/claude/claude.provider.js';
|
|
||||||
import { CodexProvider } from '@/modules/providers/list/codex/codex.provider.js';
|
|
||||||
import { CursorProvider } from '@/modules/providers/list/cursor/cursor.provider.js';
|
|
||||||
import { GeminiProvider } from '@/modules/providers/list/gemini/gemini.provider.js';
|
|
||||||
import type { IProvider } from '@/shared/interfaces.js';
|
|
||||||
import type { LLMProvider } from '@/shared/types.js';
|
|
||||||
import { AppError } from '@/shared/utils.js';
|
|
||||||
|
|
||||||
const providers: Record<LLMProvider, IProvider> = {
|
|
||||||
claude: new ClaudeProvider(),
|
|
||||||
codex: new CodexProvider(),
|
|
||||||
cursor: new CursorProvider(),
|
|
||||||
gemini: new GeminiProvider(),
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Central registry for resolving concrete provider implementations by id.
|
|
||||||
*/
|
|
||||||
export const providerRegistry = {
|
|
||||||
listProviders(): IProvider[] {
|
|
||||||
return Object.values(providers);
|
|
||||||
},
|
|
||||||
|
|
||||||
resolveProvider(provider: string): IProvider {
|
|
||||||
const key = provider as LLMProvider;
|
|
||||||
const resolvedProvider = providers[key];
|
|
||||||
if (!resolvedProvider) {
|
|
||||||
throw new AppError(`Unsupported provider "${provider}".`, {
|
|
||||||
code: 'UNSUPPORTED_PROVIDER',
|
|
||||||
statusCode: 400,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolvedProvider;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,217 +0,0 @@
|
|||||||
import express, { type Request, type Response } from 'express';
|
|
||||||
|
|
||||||
import { providerAuthService } from '@/modules/providers/services/provider-auth.service.js';
|
|
||||||
import { providerMcpService } from '@/modules/providers/services/mcp.service.js';
|
|
||||||
import type { LLMProvider, McpScope, McpTransport, UpsertProviderMcpServerInput } from '@/shared/types.js';
|
|
||||||
import { AppError, asyncHandler, createApiSuccessResponse } from '@/shared/utils.js';
|
|
||||||
|
|
||||||
const router = express.Router();
|
|
||||||
|
|
||||||
const readPathParam = (value: unknown, name: string): string => {
|
|
||||||
if (typeof value === 'string') {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(value) && typeof value[0] === 'string') {
|
|
||||||
return value[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new AppError(`${name} path parameter is invalid.`, {
|
|
||||||
code: 'INVALID_PATH_PARAMETER',
|
|
||||||
statusCode: 400,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const normalizeProviderParam = (value: unknown): string =>
|
|
||||||
readPathParam(value, 'provider').trim().toLowerCase();
|
|
||||||
|
|
||||||
const readOptionalQueryString = (value: unknown): string | undefined => {
|
|
||||||
if (typeof value !== 'string') {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalized = value.trim();
|
|
||||||
return normalized.length > 0 ? normalized : undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const parseMcpScope = (value: unknown): McpScope | undefined => {
|
|
||||||
if (value === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalized = readOptionalQueryString(value);
|
|
||||||
if (!normalized) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (normalized === 'user' || normalized === 'local' || normalized === 'project') {
|
|
||||||
return normalized;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new AppError(`Unsupported MCP scope "${normalized}".`, {
|
|
||||||
code: 'INVALID_MCP_SCOPE',
|
|
||||||
statusCode: 400,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const parseMcpTransport = (value: unknown): McpTransport => {
|
|
||||||
const normalized = readOptionalQueryString(value);
|
|
||||||
if (!normalized) {
|
|
||||||
throw new AppError('transport is required.', {
|
|
||||||
code: 'MCP_TRANSPORT_REQUIRED',
|
|
||||||
statusCode: 400,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (normalized === 'stdio' || normalized === 'http' || normalized === 'sse') {
|
|
||||||
return normalized;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new AppError(`Unsupported MCP transport "${normalized}".`, {
|
|
||||||
code: 'INVALID_MCP_TRANSPORT',
|
|
||||||
statusCode: 400,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const parseMcpUpsertPayload = (payload: unknown): UpsertProviderMcpServerInput => {
|
|
||||||
if (!payload || typeof payload !== 'object') {
|
|
||||||
throw new AppError('Request body must be an object.', {
|
|
||||||
code: 'INVALID_REQUEST_BODY',
|
|
||||||
statusCode: 400,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const body = payload as Record<string, unknown>;
|
|
||||||
const name = readOptionalQueryString(body.name);
|
|
||||||
if (!name) {
|
|
||||||
throw new AppError('name is required.', {
|
|
||||||
code: 'MCP_NAME_REQUIRED',
|
|
||||||
statusCode: 400,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const transport = parseMcpTransport(body.transport);
|
|
||||||
const scope = parseMcpScope(body.scope);
|
|
||||||
const workspacePath = readOptionalQueryString(body.workspacePath);
|
|
||||||
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
transport,
|
|
||||||
scope,
|
|
||||||
workspacePath,
|
|
||||||
command: readOptionalQueryString(body.command),
|
|
||||||
args: Array.isArray(body.args) ? body.args.filter((entry): entry is string => typeof entry === 'string') : undefined,
|
|
||||||
env: typeof body.env === 'object' && body.env !== null
|
|
||||||
? Object.fromEntries(
|
|
||||||
Object.entries(body.env as Record<string, unknown>).filter(
|
|
||||||
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: undefined,
|
|
||||||
cwd: readOptionalQueryString(body.cwd),
|
|
||||||
url: readOptionalQueryString(body.url),
|
|
||||||
headers: typeof body.headers === 'object' && body.headers !== null
|
|
||||||
? Object.fromEntries(
|
|
||||||
Object.entries(body.headers as Record<string, unknown>).filter(
|
|
||||||
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: undefined,
|
|
||||||
envVars: Array.isArray(body.envVars)
|
|
||||||
? body.envVars.filter((entry): entry is string => typeof entry === 'string')
|
|
||||||
: undefined,
|
|
||||||
bearerTokenEnvVar: readOptionalQueryString(body.bearerTokenEnvVar),
|
|
||||||
envHttpHeaders: typeof body.envHttpHeaders === 'object' && body.envHttpHeaders !== null
|
|
||||||
? Object.fromEntries(
|
|
||||||
Object.entries(body.envHttpHeaders as Record<string, unknown>).filter(
|
|
||||||
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: undefined,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const parseProvider = (value: unknown): LLMProvider => {
|
|
||||||
const normalized = normalizeProviderParam(value);
|
|
||||||
if (normalized === 'claude' || normalized === 'codex' || normalized === 'cursor' || normalized === 'gemini') {
|
|
||||||
return normalized;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new AppError(`Unsupported provider "${normalized}".`, {
|
|
||||||
code: 'UNSUPPORTED_PROVIDER',
|
|
||||||
statusCode: 400,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
router.get(
|
|
||||||
'/:provider/auth/status',
|
|
||||||
asyncHandler(async (req: Request, res: Response) => {
|
|
||||||
const provider = parseProvider(req.params.provider);
|
|
||||||
const status = await providerAuthService.getProviderAuthStatus(provider);
|
|
||||||
res.json(status);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
router.get(
|
|
||||||
'/:provider/mcp/servers',
|
|
||||||
asyncHandler(async (req: Request, res: Response) => {
|
|
||||||
const provider = parseProvider(req.params.provider);
|
|
||||||
const workspacePath = readOptionalQueryString(req.query.workspacePath);
|
|
||||||
const scope = parseMcpScope(req.query.scope);
|
|
||||||
|
|
||||||
if (scope) {
|
|
||||||
const servers = await providerMcpService.listProviderMcpServersForScope(provider, scope, { workspacePath });
|
|
||||||
res.json(createApiSuccessResponse({ provider, scope, servers }));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const groupedServers = await providerMcpService.listProviderMcpServers(provider, { workspacePath });
|
|
||||||
res.json(createApiSuccessResponse({ provider, scopes: groupedServers }));
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
router.post(
|
|
||||||
'/:provider/mcp/servers',
|
|
||||||
asyncHandler(async (req: Request, res: Response) => {
|
|
||||||
const provider = parseProvider(req.params.provider);
|
|
||||||
const payload = parseMcpUpsertPayload(req.body);
|
|
||||||
const server = await providerMcpService.upsertProviderMcpServer(provider, payload);
|
|
||||||
res.status(201).json(createApiSuccessResponse({ server }));
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
router.delete(
|
|
||||||
'/:provider/mcp/servers/:name',
|
|
||||||
asyncHandler(async (req: Request, res: Response) => {
|
|
||||||
const provider = parseProvider(req.params.provider);
|
|
||||||
const scope = parseMcpScope(req.query.scope);
|
|
||||||
const workspacePath = readOptionalQueryString(req.query.workspacePath);
|
|
||||||
const result = await providerMcpService.removeProviderMcpServer(provider, {
|
|
||||||
name: readPathParam(req.params.name, 'name'),
|
|
||||||
scope,
|
|
||||||
workspacePath,
|
|
||||||
});
|
|
||||||
res.json(createApiSuccessResponse(result));
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
router.post(
|
|
||||||
'/mcp/servers/global',
|
|
||||||
asyncHandler(async (req: Request, res: Response) => {
|
|
||||||
const payload = parseMcpUpsertPayload(req.body);
|
|
||||||
if (payload.scope === 'local') {
|
|
||||||
throw new AppError('Global MCP add supports only "user" or "project" scopes.', {
|
|
||||||
code: 'INVALID_GLOBAL_MCP_SCOPE',
|
|
||||||
statusCode: 400,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const results = await providerMcpService.addMcpServerToAllProviders({
|
|
||||||
...payload,
|
|
||||||
scope: payload.scope === 'user' ? 'user' : 'project',
|
|
||||||
});
|
|
||||||
res.status(201).json(createApiSuccessResponse({ results }));
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
export default router;
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { providerRegistry } from '@/modules/providers/provider.registry.js';
|
|
||||||
import type { ProviderAuthStatus } from '@/shared/types.js';
|
|
||||||
|
|
||||||
export const providerAuthService = {
|
|
||||||
/**
|
|
||||||
* Resolves a provider and returns its installation/authentication status.
|
|
||||||
*/
|
|
||||||
async getProviderAuthStatus(providerName: string): Promise<ProviderAuthStatus> {
|
|
||||||
const provider = providerRegistry.resolveProvider(providerName);
|
|
||||||
return provider.auth.getStatus();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
import { providerRegistry } from '@/modules/providers/provider.registry.js';
|
|
||||||
import type {
|
|
||||||
FetchHistoryOptions,
|
|
||||||
FetchHistoryResult,
|
|
||||||
LLMProvider,
|
|
||||||
NormalizedMessage,
|
|
||||||
} from '@/shared/types.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Application service for provider-backed session message operations.
|
|
||||||
*
|
|
||||||
* Callers pass a provider id and this service resolves the concrete provider
|
|
||||||
* class, keeping normalization/history call sites decoupled from implementation
|
|
||||||
* file layout.
|
|
||||||
*/
|
|
||||||
export const sessionsService = {
|
|
||||||
/**
|
|
||||||
* Lists provider ids that can load session history and normalize live messages.
|
|
||||||
*/
|
|
||||||
listProviderIds(): LLMProvider[] {
|
|
||||||
return providerRegistry.listProviders().map((provider) => provider.id);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes one provider-native event into frontend session message events.
|
|
||||||
*/
|
|
||||||
normalizeMessage(
|
|
||||||
providerName: string,
|
|
||||||
raw: unknown,
|
|
||||||
sessionId: string | null,
|
|
||||||
): NormalizedMessage[] {
|
|
||||||
return providerRegistry.resolveProvider(providerName).normalizeMessage(raw, sessionId);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches normalized persisted session history for one provider/session pair.
|
|
||||||
*/
|
|
||||||
fetchHistory(
|
|
||||||
providerName: string,
|
|
||||||
sessionId: string,
|
|
||||||
options?: FetchHistoryOptions,
|
|
||||||
): Promise<FetchHistoryResult> {
|
|
||||||
return providerRegistry.resolveProvider(providerName).fetchHistory(sessionId, options);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import type { IProvider, IProviderAuth, IProviderMcp } from '@/shared/interfaces.js';
|
|
||||||
import type {
|
|
||||||
FetchHistoryOptions,
|
|
||||||
FetchHistoryResult,
|
|
||||||
LLMProvider,
|
|
||||||
NormalizedMessage,
|
|
||||||
} from '@/shared/types.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shared provider base.
|
|
||||||
*
|
|
||||||
* Concrete providers must expose auth/MCP handlers and implement message
|
|
||||||
* normalization/history loading because those behaviors depend on native
|
|
||||||
* SDK/CLI formats.
|
|
||||||
*/
|
|
||||||
export abstract class AbstractProvider implements IProvider {
|
|
||||||
readonly id: LLMProvider;
|
|
||||||
abstract readonly mcp: IProviderMcp;
|
|
||||||
abstract readonly auth: IProviderAuth;
|
|
||||||
|
|
||||||
protected constructor(id: LLMProvider) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract normalizeMessage(raw: unknown, sessionId: string | null): NormalizedMessage[];
|
|
||||||
|
|
||||||
abstract fetchHistory(
|
|
||||||
sessionId: string,
|
|
||||||
options?: FetchHistoryOptions,
|
|
||||||
): Promise<FetchHistoryResult>;
|
|
||||||
}
|
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
import { Codex } from '@openai/codex-sdk';
|
import { Codex } from '@openai/codex-sdk';
|
||||||
import { notifyRunFailed, notifyRunStopped } from './services/notification-orchestrator.js';
|
import { notifyRunFailed, notifyRunStopped } from './services/notification-orchestrator.js';
|
||||||
import { sessionsService } from './modules/providers/services/sessions.service.js';
|
import { codexAdapter } from './providers/codex/adapter.js';
|
||||||
import { createNormalizedMessage } from './shared/utils.js';
|
import { createNormalizedMessage } from './providers/types.js';
|
||||||
|
|
||||||
// Track active sessions
|
// Track active sessions
|
||||||
const activeCodexSessions = new Map();
|
const activeCodexSessions = new Map();
|
||||||
@@ -264,7 +264,7 @@ export async function queryCodex(command, options = {}, ws) {
|
|||||||
const transformed = transformCodexEvent(event);
|
const transformed = transformCodexEvent(event);
|
||||||
|
|
||||||
// Normalize the transformed event into NormalizedMessage(s) via adapter
|
// Normalize the transformed event into NormalizedMessage(s) via adapter
|
||||||
const normalizedMsgs = sessionsService.normalizeMessage('codex', transformed, currentSessionId);
|
const normalizedMsgs = codexAdapter.normalizeMessage(transformed, currentSessionId);
|
||||||
for (const msg of normalizedMsgs) {
|
for (const msg of normalizedMsgs) {
|
||||||
sendMessage(ws, msg);
|
sendMessage(ws, msg);
|
||||||
}
|
}
|
||||||
|
|||||||
278
server/providers/claude/adapter.js
Normal file
278
server/providers/claude/adapter.js
Normal file
@@ -0,0 +1,278 @@
|
|||||||
|
/**
|
||||||
|
* Claude provider adapter.
|
||||||
|
*
|
||||||
|
* Normalizes Claude SDK session history into NormalizedMessage format.
|
||||||
|
* @module adapters/claude
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { getSessionMessages } from '../../projects.js';
|
||||||
|
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
||||||
|
import { isInternalContent } from '../utils.js';
|
||||||
|
|
||||||
|
const PROVIDER = 'claude';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize a raw JSONL message or realtime SDK event into NormalizedMessage(s).
|
||||||
|
* Handles both history entries (JSONL `{ message: { role, content } }`) and
|
||||||
|
* realtime streaming events (`content_block_delta`, `content_block_stop`, etc.).
|
||||||
|
* @param {object} raw - A single entry from JSONL or a live SDK event
|
||||||
|
* @param {string} sessionId
|
||||||
|
* @returns {import('../types.js').NormalizedMessage[]}
|
||||||
|
*/
|
||||||
|
export function normalizeMessage(raw, sessionId) {
|
||||||
|
// ── Streaming events (realtime) ──────────────────────────────────────────
|
||||||
|
if (raw.type === 'content_block_delta' && raw.delta?.text) {
|
||||||
|
return [createNormalizedMessage({ kind: 'stream_delta', content: raw.delta.text, sessionId, provider: PROVIDER })];
|
||||||
|
}
|
||||||
|
if (raw.type === 'content_block_stop') {
|
||||||
|
return [createNormalizedMessage({ kind: 'stream_end', sessionId, provider: PROVIDER })];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── History / full-message events ────────────────────────────────────────
|
||||||
|
const messages = [];
|
||||||
|
const ts = raw.timestamp || new Date().toISOString();
|
||||||
|
const baseId = raw.uuid || generateMessageId('claude');
|
||||||
|
|
||||||
|
// User message
|
||||||
|
if (raw.message?.role === 'user' && raw.message?.content) {
|
||||||
|
if (Array.isArray(raw.message.content)) {
|
||||||
|
// Handle tool_result parts
|
||||||
|
for (const part of raw.message.content) {
|
||||||
|
if (part.type === 'tool_result') {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_tr_${part.tool_use_id}`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'tool_result',
|
||||||
|
toolId: part.tool_use_id,
|
||||||
|
content: typeof part.content === 'string' ? part.content : JSON.stringify(part.content),
|
||||||
|
isError: Boolean(part.is_error),
|
||||||
|
subagentTools: raw.subagentTools,
|
||||||
|
toolUseResult: raw.toolUseResult,
|
||||||
|
}));
|
||||||
|
} else if (part.type === 'text') {
|
||||||
|
// Regular text parts from user
|
||||||
|
const text = part.text || '';
|
||||||
|
if (text && !isInternalContent(text)) {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_text`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role: 'user',
|
||||||
|
content: text,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no text parts were found, check if it's a pure user message
|
||||||
|
if (messages.length === 0) {
|
||||||
|
const textParts = raw.message.content
|
||||||
|
.filter(p => p.type === 'text')
|
||||||
|
.map(p => p.text)
|
||||||
|
.filter(Boolean)
|
||||||
|
.join('\n');
|
||||||
|
if (textParts && !isInternalContent(textParts)) {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_text`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role: 'user',
|
||||||
|
content: textParts,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (typeof raw.message.content === 'string') {
|
||||||
|
const text = raw.message.content;
|
||||||
|
if (text && !isInternalContent(text)) {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role: 'user',
|
||||||
|
content: text,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Thinking message
|
||||||
|
if (raw.type === 'thinking' && raw.message?.content) {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'thinking',
|
||||||
|
content: raw.message.content,
|
||||||
|
}));
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tool use result (codex-style in Claude)
|
||||||
|
if (raw.type === 'tool_use' && raw.toolName) {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'tool_use',
|
||||||
|
toolName: raw.toolName,
|
||||||
|
toolInput: raw.toolInput,
|
||||||
|
toolId: raw.toolCallId || baseId,
|
||||||
|
}));
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (raw.type === 'tool_result') {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'tool_result',
|
||||||
|
toolId: raw.toolCallId || '',
|
||||||
|
content: raw.output || '',
|
||||||
|
isError: false,
|
||||||
|
}));
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assistant message
|
||||||
|
if (raw.message?.role === 'assistant' && raw.message?.content) {
|
||||||
|
if (Array.isArray(raw.message.content)) {
|
||||||
|
let partIndex = 0;
|
||||||
|
for (const part of raw.message.content) {
|
||||||
|
if (part.type === 'text' && part.text) {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_${partIndex}`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role: 'assistant',
|
||||||
|
content: part.text,
|
||||||
|
}));
|
||||||
|
} else if (part.type === 'tool_use') {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_${partIndex}`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'tool_use',
|
||||||
|
toolName: part.name,
|
||||||
|
toolInput: part.input,
|
||||||
|
toolId: part.id,
|
||||||
|
}));
|
||||||
|
} else if (part.type === 'thinking' && part.thinking) {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_${partIndex}`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'thinking',
|
||||||
|
content: part.thinking,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
partIndex++;
|
||||||
|
}
|
||||||
|
} else if (typeof raw.message.content === 'string') {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role: 'assistant',
|
||||||
|
content: raw.message.content,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import('../types.js').ProviderAdapter}
|
||||||
|
*/
|
||||||
|
export const claudeAdapter = {
|
||||||
|
normalizeMessage,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch session history from JSONL files, returning normalized messages.
|
||||||
|
*/
|
||||||
|
async fetchHistory(sessionId, opts = {}) {
|
||||||
|
const { projectName, limit = null, offset = 0 } = opts;
|
||||||
|
if (!projectName) {
|
||||||
|
return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
let result;
|
||||||
|
try {
|
||||||
|
result = await getSessionMessages(projectName, sessionId, limit, offset);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`[ClaudeAdapter] Failed to load session ${sessionId}:`, error.message);
|
||||||
|
return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
// getSessionMessages returns either an array (no limit) or { messages, total, hasMore }
|
||||||
|
const rawMessages = Array.isArray(result) ? result : (result.messages || []);
|
||||||
|
const total = Array.isArray(result) ? rawMessages.length : (result.total || 0);
|
||||||
|
const hasMore = Array.isArray(result) ? false : Boolean(result.hasMore);
|
||||||
|
|
||||||
|
// First pass: collect tool results for attachment to tool_use messages
|
||||||
|
const toolResultMap = new Map();
|
||||||
|
for (const raw of rawMessages) {
|
||||||
|
if (raw.message?.role === 'user' && Array.isArray(raw.message?.content)) {
|
||||||
|
for (const part of raw.message.content) {
|
||||||
|
if (part.type === 'tool_result') {
|
||||||
|
toolResultMap.set(part.tool_use_id, {
|
||||||
|
content: part.content,
|
||||||
|
isError: Boolean(part.is_error),
|
||||||
|
timestamp: raw.timestamp,
|
||||||
|
subagentTools: raw.subagentTools,
|
||||||
|
toolUseResult: raw.toolUseResult,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Second pass: normalize all messages
|
||||||
|
const normalized = [];
|
||||||
|
for (const raw of rawMessages) {
|
||||||
|
const entries = normalizeMessage(raw, sessionId);
|
||||||
|
normalized.push(...entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach tool results to their corresponding tool_use messages
|
||||||
|
for (const msg of normalized) {
|
||||||
|
if (msg.kind === 'tool_use' && msg.toolId && toolResultMap.has(msg.toolId)) {
|
||||||
|
const tr = toolResultMap.get(msg.toolId);
|
||||||
|
msg.toolResult = {
|
||||||
|
content: typeof tr.content === 'string' ? tr.content : JSON.stringify(tr.content),
|
||||||
|
isError: tr.isError,
|
||||||
|
toolUseResult: tr.toolUseResult,
|
||||||
|
};
|
||||||
|
msg.subagentTools = tr.subagentTools;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
messages: normalized,
|
||||||
|
total,
|
||||||
|
hasMore,
|
||||||
|
offset,
|
||||||
|
limit,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
248
server/providers/codex/adapter.js
Normal file
248
server/providers/codex/adapter.js
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
/**
|
||||||
|
* Codex (OpenAI) provider adapter.
|
||||||
|
*
|
||||||
|
* Normalizes Codex SDK session history into NormalizedMessage format.
|
||||||
|
* @module adapters/codex
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { getCodexSessionMessages } from '../../projects.js';
|
||||||
|
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
||||||
|
|
||||||
|
const PROVIDER = 'codex';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize a raw Codex JSONL message into NormalizedMessage(s).
|
||||||
|
* @param {object} raw - A single parsed message from Codex JSONL
|
||||||
|
* @param {string} sessionId
|
||||||
|
* @returns {import('../types.js').NormalizedMessage[]}
|
||||||
|
*/
|
||||||
|
function normalizeCodexHistoryEntry(raw, sessionId) {
|
||||||
|
const ts = raw.timestamp || new Date().toISOString();
|
||||||
|
const baseId = raw.uuid || generateMessageId('codex');
|
||||||
|
|
||||||
|
// User message
|
||||||
|
if (raw.message?.role === 'user') {
|
||||||
|
const content = typeof raw.message.content === 'string'
|
||||||
|
? raw.message.content
|
||||||
|
: Array.isArray(raw.message.content)
|
||||||
|
? raw.message.content.map(p => typeof p === 'string' ? p : p?.text || '').filter(Boolean).join('\n')
|
||||||
|
: String(raw.message.content || '');
|
||||||
|
if (!content.trim()) return [];
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role: 'user',
|
||||||
|
content,
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assistant message
|
||||||
|
if (raw.message?.role === 'assistant') {
|
||||||
|
const content = typeof raw.message.content === 'string'
|
||||||
|
? raw.message.content
|
||||||
|
: Array.isArray(raw.message.content)
|
||||||
|
? raw.message.content.map(p => typeof p === 'string' ? p : p?.text || '').filter(Boolean).join('\n')
|
||||||
|
: '';
|
||||||
|
if (!content.trim()) return [];
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role: 'assistant',
|
||||||
|
content,
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Thinking/reasoning
|
||||||
|
if (raw.type === 'thinking' || raw.isReasoning) {
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'thinking',
|
||||||
|
content: raw.message?.content || '',
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tool use
|
||||||
|
if (raw.type === 'tool_use' || raw.toolName) {
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'tool_use',
|
||||||
|
toolName: raw.toolName || 'Unknown',
|
||||||
|
toolInput: raw.toolInput,
|
||||||
|
toolId: raw.toolCallId || baseId,
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tool result
|
||||||
|
if (raw.type === 'tool_result') {
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'tool_result',
|
||||||
|
toolId: raw.toolCallId || '',
|
||||||
|
content: raw.output || '',
|
||||||
|
isError: Boolean(raw.isError),
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize a raw Codex event (history JSONL or transformed SDK event) into NormalizedMessage(s).
|
||||||
|
* @param {object} raw - A history entry (has raw.message.role) or transformed SDK event (has raw.type)
|
||||||
|
* @param {string} sessionId
|
||||||
|
* @returns {import('../types.js').NormalizedMessage[]}
|
||||||
|
*/
|
||||||
|
export function normalizeMessage(raw, sessionId) {
|
||||||
|
// History format: has message.role
|
||||||
|
if (raw.message?.role) {
|
||||||
|
return normalizeCodexHistoryEntry(raw, sessionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ts = raw.timestamp || new Date().toISOString();
|
||||||
|
const baseId = raw.uuid || generateMessageId('codex');
|
||||||
|
|
||||||
|
// SDK event format (output of transformCodexEvent)
|
||||||
|
if (raw.type === 'item') {
|
||||||
|
switch (raw.itemType) {
|
||||||
|
case 'agent_message':
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'text', role: 'assistant', content: raw.message?.content || '',
|
||||||
|
})];
|
||||||
|
case 'reasoning':
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'thinking', content: raw.message?.content || '',
|
||||||
|
})];
|
||||||
|
case 'command_execution':
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'tool_use', toolName: 'Bash', toolInput: { command: raw.command },
|
||||||
|
toolId: baseId,
|
||||||
|
output: raw.output, exitCode: raw.exitCode, status: raw.status,
|
||||||
|
})];
|
||||||
|
case 'file_change':
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'tool_use', toolName: 'FileChanges', toolInput: raw.changes,
|
||||||
|
toolId: baseId, status: raw.status,
|
||||||
|
})];
|
||||||
|
case 'mcp_tool_call':
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'tool_use', toolName: raw.tool || 'MCP', toolInput: raw.arguments,
|
||||||
|
toolId: baseId, server: raw.server, result: raw.result,
|
||||||
|
error: raw.error, status: raw.status,
|
||||||
|
})];
|
||||||
|
case 'web_search':
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'tool_use', toolName: 'WebSearch', toolInput: { query: raw.query },
|
||||||
|
toolId: baseId,
|
||||||
|
})];
|
||||||
|
case 'todo_list':
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'tool_use', toolName: 'TodoList', toolInput: { items: raw.items },
|
||||||
|
toolId: baseId,
|
||||||
|
})];
|
||||||
|
case 'error':
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'error', content: raw.message?.content || 'Unknown error',
|
||||||
|
})];
|
||||||
|
default:
|
||||||
|
// Unknown item type — pass through as generic tool_use
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'tool_use', toolName: raw.itemType || 'Unknown',
|
||||||
|
toolInput: raw.item || raw, toolId: baseId,
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (raw.type === 'turn_complete') {
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'complete',
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
if (raw.type === 'turn_failed') {
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'error', content: raw.error?.message || 'Turn failed',
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import('../types.js').ProviderAdapter}
|
||||||
|
*/
|
||||||
|
export const codexAdapter = {
|
||||||
|
normalizeMessage,
|
||||||
|
/**
|
||||||
|
* Fetch session history from Codex JSONL files.
|
||||||
|
*/
|
||||||
|
async fetchHistory(sessionId, opts = {}) {
|
||||||
|
const { limit = null, offset = 0 } = opts;
|
||||||
|
|
||||||
|
let result;
|
||||||
|
try {
|
||||||
|
result = await getCodexSessionMessages(sessionId, limit, offset);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`[CodexAdapter] Failed to load session ${sessionId}:`, error.message);
|
||||||
|
return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
const rawMessages = Array.isArray(result) ? result : (result.messages || []);
|
||||||
|
const total = Array.isArray(result) ? rawMessages.length : (result.total || 0);
|
||||||
|
const hasMore = Array.isArray(result) ? false : Boolean(result.hasMore);
|
||||||
|
const tokenUsage = result.tokenUsage || null;
|
||||||
|
|
||||||
|
const normalized = [];
|
||||||
|
for (const raw of rawMessages) {
|
||||||
|
const entries = normalizeCodexHistoryEntry(raw, sessionId);
|
||||||
|
normalized.push(...entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach tool results to tool_use messages
|
||||||
|
const toolResultMap = new Map();
|
||||||
|
for (const msg of normalized) {
|
||||||
|
if (msg.kind === 'tool_result' && msg.toolId) {
|
||||||
|
toolResultMap.set(msg.toolId, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const msg of normalized) {
|
||||||
|
if (msg.kind === 'tool_use' && msg.toolId && toolResultMap.has(msg.toolId)) {
|
||||||
|
const tr = toolResultMap.get(msg.toolId);
|
||||||
|
msg.toolResult = { content: tr.content, isError: tr.isError };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
messages: normalized,
|
||||||
|
total,
|
||||||
|
hasMore,
|
||||||
|
offset,
|
||||||
|
limit,
|
||||||
|
tokenUsage,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
353
server/providers/cursor/adapter.js
Normal file
353
server/providers/cursor/adapter.js
Normal file
@@ -0,0 +1,353 @@
|
|||||||
|
/**
|
||||||
|
* Cursor provider adapter.
|
||||||
|
*
|
||||||
|
* Normalizes Cursor CLI session history into NormalizedMessage format.
|
||||||
|
* @module adapters/cursor
|
||||||
|
*/
|
||||||
|
|
||||||
|
import path from 'path';
|
||||||
|
import os from 'os';
|
||||||
|
import crypto from 'crypto';
|
||||||
|
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
||||||
|
|
||||||
|
const PROVIDER = 'cursor';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load raw blobs from Cursor's SQLite store.db, parse the DAG structure,
|
||||||
|
* and return sorted message blobs in chronological order.
|
||||||
|
* @param {string} sessionId
|
||||||
|
* @param {string} projectPath - Absolute project path (used to compute cwdId hash)
|
||||||
|
* @returns {Promise<Array<{id: string, sequence: number, rowid: number, content: object}>>}
|
||||||
|
*/
|
||||||
|
async function loadCursorBlobs(sessionId, projectPath) {
|
||||||
|
// Lazy-import sqlite so the module doesn't fail if sqlite3 is unavailable
|
||||||
|
const { default: sqlite3 } = await import('sqlite3');
|
||||||
|
const { open } = await import('sqlite');
|
||||||
|
|
||||||
|
const cwdId = crypto.createHash('md5').update(projectPath || process.cwd()).digest('hex');
|
||||||
|
const storeDbPath = path.join(os.homedir(), '.cursor', 'chats', cwdId, sessionId, 'store.db');
|
||||||
|
|
||||||
|
const db = await open({
|
||||||
|
filename: storeDbPath,
|
||||||
|
driver: sqlite3.Database,
|
||||||
|
mode: sqlite3.OPEN_READONLY,
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const allBlobs = await db.all('SELECT rowid, id, data FROM blobs');
|
||||||
|
|
||||||
|
const blobMap = new Map();
|
||||||
|
const parentRefs = new Map();
|
||||||
|
const childRefs = new Map();
|
||||||
|
const jsonBlobs = [];
|
||||||
|
|
||||||
|
for (const blob of allBlobs) {
|
||||||
|
blobMap.set(blob.id, blob);
|
||||||
|
|
||||||
|
if (blob.data && blob.data[0] === 0x7B) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(blob.data.toString('utf8'));
|
||||||
|
jsonBlobs.push({ ...blob, parsed });
|
||||||
|
} catch {
|
||||||
|
// skip unparseable blobs
|
||||||
|
}
|
||||||
|
} else if (blob.data) {
|
||||||
|
const parents = [];
|
||||||
|
let i = 0;
|
||||||
|
while (i < blob.data.length - 33) {
|
||||||
|
if (blob.data[i] === 0x0A && blob.data[i + 1] === 0x20) {
|
||||||
|
const parentHash = blob.data.slice(i + 2, i + 34).toString('hex');
|
||||||
|
if (blobMap.has(parentHash)) {
|
||||||
|
parents.push(parentHash);
|
||||||
|
}
|
||||||
|
i += 34;
|
||||||
|
} else {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (parents.length > 0) {
|
||||||
|
parentRefs.set(blob.id, parents);
|
||||||
|
for (const parentId of parents) {
|
||||||
|
if (!childRefs.has(parentId)) childRefs.set(parentId, []);
|
||||||
|
childRefs.get(parentId).push(blob.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Topological sort (DFS)
|
||||||
|
const visited = new Set();
|
||||||
|
const sorted = [];
|
||||||
|
function visit(nodeId) {
|
||||||
|
if (visited.has(nodeId)) return;
|
||||||
|
visited.add(nodeId);
|
||||||
|
for (const pid of (parentRefs.get(nodeId) || [])) visit(pid);
|
||||||
|
const b = blobMap.get(nodeId);
|
||||||
|
if (b) sorted.push(b);
|
||||||
|
}
|
||||||
|
for (const blob of allBlobs) {
|
||||||
|
if (!parentRefs.has(blob.id)) visit(blob.id);
|
||||||
|
}
|
||||||
|
for (const blob of allBlobs) visit(blob.id);
|
||||||
|
|
||||||
|
// Order JSON blobs by DAG appearance
|
||||||
|
const messageOrder = new Map();
|
||||||
|
let orderIndex = 0;
|
||||||
|
for (const blob of sorted) {
|
||||||
|
if (blob.data && blob.data[0] !== 0x7B) {
|
||||||
|
for (const jb of jsonBlobs) {
|
||||||
|
try {
|
||||||
|
const idBytes = Buffer.from(jb.id, 'hex');
|
||||||
|
if (blob.data.includes(idBytes) && !messageOrder.has(jb.id)) {
|
||||||
|
messageOrder.set(jb.id, orderIndex++);
|
||||||
|
}
|
||||||
|
} catch { /* skip */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const sortedJsonBlobs = jsonBlobs.sort((a, b) => {
|
||||||
|
const oa = messageOrder.get(a.id) ?? Number.MAX_SAFE_INTEGER;
|
||||||
|
const ob = messageOrder.get(b.id) ?? Number.MAX_SAFE_INTEGER;
|
||||||
|
return oa !== ob ? oa - ob : a.rowid - b.rowid;
|
||||||
|
});
|
||||||
|
|
||||||
|
const messages = [];
|
||||||
|
for (let idx = 0; idx < sortedJsonBlobs.length; idx++) {
|
||||||
|
const blob = sortedJsonBlobs[idx];
|
||||||
|
const parsed = blob.parsed;
|
||||||
|
if (!parsed) continue;
|
||||||
|
const role = parsed?.role || parsed?.message?.role;
|
||||||
|
if (role === 'system') continue;
|
||||||
|
messages.push({
|
||||||
|
id: blob.id,
|
||||||
|
sequence: idx + 1,
|
||||||
|
rowid: blob.rowid,
|
||||||
|
content: parsed,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
} finally {
|
||||||
|
await db.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize a realtime NDJSON event from Cursor CLI into NormalizedMessage(s).
|
||||||
|
* History uses normalizeCursorBlobs (SQLite DAG), this handles streaming NDJSON.
|
||||||
|
* @param {object|string} raw - A parsed NDJSON event or a raw text line
|
||||||
|
* @param {string} sessionId
|
||||||
|
* @returns {import('../types.js').NormalizedMessage[]}
|
||||||
|
*/
|
||||||
|
export function normalizeMessage(raw, sessionId) {
|
||||||
|
// Structured assistant message with content array
|
||||||
|
if (raw && typeof raw === 'object' && raw.type === 'assistant' && raw.message?.content?.[0]?.text) {
|
||||||
|
return [createNormalizedMessage({ kind: 'stream_delta', content: raw.message.content[0].text, sessionId, provider: PROVIDER })];
|
||||||
|
}
|
||||||
|
// Plain string line (non-JSON output)
|
||||||
|
if (typeof raw === 'string' && raw.trim()) {
|
||||||
|
return [createNormalizedMessage({ kind: 'stream_delta', content: raw, sessionId, provider: PROVIDER })];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import('../types.js').ProviderAdapter}
|
||||||
|
*/
|
||||||
|
export const cursorAdapter = {
|
||||||
|
normalizeMessage,
|
||||||
|
/**
|
||||||
|
* Fetch session history for Cursor from SQLite store.db.
|
||||||
|
*/
|
||||||
|
async fetchHistory(sessionId, opts = {}) {
|
||||||
|
const { projectPath = '', limit = null, offset = 0 } = opts;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const blobs = await loadCursorBlobs(sessionId, projectPath);
|
||||||
|
const allNormalized = cursorAdapter.normalizeCursorBlobs(blobs, sessionId);
|
||||||
|
|
||||||
|
// Apply pagination
|
||||||
|
if (limit !== null && limit > 0) {
|
||||||
|
const start = offset;
|
||||||
|
const page = allNormalized.slice(start, start + limit);
|
||||||
|
return {
|
||||||
|
messages: page,
|
||||||
|
total: allNormalized.length,
|
||||||
|
hasMore: start + limit < allNormalized.length,
|
||||||
|
offset,
|
||||||
|
limit,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
messages: allNormalized,
|
||||||
|
total: allNormalized.length,
|
||||||
|
hasMore: false,
|
||||||
|
offset: 0,
|
||||||
|
limit: null,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
// DB doesn't exist or is unreadable — return empty
|
||||||
|
console.warn(`[CursorAdapter] Failed to load session ${sessionId}:`, error.message);
|
||||||
|
return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize raw Cursor blob messages into NormalizedMessage[].
|
||||||
|
* @param {any[]} blobs - Raw cursor blobs from store.db ({id, sequence, rowid, content})
|
||||||
|
* @param {string} sessionId
|
||||||
|
* @returns {import('../types.js').NormalizedMessage[]}
|
||||||
|
*/
|
||||||
|
normalizeCursorBlobs(blobs, sessionId) {
|
||||||
|
const messages = [];
|
||||||
|
const toolUseMap = new Map();
|
||||||
|
|
||||||
|
// Use a fixed base timestamp so messages have stable, monotonically-increasing
|
||||||
|
// timestamps based on their sequence number rather than wall-clock time.
|
||||||
|
const baseTime = Date.now();
|
||||||
|
|
||||||
|
for (let i = 0; i < blobs.length; i++) {
|
||||||
|
const blob = blobs[i];
|
||||||
|
const content = blob.content;
|
||||||
|
const ts = new Date(baseTime + (blob.sequence ?? i) * 100).toISOString();
|
||||||
|
const baseId = blob.id || generateMessageId('cursor');
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!content?.role || !content?.content) {
|
||||||
|
// Try nested message format
|
||||||
|
if (content?.message?.role && content?.message?.content) {
|
||||||
|
if (content.message.role === 'system') continue;
|
||||||
|
const role = content.message.role === 'user' ? 'user' : 'assistant';
|
||||||
|
let text = '';
|
||||||
|
if (Array.isArray(content.message.content)) {
|
||||||
|
text = content.message.content
|
||||||
|
.map(p => typeof p === 'string' ? p : p?.text || '')
|
||||||
|
.filter(Boolean)
|
||||||
|
.join('\n');
|
||||||
|
} else if (typeof content.message.content === 'string') {
|
||||||
|
text = content.message.content;
|
||||||
|
}
|
||||||
|
if (text?.trim()) {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role,
|
||||||
|
content: text,
|
||||||
|
sequence: blob.sequence,
|
||||||
|
rowid: blob.rowid,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (content.role === 'system') continue;
|
||||||
|
|
||||||
|
// Tool results
|
||||||
|
if (content.role === 'tool') {
|
||||||
|
const toolItems = Array.isArray(content.content) ? content.content : [];
|
||||||
|
for (const item of toolItems) {
|
||||||
|
if (item?.type !== 'tool-result') continue;
|
||||||
|
const toolCallId = item.toolCallId || content.id;
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_tr`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'tool_result',
|
||||||
|
toolId: toolCallId,
|
||||||
|
content: item.result || '',
|
||||||
|
isError: false,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const role = content.role === 'user' ? 'user' : 'assistant';
|
||||||
|
|
||||||
|
if (Array.isArray(content.content)) {
|
||||||
|
for (let partIdx = 0; partIdx < content.content.length; partIdx++) {
|
||||||
|
const part = content.content[partIdx];
|
||||||
|
|
||||||
|
if (part?.type === 'text' && part?.text) {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_${partIdx}`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role,
|
||||||
|
content: part.text,
|
||||||
|
sequence: blob.sequence,
|
||||||
|
rowid: blob.rowid,
|
||||||
|
}));
|
||||||
|
} else if (part?.type === 'reasoning' && part?.text) {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_${partIdx}`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'thinking',
|
||||||
|
content: part.text,
|
||||||
|
}));
|
||||||
|
} else if (part?.type === 'tool-call' || part?.type === 'tool_use') {
|
||||||
|
const toolName = (part.toolName || part.name || 'Unknown Tool') === 'ApplyPatch'
|
||||||
|
? 'Edit' : (part.toolName || part.name || 'Unknown Tool');
|
||||||
|
const toolId = part.toolCallId || part.id || `tool_${i}_${partIdx}`;
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_${partIdx}`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'tool_use',
|
||||||
|
toolName,
|
||||||
|
toolInput: part.args || part.input,
|
||||||
|
toolId,
|
||||||
|
}));
|
||||||
|
toolUseMap.set(toolId, messages[messages.length - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (typeof content.content === 'string' && content.content.trim()) {
|
||||||
|
messages.push(createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role,
|
||||||
|
content: content.content,
|
||||||
|
sequence: blob.sequence,
|
||||||
|
rowid: blob.rowid,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Error normalizing cursor blob:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach tool results to tool_use messages
|
||||||
|
for (const msg of messages) {
|
||||||
|
if (msg.kind === 'tool_result' && msg.toolId && toolUseMap.has(msg.toolId)) {
|
||||||
|
const toolUse = toolUseMap.get(msg.toolId);
|
||||||
|
toolUse.toolResult = {
|
||||||
|
content: msg.content,
|
||||||
|
isError: msg.isError,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort by sequence/rowid
|
||||||
|
messages.sort((a, b) => {
|
||||||
|
if (a.sequence !== undefined && b.sequence !== undefined) return a.sequence - b.sequence;
|
||||||
|
if (a.rowid !== undefined && b.rowid !== undefined) return a.rowid - b.rowid;
|
||||||
|
return new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime();
|
||||||
|
});
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
},
|
||||||
|
};
|
||||||
186
server/providers/gemini/adapter.js
Normal file
186
server/providers/gemini/adapter.js
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
/**
|
||||||
|
* Gemini provider adapter.
|
||||||
|
*
|
||||||
|
* Normalizes Gemini CLI session history into NormalizedMessage format.
|
||||||
|
* @module adapters/gemini
|
||||||
|
*/
|
||||||
|
|
||||||
|
import sessionManager from '../../sessionManager.js';
|
||||||
|
import { getGeminiCliSessionMessages } from '../../projects.js';
|
||||||
|
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
||||||
|
|
||||||
|
const PROVIDER = 'gemini';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize a realtime NDJSON event from Gemini CLI into NormalizedMessage(s).
|
||||||
|
* Handles: message (delta/final), tool_use, tool_result, result, error.
|
||||||
|
* @param {object} raw - A parsed NDJSON event
|
||||||
|
* @param {string} sessionId
|
||||||
|
* @returns {import('../types.js').NormalizedMessage[]}
|
||||||
|
*/
|
||||||
|
export function normalizeMessage(raw, sessionId) {
|
||||||
|
const ts = raw.timestamp || new Date().toISOString();
|
||||||
|
const baseId = raw.uuid || generateMessageId('gemini');
|
||||||
|
|
||||||
|
if (raw.type === 'message' && raw.role === 'assistant') {
|
||||||
|
const content = raw.content || '';
|
||||||
|
const msgs = [];
|
||||||
|
if (content) {
|
||||||
|
msgs.push(createNormalizedMessage({ id: baseId, sessionId, timestamp: ts, provider: PROVIDER, kind: 'stream_delta', content }));
|
||||||
|
}
|
||||||
|
// If not a delta, also send stream_end
|
||||||
|
if (raw.delta !== true) {
|
||||||
|
msgs.push(createNormalizedMessage({ sessionId, timestamp: ts, provider: PROVIDER, kind: 'stream_end' }));
|
||||||
|
}
|
||||||
|
return msgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (raw.type === 'tool_use') {
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'tool_use', toolName: raw.tool_name, toolInput: raw.parameters || {},
|
||||||
|
toolId: raw.tool_id || baseId,
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (raw.type === 'tool_result') {
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'tool_result', toolId: raw.tool_id || '',
|
||||||
|
content: raw.output === undefined ? '' : String(raw.output),
|
||||||
|
isError: raw.status === 'error',
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (raw.type === 'result') {
|
||||||
|
const msgs = [createNormalizedMessage({ sessionId, timestamp: ts, provider: PROVIDER, kind: 'stream_end' })];
|
||||||
|
if (raw.stats?.total_tokens) {
|
||||||
|
msgs.push(createNormalizedMessage({
|
||||||
|
sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'status', text: 'Complete', tokens: raw.stats.total_tokens, canInterrupt: false,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return msgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (raw.type === 'error') {
|
||||||
|
return [createNormalizedMessage({
|
||||||
|
id: baseId, sessionId, timestamp: ts, provider: PROVIDER,
|
||||||
|
kind: 'error', content: raw.error || raw.message || 'Unknown Gemini streaming error',
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import('../types.js').ProviderAdapter}
|
||||||
|
*/
|
||||||
|
export const geminiAdapter = {
|
||||||
|
normalizeMessage,
|
||||||
|
/**
|
||||||
|
* Fetch session history for Gemini.
|
||||||
|
* First tries in-memory session manager, then falls back to CLI sessions on disk.
|
||||||
|
*/
|
||||||
|
async fetchHistory(sessionId, opts = {}) {
|
||||||
|
let rawMessages;
|
||||||
|
try {
|
||||||
|
rawMessages = sessionManager.getSessionMessages(sessionId);
|
||||||
|
|
||||||
|
// Fallback to Gemini CLI sessions on disk
|
||||||
|
if (rawMessages.length === 0) {
|
||||||
|
rawMessages = await getGeminiCliSessionMessages(sessionId);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`[GeminiAdapter] Failed to load session ${sessionId}:`, error.message);
|
||||||
|
return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalized = [];
|
||||||
|
for (let i = 0; i < rawMessages.length; i++) {
|
||||||
|
const raw = rawMessages[i];
|
||||||
|
const ts = raw.timestamp || new Date().toISOString();
|
||||||
|
const baseId = raw.uuid || generateMessageId('gemini');
|
||||||
|
|
||||||
|
// sessionManager format: { type: 'message', message: { role, content }, timestamp }
|
||||||
|
// CLI format: { role: 'user'|'gemini'|'assistant', content: string|array }
|
||||||
|
const role = raw.message?.role || raw.role;
|
||||||
|
const content = raw.message?.content || raw.content;
|
||||||
|
|
||||||
|
if (!role || !content) continue;
|
||||||
|
|
||||||
|
const normalizedRole = (role === 'user') ? 'user' : 'assistant';
|
||||||
|
|
||||||
|
if (Array.isArray(content)) {
|
||||||
|
for (let partIdx = 0; partIdx < content.length; partIdx++) {
|
||||||
|
const part = content[partIdx];
|
||||||
|
if (part.type === 'text' && part.text) {
|
||||||
|
normalized.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_${partIdx}`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role: normalizedRole,
|
||||||
|
content: part.text,
|
||||||
|
}));
|
||||||
|
} else if (part.type === 'tool_use') {
|
||||||
|
normalized.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_${partIdx}`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'tool_use',
|
||||||
|
toolName: part.name,
|
||||||
|
toolInput: part.input,
|
||||||
|
toolId: part.id || generateMessageId('gemini_tool'),
|
||||||
|
}));
|
||||||
|
} else if (part.type === 'tool_result') {
|
||||||
|
normalized.push(createNormalizedMessage({
|
||||||
|
id: `${baseId}_${partIdx}`,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'tool_result',
|
||||||
|
toolId: part.tool_use_id || '',
|
||||||
|
content: part.content === undefined ? '' : String(part.content),
|
||||||
|
isError: Boolean(part.is_error),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (typeof content === 'string' && content.trim()) {
|
||||||
|
normalized.push(createNormalizedMessage({
|
||||||
|
id: baseId,
|
||||||
|
sessionId,
|
||||||
|
timestamp: ts,
|
||||||
|
provider: PROVIDER,
|
||||||
|
kind: 'text',
|
||||||
|
role: normalizedRole,
|
||||||
|
content,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach tool results to tool_use messages
|
||||||
|
const toolResultMap = new Map();
|
||||||
|
for (const msg of normalized) {
|
||||||
|
if (msg.kind === 'tool_result' && msg.toolId) {
|
||||||
|
toolResultMap.set(msg.toolId, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const msg of normalized) {
|
||||||
|
if (msg.kind === 'tool_use' && msg.toolId && toolResultMap.has(msg.toolId)) {
|
||||||
|
const tr = toolResultMap.get(msg.toolId);
|
||||||
|
msg.toolResult = { content: tr.content, isError: tr.isError };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
messages: normalized,
|
||||||
|
total: normalized.length,
|
||||||
|
hasMore: false,
|
||||||
|
offset: 0,
|
||||||
|
limit: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
44
server/providers/registry.js
Normal file
44
server/providers/registry.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* Provider Registry
|
||||||
|
*
|
||||||
|
* Centralizes provider adapter lookup. All code that needs a provider adapter
|
||||||
|
* should go through this registry instead of importing individual adapters directly.
|
||||||
|
*
|
||||||
|
* @module providers/registry
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { claudeAdapter } from './claude/adapter.js';
|
||||||
|
import { cursorAdapter } from './cursor/adapter.js';
|
||||||
|
import { codexAdapter } from './codex/adapter.js';
|
||||||
|
import { geminiAdapter } from './gemini/adapter.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('./types.js').ProviderAdapter} ProviderAdapter
|
||||||
|
* @typedef {import('./types.js').SessionProvider} SessionProvider
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Map<string, ProviderAdapter>} */
|
||||||
|
const providers = new Map();
|
||||||
|
|
||||||
|
// Register built-in providers
|
||||||
|
providers.set('claude', claudeAdapter);
|
||||||
|
providers.set('cursor', cursorAdapter);
|
||||||
|
providers.set('codex', codexAdapter);
|
||||||
|
providers.set('gemini', geminiAdapter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a provider adapter by name.
|
||||||
|
* @param {string} name - Provider name (e.g., 'claude', 'cursor', 'codex', 'gemini')
|
||||||
|
* @returns {ProviderAdapter | undefined}
|
||||||
|
*/
|
||||||
|
export function getProvider(name) {
|
||||||
|
return providers.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all registered provider names.
|
||||||
|
* @returns {string[]}
|
||||||
|
*/
|
||||||
|
export function getAllProviders() {
|
||||||
|
return Array.from(providers.keys());
|
||||||
|
}
|
||||||
119
server/providers/types.js
Normal file
119
server/providers/types.js
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/**
|
||||||
|
* Provider Types & Interface
|
||||||
|
*
|
||||||
|
* Defines the normalized message format and the provider adapter interface.
|
||||||
|
* All providers normalize their native formats into NormalizedMessage
|
||||||
|
* before sending over REST or WebSocket.
|
||||||
|
*
|
||||||
|
* @module providers/types
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ─── Session Provider ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {'claude' | 'cursor' | 'codex' | 'gemini'} SessionProvider
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ─── Message Kind ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {'text' | 'tool_use' | 'tool_result' | 'thinking' | 'stream_delta' | 'stream_end'
|
||||||
|
* | 'error' | 'complete' | 'status' | 'permission_request' | 'permission_cancelled'
|
||||||
|
* | 'session_created' | 'interactive_prompt' | 'task_notification'} MessageKind
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ─── NormalizedMessage ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} NormalizedMessage
|
||||||
|
* @property {string} id - Unique message id (for dedup between server + realtime)
|
||||||
|
* @property {string} sessionId
|
||||||
|
* @property {string} timestamp - ISO 8601
|
||||||
|
* @property {SessionProvider} provider
|
||||||
|
* @property {MessageKind} kind
|
||||||
|
*
|
||||||
|
* Additional fields depending on kind:
|
||||||
|
* - text: role ('user'|'assistant'), content, images?
|
||||||
|
* - tool_use: toolName, toolInput, toolId
|
||||||
|
* - tool_result: toolId, content, isError
|
||||||
|
* - thinking: content
|
||||||
|
* - stream_delta: content
|
||||||
|
* - stream_end: (no extra fields)
|
||||||
|
* - error: content
|
||||||
|
* - complete: (no extra fields)
|
||||||
|
* - status: text, tokens?, canInterrupt?
|
||||||
|
* - permission_request: requestId, toolName, input, context?
|
||||||
|
* - permission_cancelled: requestId
|
||||||
|
* - session_created: newSessionId
|
||||||
|
* - interactive_prompt: content
|
||||||
|
* - task_notification: status, summary
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ─── Fetch History ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} FetchHistoryOptions
|
||||||
|
* @property {string} [projectName] - Project name (required for Claude)
|
||||||
|
* @property {string} [projectPath] - Absolute project path (required for Cursor cwdId hash)
|
||||||
|
* @property {number|null} [limit] - Page size (null = all messages)
|
||||||
|
* @property {number} [offset] - Pagination offset (default: 0)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} FetchHistoryResult
|
||||||
|
* @property {NormalizedMessage[]} messages - Normalized messages
|
||||||
|
* @property {number} total - Total number of messages in the session
|
||||||
|
* @property {boolean} hasMore - Whether more messages exist before the current page
|
||||||
|
* @property {number} offset - Current offset
|
||||||
|
* @property {number|null} limit - Page size used
|
||||||
|
* @property {object} [tokenUsage] - Token usage data (provider-specific)
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ─── Provider Adapter Interface ──────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Every provider adapter MUST implement this interface.
|
||||||
|
*
|
||||||
|
* @typedef {Object} ProviderAdapter
|
||||||
|
*
|
||||||
|
* @property {(sessionId: string, opts?: FetchHistoryOptions) => Promise<FetchHistoryResult>} fetchHistory
|
||||||
|
* Read persisted session messages from disk/database and return them as NormalizedMessage[].
|
||||||
|
* The backend calls this from the unified GET /api/sessions/:id/messages endpoint.
|
||||||
|
*
|
||||||
|
* Provider implementations:
|
||||||
|
* - Claude: reads ~/.claude/projects/{projectName}/*.jsonl
|
||||||
|
* - Cursor: reads from SQLite store.db (via normalizeCursorBlobs helper)
|
||||||
|
* - Codex: reads ~/.codex/sessions/*.jsonl
|
||||||
|
* - Gemini: reads from in-memory sessionManager or ~/.gemini/tmp/ JSON files
|
||||||
|
*
|
||||||
|
* @property {(raw: any, sessionId: string) => NormalizedMessage[]} normalizeMessage
|
||||||
|
* Normalize a provider-specific event (JSONL entry or live SDK event) into NormalizedMessage[].
|
||||||
|
* Used by provider files to convert both history and realtime events.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ─── Runtime Helpers ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a unique message ID.
|
||||||
|
* Uses crypto.randomUUID() to avoid collisions across server restarts and workers.
|
||||||
|
* @param {string} [prefix='msg'] - Optional prefix
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
export function generateMessageId(prefix = 'msg') {
|
||||||
|
return `${prefix}_${crypto.randomUUID()}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a NormalizedMessage with common fields pre-filled.
|
||||||
|
* @param {Partial<NormalizedMessage> & {kind: MessageKind, provider: SessionProvider}} fields
|
||||||
|
* @returns {NormalizedMessage}
|
||||||
|
*/
|
||||||
|
export function createNormalizedMessage(fields) {
|
||||||
|
return {
|
||||||
|
...fields,
|
||||||
|
id: fields.id || generateMessageId(fields.kind),
|
||||||
|
sessionId: fields.sessionId || '',
|
||||||
|
timestamp: fields.timestamp || new Date().toISOString(),
|
||||||
|
provider: fields.provider,
|
||||||
|
};
|
||||||
|
}
|
||||||
29
server/providers/utils.js
Normal file
29
server/providers/utils.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* Shared provider utilities.
|
||||||
|
*
|
||||||
|
* @module providers/utils
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefixes that indicate internal/system content which should be hidden from the UI.
|
||||||
|
* @type {readonly string[]}
|
||||||
|
*/
|
||||||
|
export const INTERNAL_CONTENT_PREFIXES = Object.freeze([
|
||||||
|
'<command-name>',
|
||||||
|
'<command-message>',
|
||||||
|
'<command-args>',
|
||||||
|
'<local-command-stdout>',
|
||||||
|
'<system-reminder>',
|
||||||
|
'Caveat:',
|
||||||
|
'This session is being continued from a previous',
|
||||||
|
'[Request interrupted',
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if user text content is internal/system that should be skipped.
|
||||||
|
* @param {string} content
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export function isInternalContent(content) {
|
||||||
|
return INTERNAL_CONTENT_PREFIXES.some(prefix => content.startsWith(prefix));
|
||||||
|
}
|
||||||
@@ -475,7 +475,6 @@ class SSEStreamWriter {
|
|||||||
|
|
||||||
setSessionId(sessionId) {
|
setSessionId(sessionId) {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
this.send({ type: 'session-id', sessionId });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getSessionId() {
|
getSessionId() {
|
||||||
@@ -840,7 +839,7 @@ class ResponseCollector {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
router.post('/', validateExternalApiKey, async (req, res) => {
|
router.post('/', validateExternalApiKey, async (req, res) => {
|
||||||
const { githubUrl, projectPath, message, provider = 'claude', model, githubToken, branchName, sessionId } = req.body;
|
const { githubUrl, projectPath, message, provider = 'claude', model, githubToken, branchName } = req.body;
|
||||||
|
|
||||||
// Parse stream and cleanup as booleans (handle string "true"/"false" from curl)
|
// Parse stream and cleanup as booleans (handle string "true"/"false" from curl)
|
||||||
const stream = req.body.stream === undefined ? true : (req.body.stream === true || req.body.stream === 'true');
|
const stream = req.body.stream === undefined ? true : (req.body.stream === true || req.body.stream === 'true');
|
||||||
@@ -876,8 +875,9 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
|||||||
// Determine the final project path
|
// Determine the final project path
|
||||||
if (githubUrl) {
|
if (githubUrl) {
|
||||||
// Clone repository (to projectPath if provided, otherwise generate path)
|
// Clone repository (to projectPath if provided, otherwise generate path)
|
||||||
|
// TODO: use credinitalsDB when refactoring
|
||||||
const tokenToUse = githubToken || githubTokensDb.getActiveGithubToken(req.user.id);
|
const tokenToUse = githubToken || githubTokensDb.getActiveGithubToken(req.user.id);
|
||||||
|
|
||||||
let targetPath;
|
let targetPath;
|
||||||
if (projectPath) {
|
if (projectPath) {
|
||||||
targetPath = projectPath;
|
targetPath = projectPath;
|
||||||
@@ -950,7 +950,7 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
|||||||
await queryClaudeSDK(message.trim(), {
|
await queryClaudeSDK(message.trim(), {
|
||||||
projectPath: finalProjectPath,
|
projectPath: finalProjectPath,
|
||||||
cwd: finalProjectPath,
|
cwd: finalProjectPath,
|
||||||
sessionId: sessionId || null,
|
sessionId: null, // New session
|
||||||
model: model,
|
model: model,
|
||||||
permissionMode: 'bypassPermissions' // Bypass all permissions for API calls
|
permissionMode: 'bypassPermissions' // Bypass all permissions for API calls
|
||||||
}, writer);
|
}, writer);
|
||||||
@@ -961,7 +961,7 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
|||||||
await spawnCursor(message.trim(), {
|
await spawnCursor(message.trim(), {
|
||||||
projectPath: finalProjectPath,
|
projectPath: finalProjectPath,
|
||||||
cwd: finalProjectPath,
|
cwd: finalProjectPath,
|
||||||
sessionId: sessionId || null,
|
sessionId: null, // New session
|
||||||
model: model || undefined,
|
model: model || undefined,
|
||||||
skipPermissions: true // Bypass permissions for Cursor
|
skipPermissions: true // Bypass permissions for Cursor
|
||||||
}, writer);
|
}, writer);
|
||||||
@@ -971,7 +971,7 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
|||||||
await queryCodex(message.trim(), {
|
await queryCodex(message.trim(), {
|
||||||
projectPath: finalProjectPath,
|
projectPath: finalProjectPath,
|
||||||
cwd: finalProjectPath,
|
cwd: finalProjectPath,
|
||||||
sessionId: sessionId || null,
|
sessionId: null,
|
||||||
model: model || CODEX_MODELS.DEFAULT,
|
model: model || CODEX_MODELS.DEFAULT,
|
||||||
permissionMode: 'bypassPermissions'
|
permissionMode: 'bypassPermissions'
|
||||||
}, writer);
|
}, writer);
|
||||||
@@ -981,7 +981,7 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
|||||||
await spawnGemini(message.trim(), {
|
await spawnGemini(message.trim(), {
|
||||||
projectPath: finalProjectPath,
|
projectPath: finalProjectPath,
|
||||||
cwd: finalProjectPath,
|
cwd: finalProjectPath,
|
||||||
sessionId: sessionId || null,
|
sessionId: null,
|
||||||
model: model,
|
model: model,
|
||||||
skipPermissions: true // CLI mode bypasses permissions
|
skipPermissions: true // CLI mode bypasses permissions
|
||||||
}, writer);
|
}, writer);
|
||||||
@@ -996,6 +996,7 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
|||||||
console.log('🔄 Starting GitHub branch/PR creation workflow...');
|
console.log('🔄 Starting GitHub branch/PR creation workflow...');
|
||||||
|
|
||||||
// Get GitHub token
|
// Get GitHub token
|
||||||
|
// TODO: use credinitalsDB when refactoring
|
||||||
const tokenToUse = githubToken || githubTokensDb.getActiveGithubToken(req.user.id);
|
const tokenToUse = githubToken || githubTokensDb.getActiveGithubToken(req.user.id);
|
||||||
|
|
||||||
if (!tokenToUse) {
|
if (!tokenToUse) {
|
||||||
@@ -1125,7 +1126,7 @@ router.post('/', validateExternalApiKey, async (req, res) => {
|
|||||||
} else {
|
} else {
|
||||||
prBody += `Agent task: ${message}`;
|
prBody += `Agent task: ${message}`;
|
||||||
}
|
}
|
||||||
prBody += '\n\n---\n*This pull request was automatically created by CloudCLI.ai Agent.*';
|
prBody += '\n\n---\n*This pull request was automatically created by Claude Code UI Agent.*';
|
||||||
|
|
||||||
console.log(`📝 PR Title: ${prTitle}`);
|
console.log(`📝 PR Title: ${prTitle}`);
|
||||||
|
|
||||||
|
|||||||
434
server/routes/cli-auth.js
Normal file
434
server/routes/cli-auth.js
Normal file
@@ -0,0 +1,434 @@
|
|||||||
|
import express from 'express';
|
||||||
|
import { spawn } from 'child_process';
|
||||||
|
import fs from 'fs/promises';
|
||||||
|
import path from 'path';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.get('/claude/status', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const credentialsResult = await checkClaudeCredentials();
|
||||||
|
|
||||||
|
if (credentialsResult.authenticated) {
|
||||||
|
return res.json({
|
||||||
|
authenticated: true,
|
||||||
|
email: credentialsResult.email || 'Authenticated',
|
||||||
|
method: credentialsResult.method // 'api_key' or 'credentials_file'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.json({
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
method: null,
|
||||||
|
error: credentialsResult.error || 'Not authenticated'
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error checking Claude auth status:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
method: null,
|
||||||
|
error: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/cursor/status', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const result = await checkCursorStatus();
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
authenticated: result.authenticated,
|
||||||
|
email: result.email,
|
||||||
|
error: result.error
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error checking Cursor auth status:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/codex/status', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const result = await checkCodexCredentials();
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
authenticated: result.authenticated,
|
||||||
|
email: result.email,
|
||||||
|
error: result.error
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error checking Codex auth status:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/gemini/status', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const result = await checkGeminiCredentials();
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
authenticated: result.authenticated,
|
||||||
|
email: result.email,
|
||||||
|
error: result.error
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error checking Gemini auth status:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
async function loadClaudeSettingsEnv() {
|
||||||
|
try {
|
||||||
|
const settingsPath = path.join(os.homedir(), '.claude', 'settings.json');
|
||||||
|
const content = await fs.readFile(settingsPath, 'utf8');
|
||||||
|
const settings = JSON.parse(content);
|
||||||
|
|
||||||
|
if (settings?.env && typeof settings.env === 'object') {
|
||||||
|
return settings.env;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// Ignore missing or malformed settings and fall back to other auth sources.
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks Claude authentication credentials using two methods with priority order:
|
||||||
|
*
|
||||||
|
* Priority 1: ANTHROPIC_API_KEY environment variable
|
||||||
|
* Priority 1b: ~/.claude/settings.json env values
|
||||||
|
* Priority 2: ~/.claude/.credentials.json OAuth tokens
|
||||||
|
*
|
||||||
|
* The Claude Agent SDK prioritizes environment variables over authenticated subscriptions.
|
||||||
|
* This matching behavior ensures consistency with how the SDK authenticates.
|
||||||
|
*
|
||||||
|
* References:
|
||||||
|
* - https://support.claude.com/en/articles/12304248-managing-api-key-environment-variables-in-claude-code
|
||||||
|
* "Claude Code prioritizes environment variable API keys over authenticated subscriptions"
|
||||||
|
* - https://platform.claude.com/docs/en/agent-sdk/overview
|
||||||
|
* SDK authentication documentation
|
||||||
|
*
|
||||||
|
* @returns {Promise<Object>} Authentication status with { authenticated, email, method }
|
||||||
|
* - authenticated: boolean indicating if valid credentials exist
|
||||||
|
* - email: user email or auth method identifier
|
||||||
|
* - method: 'api_key' for env var, 'credentials_file' for OAuth tokens
|
||||||
|
*/
|
||||||
|
async function checkClaudeCredentials() {
|
||||||
|
// Priority 1: Check for ANTHROPIC_API_KEY environment variable
|
||||||
|
// The SDK checks this first and uses it if present, even if OAuth tokens exist.
|
||||||
|
// When set, API calls are charged via pay-as-you-go rates instead of subscription.
|
||||||
|
if (process.env.ANTHROPIC_API_KEY && process.env.ANTHROPIC_API_KEY.trim()) {
|
||||||
|
return {
|
||||||
|
authenticated: true,
|
||||||
|
email: 'API Key Auth',
|
||||||
|
method: 'api_key'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Priority 1b: Check ~/.claude/settings.json env values.
|
||||||
|
// Claude Code can read proxy/auth values from settings.json even when the
|
||||||
|
// CloudCLI server process itself was not started with those env vars exported.
|
||||||
|
const settingsEnv = await loadClaudeSettingsEnv();
|
||||||
|
|
||||||
|
if (typeof settingsEnv.ANTHROPIC_API_KEY === 'string' && settingsEnv.ANTHROPIC_API_KEY.trim()) {
|
||||||
|
return {
|
||||||
|
authenticated: true,
|
||||||
|
email: 'API Key Auth',
|
||||||
|
method: 'api_key'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof settingsEnv.ANTHROPIC_AUTH_TOKEN === 'string' && settingsEnv.ANTHROPIC_AUTH_TOKEN.trim()) {
|
||||||
|
return {
|
||||||
|
authenticated: true,
|
||||||
|
email: 'Configured via settings.json',
|
||||||
|
method: 'api_key'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Priority 2: Check ~/.claude/.credentials.json for OAuth tokens
|
||||||
|
// This is the standard authentication method used by Claude CLI after running
|
||||||
|
// 'claude /login' or 'claude setup-token' commands.
|
||||||
|
try {
|
||||||
|
const credPath = path.join(os.homedir(), '.claude', '.credentials.json');
|
||||||
|
const content = await fs.readFile(credPath, 'utf8');
|
||||||
|
const creds = JSON.parse(content);
|
||||||
|
|
||||||
|
const oauth = creds.claudeAiOauth;
|
||||||
|
if (oauth && oauth.accessToken) {
|
||||||
|
const isExpired = oauth.expiresAt && Date.now() >= oauth.expiresAt;
|
||||||
|
|
||||||
|
if (!isExpired) {
|
||||||
|
return {
|
||||||
|
authenticated: true,
|
||||||
|
email: creds.email || creds.user || null,
|
||||||
|
method: 'credentials_file'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
method: null
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
method: null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkCursorStatus() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
let processCompleted = false;
|
||||||
|
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
if (!processCompleted) {
|
||||||
|
processCompleted = true;
|
||||||
|
if (childProcess) {
|
||||||
|
childProcess.kill();
|
||||||
|
}
|
||||||
|
resolve({
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'Command timeout'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
let childProcess;
|
||||||
|
try {
|
||||||
|
childProcess = spawn('cursor-agent', ['status']);
|
||||||
|
} catch (err) {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
processCompleted = true;
|
||||||
|
resolve({
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'Cursor CLI not found or not installed'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
childProcess.stdout.on('data', (data) => {
|
||||||
|
stdout += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
childProcess.stderr.on('data', (data) => {
|
||||||
|
stderr += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
childProcess.on('close', (code) => {
|
||||||
|
if (processCompleted) return;
|
||||||
|
processCompleted = true;
|
||||||
|
clearTimeout(timeout);
|
||||||
|
|
||||||
|
if (code === 0) {
|
||||||
|
const emailMatch = stdout.match(/Logged in as ([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/i);
|
||||||
|
|
||||||
|
if (emailMatch) {
|
||||||
|
resolve({
|
||||||
|
authenticated: true,
|
||||||
|
email: emailMatch[1],
|
||||||
|
output: stdout
|
||||||
|
});
|
||||||
|
} else if (stdout.includes('Logged in')) {
|
||||||
|
resolve({
|
||||||
|
authenticated: true,
|
||||||
|
email: 'Logged in',
|
||||||
|
output: stdout
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resolve({
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'Not logged in'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolve({
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: stderr || 'Not logged in'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
childProcess.on('error', (err) => {
|
||||||
|
if (processCompleted) return;
|
||||||
|
processCompleted = true;
|
||||||
|
clearTimeout(timeout);
|
||||||
|
|
||||||
|
resolve({
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'Cursor CLI not found or not installed'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkCodexCredentials() {
|
||||||
|
try {
|
||||||
|
const authPath = path.join(os.homedir(), '.codex', 'auth.json');
|
||||||
|
const content = await fs.readFile(authPath, 'utf8');
|
||||||
|
const auth = JSON.parse(content);
|
||||||
|
|
||||||
|
// Tokens are nested under 'tokens' key
|
||||||
|
const tokens = auth.tokens || {};
|
||||||
|
|
||||||
|
// Check for valid tokens (id_token or access_token)
|
||||||
|
if (tokens.id_token || tokens.access_token) {
|
||||||
|
// Try to extract email from id_token JWT payload
|
||||||
|
let email = 'Authenticated';
|
||||||
|
if (tokens.id_token) {
|
||||||
|
try {
|
||||||
|
// JWT is base64url encoded: header.payload.signature
|
||||||
|
const parts = tokens.id_token.split('.');
|
||||||
|
if (parts.length >= 2) {
|
||||||
|
// Decode the payload (second part)
|
||||||
|
const payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString('utf8'));
|
||||||
|
email = payload.email || payload.user || 'Authenticated';
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// If JWT decoding fails, use fallback
|
||||||
|
email = 'Authenticated';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
authenticated: true,
|
||||||
|
email
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also check for OPENAI_API_KEY as fallback auth method
|
||||||
|
if (auth.OPENAI_API_KEY) {
|
||||||
|
return {
|
||||||
|
authenticated: true,
|
||||||
|
email: 'API Key Auth'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'No valid tokens found'
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code === 'ENOENT') {
|
||||||
|
return {
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'Codex not configured'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: error.message
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkGeminiCredentials() {
|
||||||
|
if (process.env.GEMINI_API_KEY && process.env.GEMINI_API_KEY.trim()) {
|
||||||
|
return {
|
||||||
|
authenticated: true,
|
||||||
|
email: 'API Key Auth'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const credsPath = path.join(os.homedir(), '.gemini', 'oauth_creds.json');
|
||||||
|
const content = await fs.readFile(credsPath, 'utf8');
|
||||||
|
const creds = JSON.parse(content);
|
||||||
|
|
||||||
|
if (creds.access_token) {
|
||||||
|
let email = 'OAuth Session';
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Validate token against Google API
|
||||||
|
const tokenRes = await fetch(`https://oauth2.googleapis.com/tokeninfo?access_token=${creds.access_token}`);
|
||||||
|
if (tokenRes.ok) {
|
||||||
|
const tokenInfo = await tokenRes.json();
|
||||||
|
if (tokenInfo.email) {
|
||||||
|
email = tokenInfo.email;
|
||||||
|
}
|
||||||
|
} else if (!creds.refresh_token) {
|
||||||
|
// Token invalid and no refresh token available
|
||||||
|
return {
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'Access token invalid and no refresh token found'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// Token might be expired but we have a refresh token, so CLI will refresh it
|
||||||
|
try {
|
||||||
|
const accPath = path.join(os.homedir(), '.gemini', 'google_accounts.json');
|
||||||
|
const accContent = await fs.readFile(accPath, 'utf8');
|
||||||
|
const accounts = JSON.parse(accContent);
|
||||||
|
if (accounts.active) {
|
||||||
|
email = accounts.active;
|
||||||
|
}
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Network error, fallback to checking local accounts file
|
||||||
|
try {
|
||||||
|
const accPath = path.join(os.homedir(), '.gemini', 'google_accounts.json');
|
||||||
|
const accContent = await fs.readFile(accPath, 'utf8');
|
||||||
|
const accounts = JSON.parse(accContent);
|
||||||
|
if (accounts.active) {
|
||||||
|
email = accounts.active;
|
||||||
|
}
|
||||||
|
} catch (err) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
authenticated: true,
|
||||||
|
email: email
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'No valid tokens found in oauth_creds'
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'Gemini CLI not configured'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default router;
|
||||||
@@ -1,9 +1,73 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { deleteCodexSession } from '../projects.js';
|
import { spawn } from 'child_process';
|
||||||
import { sessionNamesDb } from '../database/db.js';
|
import { promises as fs } from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import os from 'os';
|
||||||
|
import TOML from '@iarna/toml';
|
||||||
|
import { getCodexSessions, deleteCodexSession } from '../projects.js';
|
||||||
|
import { applyCustomSessionNames, sessionNamesDb } from '../database/db.js';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
function createCliResponder(res) {
|
||||||
|
let responded = false;
|
||||||
|
return (status, payload) => {
|
||||||
|
if (responded || res.headersSent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
responded = true;
|
||||||
|
res.status(status).json(payload);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
router.get('/config', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const configPath = path.join(os.homedir(), '.codex', 'config.toml');
|
||||||
|
const content = await fs.readFile(configPath, 'utf8');
|
||||||
|
const config = TOML.parse(content);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
config: {
|
||||||
|
model: config.model || null,
|
||||||
|
mcpServers: config.mcp_servers || {},
|
||||||
|
approvalMode: config.approval_mode || 'suggest'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code === 'ENOENT') {
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
config: {
|
||||||
|
model: null,
|
||||||
|
mcpServers: {},
|
||||||
|
approvalMode: 'suggest'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error('Error reading Codex config:', error);
|
||||||
|
res.status(500).json({ success: false, error: error.message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/sessions', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { projectPath } = req.query;
|
||||||
|
|
||||||
|
if (!projectPath) {
|
||||||
|
return res.status(400).json({ success: false, error: 'projectPath query parameter required' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const sessions = await getCodexSessions(projectPath);
|
||||||
|
applyCustomSessionNames(sessions, 'codex');
|
||||||
|
res.json({ success: true, sessions });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching Codex sessions:', error);
|
||||||
|
res.status(500).json({ success: false, error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
router.delete('/sessions/:sessionId', async (req, res) => {
|
router.delete('/sessions/:sessionId', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { sessionId } = req.params;
|
const { sessionId } = req.params;
|
||||||
@@ -16,4 +80,250 @@ router.delete('/sessions/:sessionId', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// MCP Server Management Routes
|
||||||
|
|
||||||
|
router.get('/mcp/cli/list', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const respond = createCliResponder(res);
|
||||||
|
const proc = spawn('codex', ['mcp', 'list'], { stdio: ['pipe', 'pipe', 'pipe'] });
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
proc.stdout?.on('data', (data) => { stdout += data.toString(); });
|
||||||
|
proc.stderr?.on('data', (data) => { stderr += data.toString(); });
|
||||||
|
|
||||||
|
proc.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
respond(200, { success: true, output: stdout, servers: parseCodexListOutput(stdout) });
|
||||||
|
} else {
|
||||||
|
respond(500, { error: 'Codex CLI command failed', details: stderr || `Exited with code ${code}` });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
proc.on('error', (error) => {
|
||||||
|
const isMissing = error?.code === 'ENOENT';
|
||||||
|
respond(isMissing ? 503 : 500, {
|
||||||
|
error: isMissing ? 'Codex CLI not installed' : 'Failed to run Codex CLI',
|
||||||
|
details: error.message,
|
||||||
|
code: error.code
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Failed to list MCP servers', details: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.post('/mcp/cli/add', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { name, command, args = [], env = {} } = req.body;
|
||||||
|
|
||||||
|
if (!name || !command) {
|
||||||
|
return res.status(400).json({ error: 'name and command are required' });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build: codex mcp add <name> [-e KEY=VAL]... -- <command> [args...]
|
||||||
|
let cliArgs = ['mcp', 'add', name];
|
||||||
|
|
||||||
|
Object.entries(env).forEach(([key, value]) => {
|
||||||
|
cliArgs.push('-e', `${key}=${value}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
cliArgs.push('--', command);
|
||||||
|
|
||||||
|
if (args && args.length > 0) {
|
||||||
|
cliArgs.push(...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
const respond = createCliResponder(res);
|
||||||
|
const proc = spawn('codex', cliArgs, { stdio: ['pipe', 'pipe', 'pipe'] });
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
proc.stdout?.on('data', (data) => { stdout += data.toString(); });
|
||||||
|
proc.stderr?.on('data', (data) => { stderr += data.toString(); });
|
||||||
|
|
||||||
|
proc.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
respond(200, { success: true, output: stdout, message: `MCP server "${name}" added successfully` });
|
||||||
|
} else {
|
||||||
|
respond(400, { error: 'Codex CLI command failed', details: stderr || `Exited with code ${code}` });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
proc.on('error', (error) => {
|
||||||
|
const isMissing = error?.code === 'ENOENT';
|
||||||
|
respond(isMissing ? 503 : 500, {
|
||||||
|
error: isMissing ? 'Codex CLI not installed' : 'Failed to run Codex CLI',
|
||||||
|
details: error.message,
|
||||||
|
code: error.code
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Failed to add MCP server', details: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.delete('/mcp/cli/remove/:name', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { name } = req.params;
|
||||||
|
|
||||||
|
const respond = createCliResponder(res);
|
||||||
|
const proc = spawn('codex', ['mcp', 'remove', name], { stdio: ['pipe', 'pipe', 'pipe'] });
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
proc.stdout?.on('data', (data) => { stdout += data.toString(); });
|
||||||
|
proc.stderr?.on('data', (data) => { stderr += data.toString(); });
|
||||||
|
|
||||||
|
proc.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
respond(200, { success: true, output: stdout, message: `MCP server "${name}" removed successfully` });
|
||||||
|
} else {
|
||||||
|
respond(400, { error: 'Codex CLI command failed', details: stderr || `Exited with code ${code}` });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
proc.on('error', (error) => {
|
||||||
|
const isMissing = error?.code === 'ENOENT';
|
||||||
|
respond(isMissing ? 503 : 500, {
|
||||||
|
error: isMissing ? 'Codex CLI not installed' : 'Failed to run Codex CLI',
|
||||||
|
details: error.message,
|
||||||
|
code: error.code
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Failed to remove MCP server', details: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/mcp/cli/get/:name', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { name } = req.params;
|
||||||
|
|
||||||
|
const respond = createCliResponder(res);
|
||||||
|
const proc = spawn('codex', ['mcp', 'get', name], { stdio: ['pipe', 'pipe', 'pipe'] });
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
proc.stdout?.on('data', (data) => { stdout += data.toString(); });
|
||||||
|
proc.stderr?.on('data', (data) => { stderr += data.toString(); });
|
||||||
|
|
||||||
|
proc.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
respond(200, { success: true, output: stdout, server: parseCodexGetOutput(stdout) });
|
||||||
|
} else {
|
||||||
|
respond(404, { error: 'Codex CLI command failed', details: stderr || `Exited with code ${code}` });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
proc.on('error', (error) => {
|
||||||
|
const isMissing = error?.code === 'ENOENT';
|
||||||
|
respond(isMissing ? 503 : 500, {
|
||||||
|
error: isMissing ? 'Codex CLI not installed' : 'Failed to run Codex CLI',
|
||||||
|
details: error.message,
|
||||||
|
code: error.code
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Failed to get MCP server details', details: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/mcp/config/read', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const configPath = path.join(os.homedir(), '.codex', 'config.toml');
|
||||||
|
|
||||||
|
let configData = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const fileContent = await fs.readFile(configPath, 'utf8');
|
||||||
|
configData = TOML.parse(fileContent);
|
||||||
|
} catch (error) {
|
||||||
|
// Config file doesn't exist
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!configData) {
|
||||||
|
return res.json({ success: true, configPath, servers: [] }); }
|
||||||
|
|
||||||
|
const servers = [];
|
||||||
|
|
||||||
|
if (configData.mcp_servers && typeof configData.mcp_servers === 'object') {
|
||||||
|
for (const [name, config] of Object.entries(configData.mcp_servers)) {
|
||||||
|
servers.push({
|
||||||
|
id: name,
|
||||||
|
name: name,
|
||||||
|
type: 'stdio',
|
||||||
|
scope: 'user',
|
||||||
|
config: {
|
||||||
|
command: config.command || '',
|
||||||
|
args: config.args || [],
|
||||||
|
env: config.env || {}
|
||||||
|
},
|
||||||
|
raw: config
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({ success: true, configPath, servers });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Failed to read Codex configuration', details: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function parseCodexListOutput(output) {
|
||||||
|
const servers = [];
|
||||||
|
const lines = output.split('\n').filter(line => line.trim());
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.includes(':')) {
|
||||||
|
const colonIndex = line.indexOf(':');
|
||||||
|
const name = line.substring(0, colonIndex).trim();
|
||||||
|
|
||||||
|
if (!name) continue;
|
||||||
|
|
||||||
|
const rest = line.substring(colonIndex + 1).trim();
|
||||||
|
let description = rest;
|
||||||
|
let status = 'unknown';
|
||||||
|
|
||||||
|
if (rest.includes('✓') || rest.includes('✗')) {
|
||||||
|
const statusMatch = rest.match(/(.*?)\s*-\s*([✓✗].*)$/);
|
||||||
|
if (statusMatch) {
|
||||||
|
description = statusMatch[1].trim();
|
||||||
|
status = statusMatch[2].includes('✓') ? 'connected' : 'failed';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
servers.push({ name, type: 'stdio', status, description });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseCodexGetOutput(output) {
|
||||||
|
try {
|
||||||
|
const jsonMatch = output.match(/\{[\s\S]*\}/);
|
||||||
|
if (jsonMatch) {
|
||||||
|
return JSON.parse(jsonMatch[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const server = { raw_output: output };
|
||||||
|
const lines = output.split('\n');
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.includes('Name:')) server.name = line.split(':')[1]?.trim();
|
||||||
|
else if (line.includes('Type:')) server.type = line.split(':')[1]?.trim();
|
||||||
|
else if (line.includes('Command:')) server.command = line.split(':')[1]?.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
return server;
|
||||||
|
} catch (error) {
|
||||||
|
return { raw_output: output, parse_error: error.message };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import { CLAUDE_MODELS, CURSOR_MODELS, CODEX_MODELS } from '../../shared/modelConstants.js';
|
import { CLAUDE_MODELS, CURSOR_MODELS, CODEX_MODELS } from '../../shared/modelConstants.js';
|
||||||
import { parseFrontmatter } from '../utils/frontmatter.js';
|
import { parseFrontmatter } from '../utils/frontmatter.js';
|
||||||
import { findAppRoot, getModuleDir } from '../utils/runtime-paths.js';
|
|
||||||
|
|
||||||
const __dirname = getModuleDir(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
// This route reads the top-level package.json for the status command, so it needs the real
|
const __dirname = path.dirname(__filename);
|
||||||
// app root even after compilation moves the route file under dist-server/server/routes.
|
|
||||||
const APP_ROOT = findAppRoot(__dirname);
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
@@ -293,7 +291,7 @@ Custom commands can be created in:
|
|||||||
|
|
||||||
'/status': async (args, context) => {
|
'/status': async (args, context) => {
|
||||||
// Read version from package.json
|
// Read version from package.json
|
||||||
const packageJsonPath = path.join(APP_ROOT, 'package.json');
|
const packageJsonPath = path.join(path.dirname(__dirname), '..', 'package.json');
|
||||||
let version = 'unknown';
|
let version = 'unknown';
|
||||||
let packageName = 'claude-code-ui';
|
let packageName = 'claude-code-ui';
|
||||||
|
|
||||||
@@ -451,6 +449,55 @@ router.post('/list', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/commands/load
|
||||||
|
* Load a specific command file and return its content and metadata
|
||||||
|
*/
|
||||||
|
router.post('/load', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { commandPath } = req.body;
|
||||||
|
|
||||||
|
if (!commandPath) {
|
||||||
|
return res.status(400).json({
|
||||||
|
error: 'Command path is required'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Security: Prevent path traversal
|
||||||
|
const resolvedPath = path.resolve(commandPath);
|
||||||
|
if (!resolvedPath.startsWith(path.resolve(os.homedir())) &&
|
||||||
|
!resolvedPath.includes('.claude/commands')) {
|
||||||
|
return res.status(403).json({
|
||||||
|
error: 'Access denied',
|
||||||
|
message: 'Command must be in .claude/commands directory'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read and parse the command file
|
||||||
|
const content = await fs.readFile(commandPath, 'utf8');
|
||||||
|
const { data: metadata, content: commandContent } = parseFrontmatter(content);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
path: commandPath,
|
||||||
|
metadata,
|
||||||
|
content: commandContent
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code === 'ENOENT') {
|
||||||
|
return res.status(404).json({
|
||||||
|
error: 'Command not found',
|
||||||
|
message: `Command file not found: ${req.body.commandPath}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error('Error loading command:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to load command',
|
||||||
|
message: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /api/commands/execute
|
* POST /api/commands/execute
|
||||||
* Execute a command with argument replacement
|
* Execute a command with argument replacement
|
||||||
|
|||||||
@@ -2,7 +2,12 @@ import express from 'express';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
import { spawn } from 'child_process';
|
||||||
|
import sqlite3 from 'sqlite3';
|
||||||
|
import { open } from 'sqlite';
|
||||||
|
import crypto from 'crypto';
|
||||||
import { CURSOR_MODELS } from '../../shared/modelConstants.js';
|
import { CURSOR_MODELS } from '../../shared/modelConstants.js';
|
||||||
|
import { applyCustomSessionNames } from '../database/db.js';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
@@ -10,20 +15,20 @@ const router = express.Router();
|
|||||||
router.get('/config', async (req, res) => {
|
router.get('/config', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const configPath = path.join(os.homedir(), '.cursor', 'cli-config.json');
|
const configPath = path.join(os.homedir(), '.cursor', 'cli-config.json');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const configContent = await fs.readFile(configPath, 'utf8');
|
const configContent = await fs.readFile(configPath, 'utf8');
|
||||||
const config = JSON.parse(configContent);
|
const config = JSON.parse(configContent);
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
config,
|
config: config,
|
||||||
path: configPath,
|
path: configPath
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Config doesn't exist or is invalid
|
// Config doesn't exist or is invalid
|
||||||
console.log('Cursor config not found or invalid:', error.message);
|
console.log('Cursor config not found or invalid:', error.message);
|
||||||
|
|
||||||
// Return default config
|
// Return default config
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
@@ -31,23 +36,763 @@ router.get('/config', async (req, res) => {
|
|||||||
version: 1,
|
version: 1,
|
||||||
model: {
|
model: {
|
||||||
modelId: CURSOR_MODELS.DEFAULT,
|
modelId: CURSOR_MODELS.DEFAULT,
|
||||||
displayName: 'GPT-5',
|
displayName: "GPT-5"
|
||||||
},
|
},
|
||||||
permissions: {
|
permissions: {
|
||||||
allow: [],
|
allow: [],
|
||||||
deny: [],
|
deny: []
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
isDefault: true,
|
isDefault: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error reading Cursor config:', error);
|
console.error('Error reading Cursor config:', error);
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
error: 'Failed to read Cursor configuration',
|
error: 'Failed to read Cursor configuration',
|
||||||
details: error.message,
|
details: error.message
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
// POST /api/cursor/config - Update Cursor CLI configuration
|
||||||
|
router.post('/config', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { permissions, model } = req.body;
|
||||||
|
const configPath = path.join(os.homedir(), '.cursor', 'cli-config.json');
|
||||||
|
|
||||||
|
// Read existing config or create default
|
||||||
|
let config = {
|
||||||
|
version: 1,
|
||||||
|
editor: {
|
||||||
|
vimMode: false
|
||||||
|
},
|
||||||
|
hasChangedDefaultModel: false,
|
||||||
|
privacyCache: {
|
||||||
|
ghostMode: false,
|
||||||
|
privacyMode: 3,
|
||||||
|
updatedAt: Date.now()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const existing = await fs.readFile(configPath, 'utf8');
|
||||||
|
config = JSON.parse(existing);
|
||||||
|
} catch (error) {
|
||||||
|
// Config doesn't exist, use defaults
|
||||||
|
console.log('Creating new Cursor config');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update permissions if provided
|
||||||
|
if (permissions) {
|
||||||
|
config.permissions = {
|
||||||
|
allow: permissions.allow || [],
|
||||||
|
deny: permissions.deny || []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update model if provided
|
||||||
|
if (model) {
|
||||||
|
config.model = model;
|
||||||
|
config.hasChangedDefaultModel = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure directory exists
|
||||||
|
const configDir = path.dirname(configPath);
|
||||||
|
await fs.mkdir(configDir, { recursive: true });
|
||||||
|
|
||||||
|
// Write updated config
|
||||||
|
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
config: config,
|
||||||
|
message: 'Cursor configuration updated successfully'
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error updating Cursor config:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to update Cursor configuration',
|
||||||
|
details: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GET /api/cursor/mcp - Read Cursor MCP servers configuration
|
||||||
|
router.get('/mcp', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const mcpPath = path.join(os.homedir(), '.cursor', 'mcp.json');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const mcpContent = await fs.readFile(mcpPath, 'utf8');
|
||||||
|
const mcpConfig = JSON.parse(mcpContent);
|
||||||
|
|
||||||
|
// Convert to UI-friendly format
|
||||||
|
const servers = [];
|
||||||
|
if (mcpConfig.mcpServers && typeof mcpConfig.mcpServers === 'object') {
|
||||||
|
for (const [name, config] of Object.entries(mcpConfig.mcpServers)) {
|
||||||
|
const server = {
|
||||||
|
id: name,
|
||||||
|
name: name,
|
||||||
|
type: 'stdio',
|
||||||
|
scope: 'cursor',
|
||||||
|
config: {},
|
||||||
|
raw: config
|
||||||
|
};
|
||||||
|
|
||||||
|
// Determine transport type and extract config
|
||||||
|
if (config.command) {
|
||||||
|
server.type = 'stdio';
|
||||||
|
server.config.command = config.command;
|
||||||
|
server.config.args = config.args || [];
|
||||||
|
server.config.env = config.env || {};
|
||||||
|
} else if (config.url) {
|
||||||
|
server.type = config.transport || 'http';
|
||||||
|
server.config.url = config.url;
|
||||||
|
server.config.headers = config.headers || {};
|
||||||
|
}
|
||||||
|
|
||||||
|
servers.push(server);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
servers: servers,
|
||||||
|
path: mcpPath
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
// MCP config doesn't exist
|
||||||
|
console.log('Cursor MCP config not found:', error.message);
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
servers: [],
|
||||||
|
isDefault: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading Cursor MCP config:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to read Cursor MCP configuration',
|
||||||
|
details: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /api/cursor/mcp/add - Add MCP server to Cursor configuration
|
||||||
|
router.post('/mcp/add', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { name, type = 'stdio', command, args = [], url, headers = {}, env = {} } = req.body;
|
||||||
|
const mcpPath = path.join(os.homedir(), '.cursor', 'mcp.json');
|
||||||
|
|
||||||
|
console.log(`➕ Adding MCP server to Cursor config: ${name}`);
|
||||||
|
|
||||||
|
// Read existing config or create new
|
||||||
|
let mcpConfig = { mcpServers: {} };
|
||||||
|
|
||||||
|
try {
|
||||||
|
const existing = await fs.readFile(mcpPath, 'utf8');
|
||||||
|
mcpConfig = JSON.parse(existing);
|
||||||
|
if (!mcpConfig.mcpServers) {
|
||||||
|
mcpConfig.mcpServers = {};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Creating new Cursor MCP config');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build server config based on type
|
||||||
|
let serverConfig = {};
|
||||||
|
|
||||||
|
if (type === 'stdio') {
|
||||||
|
serverConfig = {
|
||||||
|
command: command,
|
||||||
|
args: args,
|
||||||
|
env: env
|
||||||
|
};
|
||||||
|
} else if (type === 'http' || type === 'sse') {
|
||||||
|
serverConfig = {
|
||||||
|
url: url,
|
||||||
|
transport: type,
|
||||||
|
headers: headers
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add server to config
|
||||||
|
mcpConfig.mcpServers[name] = serverConfig;
|
||||||
|
|
||||||
|
// Ensure directory exists
|
||||||
|
const mcpDir = path.dirname(mcpPath);
|
||||||
|
await fs.mkdir(mcpDir, { recursive: true });
|
||||||
|
|
||||||
|
// Write updated config
|
||||||
|
await fs.writeFile(mcpPath, JSON.stringify(mcpConfig, null, 2));
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: `MCP server "${name}" added to Cursor configuration`,
|
||||||
|
config: mcpConfig
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error adding MCP server to Cursor:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to add MCP server',
|
||||||
|
details: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// DELETE /api/cursor/mcp/:name - Remove MCP server from Cursor configuration
|
||||||
|
router.delete('/mcp/:name', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { name } = req.params;
|
||||||
|
const mcpPath = path.join(os.homedir(), '.cursor', 'mcp.json');
|
||||||
|
|
||||||
|
console.log(`🗑️ Removing MCP server from Cursor config: ${name}`);
|
||||||
|
|
||||||
|
// Read existing config
|
||||||
|
let mcpConfig = { mcpServers: {} };
|
||||||
|
|
||||||
|
try {
|
||||||
|
const existing = await fs.readFile(mcpPath, 'utf8');
|
||||||
|
mcpConfig = JSON.parse(existing);
|
||||||
|
} catch (error) {
|
||||||
|
return res.status(404).json({
|
||||||
|
error: 'Cursor MCP configuration not found'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if server exists
|
||||||
|
if (!mcpConfig.mcpServers || !mcpConfig.mcpServers[name]) {
|
||||||
|
return res.status(404).json({
|
||||||
|
error: `MCP server "${name}" not found in Cursor configuration`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove server from config
|
||||||
|
delete mcpConfig.mcpServers[name];
|
||||||
|
|
||||||
|
// Write updated config
|
||||||
|
await fs.writeFile(mcpPath, JSON.stringify(mcpConfig, null, 2));
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: `MCP server "${name}" removed from Cursor configuration`,
|
||||||
|
config: mcpConfig
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error removing MCP server from Cursor:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to remove MCP server',
|
||||||
|
details: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /api/cursor/mcp/add-json - Add MCP server using JSON format
|
||||||
|
router.post('/mcp/add-json', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { name, jsonConfig } = req.body;
|
||||||
|
const mcpPath = path.join(os.homedir(), '.cursor', 'mcp.json');
|
||||||
|
|
||||||
|
console.log(`➕ Adding MCP server to Cursor config via JSON: ${name}`);
|
||||||
|
|
||||||
|
// Validate and parse JSON config
|
||||||
|
let parsedConfig;
|
||||||
|
try {
|
||||||
|
parsedConfig = typeof jsonConfig === 'string' ? JSON.parse(jsonConfig) : jsonConfig;
|
||||||
|
} catch (parseError) {
|
||||||
|
return res.status(400).json({
|
||||||
|
error: 'Invalid JSON configuration',
|
||||||
|
details: parseError.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read existing config or create new
|
||||||
|
let mcpConfig = { mcpServers: {} };
|
||||||
|
|
||||||
|
try {
|
||||||
|
const existing = await fs.readFile(mcpPath, 'utf8');
|
||||||
|
mcpConfig = JSON.parse(existing);
|
||||||
|
if (!mcpConfig.mcpServers) {
|
||||||
|
mcpConfig.mcpServers = {};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Creating new Cursor MCP config');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add server to config
|
||||||
|
mcpConfig.mcpServers[name] = parsedConfig;
|
||||||
|
|
||||||
|
// Ensure directory exists
|
||||||
|
const mcpDir = path.dirname(mcpPath);
|
||||||
|
await fs.mkdir(mcpDir, { recursive: true });
|
||||||
|
|
||||||
|
// Write updated config
|
||||||
|
await fs.writeFile(mcpPath, JSON.stringify(mcpConfig, null, 2));
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: `MCP server "${name}" added to Cursor configuration via JSON`,
|
||||||
|
config: mcpConfig
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error adding MCP server to Cursor via JSON:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to add MCP server',
|
||||||
|
details: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GET /api/cursor/sessions - Get Cursor sessions from SQLite database
|
||||||
|
router.get('/sessions', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { projectPath } = req.query;
|
||||||
|
|
||||||
|
// Calculate cwdID hash for the project path (Cursor uses MD5 hash)
|
||||||
|
const cwdId = crypto.createHash('md5').update(projectPath || process.cwd()).digest('hex');
|
||||||
|
const cursorChatsPath = path.join(os.homedir(), '.cursor', 'chats', cwdId);
|
||||||
|
|
||||||
|
|
||||||
|
// Check if the directory exists
|
||||||
|
try {
|
||||||
|
await fs.access(cursorChatsPath);
|
||||||
|
} catch (error) {
|
||||||
|
// No sessions for this project
|
||||||
|
return res.json({
|
||||||
|
success: true,
|
||||||
|
sessions: [],
|
||||||
|
cwdId: cwdId,
|
||||||
|
path: cursorChatsPath
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// List all session directories
|
||||||
|
const sessionDirs = await fs.readdir(cursorChatsPath);
|
||||||
|
const sessions = [];
|
||||||
|
|
||||||
|
for (const sessionId of sessionDirs) {
|
||||||
|
const sessionPath = path.join(cursorChatsPath, sessionId);
|
||||||
|
const storeDbPath = path.join(sessionPath, 'store.db');
|
||||||
|
let dbStatMtimeMs = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Check if store.db exists
|
||||||
|
await fs.access(storeDbPath);
|
||||||
|
|
||||||
|
// Capture store.db mtime as a reliable fallback timestamp (last activity)
|
||||||
|
try {
|
||||||
|
const stat = await fs.stat(storeDbPath);
|
||||||
|
dbStatMtimeMs = stat.mtimeMs;
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
|
// Open SQLite database
|
||||||
|
const db = await open({
|
||||||
|
filename: storeDbPath,
|
||||||
|
driver: sqlite3.Database,
|
||||||
|
mode: sqlite3.OPEN_READONLY
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get metadata from meta table
|
||||||
|
const metaRows = await db.all(`
|
||||||
|
SELECT key, value FROM meta
|
||||||
|
`);
|
||||||
|
|
||||||
|
let sessionData = {
|
||||||
|
id: sessionId,
|
||||||
|
name: 'Untitled Session',
|
||||||
|
createdAt: null,
|
||||||
|
mode: null,
|
||||||
|
projectPath: projectPath,
|
||||||
|
lastMessage: null,
|
||||||
|
messageCount: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
// Parse meta table entries
|
||||||
|
for (const row of metaRows) {
|
||||||
|
if (row.value) {
|
||||||
|
try {
|
||||||
|
// Try to decode as hex-encoded JSON
|
||||||
|
const hexMatch = row.value.toString().match(/^[0-9a-fA-F]+$/);
|
||||||
|
if (hexMatch) {
|
||||||
|
const jsonStr = Buffer.from(row.value, 'hex').toString('utf8');
|
||||||
|
const data = JSON.parse(jsonStr);
|
||||||
|
|
||||||
|
if (row.key === 'agent') {
|
||||||
|
sessionData.name = data.name || sessionData.name;
|
||||||
|
// Normalize createdAt to ISO string in milliseconds
|
||||||
|
let createdAt = data.createdAt;
|
||||||
|
if (typeof createdAt === 'number') {
|
||||||
|
if (createdAt < 1e12) {
|
||||||
|
createdAt = createdAt * 1000; // seconds -> ms
|
||||||
|
}
|
||||||
|
sessionData.createdAt = new Date(createdAt).toISOString();
|
||||||
|
} else if (typeof createdAt === 'string') {
|
||||||
|
const n = Number(createdAt);
|
||||||
|
if (!Number.isNaN(n)) {
|
||||||
|
const ms = n < 1e12 ? n * 1000 : n;
|
||||||
|
sessionData.createdAt = new Date(ms).toISOString();
|
||||||
|
} else {
|
||||||
|
// Assume it's already an ISO/date string
|
||||||
|
const d = new Date(createdAt);
|
||||||
|
sessionData.createdAt = isNaN(d.getTime()) ? null : d.toISOString();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sessionData.createdAt = sessionData.createdAt || null;
|
||||||
|
}
|
||||||
|
sessionData.mode = data.mode;
|
||||||
|
sessionData.agentId = data.agentId;
|
||||||
|
sessionData.latestRootBlobId = data.latestRootBlobId;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If not hex, use raw value for simple keys
|
||||||
|
if (row.key === 'name') {
|
||||||
|
sessionData.name = row.value.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(`Could not parse meta value for key ${row.key}:`, e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get message count from JSON blobs only (actual messages, not DAG structure)
|
||||||
|
try {
|
||||||
|
const blobCount = await db.get(`
|
||||||
|
SELECT COUNT(*) as count
|
||||||
|
FROM blobs
|
||||||
|
WHERE substr(data, 1, 1) = X'7B'
|
||||||
|
`);
|
||||||
|
sessionData.messageCount = blobCount.count;
|
||||||
|
|
||||||
|
// Get the most recent JSON blob for preview (actual message, not DAG structure)
|
||||||
|
const lastBlob = await db.get(`
|
||||||
|
SELECT data FROM blobs
|
||||||
|
WHERE substr(data, 1, 1) = X'7B'
|
||||||
|
ORDER BY rowid DESC
|
||||||
|
LIMIT 1
|
||||||
|
`);
|
||||||
|
|
||||||
|
if (lastBlob && lastBlob.data) {
|
||||||
|
try {
|
||||||
|
// Try to extract readable preview from blob (may contain binary with embedded JSON)
|
||||||
|
const raw = lastBlob.data.toString('utf8');
|
||||||
|
let preview = '';
|
||||||
|
// Attempt direct JSON parse
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(raw);
|
||||||
|
if (parsed?.content) {
|
||||||
|
if (Array.isArray(parsed.content)) {
|
||||||
|
const firstText = parsed.content.find(p => p?.type === 'text' && p.text)?.text || '';
|
||||||
|
preview = firstText;
|
||||||
|
} else if (typeof parsed.content === 'string') {
|
||||||
|
preview = parsed.content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
if (!preview) {
|
||||||
|
// Strip non-printable and try to find JSON chunk
|
||||||
|
const cleaned = raw.replace(/[^\x09\x0A\x0D\x20-\x7E]/g, '');
|
||||||
|
const s = cleaned;
|
||||||
|
const start = s.indexOf('{');
|
||||||
|
const end = s.lastIndexOf('}');
|
||||||
|
if (start !== -1 && end > start) {
|
||||||
|
const jsonStr = s.slice(start, end + 1);
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(jsonStr);
|
||||||
|
if (parsed?.content) {
|
||||||
|
if (Array.isArray(parsed.content)) {
|
||||||
|
const firstText = parsed.content.find(p => p?.type === 'text' && p.text)?.text || '';
|
||||||
|
preview = firstText;
|
||||||
|
} else if (typeof parsed.content === 'string') {
|
||||||
|
preview = parsed.content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
preview = s;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
preview = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (preview && preview.length > 0) {
|
||||||
|
sessionData.lastMessage = preview.substring(0, 100) + (preview.length > 100 ? '...' : '');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Could not parse blob data:', e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Could not read blobs:', e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.close();
|
||||||
|
|
||||||
|
// Finalize createdAt: use parsed meta value when valid, else fall back to store.db mtime
|
||||||
|
if (!sessionData.createdAt) {
|
||||||
|
if (dbStatMtimeMs && Number.isFinite(dbStatMtimeMs)) {
|
||||||
|
sessionData.createdAt = new Date(dbStatMtimeMs).toISOString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sessions.push(sessionData);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log(`Could not read session ${sessionId}:`, error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: ensure createdAt is a valid ISO string (use session directory mtime as last resort)
|
||||||
|
for (const s of sessions) {
|
||||||
|
if (!s.createdAt) {
|
||||||
|
try {
|
||||||
|
const sessionDir = path.join(cursorChatsPath, s.id);
|
||||||
|
const st = await fs.stat(sessionDir);
|
||||||
|
s.createdAt = new Date(st.mtimeMs).toISOString();
|
||||||
|
} catch {
|
||||||
|
s.createdAt = new Date().toISOString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Sort sessions by creation date (newest first)
|
||||||
|
sessions.sort((a, b) => {
|
||||||
|
if (!a.createdAt) return 1;
|
||||||
|
if (!b.createdAt) return -1;
|
||||||
|
return new Date(b.createdAt) - new Date(a.createdAt);
|
||||||
|
});
|
||||||
|
|
||||||
|
applyCustomSessionNames(sessions, 'cursor');
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
sessions: sessions,
|
||||||
|
cwdId: cwdId,
|
||||||
|
path: cursorChatsPath
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading Cursor sessions:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to read Cursor sessions',
|
||||||
|
details: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GET /api/cursor/sessions/:sessionId - Get specific Cursor session from SQLite
|
||||||
|
router.get('/sessions/:sessionId', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { sessionId } = req.params;
|
||||||
|
const { projectPath } = req.query;
|
||||||
|
|
||||||
|
// Calculate cwdID hash for the project path
|
||||||
|
const cwdId = crypto.createHash('md5').update(projectPath || process.cwd()).digest('hex');
|
||||||
|
const storeDbPath = path.join(os.homedir(), '.cursor', 'chats', cwdId, sessionId, 'store.db');
|
||||||
|
|
||||||
|
|
||||||
|
// Open SQLite database
|
||||||
|
const db = await open({
|
||||||
|
filename: storeDbPath,
|
||||||
|
driver: sqlite3.Database,
|
||||||
|
mode: sqlite3.OPEN_READONLY
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get all blobs to build the DAG structure
|
||||||
|
const allBlobs = await db.all(`
|
||||||
|
SELECT rowid, id, data FROM blobs
|
||||||
|
`);
|
||||||
|
|
||||||
|
// Build the DAG structure from parent-child relationships
|
||||||
|
const blobMap = new Map(); // id -> blob data
|
||||||
|
const parentRefs = new Map(); // blob id -> [parent blob ids]
|
||||||
|
const childRefs = new Map(); // blob id -> [child blob ids]
|
||||||
|
const jsonBlobs = []; // Clean JSON messages
|
||||||
|
|
||||||
|
for (const blob of allBlobs) {
|
||||||
|
blobMap.set(blob.id, blob);
|
||||||
|
|
||||||
|
// Check if this is a JSON blob (actual message) or protobuf (DAG structure)
|
||||||
|
if (blob.data && blob.data[0] === 0x7B) { // Starts with '{' - JSON blob
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(blob.data.toString('utf8'));
|
||||||
|
jsonBlobs.push({ ...blob, parsed });
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Failed to parse JSON blob:', blob.rowid);
|
||||||
|
}
|
||||||
|
} else if (blob.data) { // Protobuf blob - extract parent references
|
||||||
|
const parents = [];
|
||||||
|
let i = 0;
|
||||||
|
|
||||||
|
// Scan for parent references (0x0A 0x20 followed by 32-byte hash)
|
||||||
|
while (i < blob.data.length - 33) {
|
||||||
|
if (blob.data[i] === 0x0A && blob.data[i+1] === 0x20) {
|
||||||
|
const parentHash = blob.data.slice(i+2, i+34).toString('hex');
|
||||||
|
if (blobMap.has(parentHash)) {
|
||||||
|
parents.push(parentHash);
|
||||||
|
}
|
||||||
|
i += 34;
|
||||||
|
} else {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parents.length > 0) {
|
||||||
|
parentRefs.set(blob.id, parents);
|
||||||
|
// Update child references
|
||||||
|
for (const parentId of parents) {
|
||||||
|
if (!childRefs.has(parentId)) {
|
||||||
|
childRefs.set(parentId, []);
|
||||||
|
}
|
||||||
|
childRefs.get(parentId).push(blob.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform topological sort to get chronological order
|
||||||
|
const visited = new Set();
|
||||||
|
const sorted = [];
|
||||||
|
|
||||||
|
// DFS-based topological sort
|
||||||
|
function visit(nodeId) {
|
||||||
|
if (visited.has(nodeId)) return;
|
||||||
|
visited.add(nodeId);
|
||||||
|
|
||||||
|
// Visit all parents first (dependencies)
|
||||||
|
const parents = parentRefs.get(nodeId) || [];
|
||||||
|
for (const parentId of parents) {
|
||||||
|
visit(parentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add this node after all its parents
|
||||||
|
const blob = blobMap.get(nodeId);
|
||||||
|
if (blob) {
|
||||||
|
sorted.push(blob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start with nodes that have no parents (roots)
|
||||||
|
for (const blob of allBlobs) {
|
||||||
|
if (!parentRefs.has(blob.id)) {
|
||||||
|
visit(blob.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Visit any remaining nodes (disconnected components)
|
||||||
|
for (const blob of allBlobs) {
|
||||||
|
visit(blob.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now extract JSON messages in the order they appear in the sorted DAG
|
||||||
|
const messageOrder = new Map(); // JSON blob id -> order index
|
||||||
|
let orderIndex = 0;
|
||||||
|
|
||||||
|
for (const blob of sorted) {
|
||||||
|
// Check if this blob references any JSON messages
|
||||||
|
if (blob.data && blob.data[0] !== 0x7B) { // Protobuf blob
|
||||||
|
// Look for JSON blob references
|
||||||
|
for (const jsonBlob of jsonBlobs) {
|
||||||
|
try {
|
||||||
|
const jsonIdBytes = Buffer.from(jsonBlob.id, 'hex');
|
||||||
|
if (blob.data.includes(jsonIdBytes)) {
|
||||||
|
if (!messageOrder.has(jsonBlob.id)) {
|
||||||
|
messageOrder.set(jsonBlob.id, orderIndex++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Skip if can't convert ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort JSON blobs by their appearance order in the DAG
|
||||||
|
const sortedJsonBlobs = jsonBlobs.sort((a, b) => {
|
||||||
|
const orderA = messageOrder.get(a.id) ?? Number.MAX_SAFE_INTEGER;
|
||||||
|
const orderB = messageOrder.get(b.id) ?? Number.MAX_SAFE_INTEGER;
|
||||||
|
if (orderA !== orderB) return orderA - orderB;
|
||||||
|
// Fallback to rowid if not in order map
|
||||||
|
return a.rowid - b.rowid;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Use sorted JSON blobs
|
||||||
|
const blobs = sortedJsonBlobs.map((blob, idx) => ({
|
||||||
|
...blob,
|
||||||
|
sequence_num: idx + 1,
|
||||||
|
original_rowid: blob.rowid
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Get metadata from meta table
|
||||||
|
const metaRows = await db.all(`
|
||||||
|
SELECT key, value FROM meta
|
||||||
|
`);
|
||||||
|
|
||||||
|
// Parse metadata
|
||||||
|
let metadata = {};
|
||||||
|
for (const row of metaRows) {
|
||||||
|
if (row.value) {
|
||||||
|
try {
|
||||||
|
// Try to decode as hex-encoded JSON
|
||||||
|
const hexMatch = row.value.toString().match(/^[0-9a-fA-F]+$/);
|
||||||
|
if (hexMatch) {
|
||||||
|
const jsonStr = Buffer.from(row.value, 'hex').toString('utf8');
|
||||||
|
metadata[row.key] = JSON.parse(jsonStr);
|
||||||
|
} else {
|
||||||
|
metadata[row.key] = row.value.toString();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
metadata[row.key] = row.value.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract messages from sorted JSON blobs
|
||||||
|
const messages = [];
|
||||||
|
for (const blob of blobs) {
|
||||||
|
try {
|
||||||
|
// We already parsed JSON blobs earlier
|
||||||
|
const parsed = blob.parsed;
|
||||||
|
|
||||||
|
if (parsed) {
|
||||||
|
// Filter out ONLY system messages at the server level
|
||||||
|
// Check both direct role and nested message.role
|
||||||
|
const role = parsed?.role || parsed?.message?.role;
|
||||||
|
if (role === 'system') {
|
||||||
|
continue; // Skip only system messages
|
||||||
|
}
|
||||||
|
messages.push({
|
||||||
|
id: blob.id,
|
||||||
|
sequence: blob.sequence_num,
|
||||||
|
rowid: blob.original_rowid,
|
||||||
|
content: parsed
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Skip blobs that cause errors
|
||||||
|
console.log(`Skipping blob ${blob.id}: ${e.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.close();
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
session: {
|
||||||
|
id: sessionId,
|
||||||
|
projectPath: projectPath,
|
||||||
|
messages: messages,
|
||||||
|
metadata: metadata,
|
||||||
|
cwdId: cwdId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading Cursor session:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to read Cursor session',
|
||||||
|
details: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default router;
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { detectTaskMasterMCPServer } from '../utils/mcp-detector.js';
|
import { detectTaskMasterMCPServer, getAllMCPServers } from '../utils/mcp-detector.js';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
@@ -28,4 +28,21 @@ router.get('/taskmaster-server', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
/**
|
||||||
|
* GET /api/mcp-utils/all-servers
|
||||||
|
* Get all configured MCP servers
|
||||||
|
*/
|
||||||
|
router.get('/all-servers', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const result = await getAllMCPServers();
|
||||||
|
res.json(result);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('MCP servers detection error:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to get MCP servers',
|
||||||
|
message: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default router;
|
||||||
552
server/routes/mcp.js
Normal file
552
server/routes/mcp.js
Normal file
@@ -0,0 +1,552 @@
|
|||||||
|
import express from 'express';
|
||||||
|
import { promises as fs } from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import os from 'os';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
import { dirname } from 'path';
|
||||||
|
import { spawn } from 'child_process';
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = dirname(__filename);
|
||||||
|
|
||||||
|
// Claude CLI command routes
|
||||||
|
|
||||||
|
// GET /api/mcp/cli/list - List MCP servers using Claude CLI
|
||||||
|
router.get('/cli/list', async (req, res) => {
|
||||||
|
try {
|
||||||
|
console.log('📋 Listing MCP servers using Claude CLI');
|
||||||
|
|
||||||
|
const { spawn } = await import('child_process');
|
||||||
|
const { promisify } = await import('util');
|
||||||
|
const exec = promisify(spawn);
|
||||||
|
|
||||||
|
const process = spawn('claude', ['mcp', 'list'], {
|
||||||
|
stdio: ['pipe', 'pipe', 'pipe']
|
||||||
|
});
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
process.stdout.on('data', (data) => {
|
||||||
|
stdout += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
process.stderr.on('data', (data) => {
|
||||||
|
stderr += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
res.json({ success: true, output: stdout, servers: parseClaudeListOutput(stdout) });
|
||||||
|
} else {
|
||||||
|
console.error('Claude CLI error:', stderr);
|
||||||
|
res.status(500).json({ error: 'Claude CLI command failed', details: stderr });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('error', (error) => {
|
||||||
|
console.error('Error running Claude CLI:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to run Claude CLI', details: error.message });
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error listing MCP servers via CLI:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to list MCP servers', details: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /api/mcp/cli/add - Add MCP server using Claude CLI
|
||||||
|
router.post('/cli/add', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { name, type = 'stdio', command, args = [], url, headers = {}, env = {}, scope = 'user', projectPath } = req.body;
|
||||||
|
|
||||||
|
console.log(`➕ Adding MCP server using Claude CLI (${scope} scope):`, name);
|
||||||
|
|
||||||
|
const { spawn } = await import('child_process');
|
||||||
|
|
||||||
|
let cliArgs = ['mcp', 'add'];
|
||||||
|
|
||||||
|
// Add scope flag
|
||||||
|
cliArgs.push('--scope', scope);
|
||||||
|
|
||||||
|
if (type === 'http') {
|
||||||
|
cliArgs.push('--transport', 'http', name, url);
|
||||||
|
// Add headers if provided
|
||||||
|
Object.entries(headers).forEach(([key, value]) => {
|
||||||
|
cliArgs.push('--header', `${key}: ${value}`);
|
||||||
|
});
|
||||||
|
} else if (type === 'sse') {
|
||||||
|
cliArgs.push('--transport', 'sse', name, url);
|
||||||
|
// Add headers if provided
|
||||||
|
Object.entries(headers).forEach(([key, value]) => {
|
||||||
|
cliArgs.push('--header', `${key}: ${value}`);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// stdio (default): claude mcp add --scope user <name> <command> [args...]
|
||||||
|
cliArgs.push(name);
|
||||||
|
// Add environment variables
|
||||||
|
Object.entries(env).forEach(([key, value]) => {
|
||||||
|
cliArgs.push('-e', `${key}=${value}`);
|
||||||
|
});
|
||||||
|
cliArgs.push(command);
|
||||||
|
if (args && args.length > 0) {
|
||||||
|
cliArgs.push(...args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('🔧 Running Claude CLI command:', 'claude', cliArgs.join(' '));
|
||||||
|
|
||||||
|
// For local scope, we need to run the command in the project directory
|
||||||
|
const spawnOptions = {
|
||||||
|
stdio: ['pipe', 'pipe', 'pipe']
|
||||||
|
};
|
||||||
|
|
||||||
|
if (scope === 'local' && projectPath) {
|
||||||
|
spawnOptions.cwd = projectPath;
|
||||||
|
console.log('📁 Running in project directory:', projectPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
const process = spawn('claude', cliArgs, spawnOptions);
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
process.stdout.on('data', (data) => {
|
||||||
|
stdout += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
process.stderr.on('data', (data) => {
|
||||||
|
stderr += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
res.json({ success: true, output: stdout, message: `MCP server "${name}" added successfully` });
|
||||||
|
} else {
|
||||||
|
console.error('Claude CLI error:', stderr);
|
||||||
|
res.status(400).json({ error: 'Claude CLI command failed', details: stderr });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('error', (error) => {
|
||||||
|
console.error('Error running Claude CLI:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to run Claude CLI', details: error.message });
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error adding MCP server via CLI:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to add MCP server', details: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /api/mcp/cli/add-json - Add MCP server using JSON format
|
||||||
|
router.post('/cli/add-json', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { name, jsonConfig, scope = 'user', projectPath } = req.body;
|
||||||
|
|
||||||
|
console.log('➕ Adding MCP server using JSON format:', name);
|
||||||
|
|
||||||
|
// Validate and parse JSON config
|
||||||
|
let parsedConfig;
|
||||||
|
try {
|
||||||
|
parsedConfig = typeof jsonConfig === 'string' ? JSON.parse(jsonConfig) : jsonConfig;
|
||||||
|
} catch (parseError) {
|
||||||
|
return res.status(400).json({
|
||||||
|
error: 'Invalid JSON configuration',
|
||||||
|
details: parseError.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate required fields
|
||||||
|
if (!parsedConfig.type) {
|
||||||
|
return res.status(400).json({
|
||||||
|
error: 'Invalid configuration',
|
||||||
|
details: 'Missing required field: type'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parsedConfig.type === 'stdio' && !parsedConfig.command) {
|
||||||
|
return res.status(400).json({
|
||||||
|
error: 'Invalid configuration',
|
||||||
|
details: 'stdio type requires a command field'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((parsedConfig.type === 'http' || parsedConfig.type === 'sse') && !parsedConfig.url) {
|
||||||
|
return res.status(400).json({
|
||||||
|
error: 'Invalid configuration',
|
||||||
|
details: `${parsedConfig.type} type requires a url field`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const { spawn } = await import('child_process');
|
||||||
|
|
||||||
|
// Build the command: claude mcp add-json --scope <scope> <name> '<json>'
|
||||||
|
const cliArgs = ['mcp', 'add-json', '--scope', scope, name];
|
||||||
|
|
||||||
|
// Add the JSON config as a properly formatted string
|
||||||
|
const jsonString = JSON.stringify(parsedConfig);
|
||||||
|
cliArgs.push(jsonString);
|
||||||
|
|
||||||
|
console.log('🔧 Running Claude CLI command:', 'claude', cliArgs[0], cliArgs[1], cliArgs[2], cliArgs[3], cliArgs[4], jsonString);
|
||||||
|
|
||||||
|
// For local scope, we need to run the command in the project directory
|
||||||
|
const spawnOptions = {
|
||||||
|
stdio: ['pipe', 'pipe', 'pipe']
|
||||||
|
};
|
||||||
|
|
||||||
|
if (scope === 'local' && projectPath) {
|
||||||
|
spawnOptions.cwd = projectPath;
|
||||||
|
console.log('📁 Running in project directory:', projectPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
const process = spawn('claude', cliArgs, spawnOptions);
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
process.stdout.on('data', (data) => {
|
||||||
|
stdout += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
process.stderr.on('data', (data) => {
|
||||||
|
stderr += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
res.json({ success: true, output: stdout, message: `MCP server "${name}" added successfully via JSON` });
|
||||||
|
} else {
|
||||||
|
console.error('Claude CLI error:', stderr);
|
||||||
|
res.status(400).json({ error: 'Claude CLI command failed', details: stderr });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('error', (error) => {
|
||||||
|
console.error('Error running Claude CLI:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to run Claude CLI', details: error.message });
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error adding MCP server via JSON:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to add MCP server', details: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// DELETE /api/mcp/cli/remove/:name - Remove MCP server using Claude CLI
|
||||||
|
router.delete('/cli/remove/:name', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { name } = req.params;
|
||||||
|
const { scope } = req.query; // Get scope from query params
|
||||||
|
|
||||||
|
// Handle the ID format (remove scope prefix if present)
|
||||||
|
let actualName = name;
|
||||||
|
let actualScope = scope;
|
||||||
|
|
||||||
|
// If the name includes a scope prefix like "local:test", extract it
|
||||||
|
if (name.includes(':')) {
|
||||||
|
const [prefix, serverName] = name.split(':');
|
||||||
|
actualName = serverName;
|
||||||
|
actualScope = actualScope || prefix; // Use prefix as scope if not provided in query
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('🗑️ Removing MCP server using Claude CLI:', actualName, 'scope:', actualScope);
|
||||||
|
|
||||||
|
const { spawn } = await import('child_process');
|
||||||
|
|
||||||
|
// Build command args based on scope
|
||||||
|
let cliArgs = ['mcp', 'remove'];
|
||||||
|
|
||||||
|
// Add scope flag if it's local scope
|
||||||
|
if (actualScope === 'local') {
|
||||||
|
cliArgs.push('--scope', 'local');
|
||||||
|
} else if (actualScope === 'user' || !actualScope) {
|
||||||
|
// User scope is default, but we can be explicit
|
||||||
|
cliArgs.push('--scope', 'user');
|
||||||
|
}
|
||||||
|
|
||||||
|
cliArgs.push(actualName);
|
||||||
|
|
||||||
|
console.log('🔧 Running Claude CLI command:', 'claude', cliArgs.join(' '));
|
||||||
|
|
||||||
|
const process = spawn('claude', cliArgs, {
|
||||||
|
stdio: ['pipe', 'pipe', 'pipe']
|
||||||
|
});
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
process.stdout.on('data', (data) => {
|
||||||
|
stdout += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
process.stderr.on('data', (data) => {
|
||||||
|
stderr += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
res.json({ success: true, output: stdout, message: `MCP server "${name}" removed successfully` });
|
||||||
|
} else {
|
||||||
|
console.error('Claude CLI error:', stderr);
|
||||||
|
res.status(400).json({ error: 'Claude CLI command failed', details: stderr });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('error', (error) => {
|
||||||
|
console.error('Error running Claude CLI:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to run Claude CLI', details: error.message });
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error removing MCP server via CLI:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to remove MCP server', details: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GET /api/mcp/cli/get/:name - Get MCP server details using Claude CLI
|
||||||
|
router.get('/cli/get/:name', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { name } = req.params;
|
||||||
|
|
||||||
|
console.log('📄 Getting MCP server details using Claude CLI:', name);
|
||||||
|
|
||||||
|
const { spawn } = await import('child_process');
|
||||||
|
|
||||||
|
const process = spawn('claude', ['mcp', 'get', name], {
|
||||||
|
stdio: ['pipe', 'pipe', 'pipe']
|
||||||
|
});
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
process.stdout.on('data', (data) => {
|
||||||
|
stdout += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
process.stderr.on('data', (data) => {
|
||||||
|
stderr += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
res.json({ success: true, output: stdout, server: parseClaudeGetOutput(stdout) });
|
||||||
|
} else {
|
||||||
|
console.error('Claude CLI error:', stderr);
|
||||||
|
res.status(404).json({ error: 'Claude CLI command failed', details: stderr });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('error', (error) => {
|
||||||
|
console.error('Error running Claude CLI:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to run Claude CLI', details: error.message });
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error getting MCP server details via CLI:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to get MCP server details', details: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GET /api/mcp/config/read - Read MCP servers directly from Claude config files
|
||||||
|
router.get('/config/read', async (req, res) => {
|
||||||
|
try {
|
||||||
|
console.log('📖 Reading MCP servers from Claude config files');
|
||||||
|
|
||||||
|
const homeDir = os.homedir();
|
||||||
|
const configPaths = [
|
||||||
|
path.join(homeDir, '.claude.json'),
|
||||||
|
path.join(homeDir, '.claude', 'settings.json')
|
||||||
|
];
|
||||||
|
|
||||||
|
let configData = null;
|
||||||
|
let configPath = null;
|
||||||
|
|
||||||
|
// Try to read from either config file
|
||||||
|
for (const filepath of configPaths) {
|
||||||
|
try {
|
||||||
|
const fileContent = await fs.readFile(filepath, 'utf8');
|
||||||
|
configData = JSON.parse(fileContent);
|
||||||
|
configPath = filepath;
|
||||||
|
console.log(`✅ Found Claude config at: ${filepath}`);
|
||||||
|
break;
|
||||||
|
} catch (error) {
|
||||||
|
// File doesn't exist or is not valid JSON, try next
|
||||||
|
console.log(`ℹ️ Config not found or invalid at: ${filepath}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!configData) {
|
||||||
|
return res.json({
|
||||||
|
success: false,
|
||||||
|
message: 'No Claude configuration file found',
|
||||||
|
servers: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract MCP servers from the config
|
||||||
|
const servers = [];
|
||||||
|
|
||||||
|
// Check for user-scoped MCP servers (at root level)
|
||||||
|
if (configData.mcpServers && typeof configData.mcpServers === 'object' && Object.keys(configData.mcpServers).length > 0) {
|
||||||
|
console.log('🔍 Found user-scoped MCP servers:', Object.keys(configData.mcpServers));
|
||||||
|
for (const [name, config] of Object.entries(configData.mcpServers)) {
|
||||||
|
const server = {
|
||||||
|
id: name,
|
||||||
|
name: name,
|
||||||
|
type: 'stdio', // Default type
|
||||||
|
scope: 'user', // User scope - available across all projects
|
||||||
|
config: {},
|
||||||
|
raw: config // Include raw config for full details
|
||||||
|
};
|
||||||
|
|
||||||
|
// Determine transport type and extract config
|
||||||
|
if (config.command) {
|
||||||
|
server.type = 'stdio';
|
||||||
|
server.config.command = config.command;
|
||||||
|
server.config.args = config.args || [];
|
||||||
|
server.config.env = config.env || {};
|
||||||
|
} else if (config.url) {
|
||||||
|
server.type = config.transport || 'http';
|
||||||
|
server.config.url = config.url;
|
||||||
|
server.config.headers = config.headers || {};
|
||||||
|
}
|
||||||
|
|
||||||
|
servers.push(server);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for local-scoped MCP servers (project-specific)
|
||||||
|
const currentProjectPath = process.cwd();
|
||||||
|
|
||||||
|
// Check under 'projects' key
|
||||||
|
if (configData.projects && configData.projects[currentProjectPath]) {
|
||||||
|
const projectConfig = configData.projects[currentProjectPath];
|
||||||
|
if (projectConfig.mcpServers && typeof projectConfig.mcpServers === 'object' && Object.keys(projectConfig.mcpServers).length > 0) {
|
||||||
|
console.log(`🔍 Found local-scoped MCP servers for ${currentProjectPath}:`, Object.keys(projectConfig.mcpServers));
|
||||||
|
for (const [name, config] of Object.entries(projectConfig.mcpServers)) {
|
||||||
|
const server = {
|
||||||
|
id: `local:${name}`, // Prefix with scope for uniqueness
|
||||||
|
name: name, // Keep original name
|
||||||
|
type: 'stdio', // Default type
|
||||||
|
scope: 'local', // Local scope - only for this project
|
||||||
|
projectPath: currentProjectPath,
|
||||||
|
config: {},
|
||||||
|
raw: config // Include raw config for full details
|
||||||
|
};
|
||||||
|
|
||||||
|
// Determine transport type and extract config
|
||||||
|
if (config.command) {
|
||||||
|
server.type = 'stdio';
|
||||||
|
server.config.command = config.command;
|
||||||
|
server.config.args = config.args || [];
|
||||||
|
server.config.env = config.env || {};
|
||||||
|
} else if (config.url) {
|
||||||
|
server.type = config.transport || 'http';
|
||||||
|
server.config.url = config.url;
|
||||||
|
server.config.headers = config.headers || {};
|
||||||
|
}
|
||||||
|
|
||||||
|
servers.push(server);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`📋 Found ${servers.length} MCP servers in config`);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
configPath: configPath,
|
||||||
|
servers: servers
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading Claude config:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to read Claude configuration',
|
||||||
|
details: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Helper functions to parse Claude CLI output
|
||||||
|
function parseClaudeListOutput(output) {
|
||||||
|
const servers = [];
|
||||||
|
const lines = output.split('\n').filter(line => line.trim());
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
// Skip the header line
|
||||||
|
if (line.includes('Checking MCP server health')) continue;
|
||||||
|
|
||||||
|
// Parse lines like "test: test test - ✗ Failed to connect"
|
||||||
|
// or "server-name: command or description - ✓ Connected"
|
||||||
|
if (line.includes(':')) {
|
||||||
|
const colonIndex = line.indexOf(':');
|
||||||
|
const name = line.substring(0, colonIndex).trim();
|
||||||
|
|
||||||
|
// Skip empty names
|
||||||
|
if (!name) continue;
|
||||||
|
|
||||||
|
// Extract the rest after the name
|
||||||
|
const rest = line.substring(colonIndex + 1).trim();
|
||||||
|
|
||||||
|
// Try to extract description and status
|
||||||
|
let description = rest;
|
||||||
|
let status = 'unknown';
|
||||||
|
let type = 'stdio'; // default type
|
||||||
|
|
||||||
|
// Check for status indicators
|
||||||
|
if (rest.includes('✓') || rest.includes('✗')) {
|
||||||
|
const statusMatch = rest.match(/(.*?)\s*-\s*([✓✗].*)$/);
|
||||||
|
if (statusMatch) {
|
||||||
|
description = statusMatch[1].trim();
|
||||||
|
status = statusMatch[2].includes('✓') ? 'connected' : 'failed';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to determine type from description
|
||||||
|
if (description.startsWith('http://') || description.startsWith('https://')) {
|
||||||
|
type = 'http';
|
||||||
|
}
|
||||||
|
|
||||||
|
servers.push({
|
||||||
|
name,
|
||||||
|
type,
|
||||||
|
status: status || 'active',
|
||||||
|
description
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('🔍 Parsed Claude CLI servers:', servers);
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseClaudeGetOutput(output) {
|
||||||
|
// Parse the output from 'claude mcp get <name>' command
|
||||||
|
// This is a simple parser - might need adjustment based on actual output format
|
||||||
|
try {
|
||||||
|
// Try to extract JSON if present
|
||||||
|
const jsonMatch = output.match(/\{[\s\S]*\}/);
|
||||||
|
if (jsonMatch) {
|
||||||
|
return JSON.parse(jsonMatch[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, parse as text
|
||||||
|
const server = { raw_output: output };
|
||||||
|
const lines = output.split('\n');
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.includes('Name:')) {
|
||||||
|
server.name = line.split(':')[1]?.trim();
|
||||||
|
} else if (line.includes('Type:')) {
|
||||||
|
server.type = line.split(':')[1]?.trim();
|
||||||
|
} else if (line.includes('Command:')) {
|
||||||
|
server.command = line.split(':')[1]?.trim();
|
||||||
|
} else if (line.includes('URL:')) {
|
||||||
|
server.url = line.split(':')[1]?.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return server;
|
||||||
|
} catch (error) {
|
||||||
|
return { raw_output: output, parse_error: error.message };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default router;
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { sessionsService } from '../modules/providers/services/sessions.service.js';
|
import { getProvider, getAllProviders } from '../providers/registry.js';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ const router = express.Router();
|
|||||||
router.get('/:sessionId/messages', async (req, res) => {
|
router.get('/:sessionId/messages', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { sessionId } = req.params;
|
const { sessionId } = req.params;
|
||||||
const provider = String(req.query.provider || 'claude').trim().toLowerCase();
|
const provider = req.query.provider || 'claude';
|
||||||
const projectName = req.query.projectName || '';
|
const projectName = req.query.projectName || '';
|
||||||
const projectPath = req.query.projectPath || '';
|
const projectPath = req.query.projectPath || '';
|
||||||
const limitParam = req.query.limit;
|
const limitParam = req.query.limit;
|
||||||
@@ -38,13 +38,13 @@ router.get('/:sessionId/messages', async (req, res) => {
|
|||||||
: null;
|
: null;
|
||||||
const offset = parseInt(req.query.offset || '0', 10);
|
const offset = parseInt(req.query.offset || '0', 10);
|
||||||
|
|
||||||
const availableProviders = sessionsService.listProviderIds();
|
const adapter = getProvider(provider);
|
||||||
if (!availableProviders.includes(provider)) {
|
if (!adapter) {
|
||||||
const available = availableProviders.join(', ');
|
const available = getAllProviders().join(', ');
|
||||||
return res.status(400).json({ error: `Unknown provider: ${provider}. Available: ${available}` });
|
return res.status(400).json({ error: `Unknown provider: ${provider}. Available: ${available}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await sessionsService.fetchHistory(provider, sessionId, {
|
const result = await adapter.fetchHistory(sessionId, {
|
||||||
projectName,
|
projectName,
|
||||||
projectPath,
|
projectPath,
|
||||||
limit,
|
limit,
|
||||||
|
|||||||
@@ -273,14 +273,4 @@ router.post('/push/unsubscribe', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Host OS for UI (e.g. hide Cursor agent when the backend runs on Windows).
|
|
||||||
router.get('/server-env', async (req, res) => {
|
|
||||||
try {
|
|
||||||
res.json({ platform: process.platform });
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error reading server environment:', error);
|
|
||||||
res.status(500).json({ error: 'Failed to read server environment' });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -13,10 +13,16 @@ import fs from 'fs';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { promises as fsPromises } from 'fs';
|
import { promises as fsPromises } from 'fs';
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
import { dirname } from 'path';
|
||||||
|
import os from 'os';
|
||||||
import { extractProjectDirectory } from '../projects.js';
|
import { extractProjectDirectory } from '../projects.js';
|
||||||
import { detectTaskMasterMCPServer } from '../utils/mcp-detector.js';
|
import { detectTaskMasterMCPServer } from '../utils/mcp-detector.js';
|
||||||
import { broadcastTaskMasterProjectUpdate, broadcastTaskMasterTasksUpdate } from '../utils/taskmaster-websocket.js';
|
import { broadcastTaskMasterProjectUpdate, broadcastTaskMasterTasksUpdate } from '../utils/taskmaster-websocket.js';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = dirname(__filename);
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,6 +100,140 @@ async function checkTaskMasterInstallation() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect .taskmaster folder presence in a given project directory
|
||||||
|
* @param {string} projectPath - Absolute path to project directory
|
||||||
|
* @returns {Promise<Object>} Detection result with status and metadata
|
||||||
|
*/
|
||||||
|
async function detectTaskMasterFolder(projectPath) {
|
||||||
|
try {
|
||||||
|
const taskMasterPath = path.join(projectPath, '.taskmaster');
|
||||||
|
|
||||||
|
// Check if .taskmaster directory exists
|
||||||
|
try {
|
||||||
|
const stats = await fsPromises.stat(taskMasterPath);
|
||||||
|
if (!stats.isDirectory()) {
|
||||||
|
return {
|
||||||
|
hasTaskmaster: false,
|
||||||
|
reason: '.taskmaster exists but is not a directory'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code === 'ENOENT') {
|
||||||
|
return {
|
||||||
|
hasTaskmaster: false,
|
||||||
|
reason: '.taskmaster directory not found'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for key TaskMaster files
|
||||||
|
const keyFiles = [
|
||||||
|
'tasks/tasks.json',
|
||||||
|
'config.json'
|
||||||
|
];
|
||||||
|
|
||||||
|
const fileStatus = {};
|
||||||
|
let hasEssentialFiles = true;
|
||||||
|
|
||||||
|
for (const file of keyFiles) {
|
||||||
|
const filePath = path.join(taskMasterPath, file);
|
||||||
|
try {
|
||||||
|
await fsPromises.access(filePath, fs.constants.R_OK);
|
||||||
|
fileStatus[file] = true;
|
||||||
|
} catch (error) {
|
||||||
|
fileStatus[file] = false;
|
||||||
|
if (file === 'tasks/tasks.json') {
|
||||||
|
hasEssentialFiles = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse tasks.json if it exists for metadata
|
||||||
|
let taskMetadata = null;
|
||||||
|
if (fileStatus['tasks/tasks.json']) {
|
||||||
|
try {
|
||||||
|
const tasksPath = path.join(taskMasterPath, 'tasks/tasks.json');
|
||||||
|
const tasksContent = await fsPromises.readFile(tasksPath, 'utf8');
|
||||||
|
const tasksData = JSON.parse(tasksContent);
|
||||||
|
|
||||||
|
// Handle both tagged and legacy formats
|
||||||
|
let tasks = [];
|
||||||
|
if (tasksData.tasks) {
|
||||||
|
// Legacy format
|
||||||
|
tasks = tasksData.tasks;
|
||||||
|
} else {
|
||||||
|
// Tagged format - get tasks from all tags
|
||||||
|
Object.values(tasksData).forEach(tagData => {
|
||||||
|
if (tagData.tasks) {
|
||||||
|
tasks = tasks.concat(tagData.tasks);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate task statistics
|
||||||
|
const stats = tasks.reduce((acc, task) => {
|
||||||
|
acc.total++;
|
||||||
|
acc[task.status] = (acc[task.status] || 0) + 1;
|
||||||
|
|
||||||
|
// Count subtasks
|
||||||
|
if (task.subtasks) {
|
||||||
|
task.subtasks.forEach(subtask => {
|
||||||
|
acc.subtotalTasks++;
|
||||||
|
acc.subtasks = acc.subtasks || {};
|
||||||
|
acc.subtasks[subtask.status] = (acc.subtasks[subtask.status] || 0) + 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, {
|
||||||
|
total: 0,
|
||||||
|
subtotalTasks: 0,
|
||||||
|
pending: 0,
|
||||||
|
'in-progress': 0,
|
||||||
|
done: 0,
|
||||||
|
review: 0,
|
||||||
|
deferred: 0,
|
||||||
|
cancelled: 0,
|
||||||
|
subtasks: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
taskMetadata = {
|
||||||
|
taskCount: stats.total,
|
||||||
|
subtaskCount: stats.subtotalTasks,
|
||||||
|
completed: stats.done || 0,
|
||||||
|
pending: stats.pending || 0,
|
||||||
|
inProgress: stats['in-progress'] || 0,
|
||||||
|
review: stats.review || 0,
|
||||||
|
completionPercentage: stats.total > 0 ? Math.round((stats.done / stats.total) * 100) : 0,
|
||||||
|
lastModified: (await fsPromises.stat(tasksPath)).mtime.toISOString()
|
||||||
|
};
|
||||||
|
} catch (parseError) {
|
||||||
|
console.warn('Failed to parse tasks.json:', parseError.message);
|
||||||
|
taskMetadata = { error: 'Failed to parse tasks.json' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
hasTaskmaster: true,
|
||||||
|
hasEssentialFiles,
|
||||||
|
files: fileStatus,
|
||||||
|
metadata: taskMetadata,
|
||||||
|
path: taskMasterPath
|
||||||
|
};
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error detecting TaskMaster folder:', error);
|
||||||
|
return {
|
||||||
|
hasTaskmaster: false,
|
||||||
|
reason: `Error checking directory: ${error.message}`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MCP detection is now handled by the centralized utility
|
||||||
|
|
||||||
// API Routes
|
// API Routes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,6 +271,298 @@ router.get('/installation-status', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/taskmaster/detect/:projectName
|
||||||
|
* Detect TaskMaster configuration for a specific project
|
||||||
|
*/
|
||||||
|
router.get('/detect/:projectName', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { projectName } = req.params;
|
||||||
|
|
||||||
|
// Use the existing extractProjectDirectory function to get actual project path
|
||||||
|
let projectPath;
|
||||||
|
try {
|
||||||
|
projectPath = await extractProjectDirectory(projectName);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error extracting project directory:', error);
|
||||||
|
return res.status(404).json({
|
||||||
|
error: 'Project path not found',
|
||||||
|
projectName,
|
||||||
|
message: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the project path exists
|
||||||
|
try {
|
||||||
|
await fsPromises.access(projectPath, fs.constants.R_OK);
|
||||||
|
} catch (error) {
|
||||||
|
return res.status(404).json({
|
||||||
|
error: 'Project path not accessible',
|
||||||
|
projectPath,
|
||||||
|
projectName,
|
||||||
|
message: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run detection in parallel
|
||||||
|
const [taskMasterResult, mcpResult] = await Promise.all([
|
||||||
|
detectTaskMasterFolder(projectPath),
|
||||||
|
detectTaskMasterMCPServer()
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Determine overall status
|
||||||
|
let status = 'not-configured';
|
||||||
|
if (taskMasterResult.hasTaskmaster && taskMasterResult.hasEssentialFiles) {
|
||||||
|
if (mcpResult.hasMCPServer && mcpResult.isConfigured) {
|
||||||
|
status = 'fully-configured';
|
||||||
|
} else {
|
||||||
|
status = 'taskmaster-only';
|
||||||
|
}
|
||||||
|
} else if (mcpResult.hasMCPServer && mcpResult.isConfigured) {
|
||||||
|
status = 'mcp-only';
|
||||||
|
}
|
||||||
|
|
||||||
|
const responseData = {
|
||||||
|
projectName,
|
||||||
|
projectPath,
|
||||||
|
status,
|
||||||
|
taskmaster: taskMasterResult,
|
||||||
|
mcp: mcpResult,
|
||||||
|
timestamp: new Date().toISOString()
|
||||||
|
};
|
||||||
|
|
||||||
|
res.json(responseData);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('TaskMaster detection error:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to detect TaskMaster configuration',
|
||||||
|
message: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/taskmaster/detect-all
|
||||||
|
* Detect TaskMaster configuration for all known projects
|
||||||
|
* This endpoint works with the existing projects system
|
||||||
|
*/
|
||||||
|
router.get('/detect-all', async (req, res) => {
|
||||||
|
try {
|
||||||
|
// Import getProjects from the projects module
|
||||||
|
const { getProjects } = await import('../projects.js');
|
||||||
|
const projects = await getProjects();
|
||||||
|
|
||||||
|
// Run detection for all projects in parallel
|
||||||
|
const detectionPromises = projects.map(async (project) => {
|
||||||
|
try {
|
||||||
|
// Use the project's fullPath if available, otherwise extract the directory
|
||||||
|
let projectPath;
|
||||||
|
if (project.fullPath) {
|
||||||
|
projectPath = project.fullPath;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
projectPath = await extractProjectDirectory(project.name);
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Failed to extract project directory: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [taskMasterResult, mcpResult] = await Promise.all([
|
||||||
|
detectTaskMasterFolder(projectPath),
|
||||||
|
detectTaskMasterMCPServer()
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Determine status
|
||||||
|
let status = 'not-configured';
|
||||||
|
if (taskMasterResult.hasTaskmaster && taskMasterResult.hasEssentialFiles) {
|
||||||
|
if (mcpResult.hasMCPServer && mcpResult.isConfigured) {
|
||||||
|
status = 'fully-configured';
|
||||||
|
} else {
|
||||||
|
status = 'taskmaster-only';
|
||||||
|
}
|
||||||
|
} else if (mcpResult.hasMCPServer && mcpResult.isConfigured) {
|
||||||
|
status = 'mcp-only';
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
projectName: project.name,
|
||||||
|
displayName: project.displayName,
|
||||||
|
projectPath,
|
||||||
|
status,
|
||||||
|
taskmaster: taskMasterResult,
|
||||||
|
mcp: mcpResult
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
projectName: project.name,
|
||||||
|
displayName: project.displayName,
|
||||||
|
status: 'error',
|
||||||
|
error: error.message
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const results = await Promise.all(detectionPromises);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
projects: results,
|
||||||
|
summary: {
|
||||||
|
total: results.length,
|
||||||
|
fullyConfigured: results.filter(p => p.status === 'fully-configured').length,
|
||||||
|
taskmasterOnly: results.filter(p => p.status === 'taskmaster-only').length,
|
||||||
|
mcpOnly: results.filter(p => p.status === 'mcp-only').length,
|
||||||
|
notConfigured: results.filter(p => p.status === 'not-configured').length,
|
||||||
|
errors: results.filter(p => p.status === 'error').length
|
||||||
|
},
|
||||||
|
timestamp: new Date().toISOString()
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Bulk TaskMaster detection error:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to detect TaskMaster configuration for projects',
|
||||||
|
message: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/taskmaster/initialize/:projectName
|
||||||
|
* Initialize TaskMaster in a project (placeholder for future CLI integration)
|
||||||
|
*/
|
||||||
|
router.post('/initialize/:projectName', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { projectName } = req.params;
|
||||||
|
const { rules } = req.body; // Optional rule profiles
|
||||||
|
|
||||||
|
// This will be implemented in a later subtask with CLI integration
|
||||||
|
res.status(501).json({
|
||||||
|
error: 'TaskMaster initialization not yet implemented',
|
||||||
|
message: 'This endpoint will execute task-master init via CLI in a future update',
|
||||||
|
projectName,
|
||||||
|
rules
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('TaskMaster initialization error:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to initialize TaskMaster',
|
||||||
|
message: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/taskmaster/next/:projectName
|
||||||
|
* Get the next recommended task using task-master CLI
|
||||||
|
*/
|
||||||
|
router.get('/next/:projectName', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { projectName } = req.params;
|
||||||
|
|
||||||
|
// Get project path
|
||||||
|
let projectPath;
|
||||||
|
try {
|
||||||
|
projectPath = await extractProjectDirectory(projectName);
|
||||||
|
} catch (error) {
|
||||||
|
return res.status(404).json({
|
||||||
|
error: 'Project not found',
|
||||||
|
message: `Project "${projectName}" does not exist`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to execute task-master next command
|
||||||
|
try {
|
||||||
|
const { spawn } = await import('child_process');
|
||||||
|
|
||||||
|
const nextTaskCommand = spawn('task-master', ['next'], {
|
||||||
|
cwd: projectPath,
|
||||||
|
stdio: ['pipe', 'pipe', 'pipe']
|
||||||
|
});
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
nextTaskCommand.stdout.on('data', (data) => {
|
||||||
|
stdout += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
nextTaskCommand.stderr.on('data', (data) => {
|
||||||
|
stderr += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
nextTaskCommand.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
reject(new Error(`task-master next failed with code ${code}: ${stderr}`));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
nextTaskCommand.on('error', (error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Parse the output - task-master next usually returns JSON
|
||||||
|
let nextTaskData = null;
|
||||||
|
if (stdout.trim()) {
|
||||||
|
try {
|
||||||
|
nextTaskData = JSON.parse(stdout);
|
||||||
|
} catch (parseError) {
|
||||||
|
// If not JSON, treat as plain text
|
||||||
|
nextTaskData = { message: stdout.trim() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
projectName,
|
||||||
|
projectPath,
|
||||||
|
nextTask: nextTaskData,
|
||||||
|
timestamp: new Date().toISOString()
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (cliError) {
|
||||||
|
console.warn('Failed to execute task-master CLI:', cliError.message);
|
||||||
|
|
||||||
|
// Fallback to loading tasks and finding next one locally
|
||||||
|
// Use localhost to bypass proxy for internal server-to-server calls
|
||||||
|
const tasksResponse = await fetch(`http://localhost:${process.env.SERVER_PORT || process.env.PORT || '3001'}/api/taskmaster/tasks/${encodeURIComponent(projectName)}`, {
|
||||||
|
headers: {
|
||||||
|
'Authorization': req.headers.authorization
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (tasksResponse.ok) {
|
||||||
|
const tasksData = await tasksResponse.json();
|
||||||
|
const nextTask = tasksData.tasks?.find(task =>
|
||||||
|
task.status === 'pending' || task.status === 'in-progress'
|
||||||
|
) || null;
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
projectName,
|
||||||
|
projectPath,
|
||||||
|
nextTask,
|
||||||
|
fallback: true,
|
||||||
|
message: 'Used fallback method (CLI not available)',
|
||||||
|
timestamp: new Date().toISOString()
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw new Error('Failed to load tasks via fallback method');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('TaskMaster next task error:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to get next task',
|
||||||
|
message: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /api/taskmaster/tasks/:projectName
|
* GET /api/taskmaster/tasks/:projectName
|
||||||
* Load actual tasks from .taskmaster/tasks/tasks.json
|
* Load actual tasks from .taskmaster/tasks/tasks.json
|
||||||
@@ -472,6 +904,66 @@ router.get('/prd/:projectName/:fileName', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DELETE /api/taskmaster/prd/:projectName/:fileName
|
||||||
|
* Delete a specific PRD file
|
||||||
|
*/
|
||||||
|
router.delete('/prd/:projectName/:fileName', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { projectName, fileName } = req.params;
|
||||||
|
|
||||||
|
// Get project path
|
||||||
|
let projectPath;
|
||||||
|
try {
|
||||||
|
projectPath = await extractProjectDirectory(projectName);
|
||||||
|
} catch (error) {
|
||||||
|
return res.status(404).json({
|
||||||
|
error: 'Project not found',
|
||||||
|
message: `Project "${projectName}" does not exist`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const filePath = path.join(projectPath, '.taskmaster', 'docs', fileName);
|
||||||
|
|
||||||
|
// Check if file exists
|
||||||
|
try {
|
||||||
|
await fsPromises.access(filePath, fs.constants.F_OK);
|
||||||
|
} catch (error) {
|
||||||
|
return res.status(404).json({
|
||||||
|
error: 'PRD file not found',
|
||||||
|
message: `File "${fileName}" does not exist`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the file
|
||||||
|
try {
|
||||||
|
await fsPromises.unlink(filePath);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
projectName,
|
||||||
|
projectPath,
|
||||||
|
fileName,
|
||||||
|
message: 'PRD file deleted successfully',
|
||||||
|
timestamp: new Date().toISOString()
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (deleteError) {
|
||||||
|
console.error('Failed to delete PRD file:', deleteError);
|
||||||
|
return res.status(500).json({
|
||||||
|
error: 'Failed to delete PRD file',
|
||||||
|
message: deleteError.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('PRD delete error:', error);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to delete PRD file',
|
||||||
|
message: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /api/taskmaster/init/:projectName
|
* POST /api/taskmaster/init/:projectName
|
||||||
* Initialize TaskMaster in a project
|
* Initialize TaskMaster in a project
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ function buildPushBody(event) {
|
|||||||
const message = CODE_MAP[event.code] || 'You have a new notification';
|
const message = CODE_MAP[event.code] || 'You have a new notification';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: sessionName || 'CloudCLI',
|
title: sessionName || 'Claude Code UI',
|
||||||
body: `${providerLabel}: ${message}`,
|
body: `${providerLabel}: ${message}`,
|
||||||
data: {
|
data: {
|
||||||
sessionId: event.sessionId || null,
|
sessionId: event.sessionId || null,
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
import type {
|
|
||||||
FetchHistoryOptions,
|
|
||||||
FetchHistoryResult,
|
|
||||||
LLMProvider,
|
|
||||||
McpScope,
|
|
||||||
NormalizedMessage,
|
|
||||||
ProviderAuthStatus,
|
|
||||||
ProviderMcpServer,
|
|
||||||
UpsertProviderMcpServerInput,
|
|
||||||
} from '@/shared/types.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main provider contract for CLI and SDK integrations.
|
|
||||||
*
|
|
||||||
* Each concrete provider owns its MCP/auth handlers plus the provider-specific
|
|
||||||
* logic for converting native events/history into the app's normalized shape.
|
|
||||||
*/
|
|
||||||
export interface IProvider {
|
|
||||||
readonly id: LLMProvider;
|
|
||||||
readonly mcp: IProviderMcp;
|
|
||||||
readonly auth: IProviderAuth;
|
|
||||||
|
|
||||||
normalizeMessage(raw: unknown, sessionId: string | null): NormalizedMessage[];
|
|
||||||
fetchHistory(sessionId: string, options?: FetchHistoryOptions): Promise<FetchHistoryResult>;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Auth contract for one provider.
|
|
||||||
*/
|
|
||||||
export interface IProviderAuth {
|
|
||||||
/**
|
|
||||||
* Checks whether the provider is installed and has usable credentials.
|
|
||||||
*/
|
|
||||||
getStatus(): Promise<ProviderAuthStatus>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MCP contract for one provider.
|
|
||||||
*/
|
|
||||||
export interface IProviderMcp {
|
|
||||||
listServers(options?: { workspacePath?: string }): Promise<Record<McpScope, ProviderMcpServer[]>>;
|
|
||||||
listServersForScope(scope: McpScope, options?: { workspacePath?: string }): Promise<ProviderMcpServer[]>;
|
|
||||||
upsertServer(input: UpsertProviderMcpServerInput): Promise<ProviderMcpServer>;
|
|
||||||
removeServer(
|
|
||||||
input: { name: string; scope?: McpScope; workspacePath?: string },
|
|
||||||
): Promise<{ removed: boolean; provider: LLMProvider; name: string; scope: McpScope }>;
|
|
||||||
}
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
// -------------- HTTP API response shapes for the server, shared across modules --------------
|
|
||||||
|
|
||||||
export type ApiSuccessShape<TData = unknown> = {
|
|
||||||
success: true;
|
|
||||||
data: TData;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ApiErrorShape = {
|
|
||||||
success: false;
|
|
||||||
error: {
|
|
||||||
code: string;
|
|
||||||
message: string;
|
|
||||||
details?: unknown;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export type LLMProvider = 'claude' | 'codex' | 'gemini' | 'cursor';
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export type MessageKind =
|
|
||||||
| 'text'
|
|
||||||
| 'tool_use'
|
|
||||||
| 'tool_result'
|
|
||||||
| 'thinking'
|
|
||||||
| 'stream_delta'
|
|
||||||
| 'stream_end'
|
|
||||||
| 'error'
|
|
||||||
| 'complete'
|
|
||||||
| 'status'
|
|
||||||
| 'permission_request'
|
|
||||||
| 'permission_cancelled'
|
|
||||||
| 'session_created'
|
|
||||||
| 'interactive_prompt'
|
|
||||||
| 'task_notification';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provider-neutral message event emitted over REST and realtime transports.
|
|
||||||
*
|
|
||||||
* Providers all produce their own native SDK/CLI event shapes, so this type keeps
|
|
||||||
* the common envelope strict while allowing provider-specific details to ride
|
|
||||||
* along as optional properties.
|
|
||||||
*/
|
|
||||||
export type NormalizedMessage = {
|
|
||||||
id: string;
|
|
||||||
sessionId: string;
|
|
||||||
timestamp: string;
|
|
||||||
provider: LLMProvider;
|
|
||||||
kind: MessageKind;
|
|
||||||
role?: 'user' | 'assistant';
|
|
||||||
content?: string;
|
|
||||||
images?: unknown;
|
|
||||||
toolName?: string;
|
|
||||||
toolInput?: unknown;
|
|
||||||
toolId?: string;
|
|
||||||
toolResult?: {
|
|
||||||
content?: string;
|
|
||||||
isError?: boolean;
|
|
||||||
toolUseResult?: unknown;
|
|
||||||
};
|
|
||||||
isError?: boolean;
|
|
||||||
text?: string;
|
|
||||||
tokens?: number;
|
|
||||||
canInterrupt?: boolean;
|
|
||||||
requestId?: string;
|
|
||||||
input?: unknown;
|
|
||||||
context?: unknown;
|
|
||||||
reason?: string;
|
|
||||||
newSessionId?: string;
|
|
||||||
status?: string;
|
|
||||||
summary?: string;
|
|
||||||
tokenBudget?: unknown;
|
|
||||||
subagentTools?: unknown;
|
|
||||||
toolUseResult?: unknown;
|
|
||||||
sequence?: number;
|
|
||||||
rowid?: number;
|
|
||||||
[key: string]: unknown;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pagination and provider lookup options for reading persisted session history.
|
|
||||||
*/
|
|
||||||
export type FetchHistoryOptions = {
|
|
||||||
/** Claude project folder name. Required by Claude history lookup. */
|
|
||||||
projectName?: string;
|
|
||||||
/** Absolute workspace path. Required by Cursor to compute its chat hash. */
|
|
||||||
projectPath?: string;
|
|
||||||
/** Page size. `null` means all messages. */
|
|
||||||
limit?: number | null;
|
|
||||||
/** Pagination offset from the newest messages. */
|
|
||||||
offset?: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provider-neutral history result returned by the unified messages endpoint.
|
|
||||||
*/
|
|
||||||
export type FetchHistoryResult = {
|
|
||||||
messages: NormalizedMessage[];
|
|
||||||
total: number;
|
|
||||||
hasMore: boolean;
|
|
||||||
offset: number;
|
|
||||||
limit: number | null;
|
|
||||||
tokenUsage?: unknown;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export type AppErrorOptions = {
|
|
||||||
code?: string;
|
|
||||||
statusCode?: number;
|
|
||||||
details?: unknown;
|
|
||||||
};
|
|
||||||
|
|
||||||
// -------------------- MCP related shared types --------------------
|
|
||||||
export type McpScope = 'user' | 'local' | 'project';
|
|
||||||
|
|
||||||
export type McpTransport = 'stdio' | 'http' | 'sse';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provider MCP server descriptor normalized for frontend consumption.
|
|
||||||
*/
|
|
||||||
export type ProviderMcpServer = {
|
|
||||||
provider: LLMProvider;
|
|
||||||
name: string;
|
|
||||||
scope: McpScope;
|
|
||||||
transport: McpTransport;
|
|
||||||
command?: string;
|
|
||||||
args?: string[];
|
|
||||||
env?: Record<string, string>;
|
|
||||||
cwd?: string;
|
|
||||||
url?: string;
|
|
||||||
headers?: Record<string, string>;
|
|
||||||
envVars?: string[];
|
|
||||||
bearerTokenEnvVar?: string;
|
|
||||||
envHttpHeaders?: Record<string, string>;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shared payload shape for MCP server create/update operations.
|
|
||||||
*/
|
|
||||||
export type UpsertProviderMcpServerInput = {
|
|
||||||
name: string;
|
|
||||||
scope?: McpScope;
|
|
||||||
transport: McpTransport;
|
|
||||||
workspacePath?: string;
|
|
||||||
command?: string;
|
|
||||||
args?: string[];
|
|
||||||
env?: Record<string, string>;
|
|
||||||
cwd?: string;
|
|
||||||
url?: string;
|
|
||||||
headers?: Record<string, string>;
|
|
||||||
envVars?: string[];
|
|
||||||
bearerTokenEnvVar?: string;
|
|
||||||
envHttpHeaders?: Record<string, string>;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// -------------------- Provider auth status types --------------------
|
|
||||||
/**
|
|
||||||
* Result of a provider status check (installation + authentication).
|
|
||||||
*
|
|
||||||
* installed - Whether the provider's CLI/SDK is available
|
|
||||||
* provider - Provider id the status belongs to
|
|
||||||
* authenticated - Whether valid credentials exist
|
|
||||||
* email - User email or auth method identifier
|
|
||||||
* method - Auth method (e.g. 'api_key', 'credentials_file')
|
|
||||||
* [error] - Error message if not installed or not authenticated
|
|
||||||
*/
|
|
||||||
export type ProviderAuthStatus = {
|
|
||||||
installed: boolean;
|
|
||||||
provider: LLMProvider;
|
|
||||||
authenticated: boolean;
|
|
||||||
email: string | null;
|
|
||||||
method: string | null;
|
|
||||||
error?: string;
|
|
||||||
};
|
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
|
|
||||||
import { randomUUID } from 'node:crypto';
|
|
||||||
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
||||||
import path from 'node:path';
|
|
||||||
|
|
||||||
import type { NextFunction, Request, RequestHandler, Response } from 'express';
|
|
||||||
|
|
||||||
import type {
|
|
||||||
ApiErrorShape,
|
|
||||||
ApiSuccessShape,
|
|
||||||
AppErrorOptions,
|
|
||||||
NormalizedMessage,
|
|
||||||
} from '@/shared/types.js';
|
|
||||||
|
|
||||||
type NormalizedMessageInput =
|
|
||||||
{
|
|
||||||
kind: NormalizedMessage['kind'];
|
|
||||||
provider: NormalizedMessage['provider'];
|
|
||||||
id?: string | null;
|
|
||||||
sessionId?: string | null;
|
|
||||||
timestamp?: string | null;
|
|
||||||
} & Record<string, unknown>;
|
|
||||||
|
|
||||||
export function createApiSuccessResponse<TData>(
|
|
||||||
data: TData,
|
|
||||||
): ApiSuccessShape<TData> {
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
data,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createApiErrorResponse(
|
|
||||||
code: string,
|
|
||||||
message: string,
|
|
||||||
details?: unknown
|
|
||||||
): ApiErrorShape {
|
|
||||||
return {
|
|
||||||
success: false,
|
|
||||||
error: {
|
|
||||||
code,
|
|
||||||
message,
|
|
||||||
details,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function asyncHandler(
|
|
||||||
handler: (req: Request, res: Response, next: NextFunction) => Promise<unknown>
|
|
||||||
): RequestHandler {
|
|
||||||
return (req, res, next) => {
|
|
||||||
void Promise.resolve(handler(req, res, next)).catch(next);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------- Global app error class for consistent error handling across the server ---------
|
|
||||||
export class AppError extends Error {
|
|
||||||
readonly code: string;
|
|
||||||
readonly statusCode: number;
|
|
||||||
readonly details?: unknown;
|
|
||||||
|
|
||||||
constructor(message: string, options: AppErrorOptions = {}) {
|
|
||||||
super(message);
|
|
||||||
this.name = 'AppError';
|
|
||||||
this.code = options.code ?? 'INTERNAL_ERROR';
|
|
||||||
this.statusCode = options.statusCode ?? 500;
|
|
||||||
this.details = options.details;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ------------------------ Normalized provider message helpers ------------------------
|
|
||||||
/**
|
|
||||||
* Generates a stable unique id for normalized provider messages.
|
|
||||||
*/
|
|
||||||
export function generateMessageId(prefix = 'msg'): string {
|
|
||||||
return `${prefix}_${randomUUID()}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a normalized provider message and fills the shared envelope fields.
|
|
||||||
*
|
|
||||||
* Provider adapters and live SDK handlers pass through provider-specific fields,
|
|
||||||
* while this helper guarantees every emitted event has an id, session id,
|
|
||||||
* timestamp, and provider marker.
|
|
||||||
*/
|
|
||||||
export function createNormalizedMessage(fields: NormalizedMessageInput): NormalizedMessage {
|
|
||||||
return {
|
|
||||||
...fields,
|
|
||||||
id: fields.id || generateMessageId(fields.kind),
|
|
||||||
sessionId: fields.sessionId || '',
|
|
||||||
timestamp: fields.timestamp || new Date().toISOString(),
|
|
||||||
provider: fields.provider,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ------------------------ The following are mainly for provider MCP runtimes ------------------------
|
|
||||||
/**
|
|
||||||
* Safely narrows an unknown value to a plain object record.
|
|
||||||
*
|
|
||||||
* This deliberately rejects arrays, `null`, and primitive values so callers can
|
|
||||||
* treat the returned value as a JSON-style object map without repeating the same
|
|
||||||
* defensive shape checks at every config read site.
|
|
||||||
*/
|
|
||||||
export const readObjectRecord = (value: unknown): Record<string, unknown> | null => {
|
|
||||||
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value as Record<string, unknown>;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads an optional string from unknown input and normalizes empty or whitespace-only
|
|
||||||
* values to `undefined`.
|
|
||||||
*
|
|
||||||
* This is useful when parsing config files where a field may be missing, present
|
|
||||||
* with the wrong type, or present as an empty string that should be treated as
|
|
||||||
* "not configured".
|
|
||||||
*/
|
|
||||||
export const readOptionalString = (value: unknown): string | undefined => {
|
|
||||||
if (typeof value !== 'string') {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalized = value.trim();
|
|
||||||
return normalized.length > 0 ? normalized : undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads an optional string array from unknown input.
|
|
||||||
*
|
|
||||||
* Non-array values are ignored, and any array entries that are not strings are
|
|
||||||
* filtered out. This lets provider config readers consume loosely shaped JSON/TOML
|
|
||||||
* data without failing on incidental invalid members.
|
|
||||||
*/
|
|
||||||
export const readStringArray = (value: unknown): string[] | undefined => {
|
|
||||||
if (!Array.isArray(value)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value.filter((entry): entry is string => typeof entry === 'string');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads an optional string-to-string map from unknown input.
|
|
||||||
*
|
|
||||||
* The function first ensures the source value is a plain object, then keeps only
|
|
||||||
* keys whose values are strings. If no valid entries remain, it returns `undefined`
|
|
||||||
* so callers can distinguish "no usable map" from an empty object that was
|
|
||||||
* intentionally authored downstream.
|
|
||||||
*/
|
|
||||||
export const readStringRecord = (value: unknown): Record<string, string> | undefined => {
|
|
||||||
const record = readObjectRecord(value);
|
|
||||||
if (!record) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalized: Record<string, string> = {};
|
|
||||||
for (const [key, entry] of Object.entries(record)) {
|
|
||||||
if (typeof entry === 'string') {
|
|
||||||
normalized[key] = entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.keys(normalized).length > 0 ? normalized : undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads a JSON config file and guarantees a plain object result.
|
|
||||||
*
|
|
||||||
* Missing files are treated as an empty config object so provider-specific MCP
|
|
||||||
* readers can operate against first-run environments without special-case file
|
|
||||||
* existence checks. If the file exists but contains invalid JSON, the parse error
|
|
||||||
* is preserved and rethrown.
|
|
||||||
*/
|
|
||||||
export const readJsonConfig = async (filePath: string): Promise<Record<string, unknown>> => {
|
|
||||||
try {
|
|
||||||
const content = await readFile(filePath, 'utf8');
|
|
||||||
const parsed = JSON.parse(content) as Record<string, unknown>;
|
|
||||||
return readObjectRecord(parsed) ?? {};
|
|
||||||
} catch (error) {
|
|
||||||
const code = (error as NodeJS.ErrnoException).code;
|
|
||||||
if (code === 'ENOENT') {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a JSON config file with stable, human-readable formatting.
|
|
||||||
*
|
|
||||||
* The parent directory is created automatically so callers can persist config into
|
|
||||||
* provider-specific folders without pre-creating the directory tree. Output always
|
|
||||||
* ends with a trailing newline to keep the file diff-friendly.
|
|
||||||
*/
|
|
||||||
export const writeJsonConfig = async (filePath: string, data: Record<string, unknown>): Promise<void> => {
|
|
||||||
await mkdir(path.dirname(filePath), { recursive: true });
|
|
||||||
await writeFile(filePath, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
|
|
||||||
};
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
32
server/src/app.ts
Normal file
32
server/src/app.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import './config/load-env-vars.js';
|
||||||
|
|
||||||
|
import { pathToFileURL } from 'url';
|
||||||
|
|
||||||
|
import { getRuntimePaths } from '@/config/runtime.js';
|
||||||
|
import type { ServerApplication } from '@/shared/types/app.js';
|
||||||
|
import { logger } from '@/shared/utils/logger.js';
|
||||||
|
|
||||||
|
export function createServerApplication(): ServerApplication {
|
||||||
|
const runtimePaths = getRuntimePaths();
|
||||||
|
|
||||||
|
return {
|
||||||
|
runtimePaths,
|
||||||
|
start: async () => {
|
||||||
|
// ----------------------------------------------
|
||||||
|
// Legacy backend Runner
|
||||||
|
// logger.info('Bootstrapping backend via legacy runtime bridge', {
|
||||||
|
// legacyRuntime: runtimePaths.legacyRuntimePath,
|
||||||
|
// });
|
||||||
|
// await import(pathToFileURL(runtimePaths.legacyRuntimePath).href);
|
||||||
|
// ----------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------
|
||||||
|
// Refactor backend Runner
|
||||||
|
logger.info('Bootstrapping backend via refactor runtime', {
|
||||||
|
refactorRuntime: runtimePaths.refactorRuntimePath,
|
||||||
|
});
|
||||||
|
await import(pathToFileURL(runtimePaths.refactorRuntimePath).href);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
8
server/src/bootstrap.ts
Normal file
8
server/src/bootstrap.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { createServerApplication } from '@/app.js';
|
||||||
|
|
||||||
|
async function startServerApplication(): Promise<void> {
|
||||||
|
const application = createServerApplication();
|
||||||
|
await application.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
await startServerApplication();
|
||||||
5
server/src/config/env.ts
Normal file
5
server/src/config/env.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
/**
|
||||||
|
* Environment Flag: Is Platform
|
||||||
|
* Indicates if the app is running in Platform mode (hosted) or OSS mode (self-hosted)
|
||||||
|
*/
|
||||||
|
export const IS_PLATFORM = process.env.VITE_IS_PLATFORM === 'true';
|
||||||
30
server/src/config/load-env-vars.ts
Normal file
30
server/src/config/load-env-vars.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
// Load environment variables from .env before other imports execute.
|
||||||
|
import fs from 'fs';
|
||||||
|
import os from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
import { dirname } from 'path';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = dirname(__filename);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const envPath = path.join(__dirname, '../../../.env');
|
||||||
|
const envFile = fs.readFileSync(envPath, 'utf8');
|
||||||
|
envFile.split('\n').forEach(line => {
|
||||||
|
const trimmedLine = line.trim();
|
||||||
|
if (trimmedLine && !trimmedLine.startsWith('#')) {
|
||||||
|
const [key, ...valueParts] = trimmedLine.split('=');
|
||||||
|
if (key && valueParts.length > 0 && !process.env[key]) {
|
||||||
|
process.env[key] = valueParts.join('=').trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log('No .env file found or error reading it:', e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set a default DATABASE_PATH if not already set by .env to ~/.cloudcli/auth.db
|
||||||
|
if (!process.env.DATABASE_PATH) {
|
||||||
|
process.env.DATABASE_PATH = path.join(os.homedir(), '.cloudcli', 'auth.db');
|
||||||
|
}
|
||||||
27
server/src/config/runtime.ts
Normal file
27
server/src/config/runtime.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
import type { RuntimePaths } from '@/shared/types/app.js';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
const RUN_REFACTOR_WITH_SRC = true;
|
||||||
|
|
||||||
|
export function getRuntimePaths(): RuntimePaths {
|
||||||
|
const serverSrcDir = path.resolve(__dirname, '..');
|
||||||
|
const serverDir = path.resolve(serverSrcDir, '..');
|
||||||
|
const refactorRuntimePath =
|
||||||
|
RUN_REFACTOR_WITH_SRC
|
||||||
|
? path.join(serverDir, 'src', 'runner.ts')
|
||||||
|
: path.join(serverDir, 'dist', 'runner.js');
|
||||||
|
|
||||||
|
return {
|
||||||
|
serverSrcDir,
|
||||||
|
serverDir,
|
||||||
|
projectRoot: path.resolve(serverDir, '..'),
|
||||||
|
legacyRuntimePath: path.join(serverDir, 'index.js'),
|
||||||
|
bootstrapEntrypointPath: path.join(serverDir, 'dist', 'bootstrap.js'),
|
||||||
|
refactorRuntimePath
|
||||||
|
};
|
||||||
|
}
|
||||||
1
server/src/modules/agent/.gitkeep
Normal file
1
server/src/modules/agent/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
1238
server/src/modules/agent/agent.routes.js
Normal file
1238
server/src/modules/agent/agent.routes.js
Normal file
File diff suppressed because it is too large
Load Diff
42
server/src/modules/ai-runtime/ai-runtime.registry.ts
Normal file
42
server/src/modules/ai-runtime/ai-runtime.registry.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import type { IProvider } from '@/modules/ai-runtime/types/index.js';
|
||||||
|
import { ClaudeProvider } from '@/modules/ai-runtime/providers/claude/claude.provider.js';
|
||||||
|
import { CodexProvider } from '@/modules/ai-runtime/providers/codex/codex.provider.js';
|
||||||
|
import { CursorProvider } from '@/modules/ai-runtime/providers/cursor/cursor.provider.js';
|
||||||
|
import { GeminiProvider } from '@/modules/ai-runtime/providers/gemini/gemini.provider.js';
|
||||||
|
import type { LLMProvider } from '@/shared/types/app.js';
|
||||||
|
import { AppError } from '@/shared/utils/app-error.js';
|
||||||
|
|
||||||
|
const providers: Record<LLMProvider, IProvider> = {
|
||||||
|
claude: new ClaudeProvider(),
|
||||||
|
codex: new CodexProvider(),
|
||||||
|
cursor: new CursorProvider(),
|
||||||
|
gemini: new GeminiProvider(),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Central registry for resolving provider implementations by id.
|
||||||
|
*/
|
||||||
|
export const llmProviderRegistry = {
|
||||||
|
/**
|
||||||
|
* Returns all registered providers.
|
||||||
|
*/
|
||||||
|
listProviders(): IProvider[] {
|
||||||
|
return Object.values(providers);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves one provider or throws a typed 400 error.
|
||||||
|
*/
|
||||||
|
resolveProvider(provider: string): IProvider {
|
||||||
|
const key = provider as LLMProvider;
|
||||||
|
const resolvedProvider = providers[key];
|
||||||
|
if (!resolvedProvider) {
|
||||||
|
throw new AppError(`Unsupported provider "${provider}".`, {
|
||||||
|
code: 'UNSUPPORTED_PROVIDER',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolvedProvider;
|
||||||
|
},
|
||||||
|
};
|
||||||
563
server/src/modules/ai-runtime/ai-runtime.routes.ts
Normal file
563
server/src/modules/ai-runtime/ai-runtime.routes.ts
Normal file
@@ -0,0 +1,563 @@
|
|||||||
|
import express, { type NextFunction, type Request, type Response } from 'express';
|
||||||
|
|
||||||
|
import { asyncHandler } from '@/shared/http/async-handler.js';
|
||||||
|
import { AppError } from '@/shared/utils/app-error.js';
|
||||||
|
import { createApiErrorResponse, createApiSuccessResponse } from '@/shared/http/api-response.js';
|
||||||
|
import { llmService } from '@/modules/ai-runtime/services/ai-runtime.service.js';
|
||||||
|
import { llmAuthService } from '@/modules/ai-runtime/services/auth.service.js';
|
||||||
|
import { llmSessionsService } from '@/modules/ai-runtime/services/sessions.service.js';
|
||||||
|
import { llmMcpService } from '@/modules/ai-runtime/services/mcp.service.js';
|
||||||
|
import { llmSkillsService } from '@/modules/ai-runtime/services/skills.service.js';
|
||||||
|
import type { McpScope, McpTransport, UpsertProviderMcpServerInput } from '@/modules/ai-runtime/types/index.js';
|
||||||
|
import { llmMessagesUnifier } from '@/modules/ai-runtime/services/messages-unifier.service.js';
|
||||||
|
import type { LLMProvider } from '@/shared/types/app.js';
|
||||||
|
import { logger } from '@/shared/utils/logger.js';
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Safely reads an Express path parameter that may arrive as string or string[].
|
||||||
|
*/
|
||||||
|
const readPathParam = (value: unknown, name: string): string => {
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(value) && typeof value[0] === 'string') {
|
||||||
|
return value[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new AppError(`${name} path parameter is invalid.`, {
|
||||||
|
code: 'INVALID_PATH_PARAMETER',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const normalizeProviderParam = (value: unknown): string =>
|
||||||
|
readPathParam(value, 'provider').trim().toLowerCase();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates and normalizes rename payload.
|
||||||
|
*/
|
||||||
|
const parseRenamePayload = (payload: unknown): { summary: string } => {
|
||||||
|
if (!payload || typeof payload !== 'object') {
|
||||||
|
throw new AppError('Request body must be an object.', {
|
||||||
|
code: 'INVALID_REQUEST_BODY',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = payload as Record<string, unknown>;
|
||||||
|
const summary = typeof body.summary === 'string' ? body.summary.trim() : '';
|
||||||
|
if (!summary) {
|
||||||
|
throw new AppError('summary is required.', {
|
||||||
|
code: 'SUMMARY_REQUIRED',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (summary.length > 500) {
|
||||||
|
throw new AppError('summary must not exceed 500 characters.', {
|
||||||
|
code: 'SUMMARY_TOO_LONG',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return { summary };
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads optional query values and trims surrounding whitespace.
|
||||||
|
*/
|
||||||
|
const readOptionalQueryString = (value: unknown): string | undefined => {
|
||||||
|
if (typeof value !== 'string') {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalized = value.trim();
|
||||||
|
return normalized.length > 0 ? normalized : undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates MCP scope query/body values.
|
||||||
|
*/
|
||||||
|
const parseMcpScope = (value: unknown): McpScope | undefined => {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalized = readOptionalQueryString(value);
|
||||||
|
if (!normalized) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalized === 'user' || normalized === 'local' || normalized === 'project') {
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new AppError(`Unsupported MCP scope "${normalized}".`, {
|
||||||
|
code: 'INVALID_MCP_SCOPE',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates MCP transport query/body values.
|
||||||
|
*/
|
||||||
|
const parseMcpTransport = (value: unknown): McpTransport => {
|
||||||
|
const normalized = readOptionalQueryString(value);
|
||||||
|
if (!normalized) {
|
||||||
|
throw new AppError('transport is required.', {
|
||||||
|
code: 'MCP_TRANSPORT_REQUIRED',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalized === 'stdio' || normalized === 'http' || normalized === 'sse') {
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new AppError(`Unsupported MCP transport "${normalized}".`, {
|
||||||
|
code: 'INVALID_MCP_TRANSPORT',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses and validates MCP upsert payload.
|
||||||
|
*/
|
||||||
|
const parseMcpUpsertPayload = (payload: unknown): UpsertProviderMcpServerInput => {
|
||||||
|
if (!payload || typeof payload !== 'object') {
|
||||||
|
throw new AppError('Request body must be an object.', {
|
||||||
|
code: 'INVALID_REQUEST_BODY',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = payload as Record<string, unknown>;
|
||||||
|
const name = readOptionalQueryString(body.name);
|
||||||
|
if (!name) {
|
||||||
|
throw new AppError('name is required.', {
|
||||||
|
code: 'MCP_NAME_REQUIRED',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const transport = parseMcpTransport(body.transport);
|
||||||
|
const scope = parseMcpScope(body.scope);
|
||||||
|
const workspacePath = readOptionalQueryString(body.workspacePath);
|
||||||
|
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
transport,
|
||||||
|
scope,
|
||||||
|
workspacePath,
|
||||||
|
command: readOptionalQueryString(body.command),
|
||||||
|
args: Array.isArray(body.args) ? body.args.filter((entry): entry is string => typeof entry === 'string') : undefined,
|
||||||
|
env: typeof body.env === 'object' && body.env !== null
|
||||||
|
? Object.fromEntries(
|
||||||
|
Object.entries(body.env as Record<string, unknown>).filter(
|
||||||
|
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: undefined,
|
||||||
|
cwd: readOptionalQueryString(body.cwd),
|
||||||
|
url: readOptionalQueryString(body.url),
|
||||||
|
headers: typeof body.headers === 'object' && body.headers !== null
|
||||||
|
? Object.fromEntries(
|
||||||
|
Object.entries(body.headers as Record<string, unknown>).filter(
|
||||||
|
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: undefined,
|
||||||
|
envVars: Array.isArray(body.envVars)
|
||||||
|
? body.envVars.filter((entry): entry is string => typeof entry === 'string')
|
||||||
|
: undefined,
|
||||||
|
bearerTokenEnvVar: readOptionalQueryString(body.bearerTokenEnvVar),
|
||||||
|
envHttpHeaders: typeof body.envHttpHeaders === 'object' && body.envHttpHeaders !== null
|
||||||
|
? Object.fromEntries(
|
||||||
|
Object.entries(body.envHttpHeaders as Record<string, unknown>).filter(
|
||||||
|
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: undefined,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts any provider route parameter into the strongly typed provider union.
|
||||||
|
*/
|
||||||
|
const parseProvider = (value: unknown): LLMProvider => {
|
||||||
|
const normalized = normalizeProviderParam(value);
|
||||||
|
if (normalized === 'claude' || normalized === 'codex' || normalized === 'cursor' || normalized === 'gemini') {
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new AppError(`Unsupported provider "${normalized}".`, {
|
||||||
|
code: 'UNSUPPORTED_PROVIDER',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enriches provider session snapshots with normalized message types for frontend rendering.
|
||||||
|
*/
|
||||||
|
const formatSessionSnapshot = (
|
||||||
|
provider: LLMProvider,
|
||||||
|
snapshot: {
|
||||||
|
sessionId: string;
|
||||||
|
events: Array<{
|
||||||
|
timestamp: string;
|
||||||
|
channel: 'sdk' | 'stdout' | 'stderr' | 'json' | 'system' | 'error';
|
||||||
|
message?: string;
|
||||||
|
data?: unknown;
|
||||||
|
}>;
|
||||||
|
},
|
||||||
|
) => ({
|
||||||
|
...snapshot,
|
||||||
|
messages: llmMessagesUnifier.normalizeSessionEvents(provider, snapshot.sessionId, snapshot.events),
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
'/providers',
|
||||||
|
asyncHandler(async (_req: Request, res: Response) => {
|
||||||
|
res.json(createApiSuccessResponse({ providers: llmService.listProviders() }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
'/providers/:provider/models',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const models = await llmService.listModels(provider);
|
||||||
|
res.json(createApiSuccessResponse({ provider, models }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
'/providers/:provider/auth/status',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const auth = await llmAuthService.getProviderAuthStatus(provider);
|
||||||
|
res.json(createApiSuccessResponse({ provider, auth }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
'/providers/:provider/sessions',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const sessions = llmService.listSessions(provider).map((session) => formatSessionSnapshot(provider, session));
|
||||||
|
res.json(createApiSuccessResponse({ provider, sessions }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
'/providers/:provider/sessions/:sessionId',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||||
|
const session = llmService.getSession(provider, sessionId);
|
||||||
|
if (!session) {
|
||||||
|
throw new AppError(`Session "${sessionId}" not found for provider "${provider}".`, {
|
||||||
|
code: 'SESSION_NOT_FOUND',
|
||||||
|
statusCode: 404,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json(createApiSuccessResponse({ provider, session: formatSessionSnapshot(provider, session) }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
'/providers/:provider/sessions/start',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const snapshot = await llmService.startSession(provider, req.body);
|
||||||
|
const formattedSnapshot = formatSessionSnapshot(provider, snapshot);
|
||||||
|
res.status(202).json(
|
||||||
|
createApiSuccessResponse({
|
||||||
|
provider,
|
||||||
|
session: formattedSnapshot,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
'/providers/:provider/sessions/:sessionId/resume',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||||
|
|
||||||
|
const snapshot = await llmService.resumeSession(provider, sessionId, req.body);
|
||||||
|
res.status(202).json(createApiSuccessResponse({ provider, session: formatSessionSnapshot(provider, snapshot) }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
'/providers/:provider/sessions/:sessionId/stop',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||||
|
const stopped = await llmService.stopSession(provider, sessionId);
|
||||||
|
res.json(createApiSuccessResponse({ provider, sessionId, stopped }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists MCP servers for one provider grouped by user/local/project scopes.
|
||||||
|
*/
|
||||||
|
router.get(
|
||||||
|
'/providers/:provider/mcp/servers',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const workspacePath = readOptionalQueryString(req.query.workspacePath);
|
||||||
|
const scope = parseMcpScope(req.query.scope);
|
||||||
|
|
||||||
|
if (scope) {
|
||||||
|
const servers = await llmMcpService.listProviderMcpServersForScope(provider, scope, { workspacePath });
|
||||||
|
res.json(createApiSuccessResponse({ provider, scope, servers }));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupedServers = await llmMcpService.listProviderMcpServers(provider, { workspacePath });
|
||||||
|
res.json(createApiSuccessResponse({ provider, scopes: groupedServers }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds one MCP server for one provider and scope.
|
||||||
|
*/
|
||||||
|
router.post(
|
||||||
|
'/providers/:provider/mcp/servers',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const payload = parseMcpUpsertPayload(req.body);
|
||||||
|
const server = await llmMcpService.upsertProviderMcpServer(provider, payload);
|
||||||
|
res.status(201).json(createApiSuccessResponse({ server }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates one provider MCP server definition.
|
||||||
|
*/
|
||||||
|
router.put(
|
||||||
|
'/providers/:provider/mcp/servers/:name',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const payload = parseMcpUpsertPayload({
|
||||||
|
...((req.body && typeof req.body === 'object') ? req.body as Record<string, unknown> : {}),
|
||||||
|
name: readPathParam(req.params.name, 'name'),
|
||||||
|
});
|
||||||
|
const server = await llmMcpService.upsertProviderMcpServer(provider, payload);
|
||||||
|
res.json(createApiSuccessResponse({ server }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes one provider MCP server from its configured scope.
|
||||||
|
*/
|
||||||
|
router.delete(
|
||||||
|
'/providers/:provider/mcp/servers/:name',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const scope = parseMcpScope(req.query.scope);
|
||||||
|
const workspacePath = readOptionalQueryString(req.query.workspacePath);
|
||||||
|
const result = await llmMcpService.removeProviderMcpServer(provider, {
|
||||||
|
name: readPathParam(req.params.name, 'name'),
|
||||||
|
scope,
|
||||||
|
workspacePath,
|
||||||
|
});
|
||||||
|
res.json(createApiSuccessResponse(result));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes a lightweight startup/connectivity probe for one provider MCP server.
|
||||||
|
*/
|
||||||
|
router.post(
|
||||||
|
'/providers/:provider/mcp/servers/:name/run',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const body = (req.body as Record<string, unknown> | undefined) ?? {};
|
||||||
|
const scope = parseMcpScope(body.scope ?? req.query.scope);
|
||||||
|
const workspacePath = readOptionalQueryString(body.workspacePath ?? req.query.workspacePath);
|
||||||
|
const result = await llmMcpService.runProviderMcpServer(provider, {
|
||||||
|
name: readPathParam(req.params.name, 'name'),
|
||||||
|
scope,
|
||||||
|
workspacePath,
|
||||||
|
});
|
||||||
|
res.json(createApiSuccessResponse(result));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds one HTTP/stdio MCP server to every provider.
|
||||||
|
*/
|
||||||
|
router.post(
|
||||||
|
'/mcp/servers/global',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const payload = parseMcpUpsertPayload(req.body);
|
||||||
|
if (payload.scope === 'local') {
|
||||||
|
throw new AppError('Global MCP add supports only "user" or "project" scopes.', {
|
||||||
|
code: 'INVALID_GLOBAL_MCP_SCOPE',
|
||||||
|
statusCode: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const results = await llmMcpService.addMcpServerToAllProviders({
|
||||||
|
...payload,
|
||||||
|
scope: payload.scope === 'user' ? 'user' : 'project',
|
||||||
|
});
|
||||||
|
res.status(201).json(createApiSuccessResponse({ results }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists provider-specific skills from all documented skill directories.
|
||||||
|
*/
|
||||||
|
router.get(
|
||||||
|
'/providers/:provider/skills',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider = parseProvider(req.params.provider);
|
||||||
|
const workspacePath = readOptionalQueryString(req.query.workspacePath);
|
||||||
|
const skills = await llmSkillsService.listProviderSkills(provider, { workspacePath });
|
||||||
|
res.json(createApiSuccessResponse({ provider, skills }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists skills for one provider or for all providers in a single response.
|
||||||
|
*/
|
||||||
|
router.get(
|
||||||
|
'/skills',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const providerQuery = readOptionalQueryString(req.query.provider);
|
||||||
|
const workspacePath = readOptionalQueryString(req.query.workspacePath);
|
||||||
|
if (providerQuery) {
|
||||||
|
const provider = parseProvider(providerQuery);
|
||||||
|
const skills = await llmSkillsService.listProviderSkills(provider, { workspacePath });
|
||||||
|
res.json(createApiSuccessResponse({ provider, skills }));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const providers: LLMProvider[] = ['claude', 'codex', 'cursor', 'gemini'];
|
||||||
|
const byProvider = Object.fromEntries(
|
||||||
|
await Promise.all(
|
||||||
|
providers.map(async (provider) => ([
|
||||||
|
provider,
|
||||||
|
await llmSkillsService.listProviderSkills(provider, { workspacePath }),
|
||||||
|
])),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
res.json(createApiSuccessResponse({ providers: byProvider }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
'/sessions/:sessionId/messages',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||||
|
const history = await llmSessionsService.getSessionHistory(sessionId);
|
||||||
|
res.json(createApiSuccessResponse({
|
||||||
|
sessionId,
|
||||||
|
provider: history.provider,
|
||||||
|
messages: history.messages,
|
||||||
|
}));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
'/sessions/:sessionId/history',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||||
|
const history = await llmSessionsService.getSessionHistory(sessionId);
|
||||||
|
res.json(createApiSuccessResponse(history));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renames one indexed session by writing the custom summary into DB.
|
||||||
|
*/
|
||||||
|
router.put(
|
||||||
|
'/sessions/:sessionId/rename',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||||
|
const { summary } = parseRenamePayload(req.body);
|
||||||
|
llmSessionsService.updateSessionCustomName(sessionId, summary);
|
||||||
|
res.json(createApiSuccessResponse({ sessionId, summary }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns DB-indexed sessions discovered by the session-processor scan.
|
||||||
|
*/
|
||||||
|
router.get(
|
||||||
|
'/sessions/index',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const provider =
|
||||||
|
typeof req.query.provider === 'string' ? req.query.provider.trim().toLowerCase() : undefined;
|
||||||
|
const sessions = llmSessionsService.listIndexedSessions(provider);
|
||||||
|
res.json(createApiSuccessResponse({ provider: provider ?? null, sessions }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns one DB-indexed session metadata row.
|
||||||
|
*/
|
||||||
|
router.get(
|
||||||
|
'/sessions/:sessionId',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||||
|
const session = llmSessionsService.getIndexedSession(sessionId);
|
||||||
|
res.json(createApiSuccessResponse({ session }));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers provider disk scans and refreshes the shared sessions table.
|
||||||
|
*/
|
||||||
|
router.post(
|
||||||
|
'/sessions/sync',
|
||||||
|
asyncHandler(async (_req: Request, res: Response) => {
|
||||||
|
const syncResult = await llmSessionsService.synchronizeSessions();
|
||||||
|
res.json(createApiSuccessResponse(syncResult));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes provider-specific session artifacts and removes the DB row.
|
||||||
|
*/
|
||||||
|
router.delete(
|
||||||
|
'/sessions/:sessionId',
|
||||||
|
asyncHandler(async (req: Request, res: Response) => {
|
||||||
|
const sessionId = readPathParam(req.params.sessionId, 'sessionId');
|
||||||
|
const result = await llmSessionsService.deleteSessionArtifacts(sessionId);
|
||||||
|
res.json(createApiSuccessResponse(result));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizes route-level failures to a consistent JSON API shape.
|
||||||
|
*/
|
||||||
|
router.use((error: unknown, _req: Request, res: Response, _next: NextFunction) => {
|
||||||
|
if (res.headersSent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error instanceof AppError) {
|
||||||
|
res
|
||||||
|
.status(error.statusCode)
|
||||||
|
.json(createApiErrorResponse(error.code, error.message, undefined, error.details));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const message = error instanceof Error ? error.message : 'Unexpected LLM route failure.';
|
||||||
|
logger.error(message, {
|
||||||
|
module: 'ai-runtime.routes',
|
||||||
|
});
|
||||||
|
|
||||||
|
res.status(500).json(createApiErrorResponse('INTERNAL_ERROR', message));
|
||||||
|
});
|
||||||
|
|
||||||
|
export default router;
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
import type {
|
||||||
|
IProvider,
|
||||||
|
IProviderAuthRuntime,
|
||||||
|
IProviderMcpRuntime,
|
||||||
|
IProviderSessionSynchronizerRuntime,
|
||||||
|
IProviderSkillsRuntime,
|
||||||
|
MutableProviderSession,
|
||||||
|
ProviderCapabilities,
|
||||||
|
ProviderExecutionFamily,
|
||||||
|
ProviderModel,
|
||||||
|
ProviderSessionEvent,
|
||||||
|
ProviderSessionSnapshot,
|
||||||
|
StartSessionInput,
|
||||||
|
} from '@/modules/ai-runtime/types/index.js';
|
||||||
|
import type { LLMProvider } from '@/shared/types/app.js';
|
||||||
|
|
||||||
|
const MAX_EVENT_BUFFER_SIZE = 2_000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared provider base for session lifecycle state and capability gating.
|
||||||
|
*/
|
||||||
|
export abstract class AbstractProvider implements IProvider {
|
||||||
|
readonly id: LLMProvider;
|
||||||
|
readonly family: ProviderExecutionFamily;
|
||||||
|
readonly capabilities: ProviderCapabilities;
|
||||||
|
abstract readonly mcp: IProviderMcpRuntime;
|
||||||
|
abstract readonly skills: IProviderSkillsRuntime;
|
||||||
|
abstract readonly sessionSynchronizer: IProviderSessionSynchronizerRuntime;
|
||||||
|
abstract readonly auth: IProviderAuthRuntime;
|
||||||
|
|
||||||
|
protected readonly sessions = new Map<string, MutableProviderSession>();
|
||||||
|
|
||||||
|
protected constructor(
|
||||||
|
id: LLMProvider,
|
||||||
|
family: ProviderExecutionFamily,
|
||||||
|
capabilities: ProviderCapabilities,
|
||||||
|
) {
|
||||||
|
this.id = id;
|
||||||
|
this.family = family;
|
||||||
|
this.capabilities = capabilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract listModels(): Promise<ProviderModel[]>;
|
||||||
|
abstract launchSession(input: StartSessionInput): Promise<ProviderSessionSnapshot>;
|
||||||
|
abstract resumeSession(
|
||||||
|
input: StartSessionInput & { sessionId: string },
|
||||||
|
): Promise<ProviderSessionSnapshot>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns one in-memory session snapshot when present.
|
||||||
|
*/
|
||||||
|
getSession(sessionId: string): ProviderSessionSnapshot | null {
|
||||||
|
const session = this.sessions.get(sessionId);
|
||||||
|
if (!session) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.toSnapshot(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns snapshots of all in-memory sessions.
|
||||||
|
*/
|
||||||
|
listSessions(): ProviderSessionSnapshot[] {
|
||||||
|
return [...this.sessions.values()].map((session) => this.toSnapshot(session));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests a graceful session stop.
|
||||||
|
*/
|
||||||
|
async stopSession(sessionId: string): Promise<boolean> {
|
||||||
|
const session = this.sessions.get(sessionId);
|
||||||
|
if (!session) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const stopped = await session.stop();
|
||||||
|
if (stopped && session.status === 'running') {
|
||||||
|
this.updateSessionStatus(session, 'stopped');
|
||||||
|
this.appendEvent(session, {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel: 'system',
|
||||||
|
message: 'Session stop requested.',
|
||||||
|
data: {
|
||||||
|
sessionId,
|
||||||
|
sessionStatus: 'SESSION_ABORTED',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return stopped;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates mutable internal session state and registers it in memory.
|
||||||
|
*/
|
||||||
|
protected createSessionRecord(
|
||||||
|
sessionId: string,
|
||||||
|
input: {
|
||||||
|
model?: string;
|
||||||
|
thinkingMode?: string;
|
||||||
|
},
|
||||||
|
): MutableProviderSession {
|
||||||
|
const session: MutableProviderSession = {
|
||||||
|
sessionId,
|
||||||
|
provider: this.id,
|
||||||
|
family: this.family,
|
||||||
|
status: 'running',
|
||||||
|
startedAt: new Date().toISOString(),
|
||||||
|
model: input.model,
|
||||||
|
thinkingMode: input.thinkingMode,
|
||||||
|
events: [],
|
||||||
|
completion: Promise.resolve(),
|
||||||
|
stop: async () => false,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.sessions.set(sessionId, session);
|
||||||
|
|
||||||
|
this.appendEvent(session, {
|
||||||
|
timestamp: session.startedAt,
|
||||||
|
channel: 'system',
|
||||||
|
message: 'Session started.',
|
||||||
|
data: {
|
||||||
|
sessionId,
|
||||||
|
sessionStatus: 'STARTED',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends an event while enforcing the configured ring-buffer size.
|
||||||
|
*/
|
||||||
|
protected appendEvent(session: MutableProviderSession, event: ProviderSessionEvent): void {
|
||||||
|
session.events.push(event);
|
||||||
|
|
||||||
|
if (session.events.length > MAX_EVENT_BUFFER_SIZE) {
|
||||||
|
session.events.splice(0, session.events.length - MAX_EVENT_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks the terminal state for a session.
|
||||||
|
*/
|
||||||
|
protected updateSessionStatus(
|
||||||
|
session: MutableProviderSession,
|
||||||
|
status: MutableProviderSession['status'],
|
||||||
|
error?: string,
|
||||||
|
): void {
|
||||||
|
session.status = status;
|
||||||
|
session.endedAt = new Date().toISOString();
|
||||||
|
session.error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts mutable internal session state to an external snapshot.
|
||||||
|
*/
|
||||||
|
protected toSnapshot(session: MutableProviderSession): ProviderSessionSnapshot {
|
||||||
|
return {
|
||||||
|
sessionId: session.sessionId,
|
||||||
|
provider: session.provider,
|
||||||
|
family: session.family,
|
||||||
|
status: session.status,
|
||||||
|
startedAt: session.startedAt,
|
||||||
|
endedAt: session.endedAt,
|
||||||
|
model: session.model,
|
||||||
|
thinkingMode: session.thinkingMode,
|
||||||
|
events: [...session.events],
|
||||||
|
error: session.error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,296 @@
|
|||||||
|
import { randomUUID } from 'node:crypto';
|
||||||
|
import { once } from 'node:events';
|
||||||
|
import type { ChildProcessWithoutNullStreams } from 'node:child_process';
|
||||||
|
|
||||||
|
import spawn from 'cross-spawn';
|
||||||
|
|
||||||
|
import { AbstractProvider } from '@/modules/ai-runtime/providers/base/abstract.provider.js';
|
||||||
|
import type {
|
||||||
|
MutableProviderSession,
|
||||||
|
ProviderCapabilities,
|
||||||
|
ProviderSessionEvent,
|
||||||
|
ProviderSessionSnapshot,
|
||||||
|
StartSessionInput,
|
||||||
|
} from '@/modules/ai-runtime/types/index.js';
|
||||||
|
import { createStreamLineAccumulator } from '@/shared/platform/stream.js';
|
||||||
|
import type { LLMProvider } from '@/shared/types/app.js';
|
||||||
|
|
||||||
|
type CreateCliInvocationInput = StartSessionInput & {
|
||||||
|
sessionId: string;
|
||||||
|
isResume: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
type CliInvocation = {
|
||||||
|
command: string;
|
||||||
|
args: string[];
|
||||||
|
cwd?: string;
|
||||||
|
env?: Record<string, string | undefined>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const PROCESS_SHUTDOWN_GRACE_PERIOD_MS = 2_000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for CLI-driven providers with streamed stdout/stderr parsing.
|
||||||
|
*/
|
||||||
|
export abstract class BaseCliProvider extends AbstractProvider {
|
||||||
|
protected constructor(providerId: LLMProvider, capabilities: ProviderCapabilities) {
|
||||||
|
super(providerId, 'cli', capabilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts a new CLI session and begins process output streaming.
|
||||||
|
*/
|
||||||
|
async launchSession(input: StartSessionInput): Promise<ProviderSessionSnapshot> {
|
||||||
|
return this.startSessionInternal({
|
||||||
|
...input,
|
||||||
|
sessionId: input.sessionId ?? randomUUID(),
|
||||||
|
isResume: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resumes an existing CLI session and begins process output streaming.
|
||||||
|
*/
|
||||||
|
async resumeSession(input: StartSessionInput & { sessionId: string }): Promise<ProviderSessionSnapshot> {
|
||||||
|
return this.startSessionInternal({
|
||||||
|
...input,
|
||||||
|
isResume: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implemented by concrete CLI providers to describe command invocation.
|
||||||
|
*/
|
||||||
|
protected abstract createCliInvocation(input: CreateCliInvocationInput): CliInvocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends uploaded image paths to prompt text for CLI providers that only accept string prompts.
|
||||||
|
*/
|
||||||
|
protected appendImagePathsToPrompt(prompt: string, imagePaths?: string[]): string {
|
||||||
|
if (!imagePaths || imagePaths.length === 0) {
|
||||||
|
return prompt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${prompt}\n\n${JSON.stringify(imagePaths)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps one stdout/stderr line into either JSON or plain-text event shapes.
|
||||||
|
*/
|
||||||
|
protected mapCliOutputLine(line: string, channel: 'stdout' | 'stderr'): ProviderSessionEvent {
|
||||||
|
const parsedJson = this.tryParseJson(line);
|
||||||
|
if (parsedJson !== null) {
|
||||||
|
return {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel: 'json',
|
||||||
|
data: parsedJson,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel,
|
||||||
|
message: line,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a one-off CLI command and returns full stdout text on success.
|
||||||
|
*/
|
||||||
|
protected async runCommandForOutput(command: string, args: string[]): Promise<string> {
|
||||||
|
const child = spawn(command, args, {
|
||||||
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
|
cwd: process.cwd(),
|
||||||
|
env: process.env,
|
||||||
|
});
|
||||||
|
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
|
||||||
|
child.stdout?.on('data', (chunk) => {
|
||||||
|
stdout += chunk.toString();
|
||||||
|
});
|
||||||
|
child.stderr?.on('data', (chunk) => {
|
||||||
|
stderr += chunk.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
const closePromise = once(child, 'close');
|
||||||
|
const errorPromise = once(child, 'error').then(([error]) => {
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.race([closePromise, errorPromise]);
|
||||||
|
|
||||||
|
if ((child.exitCode ?? 1) !== 0) {
|
||||||
|
const message = stderr.trim() || `Command "${command}" failed with code ${child.exitCode}`;
|
||||||
|
throw new Error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boots one CLI child process and wires stream handlers to the session buffer.
|
||||||
|
*/
|
||||||
|
private async startSessionInternal(input: CreateCliInvocationInput): Promise<ProviderSessionSnapshot> {
|
||||||
|
const session = this.createSessionRecord(input.sessionId, {
|
||||||
|
model: input.model,
|
||||||
|
thinkingMode: input.thinkingMode,
|
||||||
|
});
|
||||||
|
|
||||||
|
const invocation = this.createCliInvocation(input);
|
||||||
|
|
||||||
|
const child = spawn(invocation.command, invocation.args, {
|
||||||
|
cwd: invocation.cwd ?? input.workspacePath ?? process.cwd(),
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
...invocation.env,
|
||||||
|
},
|
||||||
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
|
}) as ChildProcessWithoutNullStreams;
|
||||||
|
|
||||||
|
const stop = async (): Promise<boolean> => this.terminateChildProcess(child);
|
||||||
|
session.stop = stop;
|
||||||
|
|
||||||
|
const stdoutAccumulator = createStreamLineAccumulator({ preserveEmptyLines: false });
|
||||||
|
const stderrAccumulator = createStreamLineAccumulator({ preserveEmptyLines: false });
|
||||||
|
|
||||||
|
child.stdout.on('data', (chunk) => {
|
||||||
|
const lines = stdoutAccumulator.push(chunk);
|
||||||
|
for (const line of lines) {
|
||||||
|
const event = this.mapCliOutputLine(line, 'stdout');
|
||||||
|
this.appendEvent(session, event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
child.stderr.on('data', (chunk) => {
|
||||||
|
const lines = stderrAccumulator.push(chunk);
|
||||||
|
for (const line of lines) {
|
||||||
|
const event = this.mapCliOutputLine(line, 'stderr');
|
||||||
|
this.appendEvent(session, event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
session.completion = this.waitForCliProcess(
|
||||||
|
session,
|
||||||
|
child,
|
||||||
|
stdoutAccumulator,
|
||||||
|
stderrAccumulator,
|
||||||
|
);
|
||||||
|
return this.toSnapshot(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits for process completion/error and marks final session status.
|
||||||
|
*/
|
||||||
|
private async waitForCliProcess(
|
||||||
|
session: MutableProviderSession,
|
||||||
|
child: ChildProcessWithoutNullStreams,
|
||||||
|
stdoutAccumulator: { flush: () => string[] },
|
||||||
|
stderrAccumulator: { flush: () => string[] },
|
||||||
|
): Promise<void> {
|
||||||
|
const closePromise = once(child, 'close') as Promise<[number | null, NodeJS.Signals | null]>;
|
||||||
|
const errorPromise = once(child, 'error') as Promise<[Error]>;
|
||||||
|
const raceResult = await Promise.race([
|
||||||
|
closePromise.then((result) => ({ type: 'close' as const, result })),
|
||||||
|
errorPromise.then((result) => ({ type: 'error' as const, result })),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const pendingStdout = stdoutAccumulator.flush();
|
||||||
|
const pendingStderr = stderrAccumulator.flush();
|
||||||
|
|
||||||
|
for (const line of pendingStdout) {
|
||||||
|
this.appendEvent(session, this.mapCliOutputLine(line, 'stdout'));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const line of pendingStderr) {
|
||||||
|
this.appendEvent(session, this.mapCliOutputLine(line, 'stderr'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (raceResult.type === 'error') {
|
||||||
|
const [error] = raceResult.result;
|
||||||
|
const message = error.message || 'CLI process failed before start.';
|
||||||
|
this.updateSessionStatus(session, 'failed', message);
|
||||||
|
this.appendEvent(session, {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel: 'error',
|
||||||
|
message,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [code, signal] = raceResult.result;
|
||||||
|
|
||||||
|
if (session.status === 'stopped') {
|
||||||
|
this.appendEvent(session, {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel: 'system',
|
||||||
|
message: `Session stopped (${signal ?? 'SIGTERM'}).`,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code === 0) {
|
||||||
|
this.updateSessionStatus(session, 'completed');
|
||||||
|
this.appendEvent(session, {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel: 'system',
|
||||||
|
message: 'Session completed.',
|
||||||
|
data: {
|
||||||
|
sessionId: session.sessionId,
|
||||||
|
sessionStatus: 'COMPLETED',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const message = `CLI command exited with code ${code ?? 'null'}${signal ? ` (signal: ${signal})` : ''}`;
|
||||||
|
this.updateSessionStatus(session, 'failed', message);
|
||||||
|
this.appendEvent(session, {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel: 'error',
|
||||||
|
message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts graceful termination first, then force-kills when necessary.
|
||||||
|
*/
|
||||||
|
private async terminateChildProcess(child: ChildProcessWithoutNullStreams): Promise<boolean> {
|
||||||
|
if (child.killed || child.exitCode !== null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
child.kill('SIGTERM');
|
||||||
|
await Promise.race([
|
||||||
|
once(child, 'close'),
|
||||||
|
new Promise((resolve) => setTimeout(resolve, PROCESS_SHUTDOWN_GRACE_PERIOD_MS)),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (child.exitCode === null) {
|
||||||
|
child.kill('SIGKILL');
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Best-effort JSON parser for stream-json providers.
|
||||||
|
*/
|
||||||
|
private tryParseJson(line: string): unknown | null {
|
||||||
|
const trimmed = line.trim();
|
||||||
|
if (!trimmed || (!trimmed.startsWith('{') && !trimmed.startsWith('['))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(trimmed);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
import { randomUUID } from 'node:crypto';
|
||||||
|
|
||||||
|
import { AbstractProvider } from '@/modules/ai-runtime/providers/base/abstract.provider.js';
|
||||||
|
import type {
|
||||||
|
MutableProviderSession,
|
||||||
|
ProviderCapabilities,
|
||||||
|
ProviderSessionEvent,
|
||||||
|
ProviderSessionSnapshot,
|
||||||
|
StartSessionInput,
|
||||||
|
} from '@/modules/ai-runtime/types/index.js';
|
||||||
|
import type { LLMProvider } from '@/shared/types/app.js';
|
||||||
|
|
||||||
|
type CreateSdkExecutionInput = StartSessionInput & {
|
||||||
|
sessionId: string;
|
||||||
|
isResume: boolean;
|
||||||
|
emitEvent?: (event: ProviderSessionEvent) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
type SdkExecution = {
|
||||||
|
stream: AsyncIterable<unknown>;
|
||||||
|
stop: () => Promise<boolean>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for SDK-driven providers with async stream consumption.
|
||||||
|
*/
|
||||||
|
export abstract class BaseSdkProvider extends AbstractProvider {
|
||||||
|
protected constructor(providerId: LLMProvider, capabilities: ProviderCapabilities) {
|
||||||
|
super(providerId, 'sdk', capabilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts a new SDK session and begins event streaming.
|
||||||
|
*/
|
||||||
|
async launchSession(input: StartSessionInput): Promise<ProviderSessionSnapshot> {
|
||||||
|
return this.startSessionInternal({
|
||||||
|
...input,
|
||||||
|
sessionId: input.sessionId ?? randomUUID(),
|
||||||
|
isResume: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resumes an existing SDK session and begins event streaming.
|
||||||
|
*/
|
||||||
|
async resumeSession(input: StartSessionInput & { sessionId: string }): Promise<ProviderSessionSnapshot> {
|
||||||
|
return this.startSessionInternal({
|
||||||
|
...input,
|
||||||
|
isResume: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implemented by concrete SDK providers to create a running execution.
|
||||||
|
*/
|
||||||
|
protected abstract createSdkExecution(input: CreateSdkExecutionInput): Promise<SdkExecution>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizes raw SDK events to the shared event shape.
|
||||||
|
*/
|
||||||
|
protected mapSdkEvent(rawEvent: unknown): ProviderSessionEvent | null {
|
||||||
|
return {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel: 'sdk',
|
||||||
|
data: rawEvent,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes one SDK execution and wires it to the internal session record.
|
||||||
|
*/
|
||||||
|
private async startSessionInternal(input: CreateSdkExecutionInput): Promise<ProviderSessionSnapshot> {
|
||||||
|
const session = this.createSessionRecord(input.sessionId, {
|
||||||
|
model: input.model,
|
||||||
|
thinkingMode: input.thinkingMode,
|
||||||
|
});
|
||||||
|
|
||||||
|
let execution: SdkExecution;
|
||||||
|
try {
|
||||||
|
execution = await this.createSdkExecution({
|
||||||
|
...input,
|
||||||
|
emitEvent: (event) => {
|
||||||
|
this.appendEvent(session, event);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : 'Failed to start SDK session';
|
||||||
|
this.updateSessionStatus(session, 'failed', message);
|
||||||
|
this.appendEvent(session, {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel: 'error',
|
||||||
|
message,
|
||||||
|
});
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
session.stop = execution.stop;
|
||||||
|
|
||||||
|
session.completion = this.consumeStream(session, execution.stream);
|
||||||
|
return this.toSnapshot(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drains SDK events until completion/error and updates final status.
|
||||||
|
*/
|
||||||
|
private async consumeStream(
|
||||||
|
session: MutableProviderSession,
|
||||||
|
stream: AsyncIterable<unknown>,
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
for await (const sdkEvent of stream) {
|
||||||
|
const normalized = this.mapSdkEvent(sdkEvent);
|
||||||
|
if (normalized) {
|
||||||
|
this.appendEvent(session, normalized);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// after stream completion, only update status if not already stopped by user
|
||||||
|
if (session.status === 'running') {
|
||||||
|
this.updateSessionStatus(session, 'completed');
|
||||||
|
this.appendEvent(session, {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel: 'system',
|
||||||
|
message: 'Session completed.',
|
||||||
|
data: {
|
||||||
|
sessionId: session.sessionId,
|
||||||
|
sessionStatus: 'COMPLETED',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : 'Unknown SDK execution failure';
|
||||||
|
|
||||||
|
if (session.status === 'stopped') {
|
||||||
|
this.appendEvent(session, {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel: 'system',
|
||||||
|
message: 'Session stopped.',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateSessionStatus(session, 'failed', message);
|
||||||
|
this.appendEvent(session, {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
channel: 'error',
|
||||||
|
message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import { readFile } from 'node:fs/promises';
|
||||||
|
|
||||||
|
import type { IProviderAuthRuntime, ProviderAuthStatus } from '@/modules/ai-runtime/types/index.js';
|
||||||
|
|
||||||
|
type ClaudeCredentialsFile = {
|
||||||
|
email?: string;
|
||||||
|
user?: string;
|
||||||
|
claudeAiOauth?: {
|
||||||
|
accessToken?: string;
|
||||||
|
expiresAt?: number | string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads auth status for Claude from env/settings and OAuth credentials.
|
||||||
|
*/
|
||||||
|
export class ClaudeAuthRuntime implements IProviderAuthRuntime {
|
||||||
|
async getStatus(): Promise<ProviderAuthStatus> {
|
||||||
|
try {
|
||||||
|
if (process.env.ANTHROPIC_API_KEY?.trim()) {
|
||||||
|
return {
|
||||||
|
provider: 'claude',
|
||||||
|
authenticated: true,
|
||||||
|
email: 'API Key Auth',
|
||||||
|
method: 'api_key',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const settingsEnv = await this.loadClaudeSettingsEnv();
|
||||||
|
if (settingsEnv.ANTHROPIC_API_KEY?.trim()) {
|
||||||
|
return {
|
||||||
|
provider: 'claude',
|
||||||
|
authenticated: true,
|
||||||
|
email: 'API Key Auth',
|
||||||
|
method: 'api_key',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settingsEnv.ANTHROPIC_AUTH_TOKEN?.trim()) {
|
||||||
|
return {
|
||||||
|
provider: 'claude',
|
||||||
|
authenticated: true,
|
||||||
|
email: 'Configured via settings.json',
|
||||||
|
method: 'api_key',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const credentialsPath = path.join(os.homedir(), '.claude', '.credentials.json');
|
||||||
|
const content = await readFile(credentialsPath, 'utf8');
|
||||||
|
const credentials = JSON.parse(content) as ClaudeCredentialsFile;
|
||||||
|
const oauth = credentials.claudeAiOauth;
|
||||||
|
const accessToken = oauth?.accessToken;
|
||||||
|
|
||||||
|
if (accessToken && !this.isExpired(oauth?.expiresAt)) {
|
||||||
|
return {
|
||||||
|
provider: 'claude',
|
||||||
|
authenticated: true,
|
||||||
|
email: credentials.email ?? credentials.user ?? null,
|
||||||
|
method: 'credentials_file',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
provider: 'claude',
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
method: null,
|
||||||
|
error: 'Not authenticated',
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
return {
|
||||||
|
provider: 'claude',
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
method: null,
|
||||||
|
error: 'Not authenticated',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads optional env values from ~/.claude/settings.json.
|
||||||
|
*/
|
||||||
|
private async loadClaudeSettingsEnv(): Promise<Record<string, string>> {
|
||||||
|
try {
|
||||||
|
const settingsPath = path.join(os.homedir(), '.claude', 'settings.json');
|
||||||
|
const content = await readFile(settingsPath, 'utf8');
|
||||||
|
const settings = JSON.parse(content) as { env?: unknown };
|
||||||
|
if (!settings.env || typeof settings.env !== 'object') {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.fromEntries(
|
||||||
|
Object.entries(settings.env as Record<string, unknown>).filter(
|
||||||
|
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true when an OAuth expiration timestamp is in the past.
|
||||||
|
*/
|
||||||
|
private isExpired(expiresAt: number | string | undefined): boolean {
|
||||||
|
if (expiresAt === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof expiresAt === 'number') {
|
||||||
|
return Date.now() >= expiresAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const numeric = Number.parseInt(expiresAt, 10);
|
||||||
|
return Number.isFinite(numeric) ? Date.now() >= numeric : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +1,33 @@
|
|||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
import { McpProvider } from '@/modules/providers/shared/mcp/mcp.provider.js';
|
import { AppError } from '@/shared/utils/app-error.js';
|
||||||
import type { McpScope, ProviderMcpServer, UpsertProviderMcpServerInput } from '@/shared/types.js';
|
import type {
|
||||||
|
McpScope,
|
||||||
|
ProviderMcpServer,
|
||||||
|
UpsertProviderMcpServerInput,
|
||||||
|
} from '@/modules/ai-runtime/types/index.js';
|
||||||
|
import { BaseProviderMcpRuntime } from '@/modules/ai-runtime/providers/shared/mcp/base-provider-mcp.runtime.js';
|
||||||
import {
|
import {
|
||||||
AppError,
|
|
||||||
readJsonConfig,
|
readJsonConfig,
|
||||||
readObjectRecord,
|
readObjectRecord,
|
||||||
readOptionalString,
|
readOptionalString,
|
||||||
readStringArray,
|
readStringArray,
|
||||||
readStringRecord,
|
readStringRecord,
|
||||||
writeJsonConfig,
|
writeJsonConfig,
|
||||||
} from '@/shared/utils.js';
|
} from '@/modules/ai-runtime/providers/shared/mcp/mcp-runtime.utils.js';
|
||||||
|
|
||||||
export class ClaudeMcpProvider extends McpProvider {
|
/**
|
||||||
|
* Claude MCP runtime backed by `~/.claude.json` and project `.mcp.json`.
|
||||||
|
*/
|
||||||
|
export class ClaudeMcpRuntime extends BaseProviderMcpRuntime {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('claude', ['user', 'local', 'project'], ['stdio', 'http', 'sse']);
|
super('claude', ['user', 'local', 'project'], ['stdio', 'http', 'sse']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads Claude MCP servers from user/local/project config locations.
|
||||||
|
*/
|
||||||
protected async readScopedServers(scope: McpScope, workspacePath: string): Promise<Record<string, unknown>> {
|
protected async readScopedServers(scope: McpScope, workspacePath: string): Promise<Record<string, unknown>> {
|
||||||
if (scope === 'project') {
|
if (scope === 'project') {
|
||||||
const filePath = path.join(workspacePath, '.mcp.json');
|
const filePath = path.join(workspacePath, '.mcp.json');
|
||||||
@@ -36,6 +46,9 @@ export class ClaudeMcpProvider extends McpProvider {
|
|||||||
return readObjectRecord(projectConfig.mcpServers) ?? {};
|
return readObjectRecord(projectConfig.mcpServers) ?? {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes Claude MCP servers to user/local/project config locations.
|
||||||
|
*/
|
||||||
protected async writeScopedServers(
|
protected async writeScopedServers(
|
||||||
scope: McpScope,
|
scope: McpScope,
|
||||||
workspacePath: string,
|
workspacePath: string,
|
||||||
@@ -65,6 +78,9 @@ export class ClaudeMcpProvider extends McpProvider {
|
|||||||
await writeJsonConfig(filePath, config);
|
await writeJsonConfig(filePath, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds one Claude-native server object from the unified input payload.
|
||||||
|
*/
|
||||||
protected buildServerConfig(input: UpsertProviderMcpServerInput): Record<string, unknown> {
|
protected buildServerConfig(input: UpsertProviderMcpServerInput): Record<string, unknown> {
|
||||||
if (input.transport === 'stdio') {
|
if (input.transport === 'stdio') {
|
||||||
if (!input.command?.trim()) {
|
if (!input.command?.trim()) {
|
||||||
@@ -96,6 +112,9 @@ export class ClaudeMcpProvider extends McpProvider {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizes one Claude server object.
|
||||||
|
*/
|
||||||
protected normalizeServerConfig(
|
protected normalizeServerConfig(
|
||||||
scope: McpScope,
|
scope: McpScope,
|
||||||
name: string,
|
name: string,
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
|
import { sessionsDb } from '@/shared/database/repositories/sessions.db.js';
|
||||||
|
import {
|
||||||
|
buildLookupMap,
|
||||||
|
extractFirstValidJsonlData,
|
||||||
|
findFilesRecursivelyCreatedAfter,
|
||||||
|
normalizeSessionName,
|
||||||
|
readFileTimestamps,
|
||||||
|
} from '@/modules/ai-runtime/providers/shared/session-synchronizer/session-synchronizer.utils.js';
|
||||||
|
import type { IProviderSessionSynchronizerRuntime } from '@/modules/ai-runtime/types/index.js';
|
||||||
|
|
||||||
|
type ParsedSession = {
|
||||||
|
sessionId: string;
|
||||||
|
workspacePath: string;
|
||||||
|
sessionName?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Session indexer for Claude transcript artifacts.
|
||||||
|
*/
|
||||||
|
export class ClaudeSessionSynchronizerRuntime implements IProviderSessionSynchronizerRuntime {
|
||||||
|
private readonly provider = 'claude' as const;
|
||||||
|
private readonly claudeHome = path.join(os.homedir(), '.claude');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scans ~/.claude projects and upserts discovered sessions into DB.
|
||||||
|
*/
|
||||||
|
async synchronize(since?: Date): Promise<number> {
|
||||||
|
const nameMap = await buildLookupMap(path.join(this.claudeHome, 'history.jsonl'), 'sessionId', 'display');
|
||||||
|
const files = await findFilesRecursivelyCreatedAfter(
|
||||||
|
path.join(this.claudeHome, 'projects'),
|
||||||
|
'.jsonl',
|
||||||
|
since ?? null,
|
||||||
|
);
|
||||||
|
|
||||||
|
let processed = 0;
|
||||||
|
for (const filePath of files) {
|
||||||
|
const parsed = await this.processSessionFile(filePath, nameMap);
|
||||||
|
if (!parsed) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const timestamps = await readFileTimestamps(filePath);
|
||||||
|
sessionsDb.createSession(
|
||||||
|
parsed.sessionId,
|
||||||
|
this.provider,
|
||||||
|
parsed.workspacePath,
|
||||||
|
parsed.sessionName,
|
||||||
|
timestamps.createdAt,
|
||||||
|
timestamps.updatedAt,
|
||||||
|
filePath,
|
||||||
|
);
|
||||||
|
processed += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses and upserts one Claude session JSONL file.
|
||||||
|
*/
|
||||||
|
async synchronizeFile(filePath: string): Promise<boolean> {
|
||||||
|
if (!filePath.endsWith('.jsonl')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nameMap = await buildLookupMap(path.join(this.claudeHome, 'history.jsonl'), 'sessionId', 'display');
|
||||||
|
const parsed = await this.processSessionFile(filePath, nameMap);
|
||||||
|
if (!parsed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const timestamps = await readFileTimestamps(filePath);
|
||||||
|
sessionsDb.createSession(
|
||||||
|
parsed.sessionId,
|
||||||
|
this.provider,
|
||||||
|
parsed.workspacePath,
|
||||||
|
parsed.sessionName,
|
||||||
|
timestamps.createdAt,
|
||||||
|
timestamps.updatedAt,
|
||||||
|
filePath,
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts session metadata from one Claude JSONL session file.
|
||||||
|
*/
|
||||||
|
private async processSessionFile(
|
||||||
|
filePath: string,
|
||||||
|
nameMap: Map<string, string>,
|
||||||
|
): Promise<ParsedSession | null> {
|
||||||
|
return extractFirstValidJsonlData(filePath, (rawData) => {
|
||||||
|
const data = rawData as Record<string, unknown>;
|
||||||
|
const sessionId = typeof data.sessionId === 'string' ? data.sessionId : undefined;
|
||||||
|
const workspacePath = typeof data.cwd === 'string' ? data.cwd : undefined;
|
||||||
|
|
||||||
|
if (!sessionId || !workspacePath) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
sessionId,
|
||||||
|
workspacePath,
|
||||||
|
sessionName: normalizeSessionName(nameMap.get(sessionId), 'Untitled Claude Session'),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user