mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-29 20:34:28 +00:00
feat(asset-read): rewrite read_asset as a reader registry and Operations (#498)
Replace the monolithic agent read_asset tool with a reader registry in @shumai/core/src/asset-read (model3d, image, video, document) behind a shared pipeline that handles access checks, version stacks, annotations, render tasks, and waiting. - Add read_asset and get_asset_render Operations (agent surface only). Renders that outlast the caller's wait budget return "pending" with the workflow task ID; the read request is stored on the task payload so get_asset_render works across restarts and instances (requester only). - Add workflowService.waitFor and presign expiry support. - Keep agent output compatible via an agent tool extension (s3KeyOnly, image blocks, session image details); autofill keeps its team-scoped tool. - Cap video frames at 20 per call; add the get_asset_render agent toggle.
This commit is contained in:
@@ -7,7 +7,7 @@ import { DatabaseSessionStorage } from './database-session-storage'
|
||||
import { agentService } from '@shumai/core/src/agent/agent'
|
||||
import { createAgentSession, type DbProviderInfo } from './index'
|
||||
import * as sandboxedBashModule from './tools/sandboxed-bash'
|
||||
import * as readAssetModule from './tools/read-asset'
|
||||
import * as operationToolsModule from './operation-tools'
|
||||
|
||||
describe('DatabaseSessionStorage', () => {
|
||||
setupTestDbHooks()
|
||||
@@ -450,8 +450,8 @@ describe('DatabaseSessionStorage', () => {
|
||||
})
|
||||
const sessionId = initialStorage.sessionId
|
||||
|
||||
// 2. Spy on media tool constructor
|
||||
const createReadAssetToolSpy = vi.spyOn(readAssetModule, 'createReadAssetTool')
|
||||
// 2. Spy on the Operation tools builder (read_asset comes from the Operation registry)
|
||||
const buildOperationToolsSpy = vi.spyOn(operationToolsModule, 'buildOperationTools')
|
||||
|
||||
// 3. Resume the session via createAgentSession with a NEW comment ID
|
||||
await createAgentSession({
|
||||
@@ -468,8 +468,10 @@ describe('DatabaseSessionStorage', () => {
|
||||
providers: mockProviders,
|
||||
})
|
||||
|
||||
// 4. Assert that the tool was instantiated using user ID
|
||||
expect(createReadAssetToolSpy).toHaveBeenCalledWith(user.id)
|
||||
// 4. Assert that the tools were built for the user
|
||||
expect(buildOperationToolsSpy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ userId: user.id }),
|
||||
)
|
||||
})
|
||||
|
||||
it('should instantiate media tools with user ID in subsequent turns (video)', async () => {
|
||||
@@ -502,8 +504,8 @@ describe('DatabaseSessionStorage', () => {
|
||||
})
|
||||
const sessionId = initialStorage.sessionId
|
||||
|
||||
// 2. Spy on media tool constructor
|
||||
const createReadAssetToolSpy = vi.spyOn(readAssetModule, 'createReadAssetTool')
|
||||
// 2. Spy on the Operation tools builder (read_asset comes from the Operation registry)
|
||||
const buildOperationToolsSpy = vi.spyOn(operationToolsModule, 'buildOperationTools')
|
||||
|
||||
// 3. Resume the session via createAgentSession with a NEW comment ID
|
||||
await createAgentSession({
|
||||
@@ -520,8 +522,10 @@ describe('DatabaseSessionStorage', () => {
|
||||
providers: mockProviders,
|
||||
})
|
||||
|
||||
// 4. Assert that the tool was instantiated using user ID
|
||||
expect(createReadAssetToolSpy).toHaveBeenCalledWith(user.id)
|
||||
// 4. Assert that the tools were built for the user
|
||||
expect(buildOperationToolsSpy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ userId: user.id }),
|
||||
)
|
||||
})
|
||||
|
||||
describe('P1 Bug Reproductions', () => {
|
||||
|
||||
Reference in New Issue
Block a user