@mohak34/opencode-notifier 0.1.9 → 0.1.11
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 -4
- package/dist/index.js +27 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ To pin a specific version:
|
|
|
18
18
|
|
|
19
19
|
```json
|
|
20
20
|
{
|
|
21
|
-
"plugin": ["@mohak34/opencode-notifier@0.1.
|
|
21
|
+
"plugin": ["@mohak34/opencode-notifier@0.1.10"]
|
|
22
22
|
}
|
|
23
23
|
```
|
|
24
24
|
|
|
@@ -46,13 +46,13 @@ Remove-Item -Recurse -Force "$env:USERPROFILE\.cache\opencode\node_modules\@moha
|
|
|
46
46
|
|
|
47
47
|
Then restart OpenCode - it will download the latest version automatically.
|
|
48
48
|
|
|
49
|
-
### If you use a pinned version (e.g., `@0.1.
|
|
49
|
+
### If you use a pinned version (e.g., `@0.1.10`)
|
|
50
50
|
|
|
51
51
|
1. Update the version in your `opencode.json`:
|
|
52
52
|
|
|
53
53
|
```json
|
|
54
54
|
{
|
|
55
|
-
"plugin": ["@mohak34/opencode-notifier@0.1.
|
|
55
|
+
"plugin": ["@mohak34/opencode-notifier@0.1.10"]
|
|
56
56
|
}
|
|
57
57
|
```
|
|
58
58
|
|
|
@@ -177,7 +177,7 @@ If a custom sound file path is provided but the file doesn't exist, the plugin w
|
|
|
177
177
|
|
|
178
178
|
### macOS: Notifications not showing (only sound works)
|
|
179
179
|
|
|
180
|
-
**Update to v0.1.
|
|
180
|
+
**Update to v0.1.10 or later** - this version includes a fix for macOS notification events.
|
|
181
181
|
|
|
182
182
|
If notifications still don't work after updating:
|
|
183
183
|
|
package/dist/index.js
CHANGED
|
@@ -3731,11 +3731,11 @@ import { readFileSync, existsSync } from "fs";
|
|
|
3731
3731
|
import { join } from "path";
|
|
3732
3732
|
import { homedir } from "os";
|
|
3733
3733
|
var DEFAULT_EVENT_CONFIG = {
|
|
3734
|
-
sound:
|
|
3734
|
+
sound: true,
|
|
3735
3735
|
notification: true
|
|
3736
3736
|
};
|
|
3737
3737
|
var DEFAULT_CONFIG = {
|
|
3738
|
-
sound:
|
|
3738
|
+
sound: true,
|
|
3739
3739
|
notification: true,
|
|
3740
3740
|
timeout: 5,
|
|
3741
3741
|
events: {
|
|
@@ -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
|
});
|
|
@@ -3875,7 +3879,17 @@ var __dirname2 = dirname(fileURLToPath(import.meta.url));
|
|
|
3875
3879
|
var DEBOUNCE_MS2 = 1000;
|
|
3876
3880
|
var lastSoundTime = {};
|
|
3877
3881
|
function getBundledSoundPath(event) {
|
|
3878
|
-
|
|
3882
|
+
const soundFilename = `${event}.wav`;
|
|
3883
|
+
const possiblePaths = [
|
|
3884
|
+
join2(__dirname2, "..", "sounds", soundFilename),
|
|
3885
|
+
join2(__dirname2, "sounds", soundFilename)
|
|
3886
|
+
];
|
|
3887
|
+
for (const path of possiblePaths) {
|
|
3888
|
+
if (existsSync2(path)) {
|
|
3889
|
+
return path;
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
return join2(__dirname2, "..", "sounds", soundFilename);
|
|
3879
3893
|
}
|
|
3880
3894
|
function getSoundFilePath(event, customPath) {
|
|
3881
3895
|
if (customPath && existsSync2(customPath)) {
|
|
@@ -3985,6 +3999,9 @@ var NotifierPlugin = async () => {
|
|
|
3985
3999
|
if (event.type === "session.error") {
|
|
3986
4000
|
await handleEvent(config, "error");
|
|
3987
4001
|
}
|
|
4002
|
+
},
|
|
4003
|
+
"permission.ask": async () => {
|
|
4004
|
+
await handleEvent(config, "permission");
|
|
3988
4005
|
}
|
|
3989
4006
|
};
|
|
3990
4007
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mohak34/opencode-notifier",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
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",
|