@spencer-kit/agent-notify 0.1.0 → 0.1.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/dist/cli.js +56 -0
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -484,9 +484,11 @@ import { execFile } from "child_process";
|
|
|
484
484
|
var DesktopProvider = class {
|
|
485
485
|
commandExists;
|
|
486
486
|
run;
|
|
487
|
+
isWsl;
|
|
487
488
|
constructor(options = {}) {
|
|
488
489
|
this.commandExists = options.commandExists ?? commandAvailable;
|
|
489
490
|
this.run = options.run ?? runCommand;
|
|
491
|
+
this.isWsl = options.isWsl ?? defaultIsWsl;
|
|
490
492
|
}
|
|
491
493
|
async send(event) {
|
|
492
494
|
const title = formatNotificationTitle(event);
|
|
@@ -503,6 +505,14 @@ var DesktopProvider = class {
|
|
|
503
505
|
if (await this.commandExists("notify-send")) {
|
|
504
506
|
return this.execute(["notify-send", title, event.summary]);
|
|
505
507
|
}
|
|
508
|
+
if (this.isWsl() && await this.commandExists("powershell.exe")) {
|
|
509
|
+
return this.execute([
|
|
510
|
+
"powershell.exe",
|
|
511
|
+
"-NoProfile",
|
|
512
|
+
"-Command",
|
|
513
|
+
buildWindowsToastScript(title, event.summary)
|
|
514
|
+
]);
|
|
515
|
+
}
|
|
506
516
|
return false;
|
|
507
517
|
}
|
|
508
518
|
async execute(command) {
|
|
@@ -519,11 +529,13 @@ var SoundProvider = class {
|
|
|
519
529
|
run;
|
|
520
530
|
writeTerminalBell;
|
|
521
531
|
writeStdoutBell;
|
|
532
|
+
isWsl;
|
|
522
533
|
constructor(options = {}) {
|
|
523
534
|
this.commandExists = options.commandExists ?? commandAvailable;
|
|
524
535
|
this.run = options.run ?? runCommand;
|
|
525
536
|
this.writeTerminalBell = options.writeTerminalBell ?? defaultWriteTerminalBell;
|
|
526
537
|
this.writeStdoutBell = options.writeStdoutBell ?? defaultWriteStdoutBell;
|
|
538
|
+
this.isWsl = options.isWsl ?? defaultIsWsl;
|
|
527
539
|
}
|
|
528
540
|
async send(_event) {
|
|
529
541
|
for (const command of SOUND_COMMANDS) {
|
|
@@ -539,6 +551,20 @@ var SoundProvider = class {
|
|
|
539
551
|
continue;
|
|
540
552
|
}
|
|
541
553
|
}
|
|
554
|
+
if (this.isWsl() && await this.commandExists("powershell.exe")) {
|
|
555
|
+
try {
|
|
556
|
+
const result = await this.run([
|
|
557
|
+
"powershell.exe",
|
|
558
|
+
"-NoProfile",
|
|
559
|
+
"-Command",
|
|
560
|
+
"[console]::beep(880,200)"
|
|
561
|
+
]);
|
|
562
|
+
if (result.ok) {
|
|
563
|
+
return true;
|
|
564
|
+
}
|
|
565
|
+
} catch {
|
|
566
|
+
}
|
|
567
|
+
}
|
|
542
568
|
try {
|
|
543
569
|
await this.writeTerminalBell();
|
|
544
570
|
return true;
|
|
@@ -605,6 +631,36 @@ async function defaultWriteStdoutBell() {
|
|
|
605
631
|
function escapeAppleScriptString(value) {
|
|
606
632
|
return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"').replaceAll("\n", "\\n");
|
|
607
633
|
}
|
|
634
|
+
function defaultIsWsl() {
|
|
635
|
+
return Boolean(process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP);
|
|
636
|
+
}
|
|
637
|
+
function buildWindowsToastScript(title, summary) {
|
|
638
|
+
const xml = [
|
|
639
|
+
"<toast>",
|
|
640
|
+
" <visual>",
|
|
641
|
+
' <binding template="ToastGeneric">',
|
|
642
|
+
` <text>${escapeXml(title)}</text>`,
|
|
643
|
+
` <text>${escapeXml(summary)}</text>`,
|
|
644
|
+
" </binding>",
|
|
645
|
+
" </visual>",
|
|
646
|
+
"</toast>"
|
|
647
|
+
].join("");
|
|
648
|
+
return [
|
|
649
|
+
"[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null",
|
|
650
|
+
"[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] > $null",
|
|
651
|
+
"$xml = New-Object Windows.Data.Xml.Dom.XmlDocument",
|
|
652
|
+
`$xml.LoadXml('${escapePowerShellSingleQuotedString(xml)}')`,
|
|
653
|
+
"$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)",
|
|
654
|
+
"$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('agent-notify')",
|
|
655
|
+
"$notifier.Show($toast)"
|
|
656
|
+
].join("; ");
|
|
657
|
+
}
|
|
658
|
+
function escapeXml(value) {
|
|
659
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
660
|
+
}
|
|
661
|
+
function escapePowerShellSingleQuotedString(value) {
|
|
662
|
+
return value.replaceAll("'", "''");
|
|
663
|
+
}
|
|
608
664
|
|
|
609
665
|
// src/notifier.ts
|
|
610
666
|
var Notifier = class {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spencer-kit/agent-notify",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "CLI notifications for Codex and Claude Code task completion and attention events",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/spencerkit/agent-notify.git"
|
|
13
|
+
"url": "git+https://github.com/spencerkit/agent-notify.git"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|