Skip to content
Open
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
20 changes: 20 additions & 0 deletions agent/app/api/v2/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ func (b *BaseApi) DeleteAgent(c *gin.Context) {
helper.Success(c)
}

// @Tags AI
// @Summary Update Agent remark
// @Accept json
// @Param request body dto.AgentRemarkUpdateReq true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /ai/agents/remark/update [post]
func (b *BaseApi) UpdateAgentRemark(c *gin.Context) {
var req dto.AgentRemarkUpdateReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := agentService.UpdateRemark(req); err != nil {
helper.InternalServer(c, err)
return
}
helper.Success(c)
}

// @Tags AI
// @Summary Reset Agent token
// @Accept json
Expand Down
6 changes: 6 additions & 0 deletions agent/app/dto/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type AgentItem struct {
Path string `json:"path"`
ConfigPath string `json:"configPath"`
Upgradable bool `json:"upgradable"`
Remark string `json:"remark"`
CreatedAt time.Time `json:"createdAt"`
}

Expand All @@ -63,6 +64,11 @@ type AgentTokenResetReq struct {
ID uint `json:"id" validate:"required"`
}

type AgentRemarkUpdateReq struct {
ID uint `json:"id" validate:"required"`
Remark string `json:"remark"`
}

type AgentModelConfigUpdateReq struct {
AgentID uint `json:"agentId" validate:"required"`
AccountID uint `json:"accountId" validate:"required"`
Expand Down
1 change: 1 addition & 0 deletions agent/app/model/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ type Agent struct {
AppInstallID uint `json:"appInstallId"`
AccountID uint `json:"accountId"`
ConfigPath string `json:"configPath"`
Remark string `json:"remark"`
}
10 changes: 10 additions & 0 deletions agent/app/service/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type IAgentService interface {
Delete(req dto.AgentDeleteReq) error
ResetToken(req dto.AgentTokenResetReq) error
UpdateModelConfig(req dto.AgentModelConfigUpdateReq) error
UpdateRemark(req dto.AgentRemarkUpdateReq) error
GetProviders() ([]dto.ProviderInfo, error)
GetSecurityConfig(req dto.AgentSecurityConfigReq) (*dto.AgentSecurityConfig, error)
UpdateSecurityConfig(req dto.AgentSecurityConfigUpdateReq) error
Expand Down Expand Up @@ -277,6 +278,15 @@ func (a AgentService) Delete(req dto.AgentDeleteReq) error {
return nil
}

func (a AgentService) UpdateRemark(req dto.AgentRemarkUpdateReq) error {
agent, err := agentRepo.GetFirst(repo.WithByID(req.ID))
if err != nil {
return err
}
agent.Remark = req.Remark
return agentRepo.Save(agent)
}

func (a AgentService) ResetToken(req dto.AgentTokenResetReq) error {
agent, err := agentRepo.GetFirst(repo.WithByID(req.ID))
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions agent/app/service/agents_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ func buildAgentItem(agent *model.Agent, appInstall *model.AppInstall, envMap map
AppInstallID: agent.AppInstallID,
AccountID: agent.AccountID,
ConfigPath: agent.ConfigPath,
Remark: agent.Remark,
CreatedAt: agent.CreatedAt,
}
if appInstall != nil && appInstall.ID > 0 {
Expand Down
1 change: 1 addition & 0 deletions agent/init/migration/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func InitAgentDB() {
migrations.InitAgentAccountModelPool,
migrations.AddHostTable,
migrations.AddAITerminalSettings,
migrations.AddAgentRemark,
})
if err := m.Migrate(); err != nil {
global.LOG.Error(err)
Expand Down
7 changes: 7 additions & 0 deletions agent/init/migration/migrations/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -1133,3 +1133,10 @@ var AddAITerminalSettings = &gormigrate.Migration{
}).Error
},
}

var AddAgentRemark = &gormigrate.Migration{
ID: "20260322-add-agent-remark",
Migrate: func(tx *gorm.DB) error {
return tx.AutoMigrate(&model.Agent{})
},
}
1 change: 1 addition & 0 deletions agent/router/ro_ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (a *AIToolsRouter) InitRouter(Router *gin.RouterGroup) {
aiToolsRouter.POST("/agents/delete", baseApi.DeleteAgent)
aiToolsRouter.POST("/agents/token/reset", baseApi.ResetAgentToken)
aiToolsRouter.POST("/agents/model/update", baseApi.UpdateAgentModelConfig)
aiToolsRouter.POST("/agents/remark/update", baseApi.UpdateAgentRemark)
aiToolsRouter.GET("/agents/providers", baseApi.GetAgentProviders)
aiToolsRouter.POST("/agents/accounts", baseApi.CreateAgentAccount)
aiToolsRouter.POST("/agents/accounts/update", baseApi.UpdateAgentAccount)
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/api/interface/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,15 @@ export namespace AI {
path: string;
configPath: string;
upgradable: boolean;
remark: string;
createdAt: string;
}

export interface AgentRemarkUpdateReq {
id: number;
remark: string;
}

export interface AgentDeleteReq {
id: number;
taskID: string;
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/api/modules/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export const updateAgentModelConfig = (req: AI.AgentModelConfigUpdateReq) => {
return http.post(`/ai/agents/model/update`, req);
};

export const updateAgentRemark = (req: AI.AgentRemarkUpdateReq) => {
return http.post(`/ai/agents/remark/update`, req);
};

export const getAgentProviders = () => {
return http.get<AI.ProviderInfo[]>(`/ai/agents/providers`);
};
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const message = {
operate: 'Actions',
message: 'Message',
description: 'Description',
remark: 'Remark',
interval: 'Interval',
user: 'Owner',
title: 'Title',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const message = {
operate: '操作',
message: '信息',
description: '描述',
remark: '备注',
interval: '耗时',
user: '用户',
title: '标题',
Expand Down
20 changes: 19 additions & 1 deletion frontend/src/views/ai/agents/agent/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column :label="$t('commons.table.remark')" prop="remark" min-width="150">
<template #default="{ row }">
<el-input
v-model="row.remark"
size="small"
:placeholder="$t('commons.table.remark')"
@change="onRemarkChange(row)"
/>
</template>
</el-table-column>
<el-table-column
:label="$t('commons.table.date')"
prop="createdAt"
Expand Down Expand Up @@ -128,7 +138,7 @@
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { pageAgents, resetAgentToken } from '@/api/modules/ai';
import { pageAgents, resetAgentToken, updateAgentRemark } from '@/api/modules/ai';
import { installedOp, searchApp, searchAppInstalled } from '@/api/modules/app';
import { AI } from '@/api/interface/ai';
import { App } from '@/api/interface/app';
Expand Down Expand Up @@ -350,6 +360,14 @@ const onDelete = (row: AI.AgentItem) => {
deleteRef.value?.acceptParams(row.id, row.name);
};

const onRemarkChange = async (row: AI.AgentItem) => {
try {
await updateAgentRemark({ id: row.id, remark: row.remark });
} catch (e) {
/* silent */
}
};

const onResetToken = async (row: AI.AgentItem) => {
await ElMessageBox.confirm(
i18n.global.t('aiTools.mcp.operatorHelper', ['token', i18n.global.t('commons.button.reset')]),
Expand Down