metainsight-context-engine 0.0.1
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/BOOTSTRAP.md +341 -0
- package/README.md +230 -0
- package/dist/cos-bootstrap.d.ts +221 -0
- package/dist/cos-bootstrap.d.ts.map +1 -0
- package/dist/cos-bootstrap.js +598 -0
- package/dist/cos-bootstrap.js.map +1 -0
- package/dist/cos-operations.d.ts +219 -0
- package/dist/cos-operations.d.ts.map +1 -0
- package/dist/cos-operations.js +583 -0
- package/dist/cos-operations.js.map +1 -0
- package/dist/engine.d.ts +101 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +157 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +993 -0
- package/dist/index.js.map +1 -0
- package/dist/local-memory-sync.d.ts +204 -0
- package/dist/local-memory-sync.d.ts.map +1 -0
- package/dist/local-memory-sync.js +1126 -0
- package/dist/local-memory-sync.js.map +1 -0
- package/openclaw.plugin.json +225 -0
- package/package.json +78 -0
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud Context Engine
|
|
3
|
+
*
|
|
4
|
+
* A lightweight ContextEngine implementation whose primary responsibilities are:
|
|
5
|
+
* 1. **Bootstrap** — Eagerly initialize COS and trigger initial local memory sync.
|
|
6
|
+
* 2. **Local Memory Sync** — Periodically sync local memory files (MEMORY.md,
|
|
7
|
+
* daily logs, config) to cloud storage via `afterTurn`.
|
|
8
|
+
*
|
|
9
|
+
* All other ContextEngine lifecycle methods are no-ops / pass-throughs:
|
|
10
|
+
* - `assemble` — pass-through (runtime handles history via `limitHistoryTurns`,
|
|
11
|
+
* memory recall is handled by `before_prompt_build` hook in index.ts).
|
|
12
|
+
* - `compact` — no-op (owns compaction flag to prevent legacy compactor).
|
|
13
|
+
* - `ingest` / `ingestBatch` — no-ops.
|
|
14
|
+
*
|
|
15
|
+
* By setting `ownsCompaction: true`, the runtime will bypass the legacy
|
|
16
|
+
* `compactEmbeddedPiSessionDirect()` and delegate entirely to our `compact()`.
|
|
17
|
+
*
|
|
18
|
+
* The engine receives a `clientFactory` function that returns a `CosOperations`
|
|
19
|
+
* instance asynchronously — this allows lazy COS bootstrap (bucket/dataset/binding
|
|
20
|
+
* initialization happens on first use, not at plugin registration time).
|
|
21
|
+
*/
|
|
22
|
+
import type { AgentMessage } from '@mariozechner/pi-agent-core';
|
|
23
|
+
import type { AssembleResult, BootstrapResult, CompactResult, ContextEngine, ContextEngineInfo, ContextEngineRuntimeContext, IngestBatchResult, IngestResult } from 'openclaw/plugin-sdk/core';
|
|
24
|
+
import type { CosOperations } from './cos-operations.js';
|
|
25
|
+
import { type LocalMemorySyncConfig } from './local-memory-sync.js';
|
|
26
|
+
export interface CloudEngineConfig {
|
|
27
|
+
localMemorySync: LocalMemorySyncConfig;
|
|
28
|
+
/** When false, local memory files (MEMORY.md / daily logs) are NOT synced to cloud. Default: true */
|
|
29
|
+
localMemorySyncEnabled: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface Logger {
|
|
32
|
+
info: (...args: unknown[]) => void;
|
|
33
|
+
warn: (...args: unknown[]) => void;
|
|
34
|
+
}
|
|
35
|
+
export declare class CloudContextEngine implements ContextEngine {
|
|
36
|
+
readonly info: ContextEngineInfo;
|
|
37
|
+
private readonly clientFactory;
|
|
38
|
+
private cachedClient;
|
|
39
|
+
private readonly config;
|
|
40
|
+
private readonly logger;
|
|
41
|
+
/** Counter for incremental local memory sync (every N turns). */
|
|
42
|
+
private turnsSinceLastSync;
|
|
43
|
+
constructor(clientFactory: () => Promise<CosOperations>, config: CloudEngineConfig, logger: Logger);
|
|
44
|
+
/**
|
|
45
|
+
* Lazily initialize and cache the CosOperations instance (triggers COS bootstrap on first call).
|
|
46
|
+
*/
|
|
47
|
+
private getClient;
|
|
48
|
+
bootstrap(params: {
|
|
49
|
+
sessionId: string;
|
|
50
|
+
sessionKey?: string;
|
|
51
|
+
sessionFile: string;
|
|
52
|
+
}): Promise<BootstrapResult>;
|
|
53
|
+
ingest(_params: {
|
|
54
|
+
sessionId: string;
|
|
55
|
+
sessionKey?: string;
|
|
56
|
+
message: AgentMessage;
|
|
57
|
+
isHeartbeat?: boolean;
|
|
58
|
+
}): Promise<IngestResult>;
|
|
59
|
+
ingestBatch(_params: {
|
|
60
|
+
sessionId: string;
|
|
61
|
+
sessionKey?: string;
|
|
62
|
+
messages: AgentMessage[];
|
|
63
|
+
isHeartbeat?: boolean;
|
|
64
|
+
}): Promise<IngestBatchResult>;
|
|
65
|
+
assemble(params: {
|
|
66
|
+
sessionId: string;
|
|
67
|
+
sessionKey?: string;
|
|
68
|
+
messages: AgentMessage[];
|
|
69
|
+
tokenBudget?: number;
|
|
70
|
+
}): Promise<AssembleResult>;
|
|
71
|
+
compact(params: {
|
|
72
|
+
sessionId: string;
|
|
73
|
+
sessionKey?: string;
|
|
74
|
+
sessionFile: string;
|
|
75
|
+
tokenBudget?: number;
|
|
76
|
+
force?: boolean;
|
|
77
|
+
currentTokenCount?: number;
|
|
78
|
+
compactionTarget?: 'budget' | 'threshold';
|
|
79
|
+
customInstructions?: string;
|
|
80
|
+
runtimeContext?: ContextEngineRuntimeContext;
|
|
81
|
+
}): Promise<CompactResult>;
|
|
82
|
+
afterTurn(params: {
|
|
83
|
+
sessionId: string;
|
|
84
|
+
sessionKey?: string;
|
|
85
|
+
sessionFile: string;
|
|
86
|
+
messages: AgentMessage[];
|
|
87
|
+
prePromptMessageCount: number;
|
|
88
|
+
autoCompactionSummary?: string;
|
|
89
|
+
isHeartbeat?: boolean;
|
|
90
|
+
tokenBudget?: number;
|
|
91
|
+
runtimeContext?: ContextEngineRuntimeContext;
|
|
92
|
+
}): Promise<void>;
|
|
93
|
+
dispose(): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Run local memory sync in the background (non-blocking).
|
|
96
|
+
* Uploads MEMORY.md, daily logs, and config to cloud storage.
|
|
97
|
+
*/
|
|
98
|
+
private runLocalMemorySync;
|
|
99
|
+
}
|
|
100
|
+
export {};
|
|
101
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,2BAA2B,EAC3B,iBAAiB,EACjB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAM5F,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,qBAAqB,CAAC;IACvC,qGAAqG;IACrG,sBAAsB,EAAE,OAAO,CAAC;CACjC;AAMD,UAAU,MAAM;IACd,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACnC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACpC;AAaD,qBAAa,kBAAmB,YAAW,aAAa;IACtD,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAK9B;IAEF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA+B;IAC7D,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,iEAAiE;IACjE,OAAO,CAAC,kBAAkB,CAAK;gBAEnB,aAAa,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,iBAAiB,EA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AAC;IAgBpB,SAAS,CAAC,MAAM,EAAE;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,YAAY,EAAE,CAAC;QACzB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,2BAA2B,CAAC;KAC9C,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBX,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAS9B;;;OAGG;YACW,kBAAkB;CAoBjC"}
|
package/dist/engine.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud Context Engine
|
|
3
|
+
*
|
|
4
|
+
* A lightweight ContextEngine implementation whose primary responsibilities are:
|
|
5
|
+
* 1. **Bootstrap** — Eagerly initialize COS and trigger initial local memory sync.
|
|
6
|
+
* 2. **Local Memory Sync** — Periodically sync local memory files (MEMORY.md,
|
|
7
|
+
* daily logs, config) to cloud storage via `afterTurn`.
|
|
8
|
+
*
|
|
9
|
+
* All other ContextEngine lifecycle methods are no-ops / pass-throughs:
|
|
10
|
+
* - `assemble` — pass-through (runtime handles history via `limitHistoryTurns`,
|
|
11
|
+
* memory recall is handled by `before_prompt_build` hook in index.ts).
|
|
12
|
+
* - `compact` — no-op (owns compaction flag to prevent legacy compactor).
|
|
13
|
+
* - `ingest` / `ingestBatch` — no-ops.
|
|
14
|
+
*
|
|
15
|
+
* By setting `ownsCompaction: true`, the runtime will bypass the legacy
|
|
16
|
+
* `compactEmbeddedPiSessionDirect()` and delegate entirely to our `compact()`.
|
|
17
|
+
*
|
|
18
|
+
* The engine receives a `clientFactory` function that returns a `CosOperations`
|
|
19
|
+
* instance asynchronously — this allows lazy COS bootstrap (bucket/dataset/binding
|
|
20
|
+
* initialization happens on first use, not at plugin registration time).
|
|
21
|
+
*/
|
|
22
|
+
import { syncLocalMemoryToCloud } from './local-memory-sync.js';
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Constants
|
|
25
|
+
// ============================================================================
|
|
26
|
+
/** Run local memory sync every N turns (to pick up file changes). */
|
|
27
|
+
const LOCAL_MEMORY_SYNC_INTERVAL = 5;
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// Implementation
|
|
30
|
+
// ============================================================================
|
|
31
|
+
export class CloudContextEngine {
|
|
32
|
+
info = {
|
|
33
|
+
id: 'metainsight-context-engine',
|
|
34
|
+
name: 'MetaInsight Context Engine',
|
|
35
|
+
version: '1.0.0',
|
|
36
|
+
ownsCompaction: true,
|
|
37
|
+
};
|
|
38
|
+
clientFactory;
|
|
39
|
+
cachedClient = null;
|
|
40
|
+
config;
|
|
41
|
+
logger;
|
|
42
|
+
/** Counter for incremental local memory sync (every N turns). */
|
|
43
|
+
turnsSinceLastSync = 0;
|
|
44
|
+
constructor(clientFactory, config, logger) {
|
|
45
|
+
this.clientFactory = clientFactory;
|
|
46
|
+
this.config = config;
|
|
47
|
+
this.logger = logger;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Lazily initialize and cache the CosOperations instance (triggers COS bootstrap on first call).
|
|
51
|
+
*/
|
|
52
|
+
async getClient() {
|
|
53
|
+
if (!this.cachedClient) {
|
|
54
|
+
this.cachedClient = await this.clientFactory();
|
|
55
|
+
}
|
|
56
|
+
return this.cachedClient;
|
|
57
|
+
}
|
|
58
|
+
// ==========================================================================
|
|
59
|
+
// bootstrap — session initialization
|
|
60
|
+
// ==========================================================================
|
|
61
|
+
async bootstrap(params) {
|
|
62
|
+
this.logger.info(`cloud-engine: bootstrap session=${params.sessionId}`);
|
|
63
|
+
// Eagerly trigger COS bootstrap so errors surface early
|
|
64
|
+
try {
|
|
65
|
+
await this.getClient();
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
this.logger.warn(`cloud-engine: COS bootstrap failed during session init: ${String(err)}`);
|
|
69
|
+
}
|
|
70
|
+
// Sync local memory files to cloud (non-blocking background task)
|
|
71
|
+
if (this.config.localMemorySyncEnabled && this.config.localMemorySync.enabled) {
|
|
72
|
+
void this.runLocalMemorySync(params.sessionFile);
|
|
73
|
+
}
|
|
74
|
+
return { bootstrapped: true };
|
|
75
|
+
}
|
|
76
|
+
// ==========================================================================
|
|
77
|
+
// ingest — no-op (conversation memory upload disabled)
|
|
78
|
+
// ==========================================================================
|
|
79
|
+
async ingest(_params) {
|
|
80
|
+
return { ingested: false };
|
|
81
|
+
}
|
|
82
|
+
// ==========================================================================
|
|
83
|
+
// ingestBatch — no-op (conversation memory upload disabled)
|
|
84
|
+
// ==========================================================================
|
|
85
|
+
async ingestBatch(_params) {
|
|
86
|
+
return { ingestedCount: 0 };
|
|
87
|
+
}
|
|
88
|
+
// ==========================================================================
|
|
89
|
+
// assemble — pass-through (memory recall handled by before_prompt_build hook)
|
|
90
|
+
// ==========================================================================
|
|
91
|
+
async assemble(params) {
|
|
92
|
+
// Pass-through: runtime handles history limiting via limitHistoryTurns(),
|
|
93
|
+
// and memory recall is handled by the before_prompt_build hook in index.ts
|
|
94
|
+
// which has full control over the system prompt.
|
|
95
|
+
return {
|
|
96
|
+
messages: params.messages,
|
|
97
|
+
estimatedTokens: 0,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// ==========================================================================
|
|
101
|
+
// compact — no-op (owns compaction to prevent legacy compactor from running)
|
|
102
|
+
// ==========================================================================
|
|
103
|
+
async compact(params) {
|
|
104
|
+
return {
|
|
105
|
+
ok: true,
|
|
106
|
+
compacted: true,
|
|
107
|
+
reason: 'cloud-engine: compaction handled by runtime limitHistoryTurns()',
|
|
108
|
+
result: {
|
|
109
|
+
tokensBefore: params.currentTokenCount ?? 0,
|
|
110
|
+
tokensAfter: 0,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// ==========================================================================
|
|
115
|
+
// afterTurn — periodic local memory sync only
|
|
116
|
+
// ==========================================================================
|
|
117
|
+
async afterTurn(params) {
|
|
118
|
+
if (params.isHeartbeat) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// Run local memory sync periodically (every N turns) to pick up file changes
|
|
122
|
+
if (this.config.localMemorySyncEnabled && this.config.localMemorySync.enabled) {
|
|
123
|
+
this.turnsSinceLastSync += 1;
|
|
124
|
+
if (this.turnsSinceLastSync >= LOCAL_MEMORY_SYNC_INTERVAL) {
|
|
125
|
+
this.turnsSinceLastSync = 0;
|
|
126
|
+
void this.runLocalMemorySync(params.sessionFile);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// ==========================================================================
|
|
131
|
+
// dispose
|
|
132
|
+
// ==========================================================================
|
|
133
|
+
async dispose() {
|
|
134
|
+
this.cachedClient = null;
|
|
135
|
+
this.logger.info('cloud-engine: disposed');
|
|
136
|
+
}
|
|
137
|
+
// ==========================================================================
|
|
138
|
+
// Private helpers
|
|
139
|
+
// ==========================================================================
|
|
140
|
+
/**
|
|
141
|
+
* Run local memory sync in the background (non-blocking).
|
|
142
|
+
* Uploads MEMORY.md, daily logs, and config to cloud storage.
|
|
143
|
+
*/
|
|
144
|
+
async runLocalMemorySync(sessionFile) {
|
|
145
|
+
try {
|
|
146
|
+
const client = await this.getClient();
|
|
147
|
+
const result = await syncLocalMemoryToCloud(client, sessionFile, this.config.localMemorySync, this.logger);
|
|
148
|
+
if (result.uploaded > 0) {
|
|
149
|
+
this.logger.info(`cloud-engine: local memory sync — uploaded=${result.uploaded}, skipped=${result.skipped}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
this.logger.warn(`cloud-engine: local memory sync failed: ${String(err)}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=engine.js.map
|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AAI,CAAC,MAAM,CAAC,IAAI,CAAC,2CAA2C,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;CAEF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MetaInsight Context Engine — Plugin Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Registers:
|
|
5
|
+
* 1. A ContextEngine implementation (replaces "legacy" engine)
|
|
6
|
+
* 2. `cloud_memory_search` tool — manual memory search from cloud
|
|
7
|
+
* 3. `llm_input` hook — cache the full system prompt per session
|
|
8
|
+
* 4. `before_prompt_build` hook — cloud memory injection (layer-based)
|
|
9
|
+
* + image/document context injection (prependContext, near user message)
|
|
10
|
+
*
|
|
11
|
+
* On startup, the plugin runs a bootstrap sequence that ensures all COS/CI
|
|
12
|
+
* infrastructure is ready (bucket exists, dataset created, binding established).
|
|
13
|
+
*
|
|
14
|
+
* Configuration (in ~/.openclaw/openclaw.json):
|
|
15
|
+
* {
|
|
16
|
+
* "plugins": {
|
|
17
|
+
* "slots": { "contextEngine": "metainsight-context-engine" },
|
|
18
|
+
* "entries": {
|
|
19
|
+
* "metainsight-context-engine": {
|
|
20
|
+
* "enabled": true,
|
|
21
|
+
* "config": {
|
|
22
|
+
* "secretId": "${COS_SECRET_ID}",
|
|
23
|
+
* "secretKey": "${COS_SECRET_KEY}",
|
|
24
|
+
* "bucket": "openclaw-metainsight",
|
|
25
|
+
* "region": "ap-beijing",
|
|
26
|
+
* "datasetName": "openclaw-metainsight-doc"
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
*/
|
|
33
|
+
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk/core';
|
|
34
|
+
declare const plugin: {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
kind: "context-engine";
|
|
39
|
+
register(api: OpenClawPluginApi): void;
|
|
40
|
+
};
|
|
41
|
+
export default plugin;
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAmalE,QAAA,MAAM,MAAM;;;;;kBAMI,iBAAiB;CAs4BhC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|