forked from mksglu/context-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
131 lines (116 loc) · 4.75 KB
/
types.ts
File metadata and controls
131 lines (116 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* types — Shared type definitions for context-mode packages.
*
* Contains interfaces that are genuinely shared between the core (ContentStore,
* PolyglotExecutor) and the session domain (SessionDB, event extraction).
* Import from "./types.js".
*/
// ─────────────────────────────────────────────────────────
// Session event types
// ─────────────────────────────────────────────────────────
/** Tool call representation used during event extraction from Claude messages. */
export interface ToolCall {
toolName: string;
toolInput: Record<string, unknown>;
toolResponse?: string;
isError?: boolean;
}
/** User message representation used during event extraction. */
export interface UserMessage {
content: string;
timestamp?: string;
}
/**
* Session event as stored in SessionDB.
* Each event captures a discrete unit of session activity (tool use, user
* message, assistant response summary, etc.) for later resume-snapshot
* reconstruction.
*/
export interface SessionEvent {
type: string;
category: string;
data: string;
priority: number;
data_hash: string;
}
// ─────────────────────────────────────────────────────────
// Execution result
// ─────────────────────────────────────────────────────────
/**
* Result returned by PolyglotExecutor after running a code snippet.
* Shared here so SessionDB can record execution outcomes without importing
* the full executor module.
*/
export interface ExecResult {
stdout: string;
stderr: string;
exitCode: number;
timedOut: boolean;
/** Process was detached and continues running in the background. */
backgrounded?: boolean;
}
// ─────────────────────────────────────────────────────────
// Content store shared types
// ─────────────────────────────────────────────────────────
/**
* Result returned after indexing content into the knowledge base.
* Shared so session tooling can record what was indexed without importing
* ContentStore.
*/
export interface IndexResult {
sourceId: number;
label: string;
totalChunks: number;
codeChunks: number;
}
/**
* A single search result returned from FTS5 BM25-ranked lookup.
* Shared for consumers that display or log results outside of ContentStore.
*/
export interface SearchResult {
title: string;
content: string;
source: string;
rank: number;
contentType: "code" | "prose";
matchLayer?: "porter" | "trigram" | "fuzzy" | "rrf" | "rrf-fuzzy";
highlighted?: string;
}
/**
* Aggregate statistics for a ContentStore instance.
*/
export interface StoreStats {
sources: number;
chunks: number;
codeChunks: number;
}
// ─────────────────────────────────────────────────────────
// Resume snapshot
// ─────────────────────────────────────────────────────────
/**
* Structured representation of a session resume snapshot, suitable for
* injecting into a new conversation as context. Generated from stored
* SessionEvents by the snapshot builder.
*/
export interface ResumeSnapshot {
/** ISO-8601 timestamp of when the snapshot was generated. */
generatedAt: string;
/** Human-readable summary of the session to this point. */
summary: string;
/** Ordered list of events selected for the snapshot (priority-filtered). */
events: SessionEvent[];
}
// ─────────────────────────────────────────────────────────
// Priority constants
// ─────────────────────────────────────────────────────────
/**
* Priority levels for SessionEvent records. Higher numbers are more important
* and are retained when the snapshot budget is tight.
*/
export const EventPriority = {
LOW: 1,
NORMAL: 2,
HIGH: 3,
CRITICAL: 4,
} as const;
export type EventPriorityLevel = (typeof EventPriority)[keyof typeof EventPriority];