feat(agent): inject user name and role into chat context

This commit is contained in:
yiling
2026-07-27 11:24:48 +08:00
parent b8345f7c46
commit cd3c7f3641
6 changed files with 151 additions and 5 deletions
+12 -1
View File
@@ -17,6 +17,7 @@ import {
executeAgentToolActivity,
generateSessionNameActivity,
type GenerateSessionNameParams,
getUserTeamInfoActivity,
} from './agent'
import * as piAgent from '../index'
import { type AgentHarness, type Session } from '@earendil-works/pi-agent-core'
@@ -548,9 +549,19 @@ describe('Agent Database Activities Integration', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- entry is stored as Json in DB and needs casting to check properties
const parsedEntry = agentSession?.entries[0].entry as any
expect(parsedEntry.message.content[0].text).toContain(
`[${user.name}]: Hello <@${user.name}> check this`,
`[${user.name} (owner)]: Hello <@${user.name}> check this`,
)
})
it('should return user name and role for team member', async () => {
const info = await getUserTeamInfoActivity({
userId: user.id,
teamId: team.id,
})
expect(info).toBeDefined()
expect(info?.name).toBe(user.name)
expect(info?.role).toBe('owner')
})
})
describe('Comment Operations', () => {