@susu-eng/gralkor 27.1.0 → 27.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/README.md CHANGED
@@ -8,15 +8,36 @@ Gralkor automatically remembers and recalls everything your agents says, _thinks
8
8
 
9
9
  ## Why Gralkor
10
10
 
11
- After years of building with every AI memory system out there, reading the latest research daily, and doing my own cognitive architecture experiments, I am here to tell you a thing or two about AI memory, and why you should use Gralkor for your OpenClaw agents and forget everything else.
11
+ After years of building with every AI memory system out there, reading the latest research daily, and doing my own cognitive architecture experiments, I am here to tell you a thing or two about AI memory, and why you should use Gralkor for your OpenClaw agents and forget everything else. I should say up front: I love this space and have enormous respect for everyone shipping in it — what follows is honest craft critique, not shade.
12
12
 
13
- **Graphs, not Markdown or pure vector** The AI ecosystem's fixation on Markdown-based memory is baffling. Graphs have been the right data structure for representing knowledge since long before LLMs existed. Your code is a graph (syntax trees). Your filesystem is a graph. The web is a graph. Relationships between entities are naturally graph-shaped, and trying to flatten them into Markdown files or pure vector embeddings is fighting reality. [Graphiti](https://github.com/getzep/graphiti) combines a knowledge graph with vector search — you get structured relationships *and* semantic retrieval. Facts carry temporal validity: when they became true, when they stopped being true, when they were superseded. This is not yet another chunking strategy or embedding experiment. Graphiti has solved this layer of the problem and we build on top of it (and not much).
13
+ Here's the honest field report on every OpenClaw memory plugin:
14
14
 
15
- **Remembering behaviour, not just dialog.** When your agent reasons through a problem — weighing options, rejecting approaches, arriving at a conclusion — that thinking process is as valuable as the final answer. Gralkor distills the agent's thinking blocks into first-person behavioural summaries and weaves them into the episode transcript before ingestion. The graph doesn't just know what was said; it knows how the agent arrived there. This adds roughly 20% to token cost during ingestion. *Fighting words*: Other memory systems only remember what was spoken, totally ignoring what your agent thinkgs and does. Even if you have a sophisticated memory system, your agent is inherently dishonest with you, frequently claiming to remember what it has done when it only really remembers what claimed to have done, or to have thought what it is only now imagining. Gralkor actually remembers what your agent thought and did - it is the only memory system with this capability AFAIK.
15
+ | Plugin | Storage | Captures thinking | Episode scope | Temporal facts | Local |
16
+ |---|---|---|---|---|---|
17
+ | **memory-core** *(built-in)* | Markdown files | no | full (LLM-written at compaction) | no | ✓ |
18
+ | **lancedb-pro** | LanceDB (flat vector) | no | new messages per run | partial | ✓ |
19
+ | **MemOS Local** | SQLite + vector | no | turn delta | recency decay only | ✓ |
20
+ | **Cognee** | Cognee graph API | no | Q&A pairs | partial | optional |
21
+ | **Supermemory** | Cloud (opaque) | no | last turn only | server-side flag | ✗ |
22
+ | **MemOS Cloud** | Cloud (opaque) | no | last turn *(default)* | none | ✗ |
23
+ | **Awareness** | Cloud + MD mirror | no | first message + last reply | none | ✗ |
24
+ | **Gralkor** | Graphiti knowledge graph | **yes** | full session | `valid_at`/`invalid_at`/`expired_at` | ✓ |
16
25
 
17
- **Maximum context at ingestion.** Most memory systems save isolated question-answer pairs or summarized snippets. Gralkor captures all messages in each session of work, distills behaviour, and feeds results to Graphiti *as whole episodes*. Extraction works _way_ better when Graphiti has full context rather fragmented QA pairs. *Fighting words*: Other memory systems capture single QA exchanges of dialog, we capture _the whole episode_ - the entire series of questions, thoughts, actions, and responses that _solved the problem_. Richer semantics, better understanding, better recall.
26
+ **Graphs, not Markdown or pure vector.** The AI ecosystem's fixation on Markdown-based memory is baffling. Graphs have been the right data structure for representing knowledge since long before LLMs existed. Your code is a graph (syntax trees). Your filesystem is a graph. The web is a graph. Relationships between entities are naturally graph-shaped, and trying to flatten them into Markdown files or pure vector embeddings is fighting reality. And yet: the most popular memory plugin memory-core, the one that ships inside OpenClaw — writes your agent's memory to `MEMORY.md` and `memory/YYYY-MM-DD.md`. The second most popular, lancedb-pro, stores extracted facts as flat rows in LanceDB. Both make recall a lookup problem when it should be a traversal problem. [Graphiti](https://github.com/getzep/graphiti) combines a knowledge graph with vector search — you get structured relationships *and* semantic retrieval. Facts carry temporal validity: when they became true, when they stopped being true, when they were superseded. This is not yet another chunking strategy or embedding experiment. Graphiti has solved this layer of the problem and we build on top of it (and not much). [HippoRAG](https://arxiv.org/abs/2405.14831) (NeurIPS 2024) found graph-based retrieval reaches 89.1% recall@5 on 2WikiMultiHopQA versus 68.2% for flat vector retrieval — a 20.9-point gap. [AriGraph](https://arxiv.org/abs/2407.04363) (IJCAI 2025) independently found KG-augmented agents markedly outperform RAG, summarization, and full-conversation-history baselines across interactive environments.
18
27
 
19
- **Built for the long term.**. Graphiti - on which Gralkor is based - is _temporally aware_. On every ingestion, it doesn't just append, it resolves new information against the existing graph, amending, expiring, and invalidating so that your agent knows _what happened over time_. This is expensive, bad for throughput, and useless for short-lived agents, so serving a single, long-lived user agent is _the perfect use case_. Graphiti was destined for Gralkor and OpenClaw.
28
+ **Remembering behaviour, not just dialog.** When your agent reasons through a problem weighing options, rejecting approaches, arriving at a conclusion — that thinking process is as valuable as the final answer. Gralkor distills the agent's thinking blocks into first-person behavioural summaries and weaves them into the episode transcript before ingestion. The graph doesn't just know what was said; it knows how the agent arrived there. *Fighting words*: Every other OpenClaw memory plugin only remembers what was spoken, totally ignoring what your agent thinks and does lancedb-pro filters for `type === "text"` only, MemOS strips `<think>` tags, Supermemory never looks at them. Even if you have a sophisticated memory system, your agent is inherently dishonest with you, frequently claiming to remember what it has done when it only really remembers what it claimed to have done, or to have thought what it is only now imagining. Gralkor actually remembers what your agent thought and did — it is the only OpenClaw memory plugin with this capability. [Reflexion](https://arxiv.org/abs/2303.11366) (NeurIPS 2023) showed agents storing self-reflective reasoning traces outperform GPT-4 output-only baselines by 11 points on HumanEval. [ExpeL](https://arxiv.org/abs/2308.10144) (AAAI 2024) directly ablated reasoning-trace storage versus output-only: +11–19 points across benchmarks from storing the reasoning process alone.
29
+
30
+ **On cost.** Yes, Gralkor costs more to run than a Markdown file. Behaviour distillation adds roughly 20% to ingestion token cost. Auto-recall adds an LLM call before each turn when results need interpretation.
31
+
32
+ Think of it as better context management, not overhead. However you handle long sessions — growing context windows, compaction, summarization — you're paying on every read. Gralkor pays once on write to extract and structure what matters, then pulls only the right stuff at read time.
33
+
34
+ And the leverage is real. A single recalled fact — "we chose postgres over mysql because of the jsonb column support we need for X" — prevents re-litigating that decision in a new session. An agent that remembers your architectural decisions, your preferences, your debugging history, and your reasoning across sessions doesn't just save time; it changes the character of the work. You stop spending turns re-establishing context and start doing the actual work you opened the terminal for.
35
+
36
+ Paying $15–20/month in API costs to make your agent meaningfully smarter across sessions is not a place to save money. The agents that cost you real money are the ones that forget everything and make you start over.
37
+
38
+ **Maximum context at ingestion.** Most memory plugins save isolated question-answer pairs or summarized snippets: Awareness stores the first user message and the last assistant reply — a 30-turn debugging session becomes two sentences. Supermemory and MemOS Cloud default to the last turn only. Gralkor captures all messages in each session of work, distills behaviour, and feeds results to Graphiti *as whole episodes*. Extraction works _way_ better when Graphiti has full context rather fragmented QA pairs. *Fighting words*: Other plugins capture single turns of dialog; we capture _the whole episode_ — the entire series of questions, thoughts, actions, and responses that _solved the problem_. Richer semantics, better understanding, better recall. [SeCom](https://arxiv.org/abs/2502.05589) (ICLR 2025) found coherent multi-turn episode storage scores 5.99 GPT4Score points higher than isolated turn-level storage on LOCOMO. [LongMemEval](https://arxiv.org/abs/2410.10813) (ICLR 2025) confirms: fact-level QA-pair extraction drops accuracy from 0.692 to 0.615 versus full-round episode storage.
39
+
40
+ **Built for the long term.** Graphiti — on which Gralkor is based — is _temporally aware_. On every ingestion, it doesn't just append; it resolves new information against the existing graph, amending, expiring, and invalidating so that your agent knows _what happened over time_. lancedb-pro has something in this direction — an `invalidated_at` timestamp on vector rows, genuinely good — but graph edges are not vector rows: Graphiti tracks four timestamps per fact (`created_at`, `valid_at`, `invalid_at`, `expired_at`) and supports point-in-time queries across a traversable structure. This is expensive, bad for throughput, and useless for short-lived agents, so serving a single, long-lived user agent is _the perfect use case_. Graphiti was destined for Gralkor and OpenClaw. [LongMemEval](https://arxiv.org/abs/2410.10813) (ICLR 2025) established that temporal reasoning is the hardest memory sub-task for commercial LLMs; time-aware indexing recovers 7–11% of that loss. [MemoTime](https://arxiv.org/abs/2510.13614) (WWW 2026) found temporal knowledge graphs enable a 4B model to match GPT-4-Turbo on temporal reasoning, with up to 24% improvement over static memory baselines.
20
41
 
21
42
  **Recursion through reflection.** A knowledge graph is a living structure. The most powerful thing you can do with it is point the agent back at its own memory — let it reflect on what it knows, identify contradictions, synthesize higher-order insights, and do with them whatever you believe to be _good cognitive architecture_ :shrug:. Gralkor doesn't prescribe how you do this. Instead, it provides the platform for cognitive architecture experimentation: a structured, temporally-aware graph that the agent can both read from and write to using OpenClaw crons.
22
43
 
@@ -27,9 +48,9 @@ Look for contradictions, outdated information, or patterns worth consolidating.
27
48
  Use memory_add to store any new insights."
28
49
  ```
29
50
 
30
- This is where it gets interesting. The graph gives you a substrate for experimentation — reflection strategies, knowledge consolidation, cross-session reasoning — that flat retrieval systems simply cannot support.
51
+ This is where it gets interesting. The graph gives you a substrate for experimentation — reflection strategies, knowledge consolidation, cross-session reasoning — that flat retrieval systems simply cannot support. [Reflexion](https://arxiv.org/abs/2303.11366) (NeurIPS 2023) demonstrated that agents storing verbal reflections in an episodic buffer gain 11 points with no weight updates. [Generative Agents](https://arxiv.org/abs/2304.03442) (UIST 2023) showed empirically that a reflection layer synthesizing raw memories into higher-order insights is essential for coherent long-term behavior.
31
52
 
32
- **Custom ontology: model your agent's world _your way_.** Define your own entity types, attributes, and relationships so that information is parsed into the language of your domain — or your life. [Apple's ODKE+](https://arxiv.org/abs/2509.04696) (2025) showed ontology-guided extraction hits 98.8% precision vs 91% raw LLM; a [separate study](https://arxiv.org/abs/2511.05991) (2025) found ontology-guided KGs substantially outperform vector baselines for retrieval. *Fighting words*: When every entity is just a "thing" and every relationship is `RELATES_TO`, your graph is a soup of ambiguity. Custom ontology turns it into a structured model of _your_ world.
53
+ **Custom ontology: model your agent's world _your way_.** Define your own entity types, attributes, and relationships so that information is parsed into the language of your domain — or your life. [Apple's ODKE+](https://arxiv.org/abs/2509.04696) (2025) showed ontology-guided extraction hits 98.8% precision vs 91% raw LLM; [GoLLIE](https://arxiv.org/abs/2310.03668) (ICLR 2024) directly ablated schema-constrained versus unconstrained generation on the same model, finding +13 F1 points average across NER, relation, and event extraction in zero-shot settings. No other OpenClaw memory plugin offers this. If you want extraction to speak your domain's language: lancedb-pro has six hardcoded categories you can filter but not extend; Supermemory lets you write a free-text hint to guide extraction; the rest offer nothing. Custom ontologies give your agent a model of the world: you could use a domain model codified by experts, be the expert, or try to encode _your_ model of the world. Agent memory doesn't have to be so fuzzy that you lose track of what matters.
33
54
 
34
55
  ## What it does
35
56
 
@@ -72,7 +93,13 @@ openclaw config set plugins.entries.gralkor.config.test true
72
93
  ### 3. Install the plugin
73
94
 
74
95
  ```bash
75
- openclaw plugins install @susu-eng/gralkor --dangerously-force-unsafe-install
96
+ openclaw plugins install @susu-eng/gralkor
97
+ ```
98
+
99
+ OpenClaw checks ClawHub before npm for bare package specs, so this installs from ClawHub automatically. To be explicit:
100
+
101
+ ```bash
102
+ openclaw plugins install clawhub:@susu-eng/gralkor
76
103
  ```
77
104
 
78
105
  From a tarball (e.g. for air-gapped deploys):
@@ -81,8 +108,6 @@ From a tarball (e.g. for air-gapped deploys):
81
108
  openclaw plugins install ./susu-eng-gralkor-memory-26.0.14.tgz --dangerously-force-unsafe-install
82
109
  ```
83
110
 
84
- The `--dangerously-force-unsafe-install` flag is required because Gralkor is not in OpenClaw's verified plugin registry.
85
-
86
111
  ### 4. Enable and assign the memory slot
87
112
 
88
113
  ```bash
@@ -126,7 +151,7 @@ openclaw config set plugins.slots.memory ""
126
151
  rm -rf ~/.openclaw/extensions/gralkor
127
152
 
128
153
  # Reinstall
129
- openclaw plugins install @susu-eng/gralkor --dangerously-force-unsafe-install
154
+ openclaw plugins install @susu-eng/gralkor
130
155
 
131
156
  # Re-assign slot
132
157
  openclaw config set plugins.slots.memory gralkor
package/dist/client.d.ts CHANGED
@@ -16,16 +16,6 @@ export interface Fact {
16
16
  expired_at: string | null;
17
17
  created_at: string;
18
18
  }
19
- /** A filtered content block for episode ingestion. */
20
- export interface EpisodeBlock {
21
- type: "text" | "thinking" | "tool_use" | "tool_result";
22
- text: string;
23
- }
24
- /** A filtered message for episode ingestion. */
25
- export interface EpisodeMessage {
26
- role: "user" | "assistant";
27
- content: EpisodeBlock[];
28
- }
29
19
  export interface AddEpisodeParams {
30
20
  name: string;
31
21
  episode_body: string;
@@ -33,11 +23,11 @@ export interface AddEpisodeParams {
33
23
  group_id: string;
34
24
  source?: "message" | "text" | "json";
35
25
  }
36
- export interface IngestMessagesParams {
26
+ export interface IngestEpisodeParams {
37
27
  name: string;
38
28
  source_description: string;
39
29
  group_id: string;
40
- messages: EpisodeMessage[];
30
+ episode_body: string;
41
31
  }
42
32
  export type SearchMode = "fast" | "slow";
43
33
  export interface EntityNode {
@@ -73,7 +63,7 @@ export declare class GraphitiClient {
73
63
  private request;
74
64
  health(): Promise<HealthResponse>;
75
65
  addEpisode(params: AddEpisodeParams): Promise<Episode>;
76
- ingestMessages(params: IngestMessagesParams): Promise<Episode>;
66
+ ingestEpisode(params: IngestEpisodeParams): Promise<Episode>;
77
67
  search(query: string, groupIds: string[], limit?: number, mode?: SearchMode): Promise<SearchResults>;
78
68
  buildIndices(): Promise<{
79
69
  status: string;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;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M,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;gBAEf,OAAO,EAAE,qBAAqB;YAM5B,OAAO;IAyEf,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;IAIjC,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAQtD,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAS5D,MAAM,CACV,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,SAAK,EACV,IAAI,GAAE,UAAmB,GACxB,OAAO,CAAC,aAAa,CAAC;IASnB,YAAY,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAI3C,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAIzF"}
package/dist/client.js CHANGED
@@ -83,9 +83,10 @@ export class GraphitiClient {
83
83
  reference_time: new Date().toISOString(),
84
84
  });
85
85
  }
86
- async ingestMessages(params) {
87
- return this.request("POST", "/ingest-messages", {
86
+ async ingestEpisode(params) {
87
+ return this.request("POST", "/episodes", {
88
88
  ...params,
89
+ source: "message",
89
90
  idempotency_key: crypto.randomUUID(),
90
91
  reference_time: new Date().toISOString(),
91
92
  });
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AA8EA,MAAM,OAAO,cAAc;IACjB,OAAO,CAAS;IAChB,SAAS,CAA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AC,MAAM,CACV,KAAa,EACb,QAAkB,EAClB,KAAK,GAAG,EAAE,EACV,OAAmB,MAAM;QAEzB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE;YACrC,KAAK;YACL,SAAS,EAAE,QAAQ;YACnB,WAAW,EAAE,KAAK;YAClB,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAAe;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3E,CAAC;CAEF"}
package/dist/config.d.ts CHANGED
@@ -38,7 +38,7 @@ export interface GralkorConfig {
38
38
  maxEntityResults: number;
39
39
  };
40
40
  idleTimeoutMs: number;
41
- llm?: ModelConfig;
41
+ llm: ModelConfig;
42
42
  embedder?: ModelConfig;
43
43
  ontology?: OntologyConfig;
44
44
  dataDir?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,sBAAsB,GAC9B,MAAM,GACN,MAAM,EAAE,GACR;IAAE,IAAI,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC/E;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5C,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAA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AG,MAAM,CAElD;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,IAAI,OAAO,CAAC;IACnB,OAAO,IAAI,IAAI,CAAC;CACjB;AAeD,wBAAgB,eAAe,IAAI,SAAS,CAK3C;AAED,6CAA6C;AAC7C,wBAAgB,cAAc,IAAI,IAAI,CAErC"}
package/dist/config.js CHANGED
@@ -58,6 +58,7 @@ export const defaultConfig = {
58
58
  idleTimeoutMs: 5 * 60 * 1000,
59
59
  autoRecall: { enabled: true, maxResults: 10 },
60
60
  search: { maxResults: 20, maxEntityResults: 10 },
61
+ llm: { provider: DEFAULT_LLM_PROVIDER, model: DEFAULT_LLM_MODEL },
61
62
  };
62
63
  export function resolveConfig(raw = {}) {
63
64
  return {
@@ -73,7 +74,10 @@ export function resolveConfig(raw = {}) {
73
74
  maxResults: raw.search?.maxResults ?? defaultConfig.search.maxResults,
74
75
  maxEntityResults: raw.search?.maxEntityResults ?? defaultConfig.search.maxEntityResults,
75
76
  },
76
- llm: raw.llm,
77
+ llm: {
78
+ provider: raw.llm?.provider ?? DEFAULT_LLM_PROVIDER,
79
+ model: raw.llm?.model ?? DEFAULT_LLM_MODEL,
80
+ },
77
81
  embedder: raw.embedder,
78
82
  ontology: raw.ontology,
79
83
  dataDir: raw.dataDir,
@@ -87,8 +91,8 @@ export function resolveConfig(raw = {}) {
87
91
  }
88
92
  export function resolveProviders(config) {
89
93
  return {
90
- llmProvider: config.llm?.provider ?? DEFAULT_LLM_PROVIDER,
91
- llmModel: config.llm?.model ?? DEFAULT_LLM_MODEL,
94
+ llmProvider: config.llm.provider,
95
+ llmModel: config.llm.model,
92
96
  embedderProvider: config.embedder?.provider ?? DEFAULT_EMBEDDER_PROVIDER,
93
97
  embedderModel: config.embedder?.model ?? DEFAULT_EMBEDDER_MODEL,
94
98
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAsBA,MAAM,qBAAqB,GAAG,IAAI,GAAG,C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WAAW,GAAG,KAAK,CAAC;AAExB,MAAM,UAAU,eAAe;IAC7B,OAAO;QACL,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW;QAC1B,OAAO,EAAE,GAAG,EAAE,GAAG,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC;KACvC,CAAC;AACJ,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,cAAc;IAC5B,WAAW,GAAG,KAAK,CAAC;AACtB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { LLMClient } from "./llm-client.js";
2
+ /** A filtered content block for episode ingestion. */
3
+ export interface EpisodeBlock {
4
+ type: "text" | "thinking" | "tool_use" | "tool_result";
5
+ text: string;
6
+ }
7
+ /** A filtered message for episode ingestion. */
8
+ export interface EpisodeMessage {
9
+ role: "user" | "assistant";
10
+ content: EpisodeBlock[];
11
+ }
12
+ export declare const DISTILL_SYSTEM_PROMPT: string;
13
+ /**
14
+ * Format structured episode messages into a transcript, distilling behaviour blocks
15
+ * (thinking, tool_use, tool_result) into per-turn summaries via LLM.
16
+ *
17
+ * Port of server-side _format_transcript(). When llmClient is null, behaviour
18
+ * blocks are silently dropped (no distillation).
19
+ */
20
+ export declare function formatTranscript(messages: EpisodeMessage[], llmClient: LLMClient | null): Promise<string>;
21
+ //# sourceMappingURL=distill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distill.d.ts","sourceRoot":"","sources":["../src/distill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,iBAAiB,CAAC;AAE7D,sDAAsD;AACtD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC;IACvD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,eAAO,MAAM,qBAAqB,QAMqD,CAAC;AA0BxF;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,cAAc,EAAE,EAC1B,SAAS,EAAE,SAAS,GAAG,IAAI,GAC1B,OAAO,CAAC,MAAM,CAAC,CAuDjB"}
@@ -0,0 +1,88 @@
1
+ export const DISTILL_SYSTEM_PROMPT = "You are a distillery for agentic thought and action. Given an AI agent's thinking and " +
2
+ "actions from a task, write one to two sentences in first person past tense capturing " +
3
+ "the reasoning, decisions, and actions that drove the outcome — including the whole " +
4
+ "journey of thought and intermediary steps, not just the final response. When the agent " +
5
+ "retrieved information from memory, do not restate it — note only that memory was " +
6
+ "consulted and what the agent concluded as a result. Output only the distilled text.";
7
+ async function distillOne(llmClient, thinking) {
8
+ const messages = [
9
+ { role: "system", content: DISTILL_SYSTEM_PROMPT },
10
+ { role: "user", content: thinking },
11
+ ];
12
+ return llmClient.generate(messages, 150);
13
+ }
14
+ async function safeDistill(llmClient, thinking) {
15
+ if (!thinking.trim())
16
+ return "";
17
+ try {
18
+ return await distillOne(llmClient, thinking);
19
+ }
20
+ catch (err) {
21
+ console.warn("[gralkor] behaviour distillation failed:", err instanceof Error ? err.message : err);
22
+ return "";
23
+ }
24
+ }
25
+ /**
26
+ * Format structured episode messages into a transcript, distilling behaviour blocks
27
+ * (thinking, tool_use, tool_result) into per-turn summaries via LLM.
28
+ *
29
+ * Port of server-side _format_transcript(). When llmClient is null, behaviour
30
+ * blocks are silently dropped (no distillation).
31
+ */
32
+ export async function formatTranscript(messages, llmClient) {
33
+ // Parse into turns: user message → assistant responses until next user
34
+ const turns = [{ userLines: [], behaviour: [], assistantLines: [] }];
35
+ for (const msg of messages) {
36
+ if (msg.role === "user") {
37
+ turns.push({ userLines: [], behaviour: [], assistantLines: [] });
38
+ for (const block of msg.content) {
39
+ if (block.type === "text")
40
+ turns[turns.length - 1].userLines.push(block.text);
41
+ }
42
+ }
43
+ else if (msg.role === "assistant") {
44
+ for (const block of msg.content) {
45
+ if (block.type === "thinking" || block.type === "tool_use" || block.type === "tool_result") {
46
+ turns[turns.length - 1].behaviour.push(block.text);
47
+ }
48
+ else if (block.type === "text") {
49
+ turns[turns.length - 1].assistantLines.push(block.text);
50
+ }
51
+ }
52
+ }
53
+ }
54
+ // Distill behaviour blocks — only for turns that have them
55
+ const toDistill = turns
56
+ .map((t, i) => ({ i, text: t.behaviour.join("\n---\n") }))
57
+ .filter(({ text }) => text.length > 0);
58
+ const summaries = new Map();
59
+ if (toDistill.length > 0 && llmClient) {
60
+ const texts = toDistill.map(({ text }) => text);
61
+ const sizes = texts.map((t) => t.length);
62
+ const totalChars = sizes.reduce((s, n) => s + n, 0);
63
+ console.log(`[gralkor] behaviour distillation — groups:${texts.length} sizes:[${sizes.join(",")}] totalChars:${totalChars}`);
64
+ const results = await Promise.all(texts.map((t) => safeDistill(llmClient, t)));
65
+ let succeeded = 0;
66
+ for (let j = 0; j < toDistill.length; j++) {
67
+ if (results[j]) {
68
+ summaries.set(toDistill[j].i, results[j]);
69
+ succeeded++;
70
+ }
71
+ }
72
+ console.log(`[gralkor] behaviour distilled — ${succeeded}/${texts.length} succeeded`);
73
+ }
74
+ // Format transcript
75
+ const lines = [];
76
+ for (let i = 0; i < turns.length; i++) {
77
+ const turn = turns[i];
78
+ for (const text of turn.userLines)
79
+ lines.push(`User: ${text}`);
80
+ const summary = summaries.get(i);
81
+ if (summary)
82
+ lines.push(`Assistant: (behaviour: ${summary})`);
83
+ for (const text of turn.assistantLines)
84
+ lines.push(`Assistant: ${text}`);
85
+ }
86
+ return lines.join("\n");
87
+ }
88
+ //# sourceMappingURL=distill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distill.js","sourceRoot":"","sources":["../src/distill.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,qBAAqB,GAChC,wFAAwF;IACxF,uFAAuF;IACvF,qFAAqF;IACrF,yFAAyF;IACzF,mFAAmF;IACnF,qFAAqF,CAAC;AAQxF,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AAC,CAAC;QACtB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QAC/D,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,0BAA0B,OAAO,GAAG,CAAC,CAAC;QAC9D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,cAAc;YAAE,KAAK,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
package/dist/hooks.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import type { GraphitiClient, EpisodeMessage } from "./client.js";
1
+ import type { GraphitiClient } from "./client.js";
2
2
  import type { GralkorConfig } from "./config.js";
3
3
  import { type ReadyGate } from "./config.js";
4
+ import { type EpisodeMessage } from "./distill.js";
5
+ import type { LLMClient } from "./llm-client.js";
4
6
  /**
5
7
  * A content block inside a message entry.
6
8
  */
@@ -81,10 +83,14 @@ export declare function extractMessagesFromCtx(event: AgentEndEvent): EpisodeMes
81
83
  * For non-JSON strings, returns 1 if non-empty (opaque content).
82
84
  */
83
85
  export interface RecallOpts {
84
- setGroupId?: (id: string) => void;
86
+ setSessionData?: (sessionKey: string, groupId: string) => void;
87
+ getGroupId: (sessionKey: string) => string;
85
88
  serverReady?: ReadyGate;
89
+ llmClient?: LLMClient | null;
86
90
  }
87
- export declare function createBeforePromptBuildHandler(client: GraphitiClient, config: GralkorConfig, opts?: RecallOpts): (event: PromptBuildEvent, ctx?: HookAgentContext) => Promise<{
91
+ export declare const INTERPRET_CHAR_BUDGET: number;
92
+ export declare function buildInterpretationContext(messages: MessageEntry[], factsText: string, charBudget?: number): string;
93
+ export declare function createBeforePromptBuildHandler(client: GraphitiClient, config: GralkorConfig, opts: RecallOpts): (event: PromptBuildEvent, ctx?: HookAgentContext) => Promise<{
88
94
  prependContext?: string;
89
95
  } | void>;
90
96
  /**
@@ -116,11 +122,14 @@ export declare class DebouncedFlush<T> {
116
122
  dispose(): void;
117
123
  }
118
124
  /**
119
- * Flush a session buffer → episode. Retries up to 3 times with exponential backoff.
125
+ * Flush a session buffer → episode. Distils behaviour blocks via LLM before sending.
126
+ * Retries up to 3 times with exponential backoff.
120
127
  */
121
- export declare function flushSessionBuffer(key: string, buffer: SessionBuffer, client: GraphitiClient, { retryDelayMs, test }?: {
128
+ export declare function flushSessionBuffer(key: string, buffer: SessionBuffer, client: GraphitiClient, { retryDelayMs, test, llmClient, getGroupId }: {
122
129
  retryDelayMs?: number;
123
130
  test?: boolean;
131
+ llmClient?: LLMClient | null;
132
+ getGroupId: (sessionKey: string) => string;
124
133
  }): Promise<void>;
125
134
  export declare function createAgentEndHandler(config: GralkorConfig, debouncer: DebouncedFlush<SessionBuffer>): (event: AgentEndEvent, ctx?: HookAgentContext) => Promise<void>;
126
135
  export declare function createSessionEndHandler(debouncer: DebouncedFlush<SessionBuffer>): (_event: unknown, ctx: HookSessionContext) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAgB,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,aAAa,CAAC;AAG9D;;GAEG;AACH,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,YAAY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O,aAAa,EAAE,MAAK,gBAAqB,KAAG,OAAO,CAAC,IAAI,CAAC,CAgC/E;AAGD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,cAAc,CAAC,aAAa,CAAC,IAE1B,QAAQ,OAAO,EAAE,KAAK,kBAAkB,KAAG,OAAO,CAAC,IAAI,CAAC,CAUvE"}
package/dist/hooks.js CHANGED
@@ -1,5 +1,6 @@
1
- import { sanitizeGroupId } from "./config.js";
1
+ import { runNativeIndexer } from "./native-indexer.js";
2
2
  import { formatFact, INTERPRETATION_INSTRUCTION } from "./tools.js";
3
+ import { formatTranscript } from "./distill.js";
3
4
  /**
4
5
  * Normalize message content to a ContentBlock array.
5
6
  *
@@ -217,13 +218,51 @@ export function extractMessagesFromCtx(event) {
217
218
  }
218
219
  return result;
219
220
  }
220
- export function createBeforePromptBuildHandler(client, config, opts = {}) {
221
- const { setGroupId, serverReady } = opts;
221
+ const INTERPRET_SYSTEM_PROMPT = "You are reviewing recalled memory facts for an agent mid-conversation. " +
222
+ "Given the conversation so far and the facts retrieved from memory, identify " +
223
+ "which facts are relevant to the current task and explain concisely how each " +
224
+ "one helps. Skip facts with no bearing on the current task. " +
225
+ "Be direct — one sentence per fact. Output only the interpretation, nothing else.";
226
+ const INTERPRET_TOKEN_BUDGET = 250_000;
227
+ const INTERPRET_CHARS_PER_TOKEN = 4;
228
+ export const INTERPRET_CHAR_BUDGET = INTERPRET_TOKEN_BUDGET * INTERPRET_CHARS_PER_TOKEN;
229
+ export function buildInterpretationContext(messages, factsText, charBudget = INTERPRET_CHAR_BUDGET) {
230
+ const lines = [];
231
+ for (const msg of messages) {
232
+ const blocks = normalizeContent(msg.content);
233
+ const text = blocks.filter(isTextBlock).map((b) => b.text).join(" ");
234
+ const cleaned = msg.role === "user" ? cleanUserMessageText(text) : text.trim();
235
+ if (!cleaned)
236
+ continue;
237
+ const role = msg.role === "user" ? "User" : "Assistant";
238
+ lines.push(`${role}: ${cleaned}`);
239
+ }
240
+ // Trim from oldest until within token budget; most recent always preserved
241
+ let budget = charBudget;
242
+ const trimmed = [];
243
+ for (let i = lines.length - 1; i >= 0; i--) {
244
+ if (budget <= 0)
245
+ break;
246
+ trimmed.unshift(lines[i]);
247
+ budget -= lines[i].length;
248
+ }
249
+ return `Conversation context:\n${trimmed.join("\n")}\n\nMemory facts to interpret:\n${factsText}`;
250
+ }
251
+ export function createBeforePromptBuildHandler(client, config, opts) {
252
+ const { setSessionData, getGroupId, serverReady, llmClient } = opts;
222
253
  return async (event, ctx = {}) => {
223
254
  const agentId = ctx.agentId;
224
- console.log(`[gralkor] auto-recall agentId:${agentId} promptLen:${event.prompt.length} messages:${event.messages.length}`);
225
- if (setGroupId && agentId) {
226
- setGroupId(agentId);
255
+ const sessionKey = ctx.sessionKey ?? ctx.sessionId ?? ctx.agentId ?? "default";
256
+ console.log(`[gralkor] auto-recall agentId:${agentId} sessionKey:${sessionKey} promptLen:${event.prompt.length} messages:${event.messages.length}`);
257
+ if (setSessionData) {
258
+ setSessionData(sessionKey, agentId ?? "default");
259
+ }
260
+ // Index workspace files fire-and-forget on every session start.
261
+ // Already-indexed files (marker at end) cost only a disk read — fast enough to call every session.
262
+ const indexWorkspaceDir = ctx.workspaceDir ?? config.workspaceDir;
263
+ if (indexWorkspaceDir && (!serverReady || serverReady.isReady())) {
264
+ const wGroupId = getGroupId(sessionKey);
265
+ void runNativeIndexer(client, indexWorkspaceDir, wGroupId).catch((err) => console.log(`[gralkor] native-index: failed — ${err instanceof Error ? err.message : err}`));
227
266
  }
228
267
  if (!config.autoRecall.enabled) {
229
268
  console.log(`[gralkor] auto-recall skip (disabled) — agentId:${agentId}`);
@@ -234,7 +273,7 @@ export function createBeforePromptBuildHandler(client, config, opts = {}) {
234
273
  console.log(`[gralkor] auto-recall skip (no query) — agentId:${agentId} promptLen:${event.prompt.length} messages:${event.messages.length}`);
235
274
  return;
236
275
  }
237
- const groupId = sanitizeGroupId(agentId ?? "default");
276
+ const groupId = getGroupId(sessionKey);
238
277
  try {
239
278
  const limit = config.autoRecall.maxResults;
240
279
  if (serverReady && !serverReady.isReady()) {
@@ -247,7 +286,30 @@ export function createBeforePromptBuildHandler(client, config, opts = {}) {
247
286
  ? "Facts:\n" + searchResults.facts.map(formatFact).join("\n")
248
287
  : "No facts found.";
249
288
  const furtherQuerying = "Then, search memory up to 3 times in parallel with diverse queries to understand more deeply.";
250
- const prependContext = `<gralkor-memory source="auto-recall" trust="untrusted">\n${factsText}\n\n${INTERPRETATION_INSTRUCTION} ${furtherQuerying}\n</gralkor-memory>`;
289
+ let contextBody = factsText;
290
+ let interpretationSucceeded = false;
291
+ if (factCount > 0 && llmClient) {
292
+ try {
293
+ const interpretCtx = buildInterpretationContext(event.messages, factsText);
294
+ const interpretMessages = [
295
+ { role: "system", content: INTERPRET_SYSTEM_PROMPT },
296
+ { role: "user", content: interpretCtx },
297
+ ];
298
+ const interpretation = await llmClient.generate(interpretMessages, 500);
299
+ if (interpretation) {
300
+ contextBody = `${factsText}\n\nInterpretation:\n${interpretation}`;
301
+ interpretationSucceeded = true;
302
+ console.log(`[gralkor] auto-recall interpretation — chars:${interpretation.length}`);
303
+ }
304
+ }
305
+ catch (err) {
306
+ console.warn("[gralkor] auto-recall interpretation failed, using fallback:", err instanceof Error ? err.message : err);
307
+ }
308
+ }
309
+ const trailer = interpretationSucceeded
310
+ ? furtherQuerying
311
+ : `${INTERPRETATION_INSTRUCTION} ${furtherQuerying}`;
312
+ const prependContext = `<gralkor-memory source="auto-recall" trust="untrusted">\n${contextBody}\n\nSession-key: ${sessionKey}\n${trailer}\n</gralkor-memory>`;
251
313
  if (config.test) {
252
314
  console.log(`[gralkor] [test] auto-recall query: ${userMessage}`);
253
315
  console.log(`[gralkor] [test] auto-recall context:\n${prependContext}`);
@@ -334,15 +396,16 @@ export class DebouncedFlush {
334
396
  }
335
397
  }
336
398
  /**
337
- * Flush a session buffer → episode. Retries up to 3 times with exponential backoff.
399
+ * Flush a session buffer → episode. Distils behaviour blocks via LLM before sending.
400
+ * Retries up to 3 times with exponential backoff.
338
401
  */
339
- export async function flushSessionBuffer(key, buffer, client, { retryDelayMs = 1000, test } = {}) {
402
+ export async function flushSessionBuffer(key, buffer, client, { retryDelayMs = 1000, test, llmClient = null, getGroupId }) {
340
403
  const filtered = extractMessagesFromCtx({ messages: buffer.messages });
341
404
  if (filtered.length === 0) {
342
405
  console.log(`[gralkor] auto-capture flush skip (empty) — key:${key}`);
343
406
  return;
344
407
  }
345
- const groupId = sanitizeGroupId(buffer.agentId ?? "default");
408
+ const groupId = getGroupId(key);
346
409
  const userFiltered = filtered.filter(m => m.role === "user").length;
347
410
  const assistantFiltered = filtered.filter(m => m.role === "assistant").length;
348
411
  const assistantBlocks = filtered.filter(m => m.role === "assistant").flatMap(m => m.content);
@@ -355,16 +418,20 @@ export async function flushSessionBuffer(key, buffer, client, { retryDelayMs = 1
355
418
  if (test) {
356
419
  console.log(`[gralkor] [test] episode messages:\n${JSON.stringify(filtered, null, 2)}`);
357
420
  }
421
+ const episodeBody = await formatTranscript(filtered, llmClient);
422
+ if (test) {
423
+ console.log(`[gralkor] [test] episode body:\n${episodeBody}`);
424
+ }
358
425
  const maxRetries = 3;
359
426
  let lastError;
360
427
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
361
428
  try {
362
429
  const flushStart = Date.now();
363
- await client.ingestMessages({
430
+ await client.ingestEpisode({
364
431
  name: `conversation-${Date.now()}`,
365
432
  source_description: "auto-capture",
366
433
  group_id: groupId,
367
- messages: filtered,
434
+ episode_body: episodeBody,
368
435
  });
369
436
  const flushDuration = Date.now() - flushStart;
370
437
  console.log(`[gralkor] auto-capture flushed — key:${key} duration:${flushDuration}ms`);