@paymanai/payman-ask-sdk 4.0.4 → 4.0.5

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
@@ -131,17 +131,11 @@ var DEFAULT_SLASH_COMMANDS = [
131
131
  requiredAnyPermissions: ["vault:author", "vault:publish"]
132
132
  }
133
133
  ];
134
- function hasCommandPermission(granted, requiredPermission) {
135
- if (granted.has("*") || granted.has(requiredPermission)) return true;
136
- if (!requiredPermission.includes(".")) return false;
137
- const wildcard = requiredPermission.substring(0, requiredPermission.lastIndexOf(".")) + ".*";
138
- return granted.has(wildcard);
139
- }
140
134
  function filterSlashCommands(commands, permissions) {
141
135
  const granted = new Set(permissions ?? []);
142
136
  return commands.filter((command) => {
143
137
  const required = command.requiredAnyPermissions ?? [];
144
- return required.length === 0 || required.some((permission) => hasCommandPermission(granted, permission));
138
+ return required.length === 0 || required.some((permission) => granted.has(permission));
145
139
  });
146
140
  }
147
141
  function parseSlashCommand(content) {
@@ -154,19 +148,9 @@ function parseSlashCommand(content) {
154
148
  body: match[2] ?? ""
155
149
  };
156
150
  }
157
- function getSlashCommandValidationHint(content) {
151
+ function slashCommandBodyIsEmpty(content) {
158
152
  const parsed = parseSlashCommand(content);
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;
153
+ return parsed?.command === "/draft-knowledge" && parsed.body.trim().length === 0;
170
154
  }
171
155
 
172
156
  // src/utils/errorMessages.ts
@@ -2638,9 +2622,8 @@ var ChatInputV2 = forwardRef(
2638
2622
  }, [isRecording, transcribedText]);
2639
2623
  const handleSend = useCallback(() => {
2640
2624
  if (!value.trim() || disabled) return;
2641
- const commandHint = getSlashCommandValidationHint(value);
2642
- if (commandHint) {
2643
- setInlineHint(commandHint);
2625
+ if (slashCommandBodyIsEmpty(value)) {
2626
+ setInlineHint("Add markdown content below the command line.");
2644
2627
  return;
2645
2628
  }
2646
2629
  voiceDraftSyncActiveRef.current = false;