@persistio/openclaw-plugin 0.1.7 → 0.2.0
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/README.md +86 -53
- package/dist/capture.d.ts +17 -0
- package/dist/capture.js +112 -0
- package/dist/client.d.ts +35 -51
- package/dist/client.js +45 -70
- package/dist/config.d.ts +29 -0
- package/dist/config.js +86 -0
- package/dist/index.js +303 -623
- package/dist/memory-format.d.ts +8 -0
- package/dist/memory-format.js +121 -0
- package/openclaw.plugin.json +69 -95
- package/package.json +10 -11
- package/src/capture.ts +132 -0
- package/src/client.ts +72 -111
- package/src/config.ts +125 -0
- package/src/index.ts +308 -718
- package/src/memory-format.ts +127 -0
- package/dist/ingest-policy.d.ts +0 -48
- package/dist/ingest-policy.js +0 -380
- package/src/ingest-policy.ts +0 -508
package/dist/config.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const DEFAULT_CONFIG = {
|
|
2
|
+
baseURL: '',
|
|
3
|
+
apiKey: '',
|
|
4
|
+
autoRecall: true,
|
|
5
|
+
autoCapture: true,
|
|
6
|
+
recall: {
|
|
7
|
+
timeoutMs: 1200,
|
|
8
|
+
maxResults: 4,
|
|
9
|
+
tokenBudget: 400,
|
|
10
|
+
includePending: false,
|
|
11
|
+
includeRelated: false,
|
|
12
|
+
queryMaxChars: 1200,
|
|
13
|
+
},
|
|
14
|
+
capture: {
|
|
15
|
+
timeoutMs: 10000,
|
|
16
|
+
maxCharsPerTurn: 6000,
|
|
17
|
+
maxCharsPerMessage: 3000,
|
|
18
|
+
maxChunksPerTurn: 4,
|
|
19
|
+
maxChunkChars: 2000,
|
|
20
|
+
roles: {
|
|
21
|
+
user: 'enabled',
|
|
22
|
+
assistant: 'bounded',
|
|
23
|
+
tool: 'disabled',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
function readObject(value) {
|
|
28
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
29
|
+
? value
|
|
30
|
+
: {};
|
|
31
|
+
}
|
|
32
|
+
function readString(value, fallback = '') {
|
|
33
|
+
return typeof value === 'string' ? value : fallback;
|
|
34
|
+
}
|
|
35
|
+
function readBoolean(value, fallback) {
|
|
36
|
+
return typeof value === 'boolean' ? value : fallback;
|
|
37
|
+
}
|
|
38
|
+
function readPositiveInteger(value, fallback, min = 1) {
|
|
39
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= min
|
|
40
|
+
? Math.floor(value)
|
|
41
|
+
: fallback;
|
|
42
|
+
}
|
|
43
|
+
function readSimilarity(value) {
|
|
44
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 1
|
|
45
|
+
? value
|
|
46
|
+
: undefined;
|
|
47
|
+
}
|
|
48
|
+
function readEnabledDisabled(value, fallback) {
|
|
49
|
+
return value === 'enabled' || value === 'disabled' ? value : fallback;
|
|
50
|
+
}
|
|
51
|
+
function readAssistantRole(value, fallback) {
|
|
52
|
+
return value === 'enabled' || value === 'bounded' || value === 'disabled' ? value : fallback;
|
|
53
|
+
}
|
|
54
|
+
export function resolveConfig(raw) {
|
|
55
|
+
const input = readObject(raw);
|
|
56
|
+
const recall = readObject(input['recall']);
|
|
57
|
+
const capture = readObject(input['capture']);
|
|
58
|
+
const roles = readObject(capture['roles']);
|
|
59
|
+
return {
|
|
60
|
+
baseURL: readString(input['baseURL'], DEFAULT_CONFIG.baseURL),
|
|
61
|
+
apiKey: readString(input['apiKey'], DEFAULT_CONFIG.apiKey),
|
|
62
|
+
autoRecall: readBoolean(input['autoRecall'], DEFAULT_CONFIG.autoRecall),
|
|
63
|
+
autoCapture: readBoolean(input['autoCapture'], DEFAULT_CONFIG.autoCapture),
|
|
64
|
+
recall: {
|
|
65
|
+
timeoutMs: readPositiveInteger(recall['timeoutMs'], DEFAULT_CONFIG.recall.timeoutMs),
|
|
66
|
+
maxResults: readPositiveInteger(recall['maxResults'], DEFAULT_CONFIG.recall.maxResults),
|
|
67
|
+
tokenBudget: readPositiveInteger(recall['tokenBudget'], DEFAULT_CONFIG.recall.tokenBudget),
|
|
68
|
+
minSimilarity: readSimilarity(recall['minSimilarity']),
|
|
69
|
+
includePending: readBoolean(recall['includePending'], DEFAULT_CONFIG.recall.includePending),
|
|
70
|
+
includeRelated: readBoolean(recall['includeRelated'], DEFAULT_CONFIG.recall.includeRelated),
|
|
71
|
+
queryMaxChars: readPositiveInteger(recall['queryMaxChars'], DEFAULT_CONFIG.recall.queryMaxChars, 100),
|
|
72
|
+
},
|
|
73
|
+
capture: {
|
|
74
|
+
timeoutMs: readPositiveInteger(capture['timeoutMs'], DEFAULT_CONFIG.capture.timeoutMs),
|
|
75
|
+
maxCharsPerTurn: readPositiveInteger(capture['maxCharsPerTurn'], DEFAULT_CONFIG.capture.maxCharsPerTurn),
|
|
76
|
+
maxCharsPerMessage: readPositiveInteger(capture['maxCharsPerMessage'], DEFAULT_CONFIG.capture.maxCharsPerMessage),
|
|
77
|
+
maxChunksPerTurn: readPositiveInteger(capture['maxChunksPerTurn'], DEFAULT_CONFIG.capture.maxChunksPerTurn),
|
|
78
|
+
maxChunkChars: readPositiveInteger(capture['maxChunkChars'], DEFAULT_CONFIG.capture.maxChunkChars, 256),
|
|
79
|
+
roles: {
|
|
80
|
+
user: readEnabledDisabled(roles['user'], DEFAULT_CONFIG.capture.roles.user),
|
|
81
|
+
assistant: readAssistantRole(roles['assistant'], DEFAULT_CONFIG.capture.roles.assistant),
|
|
82
|
+
tool: readEnabledDisabled(roles['tool'], DEFAULT_CONFIG.capture.roles.tool),
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|