@xiaoqiong0v0/opencode-sound-notify 1.1.6 → 1.1.7

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.
@@ -45,8 +45,9 @@ const TX = {
45
45
  no_sound_file: { zh: "声音文件不存在: {path}", en: "Sound file not found: {path}" },
46
46
  muted_on: { zh: "声音已关闭", en: "Sound muted" },
47
47
  muted_off: { zh: "声音已开启", en: "Sound unmuted" },
48
- mute_desc: { zh: "开/关提示音", en: "Toggle notification sound" },
49
- mute_template: { zh: "用户想要切换声音状态。调用 sound_toggle 工具。", en: "User wants to toggle sound. Call sound_toggle tool." },
48
+ mute_desc: { zh: "控制提示音开关:action=on 开启,action=off 关闭,action=toggle 切换", en: "Control notification sound: action=on to enable, action=off to disable, action=toggle to switch" },
49
+ mute_template: { zh: "用户想要切换声音状态。调用 sound_toggle 工具,action 参数:on=开启,off=关闭,toggle=切换。", en: "User wants to control sound. Call sound_toggle tool: action=on to enable, action=off to disable, action=toggle to switch." },
50
+ mute_action: { zh: "on 开启声音 off 关闭声音 toggle 切换", en: "on enable off disable toggle switch" },
50
51
  };
51
52
  const T = (key, params) => {
52
53
  const entry = TX[key] || { zh: key, en: key };
@@ -86,6 +87,7 @@ catch (e) {
86
87
  log.error(T("init_failed"), e instanceof Error ? e : Error(String(e)));
87
88
  }
88
89
  const eventTimestamps = new Map();
90
+ const subSessions = new Set();
89
91
  let globalLastPlay = 0;
90
92
  function getPlayerArgs(sound) {
91
93
  switch (process.platform) {
@@ -174,15 +176,23 @@ export const SoundNotify = async () => {
174
176
  }
175
177
  },
176
178
  event: async ({ event }) => {
177
- if (shouldPlay(event.type)) {
178
- play(event.type);
179
+ if (event.type === "session.created") {
180
+ const info = event.properties?.info;
181
+ if (info?.parentID)
182
+ subSessions.add(info.id);
183
+ return;
179
184
  }
185
+ const sid = event.properties?.sessionID;
186
+ if (sid && subSessions.has(sid))
187
+ return;
188
+ if (shouldPlay(event.type))
189
+ play(event.type);
180
190
  },
181
191
  tool: {
182
192
  sound_toggle: tool({
183
193
  description: T("mute_desc"),
184
194
  args: {
185
- action: tool.schema.enum(["on", "off", "toggle"]).optional().describe("on=开启 off=关闭 toggle=切换"),
195
+ action: tool.schema.enum(["on", "off", "toggle"]).describe(T("mute_action")),
186
196
  },
187
197
  execute: async ({ action }) => {
188
198
  if (action === "on")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiaoqiong0v0/opencode-sound-notify",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin: play notification sounds on session events (idle, error, permission asked).",
6
6
  "files": [