chatluna-plugin-kb 0.2.8 → 0.2.10
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/package.json +1 -1
- package/src/policy/acl.mjs +20 -1
- package/web/client.css +0 -1
package/package.json
CHANGED
package/src/policy/acl.mjs
CHANGED
|
@@ -16,6 +16,21 @@ export class PermissionError extends Error {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/** 调用参数缺失/自相矛盾:不是权限拒绝,模型可当场修正后重试。 */
|
|
20
|
+
export class InvalidArgumentError extends Error {
|
|
21
|
+
code = 'INVALID_ARGUMENT'
|
|
22
|
+
|
|
23
|
+
constructor(reason) {
|
|
24
|
+
super(`INVALID_ARGUMENT: ${String(reason ?? 'invalid argument')}`)
|
|
25
|
+
this.name = 'InvalidArgumentError'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** @returns {InvalidArgumentError} */
|
|
30
|
+
export function invalid(reason) {
|
|
31
|
+
return new InvalidArgumentError(reason)
|
|
32
|
+
}
|
|
33
|
+
|
|
19
34
|
/**
|
|
20
35
|
* @param {string} reason 不含知识库名称/ID 的简短原因
|
|
21
36
|
* @returns {PermissionError}
|
|
@@ -102,7 +117,11 @@ export async function resolveKbTarget({ requested, defaultKb, spec, client }) {
|
|
|
102
117
|
if (typeof client?.listKbsRaw !== 'function') throw denied('knowledge base lookup unavailable')
|
|
103
118
|
const raw = String(requested ?? '').trim()
|
|
104
119
|
const target = raw === '' ? String(defaultKb ?? '').trim() : raw
|
|
105
|
-
if (target === '')
|
|
120
|
+
if (target === '') {
|
|
121
|
+
throw invalid(
|
|
122
|
+
'knowledge_base is required because this scope has no default KB; pass a KB id or name from list_kbs'
|
|
123
|
+
)
|
|
124
|
+
}
|
|
106
125
|
|
|
107
126
|
let catalog
|
|
108
127
|
try {
|