@adhdev/daemon-core 0.6.69 → 0.6.71
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/dist/index.d.ts +1 -0
- package/dist/index.js +73 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/cli-adapters/provider-cli-adapter.ts +34 -3
- package/src/config/config.ts +51 -16
package/dist/index.d.ts
CHANGED
|
@@ -170,6 +170,7 @@ interface ADHDevConfig {
|
|
|
170
170
|
machineNickname: string | null;
|
|
171
171
|
machineId?: string;
|
|
172
172
|
machineSecret?: string | null;
|
|
173
|
+
registeredMachineId?: string;
|
|
173
174
|
cliHistory: CliHistoryEntry[];
|
|
174
175
|
providerSettings: Record<string, Record<string, any>>;
|
|
175
176
|
ideSettings: Record<string, {
|
package/dist/index.js
CHANGED
|
@@ -217,14 +217,36 @@ var config_exports = {};
|
|
|
217
217
|
__export(config_exports, {
|
|
218
218
|
addCliHistory: () => addCliHistory,
|
|
219
219
|
generateConnectionToken: () => generateConnectionToken,
|
|
220
|
+
generateMachineId: () => generateMachineId,
|
|
220
221
|
getConfigDir: () => getConfigDir,
|
|
221
222
|
isSetupComplete: () => isSetupComplete,
|
|
223
|
+
isStableMachineId: () => isStableMachineId,
|
|
222
224
|
loadConfig: () => loadConfig,
|
|
223
225
|
markSetupComplete: () => markSetupComplete,
|
|
224
226
|
resetConfig: () => resetConfig,
|
|
225
227
|
saveConfig: () => saveConfig,
|
|
226
228
|
updateConfig: () => updateConfig
|
|
227
229
|
});
|
|
230
|
+
function generateMachineId() {
|
|
231
|
+
return `${MACHINE_ID_PREFIX}${(0, import_crypto2.randomUUID)().replace(/-/g, "")}`;
|
|
232
|
+
}
|
|
233
|
+
function isStableMachineId(machineId) {
|
|
234
|
+
return typeof machineId === "string" && machineId.startsWith(MACHINE_ID_PREFIX);
|
|
235
|
+
}
|
|
236
|
+
function ensureMachineId(config) {
|
|
237
|
+
if (isStableMachineId(config.machineId)) {
|
|
238
|
+
return { config, changed: false };
|
|
239
|
+
}
|
|
240
|
+
const legacyRegisteredMachineId = !config.registeredMachineId && config.machineSecret && config.machineId ? config.machineId : config.registeredMachineId;
|
|
241
|
+
return {
|
|
242
|
+
config: {
|
|
243
|
+
...config,
|
|
244
|
+
machineId: generateMachineId(),
|
|
245
|
+
registeredMachineId: legacyRegisteredMachineId
|
|
246
|
+
},
|
|
247
|
+
changed: true
|
|
248
|
+
};
|
|
249
|
+
}
|
|
228
250
|
function getConfigDir() {
|
|
229
251
|
const dir = (0, import_path.join)((0, import_os.homedir)(), ".adhdev");
|
|
230
252
|
if (!(0, import_fs.existsSync)(dir)) {
|
|
@@ -238,7 +260,12 @@ function getConfigPath() {
|
|
|
238
260
|
function loadConfig() {
|
|
239
261
|
const configPath = getConfigPath();
|
|
240
262
|
if (!(0, import_fs.existsSync)(configPath)) {
|
|
241
|
-
|
|
263
|
+
const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
|
|
264
|
+
try {
|
|
265
|
+
saveConfig(initialized.config);
|
|
266
|
+
} catch {
|
|
267
|
+
}
|
|
268
|
+
return initialized.config;
|
|
242
269
|
}
|
|
243
270
|
try {
|
|
244
271
|
const raw = (0, import_fs.readFileSync)(configPath, "utf-8");
|
|
@@ -249,28 +276,23 @@ function loadConfig() {
|
|
|
249
276
|
}
|
|
250
277
|
delete merged.activeWorkspaceId;
|
|
251
278
|
const hadStoredWorkspaces = Array.isArray(parsed.workspaces) && parsed.workspaces.length > 0;
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const safeHostname = os15.hostname().replace(/[^a-zA-Z0-9]/g, "_");
|
|
258
|
-
const machineHash = crypto5.createHash("md5").update(os15.hostname() + os15.homedir()).digest("hex").slice(0, 8);
|
|
259
|
-
merged.machineId = `${safeHostname}_${machineHash}`;
|
|
260
|
-
configChanged = true;
|
|
261
|
-
}
|
|
262
|
-
if (!hadStoredWorkspaces && (merged.workspaces?.length || 0) > 0) {
|
|
279
|
+
const ensured = ensureMachineId(merged);
|
|
280
|
+
const normalized = ensured.config;
|
|
281
|
+
migrateWorkspacesFromRecent(normalized);
|
|
282
|
+
let configChanged = ensured.changed;
|
|
283
|
+
if (!hadStoredWorkspaces && (normalized.workspaces?.length || 0) > 0) {
|
|
263
284
|
configChanged = true;
|
|
264
285
|
}
|
|
265
286
|
if (configChanged) {
|
|
266
287
|
try {
|
|
267
|
-
saveConfig(
|
|
288
|
+
saveConfig(normalized);
|
|
268
289
|
} catch {
|
|
269
290
|
}
|
|
270
291
|
}
|
|
271
|
-
return
|
|
292
|
+
return normalized;
|
|
272
293
|
} catch {
|
|
273
|
-
|
|
294
|
+
const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
|
|
295
|
+
return initialized.config;
|
|
274
296
|
}
|
|
275
297
|
}
|
|
276
298
|
function saveConfig(config) {
|
|
@@ -344,13 +366,14 @@ function addCliHistory(entry) {
|
|
|
344
366
|
config.cliHistory = filtered.slice(0, 20);
|
|
345
367
|
saveConfig(config);
|
|
346
368
|
}
|
|
347
|
-
var import_os, import_path, import_fs, DEFAULT_CONFIG;
|
|
369
|
+
var import_os, import_path, import_fs, import_crypto2, DEFAULT_CONFIG, MACHINE_ID_PREFIX;
|
|
348
370
|
var init_config = __esm({
|
|
349
371
|
"src/config/config.ts"() {
|
|
350
372
|
"use strict";
|
|
351
373
|
import_os = require("os");
|
|
352
374
|
import_path = require("path");
|
|
353
375
|
import_fs = require("fs");
|
|
376
|
+
import_crypto2 = require("crypto");
|
|
354
377
|
init_workspaces();
|
|
355
378
|
DEFAULT_CONFIG = {
|
|
356
379
|
serverUrl: "https://api.adhf.dev",
|
|
@@ -374,11 +397,13 @@ var init_config = __esm({
|
|
|
374
397
|
machineNickname: null,
|
|
375
398
|
machineId: void 0,
|
|
376
399
|
machineSecret: null,
|
|
400
|
+
registeredMachineId: void 0,
|
|
377
401
|
cliHistory: [],
|
|
378
402
|
providerSettings: {},
|
|
379
403
|
ideSettings: {},
|
|
380
404
|
disableUpstream: false
|
|
381
405
|
};
|
|
406
|
+
MACHINE_ID_PREFIX = "mach_";
|
|
382
407
|
}
|
|
383
408
|
});
|
|
384
409
|
|
|
@@ -1092,7 +1117,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
1092
1117
|
/Do you trust the files/i,
|
|
1093
1118
|
/Quick safety check/i,
|
|
1094
1119
|
/Is this a project/i,
|
|
1095
|
-
/Enter to confirm/i
|
|
1120
|
+
/Enter to confirm/i,
|
|
1121
|
+
/be able to read, edit, and execute/i,
|
|
1122
|
+
/Security guide/i
|
|
1096
1123
|
];
|
|
1097
1124
|
if (dialogPatterns.some((p) => p.test(this.startupBuffer))) {
|
|
1098
1125
|
setTimeout(() => this.ptyProcess?.write("\r"), this.timeouts.dialogAccept);
|
|
@@ -1149,15 +1176,41 @@ var init_provider_cli_adapter = __esm({
|
|
|
1149
1176
|
}, 6e4);
|
|
1150
1177
|
}
|
|
1151
1178
|
evaluateSettled() {
|
|
1152
|
-
|
|
1153
|
-
if (this.responseSettleIgnoreUntil >
|
|
1179
|
+
const now = Date.now();
|
|
1180
|
+
if (this.submitPendingUntil > now || this.responseSettleIgnoreUntil > now) {
|
|
1181
|
+
const delayTime = Math.max(this.submitPendingUntil - now, this.responseSettleIgnoreUntil - now) + 50;
|
|
1182
|
+
if (this.settleTimer) clearTimeout(this.settleTimer);
|
|
1183
|
+
this.settleTimer = setTimeout(() => {
|
|
1184
|
+
this.settleTimer = null;
|
|
1185
|
+
this.settledBuffer = this.recentOutputBuffer;
|
|
1186
|
+
this.evaluateSettled();
|
|
1187
|
+
}, delayTime);
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1154
1190
|
const tail = this.settledBuffer;
|
|
1155
1191
|
const modal = this.runParseApproval(tail);
|
|
1156
1192
|
const rawScriptStatus = this.runDetectStatus(tail);
|
|
1157
|
-
const scriptStatus = rawScriptStatus
|
|
1193
|
+
const scriptStatus = rawScriptStatus;
|
|
1158
1194
|
if (!scriptStatus) return;
|
|
1159
1195
|
const prevStatus = this.currentStatus;
|
|
1160
1196
|
if (scriptStatus === "waiting_approval") {
|
|
1197
|
+
const modalMessage = modal?.message || "";
|
|
1198
|
+
const screenText = this.terminalScreen.getText() || this.accumulatedBuffer;
|
|
1199
|
+
const autoAcceptPatterns = [
|
|
1200
|
+
/be able to read, edit, and execute/i,
|
|
1201
|
+
/Security guide/i,
|
|
1202
|
+
/Enter to confirm/i,
|
|
1203
|
+
/Quick safety check/i,
|
|
1204
|
+
/Do you trust the files/i,
|
|
1205
|
+
/Is this a project/i
|
|
1206
|
+
];
|
|
1207
|
+
if (autoAcceptPatterns.some((p) => p.test(modalMessage) || p.test(screenText))) {
|
|
1208
|
+
LOG.info("CLI", `[${this.cliType}] Auto-accepting startup dialog: ${modalMessage.slice(0, 80)}`);
|
|
1209
|
+
setTimeout(() => this.ptyProcess?.write("\r"), 200);
|
|
1210
|
+
this.lastApprovalResolvedAt = Date.now();
|
|
1211
|
+
this.activeModal = null;
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1161
1214
|
const inCooldown = this.lastApprovalResolvedAt && Date.now() - this.lastApprovalResolvedAt < this.timeouts.approvalCooldown;
|
|
1162
1215
|
if (!inCooldown) {
|
|
1163
1216
|
this.isWaitingForResponse = true;
|