New:Socket for Asana Is Now Available.Learn more
Get Started

moshcode

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moshcode - npm Package Compare versions

Comparing version
0.76.0
to
0.77.0
+1
-1
package.json
{
"name": "moshcode",
"version": "0.76.0",
"version": "0.77.0",
"type": "module",

@@ -5,0 +5,0 @@ "description": "moshcode \u2014 a metal wrapper for coding engines and native UGig/CoinPay workflow CLIs, with OpenPRD and moshscript",

@@ -365,10 +365,28 @@ // Routing Moshpit TLDs to the local bridge, on whatever OS this is.

/** Is that pid actually ours and alive? A stale pidfile must not read as running. */
export function isAlive(pid) {
/**
* Is that pid alive? A stale pidfile must not read as running.
*
* "Alive" and "ours" are different questions, and answering the first with the
* second cost a machine its resolver. `process.kill(pid, 0)` fails two ways:
* ESRCH for a pid that is gone, and EPERM for one that is there but belongs to
* another user. Catching both as "dead" was wrong in precisely the case this
* tool manufactures — `dns enable` escalates, so the bridge is root's while
* every later `status` asking after it is not.
*
* A live root-owned bridge therefore read as a stale pidfile for the rest of
* its life: `stop` deleted the file and reported it cleared while the daemon
* kept running, and `start` saw nothing there and put a second bridge on
* 127.0.0.1 underneath the working one on 0.0.0.0 — the shadowing outage
* `bridgePresence` describes, arrived at by believing our own liveness check.
*
* So only ESRCH is dead. EPERM is alive and someone else's, which the caller
* needs told rather than papered over.
*/
export function isAlive(pid, kill = (target) => process.kill(target, 0)) {
if (!pid) return false;
try {
process.kill(pid, 0);
kill(pid);
return true;
} catch {
return false;
} catch (error) {
return error?.code === "EPERM";
}

@@ -375,0 +393,0 @@ }

@@ -142,3 +142,3 @@ // What an hour of agent time costs, written the way people say it out loud.

// silently multiply the invoice by every hour tracked.
if (!sawPeriod && rate.unit === "flat" && rate.cap === null) rate.per = "hour";
if (!sawPeriod && rate.unit === "flat" && rate.cap === null) rate.per = "project";
if (rate.cap !== null && rate.unit === "flat") {

@@ -145,0 +145,0 @@ throw new Error("upto: caps a unit, so say what it caps — $100/hour/agent/upto:4");