@yeaft/webchat-agent 0.1.665 → 0.1.667
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/connection/message-router.js +1 -24
- package/package.json +1 -1
- package/unify/cli.js +5 -84
- package/unify/config.js +2 -2
- package/unify/dream-v2/apply.js +1 -1
- package/unify/dream-v2/limits.js +1 -1
- package/unify/dream-v2/merge.js +1 -1
- package/unify/dream-v2/runner.js +2 -2
- package/unify/dream-v2/schedule.js +2 -2
- package/unify/dream-v2/segment.js +1 -1
- package/unify/dream-v2/session-wiring.js +2 -3
- package/unify/dream-v2/snapshot.js +1 -1
- package/unify/dream-v2/state.js +1 -1
- package/unify/dream-v2/triage.js +1 -1
- package/unify/engine.js +23 -133
- package/unify/eval/cases/memory.js +9 -142
- package/unify/features/summary.js +15 -98
- package/unify/index.js +0 -2
- package/unify/memory/ams.js +1 -1
- package/unify/memory/consolidate.js +10 -125
- package/unify/memory/segment-store.js +1 -1
- package/unify/memory/store-v2.js +6 -9
- package/unify/prompts.js +8 -50
- package/unify/session.js +2 -22
- package/unify/stop-hooks.js +8 -44
- package/unify/tools/index.js +0 -11
- package/unify/web-bridge.js +0 -98
- package/unify/memory/dream-shard.js +0 -722
- package/unify/memory/extract.js +0 -101
- package/unify/memory/layout.js +0 -358
- package/unify/memory/schema.js +0 -166
- package/unify/memory/shard-store.js +0 -373
- package/unify/memory/store.js +0 -578
- package/unify/memory/types.js +0 -139
- package/unify/memory/user-memory-store.js +0 -452
- package/unify/tools/memory-query.js +0 -134
- package/unify/tools/memory-read.js +0 -90
- package/unify/tools/memory-search.js +0 -140
- package/unify/tools/memory-trace.js +0 -135
- package/unify/tools/memory-write.js +0 -113
- package/unify/user-memory.js +0 -107
package/unify/session.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Wires all subsystems together:
|
|
7
7
|
* initYeaftDir → loadConfig → createTrace → createLLMAdapter →
|
|
8
|
-
* ConversationStore →
|
|
8
|
+
* ConversationStore → SkillManager → MCPManager →
|
|
9
9
|
* ToolRegistry → Engine → Session
|
|
10
10
|
*
|
|
11
11
|
* The ~/.yeaft/ directory is the agent's persistent workspace.
|
|
@@ -18,8 +18,6 @@ import { loadConfig, loadMCPConfig } from './config.js';
|
|
|
18
18
|
import { createTrace } from './debug-trace.js';
|
|
19
19
|
import { createLLMAdapter } from './llm/adapter.js';
|
|
20
20
|
import { ConversationStore } from './conversation/persist.js';
|
|
21
|
-
import { MemoryStore } from './memory/store.js';
|
|
22
|
-
import { openMemoryShardStore } from './memory/shard-store.js';
|
|
23
21
|
import { SkillManager, createSkillManager } from './skills.js';
|
|
24
22
|
import { MCPManager } from './mcp.js';
|
|
25
23
|
import { createFullRegistry } from './tools/index.js';
|
|
@@ -68,7 +66,6 @@ import { existsSync as existsSyncSafe, readFileSync as readFileSyncSafe } from '
|
|
|
68
66
|
* @property {import('./llm/adapter.js').LLMAdapter} adapter — The LLM adapter
|
|
69
67
|
* @property {object} config — Resolved configuration
|
|
70
68
|
* @property {ConversationStore} conversationStore — Conversation persistence
|
|
71
|
-
* @property {MemoryStore} memoryStore — Memory persistence
|
|
72
69
|
* @property {SkillManager} skillManager — Skill manager
|
|
73
70
|
* @property {MCPManager} mcpManager — MCP manager
|
|
74
71
|
* @property {import('./tools/registry.js').ToolRegistry} toolRegistry — Tool registry
|
|
@@ -169,19 +166,6 @@ export async function loadSession(options = {}) {
|
|
|
169
166
|
|
|
170
167
|
// ─── 5. Create stores ──────────────────────────────────
|
|
171
168
|
const conversationStore = new ConversationStore(yeaftDir);
|
|
172
|
-
const memoryStore = new MemoryStore(yeaftDir);
|
|
173
|
-
|
|
174
|
-
// ─── 5-shard. Open R6 memory shard store (task-334f) ──────
|
|
175
|
-
// VP-level memory shard store rooted at ~/.yeaft/memory/vp/default.
|
|
176
|
-
// The 'default' VP matches the single-user Unify mode; R6 multi-VP
|
|
177
|
-
// callers open per-VP stores via openMemoryShardStore() directly.
|
|
178
|
-
const memoryShardDir = join(yeaftDir, 'memory', 'vp', 'default');
|
|
179
|
-
let memoryShardStore = null;
|
|
180
|
-
try {
|
|
181
|
-
memoryShardStore = openMemoryShardStore(memoryShardDir, 'vp');
|
|
182
|
-
} catch (err) {
|
|
183
|
-
console.warn(`[Yeaft] Failed to open R6 memory shard store: ${err?.message || err}`);
|
|
184
|
-
}
|
|
185
169
|
|
|
186
170
|
// ─── 5-fts. (GC.1) Open SegmentIndex for FTS pre-flow ────
|
|
187
171
|
// When config.memoryV2 is on, build a SQLite FTS5 index over
|
|
@@ -290,8 +274,6 @@ export async function loadSession(options = {}) {
|
|
|
290
274
|
trace,
|
|
291
275
|
config,
|
|
292
276
|
conversationStore,
|
|
293
|
-
memoryStore,
|
|
294
|
-
memoryShardStore,
|
|
295
277
|
memoryIndex,
|
|
296
278
|
amsRegistry,
|
|
297
279
|
toolRegistry,
|
|
@@ -300,7 +282,7 @@ export async function loadSession(options = {}) {
|
|
|
300
282
|
yeaftDir,
|
|
301
283
|
});
|
|
302
284
|
|
|
303
|
-
// ─── 9a. Create dream scheduler
|
|
285
|
+
// ─── 9a. Create dream scheduler ────────────
|
|
304
286
|
// The legacy R6 dream-scheduler was retired alongside recall-r6;
|
|
305
287
|
// dream-v2 is the only active path. The `memoryV2: false` opt-out
|
|
306
288
|
// no longer leaves a usable system, so we always wire v2 here.
|
|
@@ -363,8 +345,6 @@ export async function loadSession(options = {}) {
|
|
|
363
345
|
adapter,
|
|
364
346
|
config,
|
|
365
347
|
conversationStore,
|
|
366
|
-
memoryStore,
|
|
367
|
-
memoryShardStore,
|
|
368
348
|
dreamScheduler,
|
|
369
349
|
skillManager,
|
|
370
350
|
mcpManager,
|
package/unify/stop-hooks.js
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Runs after each query loop completes:
|
|
5
5
|
* 1. Persist messages to conversation/messages/
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* Consolidation (compact orchestrator) is driven by the engine itself
|
|
8
|
+
* via `#maybeConsolidate`; the legacy LLM-driven `consolidate()` plus
|
|
9
|
+
* entries-store extraction was retired in the H2-AMS rip.
|
|
7
10
|
*
|
|
8
11
|
* Dream V2 owns all background memory maintenance (scope summaries +
|
|
9
|
-
* memory writes via dream-v2/session-wiring.js → createV2DreamScheduler)
|
|
10
|
-
* the legacy `memory/dream.js` gate that used to fire here was retired
|
|
11
|
-
* alongside recall-r6.
|
|
12
|
+
* memory writes via dream-v2/session-wiring.js → createV2DreamScheduler).
|
|
12
13
|
*
|
|
13
14
|
* Reference: yeaft-unify-core-systems.md §4.4
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
|
-
import { shouldConsolidate, consolidate } from './memory/consolidate.js';
|
|
17
17
|
import { isPermissionError } from './init.js';
|
|
18
18
|
|
|
19
19
|
/** Track whether we've already warned about permission issues in stop hooks. */
|
|
@@ -26,7 +26,6 @@ let _permissionWarned = false;
|
|
|
26
26
|
* yeaftDir: string,
|
|
27
27
|
* mode: string,
|
|
28
28
|
* conversationStore: import('./conversation/persist.js').ConversationStore,
|
|
29
|
-
* memoryStore: import('./memory/store.js').MemoryStore,
|
|
30
29
|
* adapter: object,
|
|
31
30
|
* config: object,
|
|
32
31
|
* primaryModel?: string,
|
|
@@ -42,7 +41,6 @@ export async function runStopHooks(context) {
|
|
|
42
41
|
yeaftDir,
|
|
43
42
|
mode,
|
|
44
43
|
conversationStore,
|
|
45
|
-
memoryStore,
|
|
46
44
|
adapter,
|
|
47
45
|
config,
|
|
48
46
|
primaryModel,
|
|
@@ -60,7 +58,6 @@ export async function runStopHooks(context) {
|
|
|
60
58
|
|
|
61
59
|
const result = {
|
|
62
60
|
messagesPersisted: 0,
|
|
63
|
-
consolidated: false,
|
|
64
61
|
errors: [],
|
|
65
62
|
};
|
|
66
63
|
|
|
@@ -133,41 +130,9 @@ export async function runStopHooks(context) {
|
|
|
133
130
|
}
|
|
134
131
|
}
|
|
135
132
|
|
|
136
|
-
// 2.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (shouldConsolidate(conversationStore, config.messageTokenBudget)) {
|
|
140
|
-
const consolidated = await consolidate({
|
|
141
|
-
conversationStore,
|
|
142
|
-
memoryStore,
|
|
143
|
-
adapter,
|
|
144
|
-
config,
|
|
145
|
-
budget: config.messageTokenBudget,
|
|
146
|
-
});
|
|
147
|
-
result.consolidated = true;
|
|
148
|
-
trace?.logEvent({
|
|
149
|
-
eventType: 'consolidate',
|
|
150
|
-
eventData: {
|
|
151
|
-
archivedCount: consolidated.archivedCount,
|
|
152
|
-
extractedEntries: consolidated.extractedEntries.length,
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
} catch (err) {
|
|
158
|
-
if (isPermissionError(err)) {
|
|
159
|
-
if (!_permissionWarned) {
|
|
160
|
-
result.errors.push('Cannot write to ~/.yeaft/ — consolidation skipped');
|
|
161
|
-
_permissionWarned = true;
|
|
162
|
-
}
|
|
163
|
-
} else {
|
|
164
|
-
result.errors.push(`Consolidate failed: ${err.message}`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// 3. Dream V2 owns background scope-memory maintenance via the session
|
|
169
|
-
// dream scheduler (createV2DreamScheduler). No legacy dream gate is
|
|
170
|
-
// invoked here; the scheduler decides when to run on its own cadence.
|
|
133
|
+
// 2. Consolidation is owned by the engine (#maybeConsolidate → compact
|
|
134
|
+
// orchestrator). Dream V2 owns background scope-memory maintenance
|
|
135
|
+
// via the session dream scheduler (createV2DreamScheduler).
|
|
171
136
|
|
|
172
137
|
return result;
|
|
173
138
|
}
|
|
@@ -175,6 +140,5 @@ export async function runStopHooks(context) {
|
|
|
175
140
|
/**
|
|
176
141
|
* @typedef {Object} StopHookResult
|
|
177
142
|
* @property {number} messagesPersisted — how many messages were persisted
|
|
178
|
-
* @property {boolean} consolidated — whether consolidation ran
|
|
179
143
|
* @property {string[]} errors — any non-fatal errors
|
|
180
144
|
*/
|
package/unify/tools/index.js
CHANGED
|
@@ -18,11 +18,6 @@ import exitWorktree from './exit-worktree.js';
|
|
|
18
18
|
|
|
19
19
|
// --- P0 Core tools ---
|
|
20
20
|
import askUser from './ask-user.js';
|
|
21
|
-
import memoryRead from './memory-read.js';
|
|
22
|
-
import memoryWrite from './memory-write.js';
|
|
23
|
-
import memorySearch, { memorySearchAlias } from './memory-search.js';
|
|
24
|
-
import memoryQuery from './memory-query.js';
|
|
25
|
-
import memoryTrace from './memory-trace.js';
|
|
26
21
|
import openSourceMessage from './open-source-message.js';
|
|
27
22
|
import webSearch from './web-search.js';
|
|
28
23
|
import webFetch from './web-fetch.js';
|
|
@@ -89,12 +84,6 @@ export const allTools = [
|
|
|
89
84
|
|
|
90
85
|
// P0 Core
|
|
91
86
|
askUser,
|
|
92
|
-
memoryRead,
|
|
93
|
-
memoryWrite,
|
|
94
|
-
memorySearch,
|
|
95
|
-
memorySearchAlias,
|
|
96
|
-
memoryQuery,
|
|
97
|
-
memoryTrace,
|
|
98
87
|
openSourceMessage,
|
|
99
88
|
webSearch,
|
|
100
89
|
webFetch,
|
package/unify/web-bridge.js
CHANGED
|
@@ -26,10 +26,6 @@ import { createVp, updateVp, deleteVp, readVp, VpCrudError } from './vp/vp-crud.
|
|
|
26
26
|
import { scanVpLibrary } from './vp/vp-store.js';
|
|
27
27
|
import { createRouter } from './routing/router.js';
|
|
28
28
|
import { handleUnifyFeatureMessage as _handleUnifyFeatureMessage } from './feature-message.js';
|
|
29
|
-
import {
|
|
30
|
-
handleUnifyUserMemoryWrite as _handleUnifyUserMemoryWrite,
|
|
31
|
-
handleUnifyUserMemoryRemove as _handleUnifyUserMemoryRemove,
|
|
32
|
-
} from './user-memory.js';
|
|
33
29
|
import {
|
|
34
30
|
GroupCrudError,
|
|
35
31
|
createGroupFromSpec,
|
|
@@ -209,36 +205,6 @@ export function handleUnifyFeatureMessage(msg) {
|
|
|
209
205
|
_handleUnifyFeatureMessage(msg, sendUnifyEvent);
|
|
210
206
|
}
|
|
211
207
|
|
|
212
|
-
export function handleUnifyUserMemoryWrite(msg) {
|
|
213
|
-
_handleUnifyUserMemoryWrite(msg, sendUnifyEvent);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export function handleUnifyUserMemoryRemove(msg) {
|
|
217
|
-
_handleUnifyUserMemoryRemove(msg, sendUnifyEvent);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export function handleUnifyMemoryScopeList(msg) {
|
|
221
|
-
const requestId = msg && typeof msg.requestId === 'string' ? msg.requestId : undefined;
|
|
222
|
-
try {
|
|
223
|
-
const store = session && session.memoryStore;
|
|
224
|
-
const entries = store && typeof store.listEntries === 'function'
|
|
225
|
-
? store.listEntries()
|
|
226
|
-
: [];
|
|
227
|
-
sendUnifyEvent({
|
|
228
|
-
type: 'memory_scope_snapshot',
|
|
229
|
-
entries,
|
|
230
|
-
...(requestId ? { requestId } : {}),
|
|
231
|
-
});
|
|
232
|
-
} catch (err) {
|
|
233
|
-
sendUnifyEvent({
|
|
234
|
-
type: 'memory_scope_snapshot',
|
|
235
|
-
entries: [],
|
|
236
|
-
error: String(err && err.message || err),
|
|
237
|
-
...(requestId ? { requestId } : {}),
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
208
|
export function handleUnifyVpRead(msg) {
|
|
243
209
|
const requestId = msg && msg.requestId;
|
|
244
210
|
const vpId = msg && msg.vpId;
|
|
@@ -1130,70 +1096,6 @@ export function handleUnifyModeSwitch(_msg) {
|
|
|
1130
1096
|
console.warn('[Unify] unify_mode_switch is deprecated and ignored — Unify now runs in a single unified mode.');
|
|
1131
1097
|
}
|
|
1132
1098
|
|
|
1133
|
-
/** Read-only memory query for the UI memory browser. */
|
|
1134
|
-
export function handleUnifyMemoryQuery(msg = {}) {
|
|
1135
|
-
const requestId = typeof msg.requestId === 'string' ? msg.requestId : undefined;
|
|
1136
|
-
const vpId = typeof msg.vpId === 'string' ? msg.vpId : null;
|
|
1137
|
-
const featureId = typeof msg.featureId === 'string' ? msg.featureId : null;
|
|
1138
|
-
const limit = Number.isFinite(msg.limit) ? Math.max(1, Math.min(200, msg.limit)) : 50;
|
|
1139
|
-
|
|
1140
|
-
const reply = (extra = {}) => sendUnifyEvent({
|
|
1141
|
-
type: 'unify_memory_query_result',
|
|
1142
|
-
scope: { vpId, featureId },
|
|
1143
|
-
...extra,
|
|
1144
|
-
...(requestId ? { requestId } : {}),
|
|
1145
|
-
});
|
|
1146
|
-
|
|
1147
|
-
if (!session || !session.memoryShardStore) {
|
|
1148
|
-
reply({ entries: [], error: 'no_memory_store' });
|
|
1149
|
-
return;
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
try {
|
|
1153
|
-
const filter = {};
|
|
1154
|
-
if (vpId) filter.vp = vpId;
|
|
1155
|
-
if (featureId) filter.feature = featureId;
|
|
1156
|
-
const res = session.memoryShardStore.query(filter);
|
|
1157
|
-
const list = Array.isArray(res?.results) ? res.results : [];
|
|
1158
|
-
list.sort((a, b) => {
|
|
1159
|
-
const ax = (a && (a.updatedAt || a.createdAt)) || 0;
|
|
1160
|
-
const bx = (b && (b.updatedAt || b.createdAt)) || 0;
|
|
1161
|
-
const at = typeof ax === 'string' ? Date.parse(ax) : ax;
|
|
1162
|
-
const bt = typeof bx === 'string' ? Date.parse(bx) : bx;
|
|
1163
|
-
return (bt || 0) - (at || 0);
|
|
1164
|
-
});
|
|
1165
|
-
reply({ entries: list.slice(0, limit) });
|
|
1166
|
-
} catch (err) {
|
|
1167
|
-
reply({ entries: [], error: String(err?.message || err) });
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
/** Open the source message behind a memory entry. */
|
|
1172
|
-
export function handleUnifyMemoryTrace(msg = {}) {
|
|
1173
|
-
const requestId = typeof msg.requestId === 'string' ? msg.requestId : undefined;
|
|
1174
|
-
const entryId = typeof msg.entryId === 'string' ? msg.entryId : null;
|
|
1175
|
-
|
|
1176
|
-
const reply = (extra = {}) => sendUnifyEvent({
|
|
1177
|
-
type: 'unify_memory_trace_result',
|
|
1178
|
-
entryId,
|
|
1179
|
-
...extra,
|
|
1180
|
-
...(requestId ? { requestId } : {}),
|
|
1181
|
-
});
|
|
1182
|
-
|
|
1183
|
-
if (!entryId) { reply({ entry: null, sourceRef: null, error: 'missing_entry_id' }); return; }
|
|
1184
|
-
if (!session || !session.memoryShardStore) {
|
|
1185
|
-
reply({ entry: null, sourceRef: null, error: 'no_memory_store' });
|
|
1186
|
-
return;
|
|
1187
|
-
}
|
|
1188
|
-
try {
|
|
1189
|
-
const entry = session.memoryShardStore.get(entryId);
|
|
1190
|
-
if (!entry) { reply({ entry: null, sourceRef: null, error: 'not_found' }); return; }
|
|
1191
|
-
reply({ entry, sourceRef: entry.sourceRef || null });
|
|
1192
|
-
} catch (err) {
|
|
1193
|
-
reply({ entry: null, sourceRef: null, error: String(err?.message || err) });
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
1099
|
/** Fetch a feature's summary history (revision chain). */
|
|
1198
1100
|
export async function handleUnifyFetchSummaryHistory(msg = {}) {
|
|
1199
1101
|
const requestId = typeof msg.requestId === 'string' ? msg.requestId : undefined;
|