mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-02 23:03:57 +08:00
@@ -11,7 +11,12 @@
|
||||
*/
|
||||
|
||||
import { ContentType, RequestParams } from "./httpClient";
|
||||
import { DomainCodeSnippet, V1GetContextReq, WebResp } from "./types";
|
||||
import {
|
||||
DomainCodeSnippet,
|
||||
V1GetContextReq,
|
||||
V1GetSemanticContextReq,
|
||||
WebResp,
|
||||
} from "./types";
|
||||
|
||||
/**
|
||||
* @description 为IDE端提供代码片段上下文检索功能,使用API Key认证。支持单个查询和批量查询。
|
||||
@@ -44,3 +49,35 @@ export const postGetContext = (
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* @description 为IDE端提供代码片段语义搜索功能,使用API Key认证。通过向量相似性搜索找到相关的代码片段。
|
||||
*
|
||||
* @tags CodeSnippet
|
||||
* @name PostGetSemanticContext
|
||||
* @summary IDE端语义搜索
|
||||
* @request POST:/api/v1/ide/codesnippet/semantic
|
||||
* @secure
|
||||
* @response `200` `(WebResp & {
|
||||
data?: (DomainCodeSnippet)[],
|
||||
|
||||
})` OK
|
||||
*/
|
||||
|
||||
export const postGetSemanticContext = (
|
||||
request: V1GetSemanticContextReq,
|
||||
params: RequestParams = {},
|
||||
) =>
|
||||
request<
|
||||
WebResp & {
|
||||
data?: DomainCodeSnippet[];
|
||||
}
|
||||
>({
|
||||
path: `/api/v1/ide/codesnippet/semantic`,
|
||||
method: "POST",
|
||||
body: request,
|
||||
secure: true,
|
||||
type: ContentType.Json,
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
@@ -15,9 +15,11 @@ import {
|
||||
DomainAcceptCompletionReq,
|
||||
DomainCreateSecurityScanningReq,
|
||||
DomainListSecurityScanningBriefResp,
|
||||
DomainListSecurityScanningDetailResp,
|
||||
DomainListSecurityScanningReq,
|
||||
DomainModelListResp,
|
||||
DomainReportReq,
|
||||
GetListSecurityScanningDetailParams,
|
||||
WebResp,
|
||||
} from "./types";
|
||||
|
||||
@@ -170,7 +172,7 @@ export const postReport = (
|
||||
});
|
||||
|
||||
/**
|
||||
* @description 分页逻辑只支持用 next_token
|
||||
* @description 扫描任务列表
|
||||
*
|
||||
* @tags OpenAIV1
|
||||
* @name GetListSecurityScanning
|
||||
@@ -221,3 +223,33 @@ export const postCreateSecurityScanning = (
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* @description 分页只支持 next_token; 首页传空,后续判断has_next_page是否为true,传入回包给的next_token
|
||||
*
|
||||
* @tags OpenAIV1
|
||||
* @name GetListSecurityScanningDetail
|
||||
* @summary 获取扫描任务风险详情列表
|
||||
* @request GET:/v1/security/scanning/detail
|
||||
* @response `200` `(WebResp & {
|
||||
data?: DomainListSecurityScanningDetailResp,
|
||||
|
||||
})` OK
|
||||
*/
|
||||
|
||||
export const getListSecurityScanningDetail = (
|
||||
query: GetListSecurityScanningDetailParams,
|
||||
params: RequestParams = {},
|
||||
) =>
|
||||
request<
|
||||
WebResp & {
|
||||
data?: DomainListSecurityScanningDetailResp;
|
||||
}
|
||||
>({
|
||||
path: `/v1/security/scanning/detail`,
|
||||
method: "GET",
|
||||
query: query,
|
||||
type: ContentType.Json,
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
@@ -259,6 +259,8 @@ export interface DomainCodeSnippet {
|
||||
definitionText?: string;
|
||||
/** 依赖项 */
|
||||
dependencies?: string[];
|
||||
/** 向量嵌入 */
|
||||
embedding?: number[];
|
||||
/** 结束列号 */
|
||||
endColumn?: number;
|
||||
/** 结束行号 */
|
||||
@@ -612,6 +614,13 @@ export interface DomainListSecurityScanningBriefResp {
|
||||
total_count?: number;
|
||||
}
|
||||
|
||||
export interface DomainListSecurityScanningDetailResp {
|
||||
has_next_page?: boolean;
|
||||
items?: DomainSecurityScanningRiskDetail[];
|
||||
next_token?: string;
|
||||
total_count?: number;
|
||||
}
|
||||
|
||||
export interface DomainListSecurityScanningReq {
|
||||
/** 作者 */
|
||||
author?: string;
|
||||
@@ -826,6 +835,8 @@ export interface DomainReportReq {
|
||||
export interface DomainSecurityScanningBrief {
|
||||
/** 创建时间 */
|
||||
created_at?: number;
|
||||
/** 扫描任务id */
|
||||
id?: string;
|
||||
/** 报告url */
|
||||
report_url?: string;
|
||||
/** 扫描状态 */
|
||||
@@ -1207,6 +1218,15 @@ export interface V1GetContextReq {
|
||||
workspacePath?: string;
|
||||
}
|
||||
|
||||
export interface V1GetSemanticContextReq {
|
||||
/** 返回结果数量限制,默认10 */
|
||||
limit?: number;
|
||||
/** 搜索查询文本(必填) */
|
||||
query?: string;
|
||||
/** 工作区路径(必填) */
|
||||
workspacePath?: string;
|
||||
}
|
||||
|
||||
export interface V1Query {
|
||||
/** 编程语言(可选) */
|
||||
language?: string;
|
||||
@@ -1617,3 +1637,14 @@ export interface GetGetWorkspaceFileByPathParams {
|
||||
/** 文件路径 */
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface GetListSecurityScanningDetailParams {
|
||||
/** 扫描任务id */
|
||||
id?: string;
|
||||
/** 下一页标识 */
|
||||
next_token?: string;
|
||||
/** 分页 */
|
||||
page?: number;
|
||||
/** 每页多少条记录 */
|
||||
size?: number;
|
||||
}
|
||||
|
||||
@@ -121,17 +121,19 @@ const CodeScanTaskList = ({
|
||||
ml: '4px'
|
||||
}}>扫描完成</Box>
|
||||
</Stack>}
|
||||
{(record.status === 'failed') && <Stack direction={'row'}>
|
||||
<ErrorOutlineIcon sx={{
|
||||
width: '16px',
|
||||
height: '16px',
|
||||
color: 'error.main'
|
||||
}} />
|
||||
<Box sx={{
|
||||
lineHeight: '16px',
|
||||
ml: '4px'
|
||||
}}>扫描失败</Box>
|
||||
</Stack>}
|
||||
{(record.status === 'failed') && <Tooltip title={record.error}>
|
||||
<Stack direction={'row'}>
|
||||
<ErrorOutlineIcon sx={{
|
||||
width: '16px',
|
||||
height: '16px',
|
||||
color: 'error.main'
|
||||
}} />
|
||||
<Box sx={{
|
||||
lineHeight: '16px',
|
||||
ml: '4px'
|
||||
}}>扫描失败</Box>
|
||||
</Stack>
|
||||
</Tooltip>}
|
||||
</Box>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user