mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 17:39:29 +00:00
refactor(agent)!: migrate to Pi Durable and embed the agent queue (#525)
* refactor(agent)!: migrate sessions to Pi Durable Replace patched AgentHarness storage with per-session SQLite and PostgreSQL commit mirroring. Migrate legacy history automatically and run agent queues with the main server. BREAKING CHANGE: Remove standalone agent workers and return native Pi entry records from chat history APIs. * fix(agent): constrain session log dialog scrolling Keep the header visible and wrap long output while log entries and expanded records scroll within the dialog. Cover desktop and narrow viewports through the dashboard Sessions flow. * fix(agent): hide entry IDs from session log card headers Retain internal entry IDs in expanded raw records for debugging. Verify that card headers omit the IDs while raw JSON preserves them. * test(e2e): handle browser wheel limits in session log checks Verify that a normal wheel event moves the viewport before explicitly scrolling to the final record. Keep the dialog bounds, fixed header, wrapping, and expanded-record assertions. * fix(agent): select model providers without inheriting unrelated auth * fix(webui): prevent resize feedback when toggling agent panel * test(agent): reproduce concurrent comment session races * fix(agent): serialize comment sessions and deduplicate history * docs(changelog): consolidate Pi Durable changes into one entry
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { invokeTool } from '@shumai/core/src/agent/tool-test-utils'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { createReadThreadTool } from './read-thread'
|
||||
|
||||
/**
|
||||
@@ -45,7 +46,7 @@ describe('read_thread authorization', () => {
|
||||
const a = await seedTeamWithThread('a')
|
||||
|
||||
const tool = createReadThreadTool({ userId: a.author.id, teamId: a.team.id })
|
||||
const result = await tool.execute('call-1', { threadId: a.thread.id })
|
||||
const result = await invokeTool(tool, 'call-1', { threadId: a.thread.id })
|
||||
const text = (result.content[0] as { text: string }).text
|
||||
|
||||
expect(text).toContain('secret message a')
|
||||
@@ -58,7 +59,7 @@ describe('read_thread authorization', () => {
|
||||
|
||||
const tool = createReadThreadTool({ userId: a.author.id, teamId: a.team.id })
|
||||
|
||||
await expect(tool.execute('call-1', { threadId: b.thread.id })).rejects.toThrow(
|
||||
await expect(invokeTool(tool, 'call-1', { threadId: b.thread.id })).rejects.toThrow(
|
||||
'User is not a member of the team',
|
||||
)
|
||||
})
|
||||
@@ -74,7 +75,7 @@ describe('read_thread authorization', () => {
|
||||
|
||||
const tool = createReadThreadTool({ userId: outsider.id, teamId: b.team.id })
|
||||
|
||||
await expect(tool.execute('call-1', { threadId: b.thread.id })).rejects.toThrow()
|
||||
await expect(invokeTool(tool, 'call-1', { threadId: b.thread.id })).rejects.toThrow()
|
||||
})
|
||||
|
||||
it('confines a system agent (no user) to threads in its own team', async () => {
|
||||
@@ -83,9 +84,11 @@ describe('read_thread authorization', () => {
|
||||
|
||||
const tool = createReadThreadTool({ teamId: a.team.id })
|
||||
|
||||
const own = await tool.execute('call-1', { threadId: a.thread.id })
|
||||
const own = await invokeTool(tool, 'call-1', { threadId: a.thread.id })
|
||||
expect((own.content[0] as { text: string }).text).toContain('secret message a')
|
||||
|
||||
await expect(tool.execute('call-2', { threadId: b.thread.id })).rejects.toThrow('Access denied')
|
||||
await expect(invokeTool(tool, 'call-2', { threadId: b.thread.id })).rejects.toThrow(
|
||||
'Access denied',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user