@chendpoc/pi-memory 0.1.0 → 0.1.11

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 (60) hide show
  1. package/README.md +156 -111
  2. package/dist/adapters/ollamaClient.d.ts +11 -0
  3. package/dist/adapters/ollamaClient.d.ts.map +1 -0
  4. package/dist/adapters/ollamaClient.js +122 -0
  5. package/dist/adapters/ollamaClient.js.map +1 -0
  6. package/dist/adapters/openaiCompatClient.d.ts +11 -0
  7. package/dist/adapters/openaiCompatClient.d.ts.map +1 -0
  8. package/dist/adapters/openaiCompatClient.js +118 -0
  9. package/dist/adapters/openaiCompatClient.js.map +1 -0
  10. package/dist/cli.js +2 -2
  11. package/dist/cli.js.map +1 -1
  12. package/dist/fallback/sessionIndex.d.ts.map +1 -1
  13. package/dist/fallback/sessionIndex.js +90 -25
  14. package/dist/fallback/sessionIndex.js.map +1 -1
  15. package/dist/fallback/sessionSearch.d.ts +1 -1
  16. package/dist/fallback/sessionSearch.d.ts.map +1 -1
  17. package/dist/fallback/sessionSearch.js +101 -28
  18. package/dist/fallback/sessionSearch.js.map +1 -1
  19. package/dist/index.d.ts +4 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +4 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/local/graphQuery.d.ts +21 -0
  24. package/dist/local/graphQuery.d.ts.map +1 -0
  25. package/dist/local/graphQuery.js +170 -0
  26. package/dist/local/graphQuery.js.map +1 -0
  27. package/dist/paths.js +1 -1
  28. package/dist/paths.js.map +1 -1
  29. package/dist/pi-extension.d.ts.map +1 -1
  30. package/dist/pi-extension.js +57 -17
  31. package/dist/pi-extension.js.map +1 -1
  32. package/dist/service.d.ts +10 -10
  33. package/dist/service.d.ts.map +1 -1
  34. package/dist/service.js +72 -30
  35. package/dist/service.js.map +1 -1
  36. package/dist/settings.d.ts +38 -0
  37. package/dist/settings.d.ts.map +1 -0
  38. package/dist/settings.js +68 -0
  39. package/dist/settings.js.map +1 -0
  40. package/dist/sidecar/process.d.ts.map +1 -1
  41. package/dist/sidecar/process.js +16 -4
  42. package/dist/sidecar/process.js.map +1 -1
  43. package/dist/trainer/sessionLoader.d.ts +2 -2
  44. package/dist/trainer/sessionLoader.d.ts.map +1 -1
  45. package/dist/trainer/sessionLoader.js +115 -39
  46. package/dist/trainer/sessionLoader.js.map +1 -1
  47. package/package.json +5 -4
  48. package/src/adapters/ollamaClient.ts +179 -0
  49. package/src/adapters/openaiCompatClient.ts +155 -0
  50. package/src/cli.ts +4 -3
  51. package/src/fallback/sessionIndex.ts +78 -40
  52. package/src/fallback/sessionSearch.ts +107 -27
  53. package/src/index.ts +26 -0
  54. package/src/local/graphQuery.ts +228 -0
  55. package/src/paths.ts +1 -1
  56. package/src/pi-extension.ts +79 -17
  57. package/src/service.ts +78 -31
  58. package/src/settings.ts +126 -0
  59. package/src/sidecar/process.ts +19 -4
  60. package/src/trainer/sessionLoader.ts +128 -42
package/README.md CHANGED
@@ -1,32 +1,29 @@
1
1
  # @chendpoc/pi-memory
2
2
 
3
- Pi Agent 本地情景记忆(**模式 B**)— TLM sidecar + `memory_recall` 工具 + **隐式 episodic preflight**。
3
+ [![npm](https://img.shields.io/npm/v/@chendpoc/pi-memory)](https://www.npmjs.com/package/@chendpoc/pi-memory)
4
4
 
5
- [Kocoro](https://github.com/Kocoro-lab/Kocoro) TLM 协议对齐:`QueryIntent` Unix socket `POST /query` `ResponseEnvelope`。
5
+ Local episodic memory for [Pi](https://pi.dev) coding agent. Automatically recalls past sessions, people, projects, and decisions during conversations.
6
6
 
7
- ## 前置条件
7
+ **No external binaries required** --- pure TypeScript, runs entirely inside Pi.
8
8
 
9
- 1. **安装 `tlm` sidecar**(与 Kocoro 相同,建议 v0.6.x+)并加入 `PATH`,或配置 `tlmPath` 绝对路径。
10
- 2. **准备本地 bundle**(自行训练或从测试环境拷贝):
9
+ ## Features
11
10
 
12
- ```text
13
- ~/.pi/memory/
14
- ├── current → bundles/2026-06-01T00-00-00Z # symlink
15
- └── bundles/
16
- └── 2026-06-01T00-00-00Z/
17
- ├── manifest.json
18
- └──
19
- ```
20
-
21
- `current` 目录下必须有可解析的 `manifest.json`(与 Kocoro `currentBundleReadable` 一致)。
11
+ - **Implicit memory preflight** --- automatically detects memory-relevant questions (Chinese/English/Japanese) and injects `<private_memory>` context before each LLM call
12
+ - **`memory_recall` tool** --- LLM can explicitly query the knowledge graph by entity/relationship
13
+ - **`memory_append` tool** --- persist user preferences and facts to `MEMORY.md`
14
+ - **Local trainer** --- extracts entities, relations, and events from Pi session history (regex or LLM-powered)
15
+ - **FTS5 search** --- SQLite full-text index for keyword fallback
16
+ - **LLM rerank** --- reranks keyword search results using `deepseek-v4-flash` for relevance scoring
17
+ - **Session dedup** --- content-hash deduplication in both trainer and indexer
18
+ - **Zero config** --- works out of the box with `pi install`
22
19
 
23
- 3. (可选)`~/.pi/MEMORY.md` — sidecar 不可用时的 fallback 关键词匹配;`~/.pi/sessions/*.json` — session 关键词 fallback。
20
+ ## Install
24
21
 
25
- ## 安装
26
-
27
- ### 作为 Pi package(推荐)
22
+ ```bash
23
+ pi install npm:@chendpoc/pi-memory
24
+ ```
28
25
 
29
- 本地开发(settings 相对路径):
26
+ Or for local development:
30
27
 
31
28
  ```json
32
29
  {
@@ -34,147 +31,195 @@ Pi Agent 本地情景记忆(**模式 B**)— TLM sidecar + `memory_recall`
34
31
  }
35
32
  ```
36
33
 
37
- 或发布后:
34
+ Pi reads `package.json` > `pi.extensions` and auto-loads the extension via [jiti](https://github.com/unjs/jiti) (TypeScript, no build step needed).
35
+
36
+ ## Quick Start
38
37
 
39
38
  ```bash
39
+ # 1. Install the package
40
40
  pi install npm:@chendpoc/pi-memory
41
- ```
42
-
43
- `package.json` 中已声明 `pi.extensions`,Pi 会自动加载 `src/pi-extension.ts`。
44
41
 
45
- ### 构建 CLI /
42
+ # 2. Train a memory bundle from your session history
43
+ npx pi-memory train --full
46
44
 
47
- ```bash
48
- cd agent/extensions/pi-memory
49
- npm install
50
- npm run build
45
+ # 3. Restart Pi --- memory is now active
46
+ # Try asking: "What projects have I worked on?"
51
47
  ```
52
48
 
53
- ## CLI 手动测试
49
+ After training, Pi will:
50
+ - Show `status: ready, mode: local_graph` when you type `/memory`
51
+ - Automatically inject past context when you ask relationship questions
52
+ - Let the LLM call `memory_recall` for explicit lookups
54
53
 
55
- ```bash
56
- # 检查 sidecar 健康(会尝试 spawn tlm)
57
- npx pi-memory health
58
-
59
- # 结构化查询
60
- npx pi-memory query '{"mode":"direct_relation","anchor_mentions":["Alice"]}'
54
+ ## How It Works
61
55
 
62
- # 安装本地 bundle(staging → bundles/<ts> → current symlink,sidecar 在跑时会 /bundle/reload)
63
- npx pi-memory install-bundle ./path/to/bundle-dir
56
+ ```
57
+ Pi session files (.jsonl)
58
+ |
59
+ v
60
+ Trainer (regex or LLM extraction)
61
+ |
62
+ v
63
+ graph.json bundle (entities + relations + events)
64
+ |
65
+ v
66
+ LocalGraphQuerier (in-memory graph query)
67
+ |
68
+ v
69
+ memory_recall tool / implicit preflight injection
64
70
  ```
65
71
 
66
- ## Pi Agent 中启用
67
-
68
- 本包已对接 `@earendil-works/pi-coding-agent` 的 `ExtensionAPI`:
72
+ ### Query Backends
69
73
 
70
- | stub API | Pi 真实 API |
71
- |-------------|-------------|
72
- | factory 内 `service.start()` | `session_start` |
73
- | `onUnload` | `session_shutdown` |
74
- | `registerTool` | `pi.registerTool`(TypeBox 参数) |
75
- | `onBeforeTurn` | `context` 事件(LLM 调用前注入,不写入 session) |
74
+ The service automatically selects the best available backend:
76
75
 
77
- 扩展加载后:
76
+ | Priority | Backend | Requires |
77
+ |----------|---------|----------|
78
+ | 1 | **LocalGraphQuerier** (in-process) | bundle only |
79
+ | 2 | **FTS5 + keyword fallback** | `better-sqlite3` (optional) |
78
80
 
79
- 1. **`session_start`** `MemoryService.start()` spawn `tlm serve`
80
- 2. 注册 **`memory_recall`** 工具(sidecar 不可用时 fallback 到 session JSON + MEMORY.md)
81
- 3. 注册 **`memory_append`** 工具(追加 `~/.pi/MEMORY.md`)
82
- 4. **`context` 事件** — 隐式 preflight,注入 `<private_memory>` 到当次 LLM 请求的 messages 副本
81
+ The default backend is LocalGraphQuerier --- pure TypeScript, no external dependencies.
83
82
 
84
- Helper 小模型通过 `@earendil-works/pi-ai/compat` 的 `complete()` 调用,默认 `deepseek/deepseek-v4-flash`:
83
+ ## Commands
85
84
 
86
- ```bash
87
- pi --memory-helper-model deepseek/deepseek-v4-flash
88
- ```
85
+ | Command | Description |
86
+ |---------|-------------|
87
+ | `/memory` | Show service status, query mode, and bundle info |
89
88
 
90
- ### Pi 命令
89
+ ## CLI
91
90
 
92
- - `/memory` — 显示 sidecar 状态、reason 与 health 摘要
91
+ ```bash
92
+ # Train a bundle from session history
93
+ npx pi-memory train --full # full rebuild
94
+ npx pi-memory train # incremental (only new sessions)
95
+ npx pi-memory train --extractor llm # use LLM for deeper extraction
96
+ npx pi-memory train --extractor llm --model deepseek/deepseek-v4-flash
93
97
 
94
- 也可程序化 import:
98
+ # Query the knowledge graph
99
+ npx pi-memory query '{"mode":"direct_relation","anchor_mentions":["Alice"]}'
95
100
 
96
- ```typescript
97
- import piMemory from "@chendpoc/pi-memory/extension";
98
- export default piMemory;
99
- ```
101
+ # Service diagnostics
102
+ npx pi-memory health
103
+ npx pi-memory status
100
104
 
101
- **持久化:** `context` 事件修改的是 messages 深拷贝,`<private_memory>` 不会写入 session JSON,无需额外 `stripPrivateMemory`。
105
+ # Manage bundles
106
+ npx pi-memory install-bundle ./path/to/bundle
102
107
 
103
- ## 隐式 Episodic Preflight
108
+ # Rebuild FTS5 search index
109
+ npx pi-memory index
104
110
 
105
- 在每轮 LLM 调用**之前**,通过 `context` 事件检测是否需要召回私人情景记忆,并将结果注入 `<private_memory>` 块。
111
+ # Continuous training (watch mode)
112
+ npx pi-memory train --watch
113
+ ```
106
114
 
107
- ### 工作流程
115
+ ## Flags
108
116
 
109
- 1. **Intent 检测** 中/英/日关系问句正则快路径;可选 `MemoryHelperLLM`(`compile_memory_intents` forced tool_use,由 `complete()` 驱动)。
110
- 2. **批量查询** — 对最多 3 个 intent 并发调用 sidecar,`2s` 超时,失败静默跳过。
111
- 3. **渲染** 组装 `<private_memory>` 正文,**8192 字节**上限。
112
- 4. **注入** — 通过 `context` 事件写回最后一条 user message。
117
+ | Flag | Description | Default |
118
+ |------|-------------|---------|
119
+ | `--memory-helper-model` | LLM model for intent detection and rerank | `deepseek/deepseek-v4-flash` |
113
120
 
114
- ### Helper LLM(Pi 集成)
121
+ ```bash
122
+ pi --memory-helper-model deepseek/deepseek-v4-flash
123
+ ```
115
124
 
116
- ```typescript
117
- import { resolveMemoryHelperLLM } from "@chendpoc/pi-memory";
125
+ ## Data Layout
118
126
 
119
- // 在 extension 的 context handler 中:
120
- const helper = await resolveMemoryHelperLLM(ctx, pi.getFlag("memory-helper-model"));
127
+ ```
128
+ ~/.pi/
129
+ ├── memory/
130
+ │ ├── current/ # active bundle (symlink)
131
+ │ │ ├── manifest.json
132
+ │ │ └── graph.json # entities, edges, events
133
+ │ ├── bundles/ # historical bundles
134
+ │ ├── sessions.db # FTS5 search index
135
+ │ └── .train_marker # incremental training timestamp
136
+ ├── agent/sessions/ # Pi session files (.jsonl)
137
+ └── MEMORY.md # persistent notes (memory_append target)
121
138
  ```
122
139
 
123
- `helper` `null` 时仅走正则快路径(fail-silent)。
140
+ ## Programmatic API
124
141
 
125
- ## 架构
142
+ ```typescript
143
+ import {
144
+ MemoryService,
145
+ defaultMemoryConfig,
146
+ trainBundle,
147
+ LocalGraphQuerier,
148
+ createLLMFactExtractor,
149
+ createStandaloneLLMClient,
150
+ rerankWithLLM,
151
+ } from "@chendpoc/pi-memory";
152
+
153
+ // --- Query the graph directly ---
154
+ const querier = new LocalGraphQuerier("/Users/you/.pi/memory");
155
+ querier.load();
156
+ const result = querier.query({
157
+ mode: "direct_relation",
158
+ anchor_mentions: ["Alice"],
159
+ });
126
160
 
127
- | 模块 | 作用 |
128
- |------|------|
129
- | `src/pi-extension.ts` | Pi ExtensionAPI 入口 |
130
- | `src/adapters/piComplete.ts` | `complete()` 适配(helper + trainer LLM) |
131
- | `SidecarProcess` | spawn / waitReady / stop |
132
- | `SidecarClient` | `/health`, `/query`, `/bundle/reload` |
133
- | `MemoryService` | 本地模式生命周期 + query / queryBatch |
134
- | `MemoryRecallTool` | Agent 工具 + session/MEMORY.md fallback |
135
- | `memory_append` | 追加 MEMORY.md |
136
- | `preflight/*` | 隐式 preflight detect → query → render → inject/strip |
137
- | `bundle/install` | `install-bundle` CLI |
161
+ // --- Train a bundle ---
162
+ const result = await trainBundle({
163
+ sessionsDir: "~/.pi/agent/sessions",
164
+ bundleRoot: "~/.pi/memory",
165
+ full: true,
166
+ });
138
167
 
139
- ## LLM 深度提取(Trainer)
168
+ // --- Train with LLM extraction ---
169
+ const client = createStandaloneLLMClient("deepseek/deepseek-v4-flash");
170
+ const extractor = createLLMFactExtractor({ client, batchSize: 10 });
171
+ await trainBundle({ extractOpts: { llmExtractor: extractor } });
140
172
 
141
- 使用 `@earendil-works/pi-ai/compat` `complete()`,不绑定具体 LLM 厂商:
173
+ // --- Use as Pi extension ---
174
+ import piMemory from "@chendpoc/pi-memory/extension";
175
+ export default piMemory;
176
+ ```
142
177
 
143
- ```typescript
144
- import { createLLMFactExtractor, createStandaloneLLMClient, trainBundle } from "@chendpoc/pi-memory";
178
+ ## Architecture
145
179
 
146
- const extractor = createLLMFactExtractor({
147
- client: createStandaloneLLMClient("deepseek/deepseek-v4-flash"),
148
- batchSize: 10,
149
- });
150
- ```
180
+ | Module | Purpose |
181
+ |--------|---------|
182
+ | `src/pi-extension.ts` | Pi ExtensionAPI entry point |
183
+ | `src/local/graphQuery.ts` | In-process graph query engine |
184
+ | `src/adapters/piComplete.ts` | LLM adapter via `@earendil-works/pi-ai/compat` |
185
+ | `src/service.ts` | Service lifecycle and query routing |
186
+ | `src/trainer/` | Session loader, fact extraction, entity resolution, bundle builder |
187
+ | `src/fallback/` | FTS5 index, keyword search, LLM rerank |
188
+ | `src/preflight/` | Intent detection, private memory render/inject/strip |
189
+ | `src/tools/` | `memory_recall` and `memory_append` tool definitions |
151
190
 
152
- CLI:
191
+ ## Implicit Preflight
153
192
 
154
- ```bash
155
- pi-memory train --extractor llm
156
- pi-memory train --extractor llm --model deepseek/deepseek-v4-flash
157
- pi-memory train --extractor regex
158
- ```
193
+ On every LLM call, the `context` event:
159
194
 
160
- 需配置对应 provider 的环境变量(如 `DEEPSEEK_API_KEY`)。LLM 不可用时 CLI 自动回退 regex。
195
+ 1. Detects memory-relevant intents via regex (Chinese/English/Japanese relationship patterns)
196
+ 2. Optionally calls a helper LLM (`compile_memory_intents` forced tool_use)
197
+ 3. Queries the graph for matching entities/relations
198
+ 4. Injects a `<private_memory>` block into the user message (deep copy, not persisted to session)
199
+ 5. Results are cached per agent loop to avoid redundant queries during multi-tool turns
161
200
 
162
- ## peerDependencies
201
+ ## Peer Dependencies
163
202
 
164
- Pi 核心包由 host 提供,列在 `peerDependencies` 中,勿 bundle:
203
+ These are provided by the Pi host and should not be bundled:
165
204
 
205
+ - `@earendil-works/pi-agent-core`
166
206
  - `@earendil-works/pi-ai`
167
207
  - `@earendil-works/pi-coding-agent`
168
208
  - `typebox`
169
209
 
170
- ## 开发
210
+ ## Optional Dependencies
211
+
212
+ - `better-sqlite3` --- enables FTS5 session search index (graceful degradation if absent)
213
+
214
+ ## Development
171
215
 
172
216
  ```bash
173
- npm test
174
- npm run typecheck
217
+ npm install
175
218
  npm run build
219
+ npm test # 129 tests
220
+ npm run typecheck
176
221
  ```
177
222
 
178
- ## 许可
223
+ ## License
179
224
 
180
225
  MIT
@@ -0,0 +1,11 @@
1
+ import type { LLMClient } from "../trainer/llmExtractor.js";
2
+ import type { MemoryHelperLLM } from "../preflight/detectIntents.js";
3
+ export interface OllamaConfig {
4
+ baseUrl: string;
5
+ model: string;
6
+ }
7
+ export declare const DEFAULT_OLLAMA_CONFIG: OllamaConfig;
8
+ export declare function ollamaHealthCheck(baseUrl: string): Promise<boolean>;
9
+ export declare function createOllamaLLMClient(cfg: OllamaConfig): LLMClient;
10
+ export declare function createOllamaMemoryHelper(cfg: OllamaConfig): MemoryHelperLLM;
11
+ //# sourceMappingURL=ollamaClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ollamaClient.d.ts","sourceRoot":"","sources":["../../src/adapters/ollamaClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAOrE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,qBAAqB,EAAE,YAGnC,CAAC;AAiFF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAezE;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,YAAY,GAAG,SAAS,CAgBlE;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,YAAY,GAAG,eAAe,CA2C3E"}
@@ -0,0 +1,122 @@
1
+ import http from "node:http";
2
+ import https from "node:https";
3
+ import { COMPILE_MEMORY_INTENTS_PARAMETERS, MEMORY_HELPER_TOOL_NAME, } from "../preflight/detectIntents.js";
4
+ export const DEFAULT_OLLAMA_CONFIG = {
5
+ baseUrl: "http://localhost:11434",
6
+ model: "qwen3:8b",
7
+ };
8
+ async function ollamaRequest(baseUrl, path, body) {
9
+ const url = new URL(path, baseUrl);
10
+ const mod = url.protocol === "https:" ? https : http;
11
+ const payload = JSON.stringify(body);
12
+ return new Promise((resolve, reject) => {
13
+ const req = mod.request(url, {
14
+ method: "POST",
15
+ headers: {
16
+ "Content-Type": "application/json",
17
+ "Content-Length": Buffer.byteLength(payload),
18
+ },
19
+ timeout: 60_000,
20
+ }, (res) => {
21
+ const chunks = [];
22
+ res.on("data", (c) => chunks.push(c));
23
+ res.on("end", () => {
24
+ const text = Buffer.concat(chunks).toString("utf8");
25
+ try {
26
+ resolve(JSON.parse(text));
27
+ }
28
+ catch {
29
+ reject(new Error(`Ollama: invalid JSON response: ${text.slice(0, 200)}`));
30
+ }
31
+ });
32
+ });
33
+ req.on("error", (err) => reject(new Error(`Ollama: ${err.message}`)));
34
+ req.on("timeout", () => {
35
+ req.destroy();
36
+ reject(new Error("Ollama: request timeout"));
37
+ });
38
+ req.write(payload);
39
+ req.end();
40
+ });
41
+ }
42
+ export async function ollamaHealthCheck(baseUrl) {
43
+ try {
44
+ const url = new URL("/api/tags", baseUrl);
45
+ const mod = url.protocol === "https:" ? https : http;
46
+ return new Promise((resolve) => {
47
+ const req = mod.get(url, { timeout: 3_000 }, (res) => {
48
+ res.resume();
49
+ resolve(res.statusCode === 200);
50
+ });
51
+ req.on("error", () => resolve(false));
52
+ req.on("timeout", () => { req.destroy(); resolve(false); });
53
+ });
54
+ }
55
+ catch {
56
+ return false;
57
+ }
58
+ }
59
+ export function createOllamaLLMClient(cfg) {
60
+ return {
61
+ async complete(prompt) {
62
+ const body = {
63
+ model: cfg.model,
64
+ messages: [{ role: "user", content: prompt }],
65
+ stream: false,
66
+ options: { num_predict: 8192 },
67
+ };
68
+ const resp = await ollamaRequest(cfg.baseUrl, "/api/chat", body);
69
+ if (resp.error)
70
+ throw new Error(`Ollama: ${resp.error}`);
71
+ const text = resp.message?.content?.trim();
72
+ if (!text)
73
+ throw new Error("Ollama: empty response");
74
+ return text;
75
+ },
76
+ };
77
+ }
78
+ export function createOllamaMemoryHelper(cfg) {
79
+ return {
80
+ async compileIntents(text) {
81
+ const body = {
82
+ model: cfg.model,
83
+ messages: [
84
+ {
85
+ role: "user",
86
+ content: `Analyze whether the user message requires recalling private episodic memory.\n\n<message>\n${text}\n</message>`,
87
+ },
88
+ ],
89
+ stream: false,
90
+ tools: [
91
+ {
92
+ type: "function",
93
+ function: {
94
+ name: MEMORY_HELPER_TOOL_NAME,
95
+ description: "Decide whether to recall private episodic memory and compile structured query intents.",
96
+ parameters: COMPILE_MEMORY_INTENTS_PARAMETERS,
97
+ },
98
+ },
99
+ ],
100
+ options: { num_predict: 2048 },
101
+ };
102
+ const resp = await ollamaRequest(cfg.baseUrl, "/api/chat", body);
103
+ if (resp.error)
104
+ throw new Error(`Ollama: ${resp.error}`);
105
+ const toolCall = resp.message?.tool_calls?.[0]?.function;
106
+ if (toolCall?.name === MEMORY_HELPER_TOOL_NAME && toolCall.arguments) {
107
+ return toolCall.arguments;
108
+ }
109
+ const raw = resp.message?.content?.trim();
110
+ if (!raw)
111
+ return { should_recall: false, intents: [] };
112
+ try {
113
+ const cleaned = raw.replace(/^```(?:json)?\s*/m, "").replace(/\s*```\s*$/m, "").trim();
114
+ return JSON.parse(cleaned);
115
+ }
116
+ catch {
117
+ return { should_recall: false, intents: [] };
118
+ }
119
+ },
120
+ };
121
+ }
122
+ //# sourceMappingURL=ollamaClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ollamaClient.js","sourceRoot":"","sources":["../../src/adapters/ollamaClient.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAK/B,OAAO,EACL,iCAAiC,EACjC,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AAOvC,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,OAAO,EAAE,wBAAwB;IACjC,KAAK,EAAE,UAAU;CAClB,CAAC;AAsCF,KAAK,UAAU,aAAa,CAC1B,OAAe,EACf,IAAY,EACZ,IAAa;IAEb,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD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gBAAE,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YAEzD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC;YACzD,IAAI,QAAQ,EAAE,IAAI,KAAK,uBAAuB,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;gBACrE,OAAO,QAAQ,CAAC,SAAkD,CAAC;YACrE,CAAC;YAED,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC1C,IAAI,CAAC,GAAG;gBAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YAEvD,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;gBACvF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAA+B,CAAC;YAC3D,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YAC/C,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { LLMClient } from "../trainer/llmExtractor.js";
2
+ import type { MemoryHelperLLM } from "../preflight/detectIntents.js";
3
+ export interface OpenAICompatConfig {
4
+ baseUrl: string;
5
+ model: string;
6
+ apiKey?: string;
7
+ }
8
+ export declare function openaiCompatHealthCheck(baseUrl: string): Promise<boolean>;
9
+ export declare function createOpenAICompatLLMClient(cfg: OpenAICompatConfig): LLMClient;
10
+ export declare function createOpenAICompatMemoryHelper(cfg: OpenAICompatConfig): MemoryHelperLLM;
11
+ //# sourceMappingURL=openaiCompatClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openaiCompatClient.d.ts","sourceRoot":"","sources":["../../src/adapters/openaiCompatClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAOrE,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAyDD,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAe/E;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,kBAAkB,GAAG,SAAS,CAgB9E;AAED,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,kBAAkB,GAAG,eAAe,CA+CvF"}
@@ -0,0 +1,118 @@
1
+ import http from "node:http";
2
+ import https from "node:https";
3
+ import { COMPILE_MEMORY_INTENTS_PARAMETERS, MEMORY_HELPER_TOOL_NAME, } from "../preflight/detectIntents.js";
4
+ async function postJSON(url, body, apiKey) {
5
+ const mod = url.protocol === "https:" ? https : http;
6
+ const payload = JSON.stringify(body);
7
+ return new Promise((resolve, reject) => {
8
+ const headers = {
9
+ "Content-Type": "application/json",
10
+ "Content-Length": String(Buffer.byteLength(payload)),
11
+ };
12
+ if (apiKey)
13
+ headers["Authorization"] = `Bearer ${apiKey}`;
14
+ const req = mod.request(url, { method: "POST", headers, timeout: 120_000 }, (res) => {
15
+ const chunks = [];
16
+ res.on("data", (c) => chunks.push(c));
17
+ res.on("end", () => {
18
+ const text = Buffer.concat(chunks).toString("utf8");
19
+ try {
20
+ resolve(JSON.parse(text));
21
+ }
22
+ catch {
23
+ reject(new Error(`OpenAI-compat: invalid JSON: ${text.slice(0, 200)}`));
24
+ }
25
+ });
26
+ });
27
+ req.on("error", (err) => reject(new Error(`OpenAI-compat: ${err.message}`)));
28
+ req.on("timeout", () => { req.destroy(); reject(new Error("OpenAI-compat: timeout")); });
29
+ req.write(payload);
30
+ req.end();
31
+ });
32
+ }
33
+ export async function openaiCompatHealthCheck(baseUrl) {
34
+ try {
35
+ const url = new URL("/v1/models", baseUrl);
36
+ const mod = url.protocol === "https:" ? https : http;
37
+ return new Promise((resolve) => {
38
+ const req = mod.get(url, { timeout: 3_000 }, (res) => {
39
+ res.resume();
40
+ resolve(res.statusCode === 200);
41
+ });
42
+ req.on("error", () => resolve(false));
43
+ req.on("timeout", () => { req.destroy(); resolve(false); });
44
+ });
45
+ }
46
+ catch {
47
+ return false;
48
+ }
49
+ }
50
+ export function createOpenAICompatLLMClient(cfg) {
51
+ return {
52
+ async complete(prompt) {
53
+ const url = new URL("/v1/chat/completions", cfg.baseUrl);
54
+ const body = {
55
+ model: cfg.model,
56
+ messages: [{ role: "user", content: prompt }],
57
+ max_tokens: 8192,
58
+ };
59
+ const resp = await postJSON(url, body, cfg.apiKey);
60
+ if (resp.error?.message)
61
+ throw new Error(`OpenAI-compat: ${resp.error.message}`);
62
+ const text = resp.choices?.[0]?.message?.content?.trim();
63
+ if (!text)
64
+ throw new Error("OpenAI-compat: empty response");
65
+ return text;
66
+ },
67
+ };
68
+ }
69
+ export function createOpenAICompatMemoryHelper(cfg) {
70
+ return {
71
+ async compileIntents(text) {
72
+ const url = new URL("/v1/chat/completions", cfg.baseUrl);
73
+ const body = {
74
+ model: cfg.model,
75
+ messages: [
76
+ {
77
+ role: "user",
78
+ content: `Analyze whether the user message requires recalling private episodic memory.\n\n<message>\n${text}\n</message>`,
79
+ },
80
+ ],
81
+ max_tokens: 2048,
82
+ tools: [
83
+ {
84
+ type: "function",
85
+ function: {
86
+ name: MEMORY_HELPER_TOOL_NAME,
87
+ description: "Decide whether to recall private episodic memory and compile structured query intents.",
88
+ parameters: COMPILE_MEMORY_INTENTS_PARAMETERS,
89
+ },
90
+ },
91
+ ],
92
+ tool_choice: { type: "function", function: { name: MEMORY_HELPER_TOOL_NAME } },
93
+ };
94
+ const resp = await postJSON(url, body, cfg.apiKey);
95
+ if (resp.error?.message)
96
+ throw new Error(`OpenAI-compat: ${resp.error.message}`);
97
+ const msg = resp.choices?.[0]?.message;
98
+ const toolCall = msg?.tool_calls?.[0]?.function;
99
+ if (toolCall?.name === MEMORY_HELPER_TOOL_NAME && toolCall.arguments) {
100
+ try {
101
+ return JSON.parse(toolCall.arguments);
102
+ }
103
+ catch { /* fall through */ }
104
+ }
105
+ const raw = msg?.content?.trim();
106
+ if (!raw)
107
+ return { should_recall: false, intents: [] };
108
+ try {
109
+ const cleaned = raw.replace(/^```(?:json)?\s*/m, "").replace(/\s*```\s*$/m, "").trim();
110
+ return JSON.parse(cleaned);
111
+ }
112
+ catch {
113
+ return { should_recall: false, intents: [] };
114
+ }
115
+ },
116
+ };
117
+ }
118
+ //# sourceMappingURL=openaiCompatClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openaiCompatClient.js","sourceRoot":"","sources":["../../src/adapters/openaiCompatClient.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAK/B,OAAO,EACL,iCAAiC,EACjC,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AAoCvC,KAAK,UAAU,QAAQ,CAAI,GAAQ,EAAE,IAAa,EAAE,MAAe;IACjE,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAErC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAA2B;YACtC,cAAc,EAAE,kBAAkB;YAClC,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAA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"node:path";
4
4
  import { createStandaloneLLMClient } from "./adapters/piComplete.js";
5
5
  import { installBundle } from "./bundle/install.js";
6
- import { defaultMemoryConfig } from "./config.js";
6
+ import { loadMemoryConfig } from "./settings.js";
7
7
  import { openSessionIndex } from "./fallback/sessionIndex.js";
8
8
  import { SidecarClient } from "./sidecar/client.js";
9
9
  import { MemoryService } from "./service.js";
@@ -31,7 +31,7 @@ async function main() {
31
31
  printHelp();
32
32
  process.exit(0);
33
33
  }
34
- const cfg = defaultMemoryConfig();
34
+ const cfg = loadMemoryConfig();
35
35
  const service = new MemoryService(cfg);
36
36
  if (cmd === "health") {
37
37
  await service.start();