lemura 1.2.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +134 -0
- package/README.md +13 -12
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +10 -2
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +10 -2
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/{storage-CG3nTa6o.d.mts → adapters-BhTAnrOM.d.mts} +79 -46
- package/dist/{storage-DBt_q0wO.d.ts → adapters-CVcfWf85.d.ts} +79 -46
- package/dist/{agent-DxRd93wl.d.ts → agent-DTcDIKIn.d.ts} +40 -4
- package/dist/{agent-D6uhF-CZ.d.mts → agent-DfN5nNXc.d.mts} +40 -4
- package/dist/context/index.d.mts +71 -7
- package/dist/context/index.d.ts +71 -7
- package/dist/context/index.js +75 -4
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +74 -5
- package/dist/context/index.mjs.map +1 -1
- package/dist/index.d.mts +339 -63
- package/dist/index.d.ts +339 -63
- package/dist/index.js +1027 -134
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1026 -135
- package/dist/index.mjs.map +1 -1
- package/dist/skills/index.d.mts +92 -3
- package/dist/skills/index.d.ts +92 -3
- package/dist/skills/index.js +138 -8
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/index.mjs +138 -8
- package/dist/skills/index.mjs.map +1 -1
- package/dist/skills-Y6D7zSSw.d.mts +66 -0
- package/dist/skills-Y6D7zSSw.d.ts +66 -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 +14 -9
- package/dist/skills-wc8S-OvC.d.mts +0 -14
- package/dist/skills-wc8S-OvC.d.ts +0 -14
|
@@ -1,6 +1,83 @@
|
|
|
1
1
|
import { I as IRAGAdapter } from './rag-La_Bo-J8.mjs';
|
|
2
2
|
import { I as ILogger } from './logger-DxvKliuk.mjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Interface for Short Term Memory storage adapters.
|
|
6
|
+
* Implementations handle the persistence of STM variables.
|
|
7
|
+
*/
|
|
8
|
+
interface IStorageAdapter {
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves content by its unique ID.
|
|
11
|
+
*
|
|
12
|
+
* @param id - The unique identifier of the stored content
|
|
13
|
+
* @returns The content or undefined if it does not exist
|
|
14
|
+
*/
|
|
15
|
+
get(id: string): Promise<any | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Saves content returning a stable ID if none was provided, or using the given ID.
|
|
18
|
+
*
|
|
19
|
+
* @param id - An optional unique identifier. If not provided, one should be generated.
|
|
20
|
+
* @param content - The content to be stored
|
|
21
|
+
* @param metadata - Optional metadata about the content (e.g. type, size)
|
|
22
|
+
* @returns A promise that resolves to the ID under which it was saved
|
|
23
|
+
*/
|
|
24
|
+
set(id: string | undefined, content: any, metadata?: Record<string, unknown>): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Deletes content by its unique ID.
|
|
27
|
+
*
|
|
28
|
+
* @param id - The unique identifier of the content to delete
|
|
29
|
+
* @returns Resolves when deletion is complete
|
|
30
|
+
*/
|
|
31
|
+
delete(id: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Optional health check for remote storage adapters.
|
|
34
|
+
*
|
|
35
|
+
* @returns true if storage is accessible, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
healthCheck?(): Promise<boolean>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Interface for Scratchpad storage adapters.
|
|
41
|
+
* Implementations handle persistence of the scratchpad per session.
|
|
42
|
+
*/
|
|
43
|
+
interface IScratchpadAdapter {
|
|
44
|
+
/**
|
|
45
|
+
* Reads the scratchpad for a given session.
|
|
46
|
+
*
|
|
47
|
+
* @param sessionId - The session identifier
|
|
48
|
+
* @returns The scratchpad content or undefined if none exists
|
|
49
|
+
*/
|
|
50
|
+
read(sessionId: string): Promise<string | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Writes the scratchpad for a given session.
|
|
53
|
+
*
|
|
54
|
+
* @param sessionId - The session identifier
|
|
55
|
+
* @param content - The scratchpad content to store
|
|
56
|
+
*/
|
|
57
|
+
write(sessionId: string, content: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Clears the scratchpad for a given session.
|
|
60
|
+
*
|
|
61
|
+
* @param sessionId - The session identifier
|
|
62
|
+
*/
|
|
63
|
+
clear(sessionId: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Optional health check for remote storage adapters.
|
|
66
|
+
*
|
|
67
|
+
* @returns true if storage is accessible, false otherwise
|
|
68
|
+
*/
|
|
69
|
+
healthCheck?(): Promise<boolean>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Represents an item stored in Short Term Memory.
|
|
73
|
+
*/
|
|
74
|
+
interface STMItem {
|
|
75
|
+
id: string;
|
|
76
|
+
content: any;
|
|
77
|
+
type: 'text' | 'blob';
|
|
78
|
+
metadata?: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
|
|
4
81
|
interface STMRegistryConfig {
|
|
5
82
|
/**
|
|
6
83
|
* The storage backend to use for Short Term Memory items.
|
|
@@ -66,6 +143,7 @@ interface ToolContext {
|
|
|
66
143
|
ragAdapter?: IRAGAdapter;
|
|
67
144
|
stmRegistry?: ShortTermMemoryRegistry;
|
|
68
145
|
scratchpad?: string;
|
|
146
|
+
scratchpadAdapter?: IScratchpadAdapter;
|
|
69
147
|
}
|
|
70
148
|
interface IToolDefinition {
|
|
71
149
|
name: string;
|
|
@@ -285,49 +363,4 @@ interface IProviderAdapter {
|
|
|
285
363
|
healthCheck(): Promise<boolean>;
|
|
286
364
|
}
|
|
287
365
|
|
|
288
|
-
|
|
289
|
-
* Interface for Short Term Memory storage adapters.
|
|
290
|
-
* Implementations handle the persistence of STM variables.
|
|
291
|
-
*/
|
|
292
|
-
interface IStorageAdapter {
|
|
293
|
-
/**
|
|
294
|
-
* Retrieves content by its unique ID.
|
|
295
|
-
*
|
|
296
|
-
* @param id - The unique identifier of the stored content
|
|
297
|
-
* @returns The content or undefined if it does not exist
|
|
298
|
-
*/
|
|
299
|
-
get(id: string): Promise<any | undefined>;
|
|
300
|
-
/**
|
|
301
|
-
* Saves content returning a stable ID if none was provided, or using the given ID.
|
|
302
|
-
*
|
|
303
|
-
* @param id - An optional unique identifier. If not provided, one should be generated.
|
|
304
|
-
* @param content - The content to be stored
|
|
305
|
-
* @param metadata - Optional metadata about the content (e.g. type, size)
|
|
306
|
-
* @returns A promise that resolves to the ID under which it was saved
|
|
307
|
-
*/
|
|
308
|
-
set(id: string | undefined, content: any, metadata?: Record<string, unknown>): Promise<string>;
|
|
309
|
-
/**
|
|
310
|
-
* Deletes content by its unique ID.
|
|
311
|
-
*
|
|
312
|
-
* @param id - The unique identifier of the content to delete
|
|
313
|
-
* @returns Resolves when deletion is complete
|
|
314
|
-
*/
|
|
315
|
-
delete(id: string): Promise<void>;
|
|
316
|
-
/**
|
|
317
|
-
* Optional health check for remote storage adapters.
|
|
318
|
-
*
|
|
319
|
-
* @returns true if storage is accessible, false otherwise
|
|
320
|
-
*/
|
|
321
|
-
healthCheck?(): Promise<boolean>;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Represents an item stored in Short Term Memory.
|
|
325
|
-
*/
|
|
326
|
-
interface STMItem {
|
|
327
|
-
id: string;
|
|
328
|
-
content: any;
|
|
329
|
-
type: 'text' | 'blob';
|
|
330
|
-
metadata?: Record<string, unknown>;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export { type AudioChunk as A, type ContextWindow as C, type IToolDefinition as I, type ModelInfo as M, type NormalizedMessage as N, ShortTermMemoryRegistry as S, type TranscriptionRequest as T, type VisionRequest as V, type IProviderAdapter as a, type IContextStrategy as b, type TranscriptionResponse as c, type SynthesisRequest as d, type VisionResponse as e, type ImageGenRequest as f, type ImageGenResponse as g, type Turn as h, type ContentBlock as i, type CompletionChunk as j, type CompletionRequest as k, type CompletionResponse as l, type IStorageAdapter as m, type STMItem as n, type STMRegistryConfig as o, type TokenUsage as p, type ToolCall as q, type ToolContext as r, type ToolResult as s };
|
|
366
|
+
export { type AudioChunk as A, type ContextWindow as C, type IToolDefinition as I, type ModelInfo as M, type NormalizedMessage as N, ShortTermMemoryRegistry as S, type TranscriptionRequest as T, type VisionRequest as V, type IProviderAdapter as a, type IContextStrategy as b, type IScratchpadAdapter as c, type TranscriptionResponse as d, type SynthesisRequest as e, type VisionResponse as f, type ImageGenRequest as g, type ImageGenResponse as h, type Turn as i, type ContentBlock as j, type CompletionChunk as k, type CompletionRequest as l, type CompletionResponse as m, type IStorageAdapter as n, type STMItem as o, type STMRegistryConfig as p, type TokenUsage as q, type ToolCall as r, type ToolContext as s, type ToolResult as t };
|
|
@@ -1,6 +1,83 @@
|
|
|
1
1
|
import { I as IRAGAdapter } from './rag-La_Bo-J8.js';
|
|
2
2
|
import { I as ILogger } from './logger-DxvKliuk.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Interface for Short Term Memory storage adapters.
|
|
6
|
+
* Implementations handle the persistence of STM variables.
|
|
7
|
+
*/
|
|
8
|
+
interface IStorageAdapter {
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves content by its unique ID.
|
|
11
|
+
*
|
|
12
|
+
* @param id - The unique identifier of the stored content
|
|
13
|
+
* @returns The content or undefined if it does not exist
|
|
14
|
+
*/
|
|
15
|
+
get(id: string): Promise<any | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Saves content returning a stable ID if none was provided, or using the given ID.
|
|
18
|
+
*
|
|
19
|
+
* @param id - An optional unique identifier. If not provided, one should be generated.
|
|
20
|
+
* @param content - The content to be stored
|
|
21
|
+
* @param metadata - Optional metadata about the content (e.g. type, size)
|
|
22
|
+
* @returns A promise that resolves to the ID under which it was saved
|
|
23
|
+
*/
|
|
24
|
+
set(id: string | undefined, content: any, metadata?: Record<string, unknown>): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Deletes content by its unique ID.
|
|
27
|
+
*
|
|
28
|
+
* @param id - The unique identifier of the content to delete
|
|
29
|
+
* @returns Resolves when deletion is complete
|
|
30
|
+
*/
|
|
31
|
+
delete(id: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Optional health check for remote storage adapters.
|
|
34
|
+
*
|
|
35
|
+
* @returns true if storage is accessible, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
healthCheck?(): Promise<boolean>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Interface for Scratchpad storage adapters.
|
|
41
|
+
* Implementations handle persistence of the scratchpad per session.
|
|
42
|
+
*/
|
|
43
|
+
interface IScratchpadAdapter {
|
|
44
|
+
/**
|
|
45
|
+
* Reads the scratchpad for a given session.
|
|
46
|
+
*
|
|
47
|
+
* @param sessionId - The session identifier
|
|
48
|
+
* @returns The scratchpad content or undefined if none exists
|
|
49
|
+
*/
|
|
50
|
+
read(sessionId: string): Promise<string | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Writes the scratchpad for a given session.
|
|
53
|
+
*
|
|
54
|
+
* @param sessionId - The session identifier
|
|
55
|
+
* @param content - The scratchpad content to store
|
|
56
|
+
*/
|
|
57
|
+
write(sessionId: string, content: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Clears the scratchpad for a given session.
|
|
60
|
+
*
|
|
61
|
+
* @param sessionId - The session identifier
|
|
62
|
+
*/
|
|
63
|
+
clear(sessionId: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Optional health check for remote storage adapters.
|
|
66
|
+
*
|
|
67
|
+
* @returns true if storage is accessible, false otherwise
|
|
68
|
+
*/
|
|
69
|
+
healthCheck?(): Promise<boolean>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Represents an item stored in Short Term Memory.
|
|
73
|
+
*/
|
|
74
|
+
interface STMItem {
|
|
75
|
+
id: string;
|
|
76
|
+
content: any;
|
|
77
|
+
type: 'text' | 'blob';
|
|
78
|
+
metadata?: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
|
|
4
81
|
interface STMRegistryConfig {
|
|
5
82
|
/**
|
|
6
83
|
* The storage backend to use for Short Term Memory items.
|
|
@@ -66,6 +143,7 @@ interface ToolContext {
|
|
|
66
143
|
ragAdapter?: IRAGAdapter;
|
|
67
144
|
stmRegistry?: ShortTermMemoryRegistry;
|
|
68
145
|
scratchpad?: string;
|
|
146
|
+
scratchpadAdapter?: IScratchpadAdapter;
|
|
69
147
|
}
|
|
70
148
|
interface IToolDefinition {
|
|
71
149
|
name: string;
|
|
@@ -285,49 +363,4 @@ interface IProviderAdapter {
|
|
|
285
363
|
healthCheck(): Promise<boolean>;
|
|
286
364
|
}
|
|
287
365
|
|
|
288
|
-
|
|
289
|
-
* Interface for Short Term Memory storage adapters.
|
|
290
|
-
* Implementations handle the persistence of STM variables.
|
|
291
|
-
*/
|
|
292
|
-
interface IStorageAdapter {
|
|
293
|
-
/**
|
|
294
|
-
* Retrieves content by its unique ID.
|
|
295
|
-
*
|
|
296
|
-
* @param id - The unique identifier of the stored content
|
|
297
|
-
* @returns The content or undefined if it does not exist
|
|
298
|
-
*/
|
|
299
|
-
get(id: string): Promise<any | undefined>;
|
|
300
|
-
/**
|
|
301
|
-
* Saves content returning a stable ID if none was provided, or using the given ID.
|
|
302
|
-
*
|
|
303
|
-
* @param id - An optional unique identifier. If not provided, one should be generated.
|
|
304
|
-
* @param content - The content to be stored
|
|
305
|
-
* @param metadata - Optional metadata about the content (e.g. type, size)
|
|
306
|
-
* @returns A promise that resolves to the ID under which it was saved
|
|
307
|
-
*/
|
|
308
|
-
set(id: string | undefined, content: any, metadata?: Record<string, unknown>): Promise<string>;
|
|
309
|
-
/**
|
|
310
|
-
* Deletes content by its unique ID.
|
|
311
|
-
*
|
|
312
|
-
* @param id - The unique identifier of the content to delete
|
|
313
|
-
* @returns Resolves when deletion is complete
|
|
314
|
-
*/
|
|
315
|
-
delete(id: string): Promise<void>;
|
|
316
|
-
/**
|
|
317
|
-
* Optional health check for remote storage adapters.
|
|
318
|
-
*
|
|
319
|
-
* @returns true if storage is accessible, false otherwise
|
|
320
|
-
*/
|
|
321
|
-
healthCheck?(): Promise<boolean>;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Represents an item stored in Short Term Memory.
|
|
325
|
-
*/
|
|
326
|
-
interface STMItem {
|
|
327
|
-
id: string;
|
|
328
|
-
content: any;
|
|
329
|
-
type: 'text' | 'blob';
|
|
330
|
-
metadata?: Record<string, unknown>;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export { type AudioChunk as A, type ContextWindow as C, type IToolDefinition as I, type ModelInfo as M, type NormalizedMessage as N, ShortTermMemoryRegistry as S, type TranscriptionRequest as T, type VisionRequest as V, type IProviderAdapter as a, type IContextStrategy as b, type TranscriptionResponse as c, type SynthesisRequest as d, type VisionResponse as e, type ImageGenRequest as f, type ImageGenResponse as g, type Turn as h, type ContentBlock as i, type CompletionChunk as j, type CompletionRequest as k, type CompletionResponse as l, type IStorageAdapter as m, type STMItem as n, type STMRegistryConfig as o, type TokenUsage as p, type ToolCall as q, type ToolContext as r, type ToolResult as s };
|
|
366
|
+
export { type AudioChunk as A, type ContextWindow as C, type IToolDefinition as I, type ModelInfo as M, type NormalizedMessage as N, ShortTermMemoryRegistry as S, type TranscriptionRequest as T, type VisionRequest as V, type IProviderAdapter as a, type IContextStrategy as b, type IScratchpadAdapter as c, type TranscriptionResponse as d, type SynthesisRequest as e, type VisionResponse as f, type ImageGenRequest as g, type ImageGenResponse as h, type Turn as i, type ContentBlock as j, type CompletionChunk as k, type CompletionRequest as l, type CompletionResponse as m, type IStorageAdapter as n, type STMItem as o, type STMRegistryConfig as p, type TokenUsage as q, type ToolCall as r, type ToolContext as s, type ToolResult as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as IToolDefinition, a as IProviderAdapter, b as IContextStrategy, S as ShortTermMemoryRegistry } from './
|
|
1
|
+
import { I as IToolDefinition, a as IProviderAdapter, b as IContextStrategy, S as ShortTermMemoryRegistry, c as IScratchpadAdapter } from './adapters-CVcfWf85.js';
|
|
2
2
|
import { I as ILogger } from './logger-DxvKliuk.js';
|
|
3
|
-
import { I as ISkill } from './skills-
|
|
3
|
+
import { I as ISkill } from './skills-Y6D7zSSw.js';
|
|
4
4
|
import { I as IRAGAdapter } from './rag-La_Bo-J8.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -55,6 +55,11 @@ interface MCPServerConfig {
|
|
|
55
55
|
* `{ GITHUB_TOKEN: process.env.GITHUB_TOKEN! }`
|
|
56
56
|
*/
|
|
57
57
|
env?: Record<string, string>;
|
|
58
|
+
/**
|
|
59
|
+
* For `http`/`sse`: custom headers to include in requests.
|
|
60
|
+
* @example { Authorization: 'Bearer <token>' }
|
|
61
|
+
*/
|
|
62
|
+
headers?: Record<string, string>;
|
|
58
63
|
/**
|
|
59
64
|
* Per-call timeout in milliseconds. Defaults to `30_000`.
|
|
60
65
|
*/
|
|
@@ -161,6 +166,8 @@ interface SessionConfig {
|
|
|
161
166
|
adapter: IProviderAdapter;
|
|
162
167
|
/** Model string */
|
|
163
168
|
model: string;
|
|
169
|
+
/** Optional session id for scratchpad and tracing */
|
|
170
|
+
sessionId?: string;
|
|
164
171
|
/** Max context tokens */
|
|
165
172
|
maxTokens: number;
|
|
166
173
|
/** Max ReAct cycles */
|
|
@@ -169,6 +176,22 @@ interface SessionConfig {
|
|
|
169
176
|
tools?: IToolDefinition[];
|
|
170
177
|
/** Explicit skills */
|
|
171
178
|
skills?: ISkill[];
|
|
179
|
+
/**
|
|
180
|
+
* Names of dynamic skills (those with `strategy: 'dynamic'`) to enable
|
|
181
|
+
* automatically at session construction. Fixed skills are always active
|
|
182
|
+
* regardless of this list.
|
|
183
|
+
*
|
|
184
|
+
* @since 1.4.0
|
|
185
|
+
*/
|
|
186
|
+
activeDynamicSkills?: string[];
|
|
187
|
+
/**
|
|
188
|
+
* Tags used to bulk-enable dynamic skills at session construction.
|
|
189
|
+
* Any dynamic skill whose `tags` array intersects with this list will be
|
|
190
|
+
* activated automatically.
|
|
191
|
+
*
|
|
192
|
+
* @since 1.4.0
|
|
193
|
+
*/
|
|
194
|
+
activeDynamicTags?: string[];
|
|
172
195
|
/** RAG adapter */
|
|
173
196
|
ragAdapter?: IRAGAdapter;
|
|
174
197
|
/** Context compression strategies */
|
|
@@ -194,12 +217,25 @@ interface SessionConfig {
|
|
|
194
217
|
enableGoalPlanning?: boolean;
|
|
195
218
|
goalInjectionFrequency?: 'always' | 'every_N_turns' | 'on_compression';
|
|
196
219
|
goalInjectionPosition?: 'system_prompt' | 'pre_turn';
|
|
197
|
-
/** Skill budget */
|
|
220
|
+
/** Skill budget — max tokens the skill injection block may consume */
|
|
198
221
|
skillTokenBudget?: number;
|
|
222
|
+
/**
|
|
223
|
+
* Maximum tokens the provider may generate per completion call.
|
|
224
|
+
* Defaults to 2 000 when not set. This is separate from `maxTokens`
|
|
225
|
+
* which controls the total context window size.
|
|
226
|
+
*/
|
|
227
|
+
maxCompletionTokens?: number;
|
|
228
|
+
/**
|
|
229
|
+
* When `goalInjectionFrequency` is `'every_N_turns'`, re-inject the goal
|
|
230
|
+
* every N ReAct iterations. Default: 3.
|
|
231
|
+
*/
|
|
232
|
+
goalInjectionN?: number;
|
|
199
233
|
/** Callback for each turn in the session */
|
|
200
234
|
onTurn?: (turn: any) => void;
|
|
201
235
|
/** Short Term Memory Registry */
|
|
202
236
|
stmRegistry?: ShortTermMemoryRegistry;
|
|
237
|
+
/** Scratchpad storage adapter */
|
|
238
|
+
scratchpadAdapter?: IScratchpadAdapter;
|
|
203
239
|
/** Max tokens allowed for a single tool response */
|
|
204
240
|
maxTokensPerTool?: number;
|
|
205
241
|
/**
|
|
@@ -235,7 +271,7 @@ interface SessionConfig {
|
|
|
235
271
|
/** Rich trace event for observability */
|
|
236
272
|
interface TraceEvent {
|
|
237
273
|
sessionId?: string;
|
|
238
|
-
type: 'planning' | 'budget' | 'tool_call' | 'tool_result' | 'thinking' | 'system' | 'compression' | 'error';
|
|
274
|
+
type: 'planning' | 'budget' | 'tool_call' | 'tool_result' | 'thinking' | 'system' | 'compression' | 'error' | 'skill';
|
|
239
275
|
name: string;
|
|
240
276
|
input?: any;
|
|
241
277
|
output?: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as IToolDefinition, a as IProviderAdapter, b as IContextStrategy, S as ShortTermMemoryRegistry } from './
|
|
1
|
+
import { I as IToolDefinition, a as IProviderAdapter, b as IContextStrategy, S as ShortTermMemoryRegistry, c as IScratchpadAdapter } from './adapters-BhTAnrOM.mjs';
|
|
2
2
|
import { I as ILogger } from './logger-DxvKliuk.mjs';
|
|
3
|
-
import { I as ISkill } from './skills-
|
|
3
|
+
import { I as ISkill } from './skills-Y6D7zSSw.mjs';
|
|
4
4
|
import { I as IRAGAdapter } from './rag-La_Bo-J8.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -55,6 +55,11 @@ interface MCPServerConfig {
|
|
|
55
55
|
* `{ GITHUB_TOKEN: process.env.GITHUB_TOKEN! }`
|
|
56
56
|
*/
|
|
57
57
|
env?: Record<string, string>;
|
|
58
|
+
/**
|
|
59
|
+
* For `http`/`sse`: custom headers to include in requests.
|
|
60
|
+
* @example { Authorization: 'Bearer <token>' }
|
|
61
|
+
*/
|
|
62
|
+
headers?: Record<string, string>;
|
|
58
63
|
/**
|
|
59
64
|
* Per-call timeout in milliseconds. Defaults to `30_000`.
|
|
60
65
|
*/
|
|
@@ -161,6 +166,8 @@ interface SessionConfig {
|
|
|
161
166
|
adapter: IProviderAdapter;
|
|
162
167
|
/** Model string */
|
|
163
168
|
model: string;
|
|
169
|
+
/** Optional session id for scratchpad and tracing */
|
|
170
|
+
sessionId?: string;
|
|
164
171
|
/** Max context tokens */
|
|
165
172
|
maxTokens: number;
|
|
166
173
|
/** Max ReAct cycles */
|
|
@@ -169,6 +176,22 @@ interface SessionConfig {
|
|
|
169
176
|
tools?: IToolDefinition[];
|
|
170
177
|
/** Explicit skills */
|
|
171
178
|
skills?: ISkill[];
|
|
179
|
+
/**
|
|
180
|
+
* Names of dynamic skills (those with `strategy: 'dynamic'`) to enable
|
|
181
|
+
* automatically at session construction. Fixed skills are always active
|
|
182
|
+
* regardless of this list.
|
|
183
|
+
*
|
|
184
|
+
* @since 1.4.0
|
|
185
|
+
*/
|
|
186
|
+
activeDynamicSkills?: string[];
|
|
187
|
+
/**
|
|
188
|
+
* Tags used to bulk-enable dynamic skills at session construction.
|
|
189
|
+
* Any dynamic skill whose `tags` array intersects with this list will be
|
|
190
|
+
* activated automatically.
|
|
191
|
+
*
|
|
192
|
+
* @since 1.4.0
|
|
193
|
+
*/
|
|
194
|
+
activeDynamicTags?: string[];
|
|
172
195
|
/** RAG adapter */
|
|
173
196
|
ragAdapter?: IRAGAdapter;
|
|
174
197
|
/** Context compression strategies */
|
|
@@ -194,12 +217,25 @@ interface SessionConfig {
|
|
|
194
217
|
enableGoalPlanning?: boolean;
|
|
195
218
|
goalInjectionFrequency?: 'always' | 'every_N_turns' | 'on_compression';
|
|
196
219
|
goalInjectionPosition?: 'system_prompt' | 'pre_turn';
|
|
197
|
-
/** Skill budget */
|
|
220
|
+
/** Skill budget — max tokens the skill injection block may consume */
|
|
198
221
|
skillTokenBudget?: number;
|
|
222
|
+
/**
|
|
223
|
+
* Maximum tokens the provider may generate per completion call.
|
|
224
|
+
* Defaults to 2 000 when not set. This is separate from `maxTokens`
|
|
225
|
+
* which controls the total context window size.
|
|
226
|
+
*/
|
|
227
|
+
maxCompletionTokens?: number;
|
|
228
|
+
/**
|
|
229
|
+
* When `goalInjectionFrequency` is `'every_N_turns'`, re-inject the goal
|
|
230
|
+
* every N ReAct iterations. Default: 3.
|
|
231
|
+
*/
|
|
232
|
+
goalInjectionN?: number;
|
|
199
233
|
/** Callback for each turn in the session */
|
|
200
234
|
onTurn?: (turn: any) => void;
|
|
201
235
|
/** Short Term Memory Registry */
|
|
202
236
|
stmRegistry?: ShortTermMemoryRegistry;
|
|
237
|
+
/** Scratchpad storage adapter */
|
|
238
|
+
scratchpadAdapter?: IScratchpadAdapter;
|
|
203
239
|
/** Max tokens allowed for a single tool response */
|
|
204
240
|
maxTokensPerTool?: number;
|
|
205
241
|
/**
|
|
@@ -235,7 +271,7 @@ interface SessionConfig {
|
|
|
235
271
|
/** Rich trace event for observability */
|
|
236
272
|
interface TraceEvent {
|
|
237
273
|
sessionId?: string;
|
|
238
|
-
type: 'planning' | 'budget' | 'tool_call' | 'tool_result' | 'thinking' | 'system' | 'compression' | 'error';
|
|
274
|
+
type: 'planning' | 'budget' | 'tool_call' | 'tool_result' | 'thinking' | 'system' | 'compression' | 'error' | 'skill';
|
|
239
275
|
name: string;
|
|
240
276
|
input?: any;
|
|
241
277
|
output?: any;
|
package/dist/context/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as IContextStrategy, C as ContextWindow, a as IProviderAdapter,
|
|
2
|
-
export {
|
|
1
|
+
import { b as IContextStrategy, C as ContextWindow, a as IProviderAdapter, n as IStorageAdapter, c as IScratchpadAdapter } from '../adapters-BhTAnrOM.mjs';
|
|
2
|
+
export { p as STMRegistryConfig, S as ShortTermMemoryRegistry } from '../adapters-BhTAnrOM.mjs';
|
|
3
3
|
import '../rag-La_Bo-J8.mjs';
|
|
4
4
|
import '../logger-DxvKliuk.mjs';
|
|
5
5
|
|
|
@@ -30,17 +30,25 @@ declare class ContextManager {
|
|
|
30
30
|
interface SandwichCompressionConfig {
|
|
31
31
|
preserveFirst: number;
|
|
32
32
|
preserveLast: number;
|
|
33
|
-
|
|
33
|
+
/** Fire when context reaches this fraction of maxTokens (e.g. 0.80 = 80%). Default: 0.80 */
|
|
34
|
+
triggerThreshold?: number;
|
|
35
|
+
/** Max tokens for the generated summary turn. Default: unlimited */
|
|
36
|
+
summaryMaxTokens?: number;
|
|
37
|
+
/** Strategy execution priority — lower number runs first. Default: 20 */
|
|
38
|
+
priority?: number;
|
|
34
39
|
}
|
|
35
40
|
/**
|
|
36
41
|
* Sandwich compression preserves the beginning and end of the conversation,
|
|
37
42
|
* replacing the middle with a generated summary.
|
|
43
|
+
*
|
|
44
|
+
* Pair with `SummaryInjectionStrategy` to ensure the compression summary is
|
|
45
|
+
* visible to the model on every subsequent call.
|
|
38
46
|
*/
|
|
39
47
|
declare class SandwichCompressionStrategy implements IContextStrategy {
|
|
40
48
|
private adapter;
|
|
41
49
|
private config;
|
|
42
50
|
readonly name = "sandwich_compression";
|
|
43
|
-
readonly priority
|
|
51
|
+
readonly priority: number;
|
|
44
52
|
constructor(adapter: IProviderAdapter, config: SandwichCompressionConfig);
|
|
45
53
|
shouldApply(ctx: ContextWindow): boolean;
|
|
46
54
|
apply(ctx: ContextWindow): Promise<ContextWindow>;
|
|
@@ -71,22 +79,66 @@ declare class ScratchpadStrategy implements IContextStrategy {
|
|
|
71
79
|
apply(ctx: ContextWindow): Promise<ContextWindow>;
|
|
72
80
|
}
|
|
73
81
|
interface HistoryCompressionConfig {
|
|
82
|
+
/** Number of oldest turns to summarize in each compression pass */
|
|
74
83
|
windowSize: number;
|
|
84
|
+
/** Fire when context reaches this fraction of maxTokens (e.g. 0.8 = 80%) */
|
|
75
85
|
triggerAtPercent: number;
|
|
86
|
+
/** Strategy execution priority — lower number runs first. Default: 30 */
|
|
87
|
+
priority?: number;
|
|
76
88
|
}
|
|
77
89
|
/**
|
|
78
|
-
*
|
|
90
|
+
* Summarizes the oldest N uncompressed turns using a rolling-window approach.
|
|
91
|
+
*
|
|
92
|
+
* Pair with `SummaryInjectionStrategy` (priority < this one) to ensure the
|
|
93
|
+
* accumulated summary is re-injected before each provider call.
|
|
79
94
|
*/
|
|
80
95
|
declare class HistoryCompressionStrategy implements IContextStrategy {
|
|
81
96
|
private adapter;
|
|
82
97
|
private config;
|
|
83
98
|
readonly name = "history_compression";
|
|
84
|
-
readonly priority
|
|
99
|
+
readonly priority: number;
|
|
85
100
|
constructor(adapter: IProviderAdapter, config: HistoryCompressionConfig);
|
|
86
101
|
shouldApply(ctx: ContextWindow): boolean;
|
|
87
102
|
apply(ctx: ContextWindow): Promise<ContextWindow>;
|
|
88
103
|
}
|
|
89
104
|
|
|
105
|
+
interface SummaryInjectionConfig {
|
|
106
|
+
/** Strategy priority — lower number runs first. Default: 1 (runs before compression). */
|
|
107
|
+
priority?: number;
|
|
108
|
+
/** Label prepended to the injected summary block. */
|
|
109
|
+
label?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* SummaryInjectionStrategy ensures that whenever a `compressionSummary` exists on
|
|
113
|
+
* the context window, it is re-injected as a synthetic system turn at the beginning
|
|
114
|
+
* of the turn list before each provider call.
|
|
115
|
+
*
|
|
116
|
+
* **Why this matters:** `HistoryCompressionStrategy` and `SandwichCompressionStrategy`
|
|
117
|
+
* store compressed context in `ctx.compressionSummary`, but without this strategy the
|
|
118
|
+
* summary never reaches the model — the pruned turns are simply gone.
|
|
119
|
+
*
|
|
120
|
+
* Pair this with any compression strategy:
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* compressionStrategies: [
|
|
125
|
+
* new SummaryInjectionStrategy({ priority: 1 }), // always runs first
|
|
126
|
+
* new SandwichCompressionStrategy(adapter, { priority: 2, triggerThreshold: 0.80 }),
|
|
127
|
+
* ]
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* The strategy is idempotent: if a summary turn already exists it is updated in-place
|
|
131
|
+
* rather than appended again.
|
|
132
|
+
*/
|
|
133
|
+
declare class SummaryInjectionStrategy implements IContextStrategy {
|
|
134
|
+
readonly name = "summary_injection";
|
|
135
|
+
readonly priority: number;
|
|
136
|
+
private readonly label;
|
|
137
|
+
constructor(config?: SummaryInjectionConfig);
|
|
138
|
+
shouldApply(ctx: ContextWindow): boolean;
|
|
139
|
+
apply(ctx: ContextWindow): Promise<ContextWindow>;
|
|
140
|
+
}
|
|
141
|
+
|
|
90
142
|
/**
|
|
91
143
|
* An in-memory implementation of IStorageAdapter for holding Short Term Memory.
|
|
92
144
|
* Ideal for testing or single-process lightweight usage.
|
|
@@ -139,4 +191,16 @@ declare class InMemoryStorageAdapter implements IStorageAdapter {
|
|
|
139
191
|
healthCheck(): Promise<boolean>;
|
|
140
192
|
}
|
|
141
193
|
|
|
142
|
-
|
|
194
|
+
/**
|
|
195
|
+
* In-memory scratchpad adapter, keyed by sessionId.
|
|
196
|
+
* Ideal for testing or single-process usage.
|
|
197
|
+
*/
|
|
198
|
+
declare class InMemoryScratchpadAdapter implements IScratchpadAdapter {
|
|
199
|
+
private store;
|
|
200
|
+
read(sessionId: string): Promise<string | undefined>;
|
|
201
|
+
write(sessionId: string, content: string): Promise<void>;
|
|
202
|
+
clear(sessionId: string): Promise<void>;
|
|
203
|
+
healthCheck(): Promise<boolean>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export { ContextManager, type HistoryCompressionConfig, HistoryCompressionStrategy, InMemoryScratchpadAdapter, InMemoryStorageAdapter, type SandwichCompressionConfig, SandwichCompressionStrategy, ScratchpadStrategy, type SummaryInjectionConfig, SummaryInjectionStrategy };
|