@neuralnomads/codenomad 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -4
- package/dist/background-processes/manager.js +0 -1
- package/dist/config/schema.js +1 -0
- package/dist/filesystem/__tests__/browser.test.js +65 -0
- package/dist/filesystem/__tests__/search-cache.test.js +2 -2
- package/dist/filesystem/browser.js +25 -4
- package/dist/index.js +13 -6
- package/dist/launcher.js +12 -1
- package/dist/opencode-plugin/codenomad-opencode-plugin.tgz +0 -0
- package/dist/opencode-plugin.js +146 -0
- package/dist/opencode-plugin.test.js +28 -0
- package/dist/previews/manager.js +63 -0
- package/dist/server/__tests__/listener-base-url.test.js +30 -0
- package/dist/server/http-server.js +378 -152
- package/dist/server/listener-base-url.js +17 -0
- package/dist/server/routes/config-files.js +92 -0
- package/dist/server/routes/config-files.test.js +115 -0
- package/dist/server/routes/filesystem.js +13 -0
- package/dist/server/routes/previews.js +25 -0
- package/dist/server/routes/workspaces.js +38 -1
- package/dist/workspaces/__tests__/git-clone.test.js +142 -0
- package/dist/workspaces/__tests__/spawn.test.js +27 -9
- package/dist/workspaces/git-clone.js +148 -0
- package/dist/workspaces/manager.js +27 -6
- package/dist/workspaces/spawn.js +35 -9
- package/dist/workspaces/worktree-map.js +16 -0
- package/package.json +3 -3
- package/public/assets/FilesTab-B5ysoRLh.js +2 -0
- package/public/assets/GitChangesTab-BksCi53d.js +2 -0
- package/public/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/public/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/public/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/public/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/public/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/public/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/public/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/public/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/public/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/public/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/public/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/public/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/public/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/public/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/public/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/public/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/public/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/public/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/public/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/public/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/public/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/public/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/public/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/public/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/public/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/public/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/public/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/public/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/public/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/public/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/public/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/public/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/public/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/public/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/public/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/public/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/public/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/public/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/public/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/public/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/public/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/public/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/public/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/public/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/public/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/public/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/public/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/public/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/public/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/public/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/public/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/public/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/public/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/public/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/public/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/public/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/public/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/public/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/public/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/public/assets/{SplitFilePanel-BOHH3F--.js → SplitFilePanel-CrSfR22r.js} +1 -1
- package/public/assets/StatusTab-Dgqekgjn.js +1 -0
- package/public/assets/{align-justify-9zpyaAdy.js → align-justify-hRtBz8xe.js} +1 -1
- package/public/assets/{bundle-full-xFW13Lny.js → bundle-full-BVDA-a9Y.js} +2 -2
- package/public/assets/{diff-viewer-xG9yjpN8.js → diff-viewer-BCAI0Cw8.js} +1 -1
- package/public/assets/index-B2Qd6xQq.css +1 -0
- package/public/assets/index-BQpEhdk5.js +1 -0
- package/public/assets/index-BXIEm2zT.js +1 -0
- package/public/assets/index-CWjU9mAF.js +1 -0
- package/public/assets/index-Cvtlo58a.js +1 -0
- package/public/assets/index-DFlxnvHT.js +2 -0
- package/public/assets/index-Ddsv8Uc0.js +1 -0
- package/public/assets/index-Dn7woJnK.js +1 -0
- package/public/assets/index-DnCBfFB3.js +1 -0
- package/public/assets/index-DnXT1F8T.js +1 -0
- package/public/assets/index-Kv-3BRTi.js +1 -0
- package/public/assets/index-g-G1RiME.js +1 -0
- package/public/assets/{loading-HUhLEgb_.js → loading-bD3ppK2l.js} +1 -1
- package/public/assets/main-BsbMOeQg.js +65 -0
- package/public/assets/markdown-DJuaMC5H.js +315 -0
- package/public/assets/monaco-viewer-BFNhPQX7.js +26 -0
- package/public/assets/tool-call-BSJluZRW.js +59 -0
- package/public/assets/{unified-picker-DuNuUpLy.js → unified-picker-DmFyrIis.js} +1 -1
- package/public/assets/{wrap-text-zghCl6wN.js → wrap-text-BkcW_eTA.js} +1 -1
- package/public/index.html +4 -4
- package/public/loading.html +4 -4
- package/public/sw.js +1 -1
- package/public/ui-version.json +1 -1
- package/dist/opencode-config/README.md +0 -32
- package/dist/opencode-config/opencode.jsonc +0 -3
- package/dist/opencode-config/package-lock.json +0 -380
- package/dist/opencode-config/package.json +0 -9
- package/dist/opencode-config/plugin/codenomad.ts +0 -62
- package/dist/opencode-config/plugin/lib/background-process.ts +0 -265
- package/dist/opencode-config/plugin/lib/client.ts +0 -133
- package/dist/opencode-config/plugin/lib/request.ts +0 -214
- package/dist/opencode-config.js +0 -26
- package/public/assets/ChangesTab-ovdqLHc3.js +0 -2
- package/public/assets/DiffToolbar-B12EfXMX.js +0 -1
- package/public/assets/FilesTab-nb_itEXG.js +0 -2
- package/public/assets/GitChangesTab-DcT_4BL2.js +0 -2
- package/public/assets/StatusTab-Dyt_EG33.js +0 -1
- package/public/assets/index-7DpT014-.js +0 -1
- package/public/assets/index-BDK4V9L0.js +0 -1
- package/public/assets/index-Bx-Bezt2.js +0 -1
- package/public/assets/index-CCAZZY0l.js +0 -1
- package/public/assets/index-CEcZq5WB.js +0 -1
- package/public/assets/index-CQCmSDHL.js +0 -1
- package/public/assets/index-Cz_fl8aY.js +0 -1
- package/public/assets/index-Dcgftm1m.css +0 -1
- package/public/assets/index-m4C3yx3J.js +0 -1
- package/public/assets/index-mh_z9p40.js +0 -2
- package/public/assets/main-CKhfaeKI.js +0 -48
- package/public/assets/markdown-BeXU9Z-x.js +0 -58
- package/public/assets/monaco-viewer-BgP6xpZ6.js +0 -26
- package/public/assets/todo-D6PVVp_f.js +0 -1
- package/public/assets/tool-call-Dgn3NlA8.js +0 -60
package/README.md
CHANGED
|
@@ -32,9 +32,11 @@
|
|
|
32
32
|
You can run CodeNomad directly without installing it:
|
|
33
33
|
|
|
34
34
|
```sh
|
|
35
|
-
npx @neuralnomads/codenomad --launch
|
|
35
|
+
npx @neuralnomads/codenomad --password <your-password> --launch
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
> **Authentication required:** The server requires a password. Pass it via `--password`, the `CODENOMAD_SERVER_PASSWORD` environment variable, or create an `auth.json` file (see [Authentication](#authentication) below).
|
|
39
|
+
|
|
38
40
|
To list all CLI options:
|
|
39
41
|
|
|
40
42
|
```sh
|
|
@@ -52,7 +54,7 @@ Or install it globally to use the `codenomad` command:
|
|
|
52
54
|
|
|
53
55
|
```sh
|
|
54
56
|
npm install -g @neuralnomads/codenomad
|
|
55
|
-
codenomad --launch
|
|
57
|
+
codenomad --password <your-password> --launch
|
|
56
58
|
```
|
|
57
59
|
|
|
58
60
|
### Install Locally (per-project)
|
|
@@ -61,7 +63,7 @@ If you prefer to install CodeNomad into a project and run the local binary:
|
|
|
61
63
|
|
|
62
64
|
```sh
|
|
63
65
|
npm install @neuralnomads/codenomad
|
|
64
|
-
npx codenomad --launch
|
|
66
|
+
npx codenomad --password <your-password> --launch
|
|
65
67
|
```
|
|
66
68
|
|
|
67
69
|
(`npx codenomad ...` will use `./node_modules/.bin/codenomad` when present.)
|
|
@@ -102,7 +104,7 @@ You can configure the server using flags or environment variables:
|
|
|
102
104
|
If you want the latest bleeding-edge builds (published as GitHub pre-releases), use the dev package:
|
|
103
105
|
|
|
104
106
|
```sh
|
|
105
|
-
npx @neuralnomads/codenomad-dev --launch
|
|
107
|
+
npx @neuralnomads/codenomad-dev --password <your-password> --launch
|
|
106
108
|
```
|
|
107
109
|
|
|
108
110
|
These environment variables control how CodeNomad checks for dev updates:
|
|
@@ -148,6 +150,14 @@ Certificates are valid for about 30 days and rotate automatically on startup whe
|
|
|
148
150
|
codenomad --tlsSANs "localhost,127.0.0.1,my-hostname,192.168.1.10"
|
|
149
151
|
```
|
|
150
152
|
|
|
153
|
+
> **Browser warning:** Self-signed certificates trigger a "Your connection is not private" warning in browsers on first visit. This is expected and safe for local development (127.0.0.1 / localhost):
|
|
154
|
+
>
|
|
155
|
+
> 1. **Chrome/Brave/Edge:** Click **Advanced** → **Proceed to 127.0.0.1 (unsafe)**
|
|
156
|
+
> 2. **Firefox:** Click **Advanced** → **Accept the Risk and Continue**
|
|
157
|
+
> 3. **Alternative:** For local-only development without the warning, run with `--https=false --http=true`
|
|
158
|
+
>
|
|
159
|
+
> **Note:** Only accept self-signed certificates for localhost/127.0.0.1 that you control. For remote hosts, use proper TLS certificates.
|
|
160
|
+
|
|
151
161
|
### Authentication
|
|
152
162
|
|
|
153
163
|
- Default behavior: CodeNomad requires a login (username/password) and stores a session cookie in the browser.
|
|
@@ -155,6 +165,42 @@ codenomad --tlsSANs "localhost,127.0.0.1,my-hostname,192.168.1.10"
|
|
|
155
165
|
Use this only when access is already protected by another layer (SSO proxy, VPN, Coder workspace auth, etc.).
|
|
156
166
|
If you bind to `0.0.0.0` while skipping auth, anyone who can reach the port can access the API.
|
|
157
167
|
|
|
168
|
+
#### Setting a password
|
|
169
|
+
|
|
170
|
+
**Practical setup options:**
|
|
171
|
+
|
|
172
|
+
1. **Runtime password (every start):** Use `--password <your-password>` or set `CODENOMAD_SERVER_PASSWORD=<your-password>` environment variable
|
|
173
|
+
2. **Persistent password (UI setup):** Launch with `--generate-token`, complete the local bootstrap flow in your browser, then set a password through the UI settings
|
|
174
|
+
|
|
175
|
+
The `--password` flag and `CODENOMAD_SERVER_PASSWORD` env var are **runtime credentials** — they must be provided on every server start and are not persisted to disk.
|
|
176
|
+
|
|
177
|
+
**Advanced: `auth.json` internals**
|
|
178
|
+
|
|
179
|
+
The `auth.json` file (`~/.config/codenomad/auth.json`) is automatically created and managed by CodeNomad when you set a password through the UI. You generally don't need to edit this file manually. For reference, it uses the following scrypt-based schema:
|
|
180
|
+
|
|
181
|
+
```json
|
|
182
|
+
{
|
|
183
|
+
"version": 1,
|
|
184
|
+
"username": "codenomad",
|
|
185
|
+
"password": {
|
|
186
|
+
"algorithm": "scrypt",
|
|
187
|
+
"saltBase64": "<base64-salt>",
|
|
188
|
+
"hashBase64": "<base64-hash>",
|
|
189
|
+
"keyLength": 64,
|
|
190
|
+
"params": {
|
|
191
|
+
"N": 16384,
|
|
192
|
+
"r": 8,
|
|
193
|
+
"p": 1,
|
|
194
|
+
"maxmem": 33554432
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
"userProvided": true,
|
|
198
|
+
"updatedAt": "2026-05-18T12:00:00.000Z"
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Manual creation of this file is not recommended unless you have a helper to generate a valid scrypt `PasswordHashRecord`.
|
|
203
|
+
|
|
158
204
|
### Progressive Web App (PWA)
|
|
159
205
|
|
|
160
206
|
When running as a server CodeNomad can also be installed as a PWA from any supported browser, giving you a native app experience just like the Electron installation but executing on the remote server instead.
|
|
@@ -521,7 +521,6 @@ export class BackgroundProcessManager {
|
|
|
521
521
|
const targetUrl = `http://127.0.0.1:${port}/session/${encodeURIComponent(notify.sessionID)}/prompt_async`;
|
|
522
522
|
const headers = {
|
|
523
523
|
"content-type": "application/json",
|
|
524
|
-
"x-opencode-directory": /[^\x00-\x7F]/.test(notify.directory) ? encodeURIComponent(notify.directory) : notify.directory,
|
|
525
524
|
};
|
|
526
525
|
const authorization = this.deps.workspaceManager.getInstanceAuthorizationHeader(workspaceId);
|
|
527
526
|
if (authorization) {
|
package/dist/config/schema.js
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { afterEach, describe, it } from "node:test";
|
|
6
|
+
import { FileSystemBrowser } from "../browser";
|
|
7
|
+
import { WINDOWS_DRIVES_ROOT } from "../../api-types";
|
|
8
|
+
const tempRoots = [];
|
|
9
|
+
describe("FileSystemBrowser", () => {
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
for (const directory of tempRoots.splice(0)) {
|
|
12
|
+
fs.rmSync(directory, { recursive: true, force: true });
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
it("starts unrestricted browsing from the configured root", () => {
|
|
16
|
+
const rootDir = createTempRoot();
|
|
17
|
+
fs.mkdirSync(path.join(rootDir, "project"));
|
|
18
|
+
const browser = new FileSystemBrowser({ rootDir, unrestricted: true });
|
|
19
|
+
const listing = browser.browse();
|
|
20
|
+
assert.equal(listing.metadata.scope, "unrestricted");
|
|
21
|
+
assert.equal(listing.metadata.currentPath, rootDir);
|
|
22
|
+
assert.equal(listing.metadata.rootPath, rootDir);
|
|
23
|
+
assert.equal(listing.metadata.displayPath, rootDir);
|
|
24
|
+
assert.equal(listing.metadata.pathKind, "absolute");
|
|
25
|
+
assert.ok(listing.entries.some((entry) => entry.name === "project" && entry.absolutePath === path.join(rootDir, "project")));
|
|
26
|
+
});
|
|
27
|
+
it("treats dot as the configured unrestricted root", () => {
|
|
28
|
+
const rootDir = createTempRoot();
|
|
29
|
+
const browser = new FileSystemBrowser({ rootDir, unrestricted: true });
|
|
30
|
+
const listing = browser.browse(".");
|
|
31
|
+
assert.equal(listing.metadata.currentPath, rootDir);
|
|
32
|
+
assert.equal(listing.metadata.rootPath, rootDir);
|
|
33
|
+
});
|
|
34
|
+
it("allows unrestricted browsing outside the configured root", () => {
|
|
35
|
+
const rootDir = createTempRoot();
|
|
36
|
+
const parentDir = path.dirname(rootDir);
|
|
37
|
+
const browser = new FileSystemBrowser({ rootDir, unrestricted: true });
|
|
38
|
+
const listing = browser.browse(parentDir);
|
|
39
|
+
assert.equal(listing.metadata.currentPath, parentDir);
|
|
40
|
+
assert.equal(listing.metadata.rootPath, rootDir);
|
|
41
|
+
assert.ok(listing.entries.some((entry) => entry.absolutePath === rootDir));
|
|
42
|
+
});
|
|
43
|
+
it("creates folders under the configured unrestricted root by default", () => {
|
|
44
|
+
const rootDir = createTempRoot();
|
|
45
|
+
const browser = new FileSystemBrowser({ rootDir, unrestricted: true });
|
|
46
|
+
const created = browser.createFolder(undefined, "created-folder");
|
|
47
|
+
assert.equal(created.path, path.join(rootDir, "created-folder"));
|
|
48
|
+
assert.equal(created.absolutePath, path.join(rootDir, "created-folder"));
|
|
49
|
+
assert.equal(fs.statSync(created.absolutePath).isDirectory(), true);
|
|
50
|
+
});
|
|
51
|
+
it("reports the configured root for the Windows drives pseudo-root", () => {
|
|
52
|
+
const rootDir = createTempRoot();
|
|
53
|
+
const browser = new FileSystemBrowser({ rootDir, unrestricted: true, platform: "win32" });
|
|
54
|
+
const listing = browser.browse(WINDOWS_DRIVES_ROOT);
|
|
55
|
+
assert.equal(listing.metadata.scope, "unrestricted");
|
|
56
|
+
assert.equal(listing.metadata.currentPath, WINDOWS_DRIVES_ROOT);
|
|
57
|
+
assert.equal(listing.metadata.rootPath, rootDir);
|
|
58
|
+
assert.equal(listing.metadata.pathKind, "drives");
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
function createTempRoot() {
|
|
62
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "codenomad-browser-"));
|
|
63
|
+
tempRoots.push(root);
|
|
64
|
+
return fs.realpathSync(root);
|
|
65
|
+
}
|
|
@@ -19,11 +19,11 @@ describe("workspace search cache", () => {
|
|
|
19
19
|
it("replaces cached entries when manually refreshed", () => {
|
|
20
20
|
const workspacePath = "/tmp/workspace";
|
|
21
21
|
refreshWorkspaceCandidates(workspacePath, () => [createEntry("file-a")], 5000);
|
|
22
|
-
const initial = getWorkspaceCandidates(workspacePath);
|
|
22
|
+
const initial = getWorkspaceCandidates(workspacePath, 5001);
|
|
23
23
|
assert.ok(initial);
|
|
24
24
|
assert.equal(initial[0].name, "file-a");
|
|
25
25
|
refreshWorkspaceCandidates(workspacePath, () => [createEntry("file-b")], 6000);
|
|
26
|
-
const refreshed = getWorkspaceCandidates(workspacePath);
|
|
26
|
+
const refreshed = getWorkspaceCandidates(workspacePath, 6001);
|
|
27
27
|
assert.ok(refreshed);
|
|
28
28
|
assert.equal(refreshed[0].name, "file-b");
|
|
29
29
|
});
|
|
@@ -3,12 +3,13 @@ import os from "os";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { WINDOWS_DRIVES_ROOT, } from "../api-types";
|
|
5
5
|
const WINDOWS_DRIVE_LETTERS = Array.from({ length: 26 }, (_, i) => String.fromCharCode(65 + i));
|
|
6
|
+
const MAX_READABLE_FILE_BYTES = 5 * 1024 * 1024;
|
|
6
7
|
export class FileSystemBrowser {
|
|
7
8
|
constructor(options) {
|
|
8
9
|
this.root = path.resolve(options.rootDir);
|
|
9
10
|
this.unrestricted = Boolean(options.unrestricted);
|
|
10
11
|
this.homeDir = os.homedir();
|
|
11
|
-
this.isWindows = process.platform === "win32";
|
|
12
|
+
this.isWindows = (options.platform ?? process.platform) === "win32";
|
|
12
13
|
}
|
|
13
14
|
list(relativePath = ".", options = {}) {
|
|
14
15
|
if (this.unrestricted) {
|
|
@@ -64,6 +65,26 @@ export class FileSystemBrowser {
|
|
|
64
65
|
const resolved = this.toRestrictedAbsolute(relativePath);
|
|
65
66
|
return fs.readFileSync(resolved, "utf-8");
|
|
66
67
|
}
|
|
68
|
+
readFileBase64(relativePath) {
|
|
69
|
+
if (this.unrestricted) {
|
|
70
|
+
throw new Error("readFileBase64 is not available in unrestricted mode");
|
|
71
|
+
}
|
|
72
|
+
const resolved = this.toRestrictedAbsolute(relativePath);
|
|
73
|
+
return fs.readFileSync(resolved).toString("base64");
|
|
74
|
+
}
|
|
75
|
+
readFileContent(targetPath, options) {
|
|
76
|
+
const encoding = options?.encoding ?? "utf-8";
|
|
77
|
+
const resolved = this.unrestricted ? this.resolveUnrestrictedPath(targetPath) : this.toRestrictedAbsolute(targetPath);
|
|
78
|
+
const stats = fs.statSync(resolved);
|
|
79
|
+
if (!stats.isFile()) {
|
|
80
|
+
throw new Error("Selected path is not a file");
|
|
81
|
+
}
|
|
82
|
+
if (stats.size > MAX_READABLE_FILE_BYTES) {
|
|
83
|
+
throw new Error("Selected file is too large to attach");
|
|
84
|
+
}
|
|
85
|
+
const contents = encoding === "base64" ? fs.readFileSync(resolved).toString("base64") : fs.readFileSync(resolved, "utf-8");
|
|
86
|
+
return { path: targetPath, contents, encoding };
|
|
87
|
+
}
|
|
67
88
|
listRestrictedWithMetadata(relativePath, includeFiles) {
|
|
68
89
|
const normalizedPath = this.normalizeRelativePath(relativePath);
|
|
69
90
|
const absolutePath = this.toRestrictedAbsolute(normalizedPath);
|
|
@@ -98,7 +119,7 @@ export class FileSystemBrowser {
|
|
|
98
119
|
scope: "unrestricted",
|
|
99
120
|
currentPath: resolvedPath,
|
|
100
121
|
parentPath,
|
|
101
|
-
rootPath: this.
|
|
122
|
+
rootPath: this.root,
|
|
102
123
|
homePath: this.homeDir,
|
|
103
124
|
displayPath: resolvedPath,
|
|
104
125
|
pathKind: "absolute",
|
|
@@ -137,7 +158,7 @@ export class FileSystemBrowser {
|
|
|
137
158
|
scope: "unrestricted",
|
|
138
159
|
currentPath: WINDOWS_DRIVES_ROOT,
|
|
139
160
|
parentPath: undefined,
|
|
140
|
-
rootPath: this.
|
|
161
|
+
rootPath: this.root,
|
|
141
162
|
homePath: this.homeDir,
|
|
142
163
|
displayPath: "Drives",
|
|
143
164
|
pathKind: "drives",
|
|
@@ -253,7 +274,7 @@ export class FileSystemBrowser {
|
|
|
253
274
|
}
|
|
254
275
|
resolveUnrestrictedPath(input) {
|
|
255
276
|
if (!input || input === "." || input === "./") {
|
|
256
|
-
return this.
|
|
277
|
+
return this.root;
|
|
257
278
|
}
|
|
258
279
|
if (this.isWindows) {
|
|
259
280
|
if (input === WINDOWS_DRIVES_ROOT) {
|
package/dist/index.js
CHANGED
|
@@ -22,9 +22,11 @@ import { AuthManager, BOOTSTRAP_TOKEN_STDOUT_PREFIX, DEFAULT_AUTH_COOKIE_NAME, D
|
|
|
22
22
|
import { resolveHttpsOptions } from "./server/tls";
|
|
23
23
|
import { RemoteProxySessionManager } from "./server/remote-proxy";
|
|
24
24
|
import { resolveNetworkAddresses, resolveRemoteAddresses } from "./server/network-addresses";
|
|
25
|
+
import { resolvePluginBaseUrl } from "./server/listener-base-url";
|
|
25
26
|
import { startDevReleaseMonitor } from "./releases/dev-release-monitor";
|
|
26
27
|
import { SpeechService } from "./speech/service";
|
|
27
28
|
import { SideCarManager } from "./sidecars/manager";
|
|
29
|
+
import { PreviewManager } from "./previews/manager";
|
|
28
30
|
import { ClientConnectionManager } from "./clients/connection-manager";
|
|
29
31
|
import { PluginChannelManager } from "./plugins/channel";
|
|
30
32
|
import { VoiceModeManager } from "./plugins/voice-mode";
|
|
@@ -230,6 +232,7 @@ async function main() {
|
|
|
230
232
|
eventBus,
|
|
231
233
|
logger: logger.child({ component: "sidecars" }),
|
|
232
234
|
});
|
|
235
|
+
const previewManager = new PreviewManager();
|
|
233
236
|
const instanceEventBridge = new InstanceEventBridge({
|
|
234
237
|
workspaceManager,
|
|
235
238
|
eventBus,
|
|
@@ -313,6 +316,7 @@ async function main() {
|
|
|
313
316
|
instanceStore,
|
|
314
317
|
speechService,
|
|
315
318
|
sidecarManager,
|
|
319
|
+
previewManager,
|
|
316
320
|
authManager,
|
|
317
321
|
clientConnectionManager,
|
|
318
322
|
pluginChannel,
|
|
@@ -338,6 +342,7 @@ async function main() {
|
|
|
338
342
|
instanceStore,
|
|
339
343
|
speechService,
|
|
340
344
|
sidecarManager,
|
|
345
|
+
previewManager,
|
|
341
346
|
authManager,
|
|
342
347
|
clientConnectionManager,
|
|
343
348
|
pluginChannel,
|
|
@@ -361,13 +366,7 @@ async function main() {
|
|
|
361
366
|
throw new Error("No listeners started");
|
|
362
367
|
}
|
|
363
368
|
const remoteStart = httpsStart ?? httpStart;
|
|
364
|
-
const localProtocol = httpStart ? "http" : "https";
|
|
365
369
|
const remoteProtocol = httpsStart ? "https" : "http";
|
|
366
|
-
// Use an explicit IPv4 loopback address for the "local" URL.
|
|
367
|
-
// On macOS, `localhost` often resolves to ::1 first, and it is possible to have
|
|
368
|
-
// another instance bound on IPv6 while this instance binds IPv4 (or vice versa),
|
|
369
|
-
// which can lead clients to talk to the wrong process.
|
|
370
|
-
const localUrl = `${localProtocol}://127.0.0.1:${localStart.port}`;
|
|
371
370
|
let remoteUrl;
|
|
372
371
|
let remoteAddresses = [];
|
|
373
372
|
if (remoteStart) {
|
|
@@ -387,6 +386,14 @@ async function main() {
|
|
|
387
386
|
remoteUrl = `${remoteProtocol}://${remoteHost}:${remoteStart.port}`;
|
|
388
387
|
}
|
|
389
388
|
}
|
|
389
|
+
// Prefer an explicit IPv4 loopback address only when one of the bound listeners
|
|
390
|
+
// accepts loopback. Concrete LAN bindings do not, so plugins need the reachable
|
|
391
|
+
// bound/listener URL instead of an unreachable 127.0.0.1 URL.
|
|
392
|
+
const localUrl = resolvePluginBaseUrl({
|
|
393
|
+
httpStart: httpStart ? { protocol: "http", bindHost: httpBindHost, port: httpStart.port } : null,
|
|
394
|
+
httpsStart: httpsStart ? { protocol: "https", bindHost: httpsBindHost, port: httpsStart.port } : null,
|
|
395
|
+
remoteUrl,
|
|
396
|
+
});
|
|
390
397
|
serverMeta.localUrl = localUrl;
|
|
391
398
|
serverMeta.localPort = localStart.port;
|
|
392
399
|
serverMeta.remoteUrl = remoteUrl;
|
package/dist/launcher.js
CHANGED
|
@@ -119,11 +119,19 @@ function buildLinuxCandidates() {
|
|
|
119
119
|
"chromium",
|
|
120
120
|
"chromium-browser",
|
|
121
121
|
"brave-browser",
|
|
122
|
+
"brave-browser-stable",
|
|
123
|
+
"brave",
|
|
124
|
+
"/snap/bin/brave",
|
|
122
125
|
"microsoft-edge",
|
|
123
126
|
"microsoft-edge-stable",
|
|
124
127
|
"vivaldi",
|
|
128
|
+
"vivaldi-stable",
|
|
129
|
+
"/snap/bin/vivaldi",
|
|
130
|
+
];
|
|
131
|
+
return [
|
|
132
|
+
...names.map((name) => ({ name, command: name, args: APP_ARGS })),
|
|
133
|
+
{ name: "xdg-open", command: "xdg-open", args: (url) => [url] },
|
|
125
134
|
];
|
|
126
|
-
return names.map((name) => ({ name, command: name, args: APP_ARGS }));
|
|
127
135
|
}
|
|
128
136
|
function buildMacManualExamples(url) {
|
|
129
137
|
return [
|
|
@@ -144,6 +152,9 @@ function buildLinuxManualExamples(url) {
|
|
|
144
152
|
`google-chrome --app="${url}" --new-window`,
|
|
145
153
|
`chromium --app="${url}" --new-window`,
|
|
146
154
|
`brave-browser --app="${url}" --new-window`,
|
|
155
|
+
`brave-browser-stable --app="${url}" --new-window`,
|
|
147
156
|
`microsoft-edge --app="${url}" --new-window`,
|
|
157
|
+
`vivaldi-stable --app="${url}" --new-window`,
|
|
158
|
+
`xdg-open "${url}"`,
|
|
148
159
|
];
|
|
149
160
|
}
|
|
Binary file
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
4
|
+
import { createLogger } from "./logger";
|
|
5
|
+
const log = createLogger({ component: "opencode-plugin" });
|
|
6
|
+
const pluginPackageName = "@codenomad/codenomad-opencode-plugin";
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const resourcesPath = process.resourcesPath;
|
|
10
|
+
const devPluginEntry = path.resolve(__dirname, "../../opencode-plugin/plugin/codenomad.ts");
|
|
11
|
+
const prodPluginDirs = [
|
|
12
|
+
resourcesPath ? path.resolve(resourcesPath, "opencode-plugin") : undefined,
|
|
13
|
+
resourcesPath ? path.resolve(resourcesPath, "server/dist/opencode-plugin") : undefined,
|
|
14
|
+
path.resolve(__dirname, "opencode-plugin"),
|
|
15
|
+
].filter((dir) => Boolean(dir));
|
|
16
|
+
const isDevBuild = Boolean(process.env.CODENOMAD_DEV ??
|
|
17
|
+
process.env.CLI_UI_DEV_SERVER ??
|
|
18
|
+
process.env.VITE_DEV_SERVER_URL ??
|
|
19
|
+
process.env.ELECTRON_RENDERER_URL);
|
|
20
|
+
const isSourceRun = path.basename(__dirname) === "src" && existsSync(devPluginEntry);
|
|
21
|
+
export function getCodeNomadPluginUrl() {
|
|
22
|
+
if (isDevBuild || isSourceRun) {
|
|
23
|
+
if (!existsSync(devPluginEntry)) {
|
|
24
|
+
throw new Error(`CodeNomad OpenCode plugin entry missing at ${devPluginEntry}`);
|
|
25
|
+
}
|
|
26
|
+
log.debug({ pluginEntry: devPluginEntry }, "Using OpenCode plugin source directly (dev mode)");
|
|
27
|
+
return pathToFileURL(devPluginEntry).href;
|
|
28
|
+
}
|
|
29
|
+
for (const dir of prodPluginDirs) {
|
|
30
|
+
const tarball = findPluginTarball(dir);
|
|
31
|
+
if (tarball) {
|
|
32
|
+
return toNpmFileSpecifier(tarball);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`CodeNomad OpenCode plugin package missing in ${prodPluginDirs.join(", ")}`);
|
|
36
|
+
}
|
|
37
|
+
export function buildOpencodeConfigContent(existingContent, pluginUrl) {
|
|
38
|
+
const config = existingContent?.trim() ? parseJsoncObject(existingContent) : {};
|
|
39
|
+
const existingPlugins = normalizePluginEntries(config.plugin);
|
|
40
|
+
if (!existingPlugins.includes(pluginUrl)) {
|
|
41
|
+
existingPlugins.push(pluginUrl);
|
|
42
|
+
}
|
|
43
|
+
return JSON.stringify({
|
|
44
|
+
"$schema": typeof config["$schema"] === "string" ? config["$schema"] : "https://opencode.ai/config.json",
|
|
45
|
+
...config,
|
|
46
|
+
plugin: existingPlugins,
|
|
47
|
+
}, null, 2);
|
|
48
|
+
}
|
|
49
|
+
export function resolveExistingOpencodeConfigContent(userEnvironment) {
|
|
50
|
+
const userValue = normalizeConfigContentValue(userEnvironment.OPENCODE_CONFIG_CONTENT);
|
|
51
|
+
if (userValue) {
|
|
52
|
+
return userValue;
|
|
53
|
+
}
|
|
54
|
+
return normalizeConfigContentValue(process.env.OPENCODE_CONFIG_CONTENT);
|
|
55
|
+
}
|
|
56
|
+
function toNpmFileSpecifier(filePath) {
|
|
57
|
+
return `${pluginPackageName}@file:${filePath.replace(/\\/g, "/")}`;
|
|
58
|
+
}
|
|
59
|
+
function findPluginTarball(dir) {
|
|
60
|
+
if (!existsSync(dir)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const tarballs = readdirSync(dir)
|
|
64
|
+
.filter((name) => name.endsWith(".tgz"))
|
|
65
|
+
.sort();
|
|
66
|
+
return tarballs.length > 0 ? path.resolve(dir, tarballs[tarballs.length - 1]) : null;
|
|
67
|
+
}
|
|
68
|
+
function normalizeConfigContentValue(value) {
|
|
69
|
+
return typeof value === "string" && value.trim().length > 0 ? value : undefined;
|
|
70
|
+
}
|
|
71
|
+
function parseJsoncObject(content) {
|
|
72
|
+
try {
|
|
73
|
+
const parsed = JSON.parse(stripJsonc(content));
|
|
74
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
75
|
+
throw new Error("OPENCODE_CONFIG_CONTENT must be a JSON object");
|
|
76
|
+
}
|
|
77
|
+
return parsed;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
81
|
+
throw new Error(`Failed to parse OPENCODE_CONFIG_CONTENT: ${reason}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function normalizePluginEntries(value) {
|
|
85
|
+
if (value === undefined) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
if (typeof value === "string") {
|
|
89
|
+
return [value];
|
|
90
|
+
}
|
|
91
|
+
if (Array.isArray(value) && value.every((item) => typeof item === "string")) {
|
|
92
|
+
return [...value];
|
|
93
|
+
}
|
|
94
|
+
throw new Error("OPENCODE_CONFIG_CONTENT plugin field must be a string or string array");
|
|
95
|
+
}
|
|
96
|
+
function stripJsonc(input) {
|
|
97
|
+
let output = "";
|
|
98
|
+
let inString = false;
|
|
99
|
+
let escape = false;
|
|
100
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
101
|
+
const char = input[index];
|
|
102
|
+
const next = input[index + 1];
|
|
103
|
+
if (escape) {
|
|
104
|
+
output += char;
|
|
105
|
+
escape = false;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (char === "\\" && inString) {
|
|
109
|
+
output += char;
|
|
110
|
+
escape = true;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (char === '"') {
|
|
114
|
+
output += char;
|
|
115
|
+
inString = !inString;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (!inString && char === "/" && next === "/") {
|
|
119
|
+
while (index < input.length && input[index] !== "\n") {
|
|
120
|
+
index += 1;
|
|
121
|
+
}
|
|
122
|
+
output += "\n";
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (!inString && char === "/" && next === "*") {
|
|
126
|
+
index += 2;
|
|
127
|
+
while (index < input.length && !(input[index] === "*" && input[index + 1] === "/")) {
|
|
128
|
+
output += input[index] === "\n" ? "\n" : "";
|
|
129
|
+
index += 1;
|
|
130
|
+
}
|
|
131
|
+
index += 1;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (!inString && char === ",") {
|
|
135
|
+
let lookahead = index + 1;
|
|
136
|
+
while (lookahead < input.length && /\s/.test(input[lookahead])) {
|
|
137
|
+
lookahead += 1;
|
|
138
|
+
}
|
|
139
|
+
if (input[lookahead] === "}" || input[lookahead] === "]") {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
output += char;
|
|
144
|
+
}
|
|
145
|
+
return output;
|
|
146
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { buildOpencodeConfigContent } from "./opencode-plugin";
|
|
4
|
+
describe("buildOpencodeConfigContent", () => {
|
|
5
|
+
it("creates config content with the CodeNomad plugin", () => {
|
|
6
|
+
const content = buildOpencodeConfigContent(undefined, "file:///plugin.tgz");
|
|
7
|
+
assert.deepEqual(JSON.parse(content), {
|
|
8
|
+
"$schema": "https://opencode.ai/config.json",
|
|
9
|
+
plugin: ["file:///plugin.tgz"],
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
it("merges with existing JSONC content", () => {
|
|
13
|
+
const content = buildOpencodeConfigContent(`{
|
|
14
|
+
// user plugin
|
|
15
|
+
"plugin": ["npm:user-plugin",],
|
|
16
|
+
"model": "test-model",
|
|
17
|
+
}`, "file:///plugin.tgz");
|
|
18
|
+
assert.deepEqual(JSON.parse(content), {
|
|
19
|
+
"$schema": "https://opencode.ai/config.json",
|
|
20
|
+
plugin: ["npm:user-plugin", "file:///plugin.tgz"],
|
|
21
|
+
model: "test-model",
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
it("does not duplicate the CodeNomad plugin", () => {
|
|
25
|
+
const content = buildOpencodeConfigContent('{"plugin":["file:///plugin.tgz"]}', "file:///plugin.tgz");
|
|
26
|
+
assert.deepEqual(JSON.parse(content).plugin, ["file:///plugin.tgz"]);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { randomUUID } from "crypto";
|
|
2
|
+
export class PreviewManager {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.previews = new Map();
|
|
5
|
+
}
|
|
6
|
+
create(sessionId, rawUrl) {
|
|
7
|
+
const target = this.normalizeTargetUrl(rawUrl);
|
|
8
|
+
const token = randomUUID();
|
|
9
|
+
const record = {
|
|
10
|
+
token,
|
|
11
|
+
sessionId,
|
|
12
|
+
target,
|
|
13
|
+
createdAt: new Date().toISOString(),
|
|
14
|
+
};
|
|
15
|
+
this.previews.set(token, record);
|
|
16
|
+
return this.toPreviewSession(record);
|
|
17
|
+
}
|
|
18
|
+
get(token) {
|
|
19
|
+
const record = this.previews.get(token);
|
|
20
|
+
return record ? this.toPreviewSession(record) : undefined;
|
|
21
|
+
}
|
|
22
|
+
delete(token) {
|
|
23
|
+
return this.previews.delete(token);
|
|
24
|
+
}
|
|
25
|
+
buildTargetUrl(token, incomingPath, search = "") {
|
|
26
|
+
const record = this.previews.get(token);
|
|
27
|
+
if (!record)
|
|
28
|
+
return undefined;
|
|
29
|
+
const publicBase = this.buildProxyBasePath(token);
|
|
30
|
+
let targetPath = incomingPath.startsWith(publicBase) ? incomingPath.slice(publicBase.length) : incomingPath;
|
|
31
|
+
if (!targetPath || targetPath === "/") {
|
|
32
|
+
targetPath = record.target.pathname || "/";
|
|
33
|
+
}
|
|
34
|
+
else if (!targetPath.startsWith("/")) {
|
|
35
|
+
targetPath = `/${targetPath}`;
|
|
36
|
+
}
|
|
37
|
+
return new URL(`${targetPath}${search}`, record.target.origin);
|
|
38
|
+
}
|
|
39
|
+
buildProxyBasePath(token) {
|
|
40
|
+
return `/previews/${encodeURIComponent(token)}`;
|
|
41
|
+
}
|
|
42
|
+
normalizeTargetUrl(rawUrl) {
|
|
43
|
+
const trimmed = rawUrl.trim();
|
|
44
|
+
const withProtocol = /^[a-z][a-z0-9+.-]*:/i.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
45
|
+
const target = new URL(withProtocol);
|
|
46
|
+
if (target.protocol !== "http:" && target.protocol !== "https:") {
|
|
47
|
+
throw new Error("Preview URL must use HTTP or HTTPS");
|
|
48
|
+
}
|
|
49
|
+
if (target.username || target.password) {
|
|
50
|
+
throw new Error("Preview URL cannot include credentials");
|
|
51
|
+
}
|
|
52
|
+
return target;
|
|
53
|
+
}
|
|
54
|
+
toPreviewSession(record) {
|
|
55
|
+
return {
|
|
56
|
+
token: record.token,
|
|
57
|
+
sessionId: record.sessionId,
|
|
58
|
+
targetUrl: record.target.toString(),
|
|
59
|
+
proxyUrl: `${this.buildProxyBasePath(record.token)}${record.target.pathname}${record.target.search}${record.target.hash}`,
|
|
60
|
+
createdAt: record.createdAt,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { resolvePluginBaseUrl } from "../listener-base-url";
|
|
4
|
+
describe("resolvePluginBaseUrl", () => {
|
|
5
|
+
it("keeps loopback URLs for default local listeners", () => {
|
|
6
|
+
assert.equal(resolvePluginBaseUrl({
|
|
7
|
+
httpsStart: { protocol: "https", bindHost: "127.0.0.1", port: 9898 },
|
|
8
|
+
remoteUrl: "https://localhost:9898",
|
|
9
|
+
}), "https://127.0.0.1:9898");
|
|
10
|
+
});
|
|
11
|
+
it("uses the concrete LAN listener when no loopback listener exists", () => {
|
|
12
|
+
assert.equal(resolvePluginBaseUrl({
|
|
13
|
+
httpsStart: { protocol: "https", bindHost: "192.168.1.25", port: 9898 },
|
|
14
|
+
remoteUrl: "https://192.168.1.25:9898",
|
|
15
|
+
}), "https://192.168.1.25:9898");
|
|
16
|
+
});
|
|
17
|
+
it("prefers loopback for wildcard listeners because 0.0.0.0 accepts loopback", () => {
|
|
18
|
+
assert.equal(resolvePluginBaseUrl({
|
|
19
|
+
httpsStart: { protocol: "https", bindHost: "0.0.0.0", port: 9898 },
|
|
20
|
+
remoteUrl: "https://192.168.1.25:9898",
|
|
21
|
+
}), "https://127.0.0.1:9898");
|
|
22
|
+
});
|
|
23
|
+
it("keeps loopback HTTP when remote HTTPS also exists", () => {
|
|
24
|
+
assert.equal(resolvePluginBaseUrl({
|
|
25
|
+
httpStart: { protocol: "http", bindHost: "127.0.0.1", port: 9899 },
|
|
26
|
+
httpsStart: { protocol: "https", bindHost: "192.168.1.25", port: 9898 },
|
|
27
|
+
remoteUrl: "https://192.168.1.25:9898",
|
|
28
|
+
}), "http://127.0.0.1:9899");
|
|
29
|
+
});
|
|
30
|
+
});
|