@fathippo/fathippo-context-engine 0.1.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/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # @fathippo/fathippo-context-engine
2
+
3
+ FatHippo Context Engine for OpenClaw — persistent agent memory with hosted cognition or private local mode.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ openclaw plugins install @fathippo/fathippo-context-engine
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ ```yaml
14
+ # ~/.openclaw/config.yaml
15
+ plugins:
16
+ slots:
17
+ contextEngine: "fathippo-context-engine"
18
+ entries:
19
+ fathippo-context-engine:
20
+ enabled: true
21
+ config:
22
+ mode: hosted # hosted or local
23
+ apiKey: "${FATHIPPO_API_KEY}" # Hosted mode only
24
+ baseUrl: "https://fathippo.ai/api"
25
+ # Optional settings
26
+ injectCritical: true # Auto-inject critical memories (default: true)
27
+ injectLimit: 20 # Max memories per turn (default: 20)
28
+ captureUserOnly: true # Only capture user messages (default: true)
29
+ dreamCycleOnCompact: true # Run Dream Cycle on /compact in hosted mode
30
+ ```
31
+
32
+ ## What It Does
33
+
34
+ Instead of bolting memory onto OpenClaw, this makes FatHippo the **entire context layer**:
35
+
36
+ | Hook | What Happens |
37
+ |------|-------------|
38
+ | **bootstrap** | Loads hosted critical context or initializes local workspace memory |
39
+ | **ingest** | Captures user messages, filters noise, stores hosted or local memory |
40
+ | **assemble** | Queries hosted FatHippo or local store and injects relevant context per turn |
41
+ | **compact** | Runs hosted Dream Cycle or skips hosted compaction in local mode |
42
+ | **afterTurn** | Invalidates caches and captures hosted or local learning signals |
43
+ | **prepareSubagentSpawn** | Scopes memories for spawned agents |
44
+ | **onSubagentEnded** | Absorbs learnings from completed subagents |
45
+
46
+ ## Features
47
+
48
+ - **Hosted mode** — Full FatHippo retrieval, cognition, sync, and receipts
49
+ - **Local mode** — Private on-device memory plus lightweight local workflow/fix learning
50
+ - **Semantic search** — Hosted hybrid search or local memory ranking
51
+ - **Dream Cycle** — Automatic synthesis, decay, and cleanup in hosted mode
52
+ - **Cross-device** — Hosted mode follows your account across devices
53
+
54
+ ## API Key
55
+
56
+ Get your API key at [fathippo.ai](https://fathippo.ai)
57
+
58
+ ## OpenClaw CLI Setup
59
+
60
+ ```bash
61
+ openclaw plugins install @fathippo/fathippo-context-engine
62
+ openclaw config set plugins.slots.contextEngine=fathippo-context-engine
63
+ openclaw config set plugins.entries.fathippo-context-engine.config.mode=hosted
64
+ openclaw config set plugins.entries.fathippo-context-engine.config.apiKey=mem_xxx
65
+ openclaw config set plugins.entries.fathippo-context-engine.config.baseUrl=https://fathippo.ai/api
66
+ openclaw config set plugins.entries.fathippo-context-engine.config.injectCritical=true
67
+ openclaw gateway restart
68
+ ```
69
+
70
+ If you previously installed `@fathippo/context-engine`, reinstall from `@fathippo/fathippo-context-engine` so OpenClaw discovers a matching package name and plugin id.
71
+
72
+ ## Links
73
+
74
+ - [FatHippo Docs](https://fathippo.ai/docs)
75
+ - [OpenClaw Plugins](https://docs.openclaw.ai/tools/plugin)
76
+ - [GitHub](https://github.com/jscianna/fathippo)
@@ -0,0 +1,75 @@
1
+ /**
2
+ * FatHippo API Client
3
+ */
4
+ import type { FatHippoConfig, Memory, SearchResult, CriticalMemoriesResponse, RememberParams, SearchParams, DreamCycleParams, IndexedMemory, IndexedMemoriesResponse } from "../types.js";
5
+ export declare class FatHippoClient {
6
+ private apiKey;
7
+ private baseUrl;
8
+ private pluginHeaders;
9
+ constructor(config: FatHippoConfig);
10
+ private request;
11
+ /**
12
+ * Store a memory
13
+ */
14
+ remember(params: RememberParams): Promise<Memory>;
15
+ /**
16
+ * Search memories
17
+ */
18
+ search(params: SearchParams): Promise<SearchResult[]>;
19
+ /**
20
+ * Get critical-tier memories (for injection)
21
+ */
22
+ getCriticalMemories(options?: {
23
+ limit?: number;
24
+ excludeAbsorbed?: boolean;
25
+ }): Promise<CriticalMemoriesResponse>;
26
+ /**
27
+ * Get recent memories (for context)
28
+ */
29
+ getRecentMemories(options?: {
30
+ hours?: number;
31
+ limit?: number;
32
+ }): Promise<Memory[]>;
33
+ /**
34
+ * Run Dream Cycle (synthesis, decay, cleanup)
35
+ */
36
+ runDreamCycle(params?: DreamCycleParams): Promise<{
37
+ ok: boolean;
38
+ synthesized?: number;
39
+ decayed?: number;
40
+ }>;
41
+ /**
42
+ * Get context for injection (optimized endpoint)
43
+ */
44
+ getContext(query?: string): Promise<{
45
+ memories: Memory[];
46
+ syntheses?: Array<{
47
+ id: string;
48
+ title: string;
49
+ content: string;
50
+ }>;
51
+ tokenEstimate?: number;
52
+ }>;
53
+ /**
54
+ * Get indexed memory summaries (compact, for agent context)
55
+ */
56
+ getIndexedSummaries(): Promise<IndexedMemoriesResponse>;
57
+ /**
58
+ * Dereference an indexed memory to get full content
59
+ */
60
+ dereferenceIndex(indexKey: string): Promise<IndexedMemory>;
61
+ /**
62
+ * Store an indexed memory
63
+ */
64
+ storeIndexed(params: {
65
+ index: string;
66
+ summary: string;
67
+ content: string;
68
+ contentType?: string;
69
+ metadata?: Record<string, unknown>;
70
+ }): Promise<{
71
+ stored: boolean;
72
+ index: string;
73
+ }>;
74
+ }
75
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,YAAY,EACZ,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACxB,MAAM,aAAa,CAAC;AAoCrB,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAyB;gBAElC,MAAM,EAAE,cAAc;YAUpB,OAAO;IAyBrB;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,G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E,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAMhD"}
@@ -0,0 +1,176 @@
1
+ /**
2
+ * FatHippo API Client
3
+ */
4
+ const DEFAULT_BASE_URL = "https://fathippo.ai/api";
5
+ function mapMemoryRecord(record) {
6
+ return {
7
+ id: record.id,
8
+ title: record.title,
9
+ content: record.text,
10
+ userId: record.userId ?? "",
11
+ memoryType: record.memoryType ?? record.type,
12
+ importanceTier: record.importanceTier ??
13
+ record.tier ??
14
+ "normal",
15
+ createdAt: record.createdAt,
16
+ updatedAt: record.createdAt,
17
+ accessCount: record.accessCount,
18
+ absorbed: record.absorbed,
19
+ absorbedIntoSynthesisId: record.absorbedIntoSynthesisId,
20
+ };
21
+ }
22
+ export class FatHippoClient {
23
+ apiKey;
24
+ baseUrl;
25
+ pluginHeaders;
26
+ constructor(config) {
27
+ this.apiKey = config.apiKey ?? "";
28
+ this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
29
+ this.pluginHeaders = {
30
+ "X-Fathippo-Plugin-Id": config.pluginId ?? "fathippo-context-engine",
31
+ "X-Fathippo-Plugin-Version": config.pluginVersion ?? "unknown",
32
+ "X-Fathippo-Plugin-Mode": config.mode === "local" ? "local" : "hosted",
33
+ };
34
+ }
35
+ async request(path, options = {}) {
36
+ const url = `${this.baseUrl}${path}`;
37
+ const headers = {
38
+ Authorization: `Bearer ${this.apiKey}`,
39
+ "Content-Type": "application/json",
40
+ ...this.pluginHeaders,
41
+ ...options.headers,
42
+ };
43
+ const response = await fetch(url, {
44
+ ...options,
45
+ headers,
46
+ });
47
+ if (!response.ok) {
48
+ const error = await response.text().catch(() => "Unknown error");
49
+ throw new Error(`FatHippo API error: ${response.status} - ${error}`);
50
+ }
51
+ return response.json();
52
+ }
53
+ /**
54
+ * Store a memory
55
+ */
56
+ async remember(params) {
57
+ const response = await this.request("/v1/memories", {
58
+ method: "POST",
59
+ body: JSON.stringify(params),
60
+ });
61
+ return mapMemoryRecord(response.memory);
62
+ }
63
+ /**
64
+ * Search memories
65
+ */
66
+ async search(params) {
67
+ const response = await this.request("/v1/search", {
68
+ method: "POST",
69
+ body: JSON.stringify(params),
70
+ });
71
+ return response.map((result) => ({
72
+ memory: mapMemoryRecord(result.memory),
73
+ score: result.score,
74
+ matchType: result.vectorScore && result.bm25Score
75
+ ? "hybrid"
76
+ : result.vectorScore
77
+ ? "vector"
78
+ : "bm25",
79
+ }));
80
+ }
81
+ /**
82
+ * Get critical-tier memories (for injection)
83
+ */
84
+ async getCriticalMemories(options) {
85
+ const response = await this.request("/v1/context", {
86
+ method: "POST",
87
+ body: JSON.stringify({
88
+ message: "",
89
+ includeHigh: false,
90
+ highLimit: 0,
91
+ }),
92
+ });
93
+ const memories = response.critical
94
+ .map(mapMemoryRecord)
95
+ .filter((memory) => (options?.excludeAbsorbed ? !memory.absorbed : true))
96
+ .slice(0, options?.limit ?? 30);
97
+ const syntheses = response.working.slice(0, options?.limit ?? 30).map((item) => ({
98
+ id: item.id,
99
+ userId: "",
100
+ title: item.title,
101
+ content: item.text,
102
+ sourceMemoryIds: item.synthesizedFrom ?? [],
103
+ createdAt: new Date().toISOString(),
104
+ }));
105
+ return { memories, syntheses };
106
+ }
107
+ /**
108
+ * Get recent memories (for context)
109
+ */
110
+ async getRecentMemories(options) {
111
+ const params = new URLSearchParams();
112
+ if (options?.limit)
113
+ params.set("limit", String(options.limit));
114
+ const response = await this.request(`/v1/memories?${params}`);
115
+ let memories = response.memories.map(mapMemoryRecord);
116
+ if (options?.hours) {
117
+ const cutoff = Date.now() - options.hours * 60 * 60 * 1000;
118
+ memories = memories.filter((memory) => Date.parse(memory.createdAt) >= cutoff);
119
+ }
120
+ return memories;
121
+ }
122
+ /**
123
+ * Run Dream Cycle (synthesis, decay, cleanup)
124
+ */
125
+ async runDreamCycle(params) {
126
+ const response = await this.request("/v1/lifecycle", {
127
+ method: "POST",
128
+ body: JSON.stringify(params || {}),
129
+ });
130
+ return {
131
+ ok: true,
132
+ synthesized: 0,
133
+ decayed: (response.maintenance?.archived ?? 0) + (response.maintenance?.deleted ?? 0),
134
+ };
135
+ }
136
+ /**
137
+ * Get context for injection (optimized endpoint)
138
+ */
139
+ async getContext(query) {
140
+ const response = await this.request("/v1/context", {
141
+ method: "POST",
142
+ body: JSON.stringify({ message: query || "" }),
143
+ });
144
+ return {
145
+ memories: [...response.critical, ...response.high].map(mapMemoryRecord),
146
+ syntheses: response.working?.map((item) => ({
147
+ id: item.id,
148
+ title: item.title,
149
+ content: item.text,
150
+ })),
151
+ tokenEstimate: response.stats?.totalTokensEstimate,
152
+ };
153
+ }
154
+ /**
155
+ * Get indexed memory summaries (compact, for agent context)
156
+ */
157
+ async getIndexedSummaries() {
158
+ return this.request("/v1/indexed");
159
+ }
160
+ /**
161
+ * Dereference an indexed memory to get full content
162
+ */
163
+ async dereferenceIndex(indexKey) {
164
+ return this.request(`/v1/indexed/${encodeURIComponent(indexKey)}`);
165
+ }
166
+ /**
167
+ * Store an indexed memory
168
+ */
169
+ async storeIndexed(params) {
170
+ return this.request("/v1/indexed", {
171
+ method: "POST",
172
+ body: JSON.stringify(params),
173
+ });
174
+ }
175
+ }
176
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAEnD,SAAS,eAAe,CAAC,MAaxB;IACC,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,OAAO,EAAE,MAAM,CAAC,IAAI;QACpB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;QAC3B,UAAU,EAAE,MAAM,CAAC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,GAAG,QAAQ,CAAC,QAAQ,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC;YACvE,SAAS,EAAE,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC1C,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,OAAO,EAAE,IAAI,CAAC,IAAI;aACnB,CAAC,CAAC;YACH,aAAa,EAAE,QAAQ,CAAC,KAAK,EAAE,mBAAmB;SACnD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,mBAAmB;QACvB,OAAO,IAAI,CAAC,OAAO,CAA0B,aAAa,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAAC,QAAgB;QACrC,OAAO,IAAI,CAAC,OAAO,CAAgB,eAAe,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,MAMlB;QACC,OAAO,IAAI,CAAC,OAAO,CAAqC,aAAa,EAAE;YACrE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export declare function sanitizeCognitiveText(text: string): string;
2
+ export declare function isShareEligible(text: string): boolean;
3
+ //# sourceMappingURL=sanitize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/cognitive/sanitize.ts"],"names":[],"mappings":"AAOA,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD"}
@@ -0,0 +1,17 @@
1
+ const SECRET_PATTERNS = [
2
+ /sk-[a-zA-Z0-9]{20,}/g,
3
+ /ghp_[a-zA-Z0-9]{20,}/g,
4
+ /AKIA[A-Z0-9]{16}/g,
5
+ /(['"]?)(?:api[_-]?key|secret|password|token)(['"]?\s*[:=]\s*)(['"]?)[^\s'"]+\3/gi,
6
+ ];
7
+ export function sanitizeCognitiveText(text) {
8
+ let sanitized = text;
9
+ for (const pattern of SECRET_PATTERNS) {
10
+ sanitized = sanitized.replace(pattern, "[REDACTED]");
11
+ }
12
+ return sanitized;
13
+ }
14
+ export function isShareEligible(text) {
15
+ return !SECRET_PATTERNS.some((pattern) => pattern.test(text));
16
+ }
17
+ //# sourceMappingURL=sanitize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../../src/cognitive/sanitize.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG;IACtB,sBAAsB;IACtB,uBAAuB;IACvB,mBAAmB;IACnB,kFAAkF;CACnF,CAAC;AAEF,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,IAAI,SAAS,GAAG,IAAI,CAAC;IACrB,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;QACtC,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { AgentMessage } from "@mariozechner/pi-agent-core";
2
+ export type StructuredTracePayload = {
3
+ sessionId: string;
4
+ type: string;
5
+ problem: string;
6
+ context: {
7
+ technologies: string[];
8
+ errorMessages?: string[];
9
+ };
10
+ reasoning: string;
11
+ approaches: Array<{
12
+ description: string;
13
+ result: "worked" | "failed" | "partial";
14
+ learnings?: string;
15
+ }>;
16
+ solution?: string;
17
+ outcome: "success" | "partial" | "failed";
18
+ heuristicOutcome: "success" | "partial" | "failed";
19
+ automatedOutcome?: "success" | "failed";
20
+ automatedSignals: Record<string, unknown>;
21
+ errorMessage?: string;
22
+ toolsUsed: string[];
23
+ toolCalls: Array<Record<string, unknown>>;
24
+ toolResults: Array<Record<string, unknown>>;
25
+ verificationCommands: string[];
26
+ retryCount: number;
27
+ repoSignals: {
28
+ filesModified: string[];
29
+ languages: string[];
30
+ diffSummary: string;
31
+ workspaceRoot?: string;
32
+ };
33
+ resolutionKind: "tests_passed" | "build_passed" | "lint_passed" | "manual_only" | "failed";
34
+ filesModified: string[];
35
+ durationMs: number;
36
+ sanitized: true;
37
+ sanitizedAt: string;
38
+ shareEligible: boolean;
39
+ };
40
+ export declare function shouldCaptureCodingTrace(messages: AgentMessage[]): boolean;
41
+ export declare function buildStructuredTrace(params: {
42
+ sessionId: string;
43
+ messages: AgentMessage[];
44
+ toolsUsed?: string[];
45
+ filesModified?: string[];
46
+ workspaceRoot?: string;
47
+ startTime: number;
48
+ endTime: number;
49
+ }): StructuredTracePayload | null;
50
+ export declare function getMessageText(message: AgentMessage): string;
51
+ //# sourceMappingURL=trace-capture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-capture.d.ts","sourceRoot":"","sources":["../../src/cognitive/trace-capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,U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