@lacneu/openclaw-knowledge 3.2.2 → 3.2.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/CHANGELOG.md +329 -0
- package/dist/config.js +22 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +102 -16
- package/dist/index.js.map +1 -1
- package/dist/jina/classifier.d.ts +7 -2
- package/dist/jina/classifier.js +4 -2
- package/dist/jina/classifier.js.map +1 -1
- package/dist/jina/client.d.ts +11 -1
- package/dist/jina/client.js +5 -1
- package/dist/jina/client.js.map +1 -1
- package/dist/jina/rate-limit.d.ts +62 -0
- package/dist/jina/rate-limit.js +100 -0
- package/dist/jina/rate-limit.js.map +1 -0
- package/dist/jina/reranker.d.ts +4 -1
- package/dist/jina/reranker.js +2 -1
- package/dist/jina/reranker.js.map +1 -1
- package/dist/pgvector.d.ts +43 -0
- package/dist/pgvector.js +47 -25
- package/dist/pgvector.js.map +1 -1
- package/dist/router/heuristic.js +39 -0
- package/dist/router/heuristic.js.map +1 -1
- package/dist/router/index.d.ts +15 -0
- package/dist/router/index.js +9 -0
- package/dist/router/index.js.map +1 -1
- package/dist/tracing/events.d.ts +43 -2
- package/dist/tracing/events.js +7 -0
- package/dist/tracing/events.js.map +1 -1
- package/dist/types.d.ts +53 -0
- package/openclaw.plugin.json +37 -1
- package/package.json +1 -1
package/dist/pgvector.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pgvector.js","sourceRoot":"","sources":["../src/pgvector.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,iEAAiE;AACjE,2EAA2E;AAC3E,6EAA6E;AAC7E,0EAA0E;AAC1E,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,wEAAwE;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{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C,IAAI,CAAC,KAAK,CAAC,CAAC;YAClC,IAAI,KAAK;gBAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,oEAAoE;QACpE,qDAAqD;QACrD,IAAI,GAAG,YAAY,SAAS;YAAE,MAAM,GAAG,CAAC;QACxC,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/router/heuristic.js
CHANGED
|
@@ -43,6 +43,45 @@ const META_PATTERNS = [
|
|
|
43
43
|
// Same anchoring for the FR variants ("tu es là ?").
|
|
44
44
|
/^\s*(?:(?:system|the\s+system)\s+)?(?:status|ping|heartbeat)\s*[?!.]*\s*$/i,
|
|
45
45
|
/^\s*(?:are\s+you\s+(?:there|alive)|t['e]es?\s+(?:la|en\s+ligne))\s*[?!.]*\s*$/i,
|
|
46
|
+
// Open WebUI automatic background prompts — Open WebUI re-uses the
|
|
47
|
+
// same chat thread to ask the LLM for a title, tags, follow-up
|
|
48
|
+
// questions, or a summary after every assistant turn. Successive
|
|
49
|
+
// code-review iterations rejected weaker signals:
|
|
50
|
+
// - Codex #28: verb alone (Generate/Suggest/Create) matches real
|
|
51
|
+
// prompts like "Create a migration plan from the docs".
|
|
52
|
+
// - Codex #29: structural triple `### Task:` + `### Output:` +
|
|
53
|
+
// `JSON format: {` matches power-user structured extraction.
|
|
54
|
+
// - Codex #30: even the four canonical OWUI keys (title / tags /
|
|
55
|
+
// follow_ups / summary) match real tasks like "Summarize the
|
|
56
|
+
// documents with JSON format: { summary: ... }".
|
|
57
|
+
// - Codex #31: just `### Task:` + `<chat_history>…</chat_history>`
|
|
58
|
+
// matches a user asking to ANALYZE the OWUI template itself.
|
|
59
|
+
//
|
|
60
|
+
// To converge, we stack FOUR OWUI-specific structural markers so a
|
|
61
|
+
// hand-written prompt would have to mimic the EXACT OWUI shape to
|
|
62
|
+
// be falsely classified:
|
|
63
|
+
//
|
|
64
|
+
// 1. `### Task:` at the START of the prompt (anchored)
|
|
65
|
+
// 2. `### Output:` OWUI directive header
|
|
66
|
+
// 3. `### Chat History:` OWUI section header (literal, not the
|
|
67
|
+
// generic XML tag — a user analyzing
|
|
68
|
+
// the OWUI template typically pastes
|
|
69
|
+
// only `<chat_history>` without the
|
|
70
|
+
// section header preceding it)
|
|
71
|
+
// 4. `<chat_history>…</chat_history>` block — and it MUST sit at
|
|
72
|
+
// the END of the prompt (`\s*$`). OWUI
|
|
73
|
+
// auto-prompts terminate exactly there;
|
|
74
|
+
// a user analyzing the template almost
|
|
75
|
+
// always appends a question / "explain"
|
|
76
|
+
// AFTER the closing tag, defeating the
|
|
77
|
+
// end anchor.
|
|
78
|
+
//
|
|
79
|
+
// The middle expansions are bounded (`{1,16000}`, `{1,4000}?`,
|
|
80
|
+
// `{0,32000}`) to keep the regex engine linear on malformed input.
|
|
81
|
+
// 16 KB covers the longest OWUI Guidelines block; 4 KB covers the
|
|
82
|
+
// Output + Examples section; 32 KB covers realistic chat history
|
|
83
|
+
// payloads (OWUI defaults to the last 6 messages).
|
|
84
|
+
/^\s*###\s*Task:[\s\S]{1,16000}\n###\s*Output:[\s\S]{1,4000}?\n###\s*Chat\s+History:\s*\n<chat_history>[\s\S]{0,32000}<\/chat_history>\s*$/i,
|
|
46
85
|
];
|
|
47
86
|
// ---------------------------------------------------------------------------
|
|
48
87
|
// CLI test guards — short trivial prompts coming from `id:"cli"`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heuristic.js","sourceRoot":"","sources":["../../src/router/heuristic.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,EAAE;AACF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,qEAAqE;AACrE,sEAAsE;AACtE,yEAAyE;AACzE,mBAAmB;AACnB,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,oDAAoD;AACp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AE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IACxD,CAAC;IAED,kDAAkD;IAClD,KAAK,MAAM,EAAE,IAAI,aAAa,EAAE,CAAC;QAC/B,IAAI,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;QACrD,CAAC;IACH,CAAC;IAED,sEAAsE;IACtE,iEAAiE;IACjE,IAAI,KAAK,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;IACtD,CAAC;IAED,yBAAyB;IACzB,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACnD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IACjE,CAAC;IACD,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACnD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IACjE,CAAC;IAED,mEAAmE;IACnE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;AACxD,CAAC"}
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RpmMonitor } from "../jina/rate-limit.js";
|
|
1
2
|
import type { RouterDecision } from "./types.js";
|
|
2
3
|
export interface RouterConfig {
|
|
3
4
|
/** Master switch. When false, every call returns `{route: "ALL"}`. */
|
|
@@ -32,6 +33,20 @@ export interface RouterConfig {
|
|
|
32
33
|
* Trusting only confident scores keeps the gate fail-safe.
|
|
33
34
|
*/
|
|
34
35
|
minConfidence?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Optional callback fired AFTER a successful Jina `/v1/classify` call
|
|
38
|
+
* with payload-level numbers (duration, model). The plugin uses it to
|
|
39
|
+
* emit a `jina` usage event so dashboards can track classify spend
|
|
40
|
+
* per turn independently of the router decision.
|
|
41
|
+
*
|
|
42
|
+
* @since 3.2.4
|
|
43
|
+
*/
|
|
44
|
+
onClassifierUsage?: (usage: {
|
|
45
|
+
durationMs: number;
|
|
46
|
+
model: "zero-shot" | "few-shot";
|
|
47
|
+
}) => void;
|
|
48
|
+
/** Optional RPM monitor (forwarded to the Jina client). @since 3.2.4 */
|
|
49
|
+
rpmMonitor?: RpmMonitor;
|
|
35
50
|
}
|
|
36
51
|
/**
|
|
37
52
|
* Default applied by {@link decideRoute} when a caller omits
|
package/dist/router/index.js
CHANGED
|
@@ -66,6 +66,7 @@ export async function decideRoute(cfg, ctx) {
|
|
|
66
66
|
return { route: FALLBACK, reason: "classifier_fallback", score: null };
|
|
67
67
|
}
|
|
68
68
|
try {
|
|
69
|
+
const startedAt = Date.now();
|
|
69
70
|
const outcome = cfg.classifierId
|
|
70
71
|
? await classifyFewShot({
|
|
71
72
|
apiKey: cfg.jinaApiKey,
|
|
@@ -73,13 +74,21 @@ export async function decideRoute(cfg, ctx) {
|
|
|
73
74
|
classifierId: cfg.classifierId,
|
|
74
75
|
expectedLabels: ROUTER_LABEL_NAMES,
|
|
75
76
|
signal: ctx.signal,
|
|
77
|
+
rpmMonitor: cfg.rpmMonitor,
|
|
76
78
|
})
|
|
77
79
|
: await classifyZeroShot({
|
|
78
80
|
apiKey: cfg.jinaApiKey,
|
|
79
81
|
text: ctx.query,
|
|
80
82
|
labels: (cfg.labels ?? DEFAULT_ROUTER_LABELS),
|
|
81
83
|
signal: ctx.signal,
|
|
84
|
+
rpmMonitor: cfg.rpmMonitor,
|
|
82
85
|
});
|
|
86
|
+
if (cfg.onClassifierUsage) {
|
|
87
|
+
cfg.onClassifierUsage({
|
|
88
|
+
durationMs: Date.now() - startedAt,
|
|
89
|
+
model: cfg.classifierId ? "few-shot" : "zero-shot",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
83
92
|
if (!outcome) {
|
|
84
93
|
return { route: FALLBACK, reason: "classifier_fallback", score: null };
|
|
85
94
|
}
|
package/dist/router/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,2EAA2E;AAC3E,kEAAkE;AAClE,EAAE;AACF,+BAA+B;AAC/B,sEAAsE;AACtE,kDAAkD;AAClD,sEAAsE;AACtE,oEAAoE;AACpE,sEAAsE;AACtE,iDAAiD;AAEjD,OAAO,EACL,eAAe,EACf,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,2EAA2E;AAC3E,kEAAkE;AAClE,EAAE;AACF,+BAA+B;AAC/B,sEAAsE;AACtE,kDAAkD;AAClD,sEAAsE;AACtE,oEAAoE;AACpE,sEAAsE;AACtE,iDAAiD;AAEjD,OAAO,EACL,eAAe,EACf,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAoDhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C,+EAA+E;AAC/E,SAAS,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25,10 +25,23 @@ export interface RouterEvent {
|
|
|
25
25
|
export interface PgvectorEvent {
|
|
26
26
|
type: "pgvector";
|
|
27
27
|
collections: string[];
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Recall size of the vector search BEFORE the optional reranker.
|
|
30
|
+
* `null` when {@link errored} is `true` and the value is therefore
|
|
31
|
+
* not a meaningful "no hits" signal.
|
|
32
|
+
*/
|
|
33
|
+
rawCount: number | null;
|
|
29
34
|
rerankedCount: number | null;
|
|
30
35
|
topScore: number | null;
|
|
31
36
|
durationMs: number;
|
|
37
|
+
/**
|
|
38
|
+
* `true` when at least one configured collection's SQL search threw.
|
|
39
|
+
* Surfaces failure modes (DB down, schema drift, network) that would
|
|
40
|
+
* otherwise be indistinguishable from a 0-hit query in the event log.
|
|
41
|
+
*
|
|
42
|
+
* @since 3.2.3
|
|
43
|
+
*/
|
|
44
|
+
errored: boolean;
|
|
32
45
|
}
|
|
33
46
|
export interface LightRAGEvent {
|
|
34
47
|
type: "lightrag";
|
|
@@ -36,7 +49,23 @@ export interface LightRAGEvent {
|
|
|
36
49
|
contextChars: number;
|
|
37
50
|
truncatedChars: number;
|
|
38
51
|
durationMs: number;
|
|
52
|
+
/**
|
|
53
|
+
* `true` when the LightRAG payload (post-truncation) is below
|
|
54
|
+
* {@link LIGHTRAG_SPARSE_THRESHOLD_CHARS}, i.e. the graph essentially
|
|
55
|
+
* returned nothing usable. Surfaces knowledge-coverage gaps in
|
|
56
|
+
* dashboards without re-inspecting the raw context.
|
|
57
|
+
*
|
|
58
|
+
* @since 3.2.3
|
|
59
|
+
*/
|
|
60
|
+
sparse: boolean;
|
|
39
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Threshold under which a LightRAG response is flagged `sparse`. Picked
|
|
64
|
+
* empirically: 200 chars is roughly two short sentences — anything
|
|
65
|
+
* below is too little to ground a non-trivial answer, so it is more
|
|
66
|
+
* useful to surface the gap than to act on it.
|
|
67
|
+
*/
|
|
68
|
+
export declare const LIGHTRAG_SPARSE_THRESHOLD_CHARS = 200;
|
|
40
69
|
export interface JinaUsageEvent {
|
|
41
70
|
type: "jina";
|
|
42
71
|
endpoint: "classify" | "rerank";
|
|
@@ -49,7 +78,19 @@ export interface CooldownEvent {
|
|
|
49
78
|
scope: "global" | "router" | "pgvector_reranker";
|
|
50
79
|
consecutiveErrors: number;
|
|
51
80
|
}
|
|
52
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Emitted (at most once per 60-second window) when the plugin's
|
|
83
|
+
* Jina RPM soft monitor observes the configured budget being exceeded.
|
|
84
|
+
* Pure observability — does not block any call.
|
|
85
|
+
*
|
|
86
|
+
* @since 3.2.4
|
|
87
|
+
*/
|
|
88
|
+
export interface JinaRpmExceededEvent {
|
|
89
|
+
type: "jina_rpm_exceeded";
|
|
90
|
+
count: number;
|
|
91
|
+
budget: number;
|
|
92
|
+
}
|
|
93
|
+
export type KnowledgeEvent = RouterEvent | PgvectorEvent | LightRAGEvent | JinaUsageEvent | CooldownEvent | JinaRpmExceededEvent;
|
|
53
94
|
/**
|
|
54
95
|
* Emit a structured event line through `logger.info`.
|
|
55
96
|
*
|
package/dist/tracing/events.js
CHANGED
|
@@ -31,6 +31,13 @@
|
|
|
31
31
|
* versions — log scrapers and Opik rules depend on it.
|
|
32
32
|
*/
|
|
33
33
|
export const EVENT_PREFIX = "[knowledge.event]";
|
|
34
|
+
/**
|
|
35
|
+
* Threshold under which a LightRAG response is flagged `sparse`. Picked
|
|
36
|
+
* empirically: 200 chars is roughly two short sentences — anything
|
|
37
|
+
* below is too little to ground a non-trivial answer, so it is more
|
|
38
|
+
* useful to surface the gap than to act on it.
|
|
39
|
+
*/
|
|
40
|
+
export const LIGHTRAG_SPARSE_THRESHOLD_CHARS = 200;
|
|
34
41
|
// ---------------------------------------------------------------------------
|
|
35
42
|
// Emitters
|
|
36
43
|
// ---------------------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/tracing/events.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,yDAAyD;AACzD,EAAE;AACF,wEAAwE;AACxE,+DAA+D;AAC/D,wEAAwE;AACxE,+BAA+B;AAC/B,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,gEAAgE;AAChE,wEAAwE;AACxE,iCAAiC;AACjC,EAAE;AACF,oEAAoE;AACpE,uEAAuE;AACvE,qEAAqE;AACrE,sEAAsE;AACtE,uEAAuE;AACvE,8DAA8D;AAC9D,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAC1E,mBAAmB;AAcnB;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/tracing/events.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,yDAAyD;AACzD,EAAE;AACF,wEAAwE;AACxE,+DAA+D;AAC/D,wEAAwE;AACxE,+BAA+B;AAC/B,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,gEAAgE;AAChE,wEAAwE;AACxE,iCAAiC;AACjC,EAAE;AACF,oEAAoE;AACpE,uEAAuE;AACvE,qEAAqE;AACrE,sEAAsE;AACtE,uEAAuE;AACvE,8DAA8D;AAC9D,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAC1E,mBAAmB;AAcnB;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAsDhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,CAAC;AAqCnD,8EAA8E;AAC9E,WAAW;AACX,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,MAAqB,EAAE,KAAqB;IACpE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,IAAI,OAAO,EAAE,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,4DAA4D;IAC9D,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAqB,EACrB,KAAyB,EACzB,WAAmB;IAEnB,IAAI,CAAC,MAAM,CAAC,KAAK;QAAE,OAAO;IAC1B,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,wBAAwB,EAAE,SAAS,WAAW,EAAE,CAAC,CAAC;IAChF,CAAC;IAAC,MAAM,CAAC;QACP,gDAAgD;IAClD,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -45,6 +45,19 @@ export interface JinaPluginConfig {
|
|
|
45
45
|
apiKey?: string;
|
|
46
46
|
router?: RouterPluginConfig;
|
|
47
47
|
pgvectorReranker?: PgvectorRerankerPluginConfig;
|
|
48
|
+
/**
|
|
49
|
+
* Soft RPM budget for ALL outbound Jina calls (router + reranker
|
|
50
|
+
* combined). When the sliding 60-second window exceeds this number,
|
|
51
|
+
* a `jina_rpm_exceeded` event is emitted (at most once per window)
|
|
52
|
+
* and a warning is logged. **The call is NEVER blocked** — the
|
|
53
|
+
* existing 429 cooldown breaker is the hard backstop.
|
|
54
|
+
*
|
|
55
|
+
* Default: 60. Set well below the Jina free-tier ceiling (100 RPM)
|
|
56
|
+
* to leave headroom for a shared key (e.g. plugin + Hindsight).
|
|
57
|
+
*
|
|
58
|
+
* @since 3.2.4
|
|
59
|
+
*/
|
|
60
|
+
rpmBudget?: number;
|
|
48
61
|
}
|
|
49
62
|
export interface RouterPluginConfig {
|
|
50
63
|
enabled?: boolean;
|
|
@@ -69,6 +82,25 @@ export interface PgvectorRerankerPluginConfig {
|
|
|
69
82
|
model?: RerankerModel;
|
|
70
83
|
/** Cap on results returned post-rerank. Default: `5`. */
|
|
71
84
|
topN?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Maximum number of candidate documents submitted to Jina per call.
|
|
87
|
+
* Pgvector recall is typically broad (20-50 hits) but only the top
|
|
88
|
+
* 10-15 are worth reranking. Trimming the tail saves Jina tokens
|
|
89
|
+
* linearly. Default: `20`. Set to `0` to disable the cap.
|
|
90
|
+
*
|
|
91
|
+
* @since 3.2.4
|
|
92
|
+
*/
|
|
93
|
+
candidatePoolMax?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Per-candidate text length cap (characters) before submission to
|
|
96
|
+
* Jina. The first ~2000 chars carry most of the relevance signal;
|
|
97
|
+
* longer chunks (transcripts, books) waste tokens on context the
|
|
98
|
+
* cross-encoder gets little additional signal from. Default: `2000`.
|
|
99
|
+
* Set to `0` to disable the truncation.
|
|
100
|
+
*
|
|
101
|
+
* @since 3.2.4
|
|
102
|
+
*/
|
|
103
|
+
maxCharsPerDoc?: number;
|
|
72
104
|
}
|
|
73
105
|
export type LightRAGQueryMode = "naive" | "local" | "global" | "hybrid";
|
|
74
106
|
/**
|
|
@@ -90,6 +122,13 @@ export interface ResolvedKnowledgeConfig {
|
|
|
90
122
|
lightragMaxChars: number;
|
|
91
123
|
lightragEnabled: boolean;
|
|
92
124
|
jinaApiKey: string;
|
|
125
|
+
/**
|
|
126
|
+
* Soft RPM budget for ALL outbound Jina calls. Default: 60.
|
|
127
|
+
* `0` disables the monitor entirely.
|
|
128
|
+
*
|
|
129
|
+
* @since 3.2.4
|
|
130
|
+
*/
|
|
131
|
+
jinaRpmBudget: number;
|
|
93
132
|
routerEnabled: boolean;
|
|
94
133
|
routerMode: "heuristic" | "jina-classifier";
|
|
95
134
|
routerClassifierId: string;
|
|
@@ -102,6 +141,20 @@ export interface ResolvedKnowledgeConfig {
|
|
|
102
141
|
pgvectorRerankerEnabled: boolean;
|
|
103
142
|
pgvectorRerankerModel: RerankerModel;
|
|
104
143
|
pgvectorRerankerTopN: number;
|
|
144
|
+
/**
|
|
145
|
+
* Cap on the number of candidates submitted to Jina /v1/rerank. `0`
|
|
146
|
+
* disables the cap (legacy v3.2.3 behavior). Default: `20`.
|
|
147
|
+
*
|
|
148
|
+
* @since 3.2.4
|
|
149
|
+
*/
|
|
150
|
+
pgvectorRerankerCandidatePoolMax: number;
|
|
151
|
+
/**
|
|
152
|
+
* Per-candidate text truncation length in characters. `0` disables
|
|
153
|
+
* truncation. Default: `2000`.
|
|
154
|
+
*
|
|
155
|
+
* @since 3.2.4
|
|
156
|
+
*/
|
|
157
|
+
pgvectorRerankerMaxCharsPerDoc: number;
|
|
105
158
|
}
|
|
106
159
|
/**
|
|
107
160
|
* One search hit from the PostgreSQL `knowledge_vectors` table, after score
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "openclaw-knowledge",
|
|
3
3
|
"name": "Knowledge Base",
|
|
4
4
|
"description": "Multi-source knowledge search (pgvector + LightRAG) with optional Jina-powered router & reranker — injects relevant documents and knowledge graph context before each turn via the before_prompt_build hook",
|
|
5
|
-
"version": "3.2.
|
|
5
|
+
"version": "3.2.4",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true
|
|
8
8
|
},
|
|
@@ -86,6 +86,13 @@
|
|
|
86
86
|
"type": "string",
|
|
87
87
|
"description": "Jina API key shared by router and reranker. Required when router.mode=jina-classifier or pgvectorReranker.enabled. Supports ${ENV_VAR} substitution."
|
|
88
88
|
},
|
|
89
|
+
"rpmBudget": {
|
|
90
|
+
"type": "number",
|
|
91
|
+
"minimum": 0,
|
|
92
|
+
"maximum": 1000,
|
|
93
|
+
"default": 60,
|
|
94
|
+
"description": "Soft RPM budget for ALL outbound Jina calls (router + reranker). When the sliding 60-second window exceeds this number, a jina_rpm_exceeded event is emitted and a warning is logged. The call is NEVER blocked — the existing 429 cooldown is the hard backstop. Default 60 leaves headroom below the Jina free tier ceiling (100 RPM). Set to 0 to disable the monitor."
|
|
95
|
+
},
|
|
89
96
|
"router": {
|
|
90
97
|
"type": "object",
|
|
91
98
|
"additionalProperties": false,
|
|
@@ -136,6 +143,20 @@
|
|
|
136
143
|
"maximum": 100,
|
|
137
144
|
"default": 5,
|
|
138
145
|
"description": "Max number of results returned after rerank. Recommendation: keep topK ≥ topN × 2 so the cross-encoder has room to re-order."
|
|
146
|
+
},
|
|
147
|
+
"candidatePoolMax": {
|
|
148
|
+
"type": "number",
|
|
149
|
+
"minimum": 0,
|
|
150
|
+
"maximum": 100,
|
|
151
|
+
"default": 20,
|
|
152
|
+
"description": "Maximum number of cosine-ranked candidates submitted to Jina /v1/rerank per call. Trims Jina token spend on noisy recall. Set to 0 to disable the cap (legacy v3.2.3 behavior)."
|
|
153
|
+
},
|
|
154
|
+
"maxCharsPerDoc": {
|
|
155
|
+
"type": "number",
|
|
156
|
+
"minimum": 0,
|
|
157
|
+
"maximum": 20000,
|
|
158
|
+
"default": 2000,
|
|
159
|
+
"description": "Per-candidate text truncation length in characters before submission to Jina. The first ~2000 chars typically carry most of the relevance signal. Set to 0 to disable the truncation."
|
|
139
160
|
}
|
|
140
161
|
}
|
|
141
162
|
}
|
|
@@ -252,6 +273,21 @@
|
|
|
252
273
|
"label": "Reranker top-N",
|
|
253
274
|
"advanced": true,
|
|
254
275
|
"help": "Max results returned after rerank. Keep topK ≥ topN × 2."
|
|
276
|
+
},
|
|
277
|
+
"jina.pgvectorReranker.candidatePoolMax": {
|
|
278
|
+
"label": "Reranker candidate-pool cap",
|
|
279
|
+
"advanced": true,
|
|
280
|
+
"help": "Max candidates submitted to Jina per rerank call. Default 20. Set to 0 to disable the cap."
|
|
281
|
+
},
|
|
282
|
+
"jina.pgvectorReranker.maxCharsPerDoc": {
|
|
283
|
+
"label": "Reranker chars-per-doc cap",
|
|
284
|
+
"advanced": true,
|
|
285
|
+
"help": "Per-candidate text truncation before sending to Jina. Default 2000 chars. Set to 0 to disable truncation."
|
|
286
|
+
},
|
|
287
|
+
"jina.rpmBudget": {
|
|
288
|
+
"label": "Jina RPM budget (soft)",
|
|
289
|
+
"advanced": true,
|
|
290
|
+
"help": "Soft alert threshold on outbound Jina calls per minute. Default 60. Never blocks — only logs and emits jina_rpm_exceeded events. Set to 0 to disable."
|
|
255
291
|
}
|
|
256
292
|
}
|
|
257
293
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lacneu/openclaw-knowledge",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Multi-source knowledge plugin for OpenClaw — pgvector + LightRAG injection with optional Jina-powered router & reranker, via before_prompt_build hook",
|
|
6
6
|
"license": "MIT",
|