feat: harden ask tool validation and fallback

This commit is contained in:
Erik Kotsiuba
2026-04-19 18:15:19 +02:00
parent 9c559c9084
commit 050e8800cd
8 changed files with 464 additions and 19 deletions
+10
View File
@@ -2,19 +2,23 @@ import { Type } from "@sinclair/typebox";
export const AskOptionSchema = Type.Object({
value: Type.String({
minLength: 1,
description:
"Machine-readable value returned for this option in the result",
}),
label: Type.String({
minLength: 1,
description: "Short visible option label shown in the list",
}),
description: Type.Optional(
Type.String({
minLength: 1,
description: "Optional one-line explanation to help the user choose",
})
),
preview: Type.Optional(
Type.String({
minLength: 1,
description:
"Optional preview content shown in the dedicated preview pane for preview questions",
})
@@ -23,15 +27,18 @@ export const AskOptionSchema = Type.Object({
export const AskQuestionSchema = Type.Object({
id: Type.String({
minLength: 1,
description:
"Stable question identifier used as the key in returned answers",
}),
label: Type.Optional(
Type.String({
minLength: 1,
description: "Short tab label, e.g. Goal, Audience, Tone, Scope",
})
),
prompt: Type.String({
minLength: 1,
description:
"Direct question shown to the user; ask about one decision at a time",
}),
@@ -51,6 +58,7 @@ export const AskQuestionSchema = Type.Object({
})
),
options: Type.Array(AskOptionSchema, {
minItems: 1,
description: "Answer options; prefer 2-4 clear choices when possible",
}),
});
@@ -58,11 +66,13 @@ export const AskQuestionSchema = Type.Object({
export const AskParamsSchema = Type.Object({
title: Type.Optional(
Type.String({
minLength: 1,
description:
"Optional short title shown above the clarification flow, e.g. README direction",
})
),
questions: Type.Array(AskQuestionSchema, {
minItems: 1,
description: "Questions to ask in the interactive clarification flow",
}),
});