@animalabs/context-manager 0.1.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/dist/src/blob-manager.d.ts +37 -0
- package/dist/src/blob-manager.d.ts.map +1 -0
- package/dist/src/blob-manager.js +128 -0
- package/dist/src/blob-manager.js.map +1 -0
- package/dist/src/context-log.d.ts +99 -0
- package/dist/src/context-log.d.ts.map +1 -0
- package/dist/src/context-log.js +277 -0
- package/dist/src/context-log.js.map +1 -0
- package/dist/src/context-manager.d.ts +245 -0
- package/dist/src/context-manager.d.ts.map +1 -0
- package/dist/src/context-manager.js +553 -0
- package/dist/src/context-manager.js.map +1 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +12 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/message-store.d.ts +135 -0
- package/dist/src/message-store.d.ts.map +1 -0
- package/dist/src/message-store.js +372 -0
- package/dist/src/message-store.js.map +1 -0
- package/dist/src/strategies/autobiographical.d.ts +199 -0
- package/dist/src/strategies/autobiographical.d.ts.map +1 -0
- package/dist/src/strategies/autobiographical.js +1122 -0
- package/dist/src/strategies/autobiographical.js.map +1 -0
- package/dist/src/strategies/index.d.ts +3 -0
- package/dist/src/strategies/index.d.ts.map +1 -0
- package/dist/src/strategies/index.js +3 -0
- package/dist/src/strategies/index.js.map +1 -0
- package/dist/src/strategies/knowledge.d.ts +46 -0
- package/dist/src/strategies/knowledge.d.ts.map +1 -0
- package/dist/src/strategies/knowledge.js +270 -0
- package/dist/src/strategies/knowledge.js.map +1 -0
- package/dist/src/strategies/passthrough.d.ts +17 -0
- package/dist/src/strategies/passthrough.d.ts.map +1 -0
- package/dist/src/strategies/passthrough.js +69 -0
- package/dist/src/strategies/passthrough.js.map +1 -0
- package/dist/src/types/context.d.ts +108 -0
- package/dist/src/types/context.d.ts.map +1 -0
- package/dist/src/types/context.js +2 -0
- package/dist/src/types/context.js.map +1 -0
- package/dist/src/types/index.d.ts +5 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +2 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/message.d.ts +129 -0
- package/dist/src/types/message.d.ts.map +1 -0
- package/dist/src/types/message.js +2 -0
- package/dist/src/types/message.js.map +1 -0
- package/dist/src/types/strategy.d.ts +233 -0
- package/dist/src/types/strategy.d.ts.map +1 -0
- package/dist/src/types/strategy.js +32 -0
- package/dist/src/types/strategy.js.map +1 -0
- package/dist/test/autobiographical.test.d.ts +2 -0
- package/dist/test/autobiographical.test.d.ts.map +1 -0
- package/dist/test/autobiographical.test.js +46 -0
- package/dist/test/autobiographical.test.js.map +1 -0
- package/dist/test/head-window-reset.test.d.ts +17 -0
- package/dist/test/head-window-reset.test.d.ts.map +1 -0
- package/dist/test/head-window-reset.test.js +342 -0
- package/dist/test/head-window-reset.test.js.map +1 -0
- package/dist/test/integration.test.d.ts +2 -0
- package/dist/test/integration.test.d.ts.map +1 -0
- package/dist/test/integration.test.js +1341 -0
- package/dist/test/integration.test.js.map +1 -0
- package/dist/test/knowledge.test.d.ts +2 -0
- package/dist/test/knowledge.test.d.ts.map +1 -0
- package/dist/test/knowledge.test.js +617 -0
- package/dist/test/knowledge.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +48 -0
- package/src/blob-manager.ts +155 -0
- package/src/context-log.ts +342 -0
- package/src/context-manager.ts +726 -0
- package/src/index.ts +50 -0
- package/src/message-store.ts +479 -0
- package/src/strategies/autobiographical.ts +1355 -0
- package/src/strategies/index.ts +2 -0
- package/src/strategies/knowledge.ts +336 -0
- package/src/strategies/passthrough.ts +98 -0
- package/src/types/context.ts +119 -0
- package/src/types/index.ts +42 -0
- package/src/types/message.ts +140 -0
- package/src/types/strategy.ts +282 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { ContentBlock } from '@animalabs/membrane';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unique identifier for a message in the store.
|
|
5
|
+
* Corresponds to Chronicle record ID.
|
|
6
|
+
*/
|
|
7
|
+
export type MessageId = string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Sequence number within a branch.
|
|
11
|
+
*/
|
|
12
|
+
export type Sequence = number;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Branch identifier.
|
|
16
|
+
*/
|
|
17
|
+
export type BranchId = string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Metadata attached to a stored message.
|
|
21
|
+
*/
|
|
22
|
+
export interface MessageMetadata {
|
|
23
|
+
/** Application-defined tags */
|
|
24
|
+
tags?: string[];
|
|
25
|
+
/** Original source ID (e.g., from external system) */
|
|
26
|
+
sourceId?: string;
|
|
27
|
+
/** Custom key-value pairs */
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A message stored in the message store.
|
|
33
|
+
* This is the source of truth for all conversation history.
|
|
34
|
+
*/
|
|
35
|
+
export interface StoredMessage {
|
|
36
|
+
/** Unique message identifier */
|
|
37
|
+
id: MessageId;
|
|
38
|
+
/** Sequence number within current branch */
|
|
39
|
+
sequence: Sequence;
|
|
40
|
+
/** Participant name: "User", "Claude", "Alice", etc. */
|
|
41
|
+
participant: string;
|
|
42
|
+
/** Message content blocks (uses Membrane types) */
|
|
43
|
+
content: ContentBlock[];
|
|
44
|
+
/** Optional metadata */
|
|
45
|
+
metadata?: MessageMetadata;
|
|
46
|
+
/** When the message was stored */
|
|
47
|
+
timestamp: Date;
|
|
48
|
+
/** IDs of messages that caused this one (from Chronicle causation) */
|
|
49
|
+
causedBy?: MessageId[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Reference to a blob stored in Chronicle.
|
|
54
|
+
* Used internally to avoid duplicating media content.
|
|
55
|
+
*/
|
|
56
|
+
export interface BlobReference {
|
|
57
|
+
/** SHA-256 hash of the blob content */
|
|
58
|
+
hash: string;
|
|
59
|
+
/** MIME type of the content */
|
|
60
|
+
mediaType: string;
|
|
61
|
+
/** Original content block type */
|
|
62
|
+
originalType: 'image' | 'document' | 'audio' | 'video';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Content block with blob references instead of inline data.
|
|
67
|
+
* Used for storage efficiency.
|
|
68
|
+
*
|
|
69
|
+
* - Media with base64 data is replaced with blob_ref
|
|
70
|
+
* - URL-based images pass through unchanged
|
|
71
|
+
* - All other content types pass through unchanged
|
|
72
|
+
*/
|
|
73
|
+
export type StoredContentBlock =
|
|
74
|
+
| Exclude<ContentBlock, { type: 'document' | 'audio' | 'video' }>
|
|
75
|
+
| { type: 'blob_ref'; ref: BlobReference };
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Internal representation of a stored message with blob references.
|
|
79
|
+
*/
|
|
80
|
+
export interface StoredMessageInternal {
|
|
81
|
+
id: MessageId;
|
|
82
|
+
sequence: Sequence;
|
|
83
|
+
participant: string;
|
|
84
|
+
content: StoredContentBlock[];
|
|
85
|
+
metadata?: MessageMetadata;
|
|
86
|
+
timestamp: number; // Unix timestamp for storage
|
|
87
|
+
causedBy?: MessageId[];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Query filter for message lookup.
|
|
92
|
+
* All fields are optional - omitted fields match everything.
|
|
93
|
+
*/
|
|
94
|
+
export interface MessageQuery {
|
|
95
|
+
/**
|
|
96
|
+
* Filter by external source (e.g., 'discord', 'slack').
|
|
97
|
+
* Matches messages where metadata.external.source === source.
|
|
98
|
+
*/
|
|
99
|
+
source?: string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Filter by specific external IDs.
|
|
103
|
+
* Matches messages where metadata.external.id is in this list.
|
|
104
|
+
*/
|
|
105
|
+
externalIds?: string[];
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Filter by participant name.
|
|
109
|
+
*/
|
|
110
|
+
participant?: string;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Filter by metadata fields.
|
|
114
|
+
* Supports dot notation for nested fields (e.g., 'external.channelId').
|
|
115
|
+
* Values are compared with strict equality.
|
|
116
|
+
*/
|
|
117
|
+
metadata?: Record<string, unknown>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Maximum number of messages to return.
|
|
121
|
+
* If not specified, returns all matching messages.
|
|
122
|
+
*/
|
|
123
|
+
limit?: number;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Return messages in reverse order (newest first).
|
|
127
|
+
* Default: false (oldest first).
|
|
128
|
+
*/
|
|
129
|
+
reverse?: boolean;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Result of a message query.
|
|
134
|
+
*/
|
|
135
|
+
export interface MessageQueryResult {
|
|
136
|
+
/** Matching messages */
|
|
137
|
+
messages: StoredMessage[];
|
|
138
|
+
/** Total count of matching messages (may be more than returned if limited) */
|
|
139
|
+
totalCount: number;
|
|
140
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import type { Membrane } from '@animalabs/membrane';
|
|
2
|
+
import type { StoredMessage, MessageId, Sequence } from './message.js';
|
|
3
|
+
import type { ContextEntry, TokenBudget, PendingWork } from './context.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Read-only view of the message store for strategies.
|
|
7
|
+
*/
|
|
8
|
+
export interface MessageStoreView {
|
|
9
|
+
/** Get all messages */
|
|
10
|
+
getAll(): StoredMessage[];
|
|
11
|
+
/** Get a specific message */
|
|
12
|
+
get(id: MessageId): StoredMessage | null;
|
|
13
|
+
/** Get messages from a specific index */
|
|
14
|
+
getFrom(index: number): StoredMessage[];
|
|
15
|
+
/** Get the last N messages */
|
|
16
|
+
getTail(count: number): StoredMessage[];
|
|
17
|
+
/** Get total message count */
|
|
18
|
+
length(): number;
|
|
19
|
+
/** Estimate tokens for a message */
|
|
20
|
+
estimateTokens(message: StoredMessage): number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Read-only view of the context log for strategies.
|
|
25
|
+
*/
|
|
26
|
+
export interface ContextLogView {
|
|
27
|
+
/** Get all entries */
|
|
28
|
+
getAll(): ContextEntry[];
|
|
29
|
+
/** Get entries from a specific index */
|
|
30
|
+
getFrom(index: number): ContextEntry[];
|
|
31
|
+
/** Get the last N entries */
|
|
32
|
+
getTail(count: number): ContextEntry[];
|
|
33
|
+
/** Get total entry count */
|
|
34
|
+
length(): number;
|
|
35
|
+
/** Estimate tokens for an entry */
|
|
36
|
+
estimateTokens(entry: ContextEntry): number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Context provided to strategy methods.
|
|
41
|
+
*/
|
|
42
|
+
export interface StrategyContext {
|
|
43
|
+
/** Read-only view of message store */
|
|
44
|
+
messageStore: MessageStoreView;
|
|
45
|
+
/** Read-only view of context log */
|
|
46
|
+
contextLog: ContextLogView;
|
|
47
|
+
/** Membrane instance for LLM calls (compression) */
|
|
48
|
+
membrane?: Membrane;
|
|
49
|
+
/** Current sequence number */
|
|
50
|
+
currentSequence: Sequence;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Result of readiness check.
|
|
55
|
+
*/
|
|
56
|
+
export interface ReadinessState {
|
|
57
|
+
/** Whether compile() can proceed immediately */
|
|
58
|
+
ready: boolean;
|
|
59
|
+
/** Promise that resolves when ready (if not ready) */
|
|
60
|
+
pendingWork?: Promise<void>;
|
|
61
|
+
/** Description of pending work */
|
|
62
|
+
description?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Pluggable strategy for context management.
|
|
67
|
+
* Strategies control how context is selected, compressed, and maintained.
|
|
68
|
+
*/
|
|
69
|
+
export interface ContextStrategy {
|
|
70
|
+
/** Strategy name for identification */
|
|
71
|
+
readonly name: string;
|
|
72
|
+
|
|
73
|
+
/** Maximum tokens per individual message. Used by the framework to truncate
|
|
74
|
+
* tool results in-flight (yielding stream) and at storage time.
|
|
75
|
+
* 0 or undefined = no limit. */
|
|
76
|
+
readonly maxMessageTokens?: number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Initialize the strategy with context.
|
|
80
|
+
* Called when strategy is set on ContextManager.
|
|
81
|
+
*/
|
|
82
|
+
initialize?(ctx: StrategyContext): Promise<void>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Periodic background maintenance.
|
|
86
|
+
* Called by application to trigger compression, indexing, etc.
|
|
87
|
+
*/
|
|
88
|
+
tick?(ctx: StrategyContext): Promise<void>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* React to new messages.
|
|
92
|
+
* Called after a message is added to the store.
|
|
93
|
+
*/
|
|
94
|
+
onNewMessage?(message: StoredMessage, ctx: StrategyContext): Promise<void>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Check if strategy is ready to compile.
|
|
98
|
+
* Returns pending work info if not ready.
|
|
99
|
+
*/
|
|
100
|
+
checkReadiness(): ReadinessState;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Select and order context entries for compilation.
|
|
104
|
+
* This is the core method that determines what goes in the context window.
|
|
105
|
+
*/
|
|
106
|
+
select(
|
|
107
|
+
store: MessageStoreView,
|
|
108
|
+
log: ContextLogView,
|
|
109
|
+
budget: TokenBudget
|
|
110
|
+
): ContextEntry[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Strategy that supports resetting the head window for topic transitions.
|
|
115
|
+
* Implemented by AutobiographicalStrategy and its subclasses.
|
|
116
|
+
*/
|
|
117
|
+
export interface ResettableStrategy extends ContextStrategy {
|
|
118
|
+
/** Reset the head window to start from a new message ID. */
|
|
119
|
+
resetHeadWindow(newStartId: string | null): void;
|
|
120
|
+
/** Generate a transition summary from the current head window + summaries. */
|
|
121
|
+
generateTransitionSummary(ctx: StrategyContext): Promise<string>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Type guard for strategies that support head window reset.
|
|
126
|
+
*/
|
|
127
|
+
export function isResettableStrategy(s: ContextStrategy): s is ResettableStrategy {
|
|
128
|
+
return 'resetHeadWindow' in s && typeof (s as ResettableStrategy).resetHeadWindow === 'function';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Configuration for the Autobiographical strategy.
|
|
133
|
+
*/
|
|
134
|
+
export interface AutobiographicalConfig {
|
|
135
|
+
/** Target tokens per chunk (~3000) */
|
|
136
|
+
targetChunkTokens: number;
|
|
137
|
+
/** Recent tokens to keep uncompressed (~30000) */
|
|
138
|
+
recentWindowTokens: number;
|
|
139
|
+
/** Tokens at the head of the conversation to preserve verbatim (default: 0).
|
|
140
|
+
* Messages within this window are never chunked or compressed — they survive
|
|
141
|
+
* as raw copies so initial instructions retain full granularity. */
|
|
142
|
+
headWindowTokens: number;
|
|
143
|
+
/** Always break at message boundaries */
|
|
144
|
+
chunkOnMessageBoundary: boolean;
|
|
145
|
+
/** Don't count attachment tokens toward chunk size */
|
|
146
|
+
attachmentsIgnoreSize: boolean;
|
|
147
|
+
/** When true, onNewMessage() fires tick() as a background promise so compression
|
|
148
|
+
* runs automatically without the framework calling tick() explicitly. */
|
|
149
|
+
autoTickOnNewMessage: boolean;
|
|
150
|
+
/** System prompt for summarization */
|
|
151
|
+
summarySystemPrompt?: string;
|
|
152
|
+
/** User prompt template for summarization. Use {content} for the transcript. */
|
|
153
|
+
summaryUserPrompt?: string;
|
|
154
|
+
/** Label shown before summaries in compiled context */
|
|
155
|
+
summaryContextLabel?: string;
|
|
156
|
+
/** Participant name for the summary (defaults to "Summary") */
|
|
157
|
+
summaryParticipant?: string;
|
|
158
|
+
/** Model to use for compression (defaults to claude-sonnet) */
|
|
159
|
+
compressionModel?: string;
|
|
160
|
+
/** Maximum tokens per individual message in compiled output. Messages exceeding
|
|
161
|
+
* this limit have their text/tool_result content truncated. 0 = no limit. */
|
|
162
|
+
maxMessageTokens: number;
|
|
163
|
+
|
|
164
|
+
// Legacy aliases (deprecated, use summary* instead)
|
|
165
|
+
/** @deprecated Use summarySystemPrompt */
|
|
166
|
+
diarySystemPrompt?: string;
|
|
167
|
+
/** @deprecated Use summaryUserPrompt */
|
|
168
|
+
diaryUserPrompt?: string;
|
|
169
|
+
|
|
170
|
+
// --- Hierarchical compression (L1/L2/L3 pyramid) ---
|
|
171
|
+
|
|
172
|
+
/** Enable hierarchical 3-level compression. Set to false for single-level legacy compression. */
|
|
173
|
+
hierarchical?: boolean;
|
|
174
|
+
/** Number of unmerged summaries before merging to the next level (default: 6) */
|
|
175
|
+
mergeThreshold?: number;
|
|
176
|
+
/** Token target for each summary at any level (default: 2000) */
|
|
177
|
+
summaryTargetTokens?: number;
|
|
178
|
+
/** Token budget for L3 summaries in select() (default: 30000) */
|
|
179
|
+
l3BudgetTokens?: number;
|
|
180
|
+
/** Token budget for L2 summaries in select() (default: 30000) */
|
|
181
|
+
l2BudgetTokens?: number;
|
|
182
|
+
/** Token budget for L1 summaries in select() (default: 30000) */
|
|
183
|
+
l1BudgetTokens?: number;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Compression level in the hierarchical pyramid.
|
|
188
|
+
*/
|
|
189
|
+
export type SummaryLevel = 1 | 2 | 3;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* A summary entry in the hierarchical memory pyramid.
|
|
193
|
+
* L1: compressed from raw message chunks.
|
|
194
|
+
* L2: merged from mergeThreshold L1s.
|
|
195
|
+
* L3: merged from mergeThreshold L2s.
|
|
196
|
+
*/
|
|
197
|
+
export interface SummaryEntry {
|
|
198
|
+
/** Unique ID (e.g., "L1-0", "L2-3") */
|
|
199
|
+
id: string;
|
|
200
|
+
/** Compression level */
|
|
201
|
+
level: SummaryLevel;
|
|
202
|
+
/** The summary text */
|
|
203
|
+
content: string;
|
|
204
|
+
/** Estimated token count (content.length / 4) */
|
|
205
|
+
tokens: number;
|
|
206
|
+
/** Level of the sources: 0 = raw messages, 1 = L1s, 2 = L2s */
|
|
207
|
+
sourceLevel: 0 | 1 | 2;
|
|
208
|
+
/** IDs of source items (message IDs for L1, summary IDs for L2/L3) */
|
|
209
|
+
sourceIds: string[];
|
|
210
|
+
/** Range of original message IDs covered */
|
|
211
|
+
sourceRange: { first: string; last: string };
|
|
212
|
+
/** If merged into a higher-level summary, that summary's ID */
|
|
213
|
+
mergedInto?: string;
|
|
214
|
+
/** Creation timestamp */
|
|
215
|
+
created: number;
|
|
216
|
+
/** Phase type tag (used by KnowledgeStrategy for asymmetric budget) */
|
|
217
|
+
phaseType?: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Phase type for knowledge extraction workflows.
|
|
222
|
+
*/
|
|
223
|
+
export type PhaseType = 'research' | 'synthesis' | 'lesson' | 'subagent';
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Configuration for the Knowledge strategy.
|
|
227
|
+
* Extends AutobiographicalConfig with phase-aware compression settings.
|
|
228
|
+
*/
|
|
229
|
+
export interface KnowledgeConfig extends AutobiographicalConfig {
|
|
230
|
+
/** Tool name prefixes that indicate research/retrieval activity.
|
|
231
|
+
* Default: ['mcpl:', 'zulip:'] */
|
|
232
|
+
researchToolPrefixes?: string[];
|
|
233
|
+
/** Tool name prefixes that indicate subagent coordination.
|
|
234
|
+
* Default: ['subagent:'] */
|
|
235
|
+
subagentToolPrefixes?: string[];
|
|
236
|
+
/** Exact tool names that indicate lesson capture.
|
|
237
|
+
* Default: ['lessons:create', 'lessons:update'] */
|
|
238
|
+
lessonToolNames?: string[];
|
|
239
|
+
|
|
240
|
+
/** Max chunk tokens for research phases (default: 2x targetChunkTokens) */
|
|
241
|
+
maxResearchChunkTokens?: number;
|
|
242
|
+
/** Max chunk tokens for synthesis phases (default: 1.5x targetChunkTokens) */
|
|
243
|
+
maxSynthesisChunkTokens?: number;
|
|
244
|
+
/** Max chunk tokens for subagent phases (default: 2x targetChunkTokens) */
|
|
245
|
+
maxSubagentChunkTokens?: number;
|
|
246
|
+
/** Max chunk tokens for lesson phases (default: targetChunkTokens) */
|
|
247
|
+
maxLessonChunkTokens?: number;
|
|
248
|
+
|
|
249
|
+
/** Maximum fraction of L1 budget for research summaries (default: 0.3) */
|
|
250
|
+
researchL1BudgetCap?: number;
|
|
251
|
+
/** Minimum fraction of L1 budget for synthesis summaries (default: 0.4) */
|
|
252
|
+
synthesisL1BudgetFloor?: number;
|
|
253
|
+
/** Maximum fraction of L1 budget for synthesis summaries (default: 0.7).
|
|
254
|
+
* Prevents synthesis from starving lessons/subagent/research phases. */
|
|
255
|
+
synthesisL1BudgetCap?: number;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Default configuration for Autobiographical strategy.
|
|
260
|
+
*/
|
|
261
|
+
export const DEFAULT_AUTOBIOGRAPHICAL_CONFIG: AutobiographicalConfig = {
|
|
262
|
+
targetChunkTokens: 3000,
|
|
263
|
+
recentWindowTokens: 30000,
|
|
264
|
+
headWindowTokens: 0,
|
|
265
|
+
chunkOnMessageBoundary: true,
|
|
266
|
+
attachmentsIgnoreSize: true,
|
|
267
|
+
autoTickOnNewMessage: false,
|
|
268
|
+
summarySystemPrompt: 'You are forming a memory of an earlier part of this conversation. The context you see is continuous with your experience - what you read is what happened. Write authentically about what occurred.',
|
|
269
|
+
summaryUserPrompt: `What do you recall from this part of the conversation?
|
|
270
|
+
|
|
271
|
+
{content}
|
|
272
|
+
|
|
273
|
+
Capture what matters:
|
|
274
|
+
- What was discussed or accomplished
|
|
275
|
+
- Key decisions, insights, or information exchanged
|
|
276
|
+
- Important context that would be needed to continue
|
|
277
|
+
|
|
278
|
+
Write naturally, as recollection of what you experienced.`,
|
|
279
|
+
summaryContextLabel: 'What do you remember from earlier?',
|
|
280
|
+
summaryParticipant: 'Claude',
|
|
281
|
+
maxMessageTokens: 0,
|
|
282
|
+
};
|