Просмотр исходного кода

fix(agents): preserve caller-provided agent id

Agent creation currently overwrites explicit IDs with a slug derived from the display name, which breaks non-ASCII names and prevents clients such as PaaS from creating stable remote identities.

- Prefer a trimmed caller-provided entity ID
- Fall back to the existing name slug only when no ID is supplied
- Preserve existing UI creation behavior for callers without an explicit ID
KongLingTT 1 месяц назад
Родитель
Сommit
df0cd1cbb1
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      src/lib/server/catalog/git.ts

+ 1 - 1
src/lib/server/catalog/git.ts

@@ -87,7 +87,7 @@ abstract class GitCatalog<T extends Entity, TCR = unknown> {
 	async create(entity: T): Promise<{ entity: T; cr: TCR }> {
 		await this.#init();
 		const branch = `feat/create-${this.#entityTypeName}-${entity.name}`;
-		entity.id = slugify(entity.name);
+		entity.id = entity.id?.trim() || slugify(entity.name);
 		const cr = this.#entitySerializer(entity);
 		await this.#gitClient.createFile(
 			`${this.#entitiesDirectory}/${entity.id}.yaml`,