@agent-webui/ai-desk-daemon 1.0.61-beta4 → 1.0.61-beta6
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/bin/cli.js +11 -1
- package/lib/daemon-registry.js +80 -13
- package/package.json +11 -11
package/bin/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ const { start, stop, restart, status } = require('../lib/daemon-manager');
|
|
|
12
12
|
const { getLogPath } = require('../lib/platform');
|
|
13
13
|
const { VERSION } = require('../lib/platform');
|
|
14
14
|
const { getPort } = require('../lib/config');
|
|
15
|
-
const { reportLifecycle } = require('../lib/daemon-registry');
|
|
15
|
+
const { reportLifecycle, syncRegistryConfigToDaemonConfig } = require('../lib/daemon-registry');
|
|
16
16
|
const { upgradePackage } = require('../lib/self-upgrade');
|
|
17
17
|
|
|
18
18
|
function wait(ms) {
|
|
@@ -141,6 +141,14 @@ async function reportRegistryLifecycle(event) {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
function syncRegistryConfigForDaemonStart() {
|
|
145
|
+
try {
|
|
146
|
+
syncRegistryConfigToDaemonConfig();
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.warn(chalk.yellow(`[registry] Failed to sync daemon registry config: ${error.message || error}`));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
144
152
|
program
|
|
145
153
|
.name('aidesk')
|
|
146
154
|
.description('AI Desk Daemon - CLI tool for managing the AI Desk daemon service')
|
|
@@ -158,6 +166,7 @@ program
|
|
|
158
166
|
try {
|
|
159
167
|
const mode = resolveRequestedMode(options) || 'native';
|
|
160
168
|
const modeResult = configureRequestedMode(mode);
|
|
169
|
+
syncRegistryConfigForDaemonStart();
|
|
161
170
|
start();
|
|
162
171
|
await reportRegistryLifecycle('start');
|
|
163
172
|
if (mode === 'cli-anything' && modeResult?.runtimeInfo?.cliAnythingPath) {
|
|
@@ -257,6 +266,7 @@ program
|
|
|
257
266
|
try {
|
|
258
267
|
const mode = resolveRequestedMode(options);
|
|
259
268
|
const modeResult = configureRequestedMode(mode);
|
|
269
|
+
syncRegistryConfigForDaemonStart();
|
|
260
270
|
restart();
|
|
261
271
|
await reportRegistryLifecycle('restart');
|
|
262
272
|
if (mode === 'cli-anything' && modeResult?.runtimeInfo?.cliAnythingPath) {
|
package/lib/daemon-registry.js
CHANGED
|
@@ -31,10 +31,15 @@ function readRegistrySessionIdentity(homeDir = os.homedir()) {
|
|
|
31
31
|
if (!fs.existsSync(sessionPath)) return null;
|
|
32
32
|
const session = JSON.parse(fs.readFileSync(sessionPath, 'utf8'));
|
|
33
33
|
if (!session || typeof session !== 'object') return null;
|
|
34
|
+
const apiBaseUrl = normalizeApiBaseUrl(session.api_base_url || session.apiBaseUrl);
|
|
34
35
|
const rcAccountId = trim(session.account_id || session.accountId);
|
|
35
36
|
const rcExtensionId = trim(session.extension_id || session.extensionId);
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
const rcUsername = trim(session.rc_username || session.rcUsername);
|
|
38
|
+
const tlsInsecureSkipVerify = Boolean(
|
|
39
|
+
session.tls_insecure_skip_verify || session.tlsInsecureSkipVerify,
|
|
40
|
+
);
|
|
41
|
+
if (!apiBaseUrl && !rcAccountId && !rcExtensionId && !rcUsername) return null;
|
|
42
|
+
return { apiBaseUrl, rcAccountId, rcExtensionId, rcUsername, tlsInsecureSkipVerify };
|
|
38
43
|
} catch {
|
|
39
44
|
return null;
|
|
40
45
|
}
|
|
@@ -55,12 +60,12 @@ function readRegistryConfigFromDaemonConfig(homeDir = os.homedir()) {
|
|
|
55
60
|
sessionIdentity?.rcAccountId || '';
|
|
56
61
|
const rcExtensionId = trim(registry.rc_extension_id || registry.rcExtensionId) ||
|
|
57
62
|
sessionIdentity?.rcExtensionId || '';
|
|
58
|
-
if (!apiBaseUrl
|
|
63
|
+
if (!apiBaseUrl) return null;
|
|
59
64
|
return {
|
|
60
65
|
apiBaseUrl,
|
|
61
66
|
rcAccountId,
|
|
62
67
|
rcExtensionId,
|
|
63
|
-
rcUsername: trim(registry.rc_username || registry.rcUsername),
|
|
68
|
+
rcUsername: trim(registry.rc_username || registry.rcUsername) || sessionIdentity?.rcUsername || '',
|
|
64
69
|
tlsInsecureSkipVerify: Boolean(registry.tls_insecure_skip_verify || registry.tlsInsecureSkipVerify),
|
|
65
70
|
};
|
|
66
71
|
} catch {
|
|
@@ -71,32 +76,75 @@ function readRegistryConfigFromDaemonConfig(homeDir = os.homedir()) {
|
|
|
71
76
|
function getRegistryConfig(env = process.env, homeDir = os.homedir()) {
|
|
72
77
|
const daemonConfig = readRegistryConfigFromDaemonConfig(homeDir);
|
|
73
78
|
const sessionIdentity = readRegistrySessionIdentity(homeDir);
|
|
74
|
-
const
|
|
79
|
+
const envApiBaseUrl = normalizeApiBaseUrl(
|
|
75
80
|
env.AI_DESK_API_BASE_URL || env.AI_DESK_BACKEND_API_URL || env.AI_DESK_BACKEND_URL,
|
|
76
|
-
)
|
|
81
|
+
);
|
|
82
|
+
const hasSessionUserIdentity = Boolean(sessionIdentity?.rcAccountId || sessionIdentity?.rcExtensionId);
|
|
83
|
+
const apiBaseUrl = normalizeApiBaseUrl(
|
|
84
|
+
envApiBaseUrl ||
|
|
85
|
+
sessionIdentity?.apiBaseUrl ||
|
|
86
|
+
daemonConfig?.apiBaseUrl ||
|
|
87
|
+
(hasSessionUserIdentity ? DEFAULT_REGISTRY_API_BASE_URL : ''),
|
|
88
|
+
);
|
|
77
89
|
const rcAccountId = trim(env.AI_DESK_RC_ACCOUNT_ID || env.rcAccountId) ||
|
|
78
|
-
daemonConfig?.rcAccountId ||
|
|
79
90
|
sessionIdentity?.rcAccountId ||
|
|
91
|
+
daemonConfig?.rcAccountId ||
|
|
80
92
|
'';
|
|
81
93
|
const rcExtensionId = trim(env.AI_DESK_RC_EXTENSION_ID || env.rcExtensionId) ||
|
|
82
|
-
daemonConfig?.rcExtensionId ||
|
|
83
94
|
sessionIdentity?.rcExtensionId ||
|
|
95
|
+
daemonConfig?.rcExtensionId ||
|
|
84
96
|
'';
|
|
85
|
-
if (apiBaseUrl
|
|
97
|
+
if (apiBaseUrl) {
|
|
86
98
|
const tlsEnvValue = parseTruthyEnv(env.AI_DESK_TLS_INSECURE_SKIP_VERIFY);
|
|
87
99
|
return {
|
|
88
100
|
apiBaseUrl,
|
|
89
101
|
rcAccountId,
|
|
90
102
|
rcExtensionId,
|
|
91
|
-
rcUsername: trim(env.AI_DESK_RC_USERNAME || env.rcUsername) ||
|
|
103
|
+
rcUsername: trim(env.AI_DESK_RC_USERNAME || env.rcUsername) ||
|
|
104
|
+
sessionIdentity?.rcUsername ||
|
|
105
|
+
daemonConfig?.rcUsername ||
|
|
106
|
+
'',
|
|
92
107
|
tlsInsecureSkipVerify: tlsEnvValue === null
|
|
93
|
-
? Boolean(daemonConfig?.tlsInsecureSkipVerify)
|
|
108
|
+
? Boolean(sessionIdentity?.tlsInsecureSkipVerify ?? daemonConfig?.tlsInsecureSkipVerify)
|
|
94
109
|
: tlsEnvValue,
|
|
95
110
|
};
|
|
96
111
|
}
|
|
97
112
|
return null;
|
|
98
113
|
}
|
|
99
114
|
|
|
115
|
+
function daemonConfigPath(homeDir = os.homedir()) {
|
|
116
|
+
return path.join(homeDir, '.aidesktop', 'daemon-config.json');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function syncRegistryConfigToDaemonConfig(env = process.env, homeDir = os.homedir()) {
|
|
120
|
+
const config = getRegistryConfig(env, homeDir);
|
|
121
|
+
if (!config) return null;
|
|
122
|
+
|
|
123
|
+
const configPath = daemonConfigPath(homeDir);
|
|
124
|
+
let daemonConfig = {};
|
|
125
|
+
try {
|
|
126
|
+
if (fs.existsSync(configPath)) {
|
|
127
|
+
const parsed = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
128
|
+
if (parsed && typeof parsed === 'object') daemonConfig = parsed;
|
|
129
|
+
}
|
|
130
|
+
} catch {
|
|
131
|
+
daemonConfig = {};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
daemonConfig.registry = {
|
|
135
|
+
...(daemonConfig.registry && typeof daemonConfig.registry === 'object' ? daemonConfig.registry : {}),
|
|
136
|
+
api_base_url: config.apiBaseUrl,
|
|
137
|
+
rc_account_id: config.rcAccountId,
|
|
138
|
+
rc_extension_id: config.rcExtensionId,
|
|
139
|
+
rc_username: config.rcUsername,
|
|
140
|
+
tls_insecure_skip_verify: Boolean(config.tlsInsecureSkipVerify),
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
144
|
+
fs.writeFileSync(configPath, `${JSON.stringify(daemonConfig, null, 2)}\n`, 'utf8');
|
|
145
|
+
return config;
|
|
146
|
+
}
|
|
147
|
+
|
|
100
148
|
function registryStatePaths(homeDir = os.homedir()) {
|
|
101
149
|
const root = path.join(homeDir, '.aidesktop');
|
|
102
150
|
return {
|
|
@@ -153,6 +201,20 @@ function listIpAddresses() {
|
|
|
153
201
|
return [...new Set(out)];
|
|
154
202
|
}
|
|
155
203
|
|
|
204
|
+
function listMacAddresses() {
|
|
205
|
+
const out = [];
|
|
206
|
+
const interfaces = os.networkInterfaces();
|
|
207
|
+
for (const items of Object.values(interfaces)) {
|
|
208
|
+
for (const item of items || []) {
|
|
209
|
+
const mac = trim(item.mac).toLowerCase();
|
|
210
|
+
if (!item.internal && mac && mac !== '00:00:00:00:00:00') {
|
|
211
|
+
out.push(mac);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return [...new Set(out)];
|
|
216
|
+
}
|
|
217
|
+
|
|
156
218
|
function buildLifecyclePayload({
|
|
157
219
|
event,
|
|
158
220
|
runId,
|
|
@@ -161,16 +223,19 @@ function buildLifecyclePayload({
|
|
|
161
223
|
version,
|
|
162
224
|
daemonInstanceId,
|
|
163
225
|
}) {
|
|
226
|
+
const macAddresses = listMacAddresses();
|
|
164
227
|
return {
|
|
165
228
|
daemonInstanceId,
|
|
166
229
|
runId,
|
|
167
230
|
event,
|
|
168
231
|
seq,
|
|
232
|
+
machineId: macAddresses[0] || daemonInstanceId,
|
|
169
233
|
hostname: os.hostname(),
|
|
170
234
|
osUsername: os.userInfo().username,
|
|
171
235
|
daemonVersion: version,
|
|
172
236
|
port,
|
|
173
237
|
ipAddresses: listIpAddresses(),
|
|
238
|
+
macAddresses,
|
|
174
239
|
};
|
|
175
240
|
}
|
|
176
241
|
|
|
@@ -189,8 +254,8 @@ function postJSON(urlString, payload, config) {
|
|
|
189
254
|
headers: {
|
|
190
255
|
'Content-Type': 'application/json',
|
|
191
256
|
'Content-Length': Buffer.byteLength(body),
|
|
192
|
-
rcAccountId: config.rcAccountId,
|
|
193
|
-
rcExtensionId: config.rcExtensionId,
|
|
257
|
+
...(config.rcAccountId ? { rcAccountId: config.rcAccountId } : {}),
|
|
258
|
+
...(config.rcExtensionId ? { rcExtensionId: config.rcExtensionId } : {}),
|
|
194
259
|
...(config.rcUsername ? { rcUsername: config.rcUsername } : {}),
|
|
195
260
|
},
|
|
196
261
|
timeout: 3000,
|
|
@@ -244,11 +309,13 @@ module.exports = {
|
|
|
244
309
|
buildLifecyclePayload,
|
|
245
310
|
DEFAULT_REGISTRY_API_BASE_URL,
|
|
246
311
|
getRegistryConfig,
|
|
312
|
+
syncRegistryConfigToDaemonConfig,
|
|
247
313
|
readRegistrySessionIdentity,
|
|
248
314
|
readRegistryConfigFromDaemonConfig,
|
|
249
315
|
registryStatePaths,
|
|
250
316
|
ensureDaemonInstanceId,
|
|
251
317
|
readRunState,
|
|
252
318
|
writeRunState,
|
|
319
|
+
listMacAddresses,
|
|
253
320
|
reportLifecycle,
|
|
254
321
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-webui/ai-desk-daemon",
|
|
3
|
-
"version": "1.0.61-
|
|
3
|
+
"version": "1.0.61-beta6",
|
|
4
4
|
"description": "AI Desk Daemon - CLI tool for managing the AI Desk daemon service",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
"packages/*"
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
"chalk": "^4.1.2"
|
|
40
40
|
},
|
|
41
41
|
"optionalDependencies": {
|
|
42
|
-
"@agent-webui/ai-desk-daemon-darwin-arm64": "1.0.61-
|
|
43
|
-
"@agent-webui/ai-desk-daemon-darwin-x64": "1.0.61-
|
|
44
|
-
"@agent-webui/ai-desk-daemon-linux-arm64": "1.0.61-
|
|
45
|
-
"@agent-webui/ai-desk-daemon-linux-x64": "1.0.61-
|
|
46
|
-
"@agent-webui/ai-desk-daemon-win32-x64": "1.0.61-
|
|
47
|
-
"@agent-webui/ai-desk-python-darwin-arm64": "1.0.61-
|
|
48
|
-
"@agent-webui/ai-desk-python-darwin-x64": "1.0.61-
|
|
49
|
-
"@agent-webui/ai-desk-python-linux-arm64": "1.0.61-
|
|
50
|
-
"@agent-webui/ai-desk-python-linux-x64": "1.0.61-
|
|
51
|
-
"@agent-webui/ai-desk-python-win32-x64": "1.0.61-
|
|
42
|
+
"@agent-webui/ai-desk-daemon-darwin-arm64": "1.0.61-beta6",
|
|
43
|
+
"@agent-webui/ai-desk-daemon-darwin-x64": "1.0.61-beta6",
|
|
44
|
+
"@agent-webui/ai-desk-daemon-linux-arm64": "1.0.61-beta6",
|
|
45
|
+
"@agent-webui/ai-desk-daemon-linux-x64": "1.0.61-beta6",
|
|
46
|
+
"@agent-webui/ai-desk-daemon-win32-x64": "1.0.61-beta6",
|
|
47
|
+
"@agent-webui/ai-desk-python-darwin-arm64": "1.0.61-beta6",
|
|
48
|
+
"@agent-webui/ai-desk-python-darwin-x64": "1.0.61-beta6",
|
|
49
|
+
"@agent-webui/ai-desk-python-linux-arm64": "1.0.61-beta6",
|
|
50
|
+
"@agent-webui/ai-desk-python-linux-x64": "1.0.61-beta6",
|
|
51
|
+
"@agent-webui/ai-desk-python-win32-x64": "1.0.61-beta6"
|
|
52
52
|
},
|
|
53
53
|
"repository": {
|
|
54
54
|
"type": "git",
|