feat(metadata): replace aiAutofill boolean with autofillSource enum (#302)

* feat(metadata): replace aiAutofill boolean with autofillSource enum

* fix(agent): validate creation-context metadata and make writes transactional

Address code review feedback on the autofillSource migration:

- Update the agent system prompt to reference the 'metadata' parameter of
  create_file/create_version instead of the removed 'context' parameter,
  which was being silently discarded by the activity
- Write metadata inside the caller's transaction via the new
  metadataService.updateAssetMetadataInTx, keeping metadata rows atomic
  with asset creation instead of opening a separate non-atomic transaction
- Reject metadata keys that are not defined CREATION_CONTEXT fields of the
  project with a non-retryable ApplicationFailure before creating the asset
- Remove dead agentContext handling from autofillAiActivity and its tests,
  and drop the unused ai_autofill i18n keys (paraglide recompiled)
- Derive the DTO autofillSource enum from the AutofillSource const instead
  of a hardcoded z.enum to prevent drift
This commit is contained in:
Yiling-J
2026-08-13 13:41:46 +08:00
committed by GitHub
parent 96493a5493
commit 41b73feeab
57 changed files with 1118 additions and 663 deletions
+12 -1
View File
@@ -701,7 +701,18 @@
"field_type": "Field Type",
"select_field_type": "Select field type",
"description_optional_placeholder": "Optional, used for AI autofill",
"ai_autofill": "AI Autofill",
"autofill_source": "Autofill Source",
"autofill_source_none": "None",
"autofill_source_content": "Content",
"autofill_source_creation_context": "Creation Context",
"autofill_source_help_title": "Autofill Source Guide",
"autofill_source_help_desc": "Understand how each autofill source option works and when to use it.",
"autofill_source_none_desc": "Metadata fields marked as 'None' will not be automatically populated by AI. They are meant for manual user entry.",
"autofill_source_none_example": "Example: Internal tags, manual notes, status tracking flags.",
"autofill_source_content_desc": "Fields marked as 'Content' are automatically analyzed and extracted from the asset's visual or textual content after upload. Note: A team owner must first create and enable an Autofill Agent in team settings for content extraction to run.",
"autofill_source_content_example": "Example: Image subject category, visual color palette, document summary, auto-detected language.",
"autofill_source_creation_context_desc": "Fields marked as 'Creation Context' capture details available at creation time (such as generation prompt, model, or provider). If an asset is created by a Shumai AI Agent, the agent will automatically populate these fields upon creation (without needing an Autofill Agent enabled). If uploaded manually by a human user, the user must enter these values manually.",
"autofill_source_creation_context_example": "Example: Generation prompt, AI model name, LLM provider, sampler seed parameters.",
"select_field_to_edit": "Select a field to edit options",
"type_label": "Type:",
"options": "Options",
+12 -1
View File
@@ -701,7 +701,18 @@
"field_type": "字段类型",
"select_field_type": "选择字段类型",
"description_optional_placeholder": "可选,用于 AI 自动填充",
"ai_autofill": "AI 自动填充",
"autofill_source": "自动填充来源",
"autofill_source_none": "无",
"autofill_source_content": "文件内容",
"autofill_source_creation_context": "创建上下文",
"autofill_source_help_title": "自动填充来源说明",
"autofill_source_help_desc": "了解每种自动填充来源的工作方式及适用场景。",
"autofill_source_none_desc": "设置为“无”的字段不会由 AI 自动填充,需由用户手动填写。",
"autofill_source_none_example": "示例:内部标签、手动备注、状态标记。",
"autofill_source_content_desc": "设置为“文件内容”的字段将在文件上传后,由 AI 自动分析并从文件的视觉或文本内容中提取填写。注意:需要团队 Owner 先在设置中创建并启用“Autofill Agent”(自动填充 Agent),上传后才会触发内容提取。",
"autofill_source_content_example": "示例:图片类别、主色调、文档摘要、自动识别语言。",
"autofill_source_creation_context_desc": "设置为“创建上下文”的字段用于记录生成资产时的上下文信息(如 Prompt、模型或供应商)。若文件由 Shumai AI Agent 生成/创建,Agent 会在创建时刻自动填入这些字段(无需启用 Autofill Agent);若由真实用户手动上传,则需用户手动填写,不会自动提取。",
"autofill_source_creation_context_example": "示例:生成 Prompt、AI 模型名称、LLM 供应商、采样种子参数。",
"select_field_to_edit": "选择一个字段以编辑选项",
"type_label": "类型:",
"options": "选项",