Feature hasn't been suggested before.
Describe the enhancement you want to request
I have a simple notification plugin like this:
import * as fs from 'fs/promises';
import * as path from 'path';
import * as os from 'os';
export const NotifyPlugin = async ({ project, client, $, directory, worktree }) => {
const icon = '/usr/share/icons/Adwaita/symbolic/status/mail-unread-symbolic.svg';
const appName = 'OpenCode';
const summary = 'Task Completed';
const body = 'OpenCode has finished the assigned task and is idle now.';
const hint = 'string:desktop-entry:ai.opencode.cli';
const logDir = path.join(os.homedir(), '.config', 'opencode', 'logs');
await fs.mkdir(logDir, { recursive: true }).catch(() => {});
const logFile = path.join(logDir, 'events.log');
return {
event: async ({ event }) => {
// Monitor session events
if (event.type.startsWith("session.")) {
const logEntry = JSON.stringify({ time: new Date().toISOString(), event }) + '\n';
await fs.appendFile(logFile, logEntry).catch(console.error);
}
// Send notification on session completion
if (event.type === "session.idle") {
$`canberra-gtk-play -i complete`; // play notification sound
await $`notify-send --app-name="${appName}" --icon=${icon} --urgency=critical --hint=${hint} "${summary}" "${body}"`;
}
},
}
}
This was supposed to notify me that opencode has done its assigned work. But after taking a subagent approach, I found that "session.idle" event is called both when the main agent or the subagent has just stopped working. This is a bit annoying.
I would like a way to determine if an event is of the main agent or the subagent. It is possible that I missed it somewhere. So if this is already possible, please point me to any documentation or give me some guides. Much appreciated.
If this is not already a thing, I'd propose to have an extra "event" field as "agent_id". The main agent's ID should be "main". And the other subagent might have some numerical ID or some sort.
Feature hasn't been suggested before.
Describe the enhancement you want to request
I have a simple notification plugin like this:
This was supposed to notify me that opencode has done its assigned work. But after taking a subagent approach, I found that "session.idle" event is called both when the main agent or the subagent has just stopped working. This is a bit annoying.
I would like a way to determine if an event is of the main agent or the subagent. It is possible that I missed it somewhere. So if this is already possible, please point me to any documentation or give me some guides. Much appreciated.
If this is not already a thing, I'd propose to have an extra "event" field as "agent_id". The main agent's ID should be "main". And the other subagent might have some numerical ID or some sort.