lemura 1.6.0 → 1.8.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/CHANGELOG.md +28 -0
- package/README.md +1 -0
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/{adapters-BN6und82.d.mts → adapters-BQA6PxCL.d.mts} +253 -23
- package/dist/{adapters-CnsgefYR.d.ts → adapters-nzsMKcf4.d.ts} +253 -23
- package/dist/{agent-B2okLlzq.d.mts → agent-D9N5kXnR.d.mts} +24 -3
- package/dist/{agent-BppqfsIZ.d.ts → agent-e7xlG9UD.d.ts} +24 -3
- package/dist/context/index.d.mts +2 -2
- package/dist/context/index.d.ts +2 -2
- package/dist/index.d.mts +25 -5
- package/dist/index.d.ts +25 -5
- package/dist/index.js +838 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +833 -18
- package/dist/index.mjs.map +1 -1
- package/dist/memory/index.d.mts +130 -0
- package/dist/memory/index.d.ts +130 -0
- package/dist/memory/index.js +527 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/index.mjs +520 -0
- package/dist/memory/index.mjs.map +1 -0
- package/dist/skills/index.d.mts +66 -6
- package/dist/skills/index.d.ts +66 -6
- package/dist/skills/index.js +91 -12
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/index.mjs +91 -12
- package/dist/skills/index.mjs.map +1 -1
- package/dist/skills-DWCC0K1B.d.mts +122 -0
- package/dist/skills-DWCC0K1B.d.ts +122 -0
- package/dist/tools/index.d.mts +3 -3
- package/dist/tools/index.d.ts +3 -3
- package/dist/types/index.d.mts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/package.json +6 -1
- package/dist/skills-Y6D7zSSw.d.mts +0 -66
- package/dist/skills-Y6D7zSSw.d.ts +0 -66
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.8.0] - 2026-06-16
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`LemurAgent` — preferred alias for `SessionManager`**: New code should construct `LemurAgent`; `SessionManager` remains exported unchanged for backward compatibility. Both are the exact same class (so `instanceof SessionManager` still holds for `new LemurAgent(...)`), exported in both value and type position from the root entry point.
|
|
13
|
+
- **Long-Term Memory subsystem** (`lemura/memory`, `SessionConfig.memory`): A persistent, cross-session, ranked, decaying, **token-budget-aware** memory — the capability missing between STM (large blobs), Scratchpad (per-session notes), and RAG (passive document store). Opt-in: when `config.memory` is absent, behavior is identical to 1.7.0. **Embedding-free by default** — the only place embeddings can enter is a pluggable scorer.
|
|
14
|
+
- **`MemoryManager`** (`src/memory/MemoryManager.ts`): Orchestrates `remember` (de-dup + reinforce), `recall` (composite-score ranking with reinforcement), `reflect` (autonomous fact extraction), `consolidate` (merge near-duplicates), and `forget`. Composite retrieval score `wR·relevance + wT·recency + wI·importance + wF·frequency` with exponential recency decay (generative-agents formula). Only the `relevance` term is pluggable; the rest is pure arithmetic.
|
|
15
|
+
- **`MemoryInjectionStrategy`** (`IContextStrategy`): Budget-aware recall. Runs inside `ContextManager.prepare()` exactly like `SummaryInjectionStrategy`, so the recalled `<lemura:memory>` block is counted against `maxTokens` — memory can never overflow the window. Greedily fills `recallTokenBudget`; injected as a single synthetic system turn (`turnIndex = -2`) updated in place across iterations (idempotent).
|
|
16
|
+
- **Pluggable scorers** (`IMemoryScorer`): `LexicalScorer` (default, embedding-free BM25-ish, offline), `EmbeddingScorer` (opt-in, requires the new optional `adapter.embed?()`; falls back to lexical otherwise), `LLMReRankScorer` (opt-in, paraphrase-robust via one cheap `complete()` call, no vector store).
|
|
17
|
+
- **`StorageMemoryStore`** (`IMemoryStore`): Default store over any `IStorageAdapter` ("Any storage" — in-memory, IndexedDB, SQLite, Redis, file store), with a lightweight index record for filtered `list()` without full scans.
|
|
18
|
+
- **Built-in `remember`/`recall`/`forget` tools** (`src/tools/builtin/memory.ts`): Auto-registered when `config.memory` is present, categorized `memory` for the router. `remember`/`recall` are auto-trusted by the firewall (local-only side effects); `forget` (a delete) stays firewall-gated.
|
|
19
|
+
- **`IProviderAdapter.embed?()`** (optional, additive): Returns an embedding vector; enables `EmbeddingScorer`. Existing adapters compile and run unchanged.
|
|
20
|
+
- **`ToolContext.memory?`** (additive): The `MemoryManager` is exposed to tool `execute()`.
|
|
21
|
+
- **`SessionConfig.memory.autoReflect`**: When true, durable facts are extracted from the conversation once at the end of each `run()` (one cheap LLM call; off by default, best-effort).
|
|
22
|
+
- **`TraceEvent.type: 'memory'`**: New trace type — `memory_write`, `memory_recall`, `memory_reflect`, `memory_consolidate`, `memory_forget`.
|
|
23
|
+
- **Tests**: `tests/unit/memory/Memory.test.ts` (store, scorer, manager ranking/dedup/reflect/forget, injection budget+idempotency) and `tests/unit/memory/SessionMemory.test.ts` (tool registration, cross-session recall, autoReflect, no-overflow).
|
|
24
|
+
|
|
25
|
+
## [1.7.0] - 2026-06-13
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- **Progressive skills — model-driven skill selection** (`strategy: 'progressive'`): A third skill strategy alongside `fixed` and `dynamic`. The model sees a lightweight catalog (`name: description`) of progressive skills in its system prompt and decides which to pull in by calling a built-in `load_skill` tool; only the chosen skill's full content is then injected. This is the "progressive disclosure" pattern — the host wires nothing, the agent selects its own skills. Fully backward-compatible (default strategy remains `fixed`).
|
|
30
|
+
- **Built-in `load_skill` tool** (`src/tools/builtin/load_skill.ts`, `createLoadSkillTool`): Auto-registered by `SessionManager` whenever a `progressive` skill is present, and auto-trusted by the tool firewall (it only toggles skill injection, no external side effects). The `name` parameter is constrained to the available progressive skills; unknown names and `maxConcurrent` violations return soft errors that keep the ReAct loop going.
|
|
31
|
+
- **`SkillSelectionConfig`** (`SessionConfig.skillSelection`): Tunes progressive selection — `persistence` (`'per_turn'` default, or `'session'`), `maxConcurrent` (cap on simultaneously loaded skills), and `catalogHeader` (override the catalog preamble). Ignored when no progressive skills are present.
|
|
32
|
+
- **`SkillInjector.buildCatalog(header?)`**: Builds the `name: description` catalog block for progressive skills. Plus `resetProgressiveSkills()`, `getProgressiveSkills()`, and `countEnabledProgressive()` helpers. `enableSkill`/`disableSkill`/`enableByTags`/`disableByTags` now operate on both `dynamic` and `progressive` skills.
|
|
33
|
+
- **Full skill-lifecycle tracing**: `skill_load` now fires for **every registered skill** (not just active ones) and carries an `enabled` flag, so inactive `dynamic`/`progressive` skills are visible from session init. New `skill_enable` trace (`{ name, source: 'load_skill' }`) records the model's selection decision when it loads a progressive skill, and new `skill_reset` trace (`{ skills, reason: 'per_turn' }`) records per-turn clearing. `session_init` reports a `progressive` skill count; `skill_inject` fires for both dynamic and progressive injections.
|
|
34
|
+
- **Tests**: `tests/unit/skills/ProgressiveSkills.test.ts` (catalog, activation, `load_skill` tool, `maxConcurrent`) and new `SessionManager` cases (auto-registration, per-turn vs session persistence).
|
|
35
|
+
|
|
8
36
|
## [1.6.0] - 2026-06-05
|
|
9
37
|
|
|
10
38
|
### Added
|
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
### ✨ Key Features
|
|
26
26
|
|
|
27
27
|
- **🧠 Dynamic Skill Market**: Switch skills on/off at runtime via tags, names, or tool dependencies.
|
|
28
|
+
- **📖 Progressive Skills**: Let the agent pick its own skills — it reads a catalog and loads only what's relevant via the built-in `load_skill` tool (`strategy: 'progressive'`).
|
|
28
29
|
- **🔌 Native MCP Support**: Connect to any Model Context Protocol server with custom header support (Auth).
|
|
29
30
|
- **🛡️ Tool Firewall**: Fully integrated ask/accept/deny policy layer for secure tool execution — fail-safe by design.
|
|
30
31
|
- **🎯 Goal Maintenance & Verification**: LLM-powered sub-goal decomposition, progress reconciliation, and post-run goal verification that re-enters the loop with full tool access to finish incomplete answers.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as IProviderAdapter,
|
|
1
|
+
import { a as IProviderAdapter, m as CompletionRequest, n as CompletionResponse, l as CompletionChunk, j as ModelInfo, d as TranscriptionRequest, e as TranscriptionResponse, f as SynthesisRequest, A as AudioChunk, V as VisionRequest, g as VisionResponse, h as ImageGenRequest, i as ImageGenResponse } from '../adapters-BQA6PxCL.mjs';
|
|
2
2
|
import '../rag-La_Bo-J8.mjs';
|
|
3
3
|
import '../logger-DxvKliuk.mjs';
|
|
4
4
|
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as IProviderAdapter,
|
|
1
|
+
import { a as IProviderAdapter, m as CompletionRequest, n as CompletionResponse, l as CompletionChunk, j as ModelInfo, d as TranscriptionRequest, e as TranscriptionResponse, f as SynthesisRequest, A as AudioChunk, V as VisionRequest, g as VisionResponse, h as ImageGenRequest, i as ImageGenResponse } from '../adapters-nzsMKcf4.js';
|
|
2
2
|
import '../rag-La_Bo-J8.js';
|
|
3
3
|
import '../logger-DxvKliuk.js';
|
|
4
4
|
|
|
@@ -135,32 +135,146 @@ declare class ShortTermMemoryRegistry {
|
|
|
135
135
|
delete(id: string): Promise<void>;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Long-Term Memory types — persistent, cross-session, ranked, decaying memory.
|
|
140
|
+
*
|
|
141
|
+
* Distinct from STM (large blobs), Scratchpad (per-session notes), and RAG (passive
|
|
142
|
+
* document store): long-term memory is written autonomously, ranked by a composite
|
|
143
|
+
* score (relevance + recency + importance + frequency), decays over time, and is
|
|
144
|
+
* recalled into the context window under a token budget.
|
|
145
|
+
*
|
|
146
|
+
* Embedding-free by default: the only place embeddings can enter is the pluggable
|
|
147
|
+
* {@link IMemoryScorer}. The default `LexicalScorer` needs no embeddings.
|
|
148
|
+
*
|
|
149
|
+
* @since 1.8.0
|
|
150
|
+
*/
|
|
151
|
+
type MemoryKind = 'fact' | 'preference' | 'episode' | 'entity' | 'summary';
|
|
152
|
+
/** A single durable memory record. */
|
|
153
|
+
interface MemoryRecord {
|
|
154
|
+
/** Stable unique id. */
|
|
155
|
+
id: string;
|
|
156
|
+
/** The fact / observation text. */
|
|
157
|
+
content: string;
|
|
158
|
+
/** Category of memory. */
|
|
159
|
+
kind: MemoryKind;
|
|
160
|
+
/** Salience 1–10, rated by the LLM at write time (default 5). Higher = recalled more readily. */
|
|
161
|
+
importance: number;
|
|
162
|
+
/** Epoch ms of creation. */
|
|
163
|
+
createdAt: number;
|
|
164
|
+
/** Epoch ms of last recall — drives the recency decay term. */
|
|
165
|
+
lastAccessedAt: number;
|
|
166
|
+
/** Number of times this record has been recalled — drives the frequency term. */
|
|
167
|
+
accessCount: number;
|
|
168
|
+
/** Free-form tags for filtering. */
|
|
169
|
+
tags?: string[];
|
|
170
|
+
/** People/places/things mentioned — keys for graph recall and pre-filtering. */
|
|
171
|
+
entities?: string[];
|
|
172
|
+
/** Ids of related memories (graph edges). */
|
|
173
|
+
links?: string[];
|
|
174
|
+
/** Optional embedding vector — present only when an embedding scorer is used. */
|
|
175
|
+
embedding?: number[];
|
|
176
|
+
/** Provenance of the write. */
|
|
177
|
+
source?: 'auto' | 'user' | 'tool';
|
|
178
|
+
/** Partition key (e.g. userId) for multi-tenant stores. */
|
|
179
|
+
scope?: string;
|
|
180
|
+
/** Arbitrary extra metadata. */
|
|
181
|
+
metadata?: Record<string, unknown>;
|
|
147
182
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
183
|
+
/**
|
|
184
|
+
* Pluggable relevance term. The ONLY place embeddings could enter the subsystem.
|
|
185
|
+
* Embedding-free implementations (the default) ignore `record.embedding`.
|
|
186
|
+
*/
|
|
187
|
+
interface IMemoryScorer {
|
|
188
|
+
readonly name: string;
|
|
154
189
|
/**
|
|
155
|
-
*
|
|
156
|
-
* narrow which tools are exposed to the model on a given turn. Open string —
|
|
157
|
-
* lemura does not own a fixed catalog. Tools left uncategorized are never
|
|
158
|
-
* filtered out (treated as always available).
|
|
190
|
+
* Relevance of a record to the query, normalized 0..1.
|
|
159
191
|
*
|
|
160
|
-
* @
|
|
192
|
+
* @param query - The current user message (or an explicit recall query).
|
|
193
|
+
* @param record - The candidate memory record.
|
|
194
|
+
* @param corpus - All candidate records, supplied so lexical scorers can compute
|
|
195
|
+
* inverse-document-frequency weighting. May be ignored.
|
|
161
196
|
*/
|
|
162
|
-
|
|
163
|
-
|
|
197
|
+
relevance(query: string, record: MemoryRecord, corpus?: MemoryRecord[]): number | Promise<number>;
|
|
198
|
+
/**
|
|
199
|
+
* Optional hook to enrich a record at write time (e.g. attach an embedding).
|
|
200
|
+
* No-op for lexical scorers. Returns the (possibly mutated) record.
|
|
201
|
+
*/
|
|
202
|
+
prepare?(record: MemoryRecord): Promise<MemoryRecord>;
|
|
203
|
+
}
|
|
204
|
+
/** Filter passed to {@link IMemoryStore.list} to narrow the candidate set. */
|
|
205
|
+
interface MemoryFilter {
|
|
206
|
+
scope?: string;
|
|
207
|
+
kinds?: MemoryKind[];
|
|
208
|
+
tags?: string[];
|
|
209
|
+
entities?: string[];
|
|
210
|
+
/** Hard cap on candidates returned to the scorer. Default 500. */
|
|
211
|
+
limit?: number;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Persistence contract for memory records. The default implementation
|
|
215
|
+
* ({@link StorageMemoryStore}) rides on any {@link IStorageAdapter}, so the same
|
|
216
|
+
* memory works against in-memory, IndexedDB, SQLite, Redis, or a file store.
|
|
217
|
+
*/
|
|
218
|
+
interface IMemoryStore {
|
|
219
|
+
put(record: MemoryRecord): Promise<void>;
|
|
220
|
+
get(id: string): Promise<MemoryRecord | undefined>;
|
|
221
|
+
/** Returns candidate records to score. May pre-filter by scope/tags/entities. */
|
|
222
|
+
list(filter?: MemoryFilter): Promise<MemoryRecord[]>;
|
|
223
|
+
delete(id: string): Promise<void>;
|
|
224
|
+
healthCheck?(): Promise<boolean>;
|
|
225
|
+
}
|
|
226
|
+
/** Relative weights for the composite retrieval score. */
|
|
227
|
+
interface MemoryScoreWeights {
|
|
228
|
+
/** Weight of the (pluggable) relevance term. Default 1.0. */
|
|
229
|
+
relevance?: number;
|
|
230
|
+
/** Weight of the recency decay term. Default 0.5. */
|
|
231
|
+
recency?: number;
|
|
232
|
+
/** Weight of the importance term. Default 0.3. */
|
|
233
|
+
importance?: number;
|
|
234
|
+
/** Weight of the access-frequency term. Default 0.1. */
|
|
235
|
+
frequency?: number;
|
|
236
|
+
}
|
|
237
|
+
/** A scored memory record returned by recall. */
|
|
238
|
+
interface RankedMemory {
|
|
239
|
+
record: MemoryRecord;
|
|
240
|
+
score: number;
|
|
241
|
+
/** Per-term breakdown, for tracing/debugging. */
|
|
242
|
+
terms: {
|
|
243
|
+
relevance: number;
|
|
244
|
+
recency: number;
|
|
245
|
+
importance: number;
|
|
246
|
+
frequency: number;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Configuration for the long-term memory subsystem. Attach to
|
|
251
|
+
* `SessionConfig.memory`. Absent ⇒ no memory wiring (identical to 1.7.0).
|
|
252
|
+
*/
|
|
253
|
+
interface MemoryConfig {
|
|
254
|
+
/** Persistence backend. Required. */
|
|
255
|
+
store: IMemoryStore;
|
|
256
|
+
/** Relevance scorer. Default: `LexicalScorer` (embedding-free). */
|
|
257
|
+
scorer?: IMemoryScorer;
|
|
258
|
+
/** Partition key applied to all writes/reads for this session. */
|
|
259
|
+
scope?: string;
|
|
260
|
+
/** Composite-score weights. */
|
|
261
|
+
weights?: MemoryScoreWeights;
|
|
262
|
+
/** Recency half-life in ms. Default 7 days. */
|
|
263
|
+
recencyHalfLifeMs?: number;
|
|
264
|
+
/** Token budget for the recalled-memory block injected each turn. Default 800. */
|
|
265
|
+
recallTokenBudget?: number;
|
|
266
|
+
/** Max records considered for injection regardless of budget. Default 8. */
|
|
267
|
+
recallTopK?: number;
|
|
268
|
+
/** Minimum composite score to be eligible for injection/recall. Default 0.15. */
|
|
269
|
+
minScore?: number;
|
|
270
|
+
/** Run reflection (autonomous write) automatically at session end. Default false. */
|
|
271
|
+
autoReflect?: boolean;
|
|
272
|
+
/** Run consolidation every N writes (0 = never). Default 0. */
|
|
273
|
+
consolidateEvery?: number;
|
|
274
|
+
/** Priority of the MemoryInjectionStrategy. Default 2 (after summary injection at 1). */
|
|
275
|
+
injectionPriority?: number;
|
|
276
|
+
/** Header label for the injected block. Default 'Relevant memories'. */
|
|
277
|
+
injectionLabel?: string;
|
|
164
278
|
}
|
|
165
279
|
|
|
166
280
|
interface ContentBlock {
|
|
@@ -198,6 +312,114 @@ interface IContextStrategy {
|
|
|
198
312
|
apply(ctx: ContextWindow): Promise<ContextWindow>;
|
|
199
313
|
}
|
|
200
314
|
|
|
315
|
+
interface MemoryManagerConfig {
|
|
316
|
+
store: IMemoryStore;
|
|
317
|
+
scorer?: IMemoryScorer;
|
|
318
|
+
adapter?: IProviderAdapter;
|
|
319
|
+
model?: string;
|
|
320
|
+
logger?: ILogger;
|
|
321
|
+
scope?: string;
|
|
322
|
+
weights?: MemoryScoreWeights;
|
|
323
|
+
recencyHalfLifeMs?: number;
|
|
324
|
+
recallTopK?: number;
|
|
325
|
+
minScore?: number;
|
|
326
|
+
consolidateEvery?: number;
|
|
327
|
+
/** Called for trace emission. */
|
|
328
|
+
onTrace?: (name: string, metadata: Record<string, unknown>) => void;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Orchestrates long-term memory: autonomous write (reflection), explicit write,
|
|
332
|
+
* ranked recall (composite score with decay), consolidation, and forgetting.
|
|
333
|
+
*
|
|
334
|
+
* Embedding-free by default — the relevance term is delegated to a pluggable
|
|
335
|
+
* {@link IMemoryScorer}; everything else (recency, importance, frequency, storage)
|
|
336
|
+
* is provider- and embedding-independent.
|
|
337
|
+
*
|
|
338
|
+
* @since 1.8.0
|
|
339
|
+
*/
|
|
340
|
+
declare class MemoryManager {
|
|
341
|
+
private cfg;
|
|
342
|
+
private store;
|
|
343
|
+
private scorer;
|
|
344
|
+
private weights;
|
|
345
|
+
private halfLifeMs;
|
|
346
|
+
private recallTopK;
|
|
347
|
+
private minScore;
|
|
348
|
+
private consolidateEvery;
|
|
349
|
+
private writesSinceConsolidate;
|
|
350
|
+
constructor(cfg: MemoryManagerConfig);
|
|
351
|
+
private trace;
|
|
352
|
+
/**
|
|
353
|
+
* Persist a memory. De-duplicates against existing records: if an existing
|
|
354
|
+
* record is near-identical (relevance > 0.9) it is reinforced (importance bumped,
|
|
355
|
+
* lastAccessedAt refreshed) instead of inserting a duplicate.
|
|
356
|
+
*/
|
|
357
|
+
remember(input: {
|
|
358
|
+
content: string;
|
|
359
|
+
kind?: MemoryKind;
|
|
360
|
+
importance?: number;
|
|
361
|
+
tags?: string[];
|
|
362
|
+
entities?: string[];
|
|
363
|
+
source?: MemoryRecord['source'];
|
|
364
|
+
}): Promise<MemoryRecord>;
|
|
365
|
+
/**
|
|
366
|
+
* Rank stored memories against a query using the composite score
|
|
367
|
+
* `wR*relevance + wT*recency + wI*importance + wF*frequency`. Returns the top
|
|
368
|
+
* records above `minScore`. Recalled records are reinforced (lastAccessedAt /
|
|
369
|
+
* accessCount bumped) so frequently-useful memories stay salient.
|
|
370
|
+
*/
|
|
371
|
+
recall(query: string, topK?: number): Promise<RankedMemory[]>;
|
|
372
|
+
/**
|
|
373
|
+
* Extract durable facts/preferences from recent turns and persist them, each
|
|
374
|
+
* rated for importance. One temperature-0 LLM call. Requires an adapter; no-op
|
|
375
|
+
* if none was supplied. This is the generative-agents "reflection" step.
|
|
376
|
+
*/
|
|
377
|
+
reflect(turns: Turn[]): Promise<MemoryRecord[]>;
|
|
378
|
+
/**
|
|
379
|
+
* Merge near-duplicate records into one, keeping the store bounded. Conservative:
|
|
380
|
+
* only collapses records whose mutual relevance exceeds 0.9 and that share a kind.
|
|
381
|
+
* The survivor inherits the max importance and summed access count.
|
|
382
|
+
*/
|
|
383
|
+
consolidate(): Promise<{
|
|
384
|
+
merged: number;
|
|
385
|
+
}>;
|
|
386
|
+
/** Delete a memory by id, or the single best match for a query. */
|
|
387
|
+
forget(input: {
|
|
388
|
+
id?: string;
|
|
389
|
+
query?: string;
|
|
390
|
+
}): Promise<boolean>;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
interface ToolContext {
|
|
394
|
+
sessionId: string;
|
|
395
|
+
turnIndex: number;
|
|
396
|
+
logger: ILogger;
|
|
397
|
+
adapter?: IProviderAdapter;
|
|
398
|
+
ragAdapter?: IRAGAdapter;
|
|
399
|
+
stmRegistry?: ShortTermMemoryRegistry;
|
|
400
|
+
scratchpad?: string;
|
|
401
|
+
scratchpadAdapter?: IScratchpadAdapter;
|
|
402
|
+
/** Long-term memory orchestrator. Present when `SessionConfig.memory` is set. @since 1.8.0 */
|
|
403
|
+
memory?: MemoryManager;
|
|
404
|
+
}
|
|
405
|
+
interface IToolDefinition {
|
|
406
|
+
name: string;
|
|
407
|
+
description: string;
|
|
408
|
+
parameters: Record<string, unknown>;
|
|
409
|
+
/** Per-call timeout in milliseconds. Falls back to ToolRegistry.defaultTimeoutMs when omitted. */
|
|
410
|
+
timeoutMs?: number;
|
|
411
|
+
/**
|
|
412
|
+
* Optional category used by the router (see `SessionConfig.enableRouting`) to
|
|
413
|
+
* narrow which tools are exposed to the model on a given turn. Open string —
|
|
414
|
+
* lemura does not own a fixed catalog. Tools left uncategorized are never
|
|
415
|
+
* filtered out (treated as always available).
|
|
416
|
+
*
|
|
417
|
+
* @since 1.6.0
|
|
418
|
+
*/
|
|
419
|
+
category?: string;
|
|
420
|
+
execute(params: unknown, context: ToolContext): Promise<unknown>;
|
|
421
|
+
}
|
|
422
|
+
|
|
201
423
|
/** Represents a single message in the provider format */
|
|
202
424
|
interface NormalizedMessage {
|
|
203
425
|
/** The role of the message sender */
|
|
@@ -353,6 +575,14 @@ interface IProviderAdapter {
|
|
|
353
575
|
synthesize(request: SynthesisRequest): AsyncIterable<AudioChunk>;
|
|
354
576
|
describeImage(request: VisionRequest): Promise<VisionResponse>;
|
|
355
577
|
generateImage(request: ImageGenRequest): Promise<ImageGenResponse>;
|
|
578
|
+
/**
|
|
579
|
+
* Optional. Returns an embedding vector for the given text. Enables the
|
|
580
|
+
* long-term-memory `EmbeddingScorer`; when absent, memory falls back to the
|
|
581
|
+
* embedding-free `LexicalScorer`. Existing adapters need not implement this.
|
|
582
|
+
*
|
|
583
|
+
* @since 1.8.0
|
|
584
|
+
*/
|
|
585
|
+
embed?(text: string, model?: string): Promise<number[]>;
|
|
356
586
|
/**
|
|
357
587
|
* Estimates token count for standard text.
|
|
358
588
|
*
|
|
@@ -374,4 +604,4 @@ interface IProviderAdapter {
|
|
|
374
604
|
healthCheck(): Promise<boolean>;
|
|
375
605
|
}
|
|
376
606
|
|
|
377
|
-
export { type AudioChunk as A, type ContextWindow as C, type IToolDefinition as I, type
|
|
607
|
+
export { type AudioChunk as A, type ToolCall as B, type ContextWindow as C, type ToolContext as D, type ToolResult as E, type IToolDefinition as I, type MemoryConfig as M, type NormalizedMessage as N, type RankedMemory as R, ShortTermMemoryRegistry as S, type Turn as T, type VisionRequest as V, type IProviderAdapter as a, type IContextStrategy as b, type IScratchpadAdapter as c, type TranscriptionRequest as d, type TranscriptionResponse as e, type SynthesisRequest as f, type VisionResponse as g, type ImageGenRequest as h, type ImageGenResponse as i, type ModelInfo as j, type ContentBlock as k, type CompletionChunk as l, type CompletionRequest as m, type CompletionResponse as n, type IMemoryScorer as o, type IMemoryStore as p, type IStorageAdapter as q, type MemoryFilter as r, type MemoryKind as s, MemoryManager as t, type MemoryManagerConfig as u, type MemoryRecord as v, type MemoryScoreWeights as w, type STMItem as x, type STMRegistryConfig as y, type TokenUsage as z };
|