@persistio/openclaw-plugin 0.1.8 → 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.
@@ -0,0 +1,29 @@
1
+ export type PersistioCaptureRoleStatus = 'enabled' | 'bounded' | 'disabled';
2
+ export interface PersistioV2Config {
3
+ baseURL: string;
4
+ apiKey: string;
5
+ autoRecall: boolean;
6
+ autoCapture: boolean;
7
+ recall: {
8
+ timeoutMs: number;
9
+ maxResults: number;
10
+ tokenBudget: number;
11
+ minSimilarity?: number;
12
+ includePending: boolean;
13
+ includeRelated: boolean;
14
+ queryMaxChars: number;
15
+ };
16
+ capture: {
17
+ timeoutMs: number;
18
+ maxCharsPerTurn: number;
19
+ maxCharsPerMessage: number;
20
+ maxChunksPerTurn: number;
21
+ maxChunkChars: number;
22
+ roles: {
23
+ user: 'enabled' | 'disabled';
24
+ assistant: PersistioCaptureRoleStatus;
25
+ tool: 'enabled' | 'disabled';
26
+ };
27
+ };
28
+ }
29
+ export declare function resolveConfig(raw: unknown): PersistioV2Config;
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
+ }