@narumitw/pi-caffeinate 0.4.1 → 0.4.3
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 +2 -2
- package/src/caffeinate.ts +7 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-caffeinate",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Pi extension that keeps the computer awake while the agent is running.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@biomejs/biome": "2.4.14",
|
|
33
|
-
"@
|
|
33
|
+
"@earendil-works/pi-coding-agent": "0.74.0",
|
|
34
34
|
"@types/node": "25.6.0",
|
|
35
35
|
"typescript": "6.0.3"
|
|
36
36
|
},
|
package/src/caffeinate.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
ExtensionAPI,
|
|
10
10
|
ExtensionCommandContext,
|
|
11
11
|
ExtensionContext,
|
|
12
|
-
} from "@
|
|
12
|
+
} from "@earendil-works/pi-coding-agent";
|
|
13
13
|
|
|
14
14
|
const STATUS_KEY = "caffeinate";
|
|
15
15
|
const DISABLED_VALUES = new Set(["1", "true", "yes", "on"]);
|
|
@@ -229,7 +229,7 @@ function stopCaffeinate(ctx: ExtensionContext, reason: string) {
|
|
|
229
229
|
updateStatus(ctx);
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
function parseCommand(args: string): CommandAction | "unknown" {
|
|
232
|
+
export function parseCommand(args: string): CommandAction | "unknown" {
|
|
233
233
|
const command = args.trim().toLowerCase();
|
|
234
234
|
if (!command) return "menu";
|
|
235
235
|
if (command === "help") return "help";
|
|
@@ -241,7 +241,7 @@ function parseCommand(args: string): CommandAction | "unknown" {
|
|
|
241
241
|
return "unknown";
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
function commandCompletions(prefix: string) {
|
|
244
|
+
export function commandCompletions(prefix: string) {
|
|
245
245
|
const normalized = prefix.trim().toLowerCase();
|
|
246
246
|
if (normalized.includes(" ")) return null;
|
|
247
247
|
|
|
@@ -455,7 +455,7 @@ function commandExists(command: string) {
|
|
|
455
455
|
return false;
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
-
function splitCommand(input: string) {
|
|
458
|
+
export function splitCommand(input: string) {
|
|
459
459
|
const parts: string[] = [];
|
|
460
460
|
let current = "";
|
|
461
461
|
let quote: '"' | "'" | undefined;
|
|
@@ -507,7 +507,7 @@ function windowsPowerInhibitorCommand(command: string, mode: CaffeinateMode): In
|
|
|
507
507
|
};
|
|
508
508
|
}
|
|
509
509
|
|
|
510
|
-
function windowsInhibitorScript(mode: CaffeinateMode) {
|
|
510
|
+
export function windowsInhibitorScript(mode: CaffeinateMode) {
|
|
511
511
|
const flags = mode === "sleep" ? "0x80000001" : "0x80000003";
|
|
512
512
|
return `$ErrorActionPreference = 'Stop'; Add-Type -Namespace Native -Name Power -MemberDefinition '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint esFlags);'; $flags = [uint32]'${flags}'; $release = [uint32]'0x80000000'; $stdin = [Console]::OpenStandardInput(); $buffer = New-Object byte[] 1; $readTask = $stdin.ReadAsync($buffer, 0, 1); try { while ($true) { [Native.Power]::SetThreadExecutionState($flags) | Out-Null; if ($readTask.Wait(30000)) { break } } } finally { [Native.Power]::SetThreadExecutionState($release) | Out-Null }`;
|
|
513
513
|
}
|
|
@@ -579,7 +579,7 @@ function statusModeLabel() {
|
|
|
579
579
|
return state.mode === "sleep" ? "sleep" : "display";
|
|
580
580
|
}
|
|
581
581
|
|
|
582
|
-
function formatMode(mode: CaffeinateMode) {
|
|
582
|
+
export function formatMode(mode: CaffeinateMode) {
|
|
583
583
|
return mode === "sleep" ? "sleep-only" : "display-awake";
|
|
584
584
|
}
|
|
585
585
|
|
|
@@ -637,7 +637,7 @@ async function loadSettings(): Promise<
|
|
|
637
637
|
}
|
|
638
638
|
}
|
|
639
639
|
|
|
640
|
-
function normalizeCaffeinateSettings(value: unknown): CaffeinateSettings | undefined {
|
|
640
|
+
export function normalizeCaffeinateSettings(value: unknown): CaffeinateSettings | undefined {
|
|
641
641
|
if (!value || typeof value !== "object") return undefined;
|
|
642
642
|
const settings = value as { mode?: unknown; updatedAt?: unknown };
|
|
643
643
|
if (!isCaffeinateMode(settings.mode)) return undefined;
|