feat: add allowedAgents config for memory hooks#28
Conversation
| const sessionKey = ctx.sessionKey as string | undefined | ||
| if ( | ||
| cfg.allowedAgents?.length && | ||
| !cfg.allowedAgents.some((agentId) => sessionKey?.includes(agentId)) | ||
| ) { | ||
| return |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
|
Good catch - the bug is real. When Fixed in the latest commit by gating the filter on |
|
Hey @Dhravya @Prasanna721, this is ready for review whenever you get a chance. CI is green, and the undefined sessionKey edge case from the Seer review is fixed with regression tests. Would love to get this merged so we can set up per-agent memory isolation. Thanks! |
|
hi @rbutera thank you for your contribution can you pls resolve the conflicts |
…fined When cfg.allowedAgents is set and sessionKey is undefined, the guard condition used optional chaining (sessionKey?.includes()) which returns undefined. Array.some() treated undefined as falsy, so .some() returned false. The negation (!false) triggered an early return, silently blocking capture/recall for sessions without a sessionKey. Fix: only apply the allowedAgents filter when sessionKey is present. Sessions without a sessionKey fall through and are processed normally, restoring prior behavior. Also adds two regression tests covering the undefined sessionKey case.
- buildCaptureHandler moved sessionKey from a builder arg to the handler ctx on main; drop the now-redundant 3rd arg in the capture tests (sessionKey is passed via ctx, matching the recall tests + the hook implementations). - add @types/bun so the bun:test import typechecks under tsc --noEmit (this is the repo's first test file; the type was previously unresolved). - formatting (biome).
1473703 to
8ec25ac
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Rebased onto The main thing that shifted underneath this PR:
@Dhravya @Prasanna721 @ved015 ready for another look whenever you get a chance, thanks for the patience. |
Summary
allowedAgents?: string[]to plugin config parsing and schemasessionKeydoes not match an allowed agentsessionKeydoes not match an allowed agentCloses #27.
Behavior
When
allowedAgentsis omitted, behavior stays the same as today.When
allowedAgentsis set, auto-capture and auto-recall only run for sessions whosesessionKeyincludes one of the configured agent IDs, for exampleagent:navi:main.Test plan
bun test allowed-agents.test.tsbun run check-typesbun run lint