eventHistorian posts summary on conversation stopped#154
Conversation
introduces auth/access.ts and per-agent capabilities.ts; grants are resolved from agentConfig on save
…cess add agentDispatcher that checks read access and dispatches events to authorized agents in Agenda job
assume single folder per agent and load capabilities.ts as agentType.capabilities if present
| await doc.save() | ||
|
|
||
| const topicId = doc.topic?._id?.toString() ?? doc.topic?.toString() | ||
| const topicIsPrivate = doc.topic?.private ?? false |
There was a problem hiding this comment.
Heads up, I think there's a way for private-topic summaries to leak here. We pull topicIsPrivate off doc.topic.private, but if topic came back as just an ID (not populated with the full topic doc), then .private is undefined and we fall back to false. That makes the topic look public, and any agent with the allPublicTopics grant will get the summary even though the event was private.
Two options that would fix this:
- Make sure topic is populated (or do a quick Topic.findById(...).select('private').lean()) before reading .private.
- Default to true if we can't tell. Better to skip a legit dispatch than to leak a private one.
There was a problem hiding this comment.
Good call. Will default to private.
| logger.debug(`conversationEvent handler ${agent._id} - event type: ${event.type}`) | ||
| const responses = await agent.onConversationEvent(event) | ||
| for (const response of responses) { | ||
| AgentResponseZodSchema.parse(response) |
There was a problem hiding this comment.
There was a problem hiding this comment.
Yep! I'll make the same fix to the agent handler as well.
cbj0hns0n
left a comment
There was a problem hiding this comment.
Left two suggestions. Tested and it works great, thanks!
allow agents to read data from all public topics
convert markdown bullets * or - to a bullet emoji in slack adapter
e064f21 to
f804d9d
Compare
What is in this PR?
The goal of this PR is for the
eventHistorianto post an event summary at the end of an event (e.g. to Slack if configured for a Slack channel). It adds infra necessary to notify agents of conversation events, determining if they have permission to read a particular conversation, either through a read grant to that specific conversation, the topic containing the conversation, or an 'allPublicTopics' grant. Agent types whose folder contains a file calledcapabilities.tswill have their read and write grants automatically loaded into the agent instances on create/update.eventHistorianis updated to post the summary generated for a conversation to thehistorianchannel on receipt of anyConversationStoppedEventwithin its scope (either app public topics or thetopicIdsconfigured in itsagentConfig).Changes in the codebase
Documentation and automated testing
Did you:
Testing this PR
Create Historian Slack Conversation in our Hoppscotch for preconfigured request. Just substitute theslackChannelwith the channel ID). RemovetopicIdsto test the defaultallPublicTopics` case.Stop conversationendpoint. Events typically auto-stop 30 minutes after endTime, but this is easiest shortcut for testing)topicIdsspecified inpropertiesand verify this also worksAdditional information