@neuralnomads/codenomad 0.10.3 → 0.11.4
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 +48 -1
- package/dist/config/location.js +57 -0
- package/dist/config/schema.js +27 -5
- package/dist/events/bus.js +4 -4
- package/dist/index.js +30 -20
- package/dist/opencode-config/package.json +1 -1
- package/dist/releases/dev-release-monitor.js +75 -0
- package/dist/releases/release-monitor.js +9 -2
- package/dist/server/http-server.js +121 -11
- package/dist/server/routes/auth-pages/login.html +2 -1
- package/dist/server/routes/auth.js +15 -1
- package/dist/server/routes/settings.js +68 -0
- package/dist/settings/binaries.js +37 -0
- package/dist/settings/merge-patch.js +33 -0
- package/dist/settings/migrate.js +233 -0
- package/dist/settings/service.js +39 -0
- package/dist/settings/yaml-doc-store.js +96 -0
- package/dist/workspaces/manager.js +22 -41
- package/dist/workspaces/runtime.js +42 -0
- package/package.json +2 -1
- package/public/assets/index-BiJPCeIN.js +1 -0
- package/public/assets/index-YOE16xUu.css +1 -0
- package/public/assets/{loading-C4tjRBOI.js → loading-VAPQCa2j.js} +1 -1
- package/public/assets/main-BY3Fy6Si.js +250 -0
- package/public/index.html +3 -3
- package/public/loading.html +3 -3
- package/public/sw.js +1 -1
- package/public/ui-version.json +1 -1
- package/dist/config/binaries.js +0 -148
- package/dist/config/store.js +0 -69
- package/dist/server/routes/config.js +0 -44
- package/public/assets/index-ByYHPepg.css +0 -1
- package/public/assets/index-qAVOl_b1.js +0 -1
- package/public/assets/main-D-G7fZxM.js +0 -188
package/README.md
CHANGED
|
@@ -5,18 +5,21 @@
|
|
|
5
5
|
## Features & Capabilities
|
|
6
6
|
|
|
7
7
|
### 🌍 Deployment Freedom
|
|
8
|
+
|
|
8
9
|
- **Remote Access**: Host CodeNomad on a powerful workstation and access it from your lightweight laptop.
|
|
9
10
|
- **Code Anywhere**: Tunnel in via VPN or SSH to code securely from coffee shops or while traveling.
|
|
10
11
|
- **Multi-Device**: The responsive web client works on tablets and iPads, turning any screen into a dev terminal.
|
|
11
12
|
- **Always-On**: Run as a background service so your sessions are always ready when you connect.
|
|
12
13
|
|
|
13
14
|
### ⚡️ Workspace Power
|
|
15
|
+
|
|
14
16
|
- **Multi-Instance**: Juggle multiple OpenCode sessions side-by-side with per-instance tabs.
|
|
15
17
|
- **Long-Context Native**: Scroll through massive transcripts without hitches.
|
|
16
18
|
- **Deep Task Awareness**: Monitor background tasks and child sessions without losing your flow.
|
|
17
19
|
- **Command Palette**: A single, global palette to jump tabs, launch tools, and fire shortcuts.
|
|
18
20
|
|
|
19
21
|
## Prerequisites
|
|
22
|
+
|
|
20
23
|
- **OpenCode**: `opencode` must be installed and configured on your system.
|
|
21
24
|
- Node.js 18+ and npm (for running or building from source).
|
|
22
25
|
- A workspace folder on disk you want to serve.
|
|
@@ -25,18 +28,26 @@
|
|
|
25
28
|
## Usage
|
|
26
29
|
|
|
27
30
|
### Run via npx (Recommended)
|
|
31
|
+
|
|
28
32
|
You can run CodeNomad directly without installing it:
|
|
29
33
|
|
|
30
34
|
```sh
|
|
31
35
|
npx @neuralnomads/codenomad --launch
|
|
32
36
|
```
|
|
33
37
|
|
|
38
|
+
To list all CLI options:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npx @neuralnomads/codenomad --help
|
|
42
|
+
```
|
|
43
|
+
|
|
34
44
|
On startup, CodeNomad prints two URLs:
|
|
35
45
|
|
|
36
46
|
- `Local Connection URL : ...` (used by desktop shells)
|
|
37
47
|
- `Remote Connection URL : ...` (used by browsers/other machines when remote access is enabled)
|
|
38
48
|
|
|
39
49
|
### Install Globally
|
|
50
|
+
|
|
40
51
|
Or install it globally to use the `codenomad` command:
|
|
41
52
|
|
|
42
53
|
```sh
|
|
@@ -44,7 +55,19 @@ npm install -g @neuralnomads/codenomad
|
|
|
44
55
|
codenomad --launch
|
|
45
56
|
```
|
|
46
57
|
|
|
58
|
+
### Install Locally (per-project)
|
|
59
|
+
|
|
60
|
+
If you prefer to install CodeNomad into a project and run the local binary:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
npm install @neuralnomads/codenomad
|
|
64
|
+
npx codenomad --launch
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
(`npx codenomad ...` will use `./node_modules/.bin/codenomad` when present.)
|
|
68
|
+
|
|
47
69
|
### Common Flags
|
|
70
|
+
|
|
48
71
|
You can configure the server using flags or environment variables:
|
|
49
72
|
|
|
50
73
|
| Flag | Env Variable | Description |
|
|
@@ -58,15 +81,36 @@ You can configure the server using flags or environment variables:
|
|
|
58
81
|
| `--tls-ca <path>` | `CLI_TLS_CA` | Optional CA chain/bundle (PEM) |
|
|
59
82
|
| `--tlsSANs <list>` | `CLI_TLS_SANS` | Additional TLS SANs (comma-separated) |
|
|
60
83
|
| `--host <addr>` | `CLI_HOST` | Interface to bind (default 127.0.0.1) |
|
|
61
|
-
| `--workspace-root <path>` | `CLI_WORKSPACE_ROOT` |
|
|
84
|
+
| `--workspace-root <path>` | `CLI_WORKSPACE_ROOT` | Restricts the root path where new workspaces can be opened. Git worktrees are created in `.codenomad/worktrees` inside the project folder. |
|
|
62
85
|
| `--unrestricted-root` | `CLI_UNRESTRICTED_ROOT` | Allow full-filesystem browsing |
|
|
63
86
|
| `--config <path>` | `CLI_CONFIG` | Config file location |
|
|
64
87
|
| `--launch` | `CLI_LAUNCH` | Open the UI in a Chromium-based browser |
|
|
65
88
|
| `--log-level <level>` | `CLI_LOG_LEVEL` | Logging level (trace, debug, info, warn, error) |
|
|
89
|
+
| `--log-destination <path>` | `CLI_LOG_DESTINATION` | Log destination file (defaults to stdout) |
|
|
66
90
|
| `--username <username>` | `CODENOMAD_SERVER_USERNAME` | Username for CodeNomad's internal auth (default `codenomad`) |
|
|
67
91
|
| `--password <password>` | `CODENOMAD_SERVER_PASSWORD` | Password for CodeNomad's internal auth |
|
|
68
92
|
| `--generate-token` | `CODENOMAD_GENERATE_TOKEN` | Emit a one-time local bootstrap token for desktop flows |
|
|
69
93
|
| `--dangerously-skip-auth` | `CODENOMAD_SKIP_AUTH` | Disable CodeNomad's internal auth (use only behind a trusted perimeter) |
|
|
94
|
+
| `--ui-dir <path>` | `CLI_UI_DIR` | Directory containing the built UI bundle |
|
|
95
|
+
| `--ui-dev-server <url>` | `CLI_UI_DEV_SERVER` | Proxy UI requests to a running dev server (requires `--https=false --http=true`) |
|
|
96
|
+
| `--ui-no-update` | `CLI_UI_NO_UPDATE` | Disable remote UI updates |
|
|
97
|
+
| `--ui-auto-update <enabled>` | `CLI_UI_AUTO_UPDATE` | Enable remote UI updates (`true` |
|
|
98
|
+
| `--ui-manifest-url <url>` | `CLI_UI_MANIFEST_URL` | Remote UI manifest URL |
|
|
99
|
+
|
|
100
|
+
### Dev Releases (Advanced)
|
|
101
|
+
|
|
102
|
+
If you want the latest bleeding-edge builds (published as GitHub pre-releases), use the dev package:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
npx @neuralnomads/codenomad-dev --launch
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
These environment variables control how CodeNomad checks for dev updates:
|
|
109
|
+
|
|
110
|
+
| Env Variable | Description |
|
|
111
|
+
|-------------|-------------|
|
|
112
|
+
| `CODENOMAD_UPDATE_CHANNEL` | Update channel (use `dev` to enable dev build update checks) |
|
|
113
|
+
| `CODENOMAD_GITHUB_REPO` | GitHub repo used for dev release checks (default `NeuralNomadsAI/CodeNomad`) |
|
|
70
114
|
|
|
71
115
|
### HTTP vs HTTPS
|
|
72
116
|
|
|
@@ -105,12 +149,14 @@ codenomad --tlsSANs "localhost,127.0.0.1,my-hostname,192.168.1.10"
|
|
|
105
149
|
```
|
|
106
150
|
|
|
107
151
|
### Authentication
|
|
152
|
+
|
|
108
153
|
- Default behavior: CodeNomad requires a login (username/password) and stores a session cookie in the browser.
|
|
109
154
|
- `--dangerously-skip-auth` / `CODENOMAD_SKIP_AUTH=true` disables the login prompt and treats all requests as authenticated.
|
|
110
155
|
Use this only when access is already protected by another layer (SSO proxy, VPN, Coder workspace auth, etc.).
|
|
111
156
|
If you bind to `0.0.0.0` while skipping auth, anyone who can reach the port can access the API.
|
|
112
157
|
|
|
113
158
|
### Progressive Web App (PWA)
|
|
159
|
+
|
|
114
160
|
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.
|
|
115
161
|
|
|
116
162
|
1. Open the CodeNomad UI in a Chromium-based browser (Chrome, Edge, Brave, etc.).
|
|
@@ -122,5 +168,6 @@ When running as a server CodeNomad can also be installed as a PWA from any suppo
|
|
|
122
168
|
> If you host CodeNomad on a remote machine, use HTTPS. Self-signed certificates generally won't work unless they are explicitly trusted by the device/browser (e.g., via a custom CA).
|
|
123
169
|
|
|
124
170
|
### Data Storage
|
|
171
|
+
|
|
125
172
|
- **Config**: `~/.config/codenomad/config.json`
|
|
126
173
|
- **Instance Data**: `~/.config/codenomad/instances` (chat history, etc.)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import os from "os";
|
|
2
|
+
import path from "path";
|
|
3
|
+
function resolvePath(inputPath) {
|
|
4
|
+
if (inputPath.startsWith("~/")) {
|
|
5
|
+
return path.join(os.homedir(), inputPath.slice(2));
|
|
6
|
+
}
|
|
7
|
+
return path.resolve(inputPath);
|
|
8
|
+
}
|
|
9
|
+
function isYamlPath(filePath) {
|
|
10
|
+
const lower = filePath.toLowerCase();
|
|
11
|
+
return lower.endsWith(".yaml") || lower.endsWith(".yml");
|
|
12
|
+
}
|
|
13
|
+
function isJsonPath(filePath) {
|
|
14
|
+
return filePath.toLowerCase().endsWith(".json");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve CodeNomad's config location into a stable base directory + derived file paths.
|
|
18
|
+
*
|
|
19
|
+
* Supported inputs:
|
|
20
|
+
* - Directory: "~/.config/codenomad"
|
|
21
|
+
* - YAML file: "~/.config/codenomad/config.yaml" (or any *.yml/*.yaml)
|
|
22
|
+
* - Legacy JSON file: "~/.config/codenomad/config.json"
|
|
23
|
+
*/
|
|
24
|
+
export function resolveConfigLocation(raw) {
|
|
25
|
+
const trimmed = (raw ?? "").trim();
|
|
26
|
+
const fallback = "~/.config/codenomad/config.json";
|
|
27
|
+
const input = trimmed.length > 0 ? trimmed : fallback;
|
|
28
|
+
const resolvedInput = resolvePath(input);
|
|
29
|
+
if (isYamlPath(resolvedInput)) {
|
|
30
|
+
const baseDir = path.dirname(resolvedInput);
|
|
31
|
+
return {
|
|
32
|
+
baseDir,
|
|
33
|
+
configYamlPath: resolvedInput,
|
|
34
|
+
stateYamlPath: path.join(baseDir, "state.yaml"),
|
|
35
|
+
legacyJsonPath: path.join(baseDir, "config.json"),
|
|
36
|
+
instancesDir: path.join(baseDir, "instances"),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (isJsonPath(resolvedInput)) {
|
|
40
|
+
const baseDir = path.dirname(resolvedInput);
|
|
41
|
+
return {
|
|
42
|
+
baseDir,
|
|
43
|
+
configYamlPath: path.join(baseDir, "config.yaml"),
|
|
44
|
+
stateYamlPath: path.join(baseDir, "state.yaml"),
|
|
45
|
+
legacyJsonPath: resolvedInput,
|
|
46
|
+
instancesDir: path.join(baseDir, "instances"),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const baseDir = resolvedInput;
|
|
50
|
+
return {
|
|
51
|
+
baseDir,
|
|
52
|
+
configYamlPath: path.join(baseDir, "config.yaml"),
|
|
53
|
+
stateYamlPath: path.join(baseDir, "state.yaml"),
|
|
54
|
+
legacyJsonPath: path.join(baseDir, "config.json"),
|
|
55
|
+
instancesDir: path.join(baseDir, "instances"),
|
|
56
|
+
};
|
|
57
|
+
}
|
package/dist/config/schema.js
CHANGED
|
@@ -5,7 +5,8 @@ const ModelPreferenceSchema = z.object({
|
|
|
5
5
|
});
|
|
6
6
|
const AgentModelSelectionSchema = z.record(z.string(), ModelPreferenceSchema);
|
|
7
7
|
const AgentModelSelectionsSchema = z.record(z.string(), AgentModelSelectionSchema);
|
|
8
|
-
const PreferencesSchema = z
|
|
8
|
+
const PreferencesSchema = z
|
|
9
|
+
.object({
|
|
9
10
|
showThinkingBlocks: z.boolean().default(false),
|
|
10
11
|
thinkingBlocksExpansion: z.enum(["expanded", "collapsed"]).default("expanded"),
|
|
11
12
|
showTimelineTools: z.boolean().default(true),
|
|
@@ -27,7 +28,9 @@ const PreferencesSchema = z.object({
|
|
|
27
28
|
osNotificationsAllowWhenVisible: z.boolean().default(false),
|
|
28
29
|
notifyOnNeedsInput: z.boolean().default(true),
|
|
29
30
|
notifyOnIdle: z.boolean().default(true),
|
|
30
|
-
})
|
|
31
|
+
})
|
|
32
|
+
// Preserve unknown preference keys so newer configs survive older binaries.
|
|
33
|
+
.passthrough();
|
|
31
34
|
const RecentFolderSchema = z.object({
|
|
32
35
|
path: z.string(),
|
|
33
36
|
lastAccessed: z.number().nonnegative(),
|
|
@@ -38,11 +41,30 @@ const OpenCodeBinarySchema = z.object({
|
|
|
38
41
|
lastUsed: z.number().nonnegative(),
|
|
39
42
|
label: z.string().optional(),
|
|
40
43
|
});
|
|
41
|
-
const ConfigFileSchema = z
|
|
44
|
+
const ConfigFileSchema = z
|
|
45
|
+
.object({
|
|
42
46
|
preferences: PreferencesSchema.default({}),
|
|
43
47
|
recentFolders: z.array(RecentFolderSchema).default([]),
|
|
44
48
|
opencodeBinaries: z.array(OpenCodeBinarySchema).default([]),
|
|
45
49
|
theme: z.enum(["light", "dark", "system"]).optional(),
|
|
46
|
-
})
|
|
50
|
+
})
|
|
51
|
+
// Preserve unknown top-level keys so optional future features survive downgrades.
|
|
52
|
+
.passthrough();
|
|
53
|
+
// On-disk config.yaml only stores stable configuration (not volatile state like recent folders).
|
|
54
|
+
const ConfigYamlSchema = z
|
|
55
|
+
.object({
|
|
56
|
+
preferences: PreferencesSchema.default({}),
|
|
57
|
+
opencodeBinaries: z.array(OpenCodeBinarySchema).default([]),
|
|
58
|
+
theme: z.enum(["light", "dark", "system"]).optional(),
|
|
59
|
+
})
|
|
60
|
+
.passthrough();
|
|
61
|
+
// On-disk state.yaml stores server-scoped mutable state (per-server, not per-client).
|
|
62
|
+
const StateFileSchema = z
|
|
63
|
+
.object({
|
|
64
|
+
recentFolders: z.array(RecentFolderSchema).default([]),
|
|
65
|
+
})
|
|
66
|
+
.passthrough();
|
|
47
67
|
const DEFAULT_CONFIG = ConfigFileSchema.parse({});
|
|
48
|
-
|
|
68
|
+
const DEFAULT_CONFIG_YAML = ConfigYamlSchema.parse({});
|
|
69
|
+
const DEFAULT_STATE = StateFileSchema.parse({});
|
|
70
|
+
export { ModelPreferenceSchema, AgentModelSelectionSchema, AgentModelSelectionsSchema, PreferencesSchema, RecentFolderSchema, OpenCodeBinarySchema, ConfigFileSchema, ConfigYamlSchema, StateFileSchema, DEFAULT_CONFIG, DEFAULT_CONFIG_YAML, DEFAULT_STATE, };
|
package/dist/events/bus.js
CHANGED
|
@@ -20,8 +20,8 @@ export class EventBus extends EventEmitter {
|
|
|
20
20
|
this.on("workspace.error", handler);
|
|
21
21
|
this.on("workspace.stopped", handler);
|
|
22
22
|
this.on("workspace.log", handler);
|
|
23
|
-
this.on("
|
|
24
|
-
this.on("
|
|
23
|
+
this.on("storage.configChanged", handler);
|
|
24
|
+
this.on("storage.stateChanged", handler);
|
|
25
25
|
this.on("instance.dataChanged", handler);
|
|
26
26
|
this.on("instance.event", handler);
|
|
27
27
|
this.on("instance.eventStatus", handler);
|
|
@@ -31,8 +31,8 @@ export class EventBus extends EventEmitter {
|
|
|
31
31
|
this.off("workspace.error", handler);
|
|
32
32
|
this.off("workspace.stopped", handler);
|
|
33
33
|
this.off("workspace.log", handler);
|
|
34
|
-
this.off("
|
|
35
|
-
this.off("
|
|
34
|
+
this.off("storage.configChanged", handler);
|
|
35
|
+
this.off("storage.stateChanged", handler);
|
|
36
36
|
this.off("instance.dataChanged", handler);
|
|
37
37
|
this.off("instance.event", handler);
|
|
38
38
|
this.off("instance.eventStatus", handler);
|
package/dist/index.js
CHANGED
|
@@ -8,8 +8,9 @@ import { fileURLToPath } from "url";
|
|
|
8
8
|
import { createRequire } from "module";
|
|
9
9
|
import { createHttpServer } from "./server/http-server";
|
|
10
10
|
import { WorkspaceManager } from "./workspaces/manager";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { resolveConfigLocation } from "./config/location";
|
|
12
|
+
import { SettingsService } from "./settings/service";
|
|
13
|
+
import { BinaryResolver } from "./settings/binaries";
|
|
13
14
|
import { FileSystemBrowser } from "./filesystem/browser";
|
|
14
15
|
import { EventBus } from "./events/bus";
|
|
15
16
|
import { InstanceStore } from "./storage/instance-store";
|
|
@@ -20,6 +21,7 @@ import { resolveUi } from "./ui/remote-ui";
|
|
|
20
21
|
import { AuthManager, BOOTSTRAP_TOKEN_STDOUT_PREFIX, DEFAULT_AUTH_USERNAME } from "./auth/manager";
|
|
21
22
|
import { resolveHttpsOptions } from "./server/tls";
|
|
22
23
|
import { resolveNetworkAddresses } from "./server/network-addresses";
|
|
24
|
+
import { startDevReleaseMonitor } from "./releases/dev-release-monitor";
|
|
23
25
|
const require = createRequire(import.meta.url);
|
|
24
26
|
const packageJson = require("../package.json");
|
|
25
27
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -43,7 +45,7 @@ function parseCliOptions(argv) {
|
|
|
43
45
|
.addOption(new Option("--tls-cert <path>", "TLS certificate (PEM)").env("CLI_TLS_CERT"))
|
|
44
46
|
.addOption(new Option("--tls-ca <path>", "TLS CA chain (PEM)").env("CLI_TLS_CA"))
|
|
45
47
|
.addOption(new Option("--tlsSANs <list>", "Additional TLS SANs (comma-separated)").env("CLI_TLS_SANS"))
|
|
46
|
-
.addOption(new Option("--workspace-root <path>", "
|
|
48
|
+
.addOption(new Option("--workspace-root <path>", "Restricts root path where workspaces can be opened").env("CLI_WORKSPACE_ROOT").default(process.cwd()))
|
|
47
49
|
.addOption(new Option("--root <path>").env("CLI_ROOT").hideHelp(true))
|
|
48
50
|
.addOption(new Option("--unrestricted-root", "Allow browsing the full filesystem").env("CLI_UNRESTRICTED_ROOT").default(false))
|
|
49
51
|
.addOption(new Option("--config <path>", "Path to the config file").env("CLI_CONFIG").default(DEFAULT_CONFIG_PATH))
|
|
@@ -126,12 +128,6 @@ function resolveHost(input) {
|
|
|
126
128
|
}
|
|
127
129
|
return trimmed;
|
|
128
130
|
}
|
|
129
|
-
function resolvePath(filePath) {
|
|
130
|
-
if (filePath.startsWith("~/")) {
|
|
131
|
-
return path.join(process.env.HOME ?? "", filePath.slice(2));
|
|
132
|
-
}
|
|
133
|
-
return path.resolve(filePath);
|
|
134
|
-
}
|
|
135
131
|
function programHasArg(argv, flag) {
|
|
136
132
|
return argv.includes(flag);
|
|
137
133
|
}
|
|
@@ -151,7 +147,8 @@ async function main() {
|
|
|
151
147
|
}
|
|
152
148
|
const eventBus = new EventBus(eventLogger);
|
|
153
149
|
const isLoopbackHost = (host) => host === "127.0.0.1" || host === "::1" || host.startsWith("127.");
|
|
154
|
-
const
|
|
150
|
+
const configLocation = resolveConfigLocation(options.configPath);
|
|
151
|
+
const configDir = configLocation.baseDir;
|
|
155
152
|
if ((options.tlsKeyPath && !options.tlsCertPath) || (!options.tlsKeyPath && options.tlsCertPath)) {
|
|
156
153
|
throw new InvalidArgumentError("--tls-key and --tls-cert must be provided together");
|
|
157
154
|
}
|
|
@@ -168,7 +165,7 @@ async function main() {
|
|
|
168
165
|
addresses: [],
|
|
169
166
|
};
|
|
170
167
|
const authManager = new AuthManager({
|
|
171
|
-
configPath:
|
|
168
|
+
configPath: configLocation.configYamlPath,
|
|
172
169
|
username: options.authUsername,
|
|
173
170
|
password: options.authPassword,
|
|
174
171
|
generateToken: options.generateToken,
|
|
@@ -191,19 +188,19 @@ async function main() {
|
|
|
191
188
|
logger: logger.child({ component: "tls" }),
|
|
192
189
|
});
|
|
193
190
|
const nodeExtraCaCertsPath = !options.http ? tlsResolution?.caCertPath : undefined;
|
|
194
|
-
const
|
|
195
|
-
const
|
|
191
|
+
const settings = new SettingsService(configLocation, eventBus, configLogger);
|
|
192
|
+
const binaryResolver = new BinaryResolver(settings);
|
|
196
193
|
const workspaceManager = new WorkspaceManager({
|
|
197
194
|
rootDir: options.rootDir,
|
|
198
|
-
|
|
199
|
-
|
|
195
|
+
settings,
|
|
196
|
+
binaryResolver,
|
|
200
197
|
eventBus,
|
|
201
198
|
logger: workspaceLogger,
|
|
202
199
|
getServerBaseUrl: () => serverMeta.localUrl,
|
|
203
200
|
nodeExtraCaCertsPath,
|
|
204
201
|
});
|
|
205
202
|
const fileSystemBrowser = new FileSystemBrowser({ rootDir: options.rootDir, unrestricted: options.unrestrictedRoot });
|
|
206
|
-
const instanceStore = new InstanceStore();
|
|
203
|
+
const instanceStore = new InstanceStore(configLocation.instancesDir);
|
|
207
204
|
const instanceEventBridge = new InstanceEventBridge({
|
|
208
205
|
workspaceManager,
|
|
209
206
|
eventBus,
|
|
@@ -235,6 +232,20 @@ async function main() {
|
|
|
235
232
|
latestServerUrl: uiResolution.latestServerUrl,
|
|
236
233
|
minServerVersion: uiResolution.minServerVersion,
|
|
237
234
|
};
|
|
235
|
+
const updateChannel = (process.env.CODENOMAD_UPDATE_CHANNEL ?? "").trim().toLowerCase();
|
|
236
|
+
const githubRepo = (process.env.CODENOMAD_GITHUB_REPO ?? "NeuralNomadsAI/CodeNomad").trim();
|
|
237
|
+
const isDevVersion = packageJson.version.includes("-dev.") || packageJson.version.includes("-dev-");
|
|
238
|
+
const enableDevUpdateChecks = updateChannel === "dev" || (updateChannel === "" && isDevVersion);
|
|
239
|
+
const devReleaseMonitor = enableDevUpdateChecks
|
|
240
|
+
? startDevReleaseMonitor({
|
|
241
|
+
currentVersion: packageJson.version,
|
|
242
|
+
repo: githubRepo,
|
|
243
|
+
logger: logger.child({ component: "updates" }),
|
|
244
|
+
onUpdate: (release) => {
|
|
245
|
+
serverMeta.update = release;
|
|
246
|
+
},
|
|
247
|
+
})
|
|
248
|
+
: null;
|
|
238
249
|
if (uiResolution.uiDevServerUrl && options.https) {
|
|
239
250
|
throw new InvalidArgumentError("UI dev proxy is only supported with --https=false --http=true");
|
|
240
251
|
}
|
|
@@ -257,8 +268,7 @@ async function main() {
|
|
|
257
268
|
defaultPort: options.httpPort,
|
|
258
269
|
protocol: "http",
|
|
259
270
|
workspaceManager,
|
|
260
|
-
|
|
261
|
-
binaryRegistry,
|
|
271
|
+
settings,
|
|
262
272
|
fileSystemBrowser,
|
|
263
273
|
eventBus,
|
|
264
274
|
serverMeta,
|
|
@@ -277,8 +287,7 @@ async function main() {
|
|
|
277
287
|
protocol: "https",
|
|
278
288
|
httpsOptions: tlsResolution?.httpsOptions,
|
|
279
289
|
workspaceManager,
|
|
280
|
-
|
|
281
|
-
binaryRegistry,
|
|
290
|
+
settings,
|
|
282
291
|
fileSystemBrowser,
|
|
283
292
|
eventBus,
|
|
284
293
|
serverMeta,
|
|
@@ -377,6 +386,7 @@ async function main() {
|
|
|
377
386
|
})();
|
|
378
387
|
await Promise.allSettled([shutdownWorkspaces, shutdownHttp]);
|
|
379
388
|
// no-op: remote UI manifest replaces GitHub release monitor
|
|
389
|
+
devReleaseMonitor?.stop();
|
|
380
390
|
logger.info("Exiting process");
|
|
381
391
|
process.exit(0);
|
|
382
392
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { fetch } from "undici";
|
|
2
|
+
import { compareVersionStrings, stripTagPrefix } from "./release-monitor";
|
|
3
|
+
const DEFAULT_POLL_INTERVAL_MS = 15 * 60 * 1000;
|
|
4
|
+
export function startDevReleaseMonitor(options) {
|
|
5
|
+
let stopped = false;
|
|
6
|
+
let timer = null;
|
|
7
|
+
const pollIntervalMs = Number.isFinite(options.pollIntervalMs) && (options.pollIntervalMs ?? 0) > 0
|
|
8
|
+
? options.pollIntervalMs
|
|
9
|
+
: DEFAULT_POLL_INTERVAL_MS;
|
|
10
|
+
const refresh = async () => {
|
|
11
|
+
if (stopped)
|
|
12
|
+
return;
|
|
13
|
+
try {
|
|
14
|
+
const release = await fetchLatestPrerelease({
|
|
15
|
+
repo: options.repo,
|
|
16
|
+
currentVersion: options.currentVersion,
|
|
17
|
+
});
|
|
18
|
+
options.onUpdate(release);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
options.logger.debug({ err: error }, "Failed to refresh dev prerelease information");
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
void refresh();
|
|
25
|
+
timer = setInterval(() => void refresh(), pollIntervalMs);
|
|
26
|
+
return {
|
|
27
|
+
stop() {
|
|
28
|
+
stopped = true;
|
|
29
|
+
if (timer) {
|
|
30
|
+
clearInterval(timer);
|
|
31
|
+
timer = null;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async function fetchLatestPrerelease(args) {
|
|
37
|
+
const normalizedRepo = args.repo.trim();
|
|
38
|
+
if (!/^[^/\s]+\/[^/\s]+$/.test(normalizedRepo)) {
|
|
39
|
+
throw new Error(`Invalid GitHub repo: ${args.repo}`);
|
|
40
|
+
}
|
|
41
|
+
const apiUrl = `https://api.github.com/repos/${normalizedRepo}/releases?per_page=20`;
|
|
42
|
+
const response = await fetch(apiUrl, {
|
|
43
|
+
headers: {
|
|
44
|
+
Accept: "application/vnd.github+json",
|
|
45
|
+
"User-Agent": "CodeNomad-CLI",
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
throw new Error(`GitHub releases API responded with ${response.status}`);
|
|
50
|
+
}
|
|
51
|
+
const list = (await response.json());
|
|
52
|
+
const latest = list.find((r) => r && r.prerelease === true && r.draft !== true);
|
|
53
|
+
if (!latest) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const tag = latest.tag_name || latest.name;
|
|
57
|
+
if (!tag) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const normalizedVersion = stripTagPrefix(tag);
|
|
61
|
+
if (!normalizedVersion) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
if (compareVersionStrings(normalizedVersion, args.currentVersion) <= 0) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
version: normalizedVersion,
|
|
69
|
+
tag,
|
|
70
|
+
url: latest.html_url ?? `https://github.com/${normalizedRepo}/releases/tag/${encodeURIComponent(tag)}`,
|
|
71
|
+
channel: "dev",
|
|
72
|
+
publishedAt: latest.published_at ?? latest.created_at,
|
|
73
|
+
notes: latest.body,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -20,6 +20,11 @@ export function startReleaseMonitor(options) {
|
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
+
export function compareVersionStrings(a, b) {
|
|
24
|
+
const left = parseVersion(a);
|
|
25
|
+
const right = parseVersion(b);
|
|
26
|
+
return compareVersions(left, right);
|
|
27
|
+
}
|
|
23
28
|
async function fetchLatestRelease(options) {
|
|
24
29
|
const response = await fetch(RELEASES_API_URL, {
|
|
25
30
|
headers: {
|
|
@@ -53,7 +58,7 @@ async function fetchLatestRelease(options) {
|
|
|
53
58
|
notes: json.body,
|
|
54
59
|
};
|
|
55
60
|
}
|
|
56
|
-
function stripTagPrefix(tag) {
|
|
61
|
+
export function stripTagPrefix(tag) {
|
|
57
62
|
if (!tag)
|
|
58
63
|
return null;
|
|
59
64
|
const trimmed = tag.trim();
|
|
@@ -63,7 +68,9 @@ function stripTagPrefix(tag) {
|
|
|
63
68
|
}
|
|
64
69
|
function parseVersion(value) {
|
|
65
70
|
const normalized = stripTagPrefix(value) ?? "0.0.0";
|
|
66
|
-
const
|
|
71
|
+
const dashIndex = normalized.indexOf("-");
|
|
72
|
+
const core = dashIndex >= 0 ? normalized.slice(0, dashIndex) : normalized;
|
|
73
|
+
const prerelease = dashIndex >= 0 ? normalized.slice(dashIndex + 1) : null;
|
|
67
74
|
const [major = 0, minor = 0, patch = 0] = core.split(".").map((segment) => {
|
|
68
75
|
const parsed = Number.parseInt(segment, 10);
|
|
69
76
|
return Number.isFinite(parsed) ? parsed : 0;
|