Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions app/controller/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ class AgentsController extends Controller {
this.ctx.body = this.app.utils.response(true, data);
}

async getRelatedAgents() {
const { name, limit = 3 } = this.ctx.query;
const data = await this.ctx.service.agents.getRelatedAgents(name, limit);
this.ctx.body = this.app.utils.response(true, data);
}

async getAgentAsset() {
const { stream, mimeType, cacheControl } =
await this.ctx.service.agents.getAgentAssetStream(this.ctx.query);
Expand All @@ -35,6 +29,12 @@ class AgentsController extends Controller {
this.ctx.body = stream;
}

async getRelatedAgents() {
const { name, limit = 3 } = this.ctx.query;
const data = await this.ctx.service.agents.getRelatedAgents(name, limit);
this.ctx.body = this.app.utils.response(true, data);
}

async importAgentFile() {
const files = this.ctx.request.files
? Array.isArray(this.ctx.request.files)
Expand All @@ -54,11 +54,14 @@ class AgentsController extends Controller {
);
this.ctx.body = this.app.utils.response(true, data);
} finally {
if (file?.filepath && fs.existsSync(file.filepath)) {
try {
fs.unlinkSync(file.filepath);
} catch (error) {
this.ctx.logger.warn(`[agents] 清理上传文件失败: ${error.message}`);
// 清理本次请求上传的所有临时文件,防止多文件或异常时泄漏
for (const item of files) {
if (item?.filepath && fs.existsSync(item.filepath)) {
try {
fs.unlinkSync(item.filepath);
} catch (error) {
this.ctx.logger.warn(`[agents] 清理上传文件失败: ${error.message}`);
}
}
}
}
Expand Down
20 changes: 0 additions & 20 deletions app/model/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,6 @@ module.exports = (app) => {
type: TEXT('long'),
comment: 'JSON 字符串数组',
},
demo_images: {
type: TEXT('long'),
comment: 'JSON 字符串数组',
},
entrypoint_host: {
type: STRING(64),
comment: '入口宿主',
},
entrypoint_type: {
type: STRING(64),
comment: '入口类型',
},
entrypoint_name: {
type: STRING(255),
comment: '入口名称',
},
entrypoint_ref: {
type: STRING(1000),
comment: '入口路径',
},
logo_path: {
type: STRING(1000),
comment: 'Logo 相对路径',
Expand Down
24 changes: 2 additions & 22 deletions app/model/agent_skill.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,7 @@ module.exports = (app) => {
skill_slug: {
type: STRING(255),
allowNull: false,
comment: 'Skill slug',
},
skill_id: {
type: INTEGER,
allowNull: true,
comment: 'skills_items.id',
},
relation_type: {
type: STRING(20),
allowNull: false,
comment: 'entrypoint、dependency 或 private',
},
sort_order: {
type: INTEGER,
allowNull: false,
defaultValue: 0,
comment: '展示顺序',
comment: 'Skill 标识(包内 SKILL.md 解析出的 name 或目录名)',
},
created_at: {
type: DATE,
Expand All @@ -52,11 +36,7 @@ module.exports = (app) => {
timestamps: true,
createdAt: 'created_at',
updatedAt: 'updated_at',
indexes: [
{ fields: ['agent_id'] },
{ fields: ['skill_slug'] },
{ fields: ['relation_type'] },
],
indexes: [{ fields: ['agent_id'] }, { fields: ['skill_slug'] }],
}
);

Expand Down
Loading
Loading