mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-18 06:12:08 +08:00
Compare commits
45 Commits
v1.26.2
...
refactor/p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
863a98d583 | ||
|
|
acfa7cfffb | ||
|
|
3e99187a01 | ||
|
|
25b00b58de | ||
|
|
6a13e1773b | ||
|
|
6102b74455 | ||
|
|
9ef1ab533d | ||
|
|
e9c7a5041c | ||
|
|
289520814c | ||
|
|
09486016e6 | ||
|
|
4c106a5083 | ||
|
|
ef916615f8 | ||
|
|
63e996bb77 | ||
|
|
9ddda5ba5e | ||
|
|
fbad3a90f8 | ||
|
|
96463df8da | ||
|
|
9f99f6ab53 | ||
|
|
31f28a2c18 | ||
|
|
8ff5f35c05 | ||
|
|
641304242d | ||
|
|
c3599cd2c4 | ||
|
|
9b11c034d9 | ||
|
|
b6d19201b6 | ||
|
|
4a569725da | ||
|
|
6ce3306947 | ||
|
|
d0dd007d0f | ||
|
|
13e97e2c71 | ||
|
|
c7a5baf147 | ||
|
|
e2459cb0f8 | ||
|
|
9552577e94 | ||
|
|
590dd42649 | ||
|
|
2207d05c1c | ||
|
|
a8dab0edcf | ||
|
|
e61f8a543d | ||
|
|
388134c7a5 | ||
|
|
ef51de259e | ||
|
|
1628868470 | ||
|
|
8f1042cf25 | ||
|
|
051a6b1e74 | ||
|
|
f1063fd339 | ||
|
|
27cd12432b | ||
|
|
004135ef01 | ||
|
|
b54cdf8168 | ||
|
|
42a131389a | ||
|
|
ebd1c0db92 |
50
.github/workflows/release.yml
vendored
Normal file
50
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
increment:
|
||||||
|
description: 'Version bump: patch, minor, major, or explicit (e.g. 1.27.0)'
|
||||||
|
required: true
|
||||||
|
default: 'patch'
|
||||||
|
type: string
|
||||||
|
release_name:
|
||||||
|
description: 'Custom release name (optional, defaults to "CloudCLI UI vX.Y.Z")'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.RELEASE_PAT }}
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
registry-url: https://registry.npmjs.org
|
||||||
|
|
||||||
|
- name: git config
|
||||||
|
run: |
|
||||||
|
git config user.name "${GITHUB_ACTOR}"
|
||||||
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||||
|
|
||||||
|
- run: npm ci
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
ARGS="--ci --increment=${{ inputs.increment }}"
|
||||||
|
if [ -n "${{ inputs.release_name }}" ]; then
|
||||||
|
ARGS="$ARGS --github.releaseName=\"${{ inputs.release_name }}\""
|
||||||
|
fi
|
||||||
|
npx release-it $ARGS
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }}
|
||||||
|
NPM_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-ssr/
|
dist-server/
|
||||||
build/
|
build/
|
||||||
out/
|
out/
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
"requireCleanWorkingDir": true
|
"requireCleanWorkingDir": true
|
||||||
},
|
},
|
||||||
"npm": {
|
"npm": {
|
||||||
"publish": true
|
"publish": true,
|
||||||
|
"publishArgs": ["--access public"]
|
||||||
},
|
},
|
||||||
"github": {
|
"github": {
|
||||||
"release": true,
|
"release": true,
|
||||||
|
|||||||
102
CHANGELOG.md
102
CHANGELOG.md
@@ -3,6 +3,108 @@
|
|||||||
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.5](https://github.com/siteboon/claudecodeui/compare/v1.29.4...v1.29.5) (2026-04-16)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* update node-pty to latest version ([6a13e17](https://github.com/siteboon/claudecodeui/commit/6a13e1773b145049ade512aa6e5cac21c2e5c4de))
|
||||||
|
|
||||||
|
## [1.29.4](https://github.com/siteboon/claudecodeui/compare/v1.29.3...v1.29.4) (2026-04-16)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* deleting from sidebar will now ask whether to remove all data as well ([e9c7a50](https://github.com/siteboon/claudecodeui/commit/e9c7a5041c31a6f7b2032f06abe19c52d3d4cd8c))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* pass pathToClaudeCodeExecutable to SDK when CLAUDE_CLI_PATH is set ([4c106a5](https://github.com/siteboon/claudecodeui/commit/4c106a5083d90989bbeedaefdbb68f5b3fa6fd58)), closes [#468](https://github.com/siteboon/claudecodeui/issues/468)
|
||||||
|
|
||||||
|
### Refactoring
|
||||||
|
|
||||||
|
* remove the sqlite3 dependency ([2895208](https://github.com/siteboon/claudecodeui/commit/289520814cf3ca36403056739ef22021f78c6033))
|
||||||
|
* **server:** extract URL detection and color utils from index.js ([#657](https://github.com/siteboon/claudecodeui/issues/657)) ([63e996b](https://github.com/siteboon/claudecodeui/commit/63e996bb77cfa97b1f55f6bdccc50161a75a3eee))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* upgrade commit lint to 20.5.0 ([0948601](https://github.com/siteboon/claudecodeui/commit/09486016e67d97358c228ebc6eb4502ccb0012e4))
|
||||||
|
|
||||||
|
## [1.29.3](https://github.com/siteboon/claudecodeui/compare/v1.29.2...v1.29.3) (2026-04-15)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **version-upgrade-modal:** implement reload countdown and update UI messages ([#655](https://github.com/siteboon/claudecodeui/issues/655)) ([6413042](https://github.com/siteboon/claudecodeui/commit/641304242d7705b54aab65faa4a7673438c92c60))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* remove unused route (migrated to providers already) ([31f28a2](https://github.com/siteboon/claudecodeui/commit/31f28a2c183f6ead50941027632d7ab64b7bb2d4))
|
||||||
|
|
||||||
|
## [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.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)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|||||||
@@ -153,4 +153,4 @@ This automatically:
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
By contributing, you agree that your contributions will be licensed under the [GPL-3.0 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.
|
||||||
691
LICENSE
691
LICENSE
@@ -1,113 +1,95 @@
|
|||||||
# GNU GENERAL PUBLIC LICENSE
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
Version 3, 29 June 2007
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
Preamble
|
||||||
<https://fsf.org/>
|
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
license document, but changing it is not allowed.
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
## Preamble
|
The licenses for most software and other practical works are designed
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
the GNU General Public License is intended to guarantee your freedom
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
to share and change all versions of a program--to make sure it remains
|
share and change all versions of a program--to make sure it remains free
|
||||||
free software for all its users. We, the Free Software Foundation, use
|
software for all its users.
|
||||||
the GNU General Public License for most of our software; it applies
|
|
||||||
also to any other work released this way by its authors. You can apply
|
|
||||||
it to your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
When we speak of free software, we are referring to freedom, not
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
have the freedom to distribute copies of free software (and charge for
|
have the freedom to distribute copies of free software (and charge for
|
||||||
them if you wish), that you receive source code or can get it if you
|
them if you wish), that you receive source code or can get it if you
|
||||||
want it, that you can change the software or use pieces of it in new
|
want it, that you can change the software or use pieces of it in new
|
||||||
free programs, and that you know you can do these things.
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
Developers that use our General Public Licenses protect your rights
|
||||||
these rights or asking you to surrender the rights. Therefore, you
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
have certain responsibilities if you distribute copies of the
|
you this License which gives you legal permission to copy, distribute
|
||||||
software, or if you modify it: responsibilities to respect the freedom
|
and/or modify the software.
|
||||||
of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
A secondary benefit of defending all users' freedom is that
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
improvements made in alternate versions of the program, if they
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
receive widespread use, become available for other developers to
|
||||||
or can get the source code. And you must show them these terms so they
|
incorporate. Many developers of free software are heartened and
|
||||||
know their rights.
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
The GNU Affero General Public License is designed specifically to
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
ensure that, in such cases, the modified source code becomes available
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
An older license, called the Affero General Public License and
|
||||||
that there is no warranty for this free software. For both users' and
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
changed, so that their problems will not be attributed erroneously to
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
authors of previous versions.
|
this license.
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
The precise terms and conditions for copying, distribution and
|
||||||
modified versions of the software inside them, although the
|
|
||||||
manufacturer can do so. This is fundamentally incompatible with the
|
|
||||||
aim of protecting users' freedom to change the software. The
|
|
||||||
systematic pattern of such abuse occurs in the area of products for
|
|
||||||
individuals to use, which is precisely where it is most unacceptable.
|
|
||||||
Therefore, we have designed this version of the GPL to prohibit the
|
|
||||||
practice for those products. If such problems arise substantially in
|
|
||||||
other domains, we stand ready to extend this provision to those
|
|
||||||
domains in future versions of the GPL, as needed to protect the
|
|
||||||
freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish
|
|
||||||
to avoid the special danger that patents applied to a free program
|
|
||||||
could make it effectively proprietary. To prevent this, the GPL
|
|
||||||
assures that patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
modification follow.
|
||||||
|
|
||||||
## TERMS AND CONDITIONS
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
### 0. Definitions.
|
0. Definitions.
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
of works, such as semiconductor masks.
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
"recipients" may be individuals or organizations.
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
in a fashion requiring copyright permission, other than the making of
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
an exact copy. The resulting work is called a "modified version" of
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
the earlier work or a work "based on" the earlier work.
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
A "covered work" means either the unmodified Program or a work based
|
||||||
on the Program.
|
on the Program.
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
To "propagate" a work means to do anything with it that, without
|
||||||
permission, would make you directly or secondarily liable for
|
permission, would make you directly or secondarily liable for
|
||||||
infringement under applicable copyright law, except executing it on a
|
infringement under applicable copyright law, except executing it on a
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
distribution (with or without modification), making available to the
|
distribution (with or without modification), making available to the
|
||||||
public, and in some countries other activities as well.
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
To "convey" a work means any kind of propagation that enables other
|
||||||
parties to make or receive copies. Mere interaction with a user
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
through a computer network, with no transfer of a copy, is not
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices" to
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
the extent that it includes a convenient and prominently visible
|
to the extent that it includes a convenient and prominently visible
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
tells the user that there is no warranty for the work (except to the
|
tells the user that there is no warranty for the work (except to the
|
||||||
extent that warranties are provided), that licensees may convey the
|
extent that warranties are provided), that licensees may convey the
|
||||||
@@ -115,18 +97,18 @@ work under this License, and how to view a copy of this License. If
|
|||||||
the interface presents a list of user commands or options, such as a
|
the interface presents a list of user commands or options, such as a
|
||||||
menu, a prominent item in the list meets this criterion.
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
### 1. Source Code.
|
1. Source Code.
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work for
|
The "source code" for a work means the preferred form of the work
|
||||||
making modifications to it. "Object code" means any non-source form of
|
for making modifications to it. "Object code" means any non-source
|
||||||
a work.
|
form of a work.
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
A "Standard Interface" means an interface that either is an official
|
||||||
standard defined by a recognized standards body, or, in the case of
|
standard defined by a recognized standards body, or, in the case of
|
||||||
interfaces specified for a particular programming language, one that
|
interfaces specified for a particular programming language, one that
|
||||||
is widely used among developers working in that language.
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
The "System Libraries" of an executable work include anything, other
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
packaging a Major Component, but which is not part of that Major
|
packaging a Major Component, but which is not part of that Major
|
||||||
Component, and (b) serves only to enable use of the work with that
|
Component, and (b) serves only to enable use of the work with that
|
||||||
@@ -137,7 +119,7 @@ implementation is available to the public in source code form. A
|
|||||||
(if any) on which the executable work runs, or a compiler used to
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
produce the work, or an object code interpreter used to run it.
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
The "Corresponding Source" for a work in object code form means all
|
||||||
the source code needed to generate, install, and (for an executable
|
the source code needed to generate, install, and (for an executable
|
||||||
work) run the object code and to modify the work, including scripts to
|
work) run the object code and to modify the work, including scripts to
|
||||||
control those activities. However, it does not include the work's
|
control those activities. However, it does not include the work's
|
||||||
@@ -150,15 +132,16 @@ linked subprograms that the work is specifically designed to require,
|
|||||||
such as by intimate data communication or control flow between those
|
such as by intimate data communication or control flow between those
|
||||||
subprograms and other parts of the work.
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users can
|
The Corresponding Source need not include anything that users
|
||||||
regenerate automatically from other parts of the Corresponding Source.
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that same
|
The Corresponding Source for a work in source code form is that
|
||||||
work.
|
same work.
|
||||||
|
|
||||||
### 2. Basic Permissions.
|
2. Basic Permissions.
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
All rights granted under this License are granted for the term of
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
permission to run the unmodified Program. The output from running a
|
permission to run the unmodified Program. The output from running a
|
||||||
@@ -166,40 +149,40 @@ covered work is covered by this License only if the output, given its
|
|||||||
content, constitutes a covered work. This License acknowledges your
|
content, constitutes a covered work. This License acknowledges your
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not convey,
|
You may make, run and propagate covered works that you do not
|
||||||
without conditions so long as your license otherwise remains in force.
|
convey, without conditions so long as your license otherwise remains
|
||||||
You may convey covered works to others for the sole purpose of having
|
in force. You may convey covered works to others for the sole purpose
|
||||||
them make modifications exclusively for you, or provide you with
|
of having them make modifications exclusively for you, or provide you
|
||||||
facilities for running those works, provided that you comply with the
|
with facilities for running those works, provided that you comply with
|
||||||
terms of this License in conveying all material for which you do not
|
the terms of this License in conveying all material for which you do
|
||||||
control copyright. Those thus making or running the covered works for
|
not control copyright. Those thus making or running the covered works
|
||||||
you must do so exclusively on your behalf, under your direction and
|
for you must do so exclusively on your behalf, under your direction
|
||||||
control, on terms that prohibit them from making any copies of your
|
and control, on terms that prohibit them from making any copies of
|
||||||
copyrighted material outside their relationship with you.
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under the
|
Conveying under any other circumstances is permitted solely under
|
||||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
it unnecessary.
|
makes it unnecessary.
|
||||||
|
|
||||||
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
No covered work shall be deemed part of an effective technological
|
||||||
measure under any applicable law fulfilling obligations under article
|
measure under any applicable law fulfilling obligations under article
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
similar laws prohibiting or restricting circumvention of such
|
similar laws prohibiting or restricting circumvention of such
|
||||||
measures.
|
measures.
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
circumvention of technological measures to the extent such
|
circumvention of technological measures to the extent such circumvention
|
||||||
circumvention is effected by exercising rights under this License with
|
is effected by exercising rights under this License with respect to
|
||||||
respect to the covered work, and you disclaim any intention to limit
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
operation or modification of the work as a means of enforcing, against
|
modification of the work as a means of enforcing, against the work's
|
||||||
the work's users, your or third parties' legal rights to forbid
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
circumvention of technological measures.
|
technological measures.
|
||||||
|
|
||||||
### 4. Conveying Verbatim Copies.
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
You may convey verbatim copies of the Program's source code as you
|
||||||
receive it, in any medium, provided that you conspicuously and
|
receive it, in any medium, provided that you conspicuously and
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
keep intact all notices stating that this License and any
|
keep intact all notices stating that this License and any
|
||||||
@@ -207,35 +190,37 @@ non-permissive terms added in accord with section 7 apply to the code;
|
|||||||
keep intact all notices of the absence of any warranty; and give all
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
recipients a copy of this License along with the Program.
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
You may charge any price or no price for each copy that you convey,
|
||||||
and you may offer support or warranty protection for a fee.
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
### 5. Conveying Modified Source Versions.
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
You may convey a work based on the Program, or the modifications to
|
||||||
produce it from the Program, in the form of source code under the
|
produce it from the Program, in the form of source code under the
|
||||||
terms of section 4, provided that you also meet all of these
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
conditions:
|
|
||||||
|
|
||||||
- a) The work must carry prominent notices stating that you modified
|
a) The work must carry prominent notices stating that you modified
|
||||||
it, and giving a relevant date.
|
it, and giving a relevant date.
|
||||||
- b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under
|
b) The work must carry prominent notices stating that it is
|
||||||
section 7. This requirement modifies the requirement in section 4
|
released under this License and any conditions added under section
|
||||||
to "keep intact all notices".
|
7. This requirement modifies the requirement in section 4 to
|
||||||
- c) You must license the entire work, as a whole, under this
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
License to anyone who comes into possession of a copy. This
|
License to anyone who comes into possession of a copy. This
|
||||||
License will therefore apply, along with any applicable section 7
|
License will therefore apply, along with any applicable section 7
|
||||||
additional terms, to the whole of the work, and all its parts,
|
additional terms, to the whole of the work, and all its parts,
|
||||||
regardless of how they are packaged. This License gives no
|
regardless of how they are packaged. This License gives no
|
||||||
permission to license the work in any other way, but it does not
|
permission to license the work in any other way, but it does not
|
||||||
invalidate such permission if you have separately received it.
|
invalidate such permission if you have separately received it.
|
||||||
- d) If the work has interactive user interfaces, each must display
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
work need not make them do so.
|
work need not make them do so.
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
A compilation of a covered work with other separate and independent
|
||||||
works, which are not by their nature extensions of the covered work,
|
works, which are not by their nature extensions of the covered work,
|
||||||
and which are not combined with it such as to form a larger program,
|
and which are not combined with it such as to form a larger program,
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
@@ -245,18 +230,19 @@ beyond what the individual works permit. Inclusion of a covered work
|
|||||||
in an aggregate does not cause this License to apply to the other
|
in an aggregate does not cause this License to apply to the other
|
||||||
parts of the aggregate.
|
parts of the aggregate.
|
||||||
|
|
||||||
### 6. Conveying Non-Source Forms.
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms of
|
You may convey a covered work in object code form under the terms
|
||||||
sections 4 and 5, provided that you also convey the machine-readable
|
of sections 4 and 5, provided that you also convey the
|
||||||
Corresponding Source under the terms of this License, in one of these
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
ways:
|
in one of these ways:
|
||||||
|
|
||||||
- a) Convey the object code in, or embodied in, a physical product
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
(including a physical distribution medium), accompanied by the
|
(including a physical distribution medium), accompanied by the
|
||||||
Corresponding Source fixed on a durable physical medium
|
Corresponding Source fixed on a durable physical medium
|
||||||
customarily used for software interchange.
|
customarily used for software interchange.
|
||||||
- b) Convey the object code in, or embodied in, a physical product
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
(including a physical distribution medium), accompanied by a
|
(including a physical distribution medium), accompanied by a
|
||||||
written offer, valid for at least three years and valid for as
|
written offer, valid for at least three years and valid for as
|
||||||
long as you offer spare parts or customer support for that product
|
long as you offer spare parts or customer support for that product
|
||||||
@@ -265,14 +251,16 @@ ways:
|
|||||||
product that is covered by this License, on a durable physical
|
product that is covered by this License, on a durable physical
|
||||||
medium customarily used for software interchange, for a price no
|
medium customarily used for software interchange, for a price no
|
||||||
more than your reasonable cost of physically performing this
|
more than your reasonable cost of physically performing this
|
||||||
conveying of source, or (2) access to copy the Corresponding
|
conveying of source, or (2) access to copy the
|
||||||
Source from a network server at no charge.
|
Corresponding Source from a network server at no charge.
|
||||||
- c) Convey individual copies of the object code with a copy of the
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
written offer to provide the Corresponding Source. This
|
written offer to provide the Corresponding Source. This
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
only if you received the object code with such an offer, in accord
|
only if you received the object code with such an offer, in accord
|
||||||
with subsection 6b.
|
with subsection 6b.
|
||||||
- d) Convey the object code by offering access from a designated
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
Corresponding Source in the same way through the same place at no
|
Corresponding Source in the same way through the same place at no
|
||||||
further charge. You need not require recipients to copy the
|
further charge. You need not require recipients to copy the
|
||||||
@@ -284,38 +272,38 @@ ways:
|
|||||||
Corresponding Source. Regardless of what server hosts the
|
Corresponding Source. Regardless of what server hosts the
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
available for as long as needed to satisfy these requirements.
|
available for as long as needed to satisfy these requirements.
|
||||||
- e) Convey the object code using peer-to-peer transmission,
|
|
||||||
provided you inform other peers where the object code and
|
|
||||||
Corresponding Source of the work are being offered to the general
|
|
||||||
public at no charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
from the Corresponding Source as a System Library, need not be
|
from the Corresponding Source as a System Library, need not be
|
||||||
included in conveying the object code work.
|
included in conveying the object code work.
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
tangible personal property which is normally used for personal,
|
tangible personal property which is normally used for personal, family,
|
||||||
family, or household purposes, or (2) anything designed or sold for
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
incorporation into a dwelling. In determining whether a product is a
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
consumer product, doubtful cases shall be resolved in favor of
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
coverage. For a particular product received by a particular user,
|
product received by a particular user, "normally used" refers to a
|
||||||
"normally used" refers to a typical or common use of that class of
|
typical or common use of that class of product, regardless of the status
|
||||||
product, regardless of the status of the particular user or of the way
|
of the particular user or of the way in which the particular user
|
||||||
in which the particular user actually uses, or expects or is expected
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
to use, the product. A product is a consumer product regardless of
|
is a consumer product regardless of whether the product has substantial
|
||||||
whether the product has substantial commercial, industrial or
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
non-consumer uses, unless such uses represent the only significant
|
the only significant mode of use of the product.
|
||||||
mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
"Installation Information" for a User Product means any methods,
|
||||||
procedures, authorization keys, or other information required to
|
procedures, authorization keys, or other information required to install
|
||||||
install and execute modified versions of a covered work in that User
|
and execute modified versions of a covered work in that User Product from
|
||||||
Product from a modified version of its Corresponding Source. The
|
a modified version of its Corresponding Source. The information must
|
||||||
information must suffice to ensure that the continued functioning of
|
suffice to ensure that the continued functioning of the modified object
|
||||||
the modified object code is in no case prevented or interfered with
|
code is in no case prevented or interfered with solely because
|
||||||
solely because modification has been made.
|
modification has been made.
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
If you convey an object code work under this section in, or with, or
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
part of a transaction in which the right of possession and use of the
|
part of a transaction in which the right of possession and use of the
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
@@ -326,24 +314,23 @@ if neither you nor any third party retains the ability to install
|
|||||||
modified object code on the User Product (for example, the work has
|
modified object code on the User Product (for example, the work has
|
||||||
been installed in ROM).
|
been installed in ROM).
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
The requirement to provide Installation Information does not include a
|
||||||
requirement to continue to provide support service, warranty, or
|
requirement to continue to provide support service, warranty, or updates
|
||||||
updates for a work that has been modified or installed by the
|
for a work that has been modified or installed by the recipient, or for
|
||||||
recipient, or for the User Product in which it has been modified or
|
the User Product in which it has been modified or installed. Access to a
|
||||||
installed. Access to a network may be denied when the modification
|
network may be denied when the modification itself materially and
|
||||||
itself materially and adversely affects the operation of the network
|
adversely affects the operation of the network or violates the rules and
|
||||||
or violates the rules and protocols for communication across the
|
protocols for communication across the network.
|
||||||
network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
in accord with this section must be in a format that is publicly
|
in accord with this section must be in a format that is publicly
|
||||||
documented (and with an implementation available to the public in
|
documented (and with an implementation available to the public in
|
||||||
source code form), and must require no special password or key for
|
source code form), and must require no special password or key for
|
||||||
unpacking, reading or copying.
|
unpacking, reading or copying.
|
||||||
|
|
||||||
### 7. Additional Terms.
|
7. Additional Terms.
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
License by making exceptions from one or more of its conditions.
|
License by making exceptions from one or more of its conditions.
|
||||||
Additional permissions that are applicable to the entire Program shall
|
Additional permissions that are applicable to the entire Program shall
|
||||||
be treated as though they were included in this License, to the extent
|
be treated as though they were included in this License, to the extent
|
||||||
@@ -352,36 +339,41 @@ apply only to part of the Program, that part may be used separately
|
|||||||
under those permissions, but the entire Program remains governed by
|
under those permissions, but the entire Program remains governed by
|
||||||
this License without regard to the additional permissions.
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
When you convey a copy of a covered work, you may at your option
|
||||||
remove any additional permissions from that copy, or from any part of
|
remove any additional permissions from that copy, or from any part of
|
||||||
it. (Additional permissions may be written to require their own
|
it. (Additional permissions may be written to require their own
|
||||||
removal in certain cases when you modify the work.) You may place
|
removal in certain cases when you modify the work.) You may place
|
||||||
additional permissions on material, added by you to a covered work,
|
additional permissions on material, added by you to a covered work,
|
||||||
for which you have or can give appropriate copyright permission.
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
Notwithstanding any other provision of this License, for material you
|
||||||
add to a covered work, you may (if authorized by the copyright holders
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
of that material) supplement the terms of this License with terms:
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
- a) Disclaiming warranty or limiting liability differently from the
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
terms of sections 15 and 16 of this License; or
|
terms of sections 15 and 16 of this License; or
|
||||||
- b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
author attributions in that material or in the Appropriate Legal
|
author attributions in that material or in the Appropriate Legal
|
||||||
Notices displayed by works containing it; or
|
Notices displayed by works containing it; or
|
||||||
- c) Prohibiting misrepresentation of the origin of that material,
|
|
||||||
or requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
- d) Limiting the use for publicity purposes of names of licensors
|
|
||||||
or authors of the material; or
|
|
||||||
- e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
- f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions
|
|
||||||
of it) with contractual assumptions of liability to the recipient,
|
|
||||||
for any liability that these contractual assumptions directly
|
|
||||||
impose on those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
received it, or any part of it, contains a notice stating that it is
|
received it, or any part of it, contains a notice stating that it is
|
||||||
governed by this License along with a term that is a further
|
governed by this License along with a term that is a further
|
||||||
@@ -391,47 +383,47 @@ License, you may add to a covered work material governed by the terms
|
|||||||
of that license document, provided that the further restriction does
|
of that license document, provided that the further restriction does
|
||||||
not survive such relicensing or conveying.
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
If you add terms to a covered work in accord with this section, you
|
||||||
must place, in the relevant source files, a statement of the
|
must place, in the relevant source files, a statement of the
|
||||||
additional terms that apply to those files, or a notice indicating
|
additional terms that apply to those files, or a notice indicating
|
||||||
where to find the applicable terms.
|
where to find the applicable terms.
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
form of a separately written license, or stated as exceptions; the
|
form of a separately written license, or stated as exceptions;
|
||||||
above requirements apply either way.
|
the above requirements apply either way.
|
||||||
|
|
||||||
### 8. Termination.
|
8. Termination.
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
You may not propagate or modify a covered work except as expressly
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
modify it is void, and will automatically terminate your rights under
|
modify it is void, and will automatically terminate your rights under
|
||||||
this License (including any patent licenses granted under the third
|
this License (including any patent licenses granted under the third
|
||||||
paragraph of section 11).
|
paragraph of section 11).
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your license
|
However, if you cease all violation of this License, then your
|
||||||
from a particular copyright holder is reinstated (a) provisionally,
|
license from a particular copyright holder is reinstated (a)
|
||||||
unless and until the copyright holder explicitly and finally
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
terminates your license, and (b) permanently, if the copyright holder
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
fails to notify you of the violation by some reasonable means prior to
|
holder fails to notify you of the violation by some reasonable means
|
||||||
60 days after the cessation.
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
Moreover, your license from a particular copyright holder is
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
violation by some reasonable means, this is the first time you have
|
violation by some reasonable means, this is the first time you have
|
||||||
received notice of violation of this License (for any work) from that
|
received notice of violation of this License (for any work) from that
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
your receipt of the notice.
|
your receipt of the notice.
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
Termination of your rights under this section does not terminate the
|
||||||
licenses of parties who have received copies or rights from you under
|
licenses of parties who have received copies or rights from you under
|
||||||
this License. If your rights have been terminated and not permanently
|
this License. If your rights have been terminated and not permanently
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
material under section 10.
|
material under section 10.
|
||||||
|
|
||||||
### 9. Acceptance Not Required for Having Copies.
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or run
|
You are not required to accept this License in order to receive or
|
||||||
a copy of the Program. Ancillary propagation of a covered work
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
to receive a copy likewise does not require acceptance. However,
|
to receive a copy likewise does not require acceptance. However,
|
||||||
nothing other than this License grants you permission to propagate or
|
nothing other than this License grants you permission to propagate or
|
||||||
@@ -439,14 +431,14 @@ modify any covered work. These actions infringe copyright if you do
|
|||||||
not accept this License. Therefore, by modifying or propagating a
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
### 10. Automatic Licensing of Downstream Recipients.
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
Each time you convey a covered work, the recipient automatically
|
||||||
receives a license from the original licensors, to run, modify and
|
receives a license from the original licensors, to run, modify and
|
||||||
propagate that work, subject to this License. You are not responsible
|
propagate that work, subject to this License. You are not responsible
|
||||||
for enforcing compliance by third parties with this License.
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
An "entity transaction" is a transaction transferring control of an
|
||||||
organization, or substantially all assets of one, or subdividing an
|
organization, or substantially all assets of one, or subdividing an
|
||||||
organization, or merging organizations. If propagation of a covered
|
organization, or merging organizations. If propagation of a covered
|
||||||
work results from an entity transaction, each party to that
|
work results from an entity transaction, each party to that
|
||||||
@@ -456,7 +448,7 @@ give under the previous paragraph, plus a right to possession of the
|
|||||||
Corresponding Source of the work from the predecessor in interest, if
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
You may not impose any further restrictions on the exercise of the
|
||||||
rights granted or affirmed under this License. For example, you may
|
rights granted or affirmed under this License. For example, you may
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
rights granted under this License, and you may not initiate litigation
|
rights granted under this License, and you may not initiate litigation
|
||||||
@@ -464,14 +456,14 @@ rights granted under this License, and you may not initiate litigation
|
|||||||
any patent claim is infringed by making, using, selling, offering for
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
sale, or importing the Program or any portion of it.
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
### 11. Patents.
|
11. Patents.
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
License of the Program or a work on which the Program is based. The
|
License of the Program or a work on which the Program is based. The
|
||||||
work thus licensed is called the contributor's "contributor version".
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims owned
|
A contributor's "essential patent claims" are all patent claims
|
||||||
or controlled by the contributor, whether already acquired or
|
owned or controlled by the contributor, whether already acquired or
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
by this License, of making, using, or selling its contributor version,
|
by this License, of making, using, or selling its contributor version,
|
||||||
but do not include claims that would be infringed only as a
|
but do not include claims that would be infringed only as a
|
||||||
@@ -480,19 +472,19 @@ purposes of this definition, "control" includes the right to grant
|
|||||||
patent sublicenses in a manner consistent with the requirements of
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
this License.
|
this License.
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
patent license under the contributor's essential patent claims, to
|
patent license under the contributor's essential patent claims, to
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
propagate the contents of its contributor version.
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
In the following three paragraphs, a "patent license" is any express
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
(such as an express permission to practice a patent or covenant not to
|
(such as an express permission to practice a patent or covenant not to
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
party means to make such an agreement or commitment not to enforce a
|
party means to make such an agreement or commitment not to enforce a
|
||||||
patent against the party.
|
patent against the party.
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
and the Corresponding Source of the work is not available for anyone
|
and the Corresponding Source of the work is not available for anyone
|
||||||
to copy, free of charge and under the terms of this License, through a
|
to copy, free of charge and under the terms of this License, through a
|
||||||
publicly available network server or other readily accessible means,
|
publicly available network server or other readily accessible means,
|
||||||
@@ -506,7 +498,7 @@ covered work in a country, or your recipient's use of the covered work
|
|||||||
in a country, would infringe one or more identifiable patents in that
|
in a country, would infringe one or more identifiable patents in that
|
||||||
country that you have reason to believe are valid.
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
If, pursuant to or in connection with a single transaction or
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
covered work, and grant a patent license to some of the parties
|
covered work, and grant a patent license to some of the parties
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
@@ -514,162 +506,213 @@ or convey a specific copy of the covered work, then the patent license
|
|||||||
you grant is automatically extended to all recipients of the covered
|
you grant is automatically extended to all recipients of the covered
|
||||||
work and works based on it.
|
work and works based on it.
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within the
|
A patent license is "discriminatory" if it does not include within
|
||||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
the non-exercise of one or more of the rights that are specifically
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
granted under this License. You may not convey a covered work if you
|
specifically granted under this License. You may not convey a covered
|
||||||
are a party to an arrangement with a third party that is in the
|
work if you are a party to an arrangement with a third party that is
|
||||||
business of distributing software, under which you make payment to the
|
in the business of distributing software, under which you make payment
|
||||||
third party based on the extent of your activity of conveying the
|
to the third party based on the extent of your activity of conveying
|
||||||
work, and under which the third party grants, to any of the parties
|
the work, and under which the third party grants, to any of the
|
||||||
who would receive the covered work from you, a discriminatory patent
|
parties who would receive the covered work from you, a discriminatory
|
||||||
license (a) in connection with copies of the covered work conveyed by
|
patent license (a) in connection with copies of the covered work
|
||||||
you (or copies made from those copies), or (b) primarily for and in
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
connection with specific products or compilations that contain the
|
for and in connection with specific products or compilations that
|
||||||
covered work, unless you entered into that arrangement, or that patent
|
contain the covered work, unless you entered into that arrangement,
|
||||||
license was granted, prior to 28 March 2007.
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
any implied license or other defenses to infringement that may
|
any implied license or other defenses to infringement that may
|
||||||
otherwise be available to you under applicable patent law.
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
### 12. No Surrender of Others' Freedom.
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
covered work so as to satisfy simultaneously your obligations under
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
this License and any other pertinent obligations, then as a
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
consequence you may not convey it at all. For example, if you agree to
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
terms that obligate you to collect a royalty for further conveying
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
from those to whom you convey the Program, the only way you could
|
the Program, the only way you could satisfy both those terms and this
|
||||||
satisfy both those terms and this License would be to refrain entirely
|
License would be to refrain entirely from conveying the Program.
|
||||||
from conveying the Program.
|
|
||||||
|
|
||||||
### 13. Use with the GNU Affero General Public License.
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
permission to link or combine any covered work with a work licensed
|
permission to link or combine any covered work with a work licensed
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
under version 3 of the GNU General Public License into a single
|
||||||
combined work, and to convey the resulting work. The terms of this
|
combined work, and to convey the resulting work. The terms of this
|
||||||
License will continue to apply to the part which is the covered work,
|
License will continue to apply to the part which is the covered work,
|
||||||
but the special requirements of the GNU Affero General Public License,
|
but the work with which it is combined will remain governed by version
|
||||||
section 13, concerning interaction through a network will apply to the
|
3 of the GNU General Public License.
|
||||||
combination as such.
|
|
||||||
|
|
||||||
### 14. Revised Versions of this License.
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
of the GNU General Public License from time to time. Such new versions
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
will be similar in spirit to the present version, but may differ in
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
detail to address new problems or concerns.
|
address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program
|
Each version is given a distinguishing version number. If the
|
||||||
specifies that a certain numbered version of the GNU General Public
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
License "or any later version" applies to it, you have the option of
|
Public License "or any later version" applies to it, you have the
|
||||||
following the terms and conditions either of that numbered version or
|
option of following the terms and conditions either of that numbered
|
||||||
of any later version published by the Free Software Foundation. If the
|
version or of any later version published by the Free Software
|
||||||
Program does not specify a version number of the GNU General Public
|
Foundation. If the Program does not specify a version number of the
|
||||||
License, you may choose any version ever published by the Free
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
Software Foundation.
|
by the Free Software Foundation.
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future versions
|
If the Program specifies that a proxy can decide which future
|
||||||
of the GNU General Public License can be used, that proxy's public
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
statement of acceptance of a version permanently authorizes you to
|
public statement of acceptance of a version permanently authorizes you
|
||||||
choose that version for the Program.
|
to choose that version for the Program.
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
Later license versions may give you additional or different
|
||||||
permissions. However, no additional obligations are imposed on any
|
permissions. However, no additional obligations are imposed on any
|
||||||
author or copyright holder as a result of your choosing to follow a
|
author or copyright holder as a result of your choosing to follow a
|
||||||
later version.
|
later version.
|
||||||
|
|
||||||
### 15. Disclaimer of Warranty.
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
CORRECTION.
|
|
||||||
|
|
||||||
### 16. Limitation of Liability.
|
16. Limitation of Liability.
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
SUCH DAMAGES.
|
||||||
|
|
||||||
### 17. Interpretation of Sections 15 and 16.
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
above cannot be given local legal effect according to their terms,
|
above cannot be given local legal effect according to their terms,
|
||||||
reviewing courts shall apply local law that most closely approximates
|
reviewing courts shall apply local law that most closely approximates
|
||||||
an absolute waiver of all civil liability in connection with the
|
an absolute waiver of all civil liability in connection with the
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
copy of the Program in return for a fee.
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
## How to Apply These Terms to Your New Programs
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
If you develop a new program, and you want it to be of the greatest
|
||||||
possible use to the public, the best way to achieve this is to make it
|
possible use to the public, the best way to achieve this is to make it
|
||||||
free software which everyone can redistribute and change under these
|
free software which everyone can redistribute and change under these terms.
|
||||||
terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest to
|
To do so, attach the following notices to the program. It is safest
|
||||||
attach them to the start of each source file to most effectively state
|
to attach them to the start of each source file to most effectively
|
||||||
the exclusion of warranty; and each file should have at least the
|
state the exclusion of warranty; and each file should have at least
|
||||||
"copyright" line and a pointer to where the full notice is found.
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
Copyright (C) <year> <name of author>
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
If your software can interact with users remotely through a computer
|
||||||
notice like this when it starts in an interactive mode:
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for the
|
||||||
|
specific requirements.
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
This is free software, and you are welcome to redistribute it
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
under certain conditions; type `show c' for details.
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
The hypothetical commands \`show w' and \`show c' should show the
|
=========================================================================
|
||||||
appropriate parts of the General Public License. Of course, your
|
|
||||||
program's commands might be different; for a GUI interface, you would
|
|
||||||
use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or
|
ADDITIONAL TERMS pursuant to Section 7 of the GNU Affero General Public
|
||||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
License, Version 3
|
||||||
necessary. For more information on this, and how to apply and follow
|
|
||||||
the GNU GPL, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your
|
The following additional terms apply to the CloudCLI UI project
|
||||||
program into proprietary programs. If your program is a subroutine
|
(https://github.com/siteboon/claudecodeui). These terms are authorized
|
||||||
library, you may consider it more useful to permit linking proprietary
|
by Siteboon AI B.V. as copyright holder pursuant to Section 7 of the AGPL-3.0.
|
||||||
applications with the library. If this is what you want to do, use the
|
|
||||||
GNU Lesser General Public License instead of this License. But first,
|
1. Attribution Requirement (Section 7(b))
|
||||||
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
||||||
|
All copies, modified versions, and derivative works of this software
|
||||||
|
must preserve the following attribution notice in their documentation,
|
||||||
|
README, or Appropriate Legal Notices:
|
||||||
|
|
||||||
|
"CloudCLI UI (https://github.com/siteboon/claudecodeui)"
|
||||||
|
|
||||||
|
This notice must be reasonably prominent and not hidden in a manner
|
||||||
|
designed to avoid notice by recipients of the software.
|
||||||
|
|
||||||
|
2. Prohibition of Misrepresentation (Section 7(c))
|
||||||
|
|
||||||
|
You may not misrepresent the origin of this software. Modified
|
||||||
|
versions of the software must be clearly and prominently marked as
|
||||||
|
such, and must not be presented as the original CloudCLI UI software.
|
||||||
|
|
||||||
|
3. Limitation on Publicity (Section 7(d))
|
||||||
|
|
||||||
|
The names "Siteboon" and "CloudCLI" may not be used for publicity
|
||||||
|
purposes to endorse or promote products derived from this software
|
||||||
|
without specific prior written permission from Siteboon AI B.V.
|
||||||
|
|
||||||
|
4. No Trademark Rights (Section 7(e))
|
||||||
|
|
||||||
|
This License does not grant permission to use the trade names,
|
||||||
|
trademarks, service marks, or product names "CloudCLI," "CloudCLI UI,"
|
||||||
|
or "Siteboon," except as required for reasonable and customary use in
|
||||||
|
describing the origin of the work and reproducing the content of the
|
||||||
|
attribution notice required above.
|
||||||
|
|
||||||
|
=========================================================================
|
||||||
|
|
||||||
|
RELICENSING NOTICE
|
||||||
|
|
||||||
|
Contributions made by Siteboon AI B.V. prior to commit
|
||||||
|
004135ef0187023e1da29c4a7137a28a42ebf9af (2026-03-28) were originally
|
||||||
|
published under GPL-3.0. These contributions are hereby relicensed under
|
||||||
|
AGPL-3.0-or-later by Siteboon AI B.V., as copyright holder.
|
||||||
|
|
||||||
|
Contributions made by other authors prior to the above commit remain
|
||||||
|
under GPL-3.0 and are incorporated into this AGPL-3.0-or-later work as
|
||||||
|
permitted by GPL-3.0 Section 13 ("Use with the GNU Affero General Public
|
||||||
|
License").
|
||||||
|
|
||||||
|
All new contributions from the above commit onward are licensed under
|
||||||
|
AGPL-3.0-or-later.
|
||||||
|
|||||||
13
NOTICE
Normal file
13
NOTICE
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
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,16 +76,18 @@ 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 @siteboon/claude-code-ui
|
npx @cloudcli-ai/cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
Oder **global** installieren für regelmäßige Nutzung:
|
Oder **global** installieren für regelmäßige Nutzung:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @siteboon/claude-code-ui
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
cloudcli
|
cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -93,6 +95,15 @@ 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/).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -104,7 +115,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 @siteboon/claude-code-ui` | Keine Einrichtung erforderlich |
|
| **Einrichtung** | `npx @cloudcli-ai/cloudcli` | 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,16 +72,18 @@
|
|||||||
|
|
||||||
### セルフホスト(オープンソース)
|
### セルフホスト(オープンソース)
|
||||||
|
|
||||||
|
#### npm
|
||||||
|
|
||||||
**npx** で今すぐ CloudCLI UI を試せます(**Node.js** v22+ が必要):
|
**npx** で今すぐ CloudCLI UI を試せます(**Node.js** v22+ が必要):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx @siteboon/claude-code-ui
|
npx @cloudcli-ai/cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
または、普段使いするなら **グローバル** にインストール:
|
または、普段使いするなら **グローバル** にインストール:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @siteboon/claude-code-ui
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
cloudcli
|
cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -89,6 +91,15 @@ 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/)をご覧ください。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -100,7 +111,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 @siteboon/claude-code-ui` | セットアップ不要 |
|
| **セットアップ** | `npx @cloudcli-ai/cloudcli` | セットアップ不要 |
|
||||||
| **マシンの稼働継続** | はい | いいえ |
|
| **マシンの稼働継続** | はい | いいえ |
|
||||||
| **モバイルアクセス** | 同一ネットワーク内の任意のブラウザ | 任意のデバイス(ネイティブアプリも準備中) |
|
| **モバイルアクセス** | 同一ネットワーク内の任意のブラウザ | 任意のデバイス(ネイティブアプリも準備中) |
|
||||||
| **利用可能なセッション** | `~/.claude` から全セッションを自動検出 | クラウド環境内の全セッション |
|
| **利用可能なセッション** | `~/.claude` から全セッションを自動検出 | クラウド環境内の全セッション |
|
||||||
|
|||||||
20
README.ko.md
20
README.ko.md
@@ -72,22 +72,34 @@
|
|||||||
|
|
||||||
### 셀프 호스트 (오픈 소스)
|
### 셀프 호스트 (오픈 소스)
|
||||||
|
|
||||||
|
#### npm
|
||||||
|
|
||||||
**npx**로 즉시 CloudCLI UI를 실행하세요 (Node.js v22+ 필요):
|
**npx**로 즉시 CloudCLI UI를 실행하세요 (Node.js v22+ 필요):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx @siteboon/claude-code-ui
|
npx @cloudcli-ai/cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
**정기적으로 사용한다면 전역 설치:**
|
**정기적으로 사용한다면 전역 설치:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @siteboon/claude-code-ui
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
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/)를 참고하세요.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -99,7 +111,7 @@ CloudCLI UI는 CloudCLI Cloud를 구동하는 오픈 소스 UI 계층입니다.
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| **적합한 대상** | 로컬 에이전트 세션을 위한 전체 UI가 필요한 개발자 | 어디서든 접근 가능한 클라우드에서 에이전트를 운영하고자 하는 팀 및 개발자 |
|
| **적합한 대상** | 로컬 에이전트 세션을 위한 전체 UI가 필요한 개발자 | 어디서든 접근 가능한 클라우드에서 에이전트를 운영하고자 하는 팀 및 개발자 |
|
||||||
| **접근 방법** | `[yourip]:port`를 통해 브라우저 접속 | 브라우저, IDE, REST API, n8n |
|
| **접근 방법** | `[yourip]:port`를 통해 브라우저 접속 | 브라우저, IDE, REST API, n8n |
|
||||||
| **설정** | `npx @siteboon/claude-code-ui` | 설정 불필요 |
|
| **설정** | `npx @cloudcli-ai/cloudcli` | 설정 불필요 |
|
||||||
| **기기 유지 필요 여부** | 예 (머신 켜둬야 함) | 아니오 |
|
| **기기 유지 필요 여부** | 예 (머신 켜둬야 함) | 아니오 |
|
||||||
| **모바일 접근** | 네트워크 내 브라우저 | 모든 기기 (네이티브 앱 예정) |
|
| **모바일 접근** | 네트워크 내 브라우저 | 모든 기기 (네이티브 앱 예정) |
|
||||||
| **세션 접근** | `~/.claude`에서 자동 발견 | 클라우드 환경 내 세션 |
|
| **세션 접근** | `~/.claude`에서 자동 발견 | 클라우드 환경 내 세션 |
|
||||||
|
|||||||
58
README.md
58
README.md
@@ -76,48 +76,58 @@ 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 @siteboon/claude-code-ui
|
npx @cloudcli-ai/cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
Or install **globally** for regular use:
|
Or install **globally** for regular use:
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install -g @siteboon/claude-code-ui
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
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 more full configuration options, PM2, remote server setup and more
|
Visit the **[documentation →](https://cloudcli.ai/docs)** for 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, or use CloudCLI Cloud which builds on top of it with a full managed cloud environment, team features, and deeper integrations.
|
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 (Self-hosted) | CloudCLI Cloud |
|
| | Self-Hosted (npm) | Self-Hosted (Docker Sandbox) *(Experimental)* | 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 |
|
| **Best for** | Local agent sessions on your own machine | Isolated agents with web/mobile IDE | Teams who want agents in the cloud |
|
||||||
| **How you access it** | Browser via `[yourip]:port` | Browser, any IDE, REST API, n8n |
|
| **How you access it** | Browser via `[yourip]:port` | Browser via `localhost:port` | Browser, any IDE, REST API, n8n |
|
||||||
| **Setup** | `npx @siteboon/claude-code-ui` | No setup required |
|
| **Setup** | `npx @cloudcli-ai/cloudcli` | `npx @cloudcli-ai/cloudcli@latest sandbox ~/project` | No setup required |
|
||||||
| **Machine needs to stay on** | Yes | No |
|
| **Isolation** | Runs on your host | Hypervisor-level sandbox (microVM) | Full cloud isolation |
|
||||||
| **Mobile access** | Any browser on your network | Any device, native app coming |
|
| **Machine needs to stay on** | Yes | Yes | No |
|
||||||
| **Sessions available** | All sessions auto-discovered from `~/.claude` | All sessions within your cloud environment |
|
| **Mobile access** | Any browser on your network | Any browser on your network | Any device, native app coming |
|
||||||
| **Agents supported** | Claude Code, Cursor CLI, Codex, Gemini CLI | Claude Code, Cursor CLI, Codex, Gemini CLI |
|
| **Agents supported** | Claude Code, Cursor CLI, Codex, Gemini CLI | Claude Code, Codex, Gemini CLI | Claude Code, Cursor CLI, Codex, Gemini CLI |
|
||||||
| **File explorer and Git** | Yes, built into the UI | Yes, built into the UI |
|
| **File explorer and Git** | Yes | Yes | Yes |
|
||||||
| **MCP configuration** | Managed via UI, synced with your local `~/.claude` config | Managed via UI |
|
| **MCP configuration** | Synced with `~/.claude` | Managed via UI | Managed via UI |
|
||||||
| **IDE access** | Your local IDE | Any IDE connected to your cloud environment |
|
| **REST API** | Yes | Yes | Yes |
|
||||||
| **REST API** | Yes | Yes |
|
| **Team sharing** | No | No | Yes |
|
||||||
| **n8n node** | No | Yes |
|
| **Platform cost** | Free, open source | Free, open source | Starts at $7/month |
|
||||||
| **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.
|
> All options use your own AI subscriptions (Claude, Cursor, etc.) — CloudCLI provides the environment, not the AI.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -213,9 +223,11 @@ Yes, for self-hosted. CloudCLI UI reads from and writes to the same `~/.claude`
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
GNU General Public License v3.0 - see [LICENSE](LICENSE) file for details.
|
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.
|
||||||
|
|
||||||
This project is open source and free to use, modify, and distribute under the GPL v3 license.
|
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
|
## Acknowledgments
|
||||||
|
|
||||||
|
|||||||
19
README.ru.md
19
README.ru.md
@@ -76,23 +76,34 @@
|
|||||||
|
|
||||||
### Self-Hosted (Open source)
|
### Self-Hosted (Open source)
|
||||||
|
|
||||||
|
#### npm
|
||||||
|
|
||||||
Попробовать CloudCLI UI можно сразу через **npx** (требуется **Node.js** v22+):
|
Попробовать CloudCLI UI можно сразу через **npx** (требуется **Node.js** v22+):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx @siteboon/claude-code-ui
|
npx @cloudcli-ai/cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
Или установить **глобально** для регулярного использования:
|
Или установить **глобально** для регулярного использования:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @siteboon/claude-code-ui
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
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/).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -104,7 +115,7 @@ CloudCLI UI — это open source UI-слой, на котором постро
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| **Лучше всего подходит для** | Разработчиков, которым нужен полноценный UI для локальных агентских сессий на своей машине | Команд и разработчиков, которым нужны агенты в облаке с доступом откуда угодно |
|
| **Лучше всего подходит для** | Разработчиков, которым нужен полноценный UI для локальных агентских сессий на своей машине | Команд и разработчиков, которым нужны агенты в облаке с доступом откуда угодно |
|
||||||
| **Как вы получаете доступ** | Браузер через `[yourip]:port` | Браузер, любая IDE, REST API, n8n |
|
| **Как вы получаете доступ** | Браузер через `[yourip]:port` | Браузер, любая IDE, REST API, n8n |
|
||||||
| **Настройка** | `npx @siteboon/claude-code-ui` | Настройка не требуется |
|
| **Настройка** | `npx @cloudcli-ai/cloudcli` | Настройка не требуется |
|
||||||
| **Машина должна оставаться включённой** | Да | Нет |
|
| **Машина должна оставаться включённой** | Да | Нет |
|
||||||
| **Доступ с мобильных устройств** | Любой браузер в вашей сети | Любое устройство, нативное приложение в разработке |
|
| **Доступ с мобильных устройств** | Любой браузер в вашей сети | Любое устройство, нативное приложение в разработке |
|
||||||
| **Доступные сессии** | Все сессии автоматически обнаруживаются из `~/.claude` | Все сессии внутри вашей облачной среды |
|
| **Доступные сессии** | Все сессии автоматически обнаруживаются из `~/.claude` | Все сессии внутри вашей облачной среды |
|
||||||
|
|||||||
@@ -72,22 +72,34 @@
|
|||||||
|
|
||||||
### 自托管(开源)
|
### 自托管(开源)
|
||||||
|
|
||||||
|
#### npm
|
||||||
|
|
||||||
启动 CloudCLI UI,只需一行 `npx`(需要 Node.js v22+):
|
启动 CloudCLI UI,只需一行 `npx`(需要 Node.js v22+):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx @siteboon/claude-code-ui
|
npx @cloudcli-ai/cloudcli
|
||||||
```
|
```
|
||||||
|
|
||||||
或进行全局安装,便于日常使用:
|
或进行全局安装,便于日常使用:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @siteboon/claude-code-ui
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
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/)。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -99,7 +111,7 @@ CloudCLI UI 是 CloudCLI Cloud 的开源 UI 层。你可以在本地机器上自
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| **适合对象** | 需要为本地代理会话提供完整 UI 的开发者 | 需要部署在云端,随时从任何地方访问代理的团队与开发者 |
|
| **适合对象** | 需要为本地代理会话提供完整 UI 的开发者 | 需要部署在云端,随时从任何地方访问代理的团队与开发者 |
|
||||||
| **访问方式** | 通过 `[yourip]:port` 在浏览器中访问 | 浏览器、任意 IDE、REST API、n8n |
|
| **访问方式** | 通过 `[yourip]:port` 在浏览器中访问 | 浏览器、任意 IDE、REST API、n8n |
|
||||||
| **设置** | `npx @siteboon/claude-code-ui` | 无需设置 |
|
| **设置** | `npx @cloudcli-ai/cloudcli` | 无需设置 |
|
||||||
| **机器需保持开机吗** | 是 | 否 |
|
| **机器需保持开机吗** | 是 | 否 |
|
||||||
| **移动端访问** | 网络内任意浏览器 | 任意设备(原生应用即将推出) |
|
| **移动端访问** | 网络内任意浏览器 | 任意设备(原生应用即将推出) |
|
||||||
| **可用会话** | 自动发现 `~/.claude` 中的所有会话 | 云端环境内的会话 |
|
| **可用会话** | 自动发现 `~/.claude` 中的所有会话 | 云端环境内的会话 |
|
||||||
|
|||||||
160
docker/README.md
Normal file
160
docker/README.md
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
<!-- 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
|
||||||
11
docker/claude-code/Dockerfile
Normal file
11
docker/claude-code/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
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
|
||||||
11
docker/codex/Dockerfile
Normal file
11
docker/codex/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
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
|
||||||
11
docker/gemini/Dockerfile
Normal file
11
docker/gemini/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
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
|
||||||
11
docker/shared/install-cloudcli.sh
Normal file
11
docker/shared/install-cloudcli.sh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/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/*
|
||||||
18
docker/shared/start-cloudcli.sh
Normal file
18
docker/shared/start-cloudcli.sh
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/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
|
||||||
132
eslint.config.js
132
eslint.config.js
@@ -3,7 +3,9 @@ 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 importX from "eslint-plugin-import-x";
|
import { createNodeResolver, 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";
|
||||||
@@ -82,7 +84,7 @@ export default tseslint.config(
|
|||||||
"sibling",
|
"sibling",
|
||||||
"index",
|
"index",
|
||||||
],
|
],
|
||||||
"newlines-between": "never",
|
"newlines-between": "always",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -98,5 +100,131 @@ 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-types", // shared backend type contract that modules may consume without creating runtime coupling
|
||||||
|
pattern: ["server/shared/types.{js,ts}"], // support the current shared types path
|
||||||
|
mode: "file", // treat the types file itself as the boundary element instead of the whole folder
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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 the shared types contract only as erased type-only imports
|
||||||
|
to: { type: "backend-shared-types" },
|
||||||
|
disallow: {
|
||||||
|
dependency: { kind: ["value", "typeof"] },
|
||||||
|
}, // block runtime imports so shared types stay a compile-time contract instead of a hidden shared module
|
||||||
|
message:
|
||||||
|
"Backend modules may only use `import type` when importing from server/shared/types.ts (or server/types.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
|
||||||
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
1902
package-lock.json
generated
1902
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
62
package.json
62
package.json
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "@siteboon/claude-code-ui",
|
"name": "@cloudcli-ai/cloudcli",
|
||||||
"version": "1.26.2",
|
"version": "1.29.5",
|
||||||
"description": "A web-based UI for Claude Code CLI",
|
"description": "A web-based UI for Claude Code CLI",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "server/index.js",
|
"main": "dist-server/server/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"claude-code-ui": "server/cli.js",
|
"cloudcli": "dist-server/server/cli.js"
|
||||||
"cloudcli": "server/cli.js"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"server/",
|
"server/",
|
||||||
"shared/",
|
"shared/",
|
||||||
"dist/",
|
"dist/",
|
||||||
|
"dist-server/",
|
||||||
"scripts/",
|
"scripts/",
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
@@ -24,29 +24,46 @@
|
|||||||
"url": "https://github.com/siteboon/claudecodeui/issues"
|
"url": "https://github.com/siteboon/claudecodeui/issues"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently --kill-others \"npm run server\" \"npm run client\"",
|
"dev": "concurrently --kill-others \"npm run server:dev\" \"npm run client\"",
|
||||||
"server": "node server/index.js",
|
"server": "node dist-server/server/index.js",
|
||||||
|
"server:dev": "tsx --tsconfig server/tsconfig.json server/index.js",
|
||||||
|
"server:dev-watch": "tsx watch --tsconfig server/tsconfig.json server/index.js",
|
||||||
"client": "vite",
|
"client": "vite",
|
||||||
"build": "vite build",
|
"build": "npm run build:client && npm run build:server",
|
||||||
|
"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",
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p server/tsconfig.json",
|
||||||
"lint": "eslint src/",
|
"lint": "eslint src/ server/",
|
||||||
"lint:fix": "eslint src/ --fix",
|
"lint:fix": "eslint src/ server/ --fix",
|
||||||
"start": "npm run build && npm run server",
|
"start": "npm run build && npm run server",
|
||||||
"release": "./release.sh",
|
"release": "./release.sh",
|
||||||
"prepublishOnly": "npm run build",
|
"prepublishOnly": "npm run 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",
|
||||||
"ai",
|
"claude-code",
|
||||||
|
"claude-code-ui",
|
||||||
|
"cloudcli",
|
||||||
|
"codex",
|
||||||
|
"gemini",
|
||||||
|
"gemini-cli",
|
||||||
|
"cursor",
|
||||||
|
"cursor-cli",
|
||||||
"anthropic",
|
"anthropic",
|
||||||
|
"openai",
|
||||||
|
"google",
|
||||||
|
"coding-agent",
|
||||||
|
"web-ui",
|
||||||
"ui",
|
"ui",
|
||||||
"mobile"
|
"mobile IDE"
|
||||||
],
|
],
|
||||||
"author": "CloudCLI UI Contributors",
|
"author": "CloudCLI UI Contributors",
|
||||||
"license": "GPL-3.0",
|
"license": "AGPL-3.0-or-later",
|
||||||
"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",
|
||||||
@@ -87,7 +104,7 @@
|
|||||||
"mime-types": "^3.0.1",
|
"mime-types": "^3.0.1",
|
||||||
"multer": "^2.0.1",
|
"multer": "^2.0.1",
|
||||||
"node-fetch": "^2.7.0",
|
"node-fetch": "^2.7.0",
|
||||||
"node-pty": "^1.1.0-beta34",
|
"node-pty": "^1.2.0-beta.12",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-dropzone": "^14.2.3",
|
"react-dropzone": "^14.2.3",
|
||||||
@@ -100,15 +117,13 @@
|
|||||||
"rehype-raw": "^7.0.0",
|
"rehype-raw": "^7.0.0",
|
||||||
"remark-gfm": "^4.0.0",
|
"remark-gfm": "^4.0.0",
|
||||||
"remark-math": "^6.0.0",
|
"remark-math": "^6.0.0",
|
||||||
"sqlite": "^5.1.1",
|
|
||||||
"sqlite3": "^5.1.7",
|
|
||||||
"tailwind-merge": "^3.3.1",
|
"tailwind-merge": "^3.3.1",
|
||||||
"web-push": "^3.6.7",
|
"web-push": "^3.6.7",
|
||||||
"ws": "^8.14.2"
|
"ws": "^8.14.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^20.4.3",
|
"@commitlint/cli": "^20.5.0",
|
||||||
"@commitlint/config-conventional": "^20.4.3",
|
"@commitlint/config-conventional": "^20.5.0",
|
||||||
"@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/node": "^22.19.7",
|
"@types/node": "^22.19.7",
|
||||||
@@ -119,6 +134,8 @@
|
|||||||
"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",
|
||||||
@@ -133,11 +150,14 @@
|
|||||||
"release-it": "^19.0.5",
|
"release-it": "^19.0.5",
|
||||||
"sharp": "^0.34.2",
|
"sharp": "^0.34.2",
|
||||||
"tailwindcss": "^3.4.0",
|
"tailwindcss": "^3.4.0",
|
||||||
|
"tsc-alias": "^1.8.16",
|
||||||
|
"tsx": "^4.21.0",
|
||||||
"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>Claude Code UI - API Documentation</title>
|
<title>CloudCLI - 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>Claude Code UI</h1>
|
<h1>CloudCLI</h1>
|
||||||
<div class="subtitle">API Documentation</div>
|
<div class="subtitle">API Documentation</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Service Worker for Claude Code UI PWA
|
// Service Worker for CloudCLI 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: 'Claude Code UI', body: event.data.text() };
|
payload = { title: 'CloudCLI', 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 || 'Claude Code UI', options)
|
self.registration.showNotification(payload.title || 'CloudCLI', options)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
248
redirect-package/README.md
Normal file
248
redirect-package/README.md
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
<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>
|
||||||
2
redirect-package/bin.js
Normal file
2
redirect-package/bin.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import('@cloudcli-ai/cloudcli/dist-server/server/cli.js');
|
||||||
2
redirect-package/index.js
Normal file
2
redirect-package/index.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from '@cloudcli-ai/cloudcli';
|
||||||
|
export { default } from '@cloudcli-ai/cloudcli';
|
||||||
43
redirect-package/package.json
Normal file
43
redirect-package/package.json
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
@@ -24,15 +24,16 @@ import {
|
|||||||
notifyRunStopped,
|
notifyRunStopped,
|
||||||
notifyUserIfEnabled
|
notifyUserIfEnabled
|
||||||
} from './services/notification-orchestrator.js';
|
} from './services/notification-orchestrator.js';
|
||||||
import { claudeAdapter } from './providers/claude/adapter.js';
|
import { claudeAdapter } from './providers/claude/index.js';
|
||||||
import { createNormalizedMessage } from './providers/types.js';
|
import { createNormalizedMessage } from './providers/types.js';
|
||||||
|
import { getStatusChecker } from './providers/registry.js';
|
||||||
|
|
||||||
const activeSessions = new Map();
|
const activeSessions = new Map();
|
||||||
const pendingToolApprovals = new Map();
|
const pendingToolApprovals = new Map();
|
||||||
|
|
||||||
const TOOL_APPROVAL_TIMEOUT_MS = parseInt(process.env.CLAUDE_TOOL_APPROVAL_TIMEOUT_MS, 10) || 55000;
|
const TOOL_APPROVAL_TIMEOUT_MS = parseInt(process.env.CLAUDE_TOOL_APPROVAL_TIMEOUT_MS, 10) || 55000;
|
||||||
|
|
||||||
const TOOLS_REQUIRING_INTERACTION = new Set(['AskUserQuestion']);
|
const TOOLS_REQUIRING_INTERACTION = new Set(['AskUserQuestion', 'ExitPlanMode']);
|
||||||
|
|
||||||
function createRequestId() {
|
function createRequestId() {
|
||||||
if (typeof crypto.randomUUID === 'function') {
|
if (typeof crypto.randomUUID === 'function') {
|
||||||
@@ -148,6 +149,10 @@ function mapCliOptionsToSDK(options = {}) {
|
|||||||
|
|
||||||
const sdkOptions = {};
|
const sdkOptions = {};
|
||||||
|
|
||||||
|
if (process.env.CLAUDE_CLI_PATH) {
|
||||||
|
sdkOptions.pathToClaudeCodeExecutable = process.env.CLAUDE_CLI_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
// Map working directory
|
// Map working directory
|
||||||
if (cwd) {
|
if (cwd) {
|
||||||
sdkOptions.cwd = cwd;
|
sdkOptions.cwd = cwd;
|
||||||
@@ -701,8 +706,14 @@ async function queryClaudeSDK(command, options = {}, ws) {
|
|||||||
// Clean up temporary image files on error
|
// Clean up temporary image files on error
|
||||||
await cleanupTempFiles(tempImagePaths, tempDir);
|
await cleanupTempFiles(tempImagePaths, tempDir);
|
||||||
|
|
||||||
|
// Check if Claude CLI is installed for a clearer error message
|
||||||
|
const installed = getStatusChecker('claude')?.checkInstalled() ?? true;
|
||||||
|
const errorContent = !installed
|
||||||
|
? 'Claude Code is not installed. Please install it first: https://docs.anthropic.com/en/docs/claude-code'
|
||||||
|
: error.message;
|
||||||
|
|
||||||
// Send error to WebSocket
|
// Send error to WebSocket
|
||||||
ws.send(createNormalizedMessage({ kind: 'error', content: error.message, sessionId: capturedSessionId || sessionId || null, provider: 'claude' }));
|
ws.send(createNormalizedMessage({ kind: 'error', content: errorContent, sessionId: capturedSessionId || sessionId || null, provider: 'claude' }));
|
||||||
notifyRunFailed({
|
notifyRunFailed({
|
||||||
userId: ws?.userId || null,
|
userId: ws?.userId || null,
|
||||||
provider: 'claude',
|
provider: 'claude',
|
||||||
@@ -710,8 +721,6 @@ async function queryClaudeSDK(command, options = {}, ws) {
|
|||||||
sessionName: sessionSummary,
|
sessionName: sessionSummary,
|
||||||
error
|
error
|
||||||
});
|
});
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
399
server/cli.js
399
server/cli.js
@@ -1,12 +1,13 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
/**
|
/**
|
||||||
* Claude Code UI CLI
|
* CloudCLI CLI
|
||||||
*
|
*
|
||||||
* Provides command-line utilities for managing Claude Code UI
|
* Provides command-line utilities for managing CloudCLI
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -15,11 +16,12 @@
|
|||||||
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 { fileURLToPath } from 'url';
|
import { findAppRoot, getModuleDir } from './utils/runtime-paths.js';
|
||||||
import { dirname } from 'path';
|
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __dirname = getModuleDir(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
// The CLI is compiled into dist-server/server, but it still needs to read the top-level
|
||||||
|
// 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 = {
|
||||||
@@ -49,13 +51,16 @@ const c = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Load package.json for version info
|
// Load package.json for version info
|
||||||
const packageJsonPath = path.join(__dirname, '../package.json');
|
const packageJsonPath = path.join(APP_ROOT, '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(__dirname, '../.env');
|
const envPath = path.join(APP_ROOT, '.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();
|
||||||
@@ -74,17 +79,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 || path.join(__dirname, 'database', 'auth.db');
|
return process.env.DATABASE_PATH || DEFAULT_DATABASE_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the installation directory
|
// Get the installation directory
|
||||||
function getInstallDir() {
|
function getInstallDir() {
|
||||||
return path.join(__dirname, '..');
|
return APP_ROOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show status command
|
// Show status command
|
||||||
function showStatus() {
|
function showStatus() {
|
||||||
console.log(`\n${c.bright('Claude Code UI - Status')}\n`);
|
console.log(`\n${c.bright('CloudCLI UI - Status')}\n`);
|
||||||
console.log(c.dim('═'.repeat(60)));
|
console.log(c.dim('═'.repeat(60)));
|
||||||
|
|
||||||
// Version info
|
// Version info
|
||||||
@@ -123,7 +128,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(__dirname, '../.env');
|
const envFilePath = path.join(APP_ROOT, '.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)}`);
|
||||||
@@ -141,7 +146,7 @@ function showStatus() {
|
|||||||
function showHelp() {
|
function showHelp() {
|
||||||
console.log(`
|
console.log(`
|
||||||
╔═══════════════════════════════════════════════════════════════╗
|
╔═══════════════════════════════════════════════════════════════╗
|
||||||
║ Claude Code UI - Command Line Tool ║
|
║ CloudCLI - Command Line Tool ║
|
||||||
╚═══════════════════════════════════════════════════════════════╝
|
╚═══════════════════════════════════════════════════════════════╝
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
@@ -149,7 +154,8 @@ Usage:
|
|||||||
cloudcli [command] [options]
|
cloudcli [command] [options]
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
start Start the Claude Code UI server (default)
|
start Start the CloudCLI 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
|
||||||
@@ -164,8 +170,7 @@ 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 -p 3000 # Short form for port
|
$ cloudcli sandbox ~/my-project # Run in a Docker sandbox
|
||||||
$ cloudcli start --port 4000 # Explicit start command
|
|
||||||
$ cloudcli status # Show configuration
|
$ cloudcli status # Show configuration
|
||||||
|
|
||||||
Environment Variables:
|
Environment Variables:
|
||||||
@@ -203,7 +208,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 @siteboon/claude-code-ui version', { encoding: 'utf8' }).trim();
|
const latestVersion = execSync('npm show @cloudcli-ai/cloudcli version', { encoding: 'utf8' }).trim();
|
||||||
const currentVersion = packageJson.version;
|
const currentVersion = packageJson.version;
|
||||||
|
|
||||||
if (isNewerVersion(latestVersion, currentVersion)) {
|
if (isNewerVersion(latestVersion, currentVersion)) {
|
||||||
@@ -236,14 +241,361 @@ 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 @siteboon/claude-code-ui', { stdio: 'inherit' });
|
execSync('npm update -g @cloudcli-ai/cloudcli', { 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 @siteboon/claude-code-ui`);
|
console.log(`${c.tip('[TIP]')} Try running manually: npm update -g @cloudcli-ai/cloudcli`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── 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
|
||||||
@@ -274,6 +626,10 @@ 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +639,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 } = parseArgs(args);
|
const { command, options, remainingArgs } = parseArgs(args);
|
||||||
|
|
||||||
// Apply CLI options to environment variables
|
// Apply CLI options to environment variables
|
||||||
if (options.serverPort) {
|
if (options.serverPort) {
|
||||||
@@ -299,6 +655,9 @@ 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,9 @@
|
|||||||
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 { cursorAdapter } from './providers/cursor/adapter.js';
|
import { cursorAdapter } from './providers/cursor/index.js';
|
||||||
import { createNormalizedMessage } from './providers/types.js';
|
import { createNormalizedMessage } from './providers/types.js';
|
||||||
|
import { getStatusChecker } from './providers/registry.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;
|
||||||
@@ -294,7 +295,13 @@ async function spawnCursor(command, options = {}, ws) {
|
|||||||
const finalSessionId = capturedSessionId || sessionId || processKey;
|
const finalSessionId = capturedSessionId || sessionId || processKey;
|
||||||
activeCursorProcesses.delete(finalSessionId);
|
activeCursorProcesses.delete(finalSessionId);
|
||||||
|
|
||||||
ws.send(createNormalizedMessage({ kind: 'error', content: error.message, sessionId: capturedSessionId || sessionId || null, provider: 'cursor' }));
|
// Check if Cursor CLI is installed for a clearer error message
|
||||||
|
const installed = getStatusChecker('cursor')?.checkInstalled() ?? true;
|
||||||
|
const errorContent = !installed
|
||||||
|
? 'Cursor CLI is not installed. Please install it from https://cursor.com'
|
||||||
|
: error.message;
|
||||||
|
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'error', content: errorContent, sessionId: capturedSessionId || sessionId || null, provider: 'cursor' }));
|
||||||
notifyTerminalState({ error });
|
notifyTerminalState({ error });
|
||||||
|
|
||||||
settleOnce(() => reject(error));
|
settleOnce(() => reject(error));
|
||||||
|
|||||||
@@ -2,11 +2,21 @@ 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 { fileURLToPath } from 'url';
|
import { findAppRoot, getModuleDir } from '../utils/runtime-paths.js';
|
||||||
import { dirname } from 'path';
|
import {
|
||||||
|
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 __filename = fileURLToPath(import.meta.url);
|
const __dirname = getModuleDir(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
// The compiled backend lives under dist-server/server/database, but the install root we log
|
||||||
|
// 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 = {
|
||||||
@@ -24,7 +34,6 @@ 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) {
|
||||||
@@ -62,14 +71,10 @@ 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(`CREATE TABLE IF NOT EXISTS app_config (
|
db.exec(APP_CONFIG_TABLE_SQL);
|
||||||
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 = path.join(__dirname, '../..');
|
const appInstallPath = APP_ROOT;
|
||||||
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)}`);
|
||||||
@@ -100,53 +105,12 @@ 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(`
|
db.exec(USER_NOTIFICATION_PREFERENCES_TABLE_SQL);
|
||||||
CREATE TABLE IF NOT EXISTS user_notification_preferences (
|
db.exec(VAPID_KEYS_TABLE_SQL);
|
||||||
user_id INTEGER PRIMARY KEY,
|
db.exec(PUSH_SUBSCRIPTIONS_TABLE_SQL);
|
||||||
preferences_json TEXT NOT NULL,
|
db.exec(APP_CONFIG_TABLE_SQL);
|
||||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
db.exec(SESSION_NAMES_TABLE_SQL);
|
||||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
db.exec(SESSION_NAMES_LOOKUP_INDEX_SQL);
|
||||||
)
|
|
||||||
`);
|
|
||||||
|
|
||||||
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) {
|
||||||
@@ -158,8 +122,7 @@ const runMigrations = () => {
|
|||||||
// Initialize database with schema
|
// Initialize database with schema
|
||||||
const initializeDatabase = async () => {
|
const initializeDatabase = async () => {
|
||||||
try {
|
try {
|
||||||
const initSQL = fs.readFileSync(INIT_SQL_PATH, 'utf8');
|
db.exec(DATABASE_SCHEMA_SQL);
|
||||||
db.exec(initSQL);
|
|
||||||
console.log('Database initialized successfully');
|
console.log('Database initialized successfully');
|
||||||
runMigrations();
|
runMigrations();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
-- 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
|
|
||||||
);
|
|
||||||
102
server/database/schema.js
Normal file
102
server/database/schema.js
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
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}
|
||||||
|
`;
|
||||||
@@ -10,6 +10,7 @@ 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 './providers/types.js';
|
import { createNormalizedMessage } from './providers/types.js';
|
||||||
|
import { getStatusChecker } from './providers/registry.js';
|
||||||
|
|
||||||
let activeGeminiProcesses = new Map(); // Track active processes by session ID
|
let activeGeminiProcesses = new Map(); // Track active processes by session ID
|
||||||
|
|
||||||
@@ -380,6 +381,15 @@ async function spawnGemini(command, options = {}, ws) {
|
|||||||
notifyTerminalState({ code });
|
notifyTerminalState({ code });
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
|
// code 127 = shell "command not found" — check installation
|
||||||
|
if (code === 127) {
|
||||||
|
const installed = getStatusChecker('gemini')?.checkInstalled() ?? true;
|
||||||
|
if (!installed) {
|
||||||
|
const socketSessionId = typeof ws.getSessionId === 'function' ? ws.getSessionId() : finalSessionId;
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'error', content: 'Gemini CLI is not installed. Please install it first: https://github.com/google-gemini/gemini-cli', sessionId: socketSessionId, provider: 'gemini' }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
notifyTerminalState({
|
notifyTerminalState({
|
||||||
code,
|
code,
|
||||||
error: code === null ? 'Gemini CLI process was terminated or timed out' : null
|
error: code === null ? 'Gemini CLI process was terminated or timed out' : null
|
||||||
@@ -394,8 +404,14 @@ async function spawnGemini(command, options = {}, ws) {
|
|||||||
const finalSessionId = capturedSessionId || sessionId || processKey;
|
const finalSessionId = capturedSessionId || sessionId || processKey;
|
||||||
activeGeminiProcesses.delete(finalSessionId);
|
activeGeminiProcesses.delete(finalSessionId);
|
||||||
|
|
||||||
|
// Check if Gemini CLI is installed for a clearer error message
|
||||||
|
const installed = getStatusChecker('gemini')?.checkInstalled() ?? true;
|
||||||
|
const errorContent = !installed
|
||||||
|
? 'Gemini CLI is not installed. Please install it first: https://github.com/google-gemini/gemini-cli'
|
||||||
|
: error.message;
|
||||||
|
|
||||||
const errorSessionId = typeof ws.getSessionId === 'function' ? ws.getSessionId() : finalSessionId;
|
const errorSessionId = typeof ws.getSessionId === 'function' ? ws.getSessionId() : finalSessionId;
|
||||||
ws.send(createNormalizedMessage({ kind: 'error', content: error.message, sessionId: errorSessionId, provider: 'gemini' }));
|
ws.send(createNormalizedMessage({ kind: 'error', content: errorContent, sessionId: errorSessionId, provider: 'gemini' }));
|
||||||
notifyTerminalState({ error });
|
notifyTerminalState({ error });
|
||||||
|
|
||||||
reject(error);
|
reject(error);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Gemini Response Handler - JSON Stream processing
|
// Gemini Response Handler - JSON Stream processing
|
||||||
import { geminiAdapter } from './providers/gemini/adapter.js';
|
import { geminiAdapter } from './providers/gemini/index.js';
|
||||||
|
|
||||||
class GeminiResponseHandler {
|
class GeminiResponseHandler {
|
||||||
constructor(ws, options = {}) {
|
constructor(ws, options = {}) {
|
||||||
|
|||||||
288
server/index.js
288
server/index.js
@@ -3,33 +3,15 @@
|
|||||||
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 { fileURLToPath } from 'url';
|
import { findAppRoot, getModuleDir } from './utils/runtime-paths.js';
|
||||||
import { dirname } from 'path';
|
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __dirname = getModuleDir(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
// 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';
|
||||||
|
|
||||||
const installMode = fs.existsSync(path.join(__dirname, '..', '.git')) ? 'git' : 'npm';
|
import { c } from './utils/colors.js';
|
||||||
|
|
||||||
// ANSI color codes for terminal output
|
|
||||||
const colors = {
|
|
||||||
reset: '\x1b[0m',
|
|
||||||
bright: '\x1b[1m',
|
|
||||||
cyan: '\x1b[36m',
|
|
||||||
green: '\x1b[32m',
|
|
||||||
yellow: '\x1b[33m',
|
|
||||||
blue: '\x1b[34m',
|
|
||||||
dim: '\x1b[2m',
|
|
||||||
};
|
|
||||||
|
|
||||||
const c = {
|
|
||||||
info: (text) => `${colors.cyan}${text}${colors.reset}`,
|
|
||||||
ok: (text) => `${colors.green}${text}${colors.reset}`,
|
|
||||||
warn: (text) => `${colors.yellow}${text}${colors.reset}`,
|
|
||||||
tip: (text) => `${colors.blue}${text}${colors.reset}`,
|
|
||||||
bright: (text) => `${colors.bright}${text}${colors.reset}`,
|
|
||||||
dim: (text) => `${colors.dim}${text}${colors.reset}`,
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log('SERVER_PORT from env:', process.env.SERVER_PORT);
|
console.log('SERVER_PORT from env:', process.env.SERVER_PORT);
|
||||||
|
|
||||||
@@ -226,68 +208,7 @@ const server = http.createServer(app);
|
|||||||
const ptySessionsMap = new Map();
|
const ptySessionsMap = new Map();
|
||||||
const PTY_SESSION_TIMEOUT = 30 * 60 * 1000;
|
const PTY_SESSION_TIMEOUT = 30 * 60 * 1000;
|
||||||
const SHELL_URL_PARSE_BUFFER_LIMIT = 32768;
|
const SHELL_URL_PARSE_BUFFER_LIMIT = 32768;
|
||||||
const ANSI_ESCAPE_SEQUENCE_REGEX = /\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/g;
|
import { stripAnsiSequences, normalizeDetectedUrl, extractUrlsFromText, shouldAutoOpenUrlFromOutput } from './utils/url-detection.js';
|
||||||
const TRAILING_URL_PUNCTUATION_REGEX = /[)\]}>.,;:!?]+$/;
|
|
||||||
|
|
||||||
function stripAnsiSequences(value = '') {
|
|
||||||
return value.replace(ANSI_ESCAPE_SEQUENCE_REGEX, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeDetectedUrl(url) {
|
|
||||||
if (!url || typeof url !== 'string') return null;
|
|
||||||
|
|
||||||
const cleaned = url.trim().replace(TRAILING_URL_PUNCTUATION_REGEX, '');
|
|
||||||
if (!cleaned) return null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const parsed = new URL(cleaned);
|
|
||||||
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return parsed.toString();
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractUrlsFromText(value = '') {
|
|
||||||
const directMatches = value.match(/https?:\/\/[^\s<>"'`\\\x1b\x07]+/gi) || [];
|
|
||||||
|
|
||||||
// Handle wrapped terminal URLs split across lines by terminal width.
|
|
||||||
const wrappedMatches = [];
|
|
||||||
const continuationRegex = /^[A-Za-z0-9\-._~:/?#\[\]@!$&'()*+,;=%]+$/;
|
|
||||||
const lines = value.split(/\r?\n/);
|
|
||||||
for (let i = 0; i < lines.length; i++) {
|
|
||||||
const line = lines[i].trim();
|
|
||||||
const startMatch = line.match(/https?:\/\/[^\s<>"'`\\\x1b\x07]+/i);
|
|
||||||
if (!startMatch) continue;
|
|
||||||
|
|
||||||
let combined = startMatch[0];
|
|
||||||
let j = i + 1;
|
|
||||||
while (j < lines.length) {
|
|
||||||
const continuation = lines[j].trim();
|
|
||||||
if (!continuation) break;
|
|
||||||
if (!continuationRegex.test(continuation)) break;
|
|
||||||
combined += continuation;
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
wrappedMatches.push(combined.replace(/\r?\n\s*/g, ''));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Array.from(new Set([...directMatches, ...wrappedMatches]));
|
|
||||||
}
|
|
||||||
|
|
||||||
function shouldAutoOpenUrlFromOutput(value = '') {
|
|
||||||
const normalized = value.toLowerCase();
|
|
||||||
return (
|
|
||||||
normalized.includes('browser didn\'t open') ||
|
|
||||||
normalized.includes('open this url') ||
|
|
||||||
normalized.includes('continue in your browser') ||
|
|
||||||
normalized.includes('press enter to open') ||
|
|
||||||
normalized.includes('open_url:')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Single WebSocket server that handles both paths
|
// Single WebSocket server that handles both paths
|
||||||
const wss = new WebSocketServer({
|
const wss = new WebSocketServer({
|
||||||
@@ -405,11 +326,11 @@ app.use('/api/sessions', authenticateToken, messagesRoutes);
|
|||||||
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(__dirname, '../public')));
|
app.use(express.static(path.join(APP_ROOT, '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(__dirname, '../dist'), {
|
app.use(express.static(path.join(APP_ROOT, '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
|
||||||
@@ -431,17 +352,24 @@ app.use(express.static(path.join(__dirname, '../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 = path.join(__dirname, '..');
|
const projectRoot = APP_ROOT;
|
||||||
|
|
||||||
console.log('Starting system update from directory:', projectRoot);
|
console.log('Starting system update from directory:', projectRoot);
|
||||||
|
|
||||||
// Run the update command based on install mode
|
// Platform deployments use their own update workflow from the project root.
|
||||||
const updateCommand = installMode === 'git'
|
const updateCommand = IS_PLATFORM
|
||||||
|
// In platform, husky and dev dependencies are not needed
|
||||||
|
? 'npm run update:platform'
|
||||||
|
: installMode === 'git'
|
||||||
? 'git checkout main && git pull && npm install'
|
? 'git checkout main && git pull && npm install'
|
||||||
: 'npm install -g @siteboon/claude-code-ui@latest';
|
: '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: installMode === 'git' ? projectRoot : os.homedir(),
|
cwd: updateCwd,
|
||||||
env: process.env
|
env: process.env
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -566,12 +494,15 @@ app.put('/api/sessions/:sessionId/rename', authenticateToken, async (req, res) =
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete project endpoint (force=true to delete with sessions)
|
// Delete project endpoint
|
||||||
|
// force=true to allow removal even when sessions exist
|
||||||
|
// deleteData=true to also delete session/memory files on disk (destructive)
|
||||||
app.delete('/api/projects/:projectName', authenticateToken, async (req, res) => {
|
app.delete('/api/projects/:projectName', authenticateToken, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { projectName } = req.params;
|
const { projectName } = req.params;
|
||||||
const force = req.query.force === 'true';
|
const force = req.query.force === 'true';
|
||||||
await deleteProject(projectName, force);
|
const deleteData = req.query.deleteData === 'true';
|
||||||
|
await deleteProject(projectName, force, deleteData);
|
||||||
res.json({ success: true });
|
res.json({ success: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
@@ -812,7 +743,7 @@ app.get('/api/projects/:projectName/file', authenticateToken, async (req, res) =
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serve binary file content endpoint (for images, etc.)
|
// Serve raw file bytes for previews and downloads.
|
||||||
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;
|
||||||
@@ -829,7 +760,11 @@ 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' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolved = path.resolve(filePath);
|
// Match the text reader endpoint so callers can pass either project-relative
|
||||||
|
// 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' });
|
||||||
@@ -1980,155 +1915,6 @@ 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 {
|
||||||
@@ -2411,7 +2197,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(__dirname, '../dist/index.html');
|
const indexPath = path.join(APP_ROOT, '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)) {
|
||||||
@@ -2526,7 +2312,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(__dirname, '../dist/index.html');
|
const distIndexPath = path.join(APP_ROOT, 'dist', 'index.html');
|
||||||
const isProduction = fs.existsSync(distIndexPath);
|
const isProduction = fs.existsSync(distIndexPath);
|
||||||
|
|
||||||
// Log Claude implementation mode
|
// Log Claude implementation mode
|
||||||
@@ -2540,11 +2326,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 = path.join(__dirname, '..');
|
const appInstallPath = APP_ROOT;
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log(c.dim('═'.repeat(63)));
|
console.log(c.dim('═'.repeat(63)));
|
||||||
console.log(` ${c.bright('Claude Code UI Server - Ready')}`);
|
console.log(` ${c.bright('CloudCLI 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,14 +2,15 @@
|
|||||||
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 { fileURLToPath } from 'url';
|
import { findAppRoot, getModuleDir } from './utils/runtime-paths.js';
|
||||||
import { dirname } from 'path';
|
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __dirname = getModuleDir(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
// Resolve the repo/app root via the nearest /server folder so this file keeps finding the
|
||||||
|
// 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(__dirname, '../.env');
|
const envPath = path.join(APP_ROOT, '.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();
|
||||||
@@ -24,6 +25,10 @@ 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 = path.join(os.homedir(), '.cloudcli', 'auth.db');
|
process.env.DATABASE_PATH = DEFAULT_DATABASE_PATH;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,9 @@
|
|||||||
|
|
||||||
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 { codexAdapter } from './providers/codex/adapter.js';
|
import { codexAdapter } from './providers/codex/index.js';
|
||||||
import { createNormalizedMessage } from './providers/types.js';
|
import { createNormalizedMessage } from './providers/types.js';
|
||||||
|
import { getStatusChecker } from './providers/registry.js';
|
||||||
|
|
||||||
// Track active sessions
|
// Track active sessions
|
||||||
const activeCodexSessions = new Map();
|
const activeCodexSessions = new Map();
|
||||||
@@ -308,7 +309,14 @@ export async function queryCodex(command, options = {}, ws) {
|
|||||||
|
|
||||||
if (!wasAborted) {
|
if (!wasAborted) {
|
||||||
console.error('[Codex] Error:', error);
|
console.error('[Codex] Error:', error);
|
||||||
sendMessage(ws, createNormalizedMessage({ kind: 'error', content: error.message, sessionId: currentSessionId, provider: 'codex' }));
|
|
||||||
|
// Check if Codex SDK is available for a clearer error message
|
||||||
|
const installed = getStatusChecker('codex')?.checkInstalled() ?? true;
|
||||||
|
const errorContent = !installed
|
||||||
|
? 'Codex CLI is not configured. Please set up authentication first.'
|
||||||
|
: error.message;
|
||||||
|
|
||||||
|
sendMessage(ws, createNormalizedMessage({ kind: 'error', content: errorContent, sessionId: currentSessionId, provider: 'codex' }));
|
||||||
if (!terminalFailure) {
|
if (!terminalFailure) {
|
||||||
notifyRunFailed({
|
notifyRunFailed({
|
||||||
userId: ws?.userId || null,
|
userId: ws?.userId || null,
|
||||||
|
|||||||
@@ -62,8 +62,7 @@ import fsSync from 'fs';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import readline from 'readline';
|
import readline from 'readline';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import sqlite3 from 'sqlite3';
|
import Database from 'better-sqlite3';
|
||||||
import { open } from 'sqlite';
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import sessionManager from './sessionManager.js';
|
import sessionManager from './sessionManager.js';
|
||||||
import { applyCustomSessionNames } from './database/db.js';
|
import { applyCustomSessionNames } from './database/db.js';
|
||||||
@@ -1164,8 +1163,9 @@ async function isProjectEmpty(projectName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete a project (force=true to delete even with sessions)
|
// Remove a project from the UI.
|
||||||
async function deleteProject(projectName, force = false) {
|
// When deleteData=true, also delete session/memory files on disk (destructive).
|
||||||
|
async function deleteProject(projectName, force = false, deleteData = false) {
|
||||||
const projectDir = path.join(os.homedir(), '.claude', 'projects', projectName);
|
const projectDir = path.join(os.homedir(), '.claude', 'projects', projectName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1175,17 +1175,18 @@ async function deleteProject(projectName, force = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const config = await loadProjectConfig();
|
const config = await loadProjectConfig();
|
||||||
let projectPath = config[projectName]?.path || config[projectName]?.originalPath;
|
|
||||||
|
|
||||||
// Fallback to extractProjectDirectory if projectPath is not in config
|
// Destructive path: delete underlying data when explicitly requested
|
||||||
|
if (deleteData) {
|
||||||
|
let projectPath = config[projectName]?.path || config[projectName]?.originalPath;
|
||||||
if (!projectPath) {
|
if (!projectPath) {
|
||||||
projectPath = await extractProjectDirectory(projectName);
|
projectPath = await extractProjectDirectory(projectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the project directory (includes all Claude sessions)
|
// Remove the Claude project directory (session logs, memory, subagent data)
|
||||||
await fs.rm(projectDir, { recursive: true, force: true });
|
await fs.rm(projectDir, { recursive: true, force: true });
|
||||||
|
|
||||||
// Delete all Codex sessions associated with this project
|
// Delete Codex sessions associated with this project
|
||||||
if (projectPath) {
|
if (projectPath) {
|
||||||
try {
|
try {
|
||||||
const codexSessions = await getCodexSessions(projectPath, { limit: 0 });
|
const codexSessions = await getCodexSessions(projectPath, { limit: 0 });
|
||||||
@@ -1209,14 +1210,15 @@ async function deleteProject(projectName, force = false) {
|
|||||||
// Cursor dir may not exist, ignore
|
// Cursor dir may not exist, ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove from project config
|
// Always remove from project config
|
||||||
delete config[projectName];
|
delete config[projectName];
|
||||||
await saveProjectConfig(config);
|
await saveProjectConfig(config);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error deleting project ${projectName}:`, error);
|
console.error(`Error removing project ${projectName}:`, error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1305,16 +1307,10 @@ async function getCursorSessions(projectPath) {
|
|||||||
} catch (_) { }
|
} catch (_) { }
|
||||||
|
|
||||||
// Open SQLite database
|
// Open SQLite database
|
||||||
const db = await open({
|
const db = new Database(storeDbPath, { readonly: true, fileMustExist: true });
|
||||||
filename: storeDbPath,
|
|
||||||
driver: sqlite3.Database,
|
|
||||||
mode: sqlite3.OPEN_READONLY
|
|
||||||
});
|
|
||||||
|
|
||||||
// Get metadata from meta table
|
// Get metadata from meta table
|
||||||
const metaRows = await db.all(`
|
const metaRows = db.prepare('SELECT key, value FROM meta').all();
|
||||||
SELECT key, value FROM meta
|
|
||||||
`);
|
|
||||||
|
|
||||||
// Parse metadata
|
// Parse metadata
|
||||||
let metadata = {};
|
let metadata = {};
|
||||||
@@ -1336,11 +1332,9 @@ async function getCursorSessions(projectPath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get message count
|
// Get message count
|
||||||
const messageCountResult = await db.get(`
|
const messageCountResult = db.prepare('SELECT COUNT(*) as count FROM blobs').get();
|
||||||
SELECT COUNT(*) as count FROM blobs
|
|
||||||
`);
|
|
||||||
|
|
||||||
await db.close();
|
db.close();
|
||||||
|
|
||||||
// Extract session info
|
// Extract session info
|
||||||
const sessionName = metadata.title || metadata.sessionTitle || 'Untitled Session';
|
const sessionName = metadata.title || metadata.sessionTitle || 'Untitled Session';
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
* @module adapters/claude
|
* @module adapters/claude
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getSessionMessages } from '../../projects.js';
|
|
||||||
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
||||||
import { isInternalContent } from '../utils.js';
|
import { isInternalContent } from '../utils.js';
|
||||||
|
|
||||||
@@ -200,79 +199,3 @@ export function normalizeMessage(raw, sessionId) {
|
|||||||
|
|
||||||
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,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|||||||
1
server/providers/claude/config.js
Normal file
1
server/providers/claude/config.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// TODO: migrate Claude session list/delete endpoints from server/index.js
|
||||||
8
server/providers/claude/index.js
Normal file
8
server/providers/claude/index.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Claude provider barrel.
|
||||||
|
* Assembles the ProviderAdapter from adapter + sessions.
|
||||||
|
*/
|
||||||
|
import { normalizeMessage } from './adapter.js';
|
||||||
|
import { fetchHistory } from './sessions.js';
|
||||||
|
|
||||||
|
export const claudeAdapter = { normalizeMessage, fetchHistory };
|
||||||
82
server/providers/claude/sessions.js
Normal file
82
server/providers/claude/sessions.js
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/**
|
||||||
|
* Claude provider session history.
|
||||||
|
*
|
||||||
|
* Fetches and normalizes persisted JSONL session data.
|
||||||
|
* @module adapters/claude/sessions
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { normalizeMessage } from './adapter.js';
|
||||||
|
import { getSessionMessages } from '../../projects.js';
|
||||||
|
import { createNormalizedMessage } from '../types.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch session history from JSONL files, returning normalized messages.
|
||||||
|
* @param {string} sessionId
|
||||||
|
* @param {import('../types.js').FetchHistoryOptions} opts
|
||||||
|
* @returns {Promise<import('../types.js').FetchHistoryResult>}
|
||||||
|
*/
|
||||||
|
export async function 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,
|
||||||
|
};
|
||||||
|
}
|
||||||
136
server/providers/claude/status.js
Normal file
136
server/providers/claude/status.js
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/**
|
||||||
|
* Claude Provider Status
|
||||||
|
*
|
||||||
|
* Checks whether Claude Code CLI is installed and whether the user
|
||||||
|
* has valid authentication credentials.
|
||||||
|
*
|
||||||
|
* @module providers/claude/status
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { execFileSync } from 'child_process';
|
||||||
|
import { promises as fs } from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Claude Code CLI is installed and available.
|
||||||
|
* Uses CLAUDE_CLI_PATH env var if set, otherwise looks for 'claude' in PATH.
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export function checkInstalled() {
|
||||||
|
const cliPath = process.env.CLAUDE_CLI_PATH || 'claude';
|
||||||
|
try {
|
||||||
|
execFileSync(cliPath, ['--version'], { stdio: 'ignore', timeout: 5000 });
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full status check: installation + authentication.
|
||||||
|
* @returns {Promise<import('../types.js').ProviderStatus>}
|
||||||
|
*/
|
||||||
|
export async function checkStatus() {
|
||||||
|
const installed = checkInstalled();
|
||||||
|
|
||||||
|
if (!installed) {
|
||||||
|
return {
|
||||||
|
installed,
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
method: null,
|
||||||
|
error: 'Claude Code CLI is not installed'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const credentialsResult = await checkCredentials();
|
||||||
|
|
||||||
|
if (credentialsResult.authenticated) {
|
||||||
|
return {
|
||||||
|
installed,
|
||||||
|
authenticated: true,
|
||||||
|
email: credentialsResult.email || 'Authenticated',
|
||||||
|
method: credentialsResult.method || null,
|
||||||
|
error: null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
installed,
|
||||||
|
authenticated: false,
|
||||||
|
email: credentialsResult.email || null,
|
||||||
|
method: credentialsResult.method || null,
|
||||||
|
error: credentialsResult.error || 'Not authenticated'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Internal helpers ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
async function loadSettingsEnv() {
|
||||||
|
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 {
|
||||||
|
// Ignore missing or malformed settings.
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks Claude authentication credentials.
|
||||||
|
*
|
||||||
|
* Priority 1: ANTHROPIC_API_KEY environment variable
|
||||||
|
* Priority 1b: ~/.claude/settings.json env values
|
||||||
|
* Priority 2: ~/.claude/.credentials.json OAuth tokens
|
||||||
|
*/
|
||||||
|
async function checkCredentials() {
|
||||||
|
if (process.env.ANTHROPIC_API_KEY && process.env.ANTHROPIC_API_KEY.trim()) {
|
||||||
|
return { authenticated: true, email: 'API Key Auth', method: 'api_key' };
|
||||||
|
}
|
||||||
|
|
||||||
|
const settingsEnv = await loadSettingsEnv();
|
||||||
|
|
||||||
|
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' };
|
||||||
|
}
|
||||||
|
|
||||||
|
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: creds.email || creds.user || null,
|
||||||
|
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 };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
* @module adapters/codex
|
* @module adapters/codex
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getCodexSessionMessages } from '../../projects.js';
|
|
||||||
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
||||||
|
|
||||||
const PROVIDER = 'codex';
|
const PROVIDER = 'codex';
|
||||||
@@ -16,7 +15,7 @@ const PROVIDER = 'codex';
|
|||||||
* @param {string} sessionId
|
* @param {string} sessionId
|
||||||
* @returns {import('../types.js').NormalizedMessage[]}
|
* @returns {import('../types.js').NormalizedMessage[]}
|
||||||
*/
|
*/
|
||||||
function normalizeCodexHistoryEntry(raw, sessionId) {
|
export function normalizeCodexHistoryEntry(raw, sessionId) {
|
||||||
const ts = raw.timestamp || new Date().toISOString();
|
const ts = raw.timestamp || new Date().toISOString();
|
||||||
const baseId = raw.uuid || generateMessageId('codex');
|
const baseId = raw.uuid || generateMessageId('codex');
|
||||||
|
|
||||||
@@ -191,58 +190,3 @@ export function normalizeMessage(raw, sessionId) {
|
|||||||
|
|
||||||
return [];
|
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,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|||||||
1
server/providers/codex/config.js
Normal file
1
server/providers/codex/config.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// TODO: migrate GET /config from server/routes/codex.js
|
||||||
8
server/providers/codex/index.js
Normal file
8
server/providers/codex/index.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Codex provider barrel.
|
||||||
|
* Assembles the ProviderAdapter from adapter + sessions.
|
||||||
|
*/
|
||||||
|
import { normalizeMessage } from './adapter.js';
|
||||||
|
import { fetchHistory } from './sessions.js';
|
||||||
|
|
||||||
|
export const codexAdapter = { normalizeMessage, fetchHistory };
|
||||||
1
server/providers/codex/mcp.js
Normal file
1
server/providers/codex/mcp.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// TODO: migrate MCP CRUD endpoints from server/routes/codex.js
|
||||||
63
server/providers/codex/sessions.js
Normal file
63
server/providers/codex/sessions.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* Codex session history fetcher.
|
||||||
|
*
|
||||||
|
* Extracted from adapter.js — pure data-access concern.
|
||||||
|
* @module providers/codex/sessions
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { normalizeCodexHistoryEntry } from './adapter.js';
|
||||||
|
import { getCodexSessionMessages } from '../../projects.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch session history from Codex JSONL files.
|
||||||
|
* @param {string} sessionId
|
||||||
|
* @param {object} opts
|
||||||
|
* @param {number|null} [opts.limit]
|
||||||
|
* @param {number} [opts.offset]
|
||||||
|
* @returns {Promise<{messages: import('../../providers/types.js').NormalizedMessage[], total: number, hasMore: boolean, offset: number, limit: number|null, tokenUsage: object|null}>}
|
||||||
|
*/
|
||||||
|
export async function 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,
|
||||||
|
};
|
||||||
|
}
|
||||||
78
server/providers/codex/status.js
Normal file
78
server/providers/codex/status.js
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
/**
|
||||||
|
* Codex Provider Status
|
||||||
|
*
|
||||||
|
* Checks whether the user has valid Codex authentication credentials.
|
||||||
|
* Codex uses an SDK that makes direct API calls (no external binary),
|
||||||
|
* so installation check always returns true if the server is running.
|
||||||
|
*
|
||||||
|
* @module providers/codex/status
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { promises as fs } from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Codex is installed.
|
||||||
|
* Codex SDK is bundled with this application — no external binary needed.
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export function checkInstalled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full status check: installation + authentication.
|
||||||
|
* @returns {Promise<import('../types.js').ProviderStatus>}
|
||||||
|
*/
|
||||||
|
export async function checkStatus() {
|
||||||
|
const installed = checkInstalled();
|
||||||
|
const result = await checkCredentials();
|
||||||
|
|
||||||
|
return {
|
||||||
|
installed,
|
||||||
|
authenticated: result.authenticated,
|
||||||
|
email: result.email || null,
|
||||||
|
error: result.error || null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Internal helpers ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
async function checkCredentials() {
|
||||||
|
try {
|
||||||
|
const authPath = path.join(os.homedir(), '.codex', 'auth.json');
|
||||||
|
const content = await fs.readFile(authPath, 'utf8');
|
||||||
|
const auth = JSON.parse(content);
|
||||||
|
|
||||||
|
const tokens = auth.tokens || {};
|
||||||
|
|
||||||
|
if (tokens.id_token || tokens.access_token) {
|
||||||
|
let email = 'Authenticated';
|
||||||
|
if (tokens.id_token) {
|
||||||
|
try {
|
||||||
|
const parts = tokens.id_token.split('.');
|
||||||
|
if (parts.length >= 2) {
|
||||||
|
const payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString('utf8'));
|
||||||
|
email = payload.email || payload.user || 'Authenticated';
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
email = 'Authenticated';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { authenticated: true, email };
|
||||||
|
}
|
||||||
|
|
||||||
|
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 };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* Cursor provider adapter.
|
* Cursor provider adapter.
|
||||||
*
|
*
|
||||||
* Normalizes Cursor CLI session history into NormalizedMessage format.
|
* Normalizes Cursor CLI realtime NDJSON events into NormalizedMessage format.
|
||||||
|
* History loading lives in ./sessions.js.
|
||||||
* @module adapters/cursor
|
* @module adapters/cursor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import path from 'path';
|
import { createNormalizedMessage } from '../types.js';
|
||||||
import os from 'os';
|
|
||||||
import crypto from 'crypto';
|
|
||||||
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
|
||||||
|
|
||||||
const PROVIDER = 'cursor';
|
const PROVIDER = 'cursor';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
* Load raw blobs from Cursor's SQLite store.db, parse the DAG structure,
|
* Load raw blobs from Cursor's SQLite store.db, parse the DAG structure,
|
||||||
* and return sorted message blobs in chronological order.
|
* and return sorted message blobs in chronological order.
|
||||||
* @param {string} sessionId
|
* @param {string} sessionId
|
||||||
@@ -20,21 +20,16 @@ const PROVIDER = 'cursor';
|
|||||||
* @returns {Promise<Array<{id: string, sequence: number, rowid: number, content: object}>>}
|
* @returns {Promise<Array<{id: string, sequence: number, rowid: number, content: object}>>}
|
||||||
*/
|
*/
|
||||||
async function loadCursorBlobs(sessionId, projectPath) {
|
async function loadCursorBlobs(sessionId, projectPath) {
|
||||||
// Lazy-import sqlite so the module doesn't fail if sqlite3 is unavailable
|
// Lazy-import better-sqlite3 so the module doesn't fail if it's unavailable
|
||||||
const { default: sqlite3 } = await import('sqlite3');
|
const { default: Database } = await import('better-sqlite3');
|
||||||
const { open } = await import('sqlite');
|
|
||||||
|
|
||||||
const cwdId = crypto.createHash('md5').update(projectPath || process.cwd()).digest('hex');
|
const cwdId = crypto.createHash('md5').update(projectPath || process.cwd()).digest('hex');
|
||||||
const storeDbPath = path.join(os.homedir(), '.cursor', 'chats', cwdId, sessionId, 'store.db');
|
const storeDbPath = path.join(os.homedir(), '.cursor', 'chats', cwdId, sessionId, 'store.db');
|
||||||
|
|
||||||
const db = await open({
|
const db = new Database(storeDbPath, { readonly: true, fileMustExist: true });
|
||||||
filename: storeDbPath,
|
|
||||||
driver: sqlite3.Database,
|
|
||||||
mode: sqlite3.OPEN_READONLY,
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const allBlobs = await db.all('SELECT rowid, id, data FROM blobs');
|
const allBlobs = db.prepare('SELECT rowid, id, data FROM blobs').all();
|
||||||
|
|
||||||
const blobMap = new Map();
|
const blobMap = new Map();
|
||||||
const parentRefs = new Map();
|
const parentRefs = new Map();
|
||||||
@@ -129,11 +124,12 @@ async function loadCursorBlobs(sessionId, projectPath) {
|
|||||||
|
|
||||||
return messages;
|
return messages;
|
||||||
} finally {
|
} finally {
|
||||||
await db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
>>>>>>> refactor/split-server-index
|
||||||
* Normalize a realtime NDJSON event from Cursor CLI into NormalizedMessage(s).
|
* Normalize a realtime NDJSON event from Cursor CLI into NormalizedMessage(s).
|
||||||
* History uses normalizeCursorBlobs (SQLite DAG), this handles streaming NDJSON.
|
* History uses normalizeCursorBlobs (SQLite DAG), this handles streaming NDJSON.
|
||||||
* @param {object|string} raw - A parsed NDJSON event or a raw text line
|
* @param {object|string} raw - A parsed NDJSON event or a raw text line
|
||||||
@@ -151,203 +147,3 @@ export function normalizeMessage(raw, sessionId) {
|
|||||||
}
|
}
|
||||||
return [];
|
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;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|||||||
1
server/providers/cursor/config.js
Normal file
1
server/providers/cursor/config.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// TODO: migrate GET/POST /config from server/routes/cursor.js
|
||||||
8
server/providers/cursor/index.js
Normal file
8
server/providers/cursor/index.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Cursor provider barrel.
|
||||||
|
* Assembles the ProviderAdapter from adapter + sessions.
|
||||||
|
*/
|
||||||
|
import { normalizeMessage } from './adapter.js';
|
||||||
|
import { fetchHistory, normalizeCursorBlobs } from './sessions.js';
|
||||||
|
|
||||||
|
export const cursorAdapter = { normalizeMessage, fetchHistory, normalizeCursorBlobs };
|
||||||
1
server/providers/cursor/mcp.js
Normal file
1
server/providers/cursor/mcp.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// TODO: migrate MCP CRUD endpoints from server/routes/cursor.js
|
||||||
330
server/providers/cursor/sessions.js
Normal file
330
server/providers/cursor/sessions.js
Normal file
@@ -0,0 +1,330 @@
|
|||||||
|
/**
|
||||||
|
* Cursor provider session history.
|
||||||
|
*
|
||||||
|
* Reads Cursor's SQLite store.db, walks the DAG, and returns
|
||||||
|
* NormalizedMessage[] for a given session.
|
||||||
|
* @module providers/cursor/sessions
|
||||||
|
*/
|
||||||
|
|
||||||
|
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 better-sqlite3 so the module doesn't fail if it's unavailable
|
||||||
|
const { default: Database } = await import('better-sqlite3');
|
||||||
|
|
||||||
|
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 = new Database(storeDbPath, { readonly: true, fileMustExist: true });
|
||||||
|
|
||||||
|
try {
|
||||||
|
const allBlobs = db.prepare('SELECT rowid, id, data FROM blobs').all();
|
||||||
|
|
||||||
|
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 {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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[]}
|
||||||
|
*/
|
||||||
|
export function 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch session history for Cursor from SQLite store.db.
|
||||||
|
* @param {string} sessionId
|
||||||
|
* @param {object} opts
|
||||||
|
* @param {string} [opts.projectPath='']
|
||||||
|
* @param {number|null} [opts.limit=null]
|
||||||
|
* @param {number} [opts.offset=0]
|
||||||
|
* @returns {Promise<{messages: import('../types.js').NormalizedMessage[], total: number, hasMore: boolean, offset: number, limit: number|null}>}
|
||||||
|
*/
|
||||||
|
export async function fetchHistory(sessionId, opts = {}) {
|
||||||
|
const { projectPath = '', limit = null, offset = 0 } = opts;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const blobs = await loadCursorBlobs(sessionId, projectPath);
|
||||||
|
const allNormalized = 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 };
|
||||||
|
}
|
||||||
|
}
|
||||||
128
server/providers/cursor/status.js
Normal file
128
server/providers/cursor/status.js
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/**
|
||||||
|
* Cursor Provider Status
|
||||||
|
*
|
||||||
|
* Checks whether cursor-agent CLI is installed and whether the user
|
||||||
|
* is logged in.
|
||||||
|
*
|
||||||
|
* @module providers/cursor/status
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { execFileSync, spawn } from 'child_process';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if cursor-agent CLI is installed.
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export function checkInstalled() {
|
||||||
|
try {
|
||||||
|
execFileSync('cursor-agent', ['--version'], { stdio: 'ignore', timeout: 5000 });
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full status check: installation + authentication.
|
||||||
|
* @returns {Promise<import('../types.js').ProviderStatus>}
|
||||||
|
*/
|
||||||
|
export async function checkStatus() {
|
||||||
|
const installed = checkInstalled();
|
||||||
|
|
||||||
|
if (!installed) {
|
||||||
|
return {
|
||||||
|
installed,
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'Cursor CLI is not installed'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await checkCursorLogin();
|
||||||
|
|
||||||
|
return {
|
||||||
|
installed,
|
||||||
|
authenticated: result.authenticated,
|
||||||
|
email: result.email || null,
|
||||||
|
error: result.error || null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Internal helpers ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
function checkCursorLogin() {
|
||||||
|
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 {
|
||||||
|
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] });
|
||||||
|
} else if (stdout.includes('Logged in')) {
|
||||||
|
resolve({ authenticated: true, email: 'Logged in' });
|
||||||
|
} else {
|
||||||
|
resolve({ authenticated: false, email: null, error: 'Not logged in' });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolve({ authenticated: false, email: null, error: stderr || 'Not logged in' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
childProcess.on('error', () => {
|
||||||
|
if (processCompleted) return;
|
||||||
|
processCompleted = true;
|
||||||
|
clearTimeout(timeout);
|
||||||
|
|
||||||
|
resolve({
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'Cursor CLI not found or not installed'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -5,8 +5,6 @@
|
|||||||
* @module adapters/gemini
|
* @module adapters/gemini
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import sessionManager from '../../sessionManager.js';
|
|
||||||
import { getGeminiCliSessionMessages } from '../../projects.js';
|
|
||||||
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
||||||
|
|
||||||
const PROVIDER = 'gemini';
|
const PROVIDER = 'gemini';
|
||||||
@@ -72,115 +70,3 @@ export function normalizeMessage(raw, sessionId) {
|
|||||||
|
|
||||||
return [];
|
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,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|||||||
8
server/providers/gemini/index.js
Normal file
8
server/providers/gemini/index.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Gemini provider barrel.
|
||||||
|
* Assembles the ProviderAdapter from adapter + sessions.
|
||||||
|
*/
|
||||||
|
import { normalizeMessage } from './adapter.js';
|
||||||
|
import { fetchHistory } from './sessions.js';
|
||||||
|
|
||||||
|
export const geminiAdapter = { normalizeMessage, fetchHistory };
|
||||||
121
server/providers/gemini/sessions.js
Normal file
121
server/providers/gemini/sessions.js
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
/**
|
||||||
|
* Gemini session history fetcher.
|
||||||
|
*
|
||||||
|
* Extracted from adapter.js — pure data-access concern.
|
||||||
|
* @module providers/gemini/sessions
|
||||||
|
*/
|
||||||
|
|
||||||
|
import sessionManager from '../../sessionManager.js';
|
||||||
|
import { getGeminiCliSessionMessages } from '../../projects.js';
|
||||||
|
import { createNormalizedMessage, generateMessageId } from '../types.js';
|
||||||
|
|
||||||
|
const PROVIDER = 'gemini';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch session history for Gemini.
|
||||||
|
* First tries in-memory session manager, then falls back to CLI sessions on disk.
|
||||||
|
* @param {string} sessionId
|
||||||
|
* @param {object} opts
|
||||||
|
* @returns {Promise<{messages: import('../types.js').NormalizedMessage[], total: number, hasMore: boolean, offset: number, limit: number|null}>}
|
||||||
|
*/
|
||||||
|
export async function 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,
|
||||||
|
};
|
||||||
|
}
|
||||||
111
server/providers/gemini/status.js
Normal file
111
server/providers/gemini/status.js
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/**
|
||||||
|
* Gemini Provider Status
|
||||||
|
*
|
||||||
|
* Checks whether Gemini CLI is installed and whether the user
|
||||||
|
* has valid authentication credentials.
|
||||||
|
*
|
||||||
|
* @module providers/gemini/status
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { execFileSync } from 'child_process';
|
||||||
|
import { promises as fs } from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Gemini CLI is installed.
|
||||||
|
* Uses GEMINI_PATH env var if set, otherwise looks for 'gemini' in PATH.
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export function checkInstalled() {
|
||||||
|
const cliPath = process.env.GEMINI_PATH || 'gemini';
|
||||||
|
try {
|
||||||
|
execFileSync(cliPath, ['--version'], { stdio: 'ignore', timeout: 5000 });
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full status check: installation + authentication.
|
||||||
|
* @returns {Promise<import('../types.js').ProviderStatus>}
|
||||||
|
*/
|
||||||
|
export async function checkStatus() {
|
||||||
|
const installed = checkInstalled();
|
||||||
|
|
||||||
|
if (!installed) {
|
||||||
|
return {
|
||||||
|
installed,
|
||||||
|
authenticated: false,
|
||||||
|
email: null,
|
||||||
|
error: 'Gemini CLI is not installed'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await checkCredentials();
|
||||||
|
|
||||||
|
return {
|
||||||
|
installed,
|
||||||
|
authenticated: result.authenticated,
|
||||||
|
email: result.email || null,
|
||||||
|
error: result.error || null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Internal helpers ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
async function checkCredentials() {
|
||||||
|
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 {
|
||||||
|
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) {
|
||||||
|
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
|
||||||
|
email = await getActiveAccountEmail() || email;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Network error, fallback to checking local accounts file
|
||||||
|
email = await getActiveAccountEmail() || email;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { authenticated: true, email };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { authenticated: false, email: null, error: 'No valid tokens found in oauth_creds' };
|
||||||
|
} catch {
|
||||||
|
return { authenticated: false, email: null, error: 'Gemini CLI not configured' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getActiveAccountEmail() {
|
||||||
|
try {
|
||||||
|
const accPath = path.join(os.homedir(), '.gemini', 'google_accounts.json');
|
||||||
|
const accContent = await fs.readFile(accPath, 'utf8');
|
||||||
|
const accounts = JSON.parse(accContent);
|
||||||
|
return accounts.active || null;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* Provider Registry
|
* Provider Registry
|
||||||
*
|
*
|
||||||
* Centralizes provider adapter lookup. All code that needs a provider adapter
|
* Centralizes provider adapter and status checker lookup. All code that needs
|
||||||
* should go through this registry instead of importing individual adapters directly.
|
* a provider adapter or status checker should go through this registry instead
|
||||||
|
* of importing individual modules directly.
|
||||||
*
|
*
|
||||||
* @module providers/registry
|
* @module providers/registry
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { claudeAdapter } from './claude/adapter.js';
|
import { claudeAdapter } from './claude/index.js';
|
||||||
import { cursorAdapter } from './cursor/adapter.js';
|
import { cursorAdapter } from './cursor/index.js';
|
||||||
import { codexAdapter } from './codex/adapter.js';
|
import { codexAdapter } from './codex/index.js';
|
||||||
import { geminiAdapter } from './gemini/adapter.js';
|
import { geminiAdapter } from './gemini/index.js';
|
||||||
|
|
||||||
|
import * as claudeStatus from './claude/status.js';
|
||||||
|
import * as cursorStatus from './cursor/status.js';
|
||||||
|
import * as codexStatus from './codex/status.js';
|
||||||
|
import * as geminiStatus from './gemini/status.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('./types.js').ProviderAdapter} ProviderAdapter
|
* @typedef {import('./types.js').ProviderAdapter} ProviderAdapter
|
||||||
@@ -20,12 +26,20 @@ import { geminiAdapter } from './gemini/adapter.js';
|
|||||||
/** @type {Map<string, ProviderAdapter>} */
|
/** @type {Map<string, ProviderAdapter>} */
|
||||||
const providers = new Map();
|
const providers = new Map();
|
||||||
|
|
||||||
|
/** @type {Map<string, { checkInstalled: () => boolean, checkStatus: () => Promise<import('./types.js').ProviderStatus> }>} */
|
||||||
|
const statusCheckers = new Map();
|
||||||
|
|
||||||
// Register built-in providers
|
// Register built-in providers
|
||||||
providers.set('claude', claudeAdapter);
|
providers.set('claude', claudeAdapter);
|
||||||
providers.set('cursor', cursorAdapter);
|
providers.set('cursor', cursorAdapter);
|
||||||
providers.set('codex', codexAdapter);
|
providers.set('codex', codexAdapter);
|
||||||
providers.set('gemini', geminiAdapter);
|
providers.set('gemini', geminiAdapter);
|
||||||
|
|
||||||
|
statusCheckers.set('claude', claudeStatus);
|
||||||
|
statusCheckers.set('cursor', cursorStatus);
|
||||||
|
statusCheckers.set('codex', codexStatus);
|
||||||
|
statusCheckers.set('gemini', geminiStatus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a provider adapter by name.
|
* Get a provider adapter by name.
|
||||||
* @param {string} name - Provider name (e.g., 'claude', 'cursor', 'codex', 'gemini')
|
* @param {string} name - Provider name (e.g., 'claude', 'cursor', 'codex', 'gemini')
|
||||||
@@ -35,6 +49,15 @@ export function getProvider(name) {
|
|||||||
return providers.get(name);
|
return providers.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a provider status checker by name.
|
||||||
|
* @param {string} name - Provider name
|
||||||
|
* @returns {{ checkInstalled: () => boolean, checkStatus: () => Promise<import('./types.js').ProviderStatus> } | undefined}
|
||||||
|
*/
|
||||||
|
export function getStatusChecker(name) {
|
||||||
|
return statusCheckers.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all registered provider names.
|
* Get all registered provider names.
|
||||||
* @returns {string[]}
|
* @returns {string[]}
|
||||||
|
|||||||
@@ -69,6 +69,19 @@
|
|||||||
* @property {object} [tokenUsage] - Token usage data (provider-specific)
|
* @property {object} [tokenUsage] - Token usage data (provider-specific)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// ─── Provider Status ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result of a provider status check (installation + authentication).
|
||||||
|
*
|
||||||
|
* @typedef {Object} ProviderStatus
|
||||||
|
* @property {boolean} installed - Whether the provider's CLI/SDK is available
|
||||||
|
* @property {boolean} authenticated - Whether valid credentials exist
|
||||||
|
* @property {string|null} email - User email or auth method identifier
|
||||||
|
* @property {string|null} [method] - Auth method (e.g. 'api_key', 'credentials_file')
|
||||||
|
* @property {string|null} [error] - Error message if not installed or not authenticated
|
||||||
|
*/
|
||||||
|
|
||||||
// ─── Provider Adapter Interface ──────────────────────────────────────────────
|
// ─── Provider Adapter Interface ──────────────────────────────────────────────
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -475,6 +475,7 @@ class SSEStreamWriter {
|
|||||||
|
|
||||||
setSessionId(sessionId) {
|
setSessionId(sessionId) {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
|
this.send({ type: 'session-id', sessionId });
|
||||||
}
|
}
|
||||||
|
|
||||||
getSessionId() {
|
getSessionId() {
|
||||||
@@ -839,7 +840,7 @@ class ResponseCollector {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
router.post('/', validateExternalApiKey, async (req, res) => {
|
router.post('/', validateExternalApiKey, async (req, res) => {
|
||||||
const { githubUrl, projectPath, message, provider = 'claude', model, githubToken, branchName } = req.body;
|
const { githubUrl, projectPath, message, provider = 'claude', model, githubToken, branchName, sessionId } = 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');
|
||||||
@@ -949,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: null, // New session
|
sessionId: sessionId || null,
|
||||||
model: model,
|
model: model,
|
||||||
permissionMode: 'bypassPermissions' // Bypass all permissions for API calls
|
permissionMode: 'bypassPermissions' // Bypass all permissions for API calls
|
||||||
}, writer);
|
}, writer);
|
||||||
@@ -960,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: null, // New session
|
sessionId: sessionId || null,
|
||||||
model: model || undefined,
|
model: model || undefined,
|
||||||
skipPermissions: true // Bypass permissions for Cursor
|
skipPermissions: true // Bypass permissions for Cursor
|
||||||
}, writer);
|
}, writer);
|
||||||
@@ -970,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: null,
|
sessionId: sessionId || null,
|
||||||
model: model || CODEX_MODELS.DEFAULT,
|
model: model || CODEX_MODELS.DEFAULT,
|
||||||
permissionMode: 'bypassPermissions'
|
permissionMode: 'bypassPermissions'
|
||||||
}, writer);
|
}, writer);
|
||||||
@@ -980,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: null,
|
sessionId: sessionId || null,
|
||||||
model: model,
|
model: model,
|
||||||
skipPermissions: true // CLI mode bypasses permissions
|
skipPermissions: true // CLI mode bypasses permissions
|
||||||
}, writer);
|
}, writer);
|
||||||
@@ -1124,7 +1125,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 Claude Code UI Agent.*';
|
prBody += '\n\n---\n*This pull request was automatically created by CloudCLI.ai Agent.*';
|
||||||
|
|
||||||
console.log(`📝 PR Title: ${prTitle}`);
|
console.log(`📝 PR Title: ${prTitle}`);
|
||||||
|
|
||||||
|
|||||||
@@ -1,434 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* CLI Auth Routes
|
||||||
|
*
|
||||||
|
* Thin router that delegates to per-provider status checkers
|
||||||
|
* registered in the provider registry.
|
||||||
|
*
|
||||||
|
* @module routes/cli-auth
|
||||||
|
*/
|
||||||
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { spawn } from 'child_process';
|
import { getAllProviders, getStatusChecker } from '../providers/registry.js';
|
||||||
import fs from 'fs/promises';
|
|
||||||
import path from 'path';
|
|
||||||
import os from 'os';
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.get('/claude/status', async (req, res) => {
|
for (const provider of getAllProviders()) {
|
||||||
|
router.get(`/${provider}/status`, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const credentialsResult = await checkClaudeCredentials();
|
const checker = getStatusChecker(provider);
|
||||||
|
res.json(await checker.checkStatus());
|
||||||
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) {
|
} catch (error) {
|
||||||
console.error('Error checking Claude auth status:', error);
|
console.error(`Error checking ${provider} status:`, error);
|
||||||
res.status(500).json({
|
res.status(500).json({ authenticated: false, error: error.message });
|
||||||
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;
|
export default router;
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
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 __filename = fileURLToPath(import.meta.url);
|
const __dirname = getModuleDir(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
// This route reads the top-level package.json for the status command, so it needs the real
|
||||||
|
// 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();
|
||||||
|
|
||||||
@@ -291,7 +293,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(path.dirname(__dirname), '..', 'package.json');
|
const packageJsonPath = path.join(APP_ROOT, 'package.json');
|
||||||
let version = 'unknown';
|
let version = 'unknown';
|
||||||
let packageName = 'claude-code-ui';
|
let packageName = 'claude-code-ui';
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ 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 Database from 'better-sqlite3';
|
||||||
import sqlite3 from 'sqlite3';
|
|
||||||
import { open } from 'sqlite';
|
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { CURSOR_MODELS } from '../../shared/modelConstants.js';
|
import { CURSOR_MODELS } from '../../shared/modelConstants.js';
|
||||||
import { applyCustomSessionNames } from '../database/db.js';
|
import { applyCustomSessionNames } from '../database/db.js';
|
||||||
@@ -387,16 +385,10 @@ router.get('/sessions', async (req, res) => {
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
||||||
// Open SQLite database
|
// Open SQLite database
|
||||||
const db = await open({
|
const db = new Database(storeDbPath, { readonly: true, fileMustExist: true });
|
||||||
filename: storeDbPath,
|
|
||||||
driver: sqlite3.Database,
|
|
||||||
mode: sqlite3.OPEN_READONLY
|
|
||||||
});
|
|
||||||
|
|
||||||
// Get metadata from meta table
|
// Get metadata from meta table
|
||||||
const metaRows = await db.all(`
|
const metaRows = db.prepare('SELECT key, value FROM meta').all();
|
||||||
SELECT key, value FROM meta
|
|
||||||
`);
|
|
||||||
|
|
||||||
let sessionData = {
|
let sessionData = {
|
||||||
id: sessionId,
|
id: sessionId,
|
||||||
@@ -458,20 +450,11 @@ router.get('/sessions', async (req, res) => {
|
|||||||
|
|
||||||
// Get message count from JSON blobs only (actual messages, not DAG structure)
|
// Get message count from JSON blobs only (actual messages, not DAG structure)
|
||||||
try {
|
try {
|
||||||
const blobCount = await db.get(`
|
const blobCount = db.prepare(`SELECT COUNT(*) as count FROM blobs WHERE substr(data, 1, 1) = X'7B'`).get();
|
||||||
SELECT COUNT(*) as count
|
|
||||||
FROM blobs
|
|
||||||
WHERE substr(data, 1, 1) = X'7B'
|
|
||||||
`);
|
|
||||||
sessionData.messageCount = blobCount.count;
|
sessionData.messageCount = blobCount.count;
|
||||||
|
|
||||||
// Get the most recent JSON blob for preview (actual message, not DAG structure)
|
// Get the most recent JSON blob for preview (actual message, not DAG structure)
|
||||||
const lastBlob = await db.get(`
|
const lastBlob = db.prepare(`SELECT data FROM blobs WHERE substr(data, 1, 1) = X'7B' ORDER BY rowid DESC LIMIT 1`).get();
|
||||||
SELECT data FROM blobs
|
|
||||||
WHERE substr(data, 1, 1) = X'7B'
|
|
||||||
ORDER BY rowid DESC
|
|
||||||
LIMIT 1
|
|
||||||
`);
|
|
||||||
|
|
||||||
if (lastBlob && lastBlob.data) {
|
if (lastBlob && lastBlob.data) {
|
||||||
try {
|
try {
|
||||||
@@ -526,7 +509,7 @@ router.get('/sessions', async (req, res) => {
|
|||||||
console.log('Could not read blobs:', e.message);
|
console.log('Could not read blobs:', e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.close();
|
db.close();
|
||||||
|
|
||||||
// Finalize createdAt: use parsed meta value when valid, else fall back to store.db mtime
|
// Finalize createdAt: use parsed meta value when valid, else fall back to store.db mtime
|
||||||
if (!sessionData.createdAt) {
|
if (!sessionData.createdAt) {
|
||||||
@@ -578,221 +561,4 @@ router.get('/sessions', async (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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;
|
export default router;
|
||||||
@@ -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 || 'Claude Code UI',
|
title: sessionName || 'CloudCLI',
|
||||||
body: `${providerLabel}: ${message}`,
|
body: `${providerLabel}: ${message}`,
|
||||||
data: {
|
data: {
|
||||||
sessionId: event.sessionId || null,
|
sessionId: event.sessionId || null,
|
||||||
|
|||||||
33
server/tsconfig.json
Normal file
33
server/tsconfig.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"lib": ["ES2022"],
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
// In the backend config, "@" maps to the /server directory itself.
|
||||||
|
"@/*": ["*"]
|
||||||
|
},
|
||||||
|
// The backend is still mostly JavaScript today, so allowJs lets us add a real
|
||||||
|
// TypeScript build without forcing a large rename before the tooling is usable.
|
||||||
|
"allowJs": true,
|
||||||
|
// Keep the migration incremental: existing JS keeps building, while any new TS files
|
||||||
|
// still go through the normal TypeScript pipeline and strict checks.
|
||||||
|
"checkJs": false,
|
||||||
|
"strict": true,
|
||||||
|
"noEmitOnError": true,
|
||||||
|
// The backend build emits both /server and /shared into dist-server, so rootDir must
|
||||||
|
// stay one level above this file even though the config itself now lives in /server.
|
||||||
|
"rootDir": "..",
|
||||||
|
"outDir": "../dist-server",
|
||||||
|
"sourceMap": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"types": ["node"]
|
||||||
|
},
|
||||||
|
"include": ["./**/*.js", "./**/*.ts", "../shared/**/*.js", "../shared/**/*.ts"],
|
||||||
|
"exclude": ["../dist", "../dist-server", "../node_modules", "../src"]
|
||||||
|
}
|
||||||
21
server/utils/colors.js
Normal file
21
server/utils/colors.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// ANSI color codes for terminal output
|
||||||
|
const colors = {
|
||||||
|
reset: '\x1b[0m',
|
||||||
|
bright: '\x1b[1m',
|
||||||
|
cyan: '\x1b[36m',
|
||||||
|
green: '\x1b[32m',
|
||||||
|
yellow: '\x1b[33m',
|
||||||
|
blue: '\x1b[34m',
|
||||||
|
dim: '\x1b[2m',
|
||||||
|
};
|
||||||
|
|
||||||
|
const c = {
|
||||||
|
info: (text) => `${colors.cyan}${text}${colors.reset}`,
|
||||||
|
ok: (text) => `${colors.green}${text}${colors.reset}`,
|
||||||
|
warn: (text) => `${colors.yellow}${text}${colors.reset}`,
|
||||||
|
tip: (text) => `${colors.blue}${text}${colors.reset}`,
|
||||||
|
bright: (text) => `${colors.bright}${text}${colors.reset}`,
|
||||||
|
dim: (text) => `${colors.dim}${text}${colors.reset}`,
|
||||||
|
};
|
||||||
|
|
||||||
|
export { colors, c };
|
||||||
37
server/utils/runtime-paths.js
Normal file
37
server/utils/runtime-paths.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
export function getModuleDir(importMetaUrl) {
|
||||||
|
return path.dirname(fileURLToPath(importMetaUrl));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findServerRoot(startDir) {
|
||||||
|
// Source files live under /server, while compiled files live under /dist-server/server.
|
||||||
|
// Walking up to the nearest "server" folder gives every backend module one stable anchor
|
||||||
|
// that works in both layouts instead of relying on fragile "../.." assumptions.
|
||||||
|
let currentDir = startDir;
|
||||||
|
|
||||||
|
while (path.basename(currentDir) !== 'server') {
|
||||||
|
const parentDir = path.dirname(currentDir);
|
||||||
|
|
||||||
|
if (parentDir === currentDir) {
|
||||||
|
throw new Error(`Could not resolve the backend server root from "${startDir}".`);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentDir = parentDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findAppRoot(startDir) {
|
||||||
|
const serverRoot = findServerRoot(startDir);
|
||||||
|
const parentOfServerRoot = path.dirname(serverRoot);
|
||||||
|
|
||||||
|
// Source files live at <app>/server, while compiled files live at <app>/dist-server/server.
|
||||||
|
// When the nearest server folder sits inside dist-server we need to hop one extra level up
|
||||||
|
// so repo-level files still resolve from the real app root instead of the build directory.
|
||||||
|
return path.basename(parentOfServerRoot) === 'dist-server'
|
||||||
|
? path.dirname(parentOfServerRoot)
|
||||||
|
: parentOfServerRoot;
|
||||||
|
}
|
||||||
71
server/utils/url-detection.js
Normal file
71
server/utils/url-detection.js
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
const ANSI_ESCAPE_SEQUENCE_REGEX = /\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/g;
|
||||||
|
const TRAILING_URL_PUNCTUATION_REGEX = /[)\]}>.,;:!?]+$/;
|
||||||
|
|
||||||
|
function stripAnsiSequences(value = '') {
|
||||||
|
return value.replace(ANSI_ESCAPE_SEQUENCE_REGEX, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeDetectedUrl(url) {
|
||||||
|
if (!url || typeof url !== 'string') return null;
|
||||||
|
|
||||||
|
const cleaned = url.trim().replace(TRAILING_URL_PUNCTUATION_REGEX, '');
|
||||||
|
if (!cleaned) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const parsed = new URL(cleaned);
|
||||||
|
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return parsed.toString();
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractUrlsFromText(value = '') {
|
||||||
|
const directMatches = value.match(/https?:\/\/[^\s<>"'`\\\x1b\x07]+/gi) || [];
|
||||||
|
|
||||||
|
// Handle wrapped terminal URLs split across lines by terminal width.
|
||||||
|
const wrappedMatches = [];
|
||||||
|
const continuationRegex = /^[A-Za-z0-9\-._~:/?#\[\]@!$&'()*+,;=%]+$/;
|
||||||
|
const lines = value.split(/\r?\n/);
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
const line = lines[i].trim();
|
||||||
|
const startMatch = line.match(/https?:\/\/[^\s<>"'`\\\x1b\x07]+/i);
|
||||||
|
if (!startMatch) continue;
|
||||||
|
|
||||||
|
let combined = startMatch[0];
|
||||||
|
let j = i + 1;
|
||||||
|
while (j < lines.length) {
|
||||||
|
const continuation = lines[j].trim();
|
||||||
|
if (!continuation) break;
|
||||||
|
if (!continuationRegex.test(continuation)) break;
|
||||||
|
combined += continuation;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
wrappedMatches.push(combined.replace(/\r?\n\s*/g, ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Array.from(new Set([...directMatches, ...wrappedMatches]));
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldAutoOpenUrlFromOutput(value = '') {
|
||||||
|
const normalized = value.toLowerCase();
|
||||||
|
return (
|
||||||
|
normalized.includes('browser didn\'t open') ||
|
||||||
|
normalized.includes('open this url') ||
|
||||||
|
normalized.includes('continue in your browser') ||
|
||||||
|
normalized.includes('press enter to open') ||
|
||||||
|
normalized.includes('open_url:')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
ANSI_ESCAPE_SEQUENCE_REGEX,
|
||||||
|
TRAILING_URL_PUNCTUATION_REGEX,
|
||||||
|
stripAnsiSequences,
|
||||||
|
normalizeDetectedUrl,
|
||||||
|
extractUrlsFromText,
|
||||||
|
shouldAutoOpenUrlFromOutput
|
||||||
|
};
|
||||||
@@ -18,9 +18,10 @@ export const CLAUDE_MODELS = {
|
|||||||
{ value: "haiku", label: "Haiku" },
|
{ value: "haiku", label: "Haiku" },
|
||||||
{ value: "opusplan", label: "Opus Plan" },
|
{ value: "opusplan", label: "Opus Plan" },
|
||||||
{ value: "sonnet[1m]", label: "Sonnet [1M]" },
|
{ value: "sonnet[1m]", label: "Sonnet [1M]" },
|
||||||
|
{ value: "opus[1m]", label: "Opus [1M]" },
|
||||||
],
|
],
|
||||||
|
|
||||||
DEFAULT: "sonnet",
|
DEFAULT: "opus",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,6 +59,7 @@ export const CURSOR_MODELS = {
|
|||||||
export const CODEX_MODELS = {
|
export const CODEX_MODELS = {
|
||||||
OPTIONS: [
|
OPTIONS: [
|
||||||
{ value: "gpt-5.4", label: "GPT-5.4" },
|
{ value: "gpt-5.4", label: "GPT-5.4" },
|
||||||
|
{ value: "gpt-5.4-mini", label: "GPT-5.4 mini" },
|
||||||
{ value: "gpt-5.3-codex", label: "GPT-5.3 Codex" },
|
{ value: "gpt-5.3-codex", label: "GPT-5.3 Codex" },
|
||||||
{ value: "gpt-5.2-codex", label: "GPT-5.2 Codex" },
|
{ value: "gpt-5.2-codex", label: "GPT-5.2 Codex" },
|
||||||
{ value: "gpt-5.2", label: "GPT-5.2" },
|
{ value: "gpt-5.2", label: "GPT-5.2" },
|
||||||
@@ -88,5 +90,5 @@ export const GEMINI_MODELS = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
DEFAULT: "gemini-2.5-flash",
|
DEFAULT: "gemini-3.1-pro-preview",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { useWebSocket } from '../../contexts/WebSocketContext';
|
|||||||
import { useDeviceSettings } from '../../hooks/useDeviceSettings';
|
import { useDeviceSettings } from '../../hooks/useDeviceSettings';
|
||||||
import { useSessionProtection } from '../../hooks/useSessionProtection';
|
import { useSessionProtection } from '../../hooks/useSessionProtection';
|
||||||
import { useProjectsState } from '../../hooks/useProjectsState';
|
import { useProjectsState } from '../../hooks/useProjectsState';
|
||||||
import MobileNav from './MobileNav';
|
|
||||||
|
|
||||||
export default function AppContent() {
|
export default function AppContent() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -33,7 +32,6 @@ export default function AppContent() {
|
|||||||
activeTab,
|
activeTab,
|
||||||
sidebarOpen,
|
sidebarOpen,
|
||||||
isLoadingProjects,
|
isLoadingProjects,
|
||||||
isInputFocused,
|
|
||||||
externalMessageUpdate,
|
externalMessageUpdate,
|
||||||
setActiveTab,
|
setActiveTab,
|
||||||
setSidebarOpen,
|
setSidebarOpen,
|
||||||
@@ -159,7 +157,7 @@ export default function AppContent() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className={`flex min-w-0 flex-1 flex-col ${isMobile ? 'pb-mobile-nav' : ''}`}>
|
<div className="flex min-w-0 flex-1 flex-col">
|
||||||
<MainContent
|
<MainContent
|
||||||
selectedProject={selectedProject}
|
selectedProject={selectedProject}
|
||||||
selectedSession={selectedSession}
|
selectedSession={selectedSession}
|
||||||
@@ -184,14 +182,6 @@ export default function AppContent() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isMobile && (
|
|
||||||
<MobileNav
|
|
||||||
activeTab={activeTab}
|
|
||||||
setActiveTab={setActiveTab}
|
|
||||||
isInputFocused={isInputFocused}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,179 +0,0 @@
|
|||||||
import { useState, useRef, useEffect, type Dispatch, type SetStateAction } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import {
|
|
||||||
MessageSquare,
|
|
||||||
Folder,
|
|
||||||
Terminal,
|
|
||||||
GitBranch,
|
|
||||||
ClipboardCheck,
|
|
||||||
Ellipsis,
|
|
||||||
Puzzle,
|
|
||||||
Box,
|
|
||||||
Database,
|
|
||||||
Globe,
|
|
||||||
Wrench,
|
|
||||||
Zap,
|
|
||||||
BarChart3,
|
|
||||||
type LucideIcon,
|
|
||||||
} from 'lucide-react';
|
|
||||||
import { useTasksSettings } from '../../contexts/TasksSettingsContext';
|
|
||||||
import { usePlugins } from '../../contexts/PluginsContext';
|
|
||||||
import { AppTab } from '../../types/app';
|
|
||||||
|
|
||||||
const PLUGIN_ICON_MAP: Record<string, LucideIcon> = {
|
|
||||||
Puzzle, Box, Database, Globe, Terminal, Wrench, Zap, BarChart3, Folder, MessageSquare, GitBranch,
|
|
||||||
};
|
|
||||||
|
|
||||||
type CoreTabId = Exclude<AppTab, `plugin:${string}` | 'preview'>;
|
|
||||||
type CoreNavItem = {
|
|
||||||
id: CoreTabId;
|
|
||||||
icon: LucideIcon;
|
|
||||||
label: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type MobileNavProps = {
|
|
||||||
activeTab: AppTab;
|
|
||||||
setActiveTab: Dispatch<SetStateAction<AppTab>>;
|
|
||||||
isInputFocused: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function MobileNav({ activeTab, setActiveTab, isInputFocused }: MobileNavProps) {
|
|
||||||
const { t } = useTranslation(['common', 'settings']);
|
|
||||||
const { tasksEnabled, isTaskMasterInstalled } = useTasksSettings();
|
|
||||||
const shouldShowTasksTab = Boolean(tasksEnabled && isTaskMasterInstalled);
|
|
||||||
const { plugins } = usePlugins();
|
|
||||||
const [moreOpen, setMoreOpen] = useState(false);
|
|
||||||
const moreRef = useRef<HTMLDivElement | null>(null);
|
|
||||||
|
|
||||||
const enabledPlugins = plugins.filter((p) => p.enabled);
|
|
||||||
const hasPlugins = enabledPlugins.length > 0;
|
|
||||||
const isPluginActive = activeTab.startsWith('plugin:');
|
|
||||||
|
|
||||||
// Close the menu on outside tap
|
|
||||||
useEffect(() => {
|
|
||||||
if (!moreOpen) return;
|
|
||||||
const handleTap = (e: PointerEvent) => {
|
|
||||||
const target = e.target;
|
|
||||||
if (moreRef.current && target instanceof Node && !moreRef.current.contains(target)) {
|
|
||||||
setMoreOpen(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
document.addEventListener('pointerdown', handleTap);
|
|
||||||
return () => document.removeEventListener('pointerdown', handleTap);
|
|
||||||
}, [moreOpen]);
|
|
||||||
|
|
||||||
// Close menu when a plugin tab is selected
|
|
||||||
const selectPlugin = (name: string) => {
|
|
||||||
const pluginTab = `plugin:${name}` as AppTab;
|
|
||||||
setActiveTab(pluginTab);
|
|
||||||
setMoreOpen(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const baseCoreItems: CoreNavItem[] = [
|
|
||||||
{ id: 'chat', icon: MessageSquare, label: 'Chat' },
|
|
||||||
{ id: 'shell', icon: Terminal, label: 'Shell' },
|
|
||||||
{ id: 'files', icon: Folder, label: 'Files' },
|
|
||||||
{ id: 'git', icon: GitBranch, label: 'Git' },
|
|
||||||
];
|
|
||||||
const coreItems: CoreNavItem[] = shouldShowTasksTab
|
|
||||||
? [...baseCoreItems, { id: 'tasks', icon: ClipboardCheck, label: 'Tasks' }]
|
|
||||||
: baseCoreItems;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={`fixed bottom-0 left-0 right-0 z-50 transform px-3 pb-[max(8px,env(safe-area-inset-bottom))] transition-transform duration-300 ease-in-out ${isInputFocused ? 'translate-y-full' : 'translate-y-0'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<div className="nav-glass mobile-nav-float rounded-2xl border border-border/30">
|
|
||||||
<div className="flex items-center justify-around gap-0.5 px-1 py-1.5">
|
|
||||||
{coreItems.map((item) => {
|
|
||||||
const Icon = item.icon;
|
|
||||||
const isActive = activeTab === item.id;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={item.id}
|
|
||||||
onClick={() => setActiveTab(item.id)}
|
|
||||||
onTouchStart={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
setActiveTab(item.id);
|
|
||||||
}}
|
|
||||||
className={`relative flex flex-1 touch-manipulation flex-col items-center justify-center gap-0.5 rounded-xl px-3 py-2 transition-all duration-200 active:scale-95 ${isActive
|
|
||||||
? 'text-primary'
|
|
||||||
: 'text-muted-foreground hover:text-foreground'
|
|
||||||
}`}
|
|
||||||
aria-label={item.label}
|
|
||||||
aria-current={isActive ? 'page' : undefined}
|
|
||||||
>
|
|
||||||
{isActive && (
|
|
||||||
<div className="bg-primary/8 dark:bg-primary/12 absolute inset-0 rounded-xl" />
|
|
||||||
)}
|
|
||||||
<Icon
|
|
||||||
className={`relative z-10 transition-all duration-200 ${isActive ? 'h-5 w-5' : 'h-[18px] w-[18px]'}`}
|
|
||||||
strokeWidth={isActive ? 2.4 : 1.8}
|
|
||||||
/>
|
|
||||||
<span className={`relative z-10 text-[10px] font-medium transition-all duration-200 ${isActive ? 'opacity-100' : 'opacity-60'}`}>
|
|
||||||
{item.label}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
{/* "More" button — only shown when there are enabled plugins */}
|
|
||||||
{hasPlugins && (
|
|
||||||
<div ref={moreRef} className="relative flex-1">
|
|
||||||
<button
|
|
||||||
onClick={() => setMoreOpen((v) => !v)}
|
|
||||||
onTouchStart={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
setMoreOpen((v) => !v);
|
|
||||||
}}
|
|
||||||
className={`relative flex w-full touch-manipulation flex-col items-center justify-center gap-0.5 rounded-xl px-3 py-2 transition-all duration-200 active:scale-95 ${isPluginActive || moreOpen
|
|
||||||
? 'text-primary'
|
|
||||||
: 'text-muted-foreground hover:text-foreground'
|
|
||||||
}`}
|
|
||||||
aria-label="More plugins"
|
|
||||||
aria-expanded={moreOpen}
|
|
||||||
>
|
|
||||||
{(isPluginActive && !moreOpen) && (
|
|
||||||
<div className="bg-primary/8 dark:bg-primary/12 absolute inset-0 rounded-xl" />
|
|
||||||
)}
|
|
||||||
<Ellipsis
|
|
||||||
className={`relative z-10 transition-all duration-200 ${isPluginActive ? 'h-5 w-5' : 'h-[18px] w-[18px]'}`}
|
|
||||||
strokeWidth={isPluginActive ? 2.4 : 1.8}
|
|
||||||
/>
|
|
||||||
<span className={`relative z-10 text-[10px] font-medium transition-all duration-200 ${isPluginActive || moreOpen ? 'opacity-100' : 'opacity-60'}`}>
|
|
||||||
{t('settings:pluginSettings.morePlugins')}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{/* Popover menu */}
|
|
||||||
{moreOpen && (
|
|
||||||
<div className="animate-in fade-in slide-in-from-bottom-2 absolute bottom-full right-0 z-[60] mb-2 min-w-[180px] rounded-xl border border-border/40 bg-popover py-1.5 shadow-lg duration-150">
|
|
||||||
{enabledPlugins.map((p) => {
|
|
||||||
const Icon = PLUGIN_ICON_MAP[p.icon] || Puzzle;
|
|
||||||
const isActive = activeTab === `plugin:${p.name}`;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={p.name}
|
|
||||||
onClick={() => selectPlugin(p.name)}
|
|
||||||
className={`flex w-full items-center gap-2.5 px-3.5 py-2.5 text-sm transition-colors ${isActive
|
|
||||||
? 'bg-primary/8 text-primary'
|
|
||||||
: 'text-foreground hover:bg-muted/60'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<Icon className="h-4 w-4 flex-shrink-0" strokeWidth={isActive ? 2.2 : 1.8} />
|
|
||||||
<span className="truncate">{p.displayName}</span>
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,7 @@ export default function AuthLoadingScreen() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1 className="mb-2 text-2xl font-bold text-foreground">Claude Code UI</h1>
|
<h1 className="mb-2 text-2xl font-bold text-foreground">CloudCLI</h1>
|
||||||
|
|
||||||
<div className="flex items-center justify-center space-x-2">
|
<div className="flex items-center justify-center space-x-2">
|
||||||
{loadingDotAnimationDelays.map((delay) => (
|
{loadingDotAnimationDelays.map((delay) => (
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { MessageSquare } from 'lucide-react';
|
import { MessageSquare } from 'lucide-react';
|
||||||
|
import { IS_PLATFORM } from '../../../constants/config';
|
||||||
|
|
||||||
type AuthScreenLayoutProps = {
|
type AuthScreenLayoutProps = {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -37,6 +38,22 @@ export default function AuthScreenLayout({
|
|||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<p className="text-sm text-muted-foreground">{footerText}</p>
|
<p className="text-sm text-muted-foreground">{footerText}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{!IS_PLATFORM && (
|
||||||
|
<div className="flex items-center justify-center gap-1.5 pt-2">
|
||||||
|
<svg className="h-3.5 w-3.5 text-muted-foreground/50" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
||||||
|
<path d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z" />
|
||||||
|
</svg>
|
||||||
|
<a
|
||||||
|
href="https://github.com/siteboon/claudecodeui"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="text-xs text-muted-foreground/50 transition-colors hover:text-muted-foreground"
|
||||||
|
>
|
||||||
|
CloudCLI is open source
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export default function LoginForm() {
|
|||||||
<AuthScreenLayout
|
<AuthScreenLayout
|
||||||
title={t('login.title')}
|
title={t('login.title')}
|
||||||
description={t('login.description')}
|
description={t('login.description')}
|
||||||
footerText="Enter your credentials to access Claude Code UI"
|
footerText="Enter your credentials to access CloudCLI"
|
||||||
>
|
>
|
||||||
<form onSubmit={handleSubmit} className="space-y-4">
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
<AuthInputField
|
<AuthInputField
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export default function SetupForm() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthScreenLayout
|
<AuthScreenLayout
|
||||||
title="Welcome to Claude Code UI"
|
title="Welcome to CloudCLI"
|
||||||
description="Set up your account to get started"
|
description="Set up your account to get started"
|
||||||
footerText="This is a single-user system. Only one account can be created."
|
footerText="This is a single-user system. Only one account can be created."
|
||||||
logo={<img src="/logo.svg" alt="CloudCLI" className="h-16 w-16" />}
|
logo={<img src="/logo.svg" alt="CloudCLI" className="h-16 w-16" />}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import type {
|
|||||||
PendingPermissionRequest,
|
PendingPermissionRequest,
|
||||||
PermissionMode,
|
PermissionMode,
|
||||||
} from '../types/types';
|
} from '../types/types';
|
||||||
import type { Project, ProjectSession, SessionProvider } from '../../../types/app';
|
import type { Project, ProjectSession, LLMProvider } from '../../../types/app';
|
||||||
import { escapeRegExp } from '../utils/chatFormatting';
|
import { escapeRegExp } from '../utils/chatFormatting';
|
||||||
import { useFileMentions } from './useFileMentions';
|
import { useFileMentions } from './useFileMentions';
|
||||||
import { type SlashCommand, useSlashCommands } from './useSlashCommands';
|
import { type SlashCommand, useSlashCommands } from './useSlashCommands';
|
||||||
@@ -33,7 +33,7 @@ interface UseChatComposerStateArgs {
|
|||||||
selectedProject: Project | null;
|
selectedProject: Project | null;
|
||||||
selectedSession: ProjectSession | null;
|
selectedSession: ProjectSession | null;
|
||||||
currentSessionId: string | null;
|
currentSessionId: string | null;
|
||||||
provider: SessionProvider;
|
provider: LLMProvider;
|
||||||
permissionMode: PermissionMode | string;
|
permissionMode: PermissionMode | string;
|
||||||
cyclePermissionMode: () => void;
|
cyclePermissionMode: () => void;
|
||||||
cursorModel: string;
|
cursorModel: string;
|
||||||
@@ -878,30 +878,6 @@ export function useChatComposerState({
|
|||||||
});
|
});
|
||||||
}, [canAbortSession, currentSessionId, pendingViewSessionRef, provider, selectedSession?.id, sendMessage]);
|
}, [canAbortSession, currentSessionId, pendingViewSessionRef, provider, selectedSession?.id, sendMessage]);
|
||||||
|
|
||||||
const handleTranscript = useCallback((text: string) => {
|
|
||||||
if (!text.trim()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setInput((previousInput) => {
|
|
||||||
const newInput = previousInput.trim() ? `${previousInput} ${text}` : text;
|
|
||||||
inputValueRef.current = newInput;
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
if (!textareaRef.current) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
textareaRef.current.style.height = 'auto';
|
|
||||||
textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;
|
|
||||||
const lineHeight = parseInt(window.getComputedStyle(textareaRef.current).lineHeight);
|
|
||||||
setIsTextareaExpanded(textareaRef.current.scrollHeight > lineHeight * 2);
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
return newInput;
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleGrantToolPermission = useCallback(
|
const handleGrantToolPermission = useCallback(
|
||||||
(suggestion: { entry: string; toolName: string }) => {
|
(suggestion: { entry: string; toolName: string }) => {
|
||||||
if (!suggestion || provider !== 'claude') {
|
if (!suggestion || provider !== 'claude') {
|
||||||
@@ -994,7 +970,6 @@ export function useChatComposerState({
|
|||||||
syncInputOverlayScroll,
|
syncInputOverlayScroll,
|
||||||
handleClearInput,
|
handleClearInput,
|
||||||
handleAbortSession,
|
handleAbortSession,
|
||||||
handleTranscript,
|
|
||||||
handlePermissionDecision,
|
handlePermissionDecision,
|
||||||
handleGrantToolPermission,
|
handleGrantToolPermission,
|
||||||
handleInputFocusChange,
|
handleInputFocusChange,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|||||||
import { authenticatedFetch } from '../../../utils/api';
|
import { authenticatedFetch } from '../../../utils/api';
|
||||||
import { CLAUDE_MODELS, CODEX_MODELS, CURSOR_MODELS, GEMINI_MODELS } from '../../../../shared/modelConstants';
|
import { CLAUDE_MODELS, CODEX_MODELS, CURSOR_MODELS, GEMINI_MODELS } from '../../../../shared/modelConstants';
|
||||||
import type { PendingPermissionRequest, PermissionMode } from '../types/types';
|
import type { PendingPermissionRequest, PermissionMode } from '../types/types';
|
||||||
import type { ProjectSession, SessionProvider } from '../../../types/app';
|
import type { ProjectSession, LLMProvider } from '../../../types/app';
|
||||||
|
|
||||||
interface UseChatProviderStateArgs {
|
interface UseChatProviderStateArgs {
|
||||||
selectedSession: ProjectSession | null;
|
selectedSession: ProjectSession | null;
|
||||||
@@ -11,8 +11,8 @@ interface UseChatProviderStateArgs {
|
|||||||
export function useChatProviderState({ selectedSession }: UseChatProviderStateArgs) {
|
export function useChatProviderState({ selectedSession }: UseChatProviderStateArgs) {
|
||||||
const [permissionMode, setPermissionMode] = useState<PermissionMode>('default');
|
const [permissionMode, setPermissionMode] = useState<PermissionMode>('default');
|
||||||
const [pendingPermissionRequests, setPendingPermissionRequests] = useState<PendingPermissionRequest[]>([]);
|
const [pendingPermissionRequests, setPendingPermissionRequests] = useState<PendingPermissionRequest[]>([]);
|
||||||
const [provider, setProvider] = useState<SessionProvider>(() => {
|
const [provider, setProvider] = useState<LLMProvider>(() => {
|
||||||
return (localStorage.getItem('selected-provider') as SessionProvider) || 'claude';
|
return (localStorage.getItem('selected-provider') as LLMProvider) || 'claude';
|
||||||
});
|
});
|
||||||
const [cursorModel, setCursorModel] = useState<string>(() => {
|
const [cursorModel, setCursorModel] = useState<string>(() => {
|
||||||
return localStorage.getItem('cursor-model') || CURSOR_MODELS.DEFAULT;
|
return localStorage.getItem('cursor-model') || CURSOR_MODELS.DEFAULT;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import type { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
import type { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
||||||
import type { PendingPermissionRequest } from '../types/types';
|
import type { PendingPermissionRequest } from '../types/types';
|
||||||
import type { Project, ProjectSession, SessionProvider } from '../../../types/app';
|
import type { Project, ProjectSession, LLMProvider } from '../../../types/app';
|
||||||
import type { SessionStore, NormalizedMessage } from '../../../stores/useSessionStore';
|
import type { SessionStore, NormalizedMessage } from '../../../stores/useSessionStore';
|
||||||
|
|
||||||
type PendingViewSession = {
|
type PendingViewSession = {
|
||||||
@@ -48,7 +48,7 @@ type LatestChatMessage = {
|
|||||||
|
|
||||||
interface UseChatRealtimeHandlersArgs {
|
interface UseChatRealtimeHandlersArgs {
|
||||||
latestMessage: LatestChatMessage | null;
|
latestMessage: LatestChatMessage | null;
|
||||||
provider: SessionProvider;
|
provider: LLMProvider;
|
||||||
selectedProject: Project | null;
|
selectedProject: Project | null;
|
||||||
selectedSession: ProjectSession | null;
|
selectedSession: ProjectSession | null;
|
||||||
currentSessionId: string | null;
|
currentSessionId: string | null;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } fr
|
|||||||
import type { MutableRefObject } from 'react';
|
import type { MutableRefObject } from 'react';
|
||||||
import { authenticatedFetch } from '../../../utils/api';
|
import { authenticatedFetch } from '../../../utils/api';
|
||||||
import type { ChatMessage, Provider } from '../types/types';
|
import type { ChatMessage, Provider } from '../types/types';
|
||||||
import type { Project, ProjectSession, SessionProvider } from '../../../types/app';
|
import type { Project, ProjectSession, LLMProvider } from '../../../types/app';
|
||||||
import { createCachedDiffCalculator, type DiffCalculator } from '../utils/messageTransforms';
|
import { createCachedDiffCalculator, type DiffCalculator } from '../utils/messageTransforms';
|
||||||
import { normalizedToChatMessages } from './useChatMessages';
|
import { normalizedToChatMessages } from './useChatMessages';
|
||||||
import type { SessionStore, NormalizedMessage } from '../../../stores/useSessionStore';
|
import type { SessionStore, NormalizedMessage } from '../../../stores/useSessionStore';
|
||||||
@@ -40,7 +40,7 @@ interface ScrollRestoreState {
|
|||||||
function chatMessageToNormalized(
|
function chatMessageToNormalized(
|
||||||
msg: ChatMessage,
|
msg: ChatMessage,
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
provider: SessionProvider,
|
provider: LLMProvider,
|
||||||
): NormalizedMessage | null {
|
): NormalizedMessage | null {
|
||||||
const id = `local_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
const id = `local_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
||||||
const ts = msg.timestamp instanceof Date
|
const ts = msg.timestamp instanceof Date
|
||||||
@@ -151,7 +151,7 @@ export function useChatSessionState({
|
|||||||
// When a real session ID arrives and we have a pending user message, flush it to the store
|
// When a real session ID arrives and we have a pending user message, flush it to the store
|
||||||
const prevActiveSessionRef = useRef<string | null>(null);
|
const prevActiveSessionRef = useRef<string | null>(null);
|
||||||
if (activeSessionId && activeSessionId !== prevActiveSessionRef.current && pendingUserMessage) {
|
if (activeSessionId && activeSessionId !== prevActiveSessionRef.current && pendingUserMessage) {
|
||||||
const prov = (localStorage.getItem('selected-provider') as SessionProvider) || 'claude';
|
const prov = (localStorage.getItem('selected-provider') as LLMProvider) || 'claude';
|
||||||
const normalized = chatMessageToNormalized(pendingUserMessage, activeSessionId, prov);
|
const normalized = chatMessageToNormalized(pendingUserMessage, activeSessionId, prov);
|
||||||
if (normalized) {
|
if (normalized) {
|
||||||
sessionStore.appendRealtime(activeSessionId, normalized);
|
sessionStore.appendRealtime(activeSessionId, normalized);
|
||||||
@@ -189,7 +189,7 @@ export function useChatSessionState({
|
|||||||
setPendingUserMessage(msg);
|
setPendingUserMessage(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const prov = (localStorage.getItem('selected-provider') as SessionProvider) || 'claude';
|
const prov = (localStorage.getItem('selected-provider') as LLMProvider) || 'claude';
|
||||||
const normalized = chatMessageToNormalized(msg, activeSessionId, prov);
|
const normalized = chatMessageToNormalized(msg, activeSessionId, prov);
|
||||||
if (normalized) {
|
if (normalized) {
|
||||||
sessionStore.appendRealtime(activeSessionId, normalized);
|
sessionStore.appendRealtime(activeSessionId, normalized);
|
||||||
@@ -240,7 +240,7 @@ export function useChatSessionState({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const slot = await sessionStore.fetchMore(selectedSession.id, {
|
const slot = await sessionStore.fetchMore(selectedSession.id, {
|
||||||
provider: sessionProvider as SessionProvider,
|
provider: sessionProvider as LLMProvider,
|
||||||
projectName: selectedProject.name,
|
projectName: selectedProject.name,
|
||||||
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
||||||
limit: MESSAGES_PER_PAGE,
|
limit: MESSAGES_PER_PAGE,
|
||||||
@@ -374,7 +374,7 @@ export function useChatSessionState({
|
|||||||
// Fetch from server → store updates → chatMessages re-derives automatically
|
// Fetch from server → store updates → chatMessages re-derives automatically
|
||||||
setIsLoadingSessionMessages(true);
|
setIsLoadingSessionMessages(true);
|
||||||
sessionStore.fetchFromServer(selectedSession.id, {
|
sessionStore.fetchFromServer(selectedSession.id, {
|
||||||
provider: (selectedSession.__provider || provider) as SessionProvider,
|
provider: (selectedSession.__provider || provider) as LLMProvider,
|
||||||
projectName: selectedProject.name,
|
projectName: selectedProject.name,
|
||||||
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
||||||
limit: MESSAGES_PER_PAGE,
|
limit: MESSAGES_PER_PAGE,
|
||||||
@@ -410,7 +410,7 @@ export function useChatSessionState({
|
|||||||
// Skip store refresh during active streaming
|
// Skip store refresh during active streaming
|
||||||
if (!isLoading) {
|
if (!isLoading) {
|
||||||
await sessionStore.refreshFromServer(selectedSession.id, {
|
await sessionStore.refreshFromServer(selectedSession.id, {
|
||||||
provider: (selectedSession.__provider || provider) as SessionProvider,
|
provider: (selectedSession.__provider || provider) as LLMProvider,
|
||||||
projectName: selectedProject.name,
|
projectName: selectedProject.name,
|
||||||
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
||||||
});
|
});
|
||||||
@@ -468,7 +468,7 @@ export function useChatSessionState({
|
|||||||
try {
|
try {
|
||||||
// Load all messages into the store for search navigation
|
// Load all messages into the store for search navigation
|
||||||
const slot = await sessionStore.fetchFromServer(selectedSession.id, {
|
const slot = await sessionStore.fetchFromServer(selectedSession.id, {
|
||||||
provider: sessionProvider as SessionProvider,
|
provider: sessionProvider as LLMProvider,
|
||||||
projectName: selectedProject.name,
|
projectName: selectedProject.name,
|
||||||
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
||||||
limit: null,
|
limit: null,
|
||||||
@@ -655,7 +655,7 @@ export function useChatSessionState({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const slot = await sessionStore.fetchFromServer(requestSessionId, {
|
const slot = await sessionStore.fetchFromServer(requestSessionId, {
|
||||||
provider: sessionProvider as SessionProvider,
|
provider: sessionProvider as LLMProvider,
|
||||||
projectName: selectedProject.name,
|
projectName: selectedProject.name,
|
||||||
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
||||||
limit: null,
|
limit: null,
|
||||||
|
|||||||
@@ -33,7 +33,12 @@ export const ToolDiffViewer: React.FC<ToolDiffViewerProps> = ({
|
|||||||
: 'bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400';
|
: 'bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400';
|
||||||
|
|
||||||
const diffLines = useMemo(
|
const diffLines = useMemo(
|
||||||
() => createDiff(oldContent, newContent),
|
() => {
|
||||||
|
if (oldContent === undefined || newContent === undefined) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return createDiff(oldContent, newContent)
|
||||||
|
},
|
||||||
[createDiff, oldContent, newContent]
|
[createDiff, oldContent, newContent]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { Project, ProjectSession, SessionProvider } from '../../../types/app';
|
import type { Project, ProjectSession, LLMProvider } from '../../../types/app';
|
||||||
|
|
||||||
export type Provider = SessionProvider;
|
export type Provider = LLMProvider;
|
||||||
|
|
||||||
export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
|
export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { useTasksSettings } from '../../../contexts/TasksSettingsContext';
|
import { useTasksSettings } from '../../../contexts/TasksSettingsContext';
|
||||||
import { QuickSettingsPanel } from '../../quick-settings-panel';
|
import { QuickSettingsPanel } from '../../quick-settings-panel';
|
||||||
import type { ChatInterfaceProps, Provider } from '../types/types';
|
import type { ChatInterfaceProps, Provider } from '../types/types';
|
||||||
import type { SessionProvider } from '../../../types/app';
|
import type { LLMProvider } from '../../../types/app';
|
||||||
import { useChatProviderState } from '../hooks/useChatProviderState';
|
import { useChatProviderState } from '../hooks/useChatProviderState';
|
||||||
import { useChatSessionState } from '../hooks/useChatSessionState';
|
import { useChatSessionState } from '../hooks/useChatSessionState';
|
||||||
import { useChatRealtimeHandlers } from '../hooks/useChatRealtimeHandlers';
|
import { useChatRealtimeHandlers } from '../hooks/useChatRealtimeHandlers';
|
||||||
@@ -165,7 +165,6 @@ function ChatInterface({
|
|||||||
syncInputOverlayScroll,
|
syncInputOverlayScroll,
|
||||||
handleClearInput,
|
handleClearInput,
|
||||||
handleAbortSession,
|
handleAbortSession,
|
||||||
handleTranscript,
|
|
||||||
handlePermissionDecision,
|
handlePermissionDecision,
|
||||||
handleGrantToolPermission,
|
handleGrantToolPermission,
|
||||||
handleInputFocusChange,
|
handleInputFocusChange,
|
||||||
@@ -207,9 +206,9 @@ function ChatInterface({
|
|||||||
// so missed streaming events are shown. Also reset isLoading.
|
// so missed streaming events are shown. Also reset isLoading.
|
||||||
const handleWebSocketReconnect = useCallback(async () => {
|
const handleWebSocketReconnect = useCallback(async () => {
|
||||||
if (!selectedProject || !selectedSession) return;
|
if (!selectedProject || !selectedSession) return;
|
||||||
const providerVal = (localStorage.getItem('selected-provider') as SessionProvider) || 'claude';
|
const providerVal = (localStorage.getItem('selected-provider') as LLMProvider) || 'claude';
|
||||||
await sessionStore.refreshFromServer(selectedSession.id, {
|
await sessionStore.refreshFromServer(selectedSession.id, {
|
||||||
provider: (selectedSession.__provider || providerVal) as SessionProvider,
|
provider: (selectedSession.__provider || providerVal) as LLMProvider,
|
||||||
projectName: selectedProject.name,
|
projectName: selectedProject.name,
|
||||||
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
projectPath: selectedProject.fullPath || selectedProject.path || '',
|
||||||
});
|
});
|
||||||
@@ -338,7 +337,6 @@ function ChatInterface({
|
|||||||
showRawParameters={showRawParameters}
|
showRawParameters={showRawParameters}
|
||||||
showThinking={showThinking}
|
showThinking={showThinking}
|
||||||
selectedProject={selectedProject}
|
selectedProject={selectedProject}
|
||||||
isLoading={isLoading}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ChatComposer
|
<ChatComposer
|
||||||
@@ -408,7 +406,6 @@ function ChatInterface({
|
|||||||
})}
|
})}
|
||||||
isTextareaExpanded={isTextareaExpanded}
|
isTextareaExpanded={isTextareaExpanded}
|
||||||
sendByCtrlEnter={sendByCtrlEnter}
|
sendByCtrlEnter={sendByCtrlEnter}
|
||||||
onTranscript={handleTranscript}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
import { SessionProvider } from '../../../../types/app';
|
|
||||||
import SessionProviderLogo from '../../../llm-logo-provider/SessionProviderLogo';
|
|
||||||
|
|
||||||
type AssistantThinkingIndicatorProps = {
|
|
||||||
selectedProvider: SessionProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export default function AssistantThinkingIndicator({ selectedProvider }: AssistantThinkingIndicatorProps) {
|
|
||||||
return (
|
|
||||||
<div className="chat-message assistant">
|
|
||||||
<div className="w-full">
|
|
||||||
<div className="mb-2 flex items-center space-x-3">
|
|
||||||
<div className="flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-transparent p-1 text-sm text-white">
|
|
||||||
<SessionProviderLogo provider={selectedProvider} className="h-full w-full" />
|
|
||||||
</div>
|
|
||||||
<div className="text-sm font-medium text-gray-900 dark:text-white">
|
|
||||||
{selectedProvider === 'cursor' ? 'Cursor' : selectedProvider === 'codex' ? 'Codex' : selectedProvider === 'gemini' ? 'Gemini' : 'Claude'}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="w-full pl-3 text-sm text-gray-500 dark:text-gray-400 sm:pl-0">
|
|
||||||
<div className="flex items-center space-x-1">
|
|
||||||
<div className="animate-pulse">.</div>
|
|
||||||
<div className="animate-pulse" style={{ animationDelay: '0.2s' }}>
|
|
||||||
.
|
|
||||||
</div>
|
|
||||||
<div className="animate-pulse" style={{ animationDelay: '0.4s' }}>
|
|
||||||
.
|
|
||||||
</div>
|
|
||||||
<span className="ml-2">Thinking...</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,6 @@ import type {
|
|||||||
SetStateAction,
|
SetStateAction,
|
||||||
TouchEvent,
|
TouchEvent,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import MicButton from '../../../mic-button/view/MicButton';
|
|
||||||
import type { PendingPermissionRequest, PermissionMode, Provider } from '../../types/types';
|
import type { PendingPermissionRequest, PermissionMode, Provider } from '../../types/types';
|
||||||
import CommandMenu from './CommandMenu';
|
import CommandMenu from './CommandMenu';
|
||||||
import ClaudeStatus from './ClaudeStatus';
|
import ClaudeStatus from './ClaudeStatus';
|
||||||
@@ -91,7 +90,6 @@ interface ChatComposerProps {
|
|||||||
placeholder: string;
|
placeholder: string;
|
||||||
isTextareaExpanded: boolean;
|
isTextareaExpanded: boolean;
|
||||||
sendByCtrlEnter?: boolean;
|
sendByCtrlEnter?: boolean;
|
||||||
onTranscript: (text: string) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ChatComposer({
|
export default function ChatComposer({
|
||||||
@@ -148,7 +146,6 @@ export default function ChatComposer({
|
|||||||
placeholder,
|
placeholder,
|
||||||
isTextareaExpanded,
|
isTextareaExpanded,
|
||||||
sendByCtrlEnter,
|
sendByCtrlEnter,
|
||||||
onTranscript,
|
|
||||||
}: ChatComposerProps) {
|
}: ChatComposerProps) {
|
||||||
const { t } = useTranslation('chat');
|
const { t } = useTranslation('chat');
|
||||||
const textareaRect = textareaRef.current?.getBoundingClientRect();
|
const textareaRect = textareaRef.current?.getBoundingClientRect();
|
||||||
@@ -163,6 +160,9 @@ export default function ChatComposer({
|
|||||||
(r) => r.toolName === 'AskUserQuestion'
|
(r) => r.toolName === 'AskUserQuestion'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Hide the thinking/status bar while any permission request is pending
|
||||||
|
const hasPendingPermissions = pendingPermissionRequests.length > 0;
|
||||||
|
|
||||||
// On mobile, when input is focused, float the input box at the bottom
|
// On mobile, when input is focused, float the input box at the bottom
|
||||||
const mobileFloatingClass = isInputFocused
|
const mobileFloatingClass = isInputFocused
|
||||||
? 'max-sm:fixed max-sm:bottom-0 max-sm:left-0 max-sm:right-0 max-sm:z-50 max-sm:bg-background max-sm:shadow-[0_-4px_20px_rgba(0,0,0,0.15)]'
|
? 'max-sm:fixed max-sm:bottom-0 max-sm:left-0 max-sm:right-0 max-sm:z-50 max-sm:bg-background max-sm:shadow-[0_-4px_20px_rgba(0,0,0,0.15)]'
|
||||||
@@ -170,7 +170,7 @@ export default function ChatComposer({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`flex-shrink-0 p-2 pb-2 sm:p-4 sm:pb-4 md:p-4 md:pb-6 ${mobileFloatingClass}`}>
|
<div className={`flex-shrink-0 p-2 pb-2 sm:p-4 sm:pb-4 md:p-4 md:pb-6 ${mobileFloatingClass}`}>
|
||||||
{!hasQuestionPanel && (
|
{!hasPendingPermissions && (
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<ClaudeStatus
|
<ClaudeStatus
|
||||||
status={claudeStatus}
|
status={claudeStatus}
|
||||||
@@ -321,10 +321,6 @@ export default function ChatComposer({
|
|||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div className="absolute right-16 top-1/2 -translate-y-1/2 transform sm:right-16" style={{ display: 'none' }}>
|
|
||||||
<MicButton onTranscript={onTranscript} className="h-10 w-10 sm:h-10 sm:w-10" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={!input.trim() || isLoading}
|
disabled={!input.trim() || isLoading}
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { useCallback, useRef } from 'react';
|
import { useCallback, useRef } from 'react';
|
||||||
import type { Dispatch, RefObject, SetStateAction } from 'react';
|
import type { Dispatch, RefObject, SetStateAction } from 'react';
|
||||||
import type { ChatMessage } from '../../types/types';
|
import type { ChatMessage } from '../../types/types';
|
||||||
import type { Project, ProjectSession, SessionProvider } from '../../../../types/app';
|
import type { Project, ProjectSession, LLMProvider } from '../../../../types/app';
|
||||||
import { getIntrinsicMessageKey } from '../../utils/messageKeys';
|
import { getIntrinsicMessageKey } from '../../utils/messageKeys';
|
||||||
import MessageComponent from './MessageComponent';
|
import MessageComponent from './MessageComponent';
|
||||||
import ProviderSelectionEmptyState from './ProviderSelectionEmptyState';
|
import ProviderSelectionEmptyState from './ProviderSelectionEmptyState';
|
||||||
import AssistantThinkingIndicator from './AssistantThinkingIndicator';
|
|
||||||
|
|
||||||
interface ChatMessagesPaneProps {
|
interface ChatMessagesPaneProps {
|
||||||
scrollContainerRef: RefObject<HTMLDivElement>;
|
scrollContainerRef: RefObject<HTMLDivElement>;
|
||||||
@@ -16,8 +15,8 @@ interface ChatMessagesPaneProps {
|
|||||||
chatMessages: ChatMessage[];
|
chatMessages: ChatMessage[];
|
||||||
selectedSession: ProjectSession | null;
|
selectedSession: ProjectSession | null;
|
||||||
currentSessionId: string | null;
|
currentSessionId: string | null;
|
||||||
provider: SessionProvider;
|
provider: LLMProvider;
|
||||||
setProvider: (provider: SessionProvider) => void;
|
setProvider: (provider: LLMProvider) => void;
|
||||||
textareaRef: RefObject<HTMLTextAreaElement>;
|
textareaRef: RefObject<HTMLTextAreaElement>;
|
||||||
claudeModel: string;
|
claudeModel: string;
|
||||||
setClaudeModel: (model: string) => void;
|
setClaudeModel: (model: string) => void;
|
||||||
@@ -51,7 +50,6 @@ interface ChatMessagesPaneProps {
|
|||||||
showRawParameters?: boolean;
|
showRawParameters?: boolean;
|
||||||
showThinking?: boolean;
|
showThinking?: boolean;
|
||||||
selectedProject: Project;
|
selectedProject: Project;
|
||||||
isLoading: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ChatMessagesPane({
|
export default function ChatMessagesPane({
|
||||||
@@ -97,7 +95,6 @@ export default function ChatMessagesPane({
|
|||||||
showRawParameters,
|
showRawParameters,
|
||||||
showThinking,
|
showThinking,
|
||||||
selectedProject,
|
selectedProject,
|
||||||
isLoading,
|
|
||||||
}: ChatMessagesPaneProps) {
|
}: ChatMessagesPaneProps) {
|
||||||
const { t } = useTranslation('chat');
|
const { t } = useTranslation('chat');
|
||||||
const messageKeyMapRef = useRef<WeakMap<ChatMessage, string>>(new WeakMap());
|
const messageKeyMapRef = useRef<WeakMap<ChatMessage, string>>(new WeakMap());
|
||||||
@@ -261,8 +258,6 @@ export default function ChatMessagesPane({
|
|||||||
})}
|
})}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isLoading && <AssistantThinkingIndicator selectedProvider={provider} />}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ const ACTION_KEYS = [
|
|||||||
'claudeStatus.actions.reasoning',
|
'claudeStatus.actions.reasoning',
|
||||||
];
|
];
|
||||||
const DEFAULT_ACTION_WORDS = ['Thinking', 'Processing', 'Analyzing', 'Working', 'Computing', 'Reasoning'];
|
const DEFAULT_ACTION_WORDS = ['Thinking', 'Processing', 'Analyzing', 'Working', 'Computing', 'Reasoning'];
|
||||||
const ANIMATION_STEPS = 40;
|
|
||||||
|
|
||||||
const PROVIDER_LABEL_KEYS: Record<string, string> = {
|
const PROVIDER_LABEL_KEYS: Record<string, string> = {
|
||||||
claude: 'messageTypes.claude',
|
claude: 'messageTypes.claude',
|
||||||
@@ -32,19 +31,10 @@ const PROVIDER_LABEL_KEYS: Record<string, string> = {
|
|||||||
gemini: 'messageTypes.gemini',
|
gemini: 'messageTypes.gemini',
|
||||||
};
|
};
|
||||||
|
|
||||||
function formatElapsedTime(totalSeconds: number, t: (key: string, options?: Record<string, unknown>) => string) {
|
function formatElapsedTime(totalSeconds: number) {
|
||||||
const minutes = Math.floor(totalSeconds / 60);
|
const mins = Math.floor(totalSeconds / 60);
|
||||||
const seconds = totalSeconds % 60;
|
const secs = totalSeconds % 60;
|
||||||
|
return mins < 1 ? `${secs}s` : `${mins}m ${secs}s`;
|
||||||
if (minutes < 1) {
|
|
||||||
return t('claudeStatus.elapsed.seconds', { count: seconds, defaultValue: '{{count}}s' });
|
|
||||||
}
|
|
||||||
|
|
||||||
return t('claudeStatus.elapsed.minutesSeconds', {
|
|
||||||
minutes,
|
|
||||||
seconds,
|
|
||||||
defaultValue: '{{minutes}}m {{seconds}}s',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ClaudeStatus({
|
export default function ClaudeStatus({
|
||||||
@@ -55,143 +45,85 @@ export default function ClaudeStatus({
|
|||||||
}: ClaudeStatusProps) {
|
}: ClaudeStatusProps) {
|
||||||
const { t } = useTranslation('chat');
|
const { t } = useTranslation('chat');
|
||||||
const [elapsedTime, setElapsedTime] = useState(0);
|
const [elapsedTime, setElapsedTime] = useState(0);
|
||||||
const [animationPhase, setAnimationPhase] = useState(0);
|
const [dots, setDots] = useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLoading) {
|
if (!isLoading) {
|
||||||
setElapsedTime(0);
|
setElapsedTime(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
const timer = setInterval(() => {
|
||||||
const timer = window.setInterval(() => {
|
setElapsedTime(Math.floor((Date.now() - startTime) / 1000));
|
||||||
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
||||||
setElapsedTime(elapsed);
|
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
const dotTimer = setInterval(() => {
|
||||||
return () => window.clearInterval(timer);
|
setDots((prev) => (prev.length >= 3 ? '' : prev + '.'));
|
||||||
}, [isLoading]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isLoading) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const timer = window.setInterval(() => {
|
|
||||||
setAnimationPhase((previous) => (previous + 1) % ANIMATION_STEPS);
|
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
return () => window.clearInterval(timer);
|
return () => {
|
||||||
|
clearInterval(timer);
|
||||||
|
clearInterval(dotTimer);
|
||||||
|
};
|
||||||
}, [isLoading]);
|
}, [isLoading]);
|
||||||
|
|
||||||
// Note: showThinking only controls the reasoning accordion in messages, not this processing indicator
|
if (!isLoading && !status) return null;
|
||||||
if (!isLoading && !status) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const actionWords = ACTION_KEYS.map((key, index) => t(key, { defaultValue: DEFAULT_ACTION_WORDS[index] }));
|
const actionWords = ACTION_KEYS.map((key, i) => t(key, { defaultValue: DEFAULT_ACTION_WORDS[i] }));
|
||||||
const actionIndex = Math.floor(elapsedTime / 3) % actionWords.length;
|
const statusText = (status?.text || actionWords[Math.floor(elapsedTime / 3) % actionWords.length]).replace(/[.]+$/, '');
|
||||||
const statusText = status?.text || actionWords[actionIndex];
|
|
||||||
const cleanStatusText = statusText.replace(/[.]+$/, '');
|
const providerLabel = t(PROVIDER_LABEL_KEYS[provider] || 'claudeStatus.providers.assistant', { defaultValue: 'Assistant' });
|
||||||
const canInterrupt = isLoading && status?.can_interrupt !== false;
|
|
||||||
const providerLabelKey = PROVIDER_LABEL_KEYS[provider];
|
|
||||||
const providerLabel = providerLabelKey
|
|
||||||
? t(providerLabelKey)
|
|
||||||
: t('claudeStatus.providers.assistant', { defaultValue: 'Assistant' });
|
|
||||||
const animatedDots = '.'.repeat((animationPhase % 3) + 1);
|
|
||||||
const elapsedLabel =
|
|
||||||
elapsedTime > 0
|
|
||||||
? t('claudeStatus.elapsed.label', {
|
|
||||||
time: formatElapsedTime(elapsedTime, t),
|
|
||||||
defaultValue: '{{time}} elapsed',
|
|
||||||
})
|
|
||||||
: t('claudeStatus.elapsed.startingNow', { defaultValue: 'Starting now' });
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="animate-in slide-in-from-bottom mb-3 w-full duration-300 sm:mb-6">
|
<div className="animate-in fade-in slide-in-from-bottom-2 mb-3 w-full duration-500">
|
||||||
<div className="relative mx-auto max-w-4xl overflow-hidden rounded-2xl border border-border/70 bg-card/90 shadow-md backdrop-blur-md">
|
<div className="mx-auto flex max-w-4xl items-center justify-between gap-3 overflow-hidden rounded-full border border-border/50 bg-slate-100 px-3 py-1.5 shadow-sm backdrop-blur-md dark:bg-slate-900">
|
||||||
<div className="pointer-events-none absolute inset-0 bg-gradient-to-r from-primary/10 via-transparent to-sky-500/10 dark:from-primary/20 dark:to-sky-400/20" />
|
|
||||||
|
|
||||||
<div className="relative px-3 py-3 sm:px-4 sm:py-3.5">
|
{/* Left Side: Identity & Status */}
|
||||||
<div className="flex flex-col gap-2.5 sm:flex-row sm:items-center sm:justify-between">
|
<div className="flex min-w-0 items-center gap-2.5">
|
||||||
<div className="flex min-w-0 items-start gap-3" role="status" aria-live="polite">
|
<div className="relative flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/20 ring-1 ring-primary/10">
|
||||||
<div className="relative mt-0.5 flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl border border-primary/25 bg-primary/10">
|
<SessionProviderLogo provider={provider} className="h-3.5 w-3.5" />
|
||||||
<SessionProviderLogo provider={provider} className="h-5 w-5" />
|
|
||||||
<span className="absolute -right-0.5 -top-0.5 flex h-2.5 w-2.5">
|
|
||||||
{isLoading && (
|
{isLoading && (
|
||||||
<span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400/70" />
|
<span className="absolute inset-0 animate-pulse rounded-full ring-2 ring-emerald-500/20" />
|
||||||
)}
|
)}
|
||||||
<span
|
|
||||||
className={cn(
|
|
||||||
'relative inline-flex h-2.5 w-2.5 rounded-full',
|
|
||||||
isLoading ? 'bg-emerald-400' : 'bg-amber-400',
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className="flex min-w-0 flex-col sm:flex-row sm:items-center sm:gap-2">
|
||||||
<div className="mb-0.5 flex items-center gap-2 text-[10px] font-semibold uppercase tracking-[0.15em] text-muted-foreground">
|
<span className="text-[10px] font-bold uppercase tracking-wider text-muted-foreground/70">
|
||||||
<span>{providerLabel}</span>
|
{providerLabel}
|
||||||
<span
|
|
||||||
className={cn(
|
|
||||||
'rounded-full px-2 py-0.5 text-[9px] tracking-[0.14em]',
|
|
||||||
isLoading
|
|
||||||
? 'bg-emerald-500/15 text-emerald-500 dark:text-emerald-400'
|
|
||||||
: 'bg-amber-500/15 text-amber-600 dark:text-amber-400',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{isLoading
|
|
||||||
? t('claudeStatus.state.live', { defaultValue: 'Live' })
|
|
||||||
: t('claudeStatus.state.paused', { defaultValue: 'Paused' })}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
<div className="flex items-center gap-1.5">
|
||||||
|
<span className={cn("h-1.5 w-1.5 rounded-full", isLoading ? "bg-emerald-500 animate-pulse" : "bg-amber-500")} />
|
||||||
<p className="truncate text-sm font-semibold text-foreground sm:text-[15px]">
|
<p className="truncate text-xs font-medium text-foreground">
|
||||||
{cleanStatusText}
|
{statusText}<span className="inline-block w-4 text-primary">{isLoading ? dots : ''}</span>
|
||||||
{isLoading && (
|
|
||||||
<span aria-hidden="true" className="text-primary">
|
|
||||||
{animatedDots}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className="mt-1 flex flex-wrap items-center gap-1.5 text-[11px] text-muted-foreground sm:text-xs">
|
|
||||||
<span
|
|
||||||
aria-hidden="true"
|
|
||||||
className="-ml-2 inline-flex items-center rounded-full border border-border/70 bg-background/60 px-2 py-0.5"
|
|
||||||
>
|
|
||||||
{elapsedLabel}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{canInterrupt && onAbort && (
|
{/* Right Side: Metrics & Actions */}
|
||||||
<div className="w-full sm:w-auto sm:text-right">
|
<div className="flex items-center gap-2">
|
||||||
|
{isLoading && status?.can_interrupt !== false && onAbort && (
|
||||||
|
<>
|
||||||
|
<div className="hidden items-center rounded-md bg-muted/50 px-2 py-0.5 text-[10px] font-medium tabular-nums text-muted-foreground sm:flex">
|
||||||
|
{formatElapsedTime(elapsedTime)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onAbort}
|
onClick={onAbort}
|
||||||
className="inline-flex w-full items-center justify-center gap-2 rounded-xl bg-destructive px-3.5 py-2 text-sm font-semibold text-destructive-foreground shadow-sm ring-1 ring-destructive/40 transition-opacity hover:opacity-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/70 active:opacity-90 sm:w-auto"
|
className="group flex items-center gap-1.5 rounded-full bg-destructive/10 px-2.5 py-1 text-[10px] font-bold text-destructive transition-all hover:bg-destructive hover:text-destructive-foreground"
|
||||||
>
|
>
|
||||||
<svg className="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<svg className="h-3 w-3 fill-current" viewBox="0 0 24 24">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
<path d="M6 6h12v12H6z" />
|
||||||
</svg>
|
</svg>
|
||||||
<span>{t('claudeStatus.controls.stopGeneration', { defaultValue: 'Stop Generation' })}</span>
|
<span className="hidden sm:inline">STOP</span>
|
||||||
<span className="rounded-md bg-black/20 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-destructive-foreground/95">
|
<kbd className="hidden rounded bg-black/10 px-1 text-[9px] group-hover:bg-white/20 sm:block">
|
||||||
Esc
|
ESC
|
||||||
</span>
|
</kbd>
|
||||||
</button>
|
</button>
|
||||||
|
</>
|
||||||
<p className="mt-1 hidden text-[11px] text-muted-foreground sm:block">
|
|
||||||
{t('claudeStatus.controls.pressEscToStop', { defaultValue: 'Press Esc anytime to stop' })}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -8,14 +8,14 @@ import {
|
|||||||
CODEX_MODELS,
|
CODEX_MODELS,
|
||||||
GEMINI_MODELS,
|
GEMINI_MODELS,
|
||||||
} from "../../../../../shared/modelConstants";
|
} from "../../../../../shared/modelConstants";
|
||||||
import type { ProjectSession, SessionProvider } from "../../../../types/app";
|
import type { ProjectSession, LLMProvider } from "../../../../types/app";
|
||||||
import { NextTaskBanner } from "../../../task-master";
|
import { NextTaskBanner } from "../../../task-master";
|
||||||
|
|
||||||
type ProviderSelectionEmptyStateProps = {
|
type ProviderSelectionEmptyStateProps = {
|
||||||
selectedSession: ProjectSession | null;
|
selectedSession: ProjectSession | null;
|
||||||
currentSessionId: string | null;
|
currentSessionId: string | null;
|
||||||
provider: SessionProvider;
|
provider: LLMProvider;
|
||||||
setProvider: (next: SessionProvider) => void;
|
setProvider: (next: LLMProvider) => void;
|
||||||
textareaRef: React.RefObject<HTMLTextAreaElement>;
|
textareaRef: React.RefObject<HTMLTextAreaElement>;
|
||||||
claudeModel: string;
|
claudeModel: string;
|
||||||
setClaudeModel: (model: string) => void;
|
setClaudeModel: (model: string) => void;
|
||||||
@@ -32,7 +32,7 @@ type ProviderSelectionEmptyStateProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type ProviderDef = {
|
type ProviderDef = {
|
||||||
id: SessionProvider;
|
id: LLMProvider;
|
||||||
name: string;
|
name: string;
|
||||||
infoKey: string;
|
infoKey: string;
|
||||||
accent: string;
|
accent: string;
|
||||||
@@ -75,7 +75,7 @@ const PROVIDERS: ProviderDef[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
function getModelConfig(p: SessionProvider) {
|
function getModelConfig(p: LLMProvider) {
|
||||||
if (p === "claude") return CLAUDE_MODELS;
|
if (p === "claude") return CLAUDE_MODELS;
|
||||||
if (p === "codex") return CODEX_MODELS;
|
if (p === "codex") return CODEX_MODELS;
|
||||||
if (p === "gemini") return GEMINI_MODELS;
|
if (p === "gemini") return GEMINI_MODELS;
|
||||||
@@ -83,7 +83,7 @@ function getModelConfig(p: SessionProvider) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getModelValue(
|
function getModelValue(
|
||||||
p: SessionProvider,
|
p: LLMProvider,
|
||||||
c: string,
|
c: string,
|
||||||
cu: string,
|
cu: string,
|
||||||
co: string,
|
co: string,
|
||||||
@@ -119,7 +119,7 @@ export default function ProviderSelectionEmptyState({
|
|||||||
defaultValue: "Start the next task",
|
defaultValue: "Start the next task",
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectProvider = (next: SessionProvider) => {
|
const selectProvider = (next: LLMProvider) => {
|
||||||
setProvider(next);
|
setProvider(next);
|
||||||
localStorage.setItem("selected-provider", next);
|
localStorage.setItem("selected-provider", next);
|
||||||
setTimeout(() => textareaRef.current?.focus(), 100);
|
setTimeout(() => textareaRef.current?.focus(), 100);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useState, useRef, useEffect } from 'react';
|
import { useState, useRef, useEffect, useCallback, type CSSProperties } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
import { Brain, X } from 'lucide-react';
|
import { Brain, X } from 'lucide-react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { thinkingModes } from '../../constants/thinkingModes';
|
import { thinkingModes } from '../../constants/thinkingModes';
|
||||||
@@ -12,6 +13,11 @@ type ThinkingModeSelectorProps = {
|
|||||||
|
|
||||||
function ThinkingModeSelector({ selectedMode, onModeChange, onClose, className = '' }: ThinkingModeSelectorProps) {
|
function ThinkingModeSelector({ selectedMode, onModeChange, onClose, className = '' }: ThinkingModeSelectorProps) {
|
||||||
const { t } = useTranslation('chat');
|
const { t } = useTranslation('chat');
|
||||||
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const triggerRef = useRef<HTMLButtonElement>(null);
|
||||||
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [dropdownStyle, setDropdownStyle] = useState<CSSProperties | null>(null);
|
||||||
|
|
||||||
// Mapping from mode ID to translation key
|
// Mapping from mode ID to translation key
|
||||||
const modeKeyMap: Record<string, string> = {
|
const modeKeyMap: Record<string, string> = {
|
||||||
@@ -29,50 +35,143 @@ function ThinkingModeSelector({ selectedMode, onModeChange, onClose, className =
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const closeDropdown = useCallback(() => {
|
||||||
const dropdownRef = useRef<HTMLDivElement>(null);
|
setIsOpen(false);
|
||||||
|
onClose?.();
|
||||||
|
}, [onClose]);
|
||||||
|
|
||||||
|
const updateDropdownPosition = useCallback(() => {
|
||||||
|
const trigger = triggerRef.current;
|
||||||
|
const dropdown = dropdownRef.current;
|
||||||
|
if (!trigger || !dropdown || typeof window === 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const triggerRect = trigger.getBoundingClientRect();
|
||||||
|
const viewportPadding = window.innerWidth < 640 ? 12 : 16;
|
||||||
|
const spacing = 8;
|
||||||
|
const width = Math.min(window.innerWidth - viewportPadding * 2, window.innerWidth < 640 ? 320 : 256);
|
||||||
|
let left = triggerRect.left + triggerRect.width / 2 - width / 2;
|
||||||
|
left = Math.max(viewportPadding, Math.min(left, window.innerWidth - width - viewportPadding));
|
||||||
|
|
||||||
|
const measuredHeight = dropdown.offsetHeight || 0;
|
||||||
|
const spaceBelow = window.innerHeight - triggerRect.bottom - spacing - viewportPadding;
|
||||||
|
const spaceAbove = triggerRect.top - spacing - viewportPadding;
|
||||||
|
const openBelow = spaceBelow >= Math.min(measuredHeight || 320, 320) || spaceBelow >= spaceAbove;
|
||||||
|
const availableHeight = Math.min(
|
||||||
|
window.innerHeight - viewportPadding * 2,
|
||||||
|
Math.max(180, openBelow ? spaceBelow : spaceAbove),
|
||||||
|
);
|
||||||
|
const panelHeight = Math.min(measuredHeight || availableHeight, availableHeight);
|
||||||
|
const top = openBelow
|
||||||
|
? Math.min(triggerRect.bottom + spacing, window.innerHeight - viewportPadding - panelHeight)
|
||||||
|
: Math.max(viewportPadding, triggerRect.top - spacing - panelHeight);
|
||||||
|
|
||||||
|
setDropdownStyle({
|
||||||
|
position: 'fixed',
|
||||||
|
top,
|
||||||
|
left,
|
||||||
|
width,
|
||||||
|
maxHeight: availableHeight,
|
||||||
|
zIndex: 80,
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleClickOutside = (event: MouseEvent) => {
|
if (!isOpen) {
|
||||||
if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {
|
setDropdownStyle(null);
|
||||||
setIsOpen(false);
|
return;
|
||||||
if (onClose) onClose();
|
}
|
||||||
|
|
||||||
|
const rafId = window.requestAnimationFrame(updateDropdownPosition);
|
||||||
|
const handleViewportChange = () => updateDropdownPosition();
|
||||||
|
|
||||||
|
window.addEventListener('resize', handleViewportChange);
|
||||||
|
window.addEventListener('scroll', handleViewportChange, true);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.cancelAnimationFrame(rafId);
|
||||||
|
window.removeEventListener('resize', handleViewportChange);
|
||||||
|
window.removeEventListener('scroll', handleViewportChange, true);
|
||||||
|
};
|
||||||
|
}, [isOpen, updateDropdownPosition]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlePointerDown = (event: PointerEvent) => {
|
||||||
|
const target = event.target;
|
||||||
|
if (!(target instanceof Node)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (containerRef.current?.contains(target) || dropdownRef.current?.contains(target)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
closeDropdown();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
|
if (event.key === 'Escape') {
|
||||||
|
closeDropdown();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('mousedown', handleClickOutside);
|
document.addEventListener('pointerdown', handlePointerDown, true);
|
||||||
return () => document.removeEventListener('mousedown', handleClickOutside);
|
document.addEventListener('keydown', handleKeyDown);
|
||||||
}, [onClose]);
|
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('pointerdown', handlePointerDown, true);
|
||||||
|
document.removeEventListener('keydown', handleKeyDown);
|
||||||
|
};
|
||||||
|
}, [isOpen, closeDropdown]);
|
||||||
|
|
||||||
const currentMode = translatedModes.find(mode => mode.id === selectedMode) || translatedModes[0];
|
const currentMode = translatedModes.find(mode => mode.id === selectedMode) || translatedModes[0];
|
||||||
const IconComponent = currentMode.icon || Brain;
|
const IconComponent = currentMode.icon || Brain;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`relative ${className}`} ref={dropdownRef}>
|
<div className={`relative ${className}`} ref={containerRef}>
|
||||||
<button
|
<button
|
||||||
|
ref={triggerRef}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setIsOpen(!isOpen)}
|
onClick={() => {
|
||||||
|
if (isOpen) {
|
||||||
|
closeDropdown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsOpen(true);
|
||||||
|
}}
|
||||||
className={`flex h-10 w-10 items-center justify-center rounded-full transition-all duration-200 sm:h-10 sm:w-10 ${selectedMode === 'none'
|
className={`flex h-10 w-10 items-center justify-center rounded-full transition-all duration-200 sm:h-10 sm:w-10 ${selectedMode === 'none'
|
||||||
? 'bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600'
|
? 'bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600'
|
||||||
: 'bg-blue-100 hover:bg-blue-200 dark:bg-blue-900 dark:hover:bg-blue-800'
|
: 'bg-blue-100 hover:bg-blue-200 dark:bg-blue-900 dark:hover:bg-blue-800'
|
||||||
}`}
|
}`}
|
||||||
title={t('thinkingMode.buttonTitle', { mode: currentMode.name })}
|
title={t('thinkingMode.buttonTitle', { mode: currentMode.name })}
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
aria-expanded={isOpen}
|
||||||
>
|
>
|
||||||
<IconComponent className={`h-5 w-5 ${currentMode.color}`} />
|
<IconComponent className={`h-5 w-5 ${currentMode.color}`} />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{isOpen && (
|
{isOpen && typeof document !== 'undefined' && createPortal(
|
||||||
<div className="absolute bottom-full right-0 mb-2 w-64 overflow-hidden rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-800">
|
<div
|
||||||
|
ref={dropdownRef}
|
||||||
|
style={dropdownStyle || { position: 'fixed', top: 0, left: 0, visibility: 'hidden' }}
|
||||||
|
className="flex flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-800"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="false"
|
||||||
|
>
|
||||||
<div className="border-b border-gray-200 p-3 dark:border-gray-700">
|
<div className="border-b border-gray-200 p-3 dark:border-gray-700">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<h3 className="text-sm font-semibold text-gray-900 dark:text-white">
|
<h3 className="text-sm font-semibold text-gray-900 dark:text-white">
|
||||||
{t('thinkingMode.selector.title')}
|
{t('thinkingMode.selector.title')}
|
||||||
</h3>
|
</h3>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
type="button"
|
||||||
setIsOpen(false);
|
onClick={closeDropdown}
|
||||||
if (onClose) onClose();
|
|
||||||
}}
|
|
||||||
className="rounded p-1 hover:bg-gray-100 dark:hover:bg-gray-700"
|
className="rounded p-1 hover:bg-gray-100 dark:hover:bg-gray-700"
|
||||||
>
|
>
|
||||||
<X className="h-4 w-4 text-gray-500" />
|
<X className="h-4 w-4 text-gray-500" />
|
||||||
@@ -83,7 +182,7 @@ function ThinkingModeSelector({ selectedMode, onModeChange, onClose, className =
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="py-1">
|
<div className="min-h-0 overflow-y-auto py-1">
|
||||||
{translatedModes.map((mode) => {
|
{translatedModes.map((mode) => {
|
||||||
const ModeIcon = mode.icon;
|
const ModeIcon = mode.icon;
|
||||||
const isSelected = mode.id === selectedMode;
|
const isSelected = mode.id === selectedMode;
|
||||||
@@ -91,10 +190,10 @@ function ThinkingModeSelector({ selectedMode, onModeChange, onClose, className =
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={mode.id}
|
key={mode.id}
|
||||||
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onModeChange(mode.id);
|
onModeChange(mode.id);
|
||||||
setIsOpen(false);
|
closeDropdown();
|
||||||
if (onClose) onClose();
|
|
||||||
}}
|
}}
|
||||||
className={`w-full px-4 py-3 text-left transition-colors hover:bg-gray-50 dark:hover:bg-gray-700 ${isSelected ? 'bg-gray-50 dark:bg-gray-700' : ''
|
className={`w-full px-4 py-3 text-left transition-colors hover:bg-gray-50 dark:hover:bg-gray-700 ${isSelected ? 'bg-gray-50 dark:bg-gray-700' : ''
|
||||||
}`}
|
}`}
|
||||||
@@ -135,7 +234,8 @@ function ThinkingModeSelector({ selectedMode, onModeChange, onClose, className =
|
|||||||
<strong>Tip:</strong> {t('thinkingMode.selector.tip')}
|
<strong>Tip:</strong> {t('thinkingMode.selector.tip')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>,
|
||||||
|
document.body
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -248,6 +248,20 @@ export function useFileTreeOperations({
|
|||||||
showToast(t('fileTree.toast.pathCopied', 'Path copied to clipboard'), 'success');
|
showToast(t('fileTree.toast.pathCopied', 'Path copied to clipboard'), 'success');
|
||||||
}, [showToast, t]);
|
}, [showToast, t]);
|
||||||
|
|
||||||
|
const triggerBrowserDownload = useCallback((blob: Blob, fileName: string) => {
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const anchor = document.createElement('a');
|
||||||
|
|
||||||
|
anchor.href = url;
|
||||||
|
anchor.download = fileName;
|
||||||
|
|
||||||
|
document.body.appendChild(anchor);
|
||||||
|
anchor.click();
|
||||||
|
document.body.removeChild(anchor);
|
||||||
|
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Download file or folder
|
// Download file or folder
|
||||||
const handleDownload = useCallback(async (item: FileTreeNode) => {
|
const handleDownload = useCallback(async (item: FileTreeNode) => {
|
||||||
if (!selectedProject) return;
|
if (!selectedProject) return;
|
||||||
@@ -272,28 +286,16 @@ export function useFileTreeOperations({
|
|||||||
const downloadSingleFile = useCallback(async (item: FileTreeNode) => {
|
const downloadSingleFile = useCallback(async (item: FileTreeNode) => {
|
||||||
if (!selectedProject) return;
|
if (!selectedProject) return;
|
||||||
|
|
||||||
const response = await api.readFile(selectedProject.name, item.path);
|
// Use the binary streaming endpoint so downloads preserve raw bytes.
|
||||||
|
const response = await api.readFileBlob(selectedProject.name, item.path);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Failed to download file');
|
throw new Error('Failed to download file');
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const blob = await response.blob();
|
||||||
const content = data.content;
|
triggerBrowserDownload(blob, item.name);
|
||||||
|
}, [selectedProject, triggerBrowserDownload]);
|
||||||
const blob = new Blob([content], { type: 'text/plain' });
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const anchor = document.createElement('a');
|
|
||||||
|
|
||||||
anchor.href = url;
|
|
||||||
anchor.download = item.name;
|
|
||||||
|
|
||||||
document.body.appendChild(anchor);
|
|
||||||
anchor.click();
|
|
||||||
document.body.removeChild(anchor);
|
|
||||||
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
}, [selectedProject]);
|
|
||||||
|
|
||||||
// Download folder as ZIP
|
// Download folder as ZIP
|
||||||
const downloadFolderAsZip = useCallback(async (folder: FileTreeNode) => {
|
const downloadFolderAsZip = useCallback(async (folder: FileTreeNode) => {
|
||||||
@@ -306,12 +308,14 @@ export function useFileTreeOperations({
|
|||||||
const fullPath = currentPath ? `${currentPath}/${node.name}` : node.name;
|
const fullPath = currentPath ? `${currentPath}/${node.name}` : node.name;
|
||||||
|
|
||||||
if (node.type === 'file') {
|
if (node.type === 'file') {
|
||||||
// Fetch file content
|
const response = await api.readFileBlob(selectedProject.name, node.path);
|
||||||
const response = await api.readFile(selectedProject.name, node.path);
|
if (!response.ok) {
|
||||||
if (response.ok) {
|
throw new Error(`Failed to download "${node.name}" for ZIP export`);
|
||||||
const data = await response.json();
|
|
||||||
zip.file(fullPath, data.content);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store raw bytes in the archive so binary files stay intact.
|
||||||
|
const fileBytes = await response.arrayBuffer();
|
||||||
|
zip.file(fullPath, fileBytes);
|
||||||
} else if (node.type === 'directory' && node.children) {
|
} else if (node.type === 'directory' && node.children) {
|
||||||
// Recursively process children
|
// Recursively process children
|
||||||
for (const child of node.children) {
|
for (const child of node.children) {
|
||||||
@@ -329,20 +333,10 @@ export function useFileTreeOperations({
|
|||||||
|
|
||||||
// Generate ZIP file
|
// Generate ZIP file
|
||||||
const zipBlob = await zip.generateAsync({ type: 'blob' });
|
const zipBlob = await zip.generateAsync({ type: 'blob' });
|
||||||
const url = URL.createObjectURL(zipBlob);
|
triggerBrowserDownload(zipBlob, `${folder.name}.zip`);
|
||||||
const anchor = document.createElement('a');
|
|
||||||
|
|
||||||
anchor.href = url;
|
|
||||||
anchor.download = `${folder.name}.zip`;
|
|
||||||
|
|
||||||
document.body.appendChild(anchor);
|
|
||||||
anchor.click();
|
|
||||||
document.body.removeChild(anchor);
|
|
||||||
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
|
|
||||||
showToast(t('fileTree.toast.folderDownloaded', 'Folder downloaded as ZIP'), 'success');
|
showToast(t('fileTree.toast.folderDownloaded', 'Folder downloaded as ZIP'), 'success');
|
||||||
}, [selectedProject, showToast, t]);
|
}, [selectedProject, showToast, t, triggerBrowserDownload]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// Rename operations
|
// Rename operations
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ export default function BranchesView({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`flex flex-1 flex-col overflow-hidden ${isMobile ? 'pb-mobile-nav' : ''}`}>
|
<div className="flex flex-1 flex-col overflow-hidden">
|
||||||
{/* Create branch button */}
|
{/* Create branch button */}
|
||||||
<div className="flex items-center justify-between border-b border-border/40 px-4 py-2.5">
|
<div className="flex items-center justify-between border-b border-border/40 px-4 py-2.5">
|
||||||
<span className="text-sm text-muted-foreground">
|
<span className="text-sm text-muted-foreground">
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ export default function ChangesView({
|
|||||||
|
|
||||||
{!gitStatus?.error && <FileStatusLegend isMobile={isMobile} />}
|
{!gitStatus?.error && <FileStatusLegend isMobile={isMobile} />}
|
||||||
|
|
||||||
<div className={`flex-1 overflow-y-auto ${isMobile ? 'pb-mobile-nav' : ''}`}>
|
<div className="flex-1 overflow-y-auto">
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="flex h-32 items-center justify-center">
|
<div className="flex h-32 items-center justify-center">
|
||||||
<RefreshCw className="h-5 w-5 animate-spin text-muted-foreground" />
|
<RefreshCw className="h-5 w-5 animate-spin text-muted-foreground" />
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Check, ChevronDown, GitCommit, RefreshCw, Sparkles } from 'lucide-react';
|
import { Check, ChevronDown, GitCommit, RefreshCw, Sparkles } from 'lucide-react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import MicButton from '../../../mic-button/view/MicButton';
|
|
||||||
import type { ConfirmationRequest } from '../../types/types';
|
import type { ConfirmationRequest } from '../../types/types';
|
||||||
|
|
||||||
// Persists commit messages across unmount/remount, keyed by project path
|
// Persists commit messages across unmount/remount, keyed by project path
|
||||||
@@ -147,13 +146,6 @@ export default function CommitComposer({
|
|||||||
<Sparkles className="h-4 w-4" />
|
<Sparkles className="h-4 w-4" />
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
<div style={{ display: 'none' }}>
|
|
||||||
<MicButton
|
|
||||||
onTranscript={(transcript) => setCommitMessage(transcript)}
|
|
||||||
mode="default"
|
|
||||||
className="p-1.5"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export default function HistoryView({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`flex-1 overflow-y-auto ${isMobile ? 'pb-mobile-nav' : ''}`}>
|
<div className="flex-1 overflow-y-auto">
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="flex h-32 items-center justify-center">
|
<div className="flex h-32 items-center justify-center">
|
||||||
<RefreshCw className="h-5 w-5 animate-spin text-muted-foreground" />
|
<RefreshCw className="h-5 w-5 animate-spin text-muted-foreground" />
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import type { SessionProvider } from '../../types/app';
|
import type { LLMProvider } from '../../types/app';
|
||||||
import ClaudeLogo from './ClaudeLogo';
|
import ClaudeLogo from './ClaudeLogo';
|
||||||
import CodexLogo from './CodexLogo';
|
import CodexLogo from './CodexLogo';
|
||||||
import CursorLogo from './CursorLogo';
|
import CursorLogo from './CursorLogo';
|
||||||
import GeminiLogo from './GeminiLogo';
|
import GeminiLogo from './GeminiLogo';
|
||||||
|
|
||||||
type SessionProviderLogoProps = {
|
type SessionProviderLogoProps = {
|
||||||
provider?: SessionProvider | string | null;
|
provider?: LLMProvider | string | null;
|
||||||
className?: string;
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
import type { MicButtonState } from '../types/types';
|
|
||||||
|
|
||||||
export const MIC_BUTTON_STATES = {
|
|
||||||
IDLE: 'idle',
|
|
||||||
RECORDING: 'recording',
|
|
||||||
TRANSCRIBING: 'transcribing',
|
|
||||||
PROCESSING: 'processing',
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export const MIC_TAP_DEBOUNCE_MS = 300;
|
|
||||||
export const PROCESSING_STATE_DELAY_MS = 2000;
|
|
||||||
|
|
||||||
export const DEFAULT_WHISPER_MODE = 'default';
|
|
||||||
|
|
||||||
// Modes that use post-transcription enhancement on the backend.
|
|
||||||
export const ENHANCEMENT_WHISPER_MODES = new Set([
|
|
||||||
'prompt',
|
|
||||||
'vibe',
|
|
||||||
'instructions',
|
|
||||||
'architect',
|
|
||||||
]);
|
|
||||||
|
|
||||||
export const BUTTON_BACKGROUND_BY_STATE: Record<MicButtonState, string> = {
|
|
||||||
idle: '#374151',
|
|
||||||
recording: '#ef4444',
|
|
||||||
transcribing: '#3b82f6',
|
|
||||||
processing: '#a855f7',
|
|
||||||
};
|
|
||||||
|
|
||||||
export const MIC_ERROR_BY_NAME = {
|
|
||||||
NotAllowedError: 'Microphone access denied. Please allow microphone permissions.',
|
|
||||||
NotFoundError: 'No microphone found. Please check your audio devices.',
|
|
||||||
NotSupportedError: 'Microphone not supported by this browser.',
|
|
||||||
NotReadableError: 'Microphone is being used by another application.',
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export const MIC_NOT_AVAILABLE_ERROR =
|
|
||||||
'Microphone access not available. Please use HTTPS or a supported browser.';
|
|
||||||
|
|
||||||
export const MIC_NOT_SUPPORTED_ERROR =
|
|
||||||
'Microphone not supported. Please use HTTPS or a modern browser.';
|
|
||||||
|
|
||||||
export const MIC_SECURE_CONTEXT_ERROR =
|
|
||||||
'Microphone requires HTTPS. Please use a secure connection.';
|
|
||||||
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
import { api } from '../../../utils/api';
|
|
||||||
|
|
||||||
type WhisperStatus = 'transcribing';
|
|
||||||
|
|
||||||
type WhisperResponse = {
|
|
||||||
text?: string;
|
|
||||||
error?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function transcribeWithWhisper(
|
|
||||||
audioBlob: Blob,
|
|
||||||
onStatusChange?: (status: WhisperStatus) => void,
|
|
||||||
): Promise<string> {
|
|
||||||
const formData = new FormData();
|
|
||||||
const fileName = `recording_${Date.now()}.webm`;
|
|
||||||
const file = new File([audioBlob], fileName, { type: audioBlob.type });
|
|
||||||
|
|
||||||
formData.append('audio', file);
|
|
||||||
|
|
||||||
const whisperMode = window.localStorage.getItem('whisperMode') || 'default';
|
|
||||||
formData.append('mode', whisperMode);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Keep existing status callback behavior.
|
|
||||||
if (onStatusChange) {
|
|
||||||
onStatusChange('transcribing');
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = (await api.transcribe(formData)) as Response;
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const errorData = (await response.json().catch(() => ({}))) as WhisperResponse;
|
|
||||||
throw new Error(
|
|
||||||
errorData.error ||
|
|
||||||
`Transcription error: ${response.status} ${response.statusText}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = (await response.json()) as WhisperResponse;
|
|
||||||
return data.text || '';
|
|
||||||
} catch (error) {
|
|
||||||
if (
|
|
||||||
error instanceof Error
|
|
||||||
&& error.name === 'TypeError'
|
|
||||||
&& error.message.includes('fetch')
|
|
||||||
) {
|
|
||||||
throw new Error('Cannot connect to server. Please ensure the backend is running.');
|
|
||||||
}
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user