@openma/cli 0.6.0 → 0.6.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/README.md +17 -0
- package/dist/index.js +80 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -35,6 +35,23 @@ oma api # HTTP API quick reference
|
|
|
35
35
|
|
|
36
36
|
Run `oma --help` for the full command tree.
|
|
37
37
|
|
|
38
|
+
## Local daemon power management
|
|
39
|
+
|
|
40
|
+
`oma bridge daemon` automatically keeps the machine available for local tasks
|
|
41
|
+
while it is running, including while idle and during graceful shutdown. The
|
|
42
|
+
screen can still turn off. No extra switch is required.
|
|
43
|
+
|
|
44
|
+
The adapter uses macOS `caffeinate`, Linux `systemd-inhibit`, or the Windows
|
|
45
|
+
power-management API through PowerShell. It releases the sleep assertion when
|
|
46
|
+
the daemon exits. If the OS denies the request or the helper is missing, the
|
|
47
|
+
daemon logs a warning and retries every 30 seconds. Linux requires logind and
|
|
48
|
+
permission to acquire an inhibitor; explicit sleep and OS policy may override
|
|
49
|
+
power requests.
|
|
50
|
+
|
|
51
|
+
Service-mode process recovery continues to use launchd KeepAlive on macOS and
|
|
52
|
+
systemd Restart=always on Linux. Windows currently installs a logon task, not a
|
|
53
|
+
crash-restart policy. Foreground execution has no external process supervisor.
|
|
54
|
+
|
|
38
55
|
## License
|
|
39
56
|
|
|
40
57
|
MIT
|
package/dist/index.js
CHANGED
|
@@ -7517,6 +7517,83 @@ var init_setup = __esm({
|
|
|
7517
7517
|
}
|
|
7518
7518
|
});
|
|
7519
7519
|
|
|
7520
|
+
// src/bridge/lib/keep-awake.ts
|
|
7521
|
+
import { spawn as spawn8 } from "node:child_process";
|
|
7522
|
+
function keepAwakeCommand(platform2, pid, node) {
|
|
7523
|
+
if (platform2 === "darwin") return { command: "/usr/bin/caffeinate", args: ["-i", "-w", String(pid)] };
|
|
7524
|
+
if (platform2 === "linux") return {
|
|
7525
|
+
command: "systemd-inhibit",
|
|
7526
|
+
args: [
|
|
7527
|
+
"--what=idle:sleep",
|
|
7528
|
+
"--who=OpenMA",
|
|
7529
|
+
"--why=OpenMA runner is available for local tasks",
|
|
7530
|
+
"--mode=block",
|
|
7531
|
+
node,
|
|
7532
|
+
"-e",
|
|
7533
|
+
'process.stdin.resume(); process.stdin.on("end", () => process.exit(0));'
|
|
7534
|
+
]
|
|
7535
|
+
};
|
|
7536
|
+
if (platform2 === "win32") return {
|
|
7537
|
+
command: "powershell.exe",
|
|
7538
|
+
args: ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", `
|
|
7539
|
+
$ErrorActionPreference = 'Stop'
|
|
7540
|
+
Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public static class OpenMAPower { [DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint flags); }'
|
|
7541
|
+
if ([OpenMAPower]::SetThreadExecutionState([uint32]2147483649) -eq 0) { throw 'Cannot prevent system idle sleep' }
|
|
7542
|
+
try { [Console]::In.ReadToEnd() | Out-Null } finally { [OpenMAPower]::SetThreadExecutionState([uint32]2147483648) | Out-Null }
|
|
7543
|
+
`]
|
|
7544
|
+
};
|
|
7545
|
+
return null;
|
|
7546
|
+
}
|
|
7547
|
+
function startKeepAwake(options) {
|
|
7548
|
+
const command = keepAwakeCommand(options.platform ?? process.platform, process.pid, process.execPath);
|
|
7549
|
+
if (!command) {
|
|
7550
|
+
options.warn("Automatic sleep prevention is unavailable on this platform");
|
|
7551
|
+
return () => {
|
|
7552
|
+
};
|
|
7553
|
+
}
|
|
7554
|
+
let stopped = false;
|
|
7555
|
+
let child;
|
|
7556
|
+
let retry;
|
|
7557
|
+
const launch = () => {
|
|
7558
|
+
if (stopped) return;
|
|
7559
|
+
let finished = false;
|
|
7560
|
+
const failed = () => {
|
|
7561
|
+
if (finished || stopped) return;
|
|
7562
|
+
finished = true;
|
|
7563
|
+
child = void 0;
|
|
7564
|
+
options.warn("Sleep prevention helper unavailable or exited; retrying in 30s. The OS may allow this runner to sleep.");
|
|
7565
|
+
retry = setTimeout(launch, 3e4);
|
|
7566
|
+
retry.unref();
|
|
7567
|
+
};
|
|
7568
|
+
try {
|
|
7569
|
+
child = (options.spawn ?? spawn8)(command.command, command.args, {
|
|
7570
|
+
stdio: ["pipe", "ignore", "ignore"],
|
|
7571
|
+
windowsHide: true
|
|
7572
|
+
});
|
|
7573
|
+
child.stdin?.on("error", () => {
|
|
7574
|
+
});
|
|
7575
|
+
child.once("error", failed);
|
|
7576
|
+
child.once("exit", failed);
|
|
7577
|
+
} catch {
|
|
7578
|
+
failed();
|
|
7579
|
+
}
|
|
7580
|
+
};
|
|
7581
|
+
launch();
|
|
7582
|
+
return () => {
|
|
7583
|
+
if (stopped) return;
|
|
7584
|
+
stopped = true;
|
|
7585
|
+
if (retry) clearTimeout(retry);
|
|
7586
|
+
child?.stdin?.end();
|
|
7587
|
+
if ((options.platform ?? process.platform) !== "linux") child?.kill();
|
|
7588
|
+
child = void 0;
|
|
7589
|
+
};
|
|
7590
|
+
}
|
|
7591
|
+
var init_keep_awake = __esm({
|
|
7592
|
+
"src/bridge/lib/keep-awake.ts"() {
|
|
7593
|
+
"use strict";
|
|
7594
|
+
}
|
|
7595
|
+
});
|
|
7596
|
+
|
|
7520
7597
|
// ../../node_modules/.pnpm/@openma+common@https+++codeload.github.com+openma-ai+openma-common+tar.gz+e196bdcac3d5f_8dd65d357989ef6fbff39c697b76e639/node_modules/@openma/common/dist/local-runtime/session-host.js
|
|
7521
7598
|
var systemRuntimeScheduler, ManagedAgentsSessionHost;
|
|
7522
7599
|
var init_session_host = __esm({
|
|
@@ -26667,6 +26744,7 @@ async function runDaemon() {
|
|
|
26667
26744
|
process.on("SIGTERM", onTerminate);
|
|
26668
26745
|
process.on("SIGINT", onInterrupt);
|
|
26669
26746
|
process.on("SIGHUP", onRefresh);
|
|
26747
|
+
const stopKeepAwake = startKeepAwake({ warn: (message) => log.warn(message) });
|
|
26670
26748
|
const pidPath = join8(paths().configDir, "daemon.pid");
|
|
26671
26749
|
try {
|
|
26672
26750
|
try {
|
|
@@ -26678,6 +26756,7 @@ async function runDaemon() {
|
|
|
26678
26756
|
host.start();
|
|
26679
26757
|
await stopped;
|
|
26680
26758
|
} finally {
|
|
26759
|
+
stopKeepAwake();
|
|
26681
26760
|
process.off("SIGTERM", onTerminate);
|
|
26682
26761
|
process.off("SIGINT", onInterrupt);
|
|
26683
26762
|
process.off("SIGHUP", onRefresh);
|
|
@@ -26692,6 +26771,7 @@ async function runDaemon() {
|
|
|
26692
26771
|
var init_daemon = __esm({
|
|
26693
26772
|
"src/bridge/commands/daemon.ts"() {
|
|
26694
26773
|
"use strict";
|
|
26774
|
+
init_keep_awake();
|
|
26695
26775
|
init_local_runtime();
|
|
26696
26776
|
init_config();
|
|
26697
26777
|
init_platform();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openma/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "CLI for the openma managed agents platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"typescript": "^7.0.2",
|
|
45
45
|
"vitest": "^4.1.3",
|
|
46
46
|
"ws": "^8.18.0",
|
|
47
|
+
"@open-managed-agents/acp-runtime": "0.0.0",
|
|
47
48
|
"@open-managed-agents/api-types": "0.1.0",
|
|
48
|
-
"@open-managed-agents/runtime": "0.1.0"
|
|
49
|
-
"@open-managed-agents/acp-runtime": "0.0.0"
|
|
49
|
+
"@open-managed-agents/runtime": "0.1.0"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --banner:js=\"#!/usr/bin/env node\nimport { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);\"",
|