@lumenflow/memory 2.9.0 → 2.11.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/index.js +1 -0
- package/dist/mem-recover-core.js +258 -0
- package/package.json +2 -2
- package/dist/index.d.ts +0 -17
- package/dist/mem-checkpoint-core.d.ts +0 -91
- package/dist/mem-cleanup-core.d.ts +0 -202
- package/dist/mem-create-core.d.ts +0 -93
- package/dist/mem-export-core.d.ts +0 -33
- package/dist/mem-id.d.ts +0 -91
- package/dist/mem-init-core.d.ts +0 -93
- package/dist/mem-ready-core.d.ts +0 -56
- package/dist/mem-signal-core.d.ts +0 -132
- package/dist/mem-start-core.d.ts +0 -76
- package/dist/mem-summarize-core.d.ts +0 -105
- package/dist/mem-triage-core.d.ts +0 -127
- package/dist/memory-schema.d.ts +0 -150
- package/dist/memory-store.d.ts +0 -108
- package/dist/paths.d.ts +0 -28
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Export Core (WU-1137)
|
|
3
|
-
*
|
|
4
|
-
* Render memory.jsonl as markdown or JSON with basic filters.
|
|
5
|
-
* Designed for human-readable inspection without changing storage format.
|
|
6
|
-
*/
|
|
7
|
-
import type { MemoryNode } from './memory-schema.js';
|
|
8
|
-
/** Supported output formats for export */
|
|
9
|
-
export type ExportFormat = 'markdown' | 'json';
|
|
10
|
-
/** Export filters */
|
|
11
|
-
export interface ExportOptions {
|
|
12
|
-
/** WU ID filter (e.g., WU-1234) */
|
|
13
|
-
wuId?: string;
|
|
14
|
-
/** Node type filter (e.g., discovery, checkpoint) */
|
|
15
|
-
type?: string;
|
|
16
|
-
/** Lifecycle filter (ephemeral, session, wu, project) */
|
|
17
|
-
lifecycle?: string;
|
|
18
|
-
/** Output format (markdown or json) */
|
|
19
|
-
format?: ExportFormat;
|
|
20
|
-
}
|
|
21
|
-
/** Export result */
|
|
22
|
-
export interface ExportResult {
|
|
23
|
-
format: ExportFormat;
|
|
24
|
-
nodes: MemoryNode[];
|
|
25
|
-
output: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Export memory nodes in the requested format.
|
|
29
|
-
*
|
|
30
|
-
* @param baseDir - Project base directory
|
|
31
|
-
* @param options - Export options
|
|
32
|
-
*/
|
|
33
|
-
export declare function exportMemory(baseDir: string, options?: ExportOptions): Promise<ExportResult>;
|
package/dist/mem-id.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory ID Generator (WU-1465)
|
|
3
|
-
*
|
|
4
|
-
* Hash-based collision-free ID generation for memory nodes.
|
|
5
|
-
* Format: mem-[4 hex chars] derived from content hash.
|
|
6
|
-
* Supports hierarchical IDs (mem-a1b2.1.2) for sub-task decomposition.
|
|
7
|
-
*
|
|
8
|
-
* @see {@link tools/lib/__tests__/mem-id.test.mjs} - Tests
|
|
9
|
-
* @see {@link tools/lib/memory-schema.mjs} - Schema definitions
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Regex patterns for memory ID validation
|
|
13
|
-
*/
|
|
14
|
-
export declare const MEM_ID_PATTERNS: {
|
|
15
|
-
/**
|
|
16
|
-
* Base memory ID format: mem-[a-f0-9]{4}
|
|
17
|
-
* Only lowercase hex characters (0-9, a-f)
|
|
18
|
-
*/
|
|
19
|
-
BASE_ID: RegExp;
|
|
20
|
-
/**
|
|
21
|
-
* Hierarchical memory ID format: mem-[a-f0-9]{4}(.[1-9][0-9]*)*
|
|
22
|
-
* Base ID followed by optional dot-separated positive integers
|
|
23
|
-
* Examples: mem-a1b2, mem-a1b2.1, mem-a1b2.1.2
|
|
24
|
-
*/
|
|
25
|
-
HIERARCHICAL_ID: RegExp;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Generates a deterministic memory ID from content.
|
|
29
|
-
*
|
|
30
|
-
* Uses SHA-256 hash of the content, taking the first 4 hex characters.
|
|
31
|
-
* Same content always produces the same ID (deterministic).
|
|
32
|
-
*
|
|
33
|
-
* @param content - Content to hash for ID generation
|
|
34
|
-
* @returns Memory ID in format mem-[a-f0-9]{4}
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* const id = generateMemId('discovered file at src/utils.mjs');
|
|
38
|
-
* // Returns something like 'mem-a3f2'
|
|
39
|
-
*/
|
|
40
|
-
export declare function generateMemId(content: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Generates a hierarchical memory ID by appending an index to a parent ID.
|
|
43
|
-
*
|
|
44
|
-
* Used for sub-task decomposition where a parent task (mem-a1b2) has
|
|
45
|
-
* child tasks (mem-a1b2.1, mem-a1b2.2) and grandchildren (mem-a1b2.1.1).
|
|
46
|
-
*
|
|
47
|
-
* @param parentId - Parent memory ID (base or hierarchical)
|
|
48
|
-
* @param index - Positive integer index (1-based)
|
|
49
|
-
* @returns Hierarchical memory ID
|
|
50
|
-
* @throws If parentId is invalid or index is not positive
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* generateHierarchicalId('mem-a1b2', 1); // 'mem-a1b2.1'
|
|
54
|
-
* generateHierarchicalId('mem-a1b2.1', 2); // 'mem-a1b2.1.2'
|
|
55
|
-
*/
|
|
56
|
-
export declare function generateHierarchicalId(parentId: string, index: number): string;
|
|
57
|
-
/**
|
|
58
|
-
* Validation result from validateMemId
|
|
59
|
-
*/
|
|
60
|
-
export interface MemIdValidationResult {
|
|
61
|
-
/** Whether the ID is valid */
|
|
62
|
-
valid: boolean;
|
|
63
|
-
/** Type of ID if valid */
|
|
64
|
-
type?: 'base' | 'hierarchical';
|
|
65
|
-
/** Base ID portion if hierarchical */
|
|
66
|
-
baseId?: string;
|
|
67
|
-
/** Hierarchical indices (empty for base IDs) */
|
|
68
|
-
indices: number[];
|
|
69
|
-
/** Error message if invalid */
|
|
70
|
-
error?: string;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Validates a memory ID and extracts its components.
|
|
74
|
-
*
|
|
75
|
-
* Returns validation result with type classification and parsed components.
|
|
76
|
-
* Compatible with MEMORY_PATTERNS.MEMORY_ID from memory-schema.mjs.
|
|
77
|
-
*
|
|
78
|
-
* @param id - Memory ID to validate
|
|
79
|
-
* @returns Validation result with parsed components
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* validateMemId('mem-a1b2');
|
|
83
|
-
* // { valid: true, type: 'base', baseId: 'mem-a1b2', indices: [] }
|
|
84
|
-
*
|
|
85
|
-
* validateMemId('mem-a1b2.1.2');
|
|
86
|
-
* // { valid: true, type: 'hierarchical', baseId: 'mem-a1b2', indices: [1, 2] }
|
|
87
|
-
*
|
|
88
|
-
* validateMemId('invalid');
|
|
89
|
-
* // { valid: false, error: 'Invalid memory ID format', indices: [] }
|
|
90
|
-
*/
|
|
91
|
-
export declare function validateMemId(id: string): MemIdValidationResult;
|
package/dist/mem-init-core.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Init Core (WU-1464)
|
|
3
|
-
*
|
|
4
|
-
* Core logic for initializing memory layer in a repository.
|
|
5
|
-
* Creates .lumenflow/memory/ directory with empty memory.jsonl and config.yaml.
|
|
6
|
-
*
|
|
7
|
-
* @see {@link tools/__tests__/mem-init.test.mjs} - Tests
|
|
8
|
-
* @see {@link tools/lib/memory-store.mjs} - Memory store operations
|
|
9
|
-
* @see {@link tools/lib/memory-schema.mjs} - Memory schema definitions
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Memory layer file/directory paths
|
|
13
|
-
*
|
|
14
|
-
* Uses LUMENFLOW_MEMORY_PATHS from local paths.ts to avoid circular dependency.
|
|
15
|
-
*/
|
|
16
|
-
export declare const MEMORY_PATHS: {
|
|
17
|
-
/** Memory directory relative to project root */
|
|
18
|
-
MEMORY_DIR: ".lumenflow/memory";
|
|
19
|
-
/** Memory JSONL file name */
|
|
20
|
-
MEMORY_FILE: string;
|
|
21
|
-
/** Config YAML file name */
|
|
22
|
-
CONFIG_FILE: string;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Default memory layer configuration
|
|
26
|
-
*
|
|
27
|
-
* Retention values are in seconds:
|
|
28
|
-
* - ephemeral: 0 (immediate discard)
|
|
29
|
-
* - session: 3600 (1 hour)
|
|
30
|
-
* - wu: 604800 (7 days)
|
|
31
|
-
* - project: -1 (never expire)
|
|
32
|
-
*/
|
|
33
|
-
export declare const DEFAULT_CONFIG: {
|
|
34
|
-
/** Config schema version */
|
|
35
|
-
version: number;
|
|
36
|
-
/** Retention policy for each lifecycle */
|
|
37
|
-
retention: {
|
|
38
|
-
/** Ephemeral nodes are discarded immediately after use */
|
|
39
|
-
ephemeral: number;
|
|
40
|
-
/** Session nodes expire after 1 hour */
|
|
41
|
-
session: number;
|
|
42
|
-
/** WU nodes expire after 7 days */
|
|
43
|
-
wu: number;
|
|
44
|
-
/** Project nodes never expire (-1 = infinite) */
|
|
45
|
-
project: number;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Memory initialization paths
|
|
50
|
-
*/
|
|
51
|
-
interface InitMemoryPaths {
|
|
52
|
-
memoryDir: string;
|
|
53
|
-
memoryJsonl: string;
|
|
54
|
-
configYaml: string;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Memory initialization created flags
|
|
58
|
-
*/
|
|
59
|
-
interface InitMemoryCreated {
|
|
60
|
-
directory: boolean;
|
|
61
|
-
memoryJsonl: boolean;
|
|
62
|
-
configYaml: boolean;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Memory initialization result
|
|
66
|
-
*/
|
|
67
|
-
export interface InitMemoryResult {
|
|
68
|
-
success: boolean;
|
|
69
|
-
alreadyInitialized: boolean;
|
|
70
|
-
paths: InitMemoryPaths;
|
|
71
|
-
created: InitMemoryCreated;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Initialize memory layer in a repository.
|
|
75
|
-
*
|
|
76
|
-
* Creates:
|
|
77
|
-
* - .lumenflow/memory/ directory
|
|
78
|
-
* - memory.jsonl (empty if not exists)
|
|
79
|
-
* - config.yaml (default settings if not exists)
|
|
80
|
-
*
|
|
81
|
-
* Idempotent: Running multiple times does not corrupt existing data.
|
|
82
|
-
*
|
|
83
|
-
* @param baseDir - Base directory of the repository
|
|
84
|
-
* @returns Result object with success, paths, and created flags
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* const result = await initMemory(process.cwd());
|
|
88
|
-
* if (result.success) {
|
|
89
|
-
* console.log('Memory initialized at:', result.paths.memoryDir);
|
|
90
|
-
* }
|
|
91
|
-
*/
|
|
92
|
-
export declare function initMemory(baseDir: string): Promise<InitMemoryResult>;
|
|
93
|
-
export {};
|
package/dist/mem-ready-core.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Ready Core (WU-1468)
|
|
3
|
-
*
|
|
4
|
-
* Deterministic ready-work query for "what next?" oracle.
|
|
5
|
-
* Returns open nodes with no blockers, ordered by priority then createdAt.
|
|
6
|
-
*
|
|
7
|
-
* Ordering algorithm:
|
|
8
|
-
* 1. Priority ASC (P0 first, then P1, P2, P3; nodes without priority last)
|
|
9
|
-
* 2. CreatedAt ASC (oldest first for same priority)
|
|
10
|
-
* 3. ID ASC (stable sort for identical priority and timestamp)
|
|
11
|
-
*
|
|
12
|
-
* A node is "ready" if:
|
|
13
|
-
* - Linked to the specified WU
|
|
14
|
-
* - Not blocked by another node (no `blocks` relationship pointing to it)
|
|
15
|
-
* - No `metadata.blocked_by` array set
|
|
16
|
-
* - Lifecycle is not `ephemeral`
|
|
17
|
-
* - Status is not `closed` (metadata.status !== 'closed')
|
|
18
|
-
*
|
|
19
|
-
* @see {@link tools/mem-ready.mjs} - CLI implementation
|
|
20
|
-
* @see {@link tools/__tests__/mem-ready.test.mjs} - Tests
|
|
21
|
-
*/
|
|
22
|
-
import { type MemoryNode } from './memory-schema.js';
|
|
23
|
-
/**
|
|
24
|
-
* Query options for ready nodes
|
|
25
|
-
*/
|
|
26
|
-
export interface QueryOptions {
|
|
27
|
-
/** WU ID to query (required) */
|
|
28
|
-
wuId: string;
|
|
29
|
-
/** Filter by node type (optional) */
|
|
30
|
-
type?: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Query ready nodes for a WU.
|
|
34
|
-
*
|
|
35
|
-
* Returns unblocked, open nodes linked to the WU in deterministic order:
|
|
36
|
-
* 1. Priority (P0 first, then P1, P2, P3; nodes without priority last)
|
|
37
|
-
* 2. CreatedAt (oldest first for same priority)
|
|
38
|
-
* 3. ID (alphabetical for stable sort)
|
|
39
|
-
*
|
|
40
|
-
* @param baseDir - Base directory containing .lumenflow/memory
|
|
41
|
-
* @param options - Query options
|
|
42
|
-
* @returns Deterministically ordered ready nodes
|
|
43
|
-
* @throws If WU ID format is invalid or file contains malformed JSON
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* const ready = await queryReadyNodes('/path/to/project', { wuId: 'WU-1234' });
|
|
47
|
-
* console.log(`${ready.length} nodes ready for processing`);
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* // Filter by type
|
|
51
|
-
* const discoveries = await queryReadyNodes('/path/to/project', {
|
|
52
|
-
* wuId: 'WU-1234',
|
|
53
|
-
* type: 'discovery',
|
|
54
|
-
* });
|
|
55
|
-
*/
|
|
56
|
-
export declare function queryReadyNodes(baseDir: string, options: QueryOptions): Promise<MemoryNode[]>;
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Signal Core Logic (WU-1473)
|
|
3
|
-
*
|
|
4
|
-
* Core logic for creating coordination signals between parallel agents.
|
|
5
|
-
* Enables sub-100ms agent communication via JSONL append operations.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Append-only writes for sub-100ms performance
|
|
9
|
-
* - WU-scoped signals for focused coordination
|
|
10
|
-
* - Lane-targeted signals for cross-team communication
|
|
11
|
-
* - Read/unread tracking for mem:inbox integration
|
|
12
|
-
*
|
|
13
|
-
* @see {@link tools/mem-signal.mjs} - CLI wrapper
|
|
14
|
-
* @see {@link tools/__tests__/mem-signal.test.mjs} - Tests
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Signal file name constant
|
|
18
|
-
*/
|
|
19
|
-
export declare const SIGNAL_FILE_NAME = "signals.jsonl";
|
|
20
|
-
/**
|
|
21
|
-
* Signal structure
|
|
22
|
-
*/
|
|
23
|
-
export interface Signal {
|
|
24
|
-
/** Unique signal identifier (sig-XXXXXXXX) */
|
|
25
|
-
id: string;
|
|
26
|
-
/** Signal content/message */
|
|
27
|
-
message: string;
|
|
28
|
-
/** ISO 8601 timestamp */
|
|
29
|
-
created_at: string;
|
|
30
|
-
/** Whether signal has been read */
|
|
31
|
-
read: boolean;
|
|
32
|
-
/** Optional WU ID scope */
|
|
33
|
-
wu_id?: string;
|
|
34
|
-
/** Optional target lane */
|
|
35
|
-
lane?: string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Result of creating a signal
|
|
39
|
-
*/
|
|
40
|
-
export interface CreateSignalResult {
|
|
41
|
-
/** Whether signal was created successfully */
|
|
42
|
-
success: boolean;
|
|
43
|
-
/** The created signal object */
|
|
44
|
-
signal: Signal;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Options for creating a signal
|
|
48
|
-
*/
|
|
49
|
-
export interface CreateSignalOptions {
|
|
50
|
-
/** Signal message content (required) */
|
|
51
|
-
message: string;
|
|
52
|
-
/** WU ID to scope signal to */
|
|
53
|
-
wuId?: string;
|
|
54
|
-
/** Lane to target signal to */
|
|
55
|
-
lane?: string;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Options for loading signals
|
|
59
|
-
*/
|
|
60
|
-
export interface LoadSignalsOptions {
|
|
61
|
-
/** Filter by WU ID */
|
|
62
|
-
wuId?: string;
|
|
63
|
-
/** Filter by lane */
|
|
64
|
-
lane?: string;
|
|
65
|
-
/** Only return unread signals */
|
|
66
|
-
unreadOnly?: boolean;
|
|
67
|
-
/** Only return signals created after this time */
|
|
68
|
-
since?: Date | string;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Result of marking signals as read
|
|
72
|
-
*/
|
|
73
|
-
export interface MarkAsReadResult {
|
|
74
|
-
/** Number of signals marked as read */
|
|
75
|
-
markedCount: number;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Creates a coordination signal between parallel agents.
|
|
79
|
-
*
|
|
80
|
-
* Signals are appended to signals.jsonl using append-only writes
|
|
81
|
-
* for sub-100ms performance. Signals can be scoped to a specific
|
|
82
|
-
* WU or targeted at a specific lane.
|
|
83
|
-
*
|
|
84
|
-
* @param {string} baseDir - Project base directory
|
|
85
|
-
* @param {CreateSignalOptions} options - Signal options
|
|
86
|
-
* @returns {Promise<CreateSignalResult>} Result with created signal
|
|
87
|
-
* @throws {Error} If message is missing or WU ID is invalid
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* const result = await createSignal('/project', {
|
|
91
|
-
* message: 'Starting feature implementation',
|
|
92
|
-
* wuId: 'WU-1473',
|
|
93
|
-
* lane: 'Operations: Tooling',
|
|
94
|
-
* });
|
|
95
|
-
*/
|
|
96
|
-
export declare function createSignal(baseDir: string, options: CreateSignalOptions): Promise<CreateSignalResult>;
|
|
97
|
-
/**
|
|
98
|
-
* Loads signals from the signals file with optional filtering.
|
|
99
|
-
*
|
|
100
|
-
* Signals are returned in chronological order (oldest first).
|
|
101
|
-
* Supports filtering by WU ID, lane, and read status.
|
|
102
|
-
*
|
|
103
|
-
* @param {string} baseDir - Project base directory
|
|
104
|
-
* @param {LoadSignalsOptions} [options={}] - Filter options
|
|
105
|
-
* @returns {Promise<Signal[]>} Array of signals matching filters
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* // Load all signals
|
|
109
|
-
* const all = await loadSignals('/project');
|
|
110
|
-
*
|
|
111
|
-
* // Load unread signals for a specific WU
|
|
112
|
-
* const unread = await loadSignals('/project', {
|
|
113
|
-
* wuId: 'WU-1473',
|
|
114
|
-
* unreadOnly: true,
|
|
115
|
-
* });
|
|
116
|
-
*/
|
|
117
|
-
export declare function loadSignals(baseDir: string, options?: LoadSignalsOptions): Promise<Signal[]>;
|
|
118
|
-
/**
|
|
119
|
-
* Marks signals as read by updating the signals file.
|
|
120
|
-
*
|
|
121
|
-
* Reads the entire file, updates the read status for matching IDs,
|
|
122
|
-
* and writes back. Only signals that were previously unread are counted.
|
|
123
|
-
*
|
|
124
|
-
* @param baseDir - Project base directory
|
|
125
|
-
* @param signalIds - Array of signal IDs to mark as read
|
|
126
|
-
* @returns Result with count of signals marked
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* const result = await markSignalsAsRead('/project', ['sig-abc12345', 'sig-def67890']);
|
|
130
|
-
* console.log(result.markedCount); // 2
|
|
131
|
-
*/
|
|
132
|
-
export declare function markSignalsAsRead(baseDir: string, signalIds: string[]): Promise<MarkAsReadResult>;
|
package/dist/mem-start-core.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Start Core (WU-1466)
|
|
3
|
-
*
|
|
4
|
-
* Core logic for creating session nodes linked to WUs.
|
|
5
|
-
* Called by wu:claim enhancement for context restoration after /clear.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Creates session nodes with WU reference
|
|
9
|
-
* - Stores agent type, start timestamp, context tier
|
|
10
|
-
* - Idempotent: multiple starts create separate sessions
|
|
11
|
-
* - Auto-initializes memory layer if not present
|
|
12
|
-
*
|
|
13
|
-
* @see {@link tools/mem-start.mjs} - CLI wrapper
|
|
14
|
-
* @see {@link tools/__tests__/mem-start.test.mjs} - Tests
|
|
15
|
-
* @see {@link tools/lib/memory-schema.mjs} - Schema definitions
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Session start options
|
|
19
|
-
*/
|
|
20
|
-
export interface StartSessionOptions {
|
|
21
|
-
/** Work Unit ID (required) */
|
|
22
|
-
wuId: string;
|
|
23
|
-
/** Agent type (defaults to 'unknown') */
|
|
24
|
-
agentType?: string;
|
|
25
|
-
/** Context tier (defaults to 'full') */
|
|
26
|
-
contextTier?: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Session node structure
|
|
30
|
-
*/
|
|
31
|
-
interface SessionNode {
|
|
32
|
-
id: string;
|
|
33
|
-
type: 'session';
|
|
34
|
-
lifecycle: 'wu';
|
|
35
|
-
content: string;
|
|
36
|
-
created_at: string;
|
|
37
|
-
wu_id: string;
|
|
38
|
-
session_id: string;
|
|
39
|
-
metadata: {
|
|
40
|
-
agentType: string;
|
|
41
|
-
contextTier: string;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Session start result
|
|
46
|
-
*/
|
|
47
|
-
export interface StartSessionResult {
|
|
48
|
-
/** Whether the operation succeeded */
|
|
49
|
-
success: boolean;
|
|
50
|
-
/** Created session node */
|
|
51
|
-
session: SessionNode;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Creates a new session node linked to a WU.
|
|
55
|
-
*
|
|
56
|
-
* Creates a session-type memory node with:
|
|
57
|
-
* - Unique ID (mem-XXXX format)
|
|
58
|
-
* - Link to WU via wu_id field
|
|
59
|
-
* - Agent type and context tier in metadata
|
|
60
|
-
* - UUID session_id for unique identification
|
|
61
|
-
*
|
|
62
|
-
* @param baseDir - Base directory containing .lumenflow/memory/
|
|
63
|
-
* @param options - Session options
|
|
64
|
-
* @returns Result with created session node
|
|
65
|
-
* @throws If wuId is missing or invalid
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* const result = await startSession('/path/to/project', {
|
|
69
|
-
* wuId: 'WU-1234',
|
|
70
|
-
* agentType: 'general-purpose',
|
|
71
|
-
* contextTier: 'core',
|
|
72
|
-
* });
|
|
73
|
-
* console.log(result.session.id); // 'mem-a1b2'
|
|
74
|
-
*/
|
|
75
|
-
export declare function startSession(baseDir: string, options: StartSessionOptions): Promise<StartSessionResult>;
|
|
76
|
-
export {};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Summarize Core (WU-1471)
|
|
3
|
-
*
|
|
4
|
-
* Rollup older memory nodes into summary nodes for compaction.
|
|
5
|
-
* Implements forgetting as first-class feature.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Aggregate checkpoint/note/discovery nodes into summaries
|
|
9
|
-
* - Mark originals for cleanup after summary creation
|
|
10
|
-
* - Respect lifecycle TTL (ephemeral, session, wu, project)
|
|
11
|
-
* - Support dry-run mode for preview
|
|
12
|
-
*
|
|
13
|
-
* @see {@link tools/mem-summarize.mjs} - CLI wrapper
|
|
14
|
-
* @see {@link tools/__tests__/mem-summarize.test.mjs} - Tests
|
|
15
|
-
*/
|
|
16
|
-
import { type MemoryNode } from './memory-schema.js';
|
|
17
|
-
/**
|
|
18
|
-
* Summarize options
|
|
19
|
-
*/
|
|
20
|
-
export interface SummarizeOptions {
|
|
21
|
-
/** WU ID to summarize (e.g., 'WU-1234') */
|
|
22
|
-
wuId: string;
|
|
23
|
-
/** If true, preview without modifications */
|
|
24
|
-
dryRun?: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Summary node structure
|
|
28
|
-
*/
|
|
29
|
-
interface SummaryNode {
|
|
30
|
-
id: string;
|
|
31
|
-
type: 'summary';
|
|
32
|
-
lifecycle: 'project';
|
|
33
|
-
content: string;
|
|
34
|
-
created_at: string;
|
|
35
|
-
wu_id: string;
|
|
36
|
-
metadata: {
|
|
37
|
-
source_nodes: string[];
|
|
38
|
-
source_count: number;
|
|
39
|
-
summarized_at: string;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Summarize result
|
|
44
|
-
*/
|
|
45
|
-
export interface SummarizeResult {
|
|
46
|
-
/** Whether summarization succeeded */
|
|
47
|
-
success: boolean;
|
|
48
|
-
/** Created summary node */
|
|
49
|
-
summary: SummaryNode;
|
|
50
|
-
/** Node IDs marked for cleanup */
|
|
51
|
-
markedForCleanup: string[];
|
|
52
|
-
/** True if in dry-run mode */
|
|
53
|
-
dryRun?: boolean;
|
|
54
|
-
/** Ratio of source nodes to summary */
|
|
55
|
-
compactionRatio: number;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Filter nodes that can be summarized for a given WU.
|
|
59
|
-
*
|
|
60
|
-
* Excludes:
|
|
61
|
-
* - Nodes from different WUs
|
|
62
|
-
* - Ephemeral lifecycle nodes (already transient)
|
|
63
|
-
* - Already-summarized nodes (have summarized_into metadata)
|
|
64
|
-
* - Summary nodes themselves
|
|
65
|
-
*
|
|
66
|
-
* @param nodes - All memory nodes
|
|
67
|
-
* @param wuId - WU ID to filter by
|
|
68
|
-
* @returns Summarizable nodes
|
|
69
|
-
*/
|
|
70
|
-
export declare function filterSummarizableNodes(nodes: MemoryNode[], wuId: string): MemoryNode[];
|
|
71
|
-
/**
|
|
72
|
-
* Calculate compaction ratio (source nodes / summary nodes).
|
|
73
|
-
*
|
|
74
|
-
* @param sourceCount - Number of source nodes
|
|
75
|
-
* @param summaryCount - Number of summary nodes created
|
|
76
|
-
* @returns Compaction ratio (0 if invalid input)
|
|
77
|
-
*/
|
|
78
|
-
export declare function getCompactionRatio(sourceCount: number, summaryCount: number): number;
|
|
79
|
-
/**
|
|
80
|
-
* Summarize memory nodes for a closed WU.
|
|
81
|
-
*
|
|
82
|
-
* Aggregates checkpoint, note, and discovery nodes into a single
|
|
83
|
-
* summary node. Original nodes are marked for cleanup (unless
|
|
84
|
-
* they have project lifecycle).
|
|
85
|
-
*
|
|
86
|
-
* @param baseDir - Base directory containing .lumenflow/memory/
|
|
87
|
-
* @param options - Summarization options
|
|
88
|
-
* @returns Result with summary and cleanup info
|
|
89
|
-
* @throws If no summarizable nodes found for WU
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* // Summarize nodes for a completed WU
|
|
93
|
-
* const result = await summarizeWu(baseDir, { wuId: 'WU-1234' });
|
|
94
|
-
* console.log(`Created summary ${result.summary.id}`);
|
|
95
|
-
* console.log(`Compaction ratio: ${result.compactionRatio}:1`);
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* // Preview without modifications
|
|
99
|
-
* const preview = await summarizeWu(baseDir, {
|
|
100
|
-
* wuId: 'WU-1234',
|
|
101
|
-
* dryRun: true,
|
|
102
|
-
* });
|
|
103
|
-
*/
|
|
104
|
-
export declare function summarizeWu(baseDir: string, options: SummarizeOptions): Promise<SummarizeResult>;
|
|
105
|
-
export {};
|