neurastream 0.2.75 → 0.2.77
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/package.json
CHANGED
|
@@ -632,10 +632,18 @@ export function deliverOwnerInbox(pi: ExtensionHost, cfg: Config): void {
|
|
|
632
632
|
let activeAdapterReset: (() => void) | null = null;
|
|
633
633
|
/** The limit tick: one check of the open episode every 30 s (plan 20261027_1500 P3). */
|
|
634
634
|
const LIMIT_TICK_MS = 30_000;
|
|
635
|
+
/** The probe's command line and env. Never process.execPath: inside the harness that is the omp
|
|
636
|
+
* binary, so the child was a full Main session (2026-11-03: stray Mains). bun comes from PATH, as
|
|
637
|
+
* every bin's `#!/usr/bin/env bun` shebang does; the child env drops MAIN_ENV. */
|
|
638
|
+
export function limitProbeSpawn(env: NodeJS.ProcessEnv = process.env): { cmd: string; args: string[]; env: NodeJS.ProcessEnv } {
|
|
639
|
+
const { [MAIN_ENV]: _main, ...rest } = env;
|
|
640
|
+
return { cmd: "nice", args: ["-n", "19", "bun", join(import.meta.dir, "../../cli/limit-probe.ts")], env: rest };
|
|
641
|
+
}
|
|
635
642
|
/** One limit probe as a niced child (cli/limit-probe.ts). It writes the episode state itself;
|
|
636
643
|
* a failed start is logged and the next tick tries again. */
|
|
637
644
|
function spawnLimitProbeChild(cfg: Config): void {
|
|
638
|
-
const
|
|
645
|
+
const p = limitProbeSpawn();
|
|
646
|
+
const child = spawn(p.cmd, p.args, { detached: true, stdio: "ignore", env: p.env });
|
|
639
647
|
child.on("error", err => adapterLog(cfg, `RATE-LIMIT probe: could not start: ${err.message}`));
|
|
640
648
|
child.unref();
|
|
641
649
|
}
|
|
@@ -6,6 +6,7 @@ THRESH_IO=${THRESH_IO:-40}
|
|
|
6
6
|
COOLDOWN=${COOLDOWN:-600}
|
|
7
7
|
STATE_DIR=${ALERT_STATE:?}
|
|
8
8
|
mkdir -p "$STATE_DIR"
|
|
9
|
+
NOTIFY_TIMEOUT_MS=${NOTIFY_TIMEOUT_MS:-10000}
|
|
9
10
|
|
|
10
11
|
alert() {
|
|
11
12
|
local last now
|
|
@@ -13,7 +14,7 @@ alert() {
|
|
|
13
14
|
now=$(date +%s)
|
|
14
15
|
if (( now - last >= COOLDOWN )); then
|
|
15
16
|
echo "$now" > "$STATE_DIR/$1"
|
|
16
|
-
notify-send -u
|
|
17
|
+
notify-send -u normal -t "$NOTIFY_TIMEOUT_MS" -a "resource-alerts" "$2" "$3" || true
|
|
17
18
|
fi
|
|
18
19
|
}
|
|
19
20
|
|