@paymanai/payman-ask-sdk 4.0.2 → 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.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -157,11 +157,17 @@ 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
|
+
}
|
|
160
166
|
function filterSlashCommands(commands, permissions) {
|
|
161
167
|
const granted = new Set(permissions ?? []);
|
|
162
168
|
return commands.filter((command) => {
|
|
163
169
|
const required = command.requiredAnyPermissions ?? [];
|
|
164
|
-
return required.length === 0 || required.some((permission) => granted
|
|
170
|
+
return required.length === 0 || required.some((permission) => hasCommandPermission(granted, permission));
|
|
165
171
|
});
|
|
166
172
|
}
|
|
167
173
|
function parseSlashCommand(content) {
|
|
@@ -174,9 +180,19 @@ function parseSlashCommand(content) {
|
|
|
174
180
|
body: match[2] ?? ""
|
|
175
181
|
};
|
|
176
182
|
}
|
|
177
|
-
function
|
|
183
|
+
function getSlashCommandValidationHint(content) {
|
|
178
184
|
const parsed = parseSlashCommand(content);
|
|
179
|
-
|
|
185
|
+
if (parsed?.command !== "/draft-knowledge") return null;
|
|
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;
|
|
180
196
|
}
|
|
181
197
|
|
|
182
198
|
// src/utils/errorMessages.ts
|
|
@@ -2648,8 +2664,9 @@ var ChatInputV2 = react.forwardRef(
|
|
|
2648
2664
|
}, [isRecording, transcribedText]);
|
|
2649
2665
|
const handleSend = react.useCallback(() => {
|
|
2650
2666
|
if (!value.trim() || disabled) return;
|
|
2651
|
-
|
|
2652
|
-
|
|
2667
|
+
const commandHint = getSlashCommandValidationHint(value);
|
|
2668
|
+
if (commandHint) {
|
|
2669
|
+
setInlineHint(commandHint);
|
|
2653
2670
|
return;
|
|
2654
2671
|
}
|
|
2655
2672
|
voiceDraftSyncActiveRef.current = false;
|