@vectorize-io/hindsight-openclaw 0.4.14 → 0.4.16
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 +41 -0
- package/dist/client.d.ts +0 -4
- package/dist/client.js +6 -4
- package/dist/index.d.ts +21 -1
- package/dist/index.js +556 -139
- package/dist/types.d.ts +24 -0
- package/openclaw.plugin.json +177 -3
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -24,6 +24,47 @@ openclaw gateway
|
|
|
24
24
|
|
|
25
25
|
That's it! The plugin will automatically start capturing and recalling memories.
|
|
26
26
|
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- **Auto-capture** and **auto-recall** of memories each turn
|
|
30
|
+
- **Memory isolation** — configurable per agent, channel, user, or provider via `dynamicBankGranularity`
|
|
31
|
+
- **Retention controls** — choose which message roles to retain and toggle auto-retain on/off
|
|
32
|
+
|
|
33
|
+
## Configuration
|
|
34
|
+
|
|
35
|
+
Optional settings in `~/.openclaw/openclaw.json` under `plugins.entries.hindsight-openclaw.config`:
|
|
36
|
+
|
|
37
|
+
| Option | Default | Description |
|
|
38
|
+
|--------|---------|-------------|
|
|
39
|
+
| `apiPort` | `9077` | Port for the local Hindsight daemon |
|
|
40
|
+
| `daemonIdleTimeout` | `0` | Seconds before daemon shuts down from inactivity (0 = never) |
|
|
41
|
+
| `embedPort` | `0` | Port for `hindsight-embed` server (`0` = auto-assign) |
|
|
42
|
+
| `embedVersion` | `"latest"` | hindsight-embed version |
|
|
43
|
+
| `embedPackagePath` | — | Local path to `hindsight-embed` package for development |
|
|
44
|
+
| `bankMission` | — | Agent identity/purpose stored on the memory bank. Helps the engine understand context for better fact extraction. Set once per bank — not a recall prompt. |
|
|
45
|
+
| `llmProvider` | auto-detect | LLM provider override for memory extraction (`openai`, `anthropic`, `gemini`, `groq`, `ollama`, `openai-codex`, `claude-code`) |
|
|
46
|
+
| `llmModel` | provider default | LLM model override used with `llmProvider` |
|
|
47
|
+
| `llmApiKeyEnv` | provider standard env var | Custom env var name for the provider API key |
|
|
48
|
+
| `dynamicBankId` | `true` | Enable per-context memory banks |
|
|
49
|
+
| `bankIdPrefix` | — | Prefix for bank IDs (e.g. `"prod"`) |
|
|
50
|
+
| `dynamicBankGranularity` | `["agent", "channel", "user"]` | Fields used to derive bank ID. Options: `agent`, `channel`, `user`, `provider` |
|
|
51
|
+
| `excludeProviders` | `[]` | Message providers to skip for recall/retain (e.g. `slack`, `telegram`, `discord`) |
|
|
52
|
+
| `autoRecall` | `true` | Auto-inject memories before each turn. Set to `false` when the agent has its own recall tool. |
|
|
53
|
+
| `autoRetain` | `true` | Auto-retain conversations after each turn |
|
|
54
|
+
| `retainRoles` | `["user", "assistant"]` | Which message roles to retain. Options: `user`, `assistant`, `system`, `tool` |
|
|
55
|
+
| `retainEveryNTurns` | `1` | Retain every Nth turn. `1` = every turn (default). Values > 1 enable chunked retention with a sliding window. |
|
|
56
|
+
| `retainOverlapTurns` | `0` | Extra prior turns included when chunked retention fires. Window = `retainEveryNTurns + retainOverlapTurns`. Only applies when `retainEveryNTurns > 1`. |
|
|
57
|
+
| `recallBudget` | `"mid"` | Recall effort: `low`, `mid`, or `high`. Higher budgets use more retrieval strategies. |
|
|
58
|
+
| `recallMaxTokens` | `1024` | Max tokens for recall response. Controls how much memory context is injected per turn. |
|
|
59
|
+
| `recallTypes` | `["world", "experience"]` | Memory types to recall. Options: `world`, `experience`, `observation`. Excludes verbose `observation` entries by default. |
|
|
60
|
+
| `recallRoles` | `["user", "assistant"]` | Roles included when building prior context for recall query composition. Options: `user`, `assistant`, `system`, `tool`. |
|
|
61
|
+
| `recallTopK` | — | Max number of memories to inject per turn. Applied after API response as a hard cap. |
|
|
62
|
+
| `recallContextTurns` | `1` | Number of user turns to include when composing recall query context. `1` keeps latest-message-only behavior. |
|
|
63
|
+
| `recallMaxQueryChars` | `800` | Maximum character length for the composed recall query before calling recall. |
|
|
64
|
+
| `recallPromptPreamble` | built-in string | Prompt text placed above recalled memories in the injected `<hindsight_memories>` block. |
|
|
65
|
+
| `hindsightApiUrl` | — | External Hindsight API URL (skips local daemon) |
|
|
66
|
+
| `hindsightApiToken` | — | Auth token for external API |
|
|
67
|
+
|
|
27
68
|
## Documentation
|
|
28
69
|
|
|
29
70
|
For full documentation, configuration options, troubleshooting, and development guide, see:
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { RetainRequest, RetainResponse, RecallRequest, RecallResponse } from './types.js';
|
|
2
2
|
export interface HindsightClientOptions {
|
|
3
|
-
llmProvider: string;
|
|
4
|
-
llmApiKey: string;
|
|
5
3
|
llmModel?: string;
|
|
6
4
|
embedVersion?: string;
|
|
7
5
|
embedPackagePath?: string;
|
|
@@ -10,8 +8,6 @@ export interface HindsightClientOptions {
|
|
|
10
8
|
}
|
|
11
9
|
export declare class HindsightClient {
|
|
12
10
|
private bankId;
|
|
13
|
-
private llmProvider;
|
|
14
|
-
private llmApiKey;
|
|
15
11
|
private llmModel?;
|
|
16
12
|
private embedVersion;
|
|
17
13
|
private embedPackagePath?;
|
package/dist/client.js
CHANGED
|
@@ -19,16 +19,12 @@ function sanitizeFilename(name) {
|
|
|
19
19
|
}
|
|
20
20
|
export class HindsightClient {
|
|
21
21
|
bankId = 'default';
|
|
22
|
-
llmProvider;
|
|
23
|
-
llmApiKey;
|
|
24
22
|
llmModel;
|
|
25
23
|
embedVersion;
|
|
26
24
|
embedPackagePath;
|
|
27
25
|
apiUrl;
|
|
28
26
|
apiToken;
|
|
29
27
|
constructor(opts) {
|
|
30
|
-
this.llmProvider = opts.llmProvider;
|
|
31
|
-
this.llmApiKey = opts.llmApiKey;
|
|
32
28
|
this.llmModel = opts.llmModel;
|
|
33
29
|
this.embedVersion = opts.embedVersion || 'latest';
|
|
34
30
|
this.embedPackagePath = opts.embedPackagePath;
|
|
@@ -181,6 +177,12 @@ export class HindsightClient {
|
|
|
181
177
|
query,
|
|
182
178
|
max_tokens: request.max_tokens || 1024,
|
|
183
179
|
};
|
|
180
|
+
if (request.budget) {
|
|
181
|
+
body.budget = request.budget;
|
|
182
|
+
}
|
|
183
|
+
if (request.types) {
|
|
184
|
+
body.types = request.types;
|
|
185
|
+
}
|
|
184
186
|
const res = await fetch(url, {
|
|
185
187
|
method: 'POST',
|
|
186
188
|
headers: this.httpHeaders(),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MoltbotPluginAPI } from './types.js';
|
|
1
|
+
import type { MoltbotPluginAPI, PluginConfig, PluginHookAgentContext, MemoryResult } from './types.js';
|
|
2
2
|
import { HindsightClient } from './client.js';
|
|
3
3
|
/**
|
|
4
4
|
* Strip plugin-injected memory tags from content to prevent retain feedback loop.
|
|
@@ -6,6 +6,17 @@ import { HindsightClient } from './client.js';
|
|
|
6
6
|
* during before_agent_start so they don't get re-stored into the memory bank.
|
|
7
7
|
*/
|
|
8
8
|
export declare function stripMemoryTags(content: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Extract sender_id from OpenClaw's injected inbound metadata blocks.
|
|
11
|
+
* Checks both "Conversation info (untrusted metadata)" and "Sender (untrusted metadata)" blocks.
|
|
12
|
+
* Returns the first sender_id / id string found, or undefined if none.
|
|
13
|
+
*/
|
|
14
|
+
export declare function extractSenderIdFromText(text: string): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Strip OpenClaw sender/conversation metadata envelopes from message content.
|
|
17
|
+
* These blocks are injected by OpenClaw but are noise for memory storage and recall.
|
|
18
|
+
*/
|
|
19
|
+
export declare function stripMetadataEnvelopes(content: string): string;
|
|
9
20
|
/**
|
|
10
21
|
* Extract a recall query from a hook event's rawMessage or prompt.
|
|
11
22
|
*
|
|
@@ -15,5 +26,14 @@ export declare function stripMemoryTags(content: string): string;
|
|
|
15
26
|
* Returns null when no usable query (< 5 chars) can be extracted.
|
|
16
27
|
*/
|
|
17
28
|
export declare function extractRecallQuery(rawMessage: string | undefined, prompt: string | undefined): string | null;
|
|
29
|
+
export declare function composeRecallQuery(latestQuery: string, messages: any[] | undefined, recallContextTurns: number, recallRoles?: Array<'user' | 'assistant' | 'system' | 'tool'>): string;
|
|
30
|
+
export declare function truncateRecallQuery(query: string, latestQuery: string, maxChars: number): string;
|
|
31
|
+
export declare function deriveBankId(ctx: PluginHookAgentContext | undefined, pluginConfig: PluginConfig): string;
|
|
32
|
+
export declare function formatMemories(results: MemoryResult[]): string;
|
|
18
33
|
export default function (api: MoltbotPluginAPI): void;
|
|
34
|
+
export declare function prepareRetentionTranscript(messages: any[], pluginConfig: PluginConfig, retainFullWindow?: boolean): {
|
|
35
|
+
transcript: string;
|
|
36
|
+
messageCount: number;
|
|
37
|
+
} | null;
|
|
38
|
+
export declare function sliceLastTurnsByUserBoundary(messages: any[], turns: number): any[];
|
|
19
39
|
export declare function getClient(): HindsightClient | null;
|