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
19 changes: 19 additions & 0 deletions ui/src/api/API_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,25 @@ API 对象和工作空间上下文,作为该抽屉的范围选择例外。Syst

### 智能体概览

Workspace 与 System 资源管理的 `application/application.ts` 提供 `getAccessToken(applicationId)`,
沿用 V2 的 `/<applicationId>/access_token` GET 接口,返回公开访问凭证 `ApplicationAccessToken`。
概览使用 `access_token` 拼接 Web 链接,不使用智能体 ID 或 API Key 替代;API 文档地址使用 Chat 部署前缀。
两范围的 `putAccessToken` 向同一路径提交 `{ access_token_reset: true }` 重置链接,或 `{ is_active: boolean }` 修改 Web 访问状态;
载荷复用 `ApplicationAccessTokenPayload`,使用返回的访问凭证与启用状态回显,不二次查询。

API Key 按三个入口分别维护:

- `admin/workspace/application/api-key.ts`:`/workspace/<workspaceId>/application/<applicationId>/application_key`。
- `admin/system/resource-management/application/api-key.ts`:`/system/resource/application/<applicationId>/application_key`。
- `admin/system/api-key.ts`:`/system/api_key`,仅用于头像菜单。

三套均提供 `getApiKeyPage`、`postApiKey`、`putApiKey`、`deleteApiKey`;
两套智能体方法以 `applicationId` 为首参,仅 Workspace 接口在内部读取工作空间 ID;头像菜单接口不接收资源 ID。
分页使用 `ParamsPage` 和 `ResponsePage<ApiKeyRecord>`;创建 POST 空对象,由后端生成密钥;
修改只提交需要更新的配置,启停仅提交 `is_active`。Workspace 智能体删除返回空数据,其他两套沿用 V2 布尔类型;调用方不依赖返回值判断成功。
共用业务类型在 `types/api-key.ts`,`remark` 字段待后端补充返回与持久化;
两套系统接口沿用 V2 路径,仍需对应部署联调;头像菜单密钥与系统资源管理智能体密钥不能互相替代。

`admin/workspace/application/overview.ts` 独立维护概览接口,沿用 v2 的应用统计协议,在
`/workspace/<workspaceId>/application/<applicationId>` 下提供三个 GET 接口,均传入
`start_time`、`end_time`,由调用方管理 loading:
Expand Down
26 changes: 26 additions & 0 deletions ui/src/api/admin/system/api-key.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** 系统 API Key 接口。TODO:联调 /system/api_key 及 remark 字段。 */
import { del, get, post, put } from '../core/request'
import type { ParamsPage, ResponsePage } from '../core/types'
import type { ApiKeyPayload, ApiKeyRecord, Dict } from '@/api/types'

const prefix = '/system/api_key'

/** 分页查询系统 API Key。 */
const getApiKeyPage = (page: ParamsPage, query?: Dict<unknown>) =>
get<ResponsePage<ApiKeyRecord>>(`${prefix}/${page.currentPage}/${page.pageSize}`, query)

/** 生成系统 API Key。 */
const postApiKey = () => post<Record<string, never>, ApiKeyRecord>(prefix, {})

/** 修改系统 API Key 配置或启用状态。 */
const putApiKey = (apiKeyId: string, payload: ApiKeyPayload) => put<ApiKeyPayload, boolean>(`${prefix}/${apiKeyId}`, payload)

/** 删除系统 API Key。 */
const deleteApiKey = (apiKeyId: string) => del<undefined, boolean>(`${prefix}/${apiKeyId}`)

export default {
getApiKeyPage,
postApiKey,
putApiKey,
deleteApiKey,
}
27 changes: 27 additions & 0 deletions ui/src/api/admin/system/resource-management/application/api-key.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/** System 资源管理智能体 API Key 接口。TODO:接口待联调。 */
import { del, get, post, put } from '@/api/admin/core/request'
import type { ParamsPage, ResponsePage } from '@/api/admin/core/types'
import type { ApiKeyPayload, ApiKeyRecord, Dict } from '@/api/types'

const getPrefix = (applicationId: string) => `/system/resource/application/${applicationId}/application_key`

/** 分页查询智能体 API Key。 */
const getApiKeyPage = (applicationId: string, page: ParamsPage, query?: Dict<unknown>) =>
get<ResponsePage<ApiKeyRecord>>(`${getPrefix(applicationId)}/${page.currentPage}/${page.pageSize}`, query)

/** 生成智能体 API Key。 */
const postApiKey = (applicationId: string) => post<Record<string, never>, ApiKeyRecord>(getPrefix(applicationId), {})

/** 修改智能体 API Key 配置或启用状态。 */
const putApiKey = (applicationId: string, apiKeyId: string, payload: ApiKeyPayload) =>
put<ApiKeyPayload, boolean>(`${getPrefix(applicationId)}/${apiKeyId}`, payload)

/** 删除智能体 API Key。 */
const deleteApiKey = (applicationId: string, apiKeyId: string) => del<undefined, boolean>(`${getPrefix(applicationId)}/${apiKeyId}`)

export default {
getApiKeyPage,
postApiKey,
putApiKey,
deleteApiKey,
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { del, get, getExportFile, put } from '@/api/admin/core/request'
import type { ParamsPage, ResponsePage } from '@/api/admin/core/types'
import type { ApplicationDetail, ApplicationFormPayload, Dict } from '@/api/types'
import type { ApplicationAccessToken, ApplicationAccessTokenPayload, ApplicationDetail, ApplicationFormPayload, Dict } from '@/api/types'

const prefix = '/system/resource/application'

Expand All @@ -25,6 +25,13 @@ const exportApplication = (applicationId: string, applicationName: string) => {
/** 获取 System 资源管理智能体详情。 */
const getApplicationDetail = (applicationId: string) => get<ApplicationDetail>(`${prefix}/${applicationId}`)

/** 获取 System 资源管理智能体公开访问凭证。 */
const getAccessToken = (applicationId: string) => get<ApplicationAccessToken>(`${prefix}/${applicationId}/access_token`)

/** 修改 System 资源管理智能体公开访问状态或重置凭证,返回更新后的配置。 */
const putAccessToken = (applicationId: string, payload: ApplicationAccessTokenPayload) =>
put<ApplicationAccessTokenPayload, ApplicationAccessToken>(`${prefix}/${applicationId}/access_token`, payload)

/** 保存 System 资源管理智能体配置。 */
const putApplication = (applicationId: string, data: ApplicationFormPayload) =>
put<ApplicationFormPayload, ApplicationDetail>(`${prefix}/${applicationId}`, data)
Expand All @@ -38,6 +45,8 @@ const putApplicationPublish = (applicationId: string, publishName: string, publi

export default {
getApplicationDetail,
getAccessToken,
putAccessToken,
putApplication,
putApplicationPublish,
getAllApplication,
Expand Down
28 changes: 28 additions & 0 deletions ui/src/api/admin/workspace/application/api-key.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/** 工作空间智能体 API Key 接口。 */
import { del, get, post, put } from '../../core/request'
import type { ParamsPage, ResponsePage } from '../../core/types'
import type { ApiKeyPayload, ApiKeyRecord, Dict } from '@/api/types'
import { getWorkspaceId } from '@/utils/resource-context'

const getPrefix = (applicationId: string) => `/workspace/${getWorkspaceId()}/application/${applicationId}/application_key`

/** 分页查询智能体 API Key。 */
const getApiKeyPage = (applicationId: string, page: ParamsPage, query?: Dict<unknown>) =>
get<ResponsePage<ApiKeyRecord>>(`${getPrefix(applicationId)}/${page.currentPage}/${page.pageSize}`, query)

/** 生成智能体 API Key。 */
const postApiKey = (applicationId: string) => post<Record<string, never>, ApiKeyRecord>(getPrefix(applicationId), {})

/** 修改智能体 API Key 配置或启用状态。 */
const putApiKey = (applicationId: string, apiKeyId: string, payload: ApiKeyPayload) =>
put<ApiKeyPayload, boolean>(`${getPrefix(applicationId)}/${apiKeyId}`, payload)

/** 删除智能体 API Key。 */
const deleteApiKey = (applicationId: string, apiKeyId: string) => del<undefined, void>(`${getPrefix(applicationId)}/${apiKeyId}`)

export default {
getApiKeyPage,
postApiKey,
putApiKey,
deleteApiKey,
}
11 changes: 10 additions & 1 deletion ui/src/api/admin/workspace/application/application.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { del, get, getExportFile, post, put } from '../../core/request'
import type { ParamsPage, ResponsePage } from '../../core/types'
import type { ApplicationDetail, ApplicationFormPayload, Dict } from '@/api/types'
import type { ApplicationAccessToken, ApplicationAccessTokenPayload, ApplicationDetail, ApplicationFormPayload, Dict } from '@/api/types'
import { getWorkspaceId } from '@/utils/resource-context'

const getPrefix = () => {
Expand All @@ -25,6 +25,13 @@ const getApplicationDetail = (applicationId: string) => {
return get<ApplicationDetail>(`${getPrefix()}/${applicationId}`)
}

/** 获取智能体公开访问凭证。 */
const getAccessToken = (applicationId: string) => get<ApplicationAccessToken>(`${getPrefix()}/${applicationId}/access_token`)

/** 修改智能体公开访问状态或重置凭证,返回更新后的配置。 */
const putAccessToken = (applicationId: string, payload: ApplicationAccessTokenPayload) =>
put<ApplicationAccessTokenPayload, ApplicationAccessToken>(`${getPrefix()}/${applicationId}/access_token`, payload)

/** 删除工作空间智能体。 */
const deleteApplication = (applicationId: string) => {
return del<undefined, boolean>(`${getPrefix()}/${applicationId}`)
Expand Down Expand Up @@ -78,6 +85,8 @@ const putApplicationPublish = (applicationId: string, publishName: string, publi
export default {
getApplicationPage,
getApplicationDetail,
getAccessToken,
putAccessToken,
deleteApplication,
exportApplication,
postApplication,
Expand Down
22 changes: 22 additions & 0 deletions ui/src/api/types/api-key.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** 智能体与系统 API Key 共用的记录和修改参数。 */
export interface ApiKeyRecord {
id: string
secret_key: string
is_active: boolean
allow_cross_domain: boolean
cross_domain_list: string[]
is_permanent: boolean
expire_time: string | null
create_time?: string
// TODO:后端补充 remark 的返回与持久化。
remark?: string | null
}

export interface ApiKeyPayload {
is_active?: boolean
allow_cross_domain?: boolean
cross_domain_list?: string[]
is_permanent?: boolean
expire_time?: string | null
remark?: string
}
13 changes: 13 additions & 0 deletions ui/src/api/types/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ export interface ApplicationAccessStatusPayload {
status: boolean
}

/** 智能体公开访问链接使用的凭证。 */
export interface ApplicationAccessToken {
application_id: string
access_token: string
is_active: boolean
}

/** 智能体公开访问状态修改或令牌重置参数。 */
export interface ApplicationAccessTokenPayload {
is_active?: boolean
access_token_reset?: boolean
}

export interface ApplicationDetail extends Omit<ApplicationFormPayload, 'desc'> {
/** 详情接口返回的主模型 ID。 */
model?: string | null
Expand Down
1 change: 1 addition & 0 deletions ui/src/api/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** API 与 View 或 Component 跨层业务类型的唯一公共入口。 */
export type * from './application'
export type * from './api-key'
export type * from './common'
export type * from './chat-user'
export type * from './chat-auth'
Expand Down
14 changes: 14 additions & 0 deletions ui/src/components/COMPONENT_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,20 @@ Model 配置器的默认模型也使用 `SelectModel`,仅展示已选的可选

业务组件显式导入,可调用固定业务 API;页面保留自身的列表查询、路由和保存编排。

### ApiKeyList

手动导入 `business/api-key-list/index.vue`,接收完整的 `api` 对象。Workspace 与 System 资源管理的智能体 API
必须同时传入 `applicationId`;头像菜单的 System API 不传该参数。API 入参类型直接在各使用组件内声明。
组件不读取路由或自行选择接口,智能体概览通过详情上下文的 `resourceApi.apiKey` 传入对应 API。
在弹窗内容中挂载,首次挂载查询,关闭后由外层弹窗销毁,下次打开重新加载。
列表默认每页 20 条,不提供排序、列宽拖拽或批量操作;创建直接生成密钥,删除前确认,
启停成功后刷新,失败保留原状态。查询与列表操作共用 loading,编辑抽屉单独管理保存状态。
密钥默认隐藏,翻页或刷新恢复隐藏,复制始终使用完整值,隐藏状态不通过 Tooltip 暴露明文。

`EditApiKeyDrawer` 是本功能内部抽屉,按永不过期、预设有效期或自定义日期编辑,预设有效期
从保存时起算;跨域地址逐行去空白后提交数组。保存失败保留草稿,成功刷新列表。
备注按 `remark` 预留,当前后端尚未持久化。Base URL 或 API 文档地址由调用方在列表外展示。

### GenerateQuestionsDialog

`business/generate-questions/index.vue` 共用关联问题配置,
Expand Down
Loading
Loading