dominds 1.26.0 → 1.26.2
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 +3 -3
- package/README.zh.md +3 -3
- package/dist/bootstrap/rtws-cli.d.ts +1 -0
- package/dist/bootstrap/rtws-cli.js +8 -8
- package/dist/cli/cert.d.ts +3 -1
- package/dist/cli/cert.js +69 -20
- package/dist/cli/create.d.ts +1 -1
- package/dist/cli/create.js +1 -1
- package/dist/cli/read.js +1 -1
- package/dist/cli/tui.js +1 -1
- package/dist/cli/webui.js +15 -5
- package/dist/cli-runner.d.ts +31 -0
- package/dist/cli-runner.js +349 -0
- package/dist/cli.d.ts +0 -31
- package/dist/cli.js +540 -304
- package/dist/docs/cli-usage.md +11 -10
- package/dist/docs/cli-usage.zh.md +11 -10
- package/dist/docs/dialog-persistence.md +1 -1
- package/dist/docs/dominds-terminology.md +2 -2
- package/dist/llm/kernel-driver/drive.js +19 -14
- package/dist/runtime/driver-messages.d.ts +2 -0
- package/dist/runtime/driver-messages.js +24 -4
- package/dist/server/certificates.js +1 -1
- package/dist/server/dominds-self-update.js +33 -121
- package/dist/server/network-hosts.js +140 -38
- package/dist/server-debug.d.ts +2 -0
- package/dist/server-debug.js +79 -0
- package/dist/server.js +4 -123
- package/dist/supervisor-protocol.d.ts +15 -0
- package/dist/supervisor-protocol.js +4 -0
- package/package.json +6 -5
- package/dist/server/dominds-self-update-restart-helper.d.ts +0 -15
- package/dist/server/dominds-self-update-restart-helper.js +0 -305
|
@@ -41,9 +41,12 @@ exports.resolveDefaultLanHttpsHosts = resolveDefaultLanHttpsHosts;
|
|
|
41
41
|
const dgram = __importStar(require("node:dgram"));
|
|
42
42
|
const net = __importStar(require("node:net"));
|
|
43
43
|
const os = __importStar(require("node:os"));
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
44
|
+
const log_1 = require("../log");
|
|
45
|
+
const UDP_ROUTE_PROBE_TARGETS = {
|
|
46
|
+
ipv4: { host: '192.0.2.1', port: 443 },
|
|
47
|
+
ipv6: { host: '2001:db8::1', port: 443 },
|
|
48
|
+
};
|
|
49
|
+
const log = (0, log_1.createLogger)('network-hosts');
|
|
47
50
|
function normalizeNetworkHost(host) {
|
|
48
51
|
const trimmed = host.trim();
|
|
49
52
|
const unwrapped = trimmed.startsWith('[') && trimmed.endsWith(']') ? trimmed.slice(1, -1) : trimmed;
|
|
@@ -58,7 +61,9 @@ function isLanHttpsHost(host) {
|
|
|
58
61
|
}
|
|
59
62
|
const ipVersion = net.isIP(normalizedHost);
|
|
60
63
|
if (ipVersion === 4) {
|
|
61
|
-
return normalizedHost !== '0.0.0.0' &&
|
|
64
|
+
return (normalizedHost !== '0.0.0.0' &&
|
|
65
|
+
!normalizedHost.startsWith('127.') &&
|
|
66
|
+
!isIpv4LinkLocalHost(normalizedHost));
|
|
62
67
|
}
|
|
63
68
|
if (ipVersion === 6) {
|
|
64
69
|
const mappedIpv4 = parseIpv4MappedIpv6Host(normalizedHost);
|
|
@@ -68,7 +73,8 @@ function isLanHttpsHost(host) {
|
|
|
68
73
|
return (normalizedHost !== '::' &&
|
|
69
74
|
normalizedHost !== '0:0:0:0:0:0:0:0' &&
|
|
70
75
|
normalizedHost !== '::1' &&
|
|
71
|
-
normalizedHost !== '0:0:0:0:0:0:0:1'
|
|
76
|
+
normalizedHost !== '0:0:0:0:0:0:0:1' &&
|
|
77
|
+
!isIpv6LinkLocalHost(normalizedHost));
|
|
72
78
|
}
|
|
73
79
|
return true;
|
|
74
80
|
}
|
|
@@ -83,80 +89,167 @@ function resolveHttpUrlHostForBindHost(bindHost) {
|
|
|
83
89
|
}
|
|
84
90
|
async function resolveLanHttpsHostsForBindHost(bindHost) {
|
|
85
91
|
const normalizedHost = normalizeNetworkHost(bindHost);
|
|
92
|
+
log.debug('Resolving LAN HTTPS certificate hosts', undefined, {
|
|
93
|
+
bindHost,
|
|
94
|
+
normalizedHost,
|
|
95
|
+
});
|
|
86
96
|
if (normalizedHost === '0.0.0.0') {
|
|
87
|
-
return
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
]).filter(isLanHttpsHost);
|
|
97
|
+
return resolveBindAllLanHttpsHosts({
|
|
98
|
+
bindHost: normalizedHost,
|
|
99
|
+
families: ['ipv4'],
|
|
100
|
+
});
|
|
92
101
|
}
|
|
93
102
|
if (normalizedHost === '::' || normalizedHost === '0:0:0:0:0:0:0:0') {
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
...getNetworkInterfaceHosts('ipv4'),
|
|
99
|
-
os.hostname(),
|
|
100
|
-
]).filter(isLanHttpsHost);
|
|
103
|
+
return resolveBindAllLanHttpsHosts({
|
|
104
|
+
bindHost: normalizedHost,
|
|
105
|
+
families: ['ipv6', 'ipv4'],
|
|
106
|
+
});
|
|
101
107
|
}
|
|
102
|
-
|
|
108
|
+
const accepted = isLanHttpsHost(normalizedHost);
|
|
109
|
+
log.info('Resolved LAN HTTPS certificate hosts', undefined, {
|
|
110
|
+
bindHost,
|
|
111
|
+
normalizedHost,
|
|
112
|
+
acceptedHosts: accepted ? [normalizedHost] : [],
|
|
113
|
+
});
|
|
114
|
+
return accepted ? [normalizedHost] : [];
|
|
103
115
|
}
|
|
104
116
|
async function resolveDefaultLanHttpsHosts() {
|
|
105
117
|
return await resolveLanHttpsHostsForBindHost('::');
|
|
106
118
|
}
|
|
107
|
-
async function
|
|
108
|
-
const
|
|
119
|
+
async function resolveBindAllLanHttpsHosts(params) {
|
|
120
|
+
const rawCandidates = [];
|
|
121
|
+
for (const family of params.families) {
|
|
122
|
+
rawCandidates.push(...(await getUdpRouteLocalHosts(family)));
|
|
123
|
+
}
|
|
124
|
+
for (const family of params.families) {
|
|
125
|
+
rawCandidates.push(...getNetworkInterfaceHosts(family));
|
|
126
|
+
}
|
|
127
|
+
const hostname = os.hostname();
|
|
128
|
+
const hostnameAccepted = isDetectedHostnameCandidate(hostname);
|
|
129
|
+
log.debug('LAN HTTPS host detection hostname candidate', undefined, {
|
|
130
|
+
method: 'os.hostname',
|
|
131
|
+
host: hostname,
|
|
132
|
+
acceptedCandidate: hostnameAccepted,
|
|
133
|
+
});
|
|
134
|
+
if (hostnameAccepted) {
|
|
135
|
+
rawCandidates.push(hostname);
|
|
136
|
+
}
|
|
137
|
+
const uniqueCandidates = uniqueHosts(rawCandidates);
|
|
138
|
+
const acceptedHosts = [];
|
|
139
|
+
const rejectedHosts = [];
|
|
140
|
+
for (const host of uniqueCandidates) {
|
|
141
|
+
if (isLanHttpsHost(host)) {
|
|
142
|
+
acceptedHosts.push(host);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
rejectedHosts.push(host);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
log.info('Resolved LAN HTTPS certificate hosts', undefined, {
|
|
149
|
+
bindHost: params.bindHost,
|
|
150
|
+
families: params.families,
|
|
151
|
+
acceptedHosts,
|
|
152
|
+
});
|
|
153
|
+
log.debug('Resolved bind-all LAN HTTPS certificate host diagnostics', undefined, {
|
|
154
|
+
bindHost: params.bindHost,
|
|
155
|
+
families: params.families,
|
|
156
|
+
rawCandidates,
|
|
157
|
+
uniqueCandidates,
|
|
158
|
+
acceptedHosts,
|
|
159
|
+
rejectedHosts,
|
|
160
|
+
});
|
|
161
|
+
return acceptedHosts;
|
|
162
|
+
}
|
|
163
|
+
async function getUdpRouteLocalHosts(kind) {
|
|
164
|
+
const host = await getUdpRouteLocalHost(kind);
|
|
109
165
|
return host === null ? [] : [host];
|
|
110
166
|
}
|
|
111
|
-
async function
|
|
167
|
+
async function getUdpRouteLocalHost(kind) {
|
|
112
168
|
return await new Promise((resolve) => {
|
|
169
|
+
const target = UDP_ROUTE_PROBE_TARGETS[kind];
|
|
170
|
+
log.debug('LAN HTTPS host detection UDP route probe start', undefined, {
|
|
171
|
+
method: 'udp_route_local_address_probe',
|
|
172
|
+
family: kind,
|
|
173
|
+
targetHost: target.host,
|
|
174
|
+
targetPort: target.port,
|
|
175
|
+
});
|
|
113
176
|
const socket = dgram.createSocket(kind === 'ipv4' ? 'udp4' : 'udp6');
|
|
114
177
|
let settled = false;
|
|
115
|
-
const finish = (host) => {
|
|
178
|
+
const finish = (host, reason) => {
|
|
116
179
|
if (settled)
|
|
117
180
|
return;
|
|
118
181
|
settled = true;
|
|
119
|
-
clearTimeout(timeout);
|
|
120
182
|
socket.removeAllListeners('error');
|
|
121
183
|
socket.close();
|
|
122
|
-
|
|
184
|
+
const normalizedHost = host === null ? null : normalizeNetworkHost(host);
|
|
185
|
+
log.debug('LAN HTTPS host detection UDP route probe finish', undefined, {
|
|
186
|
+
method: 'udp_route_local_address_probe',
|
|
187
|
+
family: kind,
|
|
188
|
+
reason,
|
|
189
|
+
host,
|
|
190
|
+
normalizedHost,
|
|
191
|
+
});
|
|
192
|
+
resolve(normalizedHost);
|
|
123
193
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
finish(null);
|
|
194
|
+
socket.once('error', (error) => {
|
|
195
|
+
log.debug('LAN HTTPS host detection UDP route probe error', error, {
|
|
196
|
+
method: 'udp_route_local_address_probe',
|
|
197
|
+
family: kind,
|
|
198
|
+
});
|
|
199
|
+
finish(null, 'error');
|
|
130
200
|
});
|
|
131
|
-
socket.connect(
|
|
201
|
+
socket.connect(target.port, target.host, () => {
|
|
132
202
|
const address = socket.address();
|
|
133
203
|
if (typeof address === 'string') {
|
|
134
|
-
finish(null);
|
|
204
|
+
finish(null, 'non_ip_socket_address');
|
|
135
205
|
return;
|
|
136
206
|
}
|
|
137
|
-
finish(address.address);
|
|
207
|
+
finish(address.address, 'connected');
|
|
138
208
|
});
|
|
139
209
|
});
|
|
140
210
|
}
|
|
141
211
|
function getNetworkInterfaceHosts(kind) {
|
|
142
212
|
const hosts = [];
|
|
143
213
|
const families = os.networkInterfaces();
|
|
144
|
-
|
|
214
|
+
const inspectedInterfaces = [];
|
|
215
|
+
for (const [name, entries] of Object.entries(families)) {
|
|
145
216
|
if (entries === undefined)
|
|
146
217
|
continue;
|
|
147
218
|
for (const entry of entries) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
219
|
+
const acceptedFamily = !entry.internal &&
|
|
220
|
+
((kind === 'ipv4' && entry.family === 'IPv4') ||
|
|
221
|
+
(kind === 'ipv6' && entry.family === 'IPv6'));
|
|
222
|
+
inspectedInterfaces.push({
|
|
223
|
+
name,
|
|
224
|
+
address: entry.address,
|
|
225
|
+
family: entry.family,
|
|
226
|
+
internal: entry.internal,
|
|
227
|
+
acceptedFamily,
|
|
228
|
+
});
|
|
229
|
+
if (acceptedFamily && kind === 'ipv4') {
|
|
151
230
|
hosts.push(entry.address);
|
|
152
231
|
}
|
|
153
|
-
if (
|
|
232
|
+
if (acceptedFamily && kind === 'ipv6') {
|
|
154
233
|
hosts.push(stripIpv6ZoneId(entry.address));
|
|
155
234
|
}
|
|
156
235
|
}
|
|
157
236
|
}
|
|
237
|
+
log.debug('LAN HTTPS host detection networkInterfaces result', undefined, {
|
|
238
|
+
method: 'os.networkInterfaces',
|
|
239
|
+
family: kind,
|
|
240
|
+
hosts,
|
|
241
|
+
inspectedInterfaces,
|
|
242
|
+
});
|
|
158
243
|
return hosts;
|
|
159
244
|
}
|
|
245
|
+
function isDetectedHostnameCandidate(host) {
|
|
246
|
+
const normalizedHost = normalizeNetworkHost(host);
|
|
247
|
+
if (!isLanHttpsHost(normalizedHost))
|
|
248
|
+
return false;
|
|
249
|
+
if (net.isIP(normalizedHost) !== 0)
|
|
250
|
+
return true;
|
|
251
|
+
return normalizedHost.includes('.');
|
|
252
|
+
}
|
|
160
253
|
function uniqueHosts(rawHosts) {
|
|
161
254
|
const hosts = [];
|
|
162
255
|
const seen = new Set();
|
|
@@ -176,6 +269,15 @@ function stripIpv6ZoneId(address) {
|
|
|
176
269
|
const zoneIndex = address.indexOf('%');
|
|
177
270
|
return zoneIndex === -1 ? address : address.slice(0, zoneIndex);
|
|
178
271
|
}
|
|
272
|
+
function isIpv4LinkLocalHost(host) {
|
|
273
|
+
return host.startsWith('169.254.');
|
|
274
|
+
}
|
|
275
|
+
function isIpv6LinkLocalHost(host) {
|
|
276
|
+
return (host.startsWith('fe8') ||
|
|
277
|
+
host.startsWith('fe9') ||
|
|
278
|
+
host.startsWith('fea') ||
|
|
279
|
+
host.startsWith('feb'));
|
|
280
|
+
}
|
|
179
281
|
function parseIpv4MappedIpv6Host(host) {
|
|
180
282
|
const dottedQuadIndex = host.lastIndexOf(':');
|
|
181
283
|
if (dottedQuadIndex === -1)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const rtws_cli_1 = require("./bootstrap/rtws-cli");
|
|
5
|
+
const log_1 = require("./log");
|
|
6
|
+
const server_1 = require("./server");
|
|
7
|
+
const port_selection_1 = require("./server/port-selection");
|
|
8
|
+
const log = (0, log_1.createLogger)('server-debug');
|
|
9
|
+
function parseArgs(argv) {
|
|
10
|
+
const out = {};
|
|
11
|
+
for (let i = 0; i < argv.length; i++) {
|
|
12
|
+
const arg = argv[i];
|
|
13
|
+
if (arg === '-p' || arg === '--port') {
|
|
14
|
+
out['p'] = argv[i + 1] ?? '';
|
|
15
|
+
i++;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (arg.startsWith('--port=')) {
|
|
19
|
+
out['p'] = arg.slice('--port='.length);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (arg === '-H' || arg === '--host' || arg === '-h') {
|
|
23
|
+
out['H'] = argv[i + 1] ?? '';
|
|
24
|
+
i++;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (arg.startsWith('--host=')) {
|
|
28
|
+
out['H'] = arg.slice('--host='.length);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (arg === '--mode') {
|
|
32
|
+
out['mode'] = argv[i + 1] ?? '';
|
|
33
|
+
i++;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (arg.startsWith('--mode=')) {
|
|
37
|
+
out['mode'] = arg.slice('--mode='.length);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
async function main(argv = process.argv.slice(2)) {
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = (0, rtws_cli_1.extractGlobalRtwsChdir)({ argv });
|
|
47
|
+
if (parsed.chdir !== undefined) {
|
|
48
|
+
process.chdir(parsed.chdir);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
53
|
+
throw new Error(`Failed to apply server debug cwd: ${message}`);
|
|
54
|
+
}
|
|
55
|
+
const cliArgs = parseArgs(parsed.argv);
|
|
56
|
+
const portSpecRaw = cliArgs['p'];
|
|
57
|
+
const parsedPort = typeof portSpecRaw === 'string' ? (0, port_selection_1.parseWebuiPortSpec)(portSpecRaw) : undefined;
|
|
58
|
+
if (portSpecRaw !== undefined && parsedPort === null) {
|
|
59
|
+
throw new Error('Invalid --port value: expected a port number, optionally suffixed with + or -');
|
|
60
|
+
}
|
|
61
|
+
const modeRaw = cliArgs['mode'];
|
|
62
|
+
if (modeRaw !== undefined && modeRaw !== 'dev' && modeRaw !== 'prod') {
|
|
63
|
+
throw new Error("Invalid --mode value: expected 'dev' or 'prod'");
|
|
64
|
+
}
|
|
65
|
+
await (0, server_1.startServer)({
|
|
66
|
+
port: parsedPort?.port,
|
|
67
|
+
host: typeof cliArgs['H'] === 'string' && cliArgs['H'] !== '' ? cliArgs['H'] : undefined,
|
|
68
|
+
mode: modeRaw,
|
|
69
|
+
strictPort: parsedPort?.strictPort,
|
|
70
|
+
portAutoDirection: parsedPort?.portAutoDirection,
|
|
71
|
+
returnAfterListen: true,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (require.main === module) {
|
|
75
|
+
main().catch((error) => {
|
|
76
|
+
log.error('Web UI debug startup failed', error);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
});
|
|
79
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -1,50 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.startServer = startServer;
|
|
37
|
-
/**
|
|
38
|
-
* Module: server
|
|
39
|
-
*
|
|
40
|
-
* HTTP/WebSocket server for both development and production modes:
|
|
41
|
-
* - Serves static files with MIME detection and SPA fallback (production)
|
|
42
|
-
* - Provides `/api/*` endpoints and `/ws` WebSocket communication
|
|
43
|
-
* - CLI bootstrap with optional cwd/port/host/mode parameters
|
|
44
|
-
* - Development mode: `tsx --watch src/server.ts -p <port> --mode dev`
|
|
45
|
-
* - Production mode: `node dist/server.js` (default port behavior: 5666-)
|
|
46
|
-
*/
|
|
47
|
-
const path = __importStar(require("path"));
|
|
48
4
|
const runtime_1 = require("./apps/runtime");
|
|
49
5
|
const dialog_display_state_1 = require("./dialog-display-state");
|
|
50
6
|
const kernel_driver_1 = require("./llm/kernel-driver");
|
|
@@ -77,45 +33,6 @@ process.on('uncaughtException', (error) => {
|
|
|
77
33
|
// Optionally, exit with code 1
|
|
78
34
|
// process.exit(1);
|
|
79
35
|
});
|
|
80
|
-
function parseArgs(argv) {
|
|
81
|
-
const out = {};
|
|
82
|
-
for (let i = 0; i < argv.length; i++) {
|
|
83
|
-
const a = argv[i];
|
|
84
|
-
if (a === '-C' || a === '--chdir') {
|
|
85
|
-
out['C'] = argv[i + 1];
|
|
86
|
-
i++;
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
if (a === '-p' || a === '--port') {
|
|
90
|
-
out['p'] = argv[i + 1];
|
|
91
|
-
i++;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
if (a.startsWith('--port=')) {
|
|
95
|
-
out['p'] = a.slice('--port='.length);
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
if (a === '-H' || a === '--host') {
|
|
99
|
-
out['H'] = argv[i + 1];
|
|
100
|
-
i++;
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
if (a.startsWith('--host=')) {
|
|
104
|
-
out['H'] = a.slice('--host='.length);
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
if (a === '--mode') {
|
|
108
|
-
out['mode'] = argv[i + 1];
|
|
109
|
-
i++;
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if (a.startsWith('--mode=')) {
|
|
113
|
-
out['mode'] = a.slice('--mode='.length);
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return out;
|
|
118
|
-
}
|
|
119
36
|
function attachPostListenStartupCancellation(httpServer, token) {
|
|
120
37
|
const originalStop = httpServer.stop.bind(httpServer);
|
|
121
38
|
httpServer.stop = async () => {
|
|
@@ -204,16 +121,16 @@ async function startServer(opts = {}) {
|
|
|
204
121
|
}
|
|
205
122
|
const tls = certificateLookup.kind === 'found' && !strictPort ? certificateLookup.certificate : undefined;
|
|
206
123
|
const urlHost = (0, network_hosts_1.resolveHttpUrlHostForBindHost)(host);
|
|
207
|
-
log.
|
|
124
|
+
log.debug(`Starting server in ${mode} mode on ${(0, auth_1.formatServerOrigin)({
|
|
208
125
|
scheme: 'http',
|
|
209
126
|
host: urlHost,
|
|
210
127
|
port: preferredPort,
|
|
211
128
|
})} (bind ${host}; ${strictPort ? 'strict port' : `auto port ${portAutoDirection}`}; working language: ${(0, work_language_1.getWorkLanguage)()} from ${source})`);
|
|
212
129
|
if (certificateLookup.kind === 'found' && strictPort) {
|
|
213
|
-
log.
|
|
130
|
+
log.debug(`HTTPS certificate found but Dominds HTTPS is disabled for strict --port; assuming HTTPS, if needed, is handled by a front proxy (${certificateLookup.certificate.certPath})`);
|
|
214
131
|
}
|
|
215
132
|
else if (tls !== undefined) {
|
|
216
|
-
log.
|
|
133
|
+
log.debug(`HTTPS certificate available: ${tls.certPath} (matched host ${tls.matchedHost})`);
|
|
217
134
|
}
|
|
218
135
|
let startedCore = null;
|
|
219
136
|
let boundPort = null;
|
|
@@ -291,7 +208,7 @@ async function startServer(opts = {}) {
|
|
|
291
208
|
await startedCore.stop();
|
|
292
209
|
throw new Error(`Failed to start WebUI HTTPS: no available adjacent port found from ${preferredHttpsPort}`);
|
|
293
210
|
}
|
|
294
|
-
log.
|
|
211
|
+
log.debug(`HTTPS WebUI ready: ${(0, auth_1.formatServerOrigin)({
|
|
295
212
|
scheme: 'https',
|
|
296
213
|
host: httpsUrlHost,
|
|
297
214
|
port: httpsPort,
|
|
@@ -375,39 +292,3 @@ async function startServer(opts = {}) {
|
|
|
375
292
|
mode,
|
|
376
293
|
};
|
|
377
294
|
}
|
|
378
|
-
// Main function for CLI execution
|
|
379
|
-
async function main() {
|
|
380
|
-
const cliArgs = parseArgs(process.argv.slice(2));
|
|
381
|
-
// Handle working directory change from -C flag
|
|
382
|
-
const wsDir = cliArgs['C'];
|
|
383
|
-
if (wsDir) {
|
|
384
|
-
if (!path.isAbsolute(wsDir)) {
|
|
385
|
-
throw new Error(`-C requires an absolute directory path: ${wsDir}`);
|
|
386
|
-
}
|
|
387
|
-
try {
|
|
388
|
-
process.chdir(wsDir);
|
|
389
|
-
}
|
|
390
|
-
catch (err) {
|
|
391
|
-
throw new Error(`Failed to change working directory to ${wsDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
// Get port, host, and mode from CLI args
|
|
395
|
-
const portSpecRaw = cliArgs['p'];
|
|
396
|
-
const parsedPort = typeof portSpecRaw === 'string' ? (0, port_selection_1.parseWebuiPortSpec)(portSpecRaw) : undefined;
|
|
397
|
-
if (portSpecRaw !== undefined && parsedPort === null) {
|
|
398
|
-
throw new Error('Invalid --port value: expected a port number, optionally suffixed with + or -');
|
|
399
|
-
}
|
|
400
|
-
const port = parsedPort?.port;
|
|
401
|
-
const strictPort = parsedPort?.strictPort;
|
|
402
|
-
const portAutoDirection = parsedPort?.portAutoDirection;
|
|
403
|
-
const host = cliArgs['H'] || undefined;
|
|
404
|
-
const mode = cliArgs['mode'] || undefined;
|
|
405
|
-
await startServer({ port, host, mode, strictPort, portAutoDirection, returnAfterListen: true });
|
|
406
|
-
}
|
|
407
|
-
// Start server if this file is run directly
|
|
408
|
-
if (require.main === module) {
|
|
409
|
-
main().catch((error) => {
|
|
410
|
-
log.error('Web UI startup failed', error);
|
|
411
|
-
process.exit(1);
|
|
412
|
-
});
|
|
413
|
-
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DomindsSelfUpdateRunKind } from '@longrun-ai/kernel/types';
|
|
2
|
+
export declare const DOMINDS_SUPERVISOR_RESTART_WEBUI = "dominds.supervisor.restart_webui.v1";
|
|
3
|
+
export type DomindsSupervisorRestartRunKind = Extract<DomindsSelfUpdateRunKind, 'global' | 'npx'>;
|
|
4
|
+
export type DomindsSupervisorRestartWebuiMessage = Readonly<{
|
|
5
|
+
type: typeof DOMINDS_SUPERVISOR_RESTART_WEBUI;
|
|
6
|
+
cwd: string;
|
|
7
|
+
host: string;
|
|
8
|
+
port: number;
|
|
9
|
+
traceFile: string;
|
|
10
|
+
debugDir: string;
|
|
11
|
+
currentVersion: string;
|
|
12
|
+
targetVersion: string | null;
|
|
13
|
+
runKind: DomindsSupervisorRestartRunKind;
|
|
14
|
+
}>;
|
|
15
|
+
export type DomindsRunnerToSupervisorMessage = DomindsSupervisorRestartWebuiMessage;
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dominds",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.2",
|
|
4
4
|
"description": "Dominds CLI and aggregation shell for the LongRun AI kernel/runtime packages.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
|
-
"dominds": "dist/cli.js"
|
|
10
|
+
"dominds": "dist/cli.js",
|
|
11
|
+
"dominds-runner": "dist/cli-runner.js"
|
|
11
12
|
},
|
|
12
13
|
"exports": {
|
|
13
14
|
"./cli": {
|
|
@@ -52,9 +53,9 @@
|
|
|
52
53
|
"ws": "^8.19.0",
|
|
53
54
|
"yaml": "^2.8.2",
|
|
54
55
|
"zod": "^4.3.6",
|
|
55
|
-
"@longrun-ai/kernel": "1.16.0",
|
|
56
56
|
"@longrun-ai/codex-auth": "0.13.0",
|
|
57
|
-
"@longrun-ai/shell": "1.16.0"
|
|
57
|
+
"@longrun-ai/shell": "1.16.0",
|
|
58
|
+
"@longrun-ai/kernel": "1.16.0"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@types/node": "^25.3.5",
|
|
@@ -83,6 +84,6 @@
|
|
|
83
84
|
"lint:types": "pnpm -r --filter './packages/*' --filter ./webapp run lint:types && tsc -p main/tsconfig.dev.json --noEmit",
|
|
84
85
|
"format": "prettier --write \"{main,webapp/src,docs,tests}/**/*.{js,jsx,ts,tsx}\" && prettier --write \"{main,webapp/src,docs,tests}/**/*.{css,md,json,html}\"",
|
|
85
86
|
"format:check": "prettier --check \"{main,webapp/src,docs,tests}/**/*.{js,jsx,ts,tsx}\" && prettier --check \"{main,webapp/src,docs,tests}/**/*.{css,md,json,html}\"",
|
|
86
|
-
"build:backend": "pnpm -C tests run manual-size-guard && rm -rf ./dist && pnpm -r --filter './packages/*' --filter ./codex-auth run build && tsc -p main/tsconfig.json --rootDir main && mkdir -p dist/llm dist/minds dist/tools dist/snippets dist/docs && cp main/llm/defaults.yaml dist/llm/ && cp -r main/minds/builtin dist/minds/ && cp -r main/tools/prompts dist/tools/ && cp -r snippets/. dist/snippets/ && cp -r docs/. dist/docs/ && chmod +x ./dist/cli.js ./dist/cli/*.js 2>/dev/null"
|
|
87
|
+
"build:backend": "pnpm -C tests run manual-size-guard && rm -rf ./dist && pnpm -r --filter './packages/*' --filter ./codex-auth run build && tsc -p main/tsconfig.json --rootDir main && mkdir -p dist/llm dist/minds dist/tools dist/snippets dist/docs && cp main/llm/defaults.yaml dist/llm/ && cp -r main/minds/builtin dist/minds/ && cp -r main/tools/prompts dist/tools/ && cp -r snippets/. dist/snippets/ && cp -r docs/. dist/docs/ && chmod +x ./dist/cli.js ./dist/cli-runner.js ./dist/server-debug.js ./dist/cli/*.js 2>/dev/null"
|
|
87
88
|
}
|
|
88
89
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type RestartHelperStdioMode = 'inherit' | 'ignore';
|
|
2
|
-
export type RestartHelperPayload = Readonly<{
|
|
3
|
-
command: string;
|
|
4
|
-
args: readonly string[];
|
|
5
|
-
cwd: string;
|
|
6
|
-
host: string;
|
|
7
|
-
port: number;
|
|
8
|
-
retiringPid: number;
|
|
9
|
-
forceKillAfterMs: number;
|
|
10
|
-
probeIntervalMs: number;
|
|
11
|
-
portReleaseTimeoutMs: number;
|
|
12
|
-
stdioMode: RestartHelperStdioMode;
|
|
13
|
-
traceFile: string;
|
|
14
|
-
debugDir: string;
|
|
15
|
-
}>;
|