feat: 增强 agent_assets 功能,支持更多资产操作

This commit is contained in:
caoxiaozhu
2026-05-18 02:48:51 +00:00
parent 68f663f2f4
commit 55e0591a5e
6 changed files with 1654 additions and 148 deletions

View File

@@ -60,6 +60,10 @@ function buildQuery(params = {}) {
search.set('limit', String(params.limit))
}
if (params.version) {
search.set('version', String(params.version))
}
if (params.agent) {
search.set('agent', params.agent)
}
@@ -80,10 +84,66 @@ export function fetchAgentAssetDetail(assetId) {
return apiRequest(`/agent-assets/${assetId}`)
}
export function fetchAgentAssetSpreadsheetOnlyOfficeConfig(assetId, version = '') {
const query = buildQuery({ version })
return apiRequest(`/agent-assets/${assetId}/spreadsheet/onlyoffice-config${query}`)
}
export function fetchAgentAssetSpreadsheetBlob(assetId, version = '', disposition = 'inline') {
const search = new URLSearchParams()
if (version) {
search.set('version', String(version).trim())
}
if (disposition) {
search.set('disposition', String(disposition).trim())
}
const query = search.toString()
return apiRequest(`/agent-assets/${assetId}/spreadsheet/content${query ? `?${query}` : ''}`, {
responseType: 'blob',
contentType: null
})
}
export function uploadAgentAssetSpreadsheet(assetId, file, options = {}) {
return apiRequest(
`/agent-assets/${assetId}/spreadsheet/upload?filename=${encodeURIComponent(file.name)}`,
{
method: 'POST',
body: file,
contentType: file.type || 'application/octet-stream',
headers: buildWriteHeaders(options)
}
)
}
export function importAgentAssetSpreadsheetContent(assetId, file, options = {}) {
return apiRequest(
`/agent-assets/${assetId}/spreadsheet/import-content?filename=${encodeURIComponent(file.name)}`,
{
method: 'POST',
body: file,
contentType: file.type || 'application/octet-stream',
headers: buildWriteHeaders(options)
}
)
}
export function fetchAgentAssetVersions(assetId, limit = 5) {
return apiRequest(`/agent-assets/${assetId}/versions${buildQuery({ limit })}`)
}
export function fetchAgentAssetVersionTimeline(assetId) {
return apiRequest(`/agent-assets/${assetId}/version-timeline`)
}
export function compareAgentAssetSpreadsheetVersions(assetId, baseVersion, targetVersion) {
const query = new URLSearchParams({
base_version: String(baseVersion || '').trim(),
target_version: String(targetVersion || '').trim()
})
return apiRequest(`/agent-assets/${assetId}/versions/compare?${query.toString()}`)
}
export function updateAgentAsset(assetId, payload, options = {}) {
return apiRequest(`/agent-assets/${assetId}`, {
method: 'PATCH',
@@ -115,6 +175,13 @@ export function activateAgentAsset(assetId, options = {}) {
})
}
export function restoreAgentAssetVersion(assetId, version, options = {}) {
return apiRequest(`/agent-assets/${assetId}/versions/${encodeURIComponent(version)}/restore`, {
method: 'POST',
headers: buildWriteHeaders(options)
})
}
export function fetchAgentRuns(params = {}) {
return apiRequest(`/agent-runs${buildQuery(params)}`)
}