@paymanai/payman-ask-sdk 4.0.3 → 4.0.4

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.
package/dist/index.mjs CHANGED
@@ -154,9 +154,19 @@ function parseSlashCommand(content) {
154
154
  body: match[2] ?? ""
155
155
  };
156
156
  }
157
- function slashCommandBodyIsEmpty(content) {
157
+ function getSlashCommandValidationHint(content) {
158
158
  const parsed = parseSlashCommand(content);
159
- return parsed?.command === "/draft-knowledge" && parsed.body.trim().length === 0;
159
+ if (parsed?.command !== "/draft-knowledge") return null;
160
+ const lines = parsed.body.split(/\r?\n/);
161
+ const title = lines[0]?.trim() ?? "";
162
+ const markdownContent = lines.slice(1).join("\n").trim();
163
+ if (!title) {
164
+ return "Add a title after /draft-knowledge, then add markdown content on the next line.";
165
+ }
166
+ if (!markdownContent) {
167
+ return "Add markdown content on a new line below the title.";
168
+ }
169
+ return null;
160
170
  }
161
171
 
162
172
  // src/utils/errorMessages.ts
@@ -2628,8 +2638,9 @@ var ChatInputV2 = forwardRef(
2628
2638
  }, [isRecording, transcribedText]);
2629
2639
  const handleSend = useCallback(() => {
2630
2640
  if (!value.trim() || disabled) return;
2631
- if (slashCommandBodyIsEmpty(value)) {
2632
- setInlineHint("Add markdown content below the command line.");
2641
+ const commandHint = getSlashCommandValidationHint(value);
2642
+ if (commandHint) {
2643
+ setInlineHint(commandHint);
2633
2644
  return;
2634
2645
  }
2635
2646
  voiceDraftSyncActiveRef.current = false;