chore(integration): snapshot local main worktree

This commit is contained in:
inman
2026-08-31 10:23:21 +08:00
parent 48a9189939
commit 33fb31fb28
116 changed files with 8108 additions and 3026 deletions

View File

@@ -16,24 +16,6 @@ export type ProjectAgentResponsibility = {
principles: string[];
};
export type ProjectAgentConfig = {
id: string;
avatarId: string;
avatarDataUrl?: string;
roleName: string;
name: string;
builtIn: boolean;
enabled: boolean;
model: string | null;
skillIds: string[];
responsibility: ProjectAgentResponsibility;
prompt: string;
archivedAt?: string | null;
pinned?: boolean;
createdAt?: string;
updatedAt?: string;
};
export const MAX_PROJECT_AGENT_AVATAR_DATA_URL_LENGTH = 800_000;
const PROJECT_AGENT_AVATAR_DATA_URL_PATTERN = /^data:image\/(?:webp|png|jpeg);base64,[A-Za-z0-9+/]+={0,2}$/u;
@@ -43,60 +25,3 @@ export function isProjectAgentAvatarDataUrl(value: unknown): value is string {
&& value.length <= MAX_PROJECT_AGENT_AVATAR_DATA_URL_LENGTH
&& PROJECT_AGENT_AVATAR_DATA_URL_PATTERN.test(value);
}
export type ProjectConfig = {
schemaVersion: 1;
projectType: ProjectType;
initialized: boolean;
defaultModel: string | null;
agents: ProjectAgentConfig[];
knowledgeDirectory: 'knowledge';
createdAt: string;
updatedAt: string;
};
export function createProjectConfig(
now = new Date().toISOString(),
projectType: ProjectType = 'custom',
): ProjectConfig {
return {
schemaVersion: 1,
projectType,
initialized: false,
defaultModel: null,
agents: [],
knowledgeDirectory: 'knowledge',
createdAt: now,
updatedAt: now,
};
}
export function validateAgentNames(agents: ProjectAgentConfig[]): string[] {
const errors: string[] = [];
const names = new Set<string>();
for (const item of agents) {
const name = item.name.trim();
if (!name) errors.push(`${item.id}:name-required`);
if (name.length > 30) errors.push(`${item.id}:name-too-long`);
const key = name.toLocaleLowerCase();
if (key && names.has(key)) errors.push(`${item.id}:name-duplicate`);
names.add(key);
}
return errors;
}
export function validateAgentConfigs(agents: ProjectAgentConfig[]): string[] {
const errors = validateAgentNames(agents);
for (const agent of agents) {
if (!/^avatar-(0[1-9]|1[0-6])$/.test(agent.avatarId)) {
errors.push(`${agent.id}:avatar-required`);
}
if (!agent.model?.trim()) {
errors.push(`${agent.id}:model-required`);
}
if (!agent.responsibility.mission.trim()) {
errors.push(`${agent.id}:responsibility-required`);
}
}
return errors;
}