feat(agent): consolidate media tools into read_asset and add S3 key support to download_asset (#376)

* feat(agent): consolidate media tools into read_asset and add S3 key support to download_asset

* fix(agent): refine parameter descriptions and remove download URL from read_asset text content

* fix(agent): resolve owning asset and enforce RBAC permissions when downloading by S3 key
This commit is contained in:
Yiling-J
2026-09-02 21:51:07 +08:00
committed by GitHub
parent 35b57cc0ab
commit e58dfaa71a
38 changed files with 1732 additions and 1851 deletions
+10 -10
View File
@@ -21,12 +21,12 @@ describe('QuotaRule Wildcard Matchers', () => {
it('correctly matches agent tool name wildcards', () => {
const starTool = wildcardToRegex('*')
expect(starTool.test('analyze_image')).toBe(true)
expect(starTool.test('screenshot')).toBe(true)
expect(starTool.test('read_asset')).toBe(true)
expect(starTool.test('create_file')).toBe(true)
const exactTool = wildcardToRegex('analyze_image')
expect(exactTool.test('analyze_image')).toBe(true)
expect(exactTool.test('screenshot')).toBe(false)
const exactTool = wildcardToRegex('read_asset')
expect(exactTool.test('read_asset')).toBe(true)
expect(exactTool.test('create_file')).toBe(false)
})
})
@@ -405,29 +405,29 @@ describe('QuotaService', () => {
await quotaService.createRule(team.id, {
scopeMode: 'all_members',
resource: 'agent_tool_call_count',
resourceData: { name: 'analyze_image' },
resourceData: { name: 'read_asset' },
limit: 1,
period: '1hour',
enabled: true,
})
// First call to analyze_image
// First call to read_asset
await quotaService.consumeQuota(
{
teamId: team.id,
resource: 'agent_tool_call_count',
resourceData: { name: 'analyze_image' },
resourceData: { name: 'read_asset' },
},
1,
)
// 2nd call to analyze_image is blocked
// 2nd call to read_asset is blocked
await expect(
quotaService.checkQuota(
{
teamId: team.id,
resource: 'agent_tool_call_count',
resourceData: { name: 'analyze_image' },
resourceData: { name: 'read_asset' },
},
1,
),