@christopherlittle51/postclaw 1.0.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.
Files changed (46) hide show
  1. package/.env.example +4 -0
  2. package/LICENSE +15 -0
  3. package/README.md +731 -0
  4. package/dist/index.d.ts +36 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +506 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/schemas/validation.d.ts +81 -0
  9. package/dist/schemas/validation.d.ts.map +1 -0
  10. package/dist/schemas/validation.js +27 -0
  11. package/dist/schemas/validation.js.map +1 -0
  12. package/dist/scripts/bootstrap_persona.d.ts +20 -0
  13. package/dist/scripts/bootstrap_persona.d.ts.map +1 -0
  14. package/dist/scripts/bootstrap_persona.js +150 -0
  15. package/dist/scripts/bootstrap_persona.js.map +1 -0
  16. package/dist/scripts/bootstrap_tools.d.ts +2 -0
  17. package/dist/scripts/bootstrap_tools.d.ts.map +1 -0
  18. package/dist/scripts/bootstrap_tools.js +67 -0
  19. package/dist/scripts/bootstrap_tools.js.map +1 -0
  20. package/dist/scripts/setup-db.d.ts +28 -0
  21. package/dist/scripts/setup-db.d.ts.map +1 -0
  22. package/dist/scripts/setup-db.js +539 -0
  23. package/dist/scripts/setup-db.js.map +1 -0
  24. package/dist/scripts/sleep_cycle.d.ts +32 -0
  25. package/dist/scripts/sleep_cycle.d.ts.map +1 -0
  26. package/dist/scripts/sleep_cycle.js +452 -0
  27. package/dist/scripts/sleep_cycle.js.map +1 -0
  28. package/dist/services/db.d.ts +28 -0
  29. package/dist/services/db.d.ts.map +1 -0
  30. package/dist/services/db.js +93 -0
  31. package/dist/services/db.js.map +1 -0
  32. package/dist/services/memoryService.d.ts +75 -0
  33. package/dist/services/memoryService.d.ts.map +1 -0
  34. package/dist/services/memoryService.js +391 -0
  35. package/dist/services/memoryService.js.map +1 -0
  36. package/dist/test-db.d.ts +8 -0
  37. package/dist/test-db.d.ts.map +1 -0
  38. package/dist/test-db.js +94 -0
  39. package/dist/test-db.js.map +1 -0
  40. package/dist/test-memory.d.ts +2 -0
  41. package/dist/test-memory.d.ts.map +1 -0
  42. package/dist/test-memory.js +79 -0
  43. package/dist/test-memory.js.map +1 -0
  44. package/openclaw.plugin.json +37 -0
  45. package/package.json +49 -0
  46. package/schemas/db.sql +371 -0
@@ -0,0 +1,36 @@
1
+ export { getSql, LM_STUDIO_URL, POSTCLAW_DB_URL, EMBEDDING_MODEL, getEmbedding, hashContent, setEmbeddingConfig, setDbUrl } from "./services/db.js";
2
+ export { ensureAgent, searchPostgres, logEpisodicMemory, logEpisodicToolCall, fetchPersonaContext, fetchDynamicTools, storeMemory, updateMemory, linkMemories, storeTool } from "./services/memoryService.js";
3
+ export type { ChatCompletionTool } from "./services/memoryService.js";
4
+ /** A single message in the OpenAI chat format. */
5
+ export interface ChatMessage {
6
+ role: "system" | "user" | "assistant" | "tool";
7
+ content: string | ContentPart[] | null;
8
+ tool_calls?: ToolCallRecord[];
9
+ tool_call_id?: string;
10
+ name?: string;
11
+ }
12
+ /** Multimodal content part (text, image, etc). */
13
+ export interface ContentPart {
14
+ type: string;
15
+ text?: string;
16
+ image_url?: {
17
+ url: string;
18
+ };
19
+ }
20
+ /** A tool call record attached to an assistant message. */
21
+ export interface ToolCallRecord {
22
+ id?: string;
23
+ type?: "function";
24
+ function: {
25
+ name: string;
26
+ arguments: string;
27
+ };
28
+ }
29
+ declare const openclawPostgresPlugin: {
30
+ id: string;
31
+ name: string;
32
+ description: string;
33
+ register(api: any): void;
34
+ };
35
+ export default openclawPostgresPlugin;
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpJ,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC9M,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAMtE,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,GAAG,IAAI,CAAC;IACvC,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7B;AAED,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAiDD,QAAA,MAAM,sBAAsB;;;;kBAKZ,GAAG;CAoflB,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,506 @@
1
+ "use strict";
2
+ // =============================================================================
3
+ // RE-EXPORTS — Single entry point for downstream consumers
4
+ // =============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.storeTool = exports.linkMemories = exports.updateMemory = exports.storeMemory = exports.fetchDynamicTools = exports.fetchPersonaContext = exports.logEpisodicToolCall = exports.logEpisodicMemory = exports.searchPostgres = exports.ensureAgent = exports.setDbUrl = exports.setEmbeddingConfig = exports.hashContent = exports.getEmbedding = exports.EMBEDDING_MODEL = exports.POSTCLAW_DB_URL = exports.LM_STUDIO_URL = exports.getSql = void 0;
7
+ var db_js_1 = require("./services/db.js");
8
+ Object.defineProperty(exports, "getSql", { enumerable: true, get: function () { return db_js_1.getSql; } });
9
+ Object.defineProperty(exports, "LM_STUDIO_URL", { enumerable: true, get: function () { return db_js_1.LM_STUDIO_URL; } });
10
+ Object.defineProperty(exports, "POSTCLAW_DB_URL", { enumerable: true, get: function () { return db_js_1.POSTCLAW_DB_URL; } });
11
+ Object.defineProperty(exports, "EMBEDDING_MODEL", { enumerable: true, get: function () { return db_js_1.EMBEDDING_MODEL; } });
12
+ Object.defineProperty(exports, "getEmbedding", { enumerable: true, get: function () { return db_js_1.getEmbedding; } });
13
+ Object.defineProperty(exports, "hashContent", { enumerable: true, get: function () { return db_js_1.hashContent; } });
14
+ Object.defineProperty(exports, "setEmbeddingConfig", { enumerable: true, get: function () { return db_js_1.setEmbeddingConfig; } });
15
+ Object.defineProperty(exports, "setDbUrl", { enumerable: true, get: function () { return db_js_1.setDbUrl; } });
16
+ var memoryService_js_1 = require("./services/memoryService.js");
17
+ Object.defineProperty(exports, "ensureAgent", { enumerable: true, get: function () { return memoryService_js_1.ensureAgent; } });
18
+ Object.defineProperty(exports, "searchPostgres", { enumerable: true, get: function () { return memoryService_js_1.searchPostgres; } });
19
+ Object.defineProperty(exports, "logEpisodicMemory", { enumerable: true, get: function () { return memoryService_js_1.logEpisodicMemory; } });
20
+ Object.defineProperty(exports, "logEpisodicToolCall", { enumerable: true, get: function () { return memoryService_js_1.logEpisodicToolCall; } });
21
+ Object.defineProperty(exports, "fetchPersonaContext", { enumerable: true, get: function () { return memoryService_js_1.fetchPersonaContext; } });
22
+ Object.defineProperty(exports, "fetchDynamicTools", { enumerable: true, get: function () { return memoryService_js_1.fetchDynamicTools; } });
23
+ Object.defineProperty(exports, "storeMemory", { enumerable: true, get: function () { return memoryService_js_1.storeMemory; } });
24
+ Object.defineProperty(exports, "updateMemory", { enumerable: true, get: function () { return memoryService_js_1.updateMemory; } });
25
+ Object.defineProperty(exports, "linkMemories", { enumerable: true, get: function () { return memoryService_js_1.linkMemories; } });
26
+ Object.defineProperty(exports, "storeTool", { enumerable: true, get: function () { return memoryService_js_1.storeTool; } });
27
+ // =============================================================================
28
+ // IN-MEMORY DEDUPLICATION
29
+ // =============================================================================
30
+ const processedEvents = new Set();
31
+ const MAX_CACHE_SIZE = 1000;
32
+ /** Cache last message from message_received (fires before before_prompt_build). */
33
+ let lastReceivedMessage = "";
34
+ function isDuplicate(key) {
35
+ if (processedEvents.has(key))
36
+ return true;
37
+ processedEvents.add(key);
38
+ if (processedEvents.size > MAX_CACHE_SIZE)
39
+ processedEvents.clear();
40
+ return false;
41
+ }
42
+ // =============================================================================
43
+ // HELPERS
44
+ // =============================================================================
45
+ const db_js_2 = require("./services/db.js");
46
+ const memoryService_js_2 = require("./services/memoryService.js");
47
+ const typebox_1 = require("@sinclair/typebox");
48
+ /**
49
+ * Extracts the text content from the last user message in a messages array.
50
+ */
51
+ function extractUserText(messages) {
52
+ const lastUserIndex = messages.findLastIndex((m) => m.role === "user");
53
+ if (lastUserIndex === -1)
54
+ return "";
55
+ const content = messages[lastUserIndex].content;
56
+ if (typeof content === "string")
57
+ return content;
58
+ if (Array.isArray(content)) {
59
+ return content
60
+ .filter((part) => part.type === "text" && part.text)
61
+ .map((part) => part.text)
62
+ .join(" ");
63
+ }
64
+ return "";
65
+ }
66
+ // =============================================================================
67
+ // OPENCLAW PLUGIN — Default export for plugin loader
68
+ // =============================================================================
69
+ const openclawPostgresPlugin = {
70
+ id: "postclaw",
71
+ name: "PostClaw",
72
+ description: "PostgreSQL-backed RAG, memory, and persona management",
73
+ register(api) {
74
+ console.log("[PostClaw] Registering plugin hooks...");
75
+ // Apply database URL from plugin config (plugins.entries.postclaw.config.dbUrl)
76
+ const pluginConfig = api.config?.plugins?.entries?.postclaw?.config;
77
+ if (pluginConfig?.dbUrl) {
78
+ (0, db_js_2.setDbUrl)(pluginConfig.dbUrl);
79
+ console.log("[PostClaw] Database URL configured via plugin config");
80
+ }
81
+ // Extract LLM configuration from OpenClaw (defaulting to localhost if not found)
82
+ const memoryConfig = api.config?.agents?.defaults?.memorySearch;
83
+ const llmUrl = memoryConfig?.remote?.baseUrl || "http://127.0.0.1:1234/v1";
84
+ const llmModel = memoryConfig?.remote?.model || memoryConfig?.model || "text-embedding-nomic-embed-text-v2-moe";
85
+ (0, db_js_2.setEmbeddingConfig)(llmUrl, llmModel);
86
+ // -------------------------------------------------------------------------
87
+ // before_prompt_build — Prune + replace system prompt, inject RAG context
88
+ //
89
+ // This is a MODIFYING hook. The handler receives:
90
+ // event = { prompt: string, messages: ChatMessage[] }
91
+ // ctx = { agentId, sessionKey, sessionId, workspaceDir }
92
+ //
93
+ // Must RETURN: { systemPrompt?: string, prependContext?: string }
94
+ // - systemPrompt: REPLACES the system prompt entirely
95
+ // - prependContext: text prepended to the user's message context
96
+ //
97
+ // This replicates the old rag_proxy.ts + payload_pruner.ts pattern:
98
+ // 1. Strip OpenClaw's default bloat sections
99
+ // 2. Inject custom memory architecture rules
100
+ // 3. Append persona from Postgres
101
+ // 4. Inject RAG context as prependContext
102
+ // -------------------------------------------------------------------------
103
+ api.on("before_prompt_build", async (event, ctx) => {
104
+ try {
105
+ const messages = event.messages ?? [];
106
+ const userText = lastReceivedMessage || extractUserText(messages);
107
+ lastReceivedMessage = ""; // consume once — prevent stale leak into heartbeats
108
+ const cleanText = userText.replace(/^\[.*?\]\s*/, "");
109
+ // Detect heartbeat via ctx metadata (preferred) with keyword fallback
110
+ const agentId = ctx.agentId;
111
+ const provider = ctx?.messageProvider ?? "";
112
+ const isHeartbeat = provider === "heartbeat" || provider === "cron";
113
+ // Lazy-register the agent if not already in the DB
114
+ await (0, memoryService_js_2.ensureAgent)(agentId);
115
+ console.log(`[PostClaw] before_prompt_build: "${cleanText.substring(0, 80)}..." (heartbeat=${isHeartbeat}, provider=${provider})`);
116
+ // ==================================================================
117
+ // STEP 1: Prune the system prompt (strip OpenClaw default bloat)
118
+ // ==================================================================
119
+ let sysPrompt = event.prompt ?? "";
120
+ // Strip default Tooling, Safety, and Skills rules
121
+ sysPrompt = sysPrompt.replace(/## Tooling[\s\S]*?(?=## Workspace)/g, "");
122
+ // Strip default Documentation and Time rules
123
+ sysPrompt = sysPrompt.replace(/## Documentation[\s\S]*?(?=## Inbound Context)/g, "");
124
+ // Strip the ENTIRE Project Context (all injected Markdown files)
125
+ sysPrompt = sysPrompt.replace(/# Project Context[\s\S]*?(?=## Silent Replies)/g, "");
126
+ // Conditionally strip Heartbeats section (keep it for heartbeat messages)
127
+ if (!isHeartbeat) {
128
+ sysPrompt = sysPrompt.replace(/## Heartbeats[\s\S]*?(?=## Runtime)/g, "");
129
+ }
130
+ // Clean up excess whitespace
131
+ sysPrompt = sysPrompt.replace(/\n{3,}/g, "\n\n");
132
+ // ==================================================================
133
+ // STEP 2: Inject custom memory architecture rules
134
+ // ==================================================================
135
+ sysPrompt += `
136
+ ## Memory & Knowledge Management
137
+ You are a stateful agent. Your context window is ephemeral but your PostgreSQL memory is permanent.
138
+ Silently manage your knowledge — never ask permission to save, link, or update facts.
139
+
140
+ - **Retrieval:** Relevant memories (with UUID tags) are auto-injected.
141
+ - **Search:** Use the \`memory_search\` tool when you need to recall facts not in the current context.
142
+ - **Correct/update facts:** Use the \`memory_update\` tool when a fact is incorrect, outdated, or needs to be updated. When using memory_update, ALWAYS assign an appropriate 'tier' and 'category'.
143
+ - **Save new facts:** Use the \`memory_store\` tool when a new fact is learned. When using memory_store, ALWAYS assign an appropriate 'tier' (e.g., 'permanent' for core user identity, 'daily' for current tasks) and 'category'.
144
+ - **Link related memories:** Use the \`memory_link\` tool when two memories are related.
145
+ - **Store a tool:** Use the \`tool_store\` tool when a new tool schema is learned.
146
+ - **Sleep cycle** (consolidates short-term memory): \`deno run -A /home/cl/.openclaw/workspace/scripts/sleep_cycle.ts "${agentId}"\`
147
+ - **Always Reply**: ALWAYS conclude your turn with a direct response to the user.
148
+ `;
149
+ sysPrompt += `
150
+ ## Autonomous Heartbeats
151
+ OpenClaw provides a native heartbeat loop — never use Linux crontab.
152
+ To schedule background tasks, add a checklist to: /home/cl/.openclaw/workspace/HEARTBEAT.md
153
+ On heartbeat poll: read that file. If no pending tasks, reply with ONLY: HEARTBEAT_OK
154
+ `;
155
+ // ==================================================================
156
+ // STEP 3: Fetch persona + RAG context from Postgres (in parallel)
157
+ // ==================================================================
158
+ const result = {};
159
+ if (!isHeartbeat) {
160
+ const hasUserText = cleanText.trim().length > 0;
161
+ const embedding = hasUserText ? await (0, db_js_2.getEmbedding)(cleanText) : null;
162
+ const [memoryContext, personaContext] = await Promise.all([
163
+ // RAG: only when we have user text to search against
164
+ hasUserText ? (0, memoryService_js_2.searchPostgres)(agentId, cleanText) : Promise.resolve(null),
165
+ // Persona: always fetch (core rules work without embedding)
166
+ (0, memoryService_js_2.fetchPersonaContext)(agentId, embedding),
167
+ ]);
168
+ // Persona context → append to the pruned system prompt
169
+ if (personaContext) {
170
+ sysPrompt += `\n\n## Dynamic Database Persona\nThe following core operational rules were loaded from your database:\n${personaContext}\n`;
171
+ console.log(`[PostClaw] 🎭 Injected persona context`);
172
+ }
173
+ // RAG context → prependContext (injected before the user message)
174
+ if (memoryContext) {
175
+ result.prependContext =
176
+ `[SYSTEM RAG CONTEXT]\n` +
177
+ `The following historical memories were retrieved from the database. ` +
178
+ `Use them to help answer the user's query if they are relevant:\n\n` +
179
+ `${memoryContext}\n\n` +
180
+ `[END CONTEXT]`;
181
+ console.log(`[PostClaw] 📚 Injected RAG context (${memoryContext.split("\n").length} lines)`);
182
+ }
183
+ }
184
+ // Return the fully replaced system prompt
185
+ result.systemPrompt = sysPrompt;
186
+ console.log(`[PostClaw] ✅ System prompt replaced (${sysPrompt.length} chars)`);
187
+ return result;
188
+ }
189
+ catch (err) {
190
+ console.error("[PostClaw] before_prompt_build error:", err);
191
+ return { systemPrompt: event.prompt };
192
+ }
193
+ }, {
194
+ name: "PostClaw.before-prompt-build",
195
+ description: "Prunes default system prompt and injects memory architecture, persona, and RAG context",
196
+ });
197
+ // -------------------------------------------------------------------------
198
+ // NATIVE TOOLS — Registered via api.registerTool()
199
+ //
200
+ // These replace the old Deno skill scripts with in-process tool handlers
201
+ // that share the plugin's DB connection pool and embedding infrastructure.
202
+ // -------------------------------------------------------------------------
203
+ // --- memory_search: Semantic search across stored memories ---
204
+ api.registerTool({
205
+ name: "memory_search",
206
+ description: "Search the agent's long-term semantic memory using natural language. Returns the most relevant stored facts and their UUIDs.",
207
+ parameters: typebox_1.Type.Object({
208
+ query: typebox_1.Type.String({ description: "Natural language search query" }),
209
+ }),
210
+ async execute(_toolCallId, args, _signal, _onUpdate, ctx) {
211
+ const agentId = ctx?.agentId || "main";
212
+ await (0, memoryService_js_2.ensureAgent)(agentId);
213
+ const result = await (0, memoryService_js_2.searchPostgres)(agentId, args.query);
214
+ return result || "No memories found matching that query.";
215
+ },
216
+ }, { names: ["memory_search"] });
217
+ // --- memory_store: Save a new durable fact ---
218
+ api.registerTool({
219
+ name: "memory_store",
220
+ description: "Store a new durable fact. You can categorize it, set volatility, and add metadata.",
221
+ parameters: typebox_1.Type.Object({
222
+ content: typebox_1.Type.String({ description: "The fact or knowledge to store" }),
223
+ scope: typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.Literal("private"), typebox_1.Type.Literal("shared"), typebox_1.Type.Literal("global")], { default: "private" })),
224
+ category: typebox_1.Type.Optional(typebox_1.Type.String({ description: "A short categorical tag (e.g., 'preference', 'project_detail')" })),
225
+ volatility: typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.Literal("low"), typebox_1.Type.Literal("medium"), typebox_1.Type.Literal("high")], { default: "low" })),
226
+ tier: typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.Literal("volatile"), typebox_1.Type.Literal("session"), typebox_1.Type.Literal("daily"), typebox_1.Type.Literal("stable"), typebox_1.Type.Literal("permanent")], { default: "daily" })),
227
+ metadata: typebox_1.Type.Optional(typebox_1.Type.Any({ description: "A JSON object of additional contextual key-value pairs" }))
228
+ }),
229
+ async execute(_toolCallId, args, _signal, _onUpdate, ctx) {
230
+ const agentId = ctx?.agentId || "main";
231
+ await (0, memoryService_js_2.ensureAgent)(agentId);
232
+ const { content, scope, ...options } = args;
233
+ const result = await (0, memoryService_js_2.storeMemory)(agentId, content, scope, options);
234
+ return JSON.stringify(result);
235
+ },
236
+ }, { names: ["memory_store"] });
237
+ // --- memory_update: Supersede an old fact with a corrected one ---
238
+ api.registerTool({
239
+ name: "memory_update",
240
+ description: "Correct or update an existing memory. Archives the old fact and creates a new one with a causal chain link. You can assign categories, volatility, and metadata.",
241
+ parameters: typebox_1.Type.Object({
242
+ old_memory_id: typebox_1.Type.String({ description: "UUID of the outdated memory to supersede" }),
243
+ new_fact: typebox_1.Type.String({ description: "The corrected or updated fact" }),
244
+ category: typebox_1.Type.Optional(typebox_1.Type.String({ description: "A short categorical tag (e.g., 'preference', 'project_detail')" })),
245
+ volatility: typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.Literal("low"), typebox_1.Type.Literal("medium"), typebox_1.Type.Literal("high")], { default: "low" })),
246
+ tier: typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.Literal("volatile"), typebox_1.Type.Literal("session"), typebox_1.Type.Literal("daily"), typebox_1.Type.Literal("stable"), typebox_1.Type.Literal("permanent")], { default: "daily" })),
247
+ metadata: typebox_1.Type.Optional(typebox_1.Type.Any({ description: "A JSON object of additional contextual key-value pairs" }))
248
+ }),
249
+ async execute(_toolCallId, args, _signal, _onUpdate, ctx) {
250
+ const agentId = ctx?.agentId || "main";
251
+ await (0, memoryService_js_2.ensureAgent)(agentId);
252
+ const { old_memory_id, new_fact, ...options } = args;
253
+ const result = await (0, memoryService_js_2.updateMemory)(agentId, old_memory_id, new_fact, options);
254
+ return JSON.stringify(result);
255
+ },
256
+ }, { names: ["memory_update"] });
257
+ // --- memory_link: Create a knowledge graph edge between two memories ---
258
+ api.registerTool({
259
+ name: "memory_link",
260
+ description: "Create a directed relationship edge between two memories in the knowledge graph.",
261
+ parameters: typebox_1.Type.Object({
262
+ source_id: typebox_1.Type.String({ description: "UUID of the source memory" }),
263
+ target_id: typebox_1.Type.String({ description: "UUID of the target memory" }),
264
+ relationship: typebox_1.Type.String({ description: "Relationship type (e.g. related_to, elaborates, contradicts, depends_on, part_of)" }),
265
+ }),
266
+ async execute(_toolCallId, args, _signal, _onUpdate, ctx) {
267
+ const agentId = ctx?.agentId || "main";
268
+ await (0, memoryService_js_2.ensureAgent)(agentId);
269
+ const result = await (0, memoryService_js_2.linkMemories)(agentId, args.source_id, args.target_id, args.relationship);
270
+ return JSON.stringify(result);
271
+ },
272
+ }, { names: ["memory_link"] });
273
+ // --- tool_store: Store or update a tool schema definition ---
274
+ api.registerTool({
275
+ name: "tool_store",
276
+ description: "Store or update a tool definition in the environment context database, so it can be dynamically loaded for future conversations.",
277
+ parameters: typebox_1.Type.Object({
278
+ tool_name: typebox_1.Type.String({ description: "Unique name for the tool" }),
279
+ tool_json: typebox_1.Type.String({ description: "Full JSON schema definition of the tool" }),
280
+ scope: typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.Literal("private"), typebox_1.Type.Literal("shared"), typebox_1.Type.Literal("global")], { description: "Visibility scope. Default: private", default: "private" })),
281
+ }),
282
+ async execute(_toolCallId, args, _signal, _onUpdate, ctx) {
283
+ const agentId = ctx?.agentId || "main";
284
+ await (0, memoryService_js_2.ensureAgent)(agentId);
285
+ const result = await (0, memoryService_js_2.storeTool)(agentId, args.tool_name, args.tool_json, args.scope);
286
+ return JSON.stringify(result);
287
+ },
288
+ }, { names: ["tool_store"] });
289
+ // -------------------------------------------------------------------------
290
+ // agent_end — Log episodic memories after agent completes
291
+ //
292
+ // This is a VOID hook (fire-and-forget). The handler receives:
293
+ // event = { messages: ChatMessage[], success: boolean, error?: string, durationMs: number }
294
+ // ctx = { agentId, sessionKey, sessionId, workspaceDir, messageProvider }
295
+ // -------------------------------------------------------------------------
296
+ api.on("agent_end", async (event, ctx) => {
297
+ try {
298
+ const messages = event.messages ?? [];
299
+ const agentId = ctx.agentId;
300
+ const provider = ctx?.messageProvider ?? "";
301
+ const isHeartbeat = provider === "heartbeat" || provider === "cron";
302
+ // Lazy-register the agent if not already in the DB
303
+ await (0, memoryService_js_2.ensureAgent)(agentId);
304
+ console.log(`[PostClaw] agent_end: ${messages.length} messages, success=${event.success}, provider=${provider}`);
305
+ // Skip all episodic logging for heartbeat/cron runs
306
+ if (isHeartbeat) {
307
+ console.log("[PostClaw] Skipped episodic logging for heartbeat run");
308
+ return;
309
+ }
310
+ // Extract the last user message
311
+ const lastUser = [...messages].reverse().find((m) => m.role === "user");
312
+ const userMessage = lastUser
313
+ ? typeof lastUser.content === "string"
314
+ ? lastUser.content
315
+ : Array.isArray(lastUser.content)
316
+ ? lastUser.content.filter((p) => p.type === "text").map((p) => p.text).join(" ")
317
+ : ""
318
+ : "";
319
+ const promises = [];
320
+ // Log user message as episodic event
321
+ if (userMessage.trim()) {
322
+ // Strip any RAG context that OpenClaw prepended to the user message
323
+ const text = userMessage
324
+ .replace(/\[SYSTEM RAG CONTEXT\][\s\S]*?\[END CONTEXT\]\s*/g, "")
325
+ .replace(/^\[.*?\]\s*/, "")
326
+ .trim();
327
+ if (!isDuplicate(text)) {
328
+ promises.push((async () => {
329
+ try {
330
+ const embedding = await (0, db_js_2.getEmbedding)(text);
331
+ await (0, memoryService_js_2.logEpisodicMemory)(agentId, text, embedding, "user_prompt");
332
+ }
333
+ catch (err) {
334
+ console.error("[PostClaw] Failed to log episodic memory:", err);
335
+ }
336
+ })());
337
+ }
338
+ }
339
+ // Log tool calls as episodic events
340
+ const toolCalls = messages
341
+ .filter((m) => m.role === "assistant" && m.tool_calls)
342
+ .flatMap((m) => m.tool_calls ?? []);
343
+ for (const toolCall of toolCalls) {
344
+ const toolCallId = toolCall.id
345
+ || `fallback-${toolCall.function.name}-${toolCall.function.arguments.substring(0, 20)}`;
346
+ if (isDuplicate(toolCallId))
347
+ continue;
348
+ promises.push((async () => {
349
+ try {
350
+ const summary = `Agent executed tool: ${toolCall.function.name} with arguments: ${toolCall.function.arguments}`;
351
+ const embedding = await (0, db_js_2.getEmbedding)(summary);
352
+ await (0, memoryService_js_2.logEpisodicToolCall)(agentId, toolCallId, toolCall.function.name, toolCall.function.arguments, embedding);
353
+ }
354
+ catch (err) {
355
+ console.error(`[PostClaw] Failed to log tool call (${toolCall.function.name}):`, err);
356
+ }
357
+ })());
358
+ }
359
+ if (promises.length > 0) {
360
+ await Promise.allSettled(promises);
361
+ console.log(`[PostClaw] Episodic logging complete (${promises.length} event(s))`);
362
+ }
363
+ }
364
+ catch (err) {
365
+ console.error("[PostClaw] agent_end error:", err);
366
+ }
367
+ }, {
368
+ name: "PostClaw.agent-end",
369
+ description: "Logs episodic memories for user prompts and tool calls after agent completes",
370
+ });
371
+ // -------------------------------------------------------------------------
372
+ // message_received — Log inbound messages to episodic memory
373
+ //
374
+ // This is a VOID hook. The handler receives:
375
+ // event = { from, content, channelId, ... } (raw message event fields)
376
+ // ctx = { agentId, sessionKey, ... }
377
+ // -------------------------------------------------------------------------
378
+ api.on("message_received", async (event, _ctx) => {
379
+ try {
380
+ const content = event.content;
381
+ if (!content || typeof content !== "string" || !content.trim())
382
+ return;
383
+ const cleanText = content.replace(/^\[.*?\]\s*/, "");
384
+ // Cache for before_prompt_build (which fires after this hook).
385
+ // Episodic logging is handled in agent_end where agentId is available.
386
+ lastReceivedMessage = cleanText;
387
+ console.log(`[PostClaw] message_received: cached "${cleanText.substring(0, 60)}..." for before_prompt_build`);
388
+ }
389
+ catch (err) {
390
+ console.error("[PostClaw] message_received error:", err);
391
+ }
392
+ }, {
393
+ name: "PostClaw.message-received",
394
+ description: "Caches inbound messages for before_prompt_build RAG injection",
395
+ });
396
+ // -------------------------------------------------------------------------
397
+ // CLI — Register `openclaw postclaw setup` command
398
+ // -------------------------------------------------------------------------
399
+ api.registerCli(({ program }) => {
400
+ const postclaw = program.command("postclaw").description("PostClaw database management");
401
+ postclaw
402
+ .command("setup")
403
+ .description("Create and initialize the PostClaw PostgreSQL database")
404
+ .option("--admin-url <url>", "PostgreSQL superuser connection string (default: postgres://localhost/postgres)")
405
+ .option("--db-name <name>", "Database name (default: memorydb)")
406
+ .option("--db-user <user>", "App user name (default: openclaw)")
407
+ .option("--db-password <pass>", "App user password (auto-generated if omitted)")
408
+ .option("--skip-config", "Don't auto-update openclaw.json with the new dbUrl")
409
+ .action(async (opts) => {
410
+ const { runSetup } = await import("./scripts/setup-db.js");
411
+ await runSetup({
412
+ adminUrl: opts.adminUrl,
413
+ dbName: opts.dbName,
414
+ dbUser: opts.dbUser,
415
+ dbPassword: opts.dbPassword,
416
+ skipConfig: opts.skipConfig,
417
+ });
418
+ });
419
+ postclaw
420
+ .command("persona")
421
+ .argument("<file>", "Path to a Markdown persona file (e.g. SOUL.md, AGENTS.md)")
422
+ .description("Bootstrap a Markdown persona file into the agent_persona table")
423
+ .option("--agent-id <id>", "Agent ID to store persona under (default: main)")
424
+ .option("--llm-model <model>", "Chat model to use for chunking (default: agent's primary model)")
425
+ .action(async (file, opts) => {
426
+ // Ensure embedding config is set from OpenClaw config before running
427
+ const memCfg = api.config?.agents?.defaults?.memorySearch;
428
+ const llmUrl = memCfg?.remote?.baseUrl || "http://127.0.0.1:1234/v1";
429
+ const embModel = memCfg?.remote?.model || memCfg?.model || "text-embedding-nomic-embed-text-v2-moe";
430
+ (0, db_js_2.setEmbeddingConfig)(llmUrl, embModel);
431
+ // Apply dbUrl from plugin config
432
+ const pluginCfg = api.config?.plugins?.entries?.postclaw?.config;
433
+ if (pluginCfg?.dbUrl) {
434
+ (0, db_js_2.setDbUrl)(pluginCfg.dbUrl);
435
+ }
436
+ const { bootstrapPersona } = await import("./scripts/bootstrap_persona.js");
437
+ await bootstrapPersona(file, {
438
+ agentId: opts.agentId,
439
+ llmUrl: llmUrl,
440
+ llmModel: opts.llmModel,
441
+ });
442
+ });
443
+ postclaw
444
+ .command("sleep")
445
+ .description("Run the sleep cycle (knowledge graph maintenance) manually")
446
+ .option("--agent-id <id>", "Agent ID to run maintenance for (default: main)")
447
+ .option("--llm-model <model>", "Chat model to use for consolidation/linking")
448
+ .action(async (opts) => {
449
+ // Ensure embedding config is set from OpenClaw config before running
450
+ const memCfg = api.config?.agents?.defaults?.memorySearch;
451
+ const llmUrl = memCfg?.remote?.baseUrl || "http://127.0.0.1:1234/v1";
452
+ const embModel = memCfg?.remote?.model || memCfg?.model || "text-embedding-nomic-embed-text-v2-moe";
453
+ (0, db_js_2.setEmbeddingConfig)(llmUrl, embModel);
454
+ // Apply dbUrl from plugin config
455
+ const pluginCfg = api.config?.plugins?.entries?.postclaw?.config;
456
+ if (pluginCfg?.dbUrl) {
457
+ (0, db_js_2.setDbUrl)(pluginCfg.dbUrl);
458
+ }
459
+ const { runSleepCycle } = await import("./scripts/sleep_cycle.js");
460
+ await runSleepCycle({
461
+ agentId: opts.agentId,
462
+ llmUrl: llmUrl,
463
+ llmModel: opts.llmModel,
464
+ });
465
+ });
466
+ }, { commands: ["postclaw"] });
467
+ // ─────────────────────────────────────────────────────────────────────────
468
+ // BACKGROUND SERVICE — Start sleep cycle on an interval
469
+ // ─────────────────────────────────────────────────────────────────────────
470
+ const sleepIntervalHours = api.config?.plugins?.entries?.postclaw?.config?.sleepIntervalHours;
471
+ if (sleepIntervalHours !== 0) {
472
+ // Start the background sleep cycle service (0 = disabled)
473
+ import("./scripts/sleep_cycle.js").then(({ startService }) => {
474
+ const memCfg = api.config?.agents?.defaults?.memorySearch;
475
+ const llmUrl = memCfg?.remote?.baseUrl || "http://127.0.0.1:1234/v1";
476
+ startService({
477
+ agentId: "main",
478
+ llmUrl,
479
+ intervalHours: sleepIntervalHours || 6,
480
+ });
481
+ }).catch((err) => {
482
+ console.error("[PostClaw] Failed to start sleep service:", err);
483
+ });
484
+ }
485
+ console.log("[PostClaw] Plugin hooks registered successfully");
486
+ },
487
+ };
488
+ exports.default = openclawPostgresPlugin;
489
+ // =============================================================================
490
+ // STANDALONE ENTRY POINT (for testing)
491
+ // =============================================================================
492
+ const db_js_3 = require("./services/db.js");
493
+ if (require.main === module) {
494
+ console.log("=== PostClaw-swarm plugin loaded ===");
495
+ console.log(` DB: ${db_js_3.POSTCLAW_DB_URL}`);
496
+ console.log(` LM: ${db_js_3.LM_STUDIO_URL}`);
497
+ console.log(` Model: ${db_js_3.EMBEDDING_MODEL}`);
498
+ console.log("Hooks: before_prompt_build, agent_end, message_received");
499
+ // Graceful shutdown
500
+ process.on("SIGINT", async () => {
501
+ console.log("\nShutting down...");
502
+ await (0, db_js_3.getSql)().end();
503
+ process.exit(0);
504
+ });
505
+ }
506
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,2DAA2D;AAC3D,gFAAgF;;;AAEhF,0CAAoJ;AAA3I,+FAAA,MAAM,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,wGAAA,eAAe,OAAA;AAAE,wGAAA,eAAe,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,oGAAA,WAAW,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAAE,iGAAA,QAAQ,OAAA;AACzH,gEAA8M;AAArM,+GAAA,WAAW,OAAA;AAAE,kHAAA,cAAc,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AAAE,uHAAA,mBAAmB,OAAA;AAAE,uHAAA,mBAAmB,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AAAE,+GAAA,WAAW,OAAA;AAAE,gHAAA,YAAY,OAAA;AAAE,gHAAA,YAAY,OAAA;AAAE,6GAAA,SAAS,OAAA;AAiCxK,gFAAgF;AAChF,0BA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