mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 14:04:50 +00:00
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:
@@ -18,6 +18,14 @@ export const FieldType = {
|
||||
|
||||
export type FieldType = (typeof FieldType)[keyof typeof FieldType]
|
||||
|
||||
export const AutofillSource = {
|
||||
NONE: 'NONE',
|
||||
CONTENT: 'CONTENT',
|
||||
CREATION_CONTEXT: 'CREATION_CONTEXT',
|
||||
} as const
|
||||
|
||||
export type AutofillSource = (typeof AutofillSource)[keyof typeof AutofillSource]
|
||||
|
||||
export const selectOptionSchema = z.object({
|
||||
id: z.string(),
|
||||
displayName: z.string(),
|
||||
@@ -39,6 +47,7 @@ export const fieldConfigSchema = z.object({
|
||||
'user',
|
||||
'userMulti',
|
||||
]),
|
||||
autofillSource: z.nativeEnum(AutofillSource).optional(),
|
||||
text: z.any().optional(),
|
||||
longText: z.any().optional(),
|
||||
select: z.any().optional(),
|
||||
@@ -56,7 +65,6 @@ export const createFieldRequestSchema = z.object({
|
||||
label: z.string().optional(),
|
||||
scope: z.string().optional(),
|
||||
config: fieldConfigSchema,
|
||||
aiAutofill: z.boolean().default(false),
|
||||
description: z.string().default(''),
|
||||
})
|
||||
export type CreateFieldRequest = z.infer<typeof createFieldRequestSchema>
|
||||
@@ -64,7 +72,6 @@ export type CreateFieldRequest = z.infer<typeof createFieldRequestSchema>
|
||||
export const updateFieldRequestSchema = z.object({
|
||||
label: z.string().optional(),
|
||||
config: fieldConfigSchema,
|
||||
aiAutofill: z.boolean().optional(),
|
||||
description: z.string().optional(),
|
||||
})
|
||||
export type UpdateFieldRequest = z.infer<typeof updateFieldRequestSchema>
|
||||
@@ -93,6 +100,5 @@ export const fieldInfoSchema = z.object({
|
||||
readOnly: z.boolean(),
|
||||
visible: z.boolean(),
|
||||
description: z.string(),
|
||||
aiAutofill: z.boolean(),
|
||||
})
|
||||
export type FieldInfo = z.infer<typeof fieldInfoSchema>
|
||||
|
||||
Reference in New Issue
Block a user