feat(assistant): optimize MCP and custom widget authoring (#6743)
* feat(assistant): optimize MCP and custom widget authoring * fix(assistant): isolate server-safe JSX analyzer * refactor(assistant): generate MCP tool staging * fix(assistant): preserve widget placement follow-up * fix(ci): allow fast gate to finish * fix(custom-widgets): address review findings * fix(custom-widgets): split preview evidence module * style: format assistant custom widget files * fix(custom-widgets): sync formatted skill schema
This commit is contained in:
1 parent
38f4b0e1f8
commit
5e23659d99
95 files changed
+6799
-1778
No files matched your search
@@ -19,6 +19,12 @@ export * from "./request-schema";
|
||||
export const CUSTOM_WIDGET_SCHEMA = "homarr-custom-widget-v2";
|
||||
const CUSTOM_WIDGET_TEMPLATE_MAX_LENGTH = 50_000;
|
||||
|
||||
export const normalizeCustomJsxAuthoringTemplate = (template: string) =>
|
||||
template
|
||||
.normalize("NFC")
|
||||
.replaceAll("\u200B", "")
|
||||
.replaceAll(/(\s)[\u0300-\u036f]+(?=[\p{L}\p{N}_$])/gu, "$1");
|
||||
|
||||
export const customWidgetBindingIdentifierSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
@@ -30,18 +36,23 @@ export const customWidgetBindingIdentifierSchema = z
|
||||
|
||||
export const customJsxTemplateSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(CUSTOM_WIDGET_TEMPLATE_MAX_LENGTH)
|
||||
.superRefine((template, ctx) => {
|
||||
for (const diagnostic of validateCustomJsxTemplate(template)) {
|
||||
if (diagnostic.severity === "error") {
|
||||
ctx.addIssue({
|
||||
code: "custom",
|
||||
message: `${diagnostic.message} (line ${diagnostic.line}, column ${diagnostic.column})`,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
.transform(normalizeCustomJsxAuthoringTemplate)
|
||||
.pipe(
|
||||
z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(CUSTOM_WIDGET_TEMPLATE_MAX_LENGTH)
|
||||
.superRefine((template, ctx) => {
|
||||
for (const diagnostic of validateCustomJsxTemplate(template)) {
|
||||
if (diagnostic.severity === "error") {
|
||||
ctx.addIssue({
|
||||
code: "custom",
|
||||
message: `${diagnostic.message} (line ${diagnostic.line}, column ${diagnostic.column})`,
|
||||
});
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
export const customWidgetSecretInputSchema = z.strictObject({
|
||||
sourceId: customWidgetIdentifierSchema,
|
||||
@@ -195,7 +206,7 @@ function validateTemplateRequests(template: string, requests: Record<string, Cus
|
||||
export type HomarrCustomWidgetV2 = z.infer<typeof customWidgetDefinitionSchema>;
|
||||
export type HomarrCustomWidgetV2Input = z.input<typeof customWidgetDefinitionSchema>;
|
||||
|
||||
const customWidgetTemplateLinesSchema = z
|
||||
export const customWidgetTemplateLinesSchema = z
|
||||
.array(z.string().max(10_000))
|
||||
.min(1)
|
||||
.max(2_000)
|
||||
|
||||
Reference in new issue
Block a user