@hermespilot/link 0.8.0 → 0.8.1-beta.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.
- package/dist/{chunk-GHZLIFQF.js → chunk-WYVLVDXH.js} +1426 -249
- package/dist/cli/index.js +175 -9
- package/dist/http/app.d.ts +1 -0
- package/dist/http/app.js +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
stopDaemonProcess,
|
|
56
56
|
summarizeUsageProbeEnsure,
|
|
57
57
|
translate
|
|
58
|
-
} from "../chunk-
|
|
58
|
+
} from "../chunk-WYVLVDXH.js";
|
|
59
59
|
|
|
60
60
|
// src/cli/index.ts
|
|
61
61
|
import { Command } from "commander";
|
|
@@ -76,7 +76,12 @@ import path from "path";
|
|
|
76
76
|
import { promisify } from "util";
|
|
77
77
|
var execFileAsync = promisify(execFile);
|
|
78
78
|
var MACOS_LABEL = "com.hermespilot.link";
|
|
79
|
+
var WINDOWS_TASK_NAME = "HermesPilot Link";
|
|
80
|
+
var WINDOWS_AUTOSTART_SCRIPT = "hermeslink-autostart.ps1";
|
|
79
81
|
async function enableAutostart() {
|
|
82
|
+
if (process.platform === "win32") {
|
|
83
|
+
return await enableWindowsAutostart();
|
|
84
|
+
}
|
|
80
85
|
const definition = await resolveAutostartDefinition();
|
|
81
86
|
if (!definition) {
|
|
82
87
|
return unsupportedStatus();
|
|
@@ -94,6 +99,9 @@ async function enableAutostart() {
|
|
|
94
99
|
return await getAutostartStatus();
|
|
95
100
|
}
|
|
96
101
|
async function disableAutostart() {
|
|
102
|
+
if (process.platform === "win32") {
|
|
103
|
+
return await disableWindowsAutostart();
|
|
104
|
+
}
|
|
97
105
|
const definitions = await allAutostartDefinitions();
|
|
98
106
|
for (const definition of definitions) {
|
|
99
107
|
if (definition.method === "systemd-user") {
|
|
@@ -104,6 +112,9 @@ async function disableAutostart() {
|
|
|
104
112
|
return await getAutostartStatus();
|
|
105
113
|
}
|
|
106
114
|
async function getAutostartStatus() {
|
|
115
|
+
if (process.platform === "win32") {
|
|
116
|
+
return await getWindowsAutostartStatus();
|
|
117
|
+
}
|
|
107
118
|
const definitions = await allAutostartDefinitions();
|
|
108
119
|
if (definitions.length === 0) {
|
|
109
120
|
return unsupportedStatus();
|
|
@@ -127,13 +138,22 @@ async function getAutostartStatus() {
|
|
|
127
138
|
filePath: primary.filePath
|
|
128
139
|
};
|
|
129
140
|
}
|
|
141
|
+
async function migrateWindowsAutostartIfNeeded() {
|
|
142
|
+
if (process.platform !== "win32") {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const legacy = windowsLegacyStartupDefinition();
|
|
146
|
+
const legacyContent = await readFile(legacy.filePath, "utf8").catch(() => null);
|
|
147
|
+
if (legacyContent === null) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
await enableWindowsTaskSchedulerAutostart();
|
|
151
|
+
await rm(legacy.filePath, { force: true }).catch(() => void 0);
|
|
152
|
+
}
|
|
130
153
|
async function resolveAutostartDefinition() {
|
|
131
154
|
if (process.platform === "darwin") {
|
|
132
155
|
return launchdDefinition();
|
|
133
156
|
}
|
|
134
|
-
if (process.platform === "win32") {
|
|
135
|
-
return windowsStartupDefinition();
|
|
136
|
-
}
|
|
137
157
|
if (process.platform === "linux") {
|
|
138
158
|
return await hasSystemctlUser() ? systemdUserDefinition() : xdgAutostartDefinition();
|
|
139
159
|
}
|
|
@@ -143,9 +163,6 @@ async function allAutostartDefinitions() {
|
|
|
143
163
|
if (process.platform === "darwin") {
|
|
144
164
|
return [launchdDefinition()];
|
|
145
165
|
}
|
|
146
|
-
if (process.platform === "win32") {
|
|
147
|
-
return [windowsStartupDefinition()];
|
|
148
|
-
}
|
|
149
166
|
if (process.platform === "linux") {
|
|
150
167
|
return [systemdUserDefinition(), xdgAutostartDefinition()];
|
|
151
168
|
}
|
|
@@ -226,7 +243,120 @@ X-GNOME-Autostart-enabled=true
|
|
|
226
243
|
`
|
|
227
244
|
};
|
|
228
245
|
}
|
|
229
|
-
function
|
|
246
|
+
async function enableWindowsAutostart() {
|
|
247
|
+
try {
|
|
248
|
+
await enableWindowsTaskSchedulerAutostart();
|
|
249
|
+
await rm(windowsLegacyStartupDefinition().filePath, { force: true }).catch(() => void 0);
|
|
250
|
+
} catch (error) {
|
|
251
|
+
await writeWindowsLegacyStartupFile().catch(() => {
|
|
252
|
+
throw error;
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return await getWindowsAutostartStatus();
|
|
256
|
+
}
|
|
257
|
+
async function disableWindowsAutostart() {
|
|
258
|
+
await execFileAsync("schtasks.exe", ["/Delete", "/TN", WINDOWS_TASK_NAME, "/F"], {
|
|
259
|
+
windowsHide: true
|
|
260
|
+
}).catch(() => void 0);
|
|
261
|
+
await rm(windowsLegacyStartupDefinition().filePath, { force: true }).catch(() => void 0);
|
|
262
|
+
await rm(windowsTaskLauncherPath(), { force: true }).catch(() => void 0);
|
|
263
|
+
return await getWindowsAutostartStatus();
|
|
264
|
+
}
|
|
265
|
+
async function getWindowsAutostartStatus() {
|
|
266
|
+
if (await windowsTaskExists()) {
|
|
267
|
+
return {
|
|
268
|
+
supported: true,
|
|
269
|
+
enabled: true,
|
|
270
|
+
method: "windows-task-scheduler",
|
|
271
|
+
filePath: WINDOWS_TASK_NAME
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
const legacy = windowsLegacyStartupDefinition();
|
|
275
|
+
const legacyContent = await readFile(legacy.filePath, "utf8").catch(() => null);
|
|
276
|
+
if (legacyContent !== null) {
|
|
277
|
+
return {
|
|
278
|
+
supported: true,
|
|
279
|
+
enabled: true,
|
|
280
|
+
method: legacy.method,
|
|
281
|
+
filePath: legacy.filePath
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
supported: true,
|
|
286
|
+
enabled: false,
|
|
287
|
+
method: "windows-task-scheduler",
|
|
288
|
+
filePath: WINDOWS_TASK_NAME
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
async function enableWindowsTaskSchedulerAutostart() {
|
|
292
|
+
const definition = windowsTaskLauncherDefinition();
|
|
293
|
+
await mkdir(path.dirname(definition.filePath), { recursive: true, mode: 448 });
|
|
294
|
+
await writeFile(definition.filePath, definition.content, { mode: 384 });
|
|
295
|
+
await execFileAsync(
|
|
296
|
+
"schtasks.exe",
|
|
297
|
+
[
|
|
298
|
+
"/Create",
|
|
299
|
+
"/TN",
|
|
300
|
+
WINDOWS_TASK_NAME,
|
|
301
|
+
"/TR",
|
|
302
|
+
windowsScheduledTaskAction(definition.filePath),
|
|
303
|
+
"/SC",
|
|
304
|
+
"ONLOGON",
|
|
305
|
+
"/RL",
|
|
306
|
+
"LIMITED",
|
|
307
|
+
"/F"
|
|
308
|
+
],
|
|
309
|
+
{ windowsHide: true }
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
async function windowsTaskExists() {
|
|
313
|
+
try {
|
|
314
|
+
await execFileAsync("schtasks.exe", ["/Query", "/TN", WINDOWS_TASK_NAME], {
|
|
315
|
+
windowsHide: true
|
|
316
|
+
});
|
|
317
|
+
return true;
|
|
318
|
+
} catch {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function windowsTaskLauncherDefinition() {
|
|
323
|
+
const environment = autostartEnvironment();
|
|
324
|
+
const argumentList = `${windowsCommandArgumentQuote(currentCliScriptPath())} daemon-supervisor`;
|
|
325
|
+
return {
|
|
326
|
+
method: "windows-task-scheduler",
|
|
327
|
+
filePath: windowsTaskLauncherPath(),
|
|
328
|
+
content: [
|
|
329
|
+
"# Generated by Hermes Link. Do not edit.",
|
|
330
|
+
"$ErrorActionPreference = 'Stop'",
|
|
331
|
+
...powershellEnvironmentLines(environment),
|
|
332
|
+
`Start-Process -FilePath ${powershellString(process.execPath)} -ArgumentList ${powershellString(
|
|
333
|
+
argumentList
|
|
334
|
+
)} -WindowStyle Hidden -WorkingDirectory ${powershellString(os.homedir())}`,
|
|
335
|
+
""
|
|
336
|
+
].join("\r\n")
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function windowsTaskLauncherPath() {
|
|
340
|
+
return path.join(resolveRuntimePaths().homeDir, "autostart", WINDOWS_AUTOSTART_SCRIPT);
|
|
341
|
+
}
|
|
342
|
+
function windowsScheduledTaskAction(scriptPath) {
|
|
343
|
+
return [
|
|
344
|
+
"powershell.exe",
|
|
345
|
+
"-NoProfile",
|
|
346
|
+
"-ExecutionPolicy",
|
|
347
|
+
"Bypass",
|
|
348
|
+
"-WindowStyle",
|
|
349
|
+
"Hidden",
|
|
350
|
+
"-File",
|
|
351
|
+
windowsCommandArgumentQuote(scriptPath)
|
|
352
|
+
].join(" ");
|
|
353
|
+
}
|
|
354
|
+
async function writeWindowsLegacyStartupFile() {
|
|
355
|
+
const definition = windowsLegacyStartupDefinition();
|
|
356
|
+
await mkdir(path.dirname(definition.filePath), { recursive: true, mode: 448 });
|
|
357
|
+
await writeFile(definition.filePath, definition.content, { mode: 384 });
|
|
358
|
+
}
|
|
359
|
+
function windowsLegacyStartupDefinition() {
|
|
230
360
|
const appData = process.env.APPDATA ?? path.join(os.homedir(), "AppData", "Roaming");
|
|
231
361
|
const filePath = path.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "HermesLink.cmd");
|
|
232
362
|
const environment = autostartEnvironment();
|
|
@@ -318,6 +448,36 @@ function cmdEnvironmentLines(environment) {
|
|
|
318
448
|
([key, value]) => `set "${key}=${value.replaceAll('"', "")}"`
|
|
319
449
|
);
|
|
320
450
|
}
|
|
451
|
+
function powershellEnvironmentLines(environment) {
|
|
452
|
+
return Object.entries(environment).map(
|
|
453
|
+
([key, value]) => `[Environment]::SetEnvironmentVariable(${powershellString(key)}, ${powershellString(value)}, 'Process')`
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
function powershellString(value) {
|
|
457
|
+
return `'${value.replaceAll("'", "''")}'`;
|
|
458
|
+
}
|
|
459
|
+
function windowsCommandArgumentQuote(value) {
|
|
460
|
+
if (!/[ \t"]/u.test(value)) {
|
|
461
|
+
return value;
|
|
462
|
+
}
|
|
463
|
+
let result = '"';
|
|
464
|
+
let backslashes = 0;
|
|
465
|
+
for (const character of value) {
|
|
466
|
+
if (character === "\\") {
|
|
467
|
+
backslashes += 1;
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if (character === '"') {
|
|
471
|
+
result += `${"\\".repeat(backslashes * 2 + 1)}"`;
|
|
472
|
+
backslashes = 0;
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
result += `${"\\".repeat(backslashes)}${character}`;
|
|
476
|
+
backslashes = 0;
|
|
477
|
+
}
|
|
478
|
+
result += `${"\\".repeat(backslashes * 2)}"`;
|
|
479
|
+
return result;
|
|
480
|
+
}
|
|
321
481
|
|
|
322
482
|
// src/hermes/api-server-diagnostics.ts
|
|
323
483
|
function formatHermesApiServerUnavailable(error, language) {
|
|
@@ -1354,7 +1514,7 @@ program.command("doctor").option("--install", helpText("doctor.installOnly")).op
|
|
|
1354
1514
|
}
|
|
1355
1515
|
});
|
|
1356
1516
|
if (isCliEntrypoint()) {
|
|
1357
|
-
program.parseAsync(process.argv).catch(async (error) => {
|
|
1517
|
+
migrateLegacyAutostartBeforeParse(process.argv).then(() => program.parseAsync(process.argv)).catch(async (error) => {
|
|
1358
1518
|
const language = await loadCliLanguage().catch(() => detectSystemLanguage());
|
|
1359
1519
|
console.error(localizeErrorMessage(error, language));
|
|
1360
1520
|
process.exitCode = 1;
|
|
@@ -1364,6 +1524,12 @@ async function loadCliLanguage() {
|
|
|
1364
1524
|
const config = await loadConfig();
|
|
1365
1525
|
return resolveLanguage(config.language);
|
|
1366
1526
|
}
|
|
1527
|
+
async function migrateLegacyAutostartBeforeParse(argv) {
|
|
1528
|
+
if (argv[2] === "autostart" && argv[3] === "off") {
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1531
|
+
await migrateWindowsAutostartIfNeeded().catch(() => void 0);
|
|
1532
|
+
}
|
|
1367
1533
|
async function ensureUsageProbeFromCli(paths, t, language, activateGateways, source) {
|
|
1368
1534
|
console.log(t("usageProbe.ensure.started"));
|
|
1369
1535
|
let failedBeforeProfileScan = false;
|
package/dist/http/app.d.ts
CHANGED
|
@@ -824,6 +824,7 @@ declare class ConversationService {
|
|
|
824
824
|
private persistConversationStats;
|
|
825
825
|
private persistConversationStatsWithoutManifestRewrite;
|
|
826
826
|
private appendEvent;
|
|
827
|
+
private reportLiveActivityEvent;
|
|
827
828
|
private abortActiveRunsForConversation;
|
|
828
829
|
private hasActiveRunControllerForConversation;
|
|
829
830
|
private liveEventName;
|
package/dist/http/app.js
CHANGED