@mrclrchtr/supi-ask-user 4.1.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "SuPi core — shared infrastructure for SuPi extensions (XML context tags, config system)",
5
5
  "license": "MIT",
6
6
  "repository": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-ask-user",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "SuPi ask-user extension — rich questionnaire UI for structured agent-user decisions",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -32,7 +32,7 @@
32
32
  "!__tests__"
33
33
  ],
34
34
  "dependencies": {
35
- "@mrclrchtr/supi-core": "4.1.0"
35
+ "@mrclrchtr/supi-core": "4.3.0"
36
36
  },
37
37
  "bundledDependencies": [
38
38
  "@mrclrchtr/supi-core"
package/src/normalize.ts CHANGED
@@ -80,8 +80,8 @@ function validateQuestionCount(count: number): void {
80
80
 
81
81
  function validateCommonFields(question: ExternalQuestion): void {
82
82
  const id = question.id.trim();
83
- const header = question.header.trim();
84
- const prompt = question.prompt.trim();
83
+ const header = normalizeDisplayText(question.header);
84
+ const prompt = normalizeDisplayText(question.prompt);
85
85
 
86
86
  if (!id) throw new AskUserValidationError("Question id must be a non-empty string.");
87
87
  if (!header) {
@@ -119,8 +119,8 @@ function normalizeChoice(question: ExternalChoiceQuestion): NormalizedChoiceQues
119
119
 
120
120
  return {
121
121
  id: question.id.trim(),
122
- header: question.header.trim(),
123
- prompt: question.prompt.trim(),
122
+ header: normalizeDisplayText(question.header),
123
+ prompt: normalizeDisplayText(question.prompt),
124
124
  type: "choice",
125
125
  options,
126
126
  multi,
@@ -155,8 +155,8 @@ function normalizeText(question: ExternalTextQuestion): NormalizedTextQuestion {
155
155
 
156
156
  return {
157
157
  id: question.id.trim(),
158
- header: question.header.trim(),
159
- prompt: question.prompt.trim(),
158
+ header: normalizeDisplayText(question.header),
159
+ prompt: normalizeDisplayText(question.prompt),
160
160
  type: "text",
161
161
  ...(recommendation ? { recommendation } : {}),
162
162
  ...(placeholder ? { placeholder } : {}),
@@ -179,7 +179,7 @@ function normalizeOptions(
179
179
  const seen = new Set<string>();
180
180
  return options.map((option) => {
181
181
  const value = option.value.trim();
182
- const label = option.label.trim();
182
+ const label = normalizeDisplayText(option.label);
183
183
  if (!value || !label) {
184
184
  throw new AskUserValidationError(
185
185
  `choice question "${questionId}" has an option with empty value or label.`,
@@ -251,7 +251,16 @@ function resolveIndexes(args: {
251
251
  });
252
252
  }
253
253
 
254
+ /** Decodes JSON-style Unicode escapes that models sometimes emit literally in display text. */
255
+ function normalizeDisplayText(value: string): string {
256
+ return value
257
+ .replace(/\\u([0-9a-fA-F]{4})/g, (_escape, hex: string) =>
258
+ String.fromCharCode(Number.parseInt(hex, 16)),
259
+ )
260
+ .trim();
261
+ }
262
+
254
263
  function trimOptional(value: string | undefined): string | undefined {
255
- const trimmed = value?.trim();
264
+ const trimmed = value === undefined ? undefined : normalizeDisplayText(value);
256
265
  return trimmed ? trimmed : undefined;
257
266
  }