mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-29 20:34:28 +00:00
feat(agent): enable read_asset tool for autofill agent (#396)
* feat(agent): enable read_asset tool for autofill agent * fix(transcode): trigger autofill task for pdf assets * fix(transcode): allow autofill task creation on all file assets * fix(agent): require targetAssetId and teamId for autofill read_asset authorization * feat(agent): instruct autofill agent to report failure directly if read_asset fails
This commit is contained in:
@@ -35,12 +35,34 @@ describe.each(['local', 'temporal'] as const)(
|
||||
// Spy on the harness prompt method to intercept the LLM call while running real activities & tools
|
||||
vi.spyOn(AgentHarness.prototype, 'prompt').mockImplementation(async function (
|
||||
this: AgentHarness,
|
||||
...args: unknown[]
|
||||
) {
|
||||
// Find the real autofill_metadata tool configured on the harness
|
||||
// Find the real tools configured on the harness
|
||||
const tools = this.getTools()
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Tool execution mock for E2E harness test
|
||||
const readAssetTool = tools.find((t) => t.name === 'read_asset') as any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Tool execution mock for E2E harness test
|
||||
const autofillTool = tools.find((t) => t.name === 'autofill_metadata') as any
|
||||
|
||||
expect(readAssetTool).toBeDefined()
|
||||
expect(autofillTool).toBeDefined()
|
||||
|
||||
const promptText = typeof args[0] === 'string' ? args[0] : ''
|
||||
const assetIdMatch = promptText.match(/ID:\s*"([^"]+)"/)
|
||||
|
||||
if (readAssetTool && assetIdMatch) {
|
||||
const assetId = assetIdMatch[1]
|
||||
const readResult = await readAssetTool.execute(
|
||||
'call-read-1',
|
||||
{ assetId },
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
)
|
||||
expect(readResult).toBeDefined()
|
||||
expect(readResult.content).toBeDefined()
|
||||
}
|
||||
|
||||
if (autofillTool) {
|
||||
// Execute the real tool callback to perform the actual DB updates
|
||||
await autofillTool.execute(
|
||||
|
||||
Reference in New Issue
Block a user