@herbertgao/pi-extensions 2026.8.15 → 2026.9.0
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/README.md +4 -1
- package/THIRD_PARTY_NOTICES.md +26 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +20 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +46 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +55 -17
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/packets.ts +6 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +5 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +34 -30
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +2 -2
- package/node_modules/@narumitw/pi-btw/README.md +5 -1
- package/node_modules/@narumitw/pi-btw/dist/index.ts +143 -14
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +3 -3
- package/node_modules/@narumitw/pi-btw/package.json +4 -4
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +158 -7
- package/node_modules/@narumitw/pi-btw/src/text.ts +18 -0
- package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +5 -16
- package/node_modules/@narumitw/pi-caffeinate/LICENSE +21 -0
- package/node_modules/@narumitw/pi-caffeinate/README.md +224 -0
- package/node_modules/@narumitw/pi-caffeinate/dist/index.ts +1112 -0
- package/node_modules/@narumitw/pi-caffeinate/dist/index.ts.map +7 -0
- package/node_modules/@narumitw/pi-caffeinate/package.json +53 -0
- package/node_modules/@narumitw/pi-caffeinate/src/caffeinate.ts +811 -0
- package/node_modules/@narumitw/pi-caffeinate/src/dbus-inhibit.ts +153 -0
- package/node_modules/@narumitw/pi-caffeinate/src/index.ts +1 -0
- package/node_modules/@narumitw/pi-caffeinate/src/inhibitor-process.ts +43 -0
- package/node_modules/@narumitw/pi-caffeinate/src/inhibitors.ts +167 -0
- package/node_modules/@narumitw/pi-caffeinate/src/settings.ts +202 -0
- package/node_modules/@tifan/pi-handoff/README.md +6 -3
- package/node_modules/@tifan/pi-handoff/package.json +1 -1
- package/node_modules/@tifan/pi-handoff/src/index.ts +8 -3
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +27 -0
- package/node_modules/pi-mcp-adapter/README.md +13 -13
- package/node_modules/pi-mcp-adapter/commands.ts +58 -21
- package/node_modules/pi-mcp-adapter/config.ts +18 -4
- package/node_modules/pi-mcp-adapter/direct-tools.ts +26 -6
- package/node_modules/pi-mcp-adapter/dist/config.d.ts +4 -0
- package/node_modules/pi-mcp-adapter/dist/config.js +13 -4
- package/node_modules/pi-mcp-adapter/dist/config.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/types.d.ts +11 -3
- package/node_modules/pi-mcp-adapter/dist/types.js.map +1 -1
- package/node_modules/pi-mcp-adapter/error-signal.ts +15 -4
- package/node_modules/pi-mcp-adapter/errors.ts +141 -0
- package/node_modules/pi-mcp-adapter/host-html-template.ts +58 -5
- package/node_modules/pi-mcp-adapter/index.ts +2 -3
- package/node_modules/pi-mcp-adapter/init.ts +5 -0
- package/node_modules/pi-mcp-adapter/mcp-panel.ts +30 -9
- package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +66 -28
- package/node_modules/pi-mcp-adapter/mcp-status.ts +2 -0
- package/node_modules/pi-mcp-adapter/package.json +2 -1
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +66 -13
- package/node_modules/pi-mcp-adapter/sandbox-proxy-template.ts +217 -0
- package/node_modules/pi-mcp-adapter/server-manager.ts +337 -6
- package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +1 -0
- package/node_modules/pi-mcp-adapter/types.ts +18 -3
- package/node_modules/pi-mcp-adapter/ui-resource-handler.ts +18 -2
- package/node_modules/pi-mcp-adapter/ui-server.ts +179 -54
- package/node_modules/pi-mcp-adapter/ui-session.ts +28 -8
- package/package.json +11 -7
|
@@ -0,0 +1,811 @@
|
|
|
1
|
+
import type { ChildProcess } from "node:child_process";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import type {
|
|
4
|
+
ExtensionAPI,
|
|
5
|
+
ExtensionCommandContext,
|
|
6
|
+
ExtensionContext,
|
|
7
|
+
} from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import {
|
|
9
|
+
type DbusScreenSaverClient,
|
|
10
|
+
type DbusScreenSaverFactory,
|
|
11
|
+
defaultDbusScreenSaverFactory,
|
|
12
|
+
INHIBIT_REASON,
|
|
13
|
+
SCREENSAVER_BUS_NAME,
|
|
14
|
+
} from "./dbus-inhibit.js";
|
|
15
|
+
import { startInhibitorProcess, stopInhibitorProcess } from "./inhibitor-process.js";
|
|
16
|
+
import { formatMode, getInhibitorCommand, type InhibitorCommand } from "./inhibitors.js";
|
|
17
|
+
import {
|
|
18
|
+
type CaffeinateMode,
|
|
19
|
+
type CaffeinateSettings,
|
|
20
|
+
loadSettings,
|
|
21
|
+
saveSettings,
|
|
22
|
+
settingsFilePath,
|
|
23
|
+
} from "./settings.js";
|
|
24
|
+
|
|
25
|
+
const STATUS_KEY = "caffeinate";
|
|
26
|
+
const DISABLED_VALUES = new Set(["1", "true", "yes", "on"]);
|
|
27
|
+
const DEFAULT_MODE = "display" satisfies CaffeinateMode;
|
|
28
|
+
const COMMAND_COMPLETIONS = [
|
|
29
|
+
{ value: "display", label: "display", description: "Keep system and display awake" },
|
|
30
|
+
{ value: "sleep", label: "sleep", description: "Keep system awake; allow display sleep" },
|
|
31
|
+
{ value: "status", label: "status", description: "Show current status" },
|
|
32
|
+
{ value: "mode", label: "mode", description: "Choose keep-awake mode" },
|
|
33
|
+
{ value: "stop", label: "stop", description: "Release inhibitor for now" },
|
|
34
|
+
{ value: "help", label: "help", description: "Show command help" },
|
|
35
|
+
];
|
|
36
|
+
const MENU_OPTIONS = {
|
|
37
|
+
display: "Keep system and display awake",
|
|
38
|
+
sleep: "Keep system awake; allow display sleep",
|
|
39
|
+
status: "Show current status",
|
|
40
|
+
stop: "Release inhibitor for now",
|
|
41
|
+
help: "Show command help",
|
|
42
|
+
} as const;
|
|
43
|
+
const MODE_OPTIONS = {
|
|
44
|
+
display: "Keep system and display awake",
|
|
45
|
+
sleep: "Keep system awake; allow display sleep",
|
|
46
|
+
} as const;
|
|
47
|
+
|
|
48
|
+
type CommandAction = "menu" | "help" | "status" | "mode" | "sleep" | "display" | "stop";
|
|
49
|
+
type CommandContext = ExtensionCommandContext;
|
|
50
|
+
|
|
51
|
+
interface CaffeinateOptions {
|
|
52
|
+
dbusFactory?: DbusScreenSaverFactory;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface PendingDbusStart {
|
|
56
|
+
token: number;
|
|
57
|
+
controller: AbortController;
|
|
58
|
+
client?: DbusScreenSaverClient;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface CaffeinateState {
|
|
62
|
+
process?: ChildProcess;
|
|
63
|
+
dbus?: DbusScreenSaverClient;
|
|
64
|
+
currentSession?: { generation: number; ctx: ExtensionContext };
|
|
65
|
+
dbusCleanup?: Promise<void>;
|
|
66
|
+
pendingDbus?: PendingDbusStart;
|
|
67
|
+
startedAt?: number;
|
|
68
|
+
command?: InhibitorCommand;
|
|
69
|
+
lastError?: string;
|
|
70
|
+
inhibitWarning?: string;
|
|
71
|
+
inhibitorStarting: boolean;
|
|
72
|
+
activeTurns: number;
|
|
73
|
+
available: boolean;
|
|
74
|
+
disabled: boolean;
|
|
75
|
+
mode: CaffeinateMode;
|
|
76
|
+
quiet: boolean;
|
|
77
|
+
settingsLoaded: boolean;
|
|
78
|
+
settingsError?: string;
|
|
79
|
+
settingsNotice?: string;
|
|
80
|
+
iconWarningShown: boolean;
|
|
81
|
+
sessionGeneration: number;
|
|
82
|
+
menuController: AbortController;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const state: CaffeinateState = {
|
|
86
|
+
activeTurns: 0,
|
|
87
|
+
available: true,
|
|
88
|
+
inhibitorStarting: false,
|
|
89
|
+
disabled: isDisabled(),
|
|
90
|
+
mode: DEFAULT_MODE,
|
|
91
|
+
quiet: false,
|
|
92
|
+
settingsLoaded: false,
|
|
93
|
+
iconWarningShown: false,
|
|
94
|
+
sessionGeneration: 0,
|
|
95
|
+
menuController: new AbortController(),
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
let dbusFactory = defaultDbusScreenSaverFactory;
|
|
99
|
+
let inhibitSequence = 0;
|
|
100
|
+
|
|
101
|
+
export default function caffeinate(pi: ExtensionAPI, options: CaffeinateOptions = {}) {
|
|
102
|
+
dbusFactory = options.dbusFactory ?? defaultDbusScreenSaverFactory;
|
|
103
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
104
|
+
const generation = ++state.sessionGeneration;
|
|
105
|
+
state.currentSession = { generation, ctx };
|
|
106
|
+
replaceMenuController("Caffeinate session replaced");
|
|
107
|
+
state.iconWarningShown = false;
|
|
108
|
+
state.settingsNotice = undefined;
|
|
109
|
+
warnDeprecatedIcon(ctx);
|
|
110
|
+
await loadSettingsIntoState(ctx, generation);
|
|
111
|
+
if (generation !== state.sessionGeneration) return;
|
|
112
|
+
updateStatus(ctx);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
pi.on("agent_start", async (_event, ctx) => {
|
|
116
|
+
const generation = state.sessionGeneration;
|
|
117
|
+
await ensureSettingsLoaded(ctx, generation);
|
|
118
|
+
if (generation !== state.sessionGeneration) return;
|
|
119
|
+
state.activeTurns += 1;
|
|
120
|
+
await startInhibitor(ctx, generation, { notify: !state.quiet });
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
pi.on("agent_end", async (_event, ctx) => {
|
|
124
|
+
const generation = state.sessionGeneration;
|
|
125
|
+
state.activeTurns = Math.max(0, state.activeTurns - 1);
|
|
126
|
+
if (state.activeTurns === 0) {
|
|
127
|
+
await stopInhibitor(ctx, "agent finished", { notify: !state.quiet });
|
|
128
|
+
}
|
|
129
|
+
if (generation !== state.sessionGeneration) return;
|
|
130
|
+
updateStatus(ctx);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
pi.on("session_shutdown", async (_event, ctx) => {
|
|
134
|
+
const generation = ++state.sessionGeneration;
|
|
135
|
+
state.currentSession = undefined;
|
|
136
|
+
state.menuController.abort(new DOMException("Caffeinate session shut down", "AbortError"));
|
|
137
|
+
state.activeTurns = 0;
|
|
138
|
+
await stopInhibitor(ctx, "session shutdown", { notify: false });
|
|
139
|
+
await modeOperationQueue;
|
|
140
|
+
if (generation !== state.sessionGeneration) return;
|
|
141
|
+
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
pi.registerCommand("caffeinate", {
|
|
145
|
+
description: "Open pi-caffeinate keep-awake controls",
|
|
146
|
+
getArgumentCompletions: (prefix) => commandCompletions(prefix),
|
|
147
|
+
handler: async (args, ctx) => {
|
|
148
|
+
const generation = state.sessionGeneration;
|
|
149
|
+
const command = parseCommand(args);
|
|
150
|
+
if (command === "sleep" || command === "display") {
|
|
151
|
+
await setModeAfterSettingsLoad(ctx, command, generation);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
await ensureSettingsLoaded(ctx, generation);
|
|
155
|
+
if (generation !== state.sessionGeneration) return;
|
|
156
|
+
await handleCaffeinateCommand(args, ctx, generation);
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function handleCaffeinateCommand(args: string, ctx: CommandContext, generation: number) {
|
|
162
|
+
const command = parseCommand(args);
|
|
163
|
+
switch (command) {
|
|
164
|
+
case "menu":
|
|
165
|
+
await showMenu(ctx, generation);
|
|
166
|
+
return;
|
|
167
|
+
case "help":
|
|
168
|
+
ctx.ui.notify(buildCommandGuide(), "info");
|
|
169
|
+
return;
|
|
170
|
+
case "status":
|
|
171
|
+
showStatus(ctx);
|
|
172
|
+
return;
|
|
173
|
+
case "mode":
|
|
174
|
+
await showModeSelector(ctx, generation);
|
|
175
|
+
return;
|
|
176
|
+
case "sleep":
|
|
177
|
+
await setMode(ctx, "sleep", generation);
|
|
178
|
+
return;
|
|
179
|
+
case "display":
|
|
180
|
+
await setMode(ctx, "display", generation);
|
|
181
|
+
return;
|
|
182
|
+
case "stop":
|
|
183
|
+
await stopCaffeinate(ctx, "manual stop", generation);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
ctx.ui.notify(`Unknown /caffeinate command: ${args.trim()}\n\n${buildCommandGuide()}`, "warning");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async function showMenu(ctx: CommandContext, generation: number) {
|
|
191
|
+
await runCaffeinateMenu(ctx, generation, "main");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async function showModeSelector(ctx: CommandContext, generation: number) {
|
|
195
|
+
await runCaffeinateMenu(ctx, generation, "mode");
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async function runCaffeinateMenu(ctx: CommandContext, generation: number, start: "main" | "mode") {
|
|
199
|
+
if (!ctx.hasUI) {
|
|
200
|
+
throw new Error(
|
|
201
|
+
start === "mode"
|
|
202
|
+
? "Mode selection requires TUI or RPC mode. Use /caffeinate sleep or /caffeinate display."
|
|
203
|
+
: `The pi-caffeinate menu requires TUI or RPC mode.\n\n${buildCommandGuide()}\n\n${describeState()}`,
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
const menuSignal = state.menuController.signal;
|
|
207
|
+
const isCurrent = () => generation === state.sessionGeneration && !menuSignal.aborted;
|
|
208
|
+
const { defineMenu, runMenu } = await import("@narumitw/pi-tui-kit");
|
|
209
|
+
if (!isCurrent()) return;
|
|
210
|
+
type Screen = "main" | "mode";
|
|
211
|
+
type Action = "display" | "sleep" | "status" | "stop" | "help";
|
|
212
|
+
const menu = defineMenu<undefined, Screen, Action>({
|
|
213
|
+
start,
|
|
214
|
+
screens: {
|
|
215
|
+
main: () => ({
|
|
216
|
+
kind: "actions",
|
|
217
|
+
title: "pi-caffeinate controls",
|
|
218
|
+
lines: describeState().split("\n"),
|
|
219
|
+
items: Object.entries(MENU_OPTIONS).map(([id, label]) => ({
|
|
220
|
+
id,
|
|
221
|
+
label,
|
|
222
|
+
action: id as Action,
|
|
223
|
+
})),
|
|
224
|
+
hint: "close",
|
|
225
|
+
}),
|
|
226
|
+
mode: () => ({
|
|
227
|
+
kind: "actions",
|
|
228
|
+
title: `pi-caffeinate mode (current: ${formatMode(state.mode)})`,
|
|
229
|
+
items: Object.entries(MODE_OPTIONS).map(([id, label]) => ({
|
|
230
|
+
id,
|
|
231
|
+
label,
|
|
232
|
+
action: id as Action,
|
|
233
|
+
})),
|
|
234
|
+
hint: "close",
|
|
235
|
+
}),
|
|
236
|
+
},
|
|
237
|
+
actions: {
|
|
238
|
+
display: async () => {
|
|
239
|
+
await setMode(ctx, "display", generation);
|
|
240
|
+
return { kind: "close" };
|
|
241
|
+
},
|
|
242
|
+
sleep: async () => {
|
|
243
|
+
await setMode(ctx, "sleep", generation);
|
|
244
|
+
return { kind: "close" };
|
|
245
|
+
},
|
|
246
|
+
status: async () => {
|
|
247
|
+
showStatus(ctx);
|
|
248
|
+
return { kind: "close" };
|
|
249
|
+
},
|
|
250
|
+
stop: async () => {
|
|
251
|
+
await stopCaffeinate(ctx, "manual stop", generation);
|
|
252
|
+
return { kind: "close" };
|
|
253
|
+
},
|
|
254
|
+
help: async () => {
|
|
255
|
+
ctx.ui.notify(buildCommandGuide(), "info");
|
|
256
|
+
return { kind: "close" };
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
await runMenu(ctx, menu, {
|
|
261
|
+
getState: () => undefined,
|
|
262
|
+
signal: menuSignal,
|
|
263
|
+
isCurrent,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function replaceMenuController(reason: string) {
|
|
268
|
+
state.menuController.abort(new DOMException(reason, "AbortError"));
|
|
269
|
+
state.menuController = new AbortController();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
let modeOperationQueue = Promise.resolve();
|
|
273
|
+
|
|
274
|
+
function setModeAfterSettingsLoad(
|
|
275
|
+
ctx: ExtensionContext,
|
|
276
|
+
mode: CaffeinateMode,
|
|
277
|
+
generation: number,
|
|
278
|
+
): Promise<void> {
|
|
279
|
+
return enqueueModeOperation(async () => {
|
|
280
|
+
await ensureSettingsLoaded(ctx, generation);
|
|
281
|
+
if (generation !== state.sessionGeneration) return;
|
|
282
|
+
await setModeNow(ctx, mode, generation);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function setMode(ctx: ExtensionContext, mode: CaffeinateMode, generation: number): Promise<void> {
|
|
287
|
+
return enqueueModeOperation(() => setModeNow(ctx, mode, generation));
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function enqueueModeOperation(operation: () => Promise<void>): Promise<void> {
|
|
291
|
+
const queued = modeOperationQueue.then(operation);
|
|
292
|
+
modeOperationQueue = queued.catch(() => undefined);
|
|
293
|
+
return queued;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
async function setModeNow(ctx: ExtensionContext, mode: CaffeinateMode, generation: number) {
|
|
297
|
+
if (generation !== state.sessionGeneration) return;
|
|
298
|
+
const previousMode = state.mode;
|
|
299
|
+
const previousQuiet = state.quiet;
|
|
300
|
+
const restartRequired = Boolean(
|
|
301
|
+
hasActiveInhibitor() && previousMode !== mode && !state.command?.custom,
|
|
302
|
+
);
|
|
303
|
+
state.settingsError = undefined;
|
|
304
|
+
|
|
305
|
+
if (restartRequired) {
|
|
306
|
+
state.mode = mode;
|
|
307
|
+
await stopInhibitor(ctx, "mode changed", { notify: false });
|
|
308
|
+
if (generation !== state.sessionGeneration) return;
|
|
309
|
+
await startInhibitor(ctx, generation, { notify: false });
|
|
310
|
+
if (generation !== state.sessionGeneration) return;
|
|
311
|
+
if (!hasActiveInhibitor()) {
|
|
312
|
+
const applicationError = state.lastError ?? "the inhibitor could not be restarted";
|
|
313
|
+
state.mode = previousMode;
|
|
314
|
+
await startInhibitor(ctx, generation, { notify: false });
|
|
315
|
+
if (generation !== state.sessionGeneration) return;
|
|
316
|
+
const rollbackError = hasActiveInhibitor()
|
|
317
|
+
? undefined
|
|
318
|
+
: (state.lastError ?? "the previous inhibitor could not be restored");
|
|
319
|
+
state.settingsError = rollbackError
|
|
320
|
+
? `mode application failed (${applicationError}); runtime rollback failed: ${rollbackError}`
|
|
321
|
+
: `mode application failed and was rolled back: ${applicationError}`;
|
|
322
|
+
ctx.ui.notify(`pi-caffeinate ${state.settingsError}`, "warning");
|
|
323
|
+
updateStatus(ctx);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
let savedSettings: CaffeinateSettings;
|
|
329
|
+
try {
|
|
330
|
+
savedSettings = await saveSettings({ mode, updatedAt: Date.now() });
|
|
331
|
+
} catch (error) {
|
|
332
|
+
if (generation !== state.sessionGeneration) return;
|
|
333
|
+
let rollbackError: string | undefined;
|
|
334
|
+
if (restartRequired) {
|
|
335
|
+
state.mode = previousMode;
|
|
336
|
+
state.quiet = previousQuiet;
|
|
337
|
+
await stopInhibitor(ctx, "settings save failed", { notify: false });
|
|
338
|
+
if (generation !== state.sessionGeneration) return;
|
|
339
|
+
await startInhibitor(ctx, generation, { notify: false });
|
|
340
|
+
if (generation !== state.sessionGeneration) return;
|
|
341
|
+
if (!hasActiveInhibitor()) {
|
|
342
|
+
rollbackError = state.lastError ?? "the prior inhibitor was not restored";
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
state.settingsError = rollbackError
|
|
346
|
+
? `settings save failed (${formatError(error)}); runtime rollback failed: ${rollbackError}`
|
|
347
|
+
: `settings save failed: ${formatError(error)}`;
|
|
348
|
+
ctx.ui.notify(
|
|
349
|
+
`pi-caffeinate mode remains ${formatMode(previousMode)}; settings were not saved: ${state.settingsError}`,
|
|
350
|
+
"warning",
|
|
351
|
+
);
|
|
352
|
+
updateStatus(ctx);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (generation !== state.sessionGeneration) return;
|
|
357
|
+
state.mode = mode;
|
|
358
|
+
state.quiet = savedSettings.quiet;
|
|
359
|
+
ctx.ui.notify(`pi-caffeinate mode set to ${formatMode(mode)} and saved.`, "info");
|
|
360
|
+
updateStatus(ctx);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function showStatus(ctx: ExtensionContext) {
|
|
364
|
+
ctx.ui.notify(describeState(), statusLevel());
|
|
365
|
+
updateStatus(ctx);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async function stopCaffeinate(ctx: ExtensionContext, reason: string, sessionGeneration: number) {
|
|
369
|
+
state.activeTurns = 0;
|
|
370
|
+
await stopInhibitor(ctx, reason);
|
|
371
|
+
if (sessionGeneration !== state.sessionGeneration) return;
|
|
372
|
+
updateStatus(ctx);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export function parseCommand(args: string): CommandAction | "unknown" {
|
|
376
|
+
const command = args.trim().toLowerCase();
|
|
377
|
+
if (!command) return "menu";
|
|
378
|
+
if (command === "help") return "help";
|
|
379
|
+
if (command === "status") return "status";
|
|
380
|
+
if (command === "mode" || command === "config" || command === "settings") return "mode";
|
|
381
|
+
if (command === "sleep" || command === "system") return "sleep";
|
|
382
|
+
if (command === "display" || command === "screen") return "display";
|
|
383
|
+
if (command === "stop" || command === "off") return "stop";
|
|
384
|
+
return "unknown";
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export function commandCompletions(prefix: string) {
|
|
388
|
+
const normalized = prefix.trimStart().toLowerCase();
|
|
389
|
+
if (/\s/.test(normalized)) return null;
|
|
390
|
+
|
|
391
|
+
const matches = COMMAND_COMPLETIONS.filter((completion) =>
|
|
392
|
+
completion.value.startsWith(normalized),
|
|
393
|
+
);
|
|
394
|
+
return matches.length > 0 ? matches : null;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function buildCommandGuide() {
|
|
398
|
+
return [
|
|
399
|
+
"pi-caffeinate commands:",
|
|
400
|
+
"/caffeinate — open keep-awake controls",
|
|
401
|
+
"/caffeinate display — keep the system and display awake",
|
|
402
|
+
"/caffeinate sleep — keep the system awake while allowing display sleep",
|
|
403
|
+
"/caffeinate status — show current mode, settings, and inhibitor state",
|
|
404
|
+
"/caffeinate mode — choose a keep-awake mode",
|
|
405
|
+
"/caffeinate stop — release the active inhibitor until the next agent run",
|
|
406
|
+
].join("\n");
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
async function startInhibitor(
|
|
410
|
+
ctx: ExtensionContext,
|
|
411
|
+
sessionGeneration: number,
|
|
412
|
+
options: { notify?: boolean } = {},
|
|
413
|
+
) {
|
|
414
|
+
if (state.disabled || hasActiveInhibitor() || state.inhibitorStarting) {
|
|
415
|
+
updateStatus(ctx);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const token = ++inhibitSequence;
|
|
420
|
+
const command = getInhibitorCommand(state.mode);
|
|
421
|
+
const wantsDbus =
|
|
422
|
+
!command?.custom &&
|
|
423
|
+
state.mode === "display" &&
|
|
424
|
+
process.platform === "linux" &&
|
|
425
|
+
(command === undefined || command.addDbusIdleInhibit === true);
|
|
426
|
+
if (!command && !wantsDbus) {
|
|
427
|
+
state.available = false;
|
|
428
|
+
state.lastError = `No supported sleep inhibitor found for ${process.platform}.`;
|
|
429
|
+
ctx.ui.notify(state.lastError, "warning");
|
|
430
|
+
updateStatus(ctx);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
state.inhibitorStarting = true;
|
|
435
|
+
state.inhibitWarning = undefined;
|
|
436
|
+
let child: ChildProcess | undefined;
|
|
437
|
+
let childError =
|
|
438
|
+
!command && wantsDbus
|
|
439
|
+
? "No supported system sleep inhibitor is available; direct system suspend may remain possible."
|
|
440
|
+
: undefined;
|
|
441
|
+
let assembling = true;
|
|
442
|
+
const handleChildFailure = (message: string) => {
|
|
443
|
+
if (!child || token !== inhibitSequence || state.process !== child) return;
|
|
444
|
+
state.process = undefined;
|
|
445
|
+
state.command = undefined;
|
|
446
|
+
if (assembling) {
|
|
447
|
+
childError = message;
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
applyChildFailure(message);
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
if (command) {
|
|
454
|
+
try {
|
|
455
|
+
child = startInhibitorProcess(
|
|
456
|
+
command,
|
|
457
|
+
(error) => handleChildFailure(`${command.description} failed: ${error.message}`),
|
|
458
|
+
(exit) => handleChildFailure(`${command.description} exited unexpectedly (${exit}).`),
|
|
459
|
+
);
|
|
460
|
+
state.process = child;
|
|
461
|
+
state.command = command;
|
|
462
|
+
state.startedAt = Date.now();
|
|
463
|
+
} catch (error) {
|
|
464
|
+
childError = `${command.description}: ${formatError(error)}`;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
let dbus: DbusScreenSaverClient | undefined;
|
|
469
|
+
let dbusError: string | undefined;
|
|
470
|
+
if (wantsDbus) {
|
|
471
|
+
const pending: PendingDbusStart = { token, controller: new AbortController() };
|
|
472
|
+
state.pendingDbus = pending;
|
|
473
|
+
try {
|
|
474
|
+
const client = await dbusFactory();
|
|
475
|
+
if (!pendingStartIsCurrent(pending, sessionGeneration)) {
|
|
476
|
+
await client.close().catch(() => undefined);
|
|
477
|
+
await cancelPendingStart(token, child, command);
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
pending.client = client;
|
|
481
|
+
await client.inhibit(INHIBIT_REASON, pending.controller.signal);
|
|
482
|
+
if (!pendingStartIsCurrent(pending, sessionGeneration)) {
|
|
483
|
+
await cancelPendingStart(token, child, command);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
pending.client = undefined;
|
|
487
|
+
state.pendingDbus = undefined;
|
|
488
|
+
dbus = client;
|
|
489
|
+
} catch (error) {
|
|
490
|
+
const stale =
|
|
491
|
+
!pendingStartIsCurrent(pending, sessionGeneration) || pending.controller.signal.aborted;
|
|
492
|
+
const pendingClient = takePendingDbusClient(pending);
|
|
493
|
+
await pendingClient?.close().catch(() => undefined);
|
|
494
|
+
if (stale) {
|
|
495
|
+
await cancelPendingStart(token, child, command);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
dbusError = `D-Bus idle inhibit (${SCREENSAVER_BUS_NAME}): ${formatError(error)}`;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
assembling = false;
|
|
503
|
+
if (startIsStale(token, sessionGeneration)) {
|
|
504
|
+
await cancelPendingStart(token, child, command);
|
|
505
|
+
await dbus?.close().catch(() => undefined);
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
state.inhibitorStarting = false;
|
|
510
|
+
state.dbus = dbus;
|
|
511
|
+
if (dbus) {
|
|
512
|
+
dbus.setFailureHandler((error) => applyDbusFailure(token, dbus, error));
|
|
513
|
+
if (state.dbus !== dbus) return;
|
|
514
|
+
}
|
|
515
|
+
const failures = [childError, dbusError].filter((failure): failure is string => Boolean(failure));
|
|
516
|
+
if (!hasActiveInhibitor()) {
|
|
517
|
+
state.startedAt = undefined;
|
|
518
|
+
state.command = undefined;
|
|
519
|
+
state.available = false;
|
|
520
|
+
state.lastError =
|
|
521
|
+
failures.join("; ") || `No supported sleep inhibitor found for ${process.platform}.`;
|
|
522
|
+
ctx.ui.notify(state.lastError, "warning");
|
|
523
|
+
updateStatus(ctx);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
state.startedAt ??= Date.now();
|
|
528
|
+
state.available = true;
|
|
529
|
+
state.lastError = undefined;
|
|
530
|
+
state.inhibitWarning = failures.length > 0 ? failures.join("; ") : undefined;
|
|
531
|
+
if (state.inhibitWarning) {
|
|
532
|
+
ctx.ui.notify(`pi-caffeinate is partially active: ${state.inhibitWarning}`, "warning");
|
|
533
|
+
} else if (options.notify !== false) {
|
|
534
|
+
ctx.ui.notify(`Keeping computer awake (${statusModeLabel()}).`, "info");
|
|
535
|
+
}
|
|
536
|
+
updateStatus(ctx);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
async function stopInhibitor(
|
|
540
|
+
ctx: ExtensionContext,
|
|
541
|
+
reason: string,
|
|
542
|
+
options: { notify?: boolean } = {},
|
|
543
|
+
) {
|
|
544
|
+
inhibitSequence += 1;
|
|
545
|
+
const child = state.process;
|
|
546
|
+
const dbus = state.dbus;
|
|
547
|
+
const dbusCleanup = state.dbusCleanup;
|
|
548
|
+
const pending = state.pendingDbus;
|
|
549
|
+
const command = state.command;
|
|
550
|
+
const wasStarting = state.inhibitorStarting;
|
|
551
|
+
state.process = undefined;
|
|
552
|
+
state.dbus = undefined;
|
|
553
|
+
state.dbusCleanup = undefined;
|
|
554
|
+
state.pendingDbus = undefined;
|
|
555
|
+
state.command = undefined;
|
|
556
|
+
state.startedAt = undefined;
|
|
557
|
+
state.inhibitWarning = undefined;
|
|
558
|
+
state.inhibitorStarting = false;
|
|
559
|
+
dbus?.setFailureHandler(undefined);
|
|
560
|
+
pending?.controller.abort(new DOMException(`Caffeinate stopped: ${reason}`, "AbortError"));
|
|
561
|
+
const pendingClient = pending ? takePendingDbusClient(pending) : undefined;
|
|
562
|
+
if (child) stopInhibitorProcess(child, command);
|
|
563
|
+
if (!child && !dbus && !pendingClient && !wasStarting) {
|
|
564
|
+
await dbusCleanup;
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
if (options.notify !== false) ctx.ui.notify(`Released pi-caffeinate (${reason}).`, "info");
|
|
568
|
+
await Promise.all([dbusCleanup, pendingClient?.close().catch(() => undefined)]);
|
|
569
|
+
if (!dbus) return;
|
|
570
|
+
try {
|
|
571
|
+
await dbus.uninhibit();
|
|
572
|
+
} catch {
|
|
573
|
+
// Closing the session-bus connection also releases its inhibition cookie.
|
|
574
|
+
}
|
|
575
|
+
await dbus.close().catch(() => undefined);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function applyChildFailure(message: string) {
|
|
579
|
+
if (state.dbus) {
|
|
580
|
+
state.available = true;
|
|
581
|
+
state.lastError = undefined;
|
|
582
|
+
state.inhibitWarning = message;
|
|
583
|
+
} else {
|
|
584
|
+
state.startedAt = undefined;
|
|
585
|
+
state.available = false;
|
|
586
|
+
state.lastError = message;
|
|
587
|
+
state.inhibitWarning = undefined;
|
|
588
|
+
}
|
|
589
|
+
const ctx = currentSessionContext();
|
|
590
|
+
if (!ctx) return;
|
|
591
|
+
ctx.ui.notify(message, "warning");
|
|
592
|
+
updateStatus(ctx);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function applyDbusFailure(token: number, client: DbusScreenSaverClient, error: Error) {
|
|
596
|
+
if (token !== inhibitSequence || state.dbus !== client) return;
|
|
597
|
+
client.setFailureHandler(undefined);
|
|
598
|
+
state.dbus = undefined;
|
|
599
|
+
const message = `D-Bus idle inhibit (${SCREENSAVER_BUS_NAME}) failed: ${formatError(error)}`;
|
|
600
|
+
const notification = state.process ? `pi-caffeinate is partially active: ${message}` : message;
|
|
601
|
+
if (state.process) {
|
|
602
|
+
state.available = true;
|
|
603
|
+
state.lastError = undefined;
|
|
604
|
+
state.inhibitWarning = message;
|
|
605
|
+
} else {
|
|
606
|
+
state.startedAt = undefined;
|
|
607
|
+
state.command = undefined;
|
|
608
|
+
state.available = false;
|
|
609
|
+
state.lastError = [state.inhibitWarning, message].filter(Boolean).join("; ");
|
|
610
|
+
state.inhibitWarning = undefined;
|
|
611
|
+
}
|
|
612
|
+
const cleanup = client.close().catch(() => undefined);
|
|
613
|
+
state.dbusCleanup = cleanup;
|
|
614
|
+
void cleanup.then(() => {
|
|
615
|
+
if (state.dbusCleanup === cleanup) state.dbusCleanup = undefined;
|
|
616
|
+
});
|
|
617
|
+
const ctx = currentSessionContext();
|
|
618
|
+
if (!ctx) return;
|
|
619
|
+
ctx.ui.notify(notification, "warning");
|
|
620
|
+
updateStatus(ctx);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function currentSessionContext() {
|
|
624
|
+
const session = state.currentSession;
|
|
625
|
+
return session?.generation === state.sessionGeneration ? session.ctx : undefined;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function hasActiveInhibitor() {
|
|
629
|
+
return Boolean(state.process || state.dbus);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function startIsStale(token: number, sessionGeneration: number) {
|
|
633
|
+
return token !== inhibitSequence || sessionGeneration !== state.sessionGeneration;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
function pendingStartIsCurrent(pending: PendingDbusStart, sessionGeneration: number) {
|
|
637
|
+
return (
|
|
638
|
+
state.pendingDbus === pending &&
|
|
639
|
+
!pending.controller.signal.aborted &&
|
|
640
|
+
!startIsStale(pending.token, sessionGeneration)
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function takePendingDbusClient(pending: PendingDbusStart) {
|
|
645
|
+
if (state.pendingDbus === pending) state.pendingDbus = undefined;
|
|
646
|
+
const client = pending.client;
|
|
647
|
+
pending.client = undefined;
|
|
648
|
+
return client;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
async function cancelPendingStart(
|
|
652
|
+
token: number,
|
|
653
|
+
child: ChildProcess | undefined,
|
|
654
|
+
command: InhibitorCommand | undefined,
|
|
655
|
+
) {
|
|
656
|
+
if (token !== inhibitSequence) return;
|
|
657
|
+
inhibitSequence += 1;
|
|
658
|
+
state.inhibitorStarting = false;
|
|
659
|
+
const pending = state.pendingDbus?.token === token ? state.pendingDbus : undefined;
|
|
660
|
+
state.pendingDbus = undefined;
|
|
661
|
+
pending?.controller.abort(new DOMException("Caffeinate start cancelled", "AbortError"));
|
|
662
|
+
const pendingClient = pending ? takePendingDbusClient(pending) : undefined;
|
|
663
|
+
if (child && state.process === child) {
|
|
664
|
+
state.process = undefined;
|
|
665
|
+
state.command = undefined;
|
|
666
|
+
state.startedAt = undefined;
|
|
667
|
+
stopInhibitorProcess(child, command);
|
|
668
|
+
}
|
|
669
|
+
await pendingClient?.close().catch(() => undefined);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function updateStatus(ctx: ExtensionContext) {
|
|
673
|
+
if (state.disabled || state.quiet) {
|
|
674
|
+
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
if (hasActiveInhibitor()) {
|
|
679
|
+
ctx.ui.setStatus(STATUS_KEY, withDeprecatedIcon(statusModeLabel()));
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
if (!state.available) {
|
|
684
|
+
ctx.ui.setStatus(STATUS_KEY, withDeprecatedIcon("unavailable"));
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
function describeState() {
|
|
692
|
+
const customCommand = hasCustomCommand();
|
|
693
|
+
const lines = [
|
|
694
|
+
`Mode: ${formatMode(state.mode)}${customCommand ? " (overridden by custom command)" : ""}`,
|
|
695
|
+
`Quiet mode: ${state.quiet ? "enabled" : "disabled"}`,
|
|
696
|
+
`Settings: ${settingsFilePath()}`,
|
|
697
|
+
];
|
|
698
|
+
|
|
699
|
+
if (customCommand) lines.push("Custom command: PI_CAFFEINATE_COMMAND overrides the saved mode.");
|
|
700
|
+
if (state.settingsNotice) lines.push(`Settings note: ${state.settingsNotice}`);
|
|
701
|
+
if (state.settingsError) lines.push(`Settings warning: ${state.settingsError}`);
|
|
702
|
+
if (state.disabled) {
|
|
703
|
+
lines.unshift("pi-caffeinate is disabled by PI_CAFFEINATE_DISABLED.");
|
|
704
|
+
return lines.join("\n");
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if (hasActiveInhibitor()) {
|
|
708
|
+
const seconds = state.startedAt ? Math.round((Date.now() - state.startedAt) / 1000) : 0;
|
|
709
|
+
const activeParts: string[] = [];
|
|
710
|
+
if (state.dbus) activeParts.push(`D-Bus idle inhibit (${SCREENSAVER_BUS_NAME})`);
|
|
711
|
+
if (state.process && state.command) activeParts.push(state.command.description);
|
|
712
|
+
lines.unshift(
|
|
713
|
+
`pi-caffeinate is active using ${activeParts.join(" + ") || "an inhibitor"} for ${seconds}s.`,
|
|
714
|
+
);
|
|
715
|
+
if (state.inhibitWarning) lines.push(`Inhibitor warning: ${state.inhibitWarning}`);
|
|
716
|
+
return lines.join("\n");
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
if (!state.available) {
|
|
720
|
+
lines.unshift(`pi-caffeinate is unavailable: ${state.lastError ?? "unknown reason"}`);
|
|
721
|
+
return lines.join("\n");
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
lines.unshift(
|
|
725
|
+
"pi-caffeinate is idle and will keep the computer awake during the next agent run.",
|
|
726
|
+
);
|
|
727
|
+
return lines.join("\n");
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
function statusLevel() {
|
|
731
|
+
return state.available && !state.settingsError && !state.inhibitWarning ? "info" : "warning";
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
function statusModeLabel() {
|
|
735
|
+
if (state.command?.custom) return "custom";
|
|
736
|
+
return formatMode(state.mode);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
async function ensureSettingsLoaded(ctx: ExtensionContext, generation: number) {
|
|
740
|
+
if (state.disabled || state.settingsLoaded) return;
|
|
741
|
+
await loadSettingsIntoState(ctx, generation);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
async function loadSettingsIntoState(ctx: ExtensionContext, generation: number) {
|
|
745
|
+
if (state.disabled) {
|
|
746
|
+
state.settingsLoaded = true;
|
|
747
|
+
state.settingsError = undefined;
|
|
748
|
+
state.quiet = false;
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
const settings = await loadSettings();
|
|
753
|
+
if (generation !== state.sessionGeneration) return;
|
|
754
|
+
state.settingsLoaded = true;
|
|
755
|
+
state.settingsError = undefined;
|
|
756
|
+
if (settings.notice) {
|
|
757
|
+
state.settingsNotice = settings.notice;
|
|
758
|
+
ctx.ui.notify(settings.notice, "warning");
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (settings.kind === "loaded") {
|
|
762
|
+
state.mode = settings.settings.mode;
|
|
763
|
+
state.quiet = settings.settings.quiet;
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
state.mode = DEFAULT_MODE;
|
|
768
|
+
state.quiet = false;
|
|
769
|
+
if (settings.kind === "invalid") {
|
|
770
|
+
state.settingsError = settings.reason;
|
|
771
|
+
ctx.ui.notify(
|
|
772
|
+
`pi-caffeinate settings ignored: ${settings.reason}; using ${formatMode(DEFAULT_MODE)} mode.`,
|
|
773
|
+
"warning",
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
function formatError(error: unknown) {
|
|
779
|
+
return error instanceof Error ? error.message : String(error);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
function isDisabled() {
|
|
783
|
+
const value = process.env.PI_CAFFEINATE_DISABLED?.trim().toLowerCase();
|
|
784
|
+
return value ? DISABLED_VALUES.has(value) : false;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
function hasCustomCommand() {
|
|
788
|
+
return Boolean(process.env.PI_CAFFEINATE_COMMAND?.trim());
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
function withDeprecatedIcon(text: string) {
|
|
792
|
+
const icon = process.env.PI_CAFFEINATE_ICON?.trim();
|
|
793
|
+
return icon ? `${icon} ${text}` : text;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
function warnDeprecatedIcon(ctx: ExtensionContext) {
|
|
797
|
+
if (state.iconWarningShown || !process.env.PI_CAFFEINATE_ICON?.trim()) return;
|
|
798
|
+
state.iconWarningShown = true;
|
|
799
|
+
ctx.ui.notify(
|
|
800
|
+
"PI_CAFFEINATE_ICON is deprecated but still works for now. If you use @narumitw/pi-statusline, move it to pi-statusline.json (extensionStatusIcons.caffeinate).",
|
|
801
|
+
"warning",
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
export {
|
|
806
|
+
formatMode,
|
|
807
|
+
getInhibitorCommand,
|
|
808
|
+
splitCommand,
|
|
809
|
+
windowsInhibitorScript,
|
|
810
|
+
} from "./inhibitors.js";
|
|
811
|
+
export { normalizeCaffeinateSettings } from "./settings.js";
|