@mohak34/opencode-notifier 0.1.9 → 0.1.10
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/index.js +14 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3826,6 +3826,7 @@ function getSoundPath(config, event) {
|
|
|
3826
3826
|
// src/notify.ts
|
|
3827
3827
|
var import_node_notifier = __toESM(require_node_notifier(), 1);
|
|
3828
3828
|
import os from "os";
|
|
3829
|
+
import { exec } from "child_process";
|
|
3829
3830
|
var NOTIFICATION_TITLE = "OpenCode";
|
|
3830
3831
|
var DEBOUNCE_MS = 1000;
|
|
3831
3832
|
var platform = os.type();
|
|
@@ -3833,13 +3834,10 @@ var platformNotifier;
|
|
|
3833
3834
|
if (platform === "Linux" || platform.match(/BSD$/)) {
|
|
3834
3835
|
const { NotifySend } = import_node_notifier.default;
|
|
3835
3836
|
platformNotifier = new NotifySend({ withFallback: false });
|
|
3836
|
-
} else if (platform === "Darwin") {
|
|
3837
|
-
const { NotificationCenter } = import_node_notifier.default;
|
|
3838
|
-
platformNotifier = new NotificationCenter({ withFallback: true });
|
|
3839
3837
|
} else if (platform === "Windows_NT") {
|
|
3840
3838
|
const { WindowsToaster } = import_node_notifier.default;
|
|
3841
3839
|
platformNotifier = new WindowsToaster({ withFallback: false });
|
|
3842
|
-
} else {
|
|
3840
|
+
} else if (platform !== "Darwin") {
|
|
3843
3841
|
platformNotifier = import_node_notifier.default;
|
|
3844
3842
|
}
|
|
3845
3843
|
var lastNotificationTime = {};
|
|
@@ -3849,6 +3847,15 @@ async function sendNotification(message, timeout) {
|
|
|
3849
3847
|
return;
|
|
3850
3848
|
}
|
|
3851
3849
|
lastNotificationTime[message] = now;
|
|
3850
|
+
if (platform === "Darwin") {
|
|
3851
|
+
return new Promise((resolve) => {
|
|
3852
|
+
const escapedMessage = message.replace(/"/g, "\\\"");
|
|
3853
|
+
const escapedTitle = NOTIFICATION_TITLE.replace(/"/g, "\\\"");
|
|
3854
|
+
exec(`osascript -e 'display notification "${escapedMessage}" with title "${escapedTitle}"'`, () => {
|
|
3855
|
+
resolve();
|
|
3856
|
+
});
|
|
3857
|
+
});
|
|
3858
|
+
}
|
|
3852
3859
|
return new Promise((resolve) => {
|
|
3853
3860
|
const notificationOptions = {
|
|
3854
3861
|
title: NOTIFICATION_TITLE,
|
|
@@ -3856,9 +3863,6 @@ async function sendNotification(message, timeout) {
|
|
|
3856
3863
|
timeout,
|
|
3857
3864
|
icon: undefined
|
|
3858
3865
|
};
|
|
3859
|
-
if (platform === "Darwin") {
|
|
3860
|
-
notificationOptions.sound = false;
|
|
3861
|
-
}
|
|
3862
3866
|
platformNotifier.notify(notificationOptions, () => {
|
|
3863
3867
|
resolve();
|
|
3864
3868
|
});
|
|
@@ -3985,6 +3989,9 @@ var NotifierPlugin = async () => {
|
|
|
3985
3989
|
if (event.type === "session.error") {
|
|
3986
3990
|
await handleEvent(config, "error");
|
|
3987
3991
|
}
|
|
3992
|
+
},
|
|
3993
|
+
"permission.ask": async () => {
|
|
3994
|
+
await handleEvent(config, "permission");
|
|
3988
3995
|
}
|
|
3989
3996
|
};
|
|
3990
3997
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mohak34/opencode-notifier",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "OpenCode plugin that sends system notifications and plays sounds when permission is needed, generation completes, or errors occur",
|
|
5
5
|
"author": "mohak34",
|
|
6
6
|
"license": "MIT",
|