The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | // Effect-free so the service launcher shares the pre-lock owner identity check with server startup. |
| 2 | |
| 3 | export const legacyOwnerStartTimeCommand = (pid: number, platform: NodeJS.Platform) => { |
| 4 | const windows = platform === "win32"; |
| 5 | return { |
| 6 | command: windows ? "powershell.exe" : "ps", |
| 7 | args: windows |
| 8 | ? [ |
| 9 | "-NoProfile", |
| 10 | "-NonInteractive", |
| 11 | "-Command", |
| 12 | `(Get-Process -Id ${pid} -ErrorAction Stop).StartTime.ToUniversalTime().ToString('o')`, |
| 13 | ] |
| 14 | : ["-p", String(pid), "-o", "lstart="], |
| 15 | env: { LC_ALL: "C", TZ: "UTC" }, |
| 16 | }; |
| 17 | }; |
| 18 | |
| 19 | // ps reports whole seconds. Unknown identity (no output) stays conservative. |
| 20 | export const legacyOwnerStartedBeforeRecord = ( |
| 21 | output: string | undefined, |
| 22 | recordedAt: number, |
| 23 | platform: NodeJS.Platform, |
| 24 | ): boolean => { |
| 25 | if (output === undefined) return true; |
| 26 | const trimmed = output.trim(); |
| 27 | const startedAt = Date.parse(platform === "win32" ? trimmed : `${trimmed} UTC`); |
| 28 | return !Number.isFinite(startedAt) || startedAt <= recordedAt + 1_000; |
| 29 | }; |