fix(saas): deep audit round industry template system - critical fixes
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

C1: Use backend createAgentFromTemplate API + tools forwarding
C3: seed source='builtin' instead of 'custom'
C4: immutable clone data handling (return fresh from store) + spread)
H3: assignTemplate error propagation (try/catch)
H4: input validation for name/fields
H5: assign_template account existence check
H6: remove dead route get_full_template
H7: model fallback gpt-4o-mini (hardcoded constant)
H8: logout clears template state
H9: console.warn -> structured logger
C2: restoreSession fetches assignedTemplate
This commit is contained in:
iven
2026-04-03 19:45:25 +08:00
parent 0857a1f608
commit edecd4c81f
5 changed files with 62 additions and 802 deletions

View File

@@ -368,7 +368,8 @@ pub async fn create_agent_from_template(
Ok(AgentConfigFromTemplate {
name: t.name,
model: t.model.unwrap_or_else(|| "glm-4-flash".to_string()),
model: t.model.unwrap_or_else(|| "gpt-4o-mini".to_string()),
system_prompt: t.system_prompt,
tools: merged_tools,
soul_content: t.soul_content,

View File

@@ -642,7 +642,7 @@ async fn seed_demo_data(pool: &PgPool) -> SaasResult<()> {
"INSERT INTO agent_templates (id, name, description, category, source, model, system_prompt, tools, capabilities,
temperature, max_tokens, visibility, status, current_version, created_at, updated_at,
soul_content, scenarios, welcome_message, quick_commands, personality, communication_style, emoji, version, source_id)
VALUES ($1,$2,$3,$4,'custom',$5,$6,$7,$8,$9,$10,'public','active',1,$11,$11,$12,$13,$14,$15,$16,$17,$18,1,$19)
VALUES ($1,$2,$3,$4,'builtin',$5,$6,$7,$8,$9,$10,'public','active',1,$11,$11,$12,$13,$14,$15,$16,$17,$18,1,$19)
ON CONFLICT (id) DO NOTHING"
).bind(id).bind(name).bind(desc).bind(cat).bind(model).bind(prompt).bind(tools).bind(caps)
.bind(*temp).bind(*max_tok).bind(&ts)