@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.js +5 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -157,17 +157,11 @@ var DEFAULT_SLASH_COMMANDS = [
|
|
|
157
157
|
requiredAnyPermissions: ["vault:author", "vault:publish"]
|
|
158
158
|
}
|
|
159
159
|
];
|
|
160
|
-
function hasCommandPermission(granted, requiredPermission) {
|
|
161
|
-
if (granted.has("*") || granted.has(requiredPermission)) return true;
|
|
162
|
-
if (!requiredPermission.includes(".")) return false;
|
|
163
|
-
const wildcard = requiredPermission.substring(0, requiredPermission.lastIndexOf(".")) + ".*";
|
|
164
|
-
return granted.has(wildcard);
|
|
165
|
-
}
|
|
166
160
|
function filterSlashCommands(commands, permissions) {
|
|
167
161
|
const granted = new Set(permissions ?? []);
|
|
168
162
|
return commands.filter((command) => {
|
|
169
163
|
const required = command.requiredAnyPermissions ?? [];
|
|
170
|
-
return required.length === 0 || required.some((permission) =>
|
|
164
|
+
return required.length === 0 || required.some((permission) => granted.has(permission));
|
|
171
165
|
});
|
|
172
166
|
}
|
|
173
167
|
function parseSlashCommand(content) {
|
|
@@ -180,19 +174,9 @@ function parseSlashCommand(content) {
|
|
|
180
174
|
body: match[2] ?? ""
|
|
181
175
|
};
|
|
182
176
|
}
|
|
183
|
-
function
|
|
177
|
+
function slashCommandBodyIsEmpty(content) {
|
|
184
178
|
const parsed = parseSlashCommand(content);
|
|
185
|
-
|
|
186
|
-
const lines = parsed.body.split(/\r?\n/);
|
|
187
|
-
const title = lines[0]?.trim() ?? "";
|
|
188
|
-
const markdownContent = lines.slice(1).join("\n").trim();
|
|
189
|
-
if (!title) {
|
|
190
|
-
return "Add a title after /draft-knowledge, then add markdown content on the next line.";
|
|
191
|
-
}
|
|
192
|
-
if (!markdownContent) {
|
|
193
|
-
return "Add markdown content on a new line below the title.";
|
|
194
|
-
}
|
|
195
|
-
return null;
|
|
179
|
+
return parsed?.command === "/draft-knowledge" && parsed.body.trim().length === 0;
|
|
196
180
|
}
|
|
197
181
|
|
|
198
182
|
// src/utils/errorMessages.ts
|
|
@@ -2664,9 +2648,8 @@ var ChatInputV2 = react.forwardRef(
|
|
|
2664
2648
|
}, [isRecording, transcribedText]);
|
|
2665
2649
|
const handleSend = react.useCallback(() => {
|
|
2666
2650
|
if (!value.trim() || disabled) return;
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
setInlineHint(commandHint);
|
|
2651
|
+
if (slashCommandBodyIsEmpty(value)) {
|
|
2652
|
+
setInlineHint("Add markdown content below the command line.");
|
|
2670
2653
|
return;
|
|
2671
2654
|
}
|
|
2672
2655
|
voiceDraftSyncActiveRef.current = false;
|