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
@@ -11,7 +11,7 @@ import {
|
||||
import { permissionRequiredProcedure } from "../../trpc";
|
||||
import { parseCustomWidgetAuthoringInput } from "./authoring-validation";
|
||||
import { insertCustomWidgetDefinition } from "./definition-insert";
|
||||
import { getPreviewJournal, getPreviewSession, getPreviewSessionSecrets } from "./preview-sessions";
|
||||
import { getPreviewEvidence, getPreviewSession, getPreviewSessionSecrets } from "./preview-sessions";
|
||||
import { assertSecretSources } from "./secret-policy";
|
||||
|
||||
const logger = createLogger({ module: "custom-widget" });
|
||||
@@ -37,7 +37,7 @@ export const creationProcedures = {
|
||||
mcp: {
|
||||
enabled: true,
|
||||
description:
|
||||
"Create a Custom JSX widget only after customWidget_validate, customWidget_previewCreate, and every returned preview query succeed. Prefer templateLines for multiline JSX. Returns a client-navigable edit link.",
|
||||
"Requires administrator permission. Create a Custom JSX widget without reusing a preview. Prefer customWidget_createFromPreview after full preview validation and query checks so the definition is not streamed again.",
|
||||
},
|
||||
})
|
||||
.input(customWidgetCreateSchema)
|
||||
@@ -56,16 +56,16 @@ export const creationProcedures = {
|
||||
mcp: {
|
||||
enabled: true,
|
||||
description:
|
||||
"Persist the exact tested definition from a customWidget_previewCreate session. Prefer this over resending a large widget to customWidget_create. Every query in the final preview must have a successful customWidget_previewQuery journal entry.",
|
||||
"Requires administrator permission. Persist the exact tested definition from a customWidget_previewCreate or customWidget_previewReviseTemplate session. Prefer this over resending a large widget to customWidget_create. Every query and action in the final preview revision must have current evidence.",
|
||||
},
|
||||
})
|
||||
.input(z.object({ previewSessionId: z.string().min(1), targetBoardId: z.string().min(1).optional() }))
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const session = await getPreviewSession(input.previewSessionId, ctx.session.user.id);
|
||||
const journal = await getPreviewJournal(session.id, ctx.session.user.id);
|
||||
const evidence = await getPreviewEvidence(session.id, ctx.session.user.id);
|
||||
const unverifiedQueryIds = Object.entries(session.requests).flatMap(([requestId, request]) => {
|
||||
if (request.kind !== "query") return [];
|
||||
const verified = journal.some(
|
||||
const verified = evidence.some(
|
||||
(entry) =>
|
||||
entry.kind === "query" &&
|
||||
entry.requestId === requestId &&
|
||||
@@ -82,6 +82,23 @@ export const creationProcedures = {
|
||||
message: `Test every final preview query successfully before creating the widget: ${unverifiedQueryIds.join(", ")}`,
|
||||
});
|
||||
}
|
||||
const unverifiedActionIds = Object.entries(session.requests).flatMap(([requestId, request]) => {
|
||||
if (request.kind !== "action") return [];
|
||||
const verified = evidence.some((entry) => {
|
||||
if (entry.kind !== "action" || entry.requestId !== requestId || entry.sessionRevision !== session.revision) {
|
||||
return false;
|
||||
}
|
||||
if (entry.simulated) return true;
|
||||
return entry.status !== null && entry.status >= 200 && entry.status < 300;
|
||||
});
|
||||
return verified ? [] : [requestId];
|
||||
});
|
||||
if (unverifiedActionIds.length > 0) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
message: `Test every final preview action before creating the widget: ${unverifiedActionIds.join(", ")}`,
|
||||
});
|
||||
}
|
||||
|
||||
const definition = parseCustomWidgetAuthoringInput(() =>
|
||||
customWidgetDefinitionSchema.parse({
|
||||
|
||||
Reference in new issue
Block a user