openclaw-engram 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/dist/availability.d.ts +34 -0
- package/dist/availability.d.ts.map +1 -0
- package/dist/availability.js +70 -0
- package/dist/availability.js.map +1 -0
- package/dist/client.d.ts +147 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +199 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/memory.d.ts +11 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +49 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/remember.d.ts +15 -0
- package/dist/commands/remember.d.ts.map +1 -0
- package/dist/commands/remember.js +61 -0
- package/dist/commands/remember.js.map +1 -0
- package/dist/config.d.ts +73 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +81 -0
- package/dist/config.js.map +1 -0
- package/dist/context/formatter.d.ts +33 -0
- package/dist/context/formatter.d.ts.map +1 -0
- package/dist/context/formatter.js +193 -0
- package/dist/context/formatter.js.map +1 -0
- package/dist/hooks/after-tool-call.d.ts +19 -0
- package/dist/hooks/after-tool-call.d.ts.map +1 -0
- package/dist/hooks/after-tool-call.js +53 -0
- package/dist/hooks/after-tool-call.js.map +1 -0
- package/dist/hooks/before-compaction.d.ts +19 -0
- package/dist/hooks/before-compaction.d.ts.map +1 -0
- package/dist/hooks/before-compaction.js +60 -0
- package/dist/hooks/before-compaction.js.map +1 -0
- package/dist/hooks/before-prompt-build.d.ts +20 -0
- package/dist/hooks/before-prompt-build.d.ts.map +1 -0
- package/dist/hooks/before-prompt-build.js +76 -0
- package/dist/hooks/before-prompt-build.js.map +1 -0
- package/dist/hooks/session-end.d.ts +18 -0
- package/dist/hooks/session-end.d.ts.map +1 -0
- package/dist/hooks/session-end.js +57 -0
- package/dist/hooks/session-end.js.map +1 -0
- package/dist/hooks/session-start.d.ts +17 -0
- package/dist/hooks/session-start.d.ts.map +1 -0
- package/dist/hooks/session-start.js +77 -0
- package/dist/hooks/session-start.js.map +1 -0
- package/dist/identity.d.ts +36 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +106 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +208 -0
- package/dist/index.js.map +1 -0
- package/dist/services/file-watcher.d.ts +11 -0
- package/dist/services/file-watcher.d.ts.map +1 -0
- package/dist/services/file-watcher.js +139 -0
- package/dist/services/file-watcher.js.map +1 -0
- package/dist/tools/engram-decisions.d.ts +8 -0
- package/dist/tools/engram-decisions.d.ts.map +1 -0
- package/dist/tools/engram-decisions.js +70 -0
- package/dist/tools/engram-decisions.js.map +1 -0
- package/dist/tools/engram-remember.d.ts +9 -0
- package/dist/tools/engram-remember.d.ts.map +1 -0
- package/dist/tools/engram-remember.js +116 -0
- package/dist/tools/engram-remember.js.map +1 -0
- package/dist/tools/engram-search.d.ts +9 -0
- package/dist/tools/engram-search.d.ts.map +1 -0
- package/dist/tools/engram-search.js +62 -0
- package/dist/tools/engram-search.js.map +1 -0
- package/dist/tools/memory-forget.d.ts +10 -0
- package/dist/tools/memory-forget.d.ts.map +1 -0
- package/dist/tools/memory-forget.js +41 -0
- package/dist/tools/memory-forget.js.map +1 -0
- package/dist/tools/memory-get.d.ts +11 -0
- package/dist/tools/memory-get.d.ts.map +1 -0
- package/dist/tools/memory-get.js +86 -0
- package/dist/tools/memory-get.js.map +1 -0
- package/dist/tools/memory-migrate.d.ts +11 -0
- package/dist/tools/memory-migrate.d.ts.map +1 -0
- package/dist/tools/memory-migrate.js +180 -0
- package/dist/tools/memory-migrate.js.map +1 -0
- package/dist/types/openclaw.d.ts +212 -0
- package/dist/types/openclaw.d.ts.map +1 -0
- package/dist/types/openclaw.js +9 -0
- package/dist/types/openclaw.js.map +1 -0
- package/dist/utils/memory-files.d.ts +25 -0
- package/dist/utils/memory-files.d.ts.map +1 -0
- package/dist/utils/memory-files.js +187 -0
- package/dist/utils/memory-files.js.map +1 -0
- package/openclaw.plugin.json +86 -0
- package/package.json +45 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local type definitions matching the real OpenClaw Plugin SDK.
|
|
3
|
+
*
|
|
4
|
+
* These are locally defined since no SDK package is published.
|
|
5
|
+
* Shapes match openclaw/openclaw:src/plugins/types.ts (verified via Nia research).
|
|
6
|
+
*/
|
|
7
|
+
/** Logger provided by the SDK on the plugin API. */
|
|
8
|
+
export interface PluginLogger {
|
|
9
|
+
debug(message: string, ...args: unknown[]): void;
|
|
10
|
+
info(message: string, ...args: unknown[]): void;
|
|
11
|
+
warn(message: string, ...args: unknown[]): void;
|
|
12
|
+
error(message: string, ...args: unknown[]): void;
|
|
13
|
+
}
|
|
14
|
+
/** Runtime services exposed by the SDK. */
|
|
15
|
+
export interface PluginRuntime {
|
|
16
|
+
tools: {
|
|
17
|
+
createMemorySearchTool(): unknown;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** OpenClaw global config (opaque to plugins). */
|
|
21
|
+
export type OpenClawConfig = Record<string, unknown>;
|
|
22
|
+
/** JSON Schema for plugin config (static, declared in plugin definition). */
|
|
23
|
+
export type OpenClawPluginConfigSchema = Record<string, unknown>;
|
|
24
|
+
export interface OpenClawPluginApi {
|
|
25
|
+
/** Plugin ID. */
|
|
26
|
+
id: string;
|
|
27
|
+
/** Plugin display name. */
|
|
28
|
+
name: string;
|
|
29
|
+
/** OpenClaw global config. */
|
|
30
|
+
config: OpenClawConfig;
|
|
31
|
+
/** Plugin-specific config from the user's OpenClaw settings. */
|
|
32
|
+
pluginConfig?: Record<string, unknown>;
|
|
33
|
+
/** Runtime services. */
|
|
34
|
+
runtime: PluginRuntime;
|
|
35
|
+
/** Logger scoped to this plugin. */
|
|
36
|
+
logger: PluginLogger;
|
|
37
|
+
/** Register a tool or tool factory. */
|
|
38
|
+
registerTool(toolOrFactory: AnyAgentTool | AnyAgentTool[] | ToolFactory, opts?: {
|
|
39
|
+
names?: string[];
|
|
40
|
+
}): void;
|
|
41
|
+
/** Register a lifecycle hook handler (typed). */
|
|
42
|
+
on<K extends PluginHookName>(hookName: K, handler: PluginHookHandler<K>, opts?: {
|
|
43
|
+
priority?: number;
|
|
44
|
+
}): void;
|
|
45
|
+
/** Register a CLI extension. */
|
|
46
|
+
registerCli(registrar: (ctx: {
|
|
47
|
+
program: CliProgram;
|
|
48
|
+
}) => void, opts?: {
|
|
49
|
+
commands?: string[];
|
|
50
|
+
}): void;
|
|
51
|
+
/** Register a background service. */
|
|
52
|
+
registerService(service: OpenClawPluginService): void;
|
|
53
|
+
/** Register a slash command. */
|
|
54
|
+
registerCommand(command: OpenClawPluginCommandDefinition): void;
|
|
55
|
+
/** Resolve a workspace-relative path safely. */
|
|
56
|
+
resolvePath(input: string): string;
|
|
57
|
+
}
|
|
58
|
+
export interface OpenClawPluginDefinition {
|
|
59
|
+
/** Unique plugin identifier. */
|
|
60
|
+
id: string;
|
|
61
|
+
/** Optional display name. */
|
|
62
|
+
name?: string;
|
|
63
|
+
/** Human-readable description. */
|
|
64
|
+
description?: string;
|
|
65
|
+
/** Version string. */
|
|
66
|
+
version?: string;
|
|
67
|
+
/** Plugin kind — "memory" is an exclusive slot. */
|
|
68
|
+
kind?: 'memory' | 'context-engine';
|
|
69
|
+
/** JSON Schema for plugin config (declared statically). */
|
|
70
|
+
configSchema?: OpenClawPluginConfigSchema;
|
|
71
|
+
/**
|
|
72
|
+
* Called once when the plugin is loaded. Register all hooks, tools,
|
|
73
|
+
* commands, and services here.
|
|
74
|
+
*/
|
|
75
|
+
register?: (api: OpenClawPluginApi) => void | Promise<void>;
|
|
76
|
+
/** Optional activation phase (called after all plugins registered). */
|
|
77
|
+
activate?: (api: OpenClawPluginApi) => void | Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
/** A TSchema-compatible object (from @sinclair/typebox). */
|
|
80
|
+
export type TSchema = Record<string, unknown>;
|
|
81
|
+
export interface AnyAgentTool {
|
|
82
|
+
name: string;
|
|
83
|
+
label?: string;
|
|
84
|
+
description: string;
|
|
85
|
+
/** TypeBox Type.Object schema for tool parameters. */
|
|
86
|
+
parameters: TSchema;
|
|
87
|
+
/** Execute the tool. Returns a string result. */
|
|
88
|
+
execute(toolCallId: string, params: Record<string, unknown>): Promise<string>;
|
|
89
|
+
}
|
|
90
|
+
/** Tool factory: receives context, returns array of tools. */
|
|
91
|
+
export type ToolFactory = (ctx: OpenClawPluginToolContext) => AnyAgentTool[];
|
|
92
|
+
export interface OpenClawPluginToolContext {
|
|
93
|
+
config?: OpenClawConfig;
|
|
94
|
+
workspaceDir?: string;
|
|
95
|
+
agentDir?: string;
|
|
96
|
+
agentId?: string;
|
|
97
|
+
sessionKey?: string;
|
|
98
|
+
/** Per-conversation ID, regenerated on /new and /reset. */
|
|
99
|
+
sessionId?: string;
|
|
100
|
+
messageChannel?: string;
|
|
101
|
+
}
|
|
102
|
+
export type PluginHookName = 'before_model_resolve' | 'before_prompt_build' | 'before_agent_start' | 'llm_input' | 'llm_output' | 'agent_end' | 'before_compaction' | 'after_compaction' | 'before_reset' | 'message_received' | 'message_sending' | 'message_sent' | 'before_tool_call' | 'after_tool_call' | 'tool_result_persist' | 'before_message_write' | 'session_start' | 'session_end' | 'subagent_spawning' | 'subagent_delivery_target' | 'subagent_spawned' | 'subagent_ended' | 'gateway_start' | 'gateway_stop';
|
|
103
|
+
/** Base fields present in every hook event. */
|
|
104
|
+
export interface BaseHookEvent {
|
|
105
|
+
agentId?: string;
|
|
106
|
+
sessionId?: string;
|
|
107
|
+
sessionKey?: string;
|
|
108
|
+
workspaceDir?: string;
|
|
109
|
+
timestamp?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface SessionStartEvent extends BaseHookEvent {
|
|
112
|
+
initialPrompt?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface BeforePromptBuildEvent extends BaseHookEvent {
|
|
115
|
+
prompt?: string;
|
|
116
|
+
turnIndex?: number;
|
|
117
|
+
}
|
|
118
|
+
export interface AfterToolCallEvent extends BaseHookEvent {
|
|
119
|
+
toolName?: string;
|
|
120
|
+
toolInput?: unknown;
|
|
121
|
+
toolResult?: unknown;
|
|
122
|
+
success?: boolean;
|
|
123
|
+
error?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface BeforeCompactionEvent extends BaseHookEvent {
|
|
126
|
+
messages?: ConversationMessage[];
|
|
127
|
+
reason?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface SessionEndEvent extends BaseHookEvent {
|
|
130
|
+
messages?: ConversationMessage[];
|
|
131
|
+
reason?: string;
|
|
132
|
+
}
|
|
133
|
+
export interface ConversationMessage {
|
|
134
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
135
|
+
content: string;
|
|
136
|
+
}
|
|
137
|
+
export interface PromptBuildResult {
|
|
138
|
+
prependContext?: string;
|
|
139
|
+
appendSystemContext?: string;
|
|
140
|
+
}
|
|
141
|
+
export interface SessionStartResult {
|
|
142
|
+
appendSystemContext?: string;
|
|
143
|
+
}
|
|
144
|
+
export type HookResult = void | PromptBuildResult | SessionStartResult | undefined;
|
|
145
|
+
/** Map hook names to their event types (for hooks we use). */
|
|
146
|
+
export interface HookEventMap {
|
|
147
|
+
session_start: SessionStartEvent;
|
|
148
|
+
before_prompt_build: BeforePromptBuildEvent;
|
|
149
|
+
after_tool_call: AfterToolCallEvent;
|
|
150
|
+
before_compaction: BeforeCompactionEvent;
|
|
151
|
+
session_end: SessionEndEvent;
|
|
152
|
+
}
|
|
153
|
+
/** Generic hook handler type. */
|
|
154
|
+
export type PluginHookHandler<K extends PluginHookName> = K extends keyof HookEventMap ? (event: HookEventMap[K]) => HookResult | Promise<HookResult> : (event: BaseHookEvent) => HookResult | Promise<HookResult>;
|
|
155
|
+
export interface OpenClawPluginServiceContext {
|
|
156
|
+
logger: PluginLogger;
|
|
157
|
+
}
|
|
158
|
+
export interface OpenClawPluginService {
|
|
159
|
+
id: string;
|
|
160
|
+
start(ctx: OpenClawPluginServiceContext): Promise<void> | void;
|
|
161
|
+
stop(ctx: OpenClawPluginServiceContext): Promise<void> | void;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Context passed to plugin command handlers by the SDK.
|
|
165
|
+
* Commands are channel-facing (Telegram, Discord, etc.), not agent-facing.
|
|
166
|
+
*/
|
|
167
|
+
export interface PluginCommandContext {
|
|
168
|
+
senderId?: string;
|
|
169
|
+
channel: string;
|
|
170
|
+
channelId?: string;
|
|
171
|
+
isAuthorizedSender: boolean;
|
|
172
|
+
/** Raw command arguments after the command name (single string, not array). */
|
|
173
|
+
args?: string;
|
|
174
|
+
commandBody: string;
|
|
175
|
+
config: OpenClawConfig;
|
|
176
|
+
from?: string;
|
|
177
|
+
to?: string;
|
|
178
|
+
accountId?: string;
|
|
179
|
+
messageThreadId?: number;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Result returned by a plugin command handler.
|
|
183
|
+
* Must contain `text` field (not `output`).
|
|
184
|
+
*/
|
|
185
|
+
export interface PluginCommandResult {
|
|
186
|
+
text: string;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Handler function for plugin commands.
|
|
190
|
+
*/
|
|
191
|
+
export type PluginCommandHandler = (ctx: PluginCommandContext) => PluginCommandResult | Promise<PluginCommandResult>;
|
|
192
|
+
export interface OpenClawPluginCommandDefinition {
|
|
193
|
+
name: string;
|
|
194
|
+
description: string;
|
|
195
|
+
/** Whether this command accepts arguments. */
|
|
196
|
+
acceptsArgs?: boolean;
|
|
197
|
+
/** Whether only authorized senders can use this command (default: true). */
|
|
198
|
+
requireAuth?: boolean;
|
|
199
|
+
/** The handler function — SDK checks typeof handler === "function". */
|
|
200
|
+
handler: PluginCommandHandler;
|
|
201
|
+
}
|
|
202
|
+
export interface CliProgram {
|
|
203
|
+
command(name: string): CliCommand;
|
|
204
|
+
}
|
|
205
|
+
export interface CliCommand {
|
|
206
|
+
command(name: string): CliCommand;
|
|
207
|
+
description(desc: string): CliCommand;
|
|
208
|
+
argument(name: string, desc?: string): CliCommand;
|
|
209
|
+
option(flags: string, desc?: string, defaultValue?: unknown): CliCommand;
|
|
210
|
+
action(fn: (...args: unknown[]) => void | Promise<void>): CliCommand;
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=openclaw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclaw.d.ts","sourceRoot":"","sources":["../../src/types/openclaw.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAClD;AAED,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,sBAAsB,IAAI,OAAO,CAAC;KACnC,CAAC;CACH;AAED,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD,6EAA6E;AAC7E,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjE,MAAM,WAAW,iBAAiB;IAChC,iBAAiB;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,MAAM,EAAE,cAAc,CAAC;IACvB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAA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@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Local type definitions matching the real OpenClaw Plugin SDK.
|
|
4
|
+
*
|
|
5
|
+
* These are locally defined since no SDK package is published.
|
|
6
|
+
* Shapes match openclaw/openclaw:src/plugins/types.ts (verified via Nia research).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=openclaw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclaw.js","sourceRoot":"","sources":["../../src/types/openclaw.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared memory file utilities — used by memory-migrate tool and file-watcher service.
|
|
3
|
+
*
|
|
4
|
+
* Provides chunking, marker file I/O, file discovery, and safe file reading.
|
|
5
|
+
*/
|
|
6
|
+
export declare const MARKER_FILE = ".engram-migrated.json";
|
|
7
|
+
export declare const MAX_FILE_SIZE = 50000;
|
|
8
|
+
export interface MigrationMarker {
|
|
9
|
+
lastMigrated: string;
|
|
10
|
+
files: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
export interface MemoryChunk {
|
|
13
|
+
title: string;
|
|
14
|
+
content: string;
|
|
15
|
+
sourcePath: string;
|
|
16
|
+
type: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function splitIntoChunks(content: string, sourcePath: string): MemoryChunk[];
|
|
19
|
+
export declare function inferType(_sourcePath: string, content: string): string;
|
|
20
|
+
export declare function loadMarker(path: string): Promise<MigrationMarker | null>;
|
|
21
|
+
export declare function saveMarker(markerPath: string, marker: MigrationMarker): Promise<void>;
|
|
22
|
+
export declare function discoverMemoryFiles(workspaceDir: string): Promise<string[]>;
|
|
23
|
+
export declare function fileExists(path: string): Promise<boolean>;
|
|
24
|
+
export declare function safeReadFile(path: string): Promise<string | null>;
|
|
25
|
+
//# sourceMappingURL=memory-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-files.d.ts","sourceRoot":"","sources":["../../src/utils/memory-files.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,eAAO,MAAM,WAAW,0BAA0B,CAAC;AACnD,eAAO,MAAM,aAAa,QAAS,CAAC;AAEpC,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAMD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,EAAE,CA8DlF;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAMtE;AAMD,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAW9E;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAW3F;AAMD,wBAAsB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBjF;AA2BD,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO/D;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQvE"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared memory file utilities — used by memory-migrate tool and file-watcher service.
|
|
4
|
+
*
|
|
5
|
+
* Provides chunking, marker file I/O, file discovery, and safe file reading.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.MAX_FILE_SIZE = exports.MARKER_FILE = void 0;
|
|
9
|
+
exports.splitIntoChunks = splitIntoChunks;
|
|
10
|
+
exports.inferType = inferType;
|
|
11
|
+
exports.loadMarker = loadMarker;
|
|
12
|
+
exports.saveMarker = saveMarker;
|
|
13
|
+
exports.discoverMemoryFiles = discoverMemoryFiles;
|
|
14
|
+
exports.fileExists = fileExists;
|
|
15
|
+
exports.safeReadFile = safeReadFile;
|
|
16
|
+
const promises_1 = require("node:fs/promises");
|
|
17
|
+
const node_path_1 = require("node:path");
|
|
18
|
+
exports.MARKER_FILE = '.engram-migrated.json';
|
|
19
|
+
exports.MAX_FILE_SIZE = 50_000; // 50KB limit per file
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Chunking
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
function splitIntoChunks(content, sourcePath) {
|
|
24
|
+
const chunks = [];
|
|
25
|
+
const lines = content.split('\n');
|
|
26
|
+
// Try splitting by ## headers
|
|
27
|
+
const sections = [];
|
|
28
|
+
let currentTitle = '';
|
|
29
|
+
let currentContent = [];
|
|
30
|
+
let inFence = false;
|
|
31
|
+
for (const line of lines) {
|
|
32
|
+
if (line.startsWith('```')) {
|
|
33
|
+
inFence = !inFence;
|
|
34
|
+
}
|
|
35
|
+
const headerMatch = !inFence ? line.match(/^##\s+(.+)/) : null;
|
|
36
|
+
if (headerMatch) {
|
|
37
|
+
if (currentContent.length > 0) {
|
|
38
|
+
sections.push({
|
|
39
|
+
title: currentTitle || sourcePath,
|
|
40
|
+
content: currentContent.join('\n').trim(),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
currentTitle = headerMatch[1].trim();
|
|
44
|
+
currentContent = [];
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
currentContent.push(line);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Push last section
|
|
51
|
+
if (currentContent.length > 0) {
|
|
52
|
+
sections.push({
|
|
53
|
+
title: currentTitle || sourcePath,
|
|
54
|
+
content: currentContent.join('\n').trim(),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// If no ## headers found, treat whole file as one chunk
|
|
58
|
+
if (sections.length === 0) {
|
|
59
|
+
const trimmed = content.trim();
|
|
60
|
+
if (trimmed) {
|
|
61
|
+
chunks.push({
|
|
62
|
+
title: sourcePath,
|
|
63
|
+
content: trimmed,
|
|
64
|
+
sourcePath,
|
|
65
|
+
type: inferType(sourcePath, trimmed),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return chunks;
|
|
69
|
+
}
|
|
70
|
+
// Filter out empty sections and create chunks
|
|
71
|
+
for (const section of sections) {
|
|
72
|
+
if (!section.content)
|
|
73
|
+
continue;
|
|
74
|
+
chunks.push({
|
|
75
|
+
title: section.title,
|
|
76
|
+
content: section.content,
|
|
77
|
+
sourcePath,
|
|
78
|
+
type: inferType(sourcePath, section.content),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return chunks;
|
|
82
|
+
}
|
|
83
|
+
function inferType(_sourcePath, content) {
|
|
84
|
+
const lower = content.toLowerCase();
|
|
85
|
+
if (lower.includes('decision') || lower.includes('chose') || lower.includes('decided'))
|
|
86
|
+
return 'decision';
|
|
87
|
+
if (lower.includes('bug') || lower.includes('fix') || lower.includes('resolved'))
|
|
88
|
+
return 'bugfix';
|
|
89
|
+
if (lower.includes('pattern') || lower.includes('convention'))
|
|
90
|
+
return 'discovery';
|
|
91
|
+
return 'change';
|
|
92
|
+
}
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
// Marker file
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
async function loadMarker(path) {
|
|
97
|
+
try {
|
|
98
|
+
const raw = await (0, promises_1.readFile)(path, 'utf-8');
|
|
99
|
+
const parsed = JSON.parse(raw);
|
|
100
|
+
if (!parsed || typeof parsed !== 'object' || typeof parsed.files !== 'object') {
|
|
101
|
+
return null; // corrupted marker, treat as fresh
|
|
102
|
+
}
|
|
103
|
+
return parsed;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function saveMarker(markerPath, marker) {
|
|
110
|
+
// Atomic write via temp file + rename to reduce race window when
|
|
111
|
+
// two agents migrate concurrently (last writer wins, no corruption).
|
|
112
|
+
const tmp = markerPath + '.tmp';
|
|
113
|
+
try {
|
|
114
|
+
await (0, promises_1.writeFile)(tmp, JSON.stringify(marker, null, 2), 'utf-8');
|
|
115
|
+
await (0, promises_1.rename)(tmp, markerPath);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
119
|
+
console.warn(`[engram] failed to save migration marker: ${msg}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
// File discovery
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
async function discoverMemoryFiles(workspaceDir) {
|
|
126
|
+
const files = [];
|
|
127
|
+
// Check MEMORY.md
|
|
128
|
+
const memoryMd = (0, node_path_1.join)(workspaceDir, 'MEMORY.md');
|
|
129
|
+
if (await fileExists(memoryMd)) {
|
|
130
|
+
files.push(memoryMd);
|
|
131
|
+
}
|
|
132
|
+
// Check memory/ directory recursively
|
|
133
|
+
const memoryDir = (0, node_path_1.join)(workspaceDir, 'memory');
|
|
134
|
+
if (await fileExists(memoryDir)) {
|
|
135
|
+
const mdFiles = await findMdFiles(memoryDir);
|
|
136
|
+
files.push(...mdFiles);
|
|
137
|
+
}
|
|
138
|
+
return files;
|
|
139
|
+
}
|
|
140
|
+
async function findMdFiles(dir, depth = 0) {
|
|
141
|
+
if (depth > 10)
|
|
142
|
+
return []; // Guard against excessive nesting
|
|
143
|
+
const results = [];
|
|
144
|
+
try {
|
|
145
|
+
const entries = await (0, promises_1.readdir)(dir, { withFileTypes: true });
|
|
146
|
+
for (const entry of entries) {
|
|
147
|
+
if (entry.isSymbolicLink())
|
|
148
|
+
continue; // Prevent symlink cycles
|
|
149
|
+
const fullPath = (0, node_path_1.join)(dir, entry.name);
|
|
150
|
+
if (entry.isDirectory()) {
|
|
151
|
+
const nested = await findMdFiles(fullPath, depth + 1);
|
|
152
|
+
results.push(...nested);
|
|
153
|
+
}
|
|
154
|
+
else if (entry.isFile() && entry.name.endsWith('.md')) {
|
|
155
|
+
results.push(fullPath);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
// Directory not readable — skip
|
|
161
|
+
}
|
|
162
|
+
return results;
|
|
163
|
+
}
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
// Helpers
|
|
166
|
+
// ---------------------------------------------------------------------------
|
|
167
|
+
async function fileExists(path) {
|
|
168
|
+
try {
|
|
169
|
+
await (0, promises_1.stat)(path);
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async function safeReadFile(path) {
|
|
177
|
+
try {
|
|
178
|
+
const info = await (0, promises_1.stat)(path);
|
|
179
|
+
if (info.size > exports.MAX_FILE_SIZE)
|
|
180
|
+
return null;
|
|
181
|
+
return await (0, promises_1.readFile)(path, 'utf-8');
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=memory-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-files.js","sourceRoot":"","sources":["../../src/utils/memory-files.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAwBH,0CA8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
+
"id": "engram",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"displayName": "Engram Memory",
|
|
6
|
+
"description": "Connects OpenClaw agents to engram persistent memory server for long-term context retention",
|
|
7
|
+
"kind": "memory",
|
|
8
|
+
"author": "thebtf",
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"configSchema": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"url": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Engram server URL (e.g. http://localhost:37777)",
|
|
16
|
+
"default": "http://localhost:37777"
|
|
17
|
+
},
|
|
18
|
+
"token": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "Bearer token for engram API authentication",
|
|
21
|
+
"uiHints": { "sensitive": true }
|
|
22
|
+
},
|
|
23
|
+
"project": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Project scope override (defaults to auto-detected from workspace)"
|
|
26
|
+
},
|
|
27
|
+
"contextLimit": {
|
|
28
|
+
"type": "number",
|
|
29
|
+
"description": "Maximum observations to inject per prompt",
|
|
30
|
+
"default": 10
|
|
31
|
+
},
|
|
32
|
+
"sessionContextLimit": {
|
|
33
|
+
"type": "number",
|
|
34
|
+
"description": "Maximum observations to inject at session start",
|
|
35
|
+
"default": 20
|
|
36
|
+
},
|
|
37
|
+
"tokenBudget": {
|
|
38
|
+
"type": "number",
|
|
39
|
+
"description": "Maximum token budget for context injection (approx 4 chars per token)",
|
|
40
|
+
"default": 2000
|
|
41
|
+
},
|
|
42
|
+
"timeoutMs": {
|
|
43
|
+
"type": "number",
|
|
44
|
+
"description": "Per-request timeout in milliseconds",
|
|
45
|
+
"default": 5000
|
|
46
|
+
},
|
|
47
|
+
"autoExtract": {
|
|
48
|
+
"type": "boolean",
|
|
49
|
+
"description": "Enable automatic observation extraction on compaction/session-end",
|
|
50
|
+
"default": true
|
|
51
|
+
},
|
|
52
|
+
"logLevel": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"enum": ["debug", "info", "warn", "error"],
|
|
55
|
+
"description": "Log verbosity level",
|
|
56
|
+
"default": "warn"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"required": ["url", "token"]
|
|
60
|
+
},
|
|
61
|
+
"hooks": [
|
|
62
|
+
"session_start",
|
|
63
|
+
"before_prompt_build",
|
|
64
|
+
"after_tool_call",
|
|
65
|
+
"before_compaction",
|
|
66
|
+
"session_end"
|
|
67
|
+
],
|
|
68
|
+
"tools": [
|
|
69
|
+
"engram_search",
|
|
70
|
+
"engram_remember",
|
|
71
|
+
"engram_decisions",
|
|
72
|
+
"memory_search",
|
|
73
|
+
"memory_store",
|
|
74
|
+
"memory_forget",
|
|
75
|
+
"memory_get",
|
|
76
|
+
"memory_migrate"
|
|
77
|
+
],
|
|
78
|
+
"commands": [
|
|
79
|
+
"memory",
|
|
80
|
+
"remember",
|
|
81
|
+
"migrate"
|
|
82
|
+
],
|
|
83
|
+
"cli": {
|
|
84
|
+
"commands": ["memory"]
|
|
85
|
+
}
|
|
86
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "openclaw-engram",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "OpenClaw plugin that connects to engram persistent memory server",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"typecheck": "tsc --noEmit",
|
|
10
|
+
"prepublishOnly": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/",
|
|
14
|
+
"openclaw.plugin.json"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"openclaw",
|
|
18
|
+
"engram",
|
|
19
|
+
"memory",
|
|
20
|
+
"plugin"
|
|
21
|
+
],
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/thebtf/engram.git",
|
|
25
|
+
"directory": "plugin/openclaw-engram"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@sinclair/typebox": "^0.34.0",
|
|
30
|
+
"chokidar": "^4.0.3",
|
|
31
|
+
"zod": "^3.25.76"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^18.19.0",
|
|
35
|
+
"typescript": "^5.9.3"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18.0.0"
|
|
39
|
+
},
|
|
40
|
+
"openclaw": {
|
|
41
|
+
"extensions": [
|
|
42
|
+
"dist/index.js"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}
|