UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

3 lines (2 loc) • 1.28 kB
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } } import{uptime as osUptimeSeconds}from"node:os";import{workerData}from"node:worker_threads";var BOOT_INSTANT_TOLERANCE_MS=12e4,wholeSeconds=ms=>Math.round(ms/1e3)*1e3;function processBootAtMs(now=Date.now){return wholeSeconds(now()-osUptimeSeconds()*1e3)}var floorToSecond=ms=>Math.floor(ms/1e3)*1e3,hostIdentity=workerData,OWN_START_AT_LOAD=typeof hostIdentity=="object"&&hostIdentity!==null&&"hostProcessStartedAtMs"in hostIdentity&&typeof hostIdentity.hostProcessStartedAtMs=="number"&&Number.isFinite(hostIdentity.hostProcessStartedAtMs)?hostIdentity.hostProcessStartedAtMs:floorToSecond(Date.now()-process.uptime()*1e3);function ownProcessStartedAtMs(now){return now===void 0?OWN_START_AT_LOAD:floorToSecond(now()-process.uptime()*1e3)}function sameBoot(bootAtMs,otherBootAtMs){return otherBootAtMs===void 0||!Number.isFinite(otherBootAtMs)?!1:Math.abs(bootAtMs-otherBootAtMs)<=BOOT_INSTANT_TOLERANCE_MS}export{BOOT_INSTANT_TOLERANCE_MS,processBootAtMs,ownProcessStartedAtMs,sameBoot};