dominds 1.26.0 → 1.26.1

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.
@@ -41,9 +41,11 @@ 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 log_1 = require("../log");
44
45
  const OUTBOUND_PROBE_HOST = 'github.com';
45
46
  const OUTBOUND_PROBE_PORT = 443;
46
47
  const OUTBOUND_PROBE_TIMEOUT_MS = 800;
48
+ const log = (0, log_1.createLogger)('network-hosts');
47
49
  function normalizeNetworkHost(host) {
48
50
  const trimmed = host.trim();
49
51
  const unwrapped = trimmed.startsWith('[') && trimmed.endsWith(']') ? trimmed.slice(1, -1) : trimmed;
@@ -58,7 +60,9 @@ function isLanHttpsHost(host) {
58
60
  }
59
61
  const ipVersion = net.isIP(normalizedHost);
60
62
  if (ipVersion === 4) {
61
- return normalizedHost !== '0.0.0.0' && !normalizedHost.startsWith('127.');
63
+ return (normalizedHost !== '0.0.0.0' &&
64
+ !normalizedHost.startsWith('127.') &&
65
+ !isIpv4LinkLocalHost(normalizedHost));
62
66
  }
63
67
  if (ipVersion === 6) {
64
68
  const mappedIpv4 = parseIpv4MappedIpv6Host(normalizedHost);
@@ -68,7 +72,8 @@ function isLanHttpsHost(host) {
68
72
  return (normalizedHost !== '::' &&
69
73
  normalizedHost !== '0:0:0:0:0:0:0:0' &&
70
74
  normalizedHost !== '::1' &&
71
- normalizedHost !== '0:0:0:0:0:0:0:1');
75
+ normalizedHost !== '0:0:0:0:0:0:0:1' &&
76
+ !isIpv6LinkLocalHost(normalizedHost));
72
77
  }
73
78
  return true;
74
79
  }
@@ -83,78 +88,153 @@ function resolveHttpUrlHostForBindHost(bindHost) {
83
88
  }
84
89
  async function resolveLanHttpsHostsForBindHost(bindHost) {
85
90
  const normalizedHost = normalizeNetworkHost(bindHost);
91
+ log.info('Resolving LAN HTTPS certificate hosts', undefined, {
92
+ bindHost,
93
+ normalizedHost,
94
+ });
86
95
  if (normalizedHost === '0.0.0.0') {
87
- return uniqueHosts([
88
- ...(await getUdpOutboundHosts('ipv4')),
89
- ...getNetworkInterfaceHosts('ipv4'),
90
- os.hostname(),
91
- ]).filter(isLanHttpsHost);
96
+ return resolveBindAllLanHttpsHosts({
97
+ bindHost: normalizedHost,
98
+ families: ['ipv4'],
99
+ });
92
100
  }
93
101
  if (normalizedHost === '::' || normalizedHost === '0:0:0:0:0:0:0:0') {
94
- return uniqueHosts([
95
- ...(await getUdpOutboundHosts('ipv6')),
96
- ...(await getUdpOutboundHosts('ipv4')),
97
- ...getNetworkInterfaceHosts('ipv6'),
98
- ...getNetworkInterfaceHosts('ipv4'),
99
- os.hostname(),
100
- ]).filter(isLanHttpsHost);
102
+ return resolveBindAllLanHttpsHosts({
103
+ bindHost: normalizedHost,
104
+ families: ['ipv6', 'ipv4'],
105
+ });
101
106
  }
102
- return isLanHttpsHost(normalizedHost) ? [normalizedHost] : [];
107
+ const accepted = isLanHttpsHost(normalizedHost);
108
+ log.info('Resolved explicit LAN HTTPS certificate host', undefined, {
109
+ bindHost,
110
+ normalizedHost,
111
+ accepted,
112
+ });
113
+ return accepted ? [normalizedHost] : [];
103
114
  }
104
115
  async function resolveDefaultLanHttpsHosts() {
105
116
  return await resolveLanHttpsHostsForBindHost('::');
106
117
  }
118
+ async function resolveBindAllLanHttpsHosts(params) {
119
+ const rawCandidates = [];
120
+ for (const family of params.families) {
121
+ rawCandidates.push(...(await getUdpOutboundHosts(family)));
122
+ }
123
+ for (const family of params.families) {
124
+ rawCandidates.push(...getNetworkInterfaceHosts(family));
125
+ }
126
+ const hostname = os.hostname();
127
+ log.info('LAN HTTPS host detection hostname candidate', undefined, {
128
+ method: 'os.hostname',
129
+ host: hostname,
130
+ });
131
+ rawCandidates.push(hostname);
132
+ const uniqueCandidates = uniqueHosts(rawCandidates);
133
+ const acceptedHosts = [];
134
+ const rejectedHosts = [];
135
+ for (const host of uniqueCandidates) {
136
+ if (isLanHttpsHost(host)) {
137
+ acceptedHosts.push(host);
138
+ }
139
+ else {
140
+ rejectedHosts.push(host);
141
+ }
142
+ }
143
+ log.info('Resolved bind-all LAN HTTPS certificate hosts', undefined, {
144
+ bindHost: params.bindHost,
145
+ families: params.families,
146
+ rawCandidates,
147
+ uniqueCandidates,
148
+ acceptedHosts,
149
+ rejectedHosts,
150
+ });
151
+ return acceptedHosts;
152
+ }
107
153
  async function getUdpOutboundHosts(kind) {
108
154
  const host = await getUdpOutboundHost(kind);
109
155
  return host === null ? [] : [host];
110
156
  }
111
157
  async function getUdpOutboundHost(kind) {
112
158
  return await new Promise((resolve) => {
159
+ log.info('LAN HTTPS host detection UDP probe start', undefined, {
160
+ method: 'udp_outbound_probe',
161
+ family: kind,
162
+ remoteHost: OUTBOUND_PROBE_HOST,
163
+ remotePort: OUTBOUND_PROBE_PORT,
164
+ timeoutMs: OUTBOUND_PROBE_TIMEOUT_MS,
165
+ });
113
166
  const socket = dgram.createSocket(kind === 'ipv4' ? 'udp4' : 'udp6');
114
167
  let settled = false;
115
- const finish = (host) => {
168
+ const finish = (host, reason) => {
116
169
  if (settled)
117
170
  return;
118
171
  settled = true;
119
172
  clearTimeout(timeout);
120
173
  socket.removeAllListeners('error');
121
174
  socket.close();
122
- resolve(host === null ? null : normalizeNetworkHost(host));
175
+ const normalizedHost = host === null ? null : normalizeNetworkHost(host);
176
+ log.info('LAN HTTPS host detection UDP probe finish', undefined, {
177
+ method: 'udp_outbound_probe',
178
+ family: kind,
179
+ reason,
180
+ host,
181
+ normalizedHost,
182
+ });
183
+ resolve(normalizedHost);
123
184
  };
124
185
  const timeout = setTimeout(() => {
125
- finish(null);
186
+ finish(null, 'timeout');
126
187
  }, OUTBOUND_PROBE_TIMEOUT_MS);
127
188
  timeout.unref();
128
- socket.once('error', () => {
129
- finish(null);
189
+ socket.once('error', (error) => {
190
+ log.info('LAN HTTPS host detection UDP probe error', error, {
191
+ method: 'udp_outbound_probe',
192
+ family: kind,
193
+ });
194
+ finish(null, 'error');
130
195
  });
131
196
  socket.connect(OUTBOUND_PROBE_PORT, OUTBOUND_PROBE_HOST, () => {
132
197
  const address = socket.address();
133
198
  if (typeof address === 'string') {
134
- finish(null);
199
+ finish(null, 'non_ip_socket_address');
135
200
  return;
136
201
  }
137
- finish(address.address);
202
+ finish(address.address, 'connected');
138
203
  });
139
204
  });
140
205
  }
141
206
  function getNetworkInterfaceHosts(kind) {
142
207
  const hosts = [];
143
208
  const families = os.networkInterfaces();
144
- for (const entries of Object.values(families)) {
209
+ const inspectedInterfaces = [];
210
+ for (const [name, entries] of Object.entries(families)) {
145
211
  if (entries === undefined)
146
212
  continue;
147
213
  for (const entry of entries) {
148
- if (entry.internal)
149
- continue;
150
- if (kind === 'ipv4' && entry.family === 'IPv4') {
214
+ const acceptedFamily = !entry.internal &&
215
+ ((kind === 'ipv4' && entry.family === 'IPv4') ||
216
+ (kind === 'ipv6' && entry.family === 'IPv6'));
217
+ inspectedInterfaces.push({
218
+ name,
219
+ address: entry.address,
220
+ family: entry.family,
221
+ internal: entry.internal,
222
+ acceptedFamily,
223
+ });
224
+ if (acceptedFamily && kind === 'ipv4') {
151
225
  hosts.push(entry.address);
152
226
  }
153
- if (kind === 'ipv6' && entry.family === 'IPv6') {
227
+ if (acceptedFamily && kind === 'ipv6') {
154
228
  hosts.push(stripIpv6ZoneId(entry.address));
155
229
  }
156
230
  }
157
231
  }
232
+ log.info('LAN HTTPS host detection networkInterfaces result', undefined, {
233
+ method: 'os.networkInterfaces',
234
+ family: kind,
235
+ hosts,
236
+ inspectedInterfaces,
237
+ });
158
238
  return hosts;
159
239
  }
160
240
  function uniqueHosts(rawHosts) {
@@ -176,6 +256,15 @@ function stripIpv6ZoneId(address) {
176
256
  const zoneIndex = address.indexOf('%');
177
257
  return zoneIndex === -1 ? address : address.slice(0, zoneIndex);
178
258
  }
259
+ function isIpv4LinkLocalHost(host) {
260
+ return host.startsWith('169.254.');
261
+ }
262
+ function isIpv6LinkLocalHost(host) {
263
+ return (host.startsWith('fe8') ||
264
+ host.startsWith('fe9') ||
265
+ host.startsWith('fea') ||
266
+ host.startsWith('feb'));
267
+ }
179
268
  function parseIpv4MappedIpv6Host(host) {
180
269
  const dottedQuadIndex = host.lastIndexOf(':');
181
270
  if (dottedQuadIndex === -1)
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -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 () => {
@@ -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;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DOMINDS_SUPERVISOR_RESTART_WEBUI = void 0;
4
+ exports.DOMINDS_SUPERVISOR_RESTART_WEBUI = 'dominds.supervisor.restart_webui.v1';
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "dominds",
3
- "version": "1.26.0",
3
+ "version": "1.26.1",
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": {
@@ -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
- }>;