ai-hist 0.6.0 → 0.8.2
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/README.md +34 -254
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +248 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud-client.d.ts +0 -1
- package/dist/cloud-client.d.ts.map +1 -1
- package/dist/cloud-client.js +0 -2
- package/dist/cloud-client.js.map +1 -1
- package/dist/index.d.ts +138 -309
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +258 -1191
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.d.ts +0 -9
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +52 -790
- package/dist/mcp-server.js.map +1 -1
- package/package.json +14 -8
- package/dist/cloud-push.d.ts +0 -51
- package/dist/cloud-push.d.ts.map +0 -1
- package/dist/cloud-push.js +0 -113
- package/dist/cloud-push.js.map +0 -1
- package/dist/cloud-push.test.d.ts +0 -2
- package/dist/cloud-push.test.d.ts.map +0 -1
- package/dist/cloud-push.test.js +0 -82
- package/dist/cloud-push.test.js.map +0 -1
- package/dist/jsonl-sources.d.ts +0 -33
- package/dist/jsonl-sources.d.ts.map +0 -1
- package/dist/jsonl-sources.js +0 -351
- package/dist/jsonl-sources.js.map +0 -1
- package/dist/mcp-smoke.test.d.ts +0 -2
- package/dist/mcp-smoke.test.d.ts.map +0 -1
- package/dist/mcp-smoke.test.js +0 -574
- package/dist/mcp-smoke.test.js.map +0 -1
- package/dist/pair-client.d.ts +0 -41
- package/dist/pair-client.d.ts.map +0 -1
- package/dist/pair-client.js +0 -60
- package/dist/pair-client.js.map +0 -1
- package/dist/pair-client.test.d.ts +0 -2
- package/dist/pair-client.test.d.ts.map +0 -1
- package/dist/pair-client.test.js +0 -118
- package/dist/pair-client.test.js.map +0 -1
- package/dist/session-catalog.d.ts +0 -257
- package/dist/session-catalog.d.ts.map +0 -1
- package/dist/session-catalog.js +0 -340
- package/dist/session-catalog.js.map +0 -1
- package/dist/session-catalog.test.d.ts +0 -2
- package/dist/session-catalog.test.d.ts.map +0 -1
- package/dist/session-catalog.test.js +0 -710
- package/dist/session-catalog.test.js.map +0 -1
- package/dist/session-events.test.d.ts +0 -2
- package/dist/session-events.test.d.ts.map +0 -1
- package/dist/session-events.test.js +0 -177
- package/dist/session-events.test.js.map +0 -1
- package/dist/trajectory-sources.d.ts +0 -36
- package/dist/trajectory-sources.d.ts.map +0 -1
- package/dist/trajectory-sources.js +0 -201
- package/dist/trajectory-sources.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* RelayHistory's public TypeScript API.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* that `ai-hist sync` writes (default
|
|
8
|
-
* `~/.local/share/ai-hist/ai-history.db`, or `$AI_HIST_DB`).
|
|
9
|
-
*
|
|
10
|
-
* Trade-off vs better-sqlite3: sql.js loads the whole DB file into
|
|
11
|
-
* memory. Fine for the ai-hist scale (tens of thousands of rows, MBs
|
|
12
|
-
* of data); revisit if anyone hits millions.
|
|
4
|
+
* Every production operation crosses one mandatory Node-API boundary into the
|
|
5
|
+
* Rust engine. This module owns only input defaults, object normalization,
|
|
6
|
+
* pagination ergonomics, and stable JavaScript errors.
|
|
13
7
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import { type CatalogSession, type ListCatalogOptions, type SessionCatalogPage } from './session-catalog.js';
|
|
17
|
-
export { SESSION_CATALOG_CONTRACT_VERSION, DiscoveryError, discoverSessions, type CatalogSession, type CatalogCursor, type SessionCatalogPage, type ListCatalogOptions, type DiscoverSessionsOptions, type DiscoverResult, type DiscoverySummary, type DiscoveryDiagnostic, type DiscoveryCounters, type ProviderDiscoverySummary, type SourceExemption, } from './session-catalog.js';
|
|
8
|
+
export declare const NATIVE_CONTRACT_VERSION = 2;
|
|
9
|
+
export declare const SESSION_CATALOG_CONTRACT_VERSION = 1;
|
|
18
10
|
export type Source = 'claude' | 'codex' | 'cursor' | 'grok' | 'relay' | 'trajectory' | 'opencode';
|
|
11
|
+
export type CatalogSource = Exclude<Source, 'trajectory'>;
|
|
12
|
+
export declare class RelayHistoryError extends Error {
|
|
13
|
+
readonly code: string;
|
|
14
|
+
constructor(message: string, code: string, options?: ErrorOptions);
|
|
15
|
+
}
|
|
16
|
+
export declare class UnsupportedPlatformError extends RelayHistoryError {
|
|
17
|
+
}
|
|
18
|
+
export declare class NativePackageMissingError extends RelayHistoryError {
|
|
19
|
+
}
|
|
20
|
+
export declare class NativeLoadError extends RelayHistoryError {
|
|
21
|
+
}
|
|
22
|
+
export declare class NativeContractMismatchError extends RelayHistoryError {
|
|
23
|
+
}
|
|
24
|
+
export declare class DatabaseOpenError extends RelayHistoryError {
|
|
25
|
+
}
|
|
26
|
+
export declare class InvalidArgumentError extends RelayHistoryError {
|
|
27
|
+
}
|
|
19
28
|
export interface HistoryEntry {
|
|
20
29
|
id: number;
|
|
21
30
|
source: Source;
|
|
@@ -23,72 +32,98 @@ export interface HistoryEntry {
|
|
|
23
32
|
project: string | null;
|
|
24
33
|
prompt: string;
|
|
25
34
|
timestampMs: number;
|
|
26
|
-
gitBranch: string | null;
|
|
27
35
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
export interface ListOptions {
|
|
37
|
+
dbPath?: string;
|
|
38
|
+
source?: Source;
|
|
39
|
+
project?: string;
|
|
40
|
+
tag?: string;
|
|
41
|
+
beforeMs?: number;
|
|
42
|
+
limit?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface SearchOptions extends ListOptions {
|
|
45
|
+
rawFts?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface SessionOptions {
|
|
48
|
+
dbPath?: string;
|
|
49
|
+
source?: Source;
|
|
50
|
+
tag?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface CatalogCursor {
|
|
40
53
|
lastActivityMs: number | null;
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
source: string;
|
|
55
|
+
sessionId: string;
|
|
43
56
|
}
|
|
44
|
-
export interface
|
|
57
|
+
export interface CatalogSession {
|
|
58
|
+
source: CatalogSource;
|
|
45
59
|
sessionId: string;
|
|
46
|
-
source: Source;
|
|
47
60
|
cwd: string | null;
|
|
48
61
|
gitBranch: string | null;
|
|
49
62
|
firstActivityMs: number | null;
|
|
50
63
|
lastActivityMs: number | null;
|
|
51
|
-
|
|
52
|
-
goal: string;
|
|
53
|
-
lastState: string;
|
|
64
|
+
firstPrompt: string | null;
|
|
54
65
|
lastAssistantText: string | null;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
firstTaggedMs: number | null;
|
|
66
|
-
lastTaggedMs: number | null;
|
|
66
|
+
models: string[];
|
|
67
|
+
originator: string | null;
|
|
68
|
+
agentVersion: string | null;
|
|
69
|
+
repoUrl: string | null;
|
|
70
|
+
initialCommit: string | null;
|
|
71
|
+
workspaceRoots: string[];
|
|
72
|
+
rawPath: string | null;
|
|
73
|
+
sourceStamp: string | null;
|
|
74
|
+
discoveryState: 'shallow' | 'full';
|
|
75
|
+
fromCache: boolean;
|
|
67
76
|
}
|
|
68
|
-
export interface
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
export interface ListCatalogOptions {
|
|
78
|
+
dbPath?: string;
|
|
79
|
+
sources?: CatalogSource[];
|
|
80
|
+
limit?: number;
|
|
81
|
+
beforeMs?: number;
|
|
82
|
+
after?: CatalogCursor;
|
|
83
|
+
}
|
|
84
|
+
export interface SessionCatalogPage {
|
|
85
|
+
contractVersion: number;
|
|
86
|
+
sessions: CatalogSession[];
|
|
87
|
+
nextCursor: CatalogCursor | null;
|
|
88
|
+
}
|
|
89
|
+
export interface DiscoveryDiagnostic {
|
|
90
|
+
source: string;
|
|
91
|
+
locator: string | null;
|
|
92
|
+
error: string;
|
|
93
|
+
}
|
|
94
|
+
export interface ProviderDiscoverySummary {
|
|
95
|
+
source: string;
|
|
96
|
+
candidates: number;
|
|
97
|
+
discovered: number;
|
|
98
|
+
skippedUnchanged: number;
|
|
99
|
+
failed: boolean;
|
|
100
|
+
}
|
|
101
|
+
export interface DiscoveryCounters {
|
|
102
|
+
candidatesEnumerated: number;
|
|
103
|
+
shallowReads: number;
|
|
104
|
+
skippedUnchanged: number;
|
|
105
|
+
filesOpened: number;
|
|
106
|
+
bytesRead: number;
|
|
107
|
+
}
|
|
108
|
+
export interface SourceExemption {
|
|
109
|
+
source: string;
|
|
110
|
+
reason: string;
|
|
111
|
+
}
|
|
112
|
+
export interface DiscoverSessionsOptions {
|
|
113
|
+
dbPath?: string;
|
|
114
|
+
sources?: CatalogSource[];
|
|
115
|
+
limit?: number;
|
|
74
116
|
}
|
|
75
|
-
export interface
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
117
|
+
export interface DiscoverResult {
|
|
118
|
+
contractVersion: number;
|
|
119
|
+
sessions: CatalogSession[];
|
|
120
|
+
discovered: number;
|
|
121
|
+
skippedUnchanged: number;
|
|
122
|
+
providers: ProviderDiscoverySummary[];
|
|
123
|
+
exemptSources: SourceExemption[];
|
|
124
|
+
diagnostics: DiscoveryDiagnostic[];
|
|
125
|
+
counters: DiscoveryCounters;
|
|
83
126
|
}
|
|
84
|
-
/**
|
|
85
|
-
* One normalized transcript event from the `session_events` table: user and
|
|
86
|
-
* assistant text, thinking, tool calls, and tool results, in order.
|
|
87
|
-
* `tokenUsage` is the parsed `token_json` blob — Claude's per-message
|
|
88
|
-
* `usage` shape, or a Codex per-request delta (`input_tokens` inclusive of
|
|
89
|
-
* `cached_input_tokens`). Claude repeats the same usage on every content
|
|
90
|
-
* block of a message, so sum per distinct `messageId`, not per row.
|
|
91
|
-
*/
|
|
92
127
|
export interface SessionEvent {
|
|
93
128
|
id: number;
|
|
94
129
|
source: Source;
|
|
@@ -106,32 +141,20 @@ export interface SessionEvent {
|
|
|
106
141
|
tokenUsage: Record<string, unknown> | null;
|
|
107
142
|
eventUid: string;
|
|
108
143
|
}
|
|
109
|
-
|
|
110
|
-
|
|
144
|
+
export interface EventCursor {
|
|
145
|
+
tsMs: number;
|
|
111
146
|
id: number;
|
|
112
|
-
source: Source;
|
|
113
|
-
sessionId: string;
|
|
114
|
-
messageId: string | null;
|
|
115
|
-
toolUseId: string;
|
|
116
|
-
name: string;
|
|
117
|
-
target: string | null;
|
|
118
|
-
argsJson: string | null;
|
|
119
|
-
isError: boolean | null;
|
|
120
|
-
tsMs: number | null;
|
|
121
147
|
}
|
|
122
|
-
export interface
|
|
148
|
+
export interface EventsPageOptions {
|
|
149
|
+
dbPath?: string;
|
|
123
150
|
source?: Source;
|
|
124
|
-
project?: string;
|
|
125
|
-
tag?: string;
|
|
126
|
-
/** Default 50. */
|
|
127
151
|
limit?: number;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
152
|
+
after?: EventCursor;
|
|
153
|
+
}
|
|
154
|
+
export interface SessionEventsPage {
|
|
155
|
+
events: SessionEvent[];
|
|
156
|
+
nextCursor: EventCursor | null;
|
|
133
157
|
}
|
|
134
|
-
export type SearchOptions = ListOptions;
|
|
135
158
|
export interface Stats {
|
|
136
159
|
total: number;
|
|
137
160
|
bySource: Partial<Record<Source, number>>;
|
|
@@ -142,231 +165,37 @@ export interface Stats {
|
|
|
142
165
|
firstTimestampMs: number | null;
|
|
143
166
|
lastTimestampMs: number | null;
|
|
144
167
|
}
|
|
145
|
-
export interface
|
|
146
|
-
id: string;
|
|
147
|
-
version: number | null;
|
|
148
|
-
personaId: string | null;
|
|
149
|
-
projectId: string | null;
|
|
150
|
-
task: {
|
|
151
|
-
title: string | null;
|
|
152
|
-
description: string | null;
|
|
153
|
-
};
|
|
154
|
-
status: string | null;
|
|
155
|
-
startedAt: string | null;
|
|
156
|
-
completedAt: string | null;
|
|
157
|
-
decisions: TrajectoryDecision[];
|
|
158
|
-
retrospective: TrajectoryRetrospective;
|
|
159
|
-
searchText: string;
|
|
160
|
-
path: string | null;
|
|
161
|
-
updatedMs: number;
|
|
162
|
-
timestampMs: number;
|
|
163
|
-
}
|
|
164
|
-
export interface TrajectorySearchOptions {
|
|
165
|
-
/** Default 20. */
|
|
166
|
-
limit?: number;
|
|
167
|
-
/** Filter to a trajectory projectId or path. */
|
|
168
|
-
project?: string;
|
|
169
|
-
}
|
|
170
|
-
export interface GetHandoffOptions {
|
|
171
|
-
/** Substring match against session cwd. */
|
|
172
|
-
repo?: string;
|
|
173
|
-
/** Substring match against git_branch. */
|
|
174
|
-
branch?: string;
|
|
175
|
-
/** Filter to a specific CLI source. */
|
|
176
|
-
source?: 'claude' | 'codex';
|
|
177
|
-
/** Max candidates to return. Default 3. */
|
|
178
|
-
limit?: number;
|
|
179
|
-
}
|
|
180
|
-
/** Resolve the SQLite path that ai-hist writes to. */
|
|
181
|
-
export declare function defaultDbPath(): string;
|
|
182
|
-
export interface OpenOptions {
|
|
183
|
-
/** Override the SQLite path (default: `$AI_HIST_DB` or `~/.local/share/ai-hist/ai-history.db`). */
|
|
168
|
+
export interface StatsOptions {
|
|
184
169
|
dbPath?: string;
|
|
185
|
-
|
|
186
|
-
* Restrict all reads to one project directory/path. Exact matches and
|
|
187
|
-
* child paths are included, so a scope of `/repo` also includes `/repo/pkg`.
|
|
188
|
-
*/
|
|
189
|
-
projectScope?: string;
|
|
190
|
-
/**
|
|
191
|
-
* What to do when the SQLite DB is missing:
|
|
192
|
-
* - `'jsonl'` (default): scan local Claude/Codex/Cursor/Grok history files
|
|
193
|
-
* directly into an in-memory SQLite — works without the native
|
|
194
|
-
* `ai-hist` CLI installed.
|
|
195
|
-
* - `'error'`: throw with an install hint (legacy 0.1.x behavior).
|
|
196
|
-
*/
|
|
197
|
-
fallback?: 'jsonl' | 'error';
|
|
170
|
+
tag?: string;
|
|
198
171
|
}
|
|
199
|
-
export interface
|
|
200
|
-
|
|
201
|
-
kind: 'sqlite' | 'jsonl';
|
|
202
|
-
/** SQLite DB path or, in jsonl mode, the paths that were scanned. */
|
|
203
|
-
path: string;
|
|
172
|
+
export interface SyncOptions {
|
|
173
|
+
dbPath?: string;
|
|
204
174
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
* process's event loop isn't blocked.
|
|
209
|
-
*
|
|
210
|
-
* Each call snapshots the data; to pick up later writes, call `reload()`
|
|
211
|
-
* (or open a fresh instance).
|
|
212
|
-
*/
|
|
213
|
-
export declare function openAiHist(opts?: OpenOptions): Promise<AiHist>;
|
|
214
|
-
export declare class AiHist {
|
|
215
|
-
private readonly db;
|
|
216
|
-
private readonly _source;
|
|
217
|
-
private readonly _projectScope;
|
|
218
|
-
private closed;
|
|
219
|
-
/** @internal — use `openAiHist(...)` to construct. */
|
|
220
|
-
constructor(db: Database, source: OpenSourceInfo, opts?: Pick<OpenOptions, 'projectScope'>);
|
|
221
|
-
/**
|
|
222
|
-
* Path the data came from. SQLite mode: the .db path. JSONL fallback
|
|
223
|
-
* mode: a comma-separated list of the scanned source paths.
|
|
224
|
-
*/
|
|
225
|
-
get dbPath(): string;
|
|
226
|
-
/** Which data path was used: `'sqlite'` (on-disk SQLite database) or `'jsonl'` (fallback). */
|
|
227
|
-
get sourceKind(): 'sqlite' | 'jsonl';
|
|
228
|
-
/** Server/client-wide project scope applied to every read, if configured. */
|
|
229
|
-
get projectScope(): string | undefined;
|
|
230
|
-
close(): void;
|
|
231
|
-
private persistIfWritable;
|
|
232
|
-
private ensureTag;
|
|
233
|
-
private matchingSessions;
|
|
234
|
-
tagSession(sessionId: string, tagName: string, opts?: {
|
|
235
|
-
source?: Source;
|
|
236
|
-
color?: string | null;
|
|
237
|
-
}): TaggedSession[];
|
|
238
|
-
untagSession(sessionId: string, tagName: string, opts?: {
|
|
239
|
-
source?: Source;
|
|
240
|
-
}): number;
|
|
241
|
-
listTags(opts?: {
|
|
242
|
-
tag?: string;
|
|
243
|
-
includeSessions?: boolean;
|
|
244
|
-
}): Array<Tag & {
|
|
245
|
-
sessions?: TaggedSession[];
|
|
246
|
-
}>;
|
|
247
|
-
sessionsByTag(tagName: string): TaggedSession[];
|
|
248
|
-
searchByTag(tagName: string, opts?: Omit<SearchOptions, 'tag'>): HistoryEntry[];
|
|
249
|
-
/** Most recent prompts, newest first. */
|
|
250
|
-
recent(opts?: ListOptions): HistoryEntry[];
|
|
251
|
-
/**
|
|
252
|
-
* Group history into sessions, ordered by last activity (newest first).
|
|
253
|
-
* Sessions without a `session_id` are skipped.
|
|
254
|
-
*
|
|
255
|
-
* This derives sessions from the `history` table, so it only ever sees
|
|
256
|
-
* sessions a full `ai-hist sync` has ingested, and it pays a window-function
|
|
257
|
-
* pass over history to do it. For the fast and complete path — every session
|
|
258
|
-
* the catalog knows, including ones only shallow discovery has seen, with
|
|
259
|
-
* cwd, branch, models, originator and repo identity attached — use
|
|
260
|
-
* {@link AiHist.listSessionCatalog}. This method stays as-is for callers
|
|
261
|
-
* that want prompt counts and the project-derived grouping.
|
|
262
|
-
*
|
|
263
|
-
* Implementation note: this used to use a correlated scalar subquery
|
|
264
|
-
* to pick `first_prompt`, which ran in O(sessions × rows) — ~19s on a
|
|
265
|
-
* 35K-row DB. Switched to `ROW_NUMBER() OVER (PARTITION BY session_id
|
|
266
|
-
* ORDER BY timestamp_ms)` so first-prompt picking is a single pass
|
|
267
|
-
* over the table (~300ms on the same DB). Plus the index ensure step
|
|
268
|
-
* in `openAiHist` keeps it fast even when the DB was written by an
|
|
269
|
-
* older CLI that didn't create `idx_history_session`.
|
|
270
|
-
*/
|
|
271
|
-
listSessions(opts?: ListOptions): SessionSummary[];
|
|
272
|
-
/**
|
|
273
|
-
* The session catalog, newest first — one indexed query over `sessions` and
|
|
274
|
-
* nothing else.
|
|
275
|
-
*
|
|
276
|
-
* No provider transcript is opened and neither `history` nor
|
|
277
|
-
* `session_events` is touched, so this stays fast on first paint even with
|
|
278
|
-
* thousands of historical sessions. It is the read side of the native
|
|
279
|
-
* `ai-hist sessions list`; populate the catalog with `discoverSessions()`
|
|
280
|
-
* (or a full `ai-hist sync`).
|
|
281
|
-
*
|
|
282
|
-
* Details worth knowing:
|
|
283
|
-
* - `trajectory` rows are excluded defensively — trajectories are derived
|
|
284
|
-
* records, not sessions, and must never appear in a session list.
|
|
285
|
-
* - The catalog's total order is
|
|
286
|
-
* `(last_activity_ms DESC, source ASC, session_id ASC)`. SQLite sorts
|
|
287
|
-
* NULL lowest, so rows of unknown recency land last under `DESC` without
|
|
288
|
-
* a helper expression. Recency alone is not a key: one discovery pass can
|
|
289
|
-
* stamp many sessions with the same mtime-derived millisecond, which is
|
|
290
|
-
* why the identity columns are part of the order.
|
|
291
|
-
* - To page, use {@link AiHist.listSessionCatalogPage} and follow its
|
|
292
|
-
* `nextCursor`. `beforeMs` is only a *coarse* cutoff ("anything before
|
|
293
|
-
* last Tuesday"): it cannot separate rows sharing a millisecond, so a
|
|
294
|
-
* walk built on it drops every row tied with a page boundary. It is
|
|
295
|
-
* ignored when `after` is set.
|
|
296
|
-
* - A configured `projectScope` constrains rows by `cwd`, like
|
|
297
|
-
* `getHandoff`. Sources with no working directory (relay) therefore drop
|
|
298
|
-
* out of a scoped listing.
|
|
299
|
-
* - In JSONL fallback mode (no SQLite database) the catalog is empty and
|
|
300
|
-
* this returns `[]`: the fallback scan builds `history` rows only, and
|
|
301
|
-
* only the native discovery engine writes the catalog.
|
|
302
|
-
*/
|
|
303
|
-
listSessionCatalog(opts?: ListCatalogOptions): CatalogSession[];
|
|
304
|
-
/**
|
|
305
|
-
* {@link AiHist.listSessionCatalog} plus the cursor that continues it.
|
|
306
|
-
*
|
|
307
|
-
* Follow `nextCursor` until it comes back `null` to walk the whole catalog:
|
|
308
|
-
* no skipped and no duplicated rows, even when a whole page shares one
|
|
309
|
-
* millisecond, and the undated tail stays reachable from a dated cursor.
|
|
310
|
-
* `nextCursor` is non-null only when the page filled its limit, mirroring
|
|
311
|
-
* the native `list_session_catalog_page` and the CLI's `next_cursor`.
|
|
312
|
-
*/
|
|
313
|
-
listSessionCatalogPage(opts?: ListCatalogOptions): SessionCatalogPage;
|
|
314
|
-
/** All prompts in a session, ordered oldest → newest. */
|
|
315
|
-
getSession(sessionId: string, opts?: Pick<ListOptions, 'source' | 'tag'>): HistoryEntry[];
|
|
316
|
-
/**
|
|
317
|
-
* All normalized events for a session, oldest first — messages, thinking,
|
|
318
|
-
* tool calls, and tool results with per-event token usage where the
|
|
319
|
-
* transcript provides it. Returns `[]` when the database predates the
|
|
320
|
-
* `session_events` table (or in JSONL fallback mode, which has no events).
|
|
321
|
-
*
|
|
322
|
-
* Size caveat: this SDK loads the whole database file into memory, so on
|
|
323
|
-
* large event-bearing databases prefer streaming from the native CLI
|
|
324
|
-
* (`ai-hist events <session-id> --json`).
|
|
325
|
-
*/
|
|
326
|
-
getSessionEvents(sessionId: string, opts?: {
|
|
327
|
-
source?: Source;
|
|
328
|
-
}): SessionEvent[];
|
|
329
|
-
/** All tool calls for a session, oldest first; `[]` on pre-events databases. */
|
|
330
|
-
getToolCalls(sessionId: string, opts?: {
|
|
331
|
-
source?: Source;
|
|
332
|
-
}): SessionToolCall[];
|
|
333
|
-
/**
|
|
334
|
-
* Substring search across prompt + project, case-insensitive, recent
|
|
335
|
-
* matches first. The native CLI uses FTS5; this SDK uses LIKE because
|
|
336
|
-
* sql.js's default WASM build doesn't ship the FTS5 module. Plenty fast
|
|
337
|
-
* for the ai-hist scale (~tens of thousands of rows); revisit if a
|
|
338
|
-
* future consumer needs phrase/boolean queries.
|
|
339
|
-
*
|
|
340
|
-
* The query is matched literally — `%` and `_` are escaped so users can
|
|
341
|
-
* search for them. Empty queries return recent entries matching the filters.
|
|
342
|
-
*/
|
|
343
|
-
search(query: string, opts?: SearchOptions): HistoryEntry[];
|
|
344
|
-
/** Search compacted per-run trajectory WHY: decisions and retrospectives. */
|
|
345
|
-
searchTrajectories(query: string, opts?: TrajectorySearchOptions): TrajectoryEntry[];
|
|
346
|
-
/** Best-matching per-run trajectory for a task query, or `null` if none match. */
|
|
347
|
-
whyForTask(query: string): TrajectoryEntry | null;
|
|
348
|
-
/** Single entry by id, or `null` if not found. */
|
|
349
|
-
getEntry(id: number): HistoryEntry | null;
|
|
350
|
-
/**
|
|
351
|
-
* All entries whose timestamp falls within [timestampMs - windowMs,
|
|
352
|
-
* timestampMs + windowMs], ordered oldest first. Used by get_context.
|
|
353
|
-
*/
|
|
354
|
-
getInTimeWindow(timestampMs: number, windowMs: number): HistoryEntry[];
|
|
355
|
-
/**
|
|
356
|
-
* Find sessions matching the given repo/branch/source and return ranked
|
|
357
|
-
* handoff candidates with a warm-start command for the target CLI.
|
|
358
|
-
*
|
|
359
|
-
* Queries the `sessions` table (populated by `ai-hist sync`) for objective
|
|
360
|
-
* metadata, then joins the last N user prompts from `history` to generate
|
|
361
|
-
* a brief on demand — no pre-computed summaries.
|
|
362
|
-
*/
|
|
363
|
-
getHandoff(opts?: GetHandoffOptions): HandoffCandidate[];
|
|
364
|
-
/** Counts + date range, mirroring `ai-hist stats`. */
|
|
365
|
-
stats(): Stats;
|
|
175
|
+
export interface SyncResult {
|
|
176
|
+
databasePath: string;
|
|
177
|
+
completed: boolean;
|
|
366
178
|
}
|
|
179
|
+
export declare function runtimePlatform(): string;
|
|
180
|
+
export declare function validateNativeContract(actual: number): void;
|
|
181
|
+
export declare function defaultDbPath(): string;
|
|
367
182
|
/**
|
|
368
|
-
*
|
|
369
|
-
*
|
|
183
|
+
* Optimization profile of the loaded native addon: 'release', 'debug', or
|
|
184
|
+
* 'unknown' for an addon predating the probe. Performance measurements are
|
|
185
|
+
* only meaningful against 'release'.
|
|
370
186
|
*/
|
|
187
|
+
export declare function nativeBuildProfile(): Promise<string>;
|
|
188
|
+
export declare function search(query: string, options?: SearchOptions): Promise<HistoryEntry[]>;
|
|
189
|
+
export declare function recent(options?: ListOptions): Promise<HistoryEntry[]>;
|
|
190
|
+
export declare function getSession(sessionId: string, options?: SessionOptions): Promise<HistoryEntry[]>;
|
|
191
|
+
export declare function listSessionCatalog(options?: ListCatalogOptions): Promise<CatalogSession[]>;
|
|
192
|
+
export declare function listSessionCatalogPage(options?: ListCatalogOptions): Promise<SessionCatalogPage>;
|
|
193
|
+
export declare function discoverSessions(options?: DiscoverSessionsOptions): Promise<DiscoverResult>;
|
|
194
|
+
export declare function discoverAndList(options?: DiscoverSessionsOptions & ListCatalogOptions): Promise<SessionCatalogPage>;
|
|
195
|
+
export declare function getSessionEventsPage(sessionId: string, options?: EventsPageOptions): Promise<SessionEventsPage>;
|
|
196
|
+
export declare function sessionEvents(sessionId: string, options?: Omit<EventsPageOptions, 'after'>): AsyncGenerator<SessionEvent>;
|
|
197
|
+
export declare function getSessionEvents(sessionId: string, options?: Omit<EventsPageOptions, 'after'>): Promise<SessionEvent[]>;
|
|
198
|
+
export declare function stats(options?: StatsOptions): Promise<Stats>;
|
|
199
|
+
export declare function sync(options?: SyncOptions): Promise<SyncResult>;
|
|
371
200
|
export declare function resumeCommand(entry: Pick<HistoryEntry, 'source' | 'sessionId' | 'project'>): string | null;
|
|
372
201
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,eAAO,MAAM,uBAA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