Files
devops-platform-api/src/agent/create-agent-invocation.dto.ts
T
湛兮 bc3aa31289 feat: 接入真实登录与成员权限
- auth/members/messages: 新增超级管理员登录、成员权限和密码消息流程
- agent-config/agent: 支持服务端保存 Agent 配置并取消未配置 mock 成功结果
- projects/deploy-runs/settings: 按当前用户权限保护真实接口
- prisma: 新增用户、项目权限和平台消息表结构
2026-06-12 00:38:23 +08:00

60 lines
1.4 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { z } from 'zod';
import { AgentPurpose } from './agent.types';
const agentPurposeSchema = z.enum([
'release-risk',
'failure-diagnosis',
'runbook-qa',
'release-note',
'incident-review',
]);
const optionalTrimmedString = (maxLength: number) =>
z
.string()
.trim()
.max(maxLength)
.optional()
.or(z.literal('').transform(() => undefined));
/**
* Agent 入口只接受 DevOps 场景参数,防止演变成通用聊天代理。
*/
export const createAgentInvocationSchema = z.object({
type: agentPurposeSchema,
runId: optionalTrimmedString(120),
projectKey: optionalTrimmedString(80),
promptSummary: z.string().trim().min(1).max(2000),
});
export type CreateAgentInvocationInput = z.infer<
typeof createAgentInvocationSchema
>;
export class CreateAgentInvocationDto {
@ApiProperty({
enum: [
'release-risk',
'failure-diagnosis',
'runbook-qa',
'release-note',
'incident-review',
],
example: 'failure-diagnosis',
})
type!: AgentPurpose;
@ApiPropertyOptional({ example: 'run-1052' })
runId?: string;
@ApiPropertyOptional({ example: 'access-manage' })
projectKey?: string;
@ApiProperty({
description: '本次 Agent 调用的中文问题或任务摘要',
example: '分析 access-manage 测试环境最近一次 Jenkins 失败日志。',
})
promptSummary!: string;
}