mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +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
|
|
@ -865,6 +865,7 @@ export class AgentSession {
|
|||
this.sessionManager.newSession(options);
|
||||
this._steeringMessages = [];
|
||||
this._followUpMessages = [];
|
||||
this._pendingNextTurnMessages = [];
|
||||
this._reconnectToAgent();
|
||||
|
||||
// Emit session_switch event with reason "new" to hooks
|
||||
|
|
@ -1653,6 +1654,7 @@ export class AgentSession {
|
|||
await this.abort();
|
||||
this._steeringMessages = [];
|
||||
this._followUpMessages = [];
|
||||
this._pendingNextTurnMessages = [];
|
||||
|
||||
// Set new session
|
||||
this.sessionManager.setSessionFile(sessionPath);
|
||||
|
|
@ -1728,6 +1730,9 @@ export class AgentSession {
|
|||
skipConversationRestore = result?.skipConversationRestore ?? false;
|
||||
}
|
||||
|
||||
// Clear pending messages (bound to old session state)
|
||||
this._pendingNextTurnMessages = [];
|
||||
|
||||
if (!selectedEntry.parentId) {
|
||||
this.sessionManager.newSession();
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue