@mohak34/opencode-notifier 0.1.1 → 0.1.2

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 CHANGED
@@ -1,4 +1,4 @@
1
- # @mohak34/opencode-notifier
1
+ # opencode-notifier
2
2
 
3
3
  OpenCode plugin that plays sounds and sends system notifications when permission is needed, generation completes, or errors occur. Works on macOS, Linux, and Windows.
4
4
 
package/dist/index.js CHANGED
@@ -3826,7 +3826,11 @@ function getSoundPath(config, event) {
3826
3826
  // src/notify.ts
3827
3827
  var import_node_notifier = __toESM(require_node_notifier(), 1);
3828
3828
  var NOTIFICATION_TITLE = "OpenCode";
3829
+ function debug(msg) {
3830
+ console.error(`[opencode-notifier] ${msg}`);
3831
+ }
3829
3832
  async function sendNotification(message, timeout) {
3833
+ debug(`Sending notification: "${message}" (timeout: ${timeout}s)`);
3830
3834
  return new Promise((resolve) => {
3831
3835
  import_node_notifier.default.notify({
3832
3836
  title: NOTIFICATION_TITLE,
@@ -3834,7 +3838,12 @@ async function sendNotification(message, timeout) {
3834
3838
  sound: false,
3835
3839
  timeout,
3836
3840
  icon: undefined
3837
- }, () => {
3841
+ }, (err, response, metadata) => {
3842
+ if (err) {
3843
+ debug(`Notification error: ${err}`);
3844
+ } else {
3845
+ debug(`Notification sent. Response: ${response}, Metadata: ${JSON.stringify(metadata)}`);
3846
+ }
3838
3847
  resolve();
3839
3848
  });
3840
3849
  });
@@ -3925,22 +3934,32 @@ async function playSound(event, customPath) {
3925
3934
  }
3926
3935
 
3927
3936
  // src/index.ts
3937
+ function debug2(msg) {
3938
+ console.error(`[opencode-notifier] ${msg}`);
3939
+ }
3928
3940
  async function handleEvent(config, eventType) {
3941
+ debug2(`Handling event: ${eventType}`);
3942
+ debug2(`Config for ${eventType}: sound=${isEventSoundEnabled(config, eventType)}, notification=${isEventNotificationEnabled(config, eventType)}`);
3929
3943
  const promises = [];
3930
3944
  if (isEventNotificationEnabled(config, eventType)) {
3931
3945
  const message = getMessage(config, eventType);
3946
+ debug2(`Queueing notification: "${message}"`);
3932
3947
  promises.push(sendNotification(message, config.timeout));
3933
3948
  }
3934
3949
  if (isEventSoundEnabled(config, eventType)) {
3935
3950
  const customSoundPath = getSoundPath(config, eventType);
3951
+ debug2(`Queueing sound: ${customSoundPath || "default"}`);
3936
3952
  promises.push(playSound(eventType, customSoundPath));
3937
3953
  }
3938
3954
  await Promise.allSettled(promises);
3955
+ debug2(`Event ${eventType} handled`);
3939
3956
  }
3940
3957
  var NotifierPlugin = async () => {
3941
3958
  const config = loadConfig();
3959
+ debug2(`Plugin loaded. Config: ${JSON.stringify(config)}`);
3942
3960
  return {
3943
3961
  event: async ({ event }) => {
3962
+ debug2(`Received event: ${event.type}`);
3944
3963
  if (event.type === "permission.updated") {
3945
3964
  await handleEvent(config, "permission");
3946
3965
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mohak34/opencode-notifier",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
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",