mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 14:02:51 +00:00
Fix event bus async error handling, clear pending messages on session switch, improve SDK docs
- event-bus.ts: await async handlers to catch errors properly - agent-session.ts: clear _pendingNextTurnMessages on newSession/switchSession/branch - sdk.ts: make eventBus first (required) param for discoverHooks/discoverCustomTools - docs/sdk.md: document eventBus sharing pattern for hook/tool communication
This commit is contained in:
parent
024ec33bf2
commit
be330fdd9c
4 changed files with 35 additions and 13 deletions
|
|
@ -16,9 +16,9 @@ export function createEventBus(): EventBusController {
|
|||
emitter.emit(channel, data);
|
||||
},
|
||||
on: (channel, handler) => {
|
||||
const safeHandler = (data: unknown) => {
|
||||
const safeHandler = async (data: unknown) => {
|
||||
try {
|
||||
handler(data);
|
||||
await handler(data);
|
||||
} catch (err) {
|
||||
console.error(`Event handler error (${channel}):`, err);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue