agentation-vue-mcp 0.0.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/LICENSE +27 -0
- package/README.md +171 -0
- package/dist/cli.js +2952 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.mts +341 -0
- package/dist/index.d.ts +341 -0
- package/dist/index.js +2817 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2761 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +60 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create and start the HTTP server.
|
|
3
|
+
* @param port - Port to listen on
|
|
4
|
+
* @param apiKey - Optional API key for cloud storage mode
|
|
5
|
+
*/
|
|
6
|
+
declare function startHttpServer(port: number, apiKey?: string): void;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create and start the MCP server on stdio.
|
|
10
|
+
* @param baseUrl - Optional HTTP server URL to fetch from (default: http://localhost:4747)
|
|
11
|
+
*/
|
|
12
|
+
declare function startMcpServer(baseUrl?: string): Promise<void>;
|
|
13
|
+
|
|
14
|
+
type Annotation = {
|
|
15
|
+
id: string;
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
comment: string;
|
|
19
|
+
element: string;
|
|
20
|
+
elementPath: string;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
selectedText?: string;
|
|
23
|
+
boundingBox?: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
29
|
+
nearbyText?: string;
|
|
30
|
+
cssClasses?: string;
|
|
31
|
+
nearbyElements?: string;
|
|
32
|
+
computedStyles?: string;
|
|
33
|
+
fullPath?: string;
|
|
34
|
+
accessibility?: string;
|
|
35
|
+
isMultiSelect?: boolean;
|
|
36
|
+
isFixed?: boolean;
|
|
37
|
+
reactComponents?: string;
|
|
38
|
+
sessionId?: string;
|
|
39
|
+
url?: string;
|
|
40
|
+
intent?: AnnotationIntent;
|
|
41
|
+
severity?: AnnotationSeverity;
|
|
42
|
+
status?: AnnotationStatus;
|
|
43
|
+
thread?: ThreadMessage[];
|
|
44
|
+
createdAt?: string;
|
|
45
|
+
updatedAt?: string;
|
|
46
|
+
resolvedAt?: string;
|
|
47
|
+
resolvedBy?: "human" | "agent";
|
|
48
|
+
authorId?: string;
|
|
49
|
+
};
|
|
50
|
+
type AnnotationIntent = "fix" | "change" | "question" | "approve";
|
|
51
|
+
type AnnotationSeverity = "blocking" | "important" | "suggestion";
|
|
52
|
+
type AnnotationStatus = "pending" | "acknowledged" | "resolved" | "dismissed";
|
|
53
|
+
type Session = {
|
|
54
|
+
id: string;
|
|
55
|
+
url: string;
|
|
56
|
+
status: SessionStatus;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
updatedAt?: string;
|
|
59
|
+
projectId?: string;
|
|
60
|
+
metadata?: Record<string, unknown>;
|
|
61
|
+
};
|
|
62
|
+
type SessionStatus = "active" | "approved" | "closed";
|
|
63
|
+
type SessionWithAnnotations = Session & {
|
|
64
|
+
annotations: Annotation[];
|
|
65
|
+
};
|
|
66
|
+
type FrameworkKind = "vue" | "react" | "unknown";
|
|
67
|
+
type SourceLocation = {
|
|
68
|
+
framework: FrameworkKind;
|
|
69
|
+
componentName: string;
|
|
70
|
+
componentHierarchy?: string;
|
|
71
|
+
file: string;
|
|
72
|
+
line?: number;
|
|
73
|
+
column?: number;
|
|
74
|
+
resolver: string;
|
|
75
|
+
};
|
|
76
|
+
type AnnotationV2 = {
|
|
77
|
+
id: string;
|
|
78
|
+
schemaVersion: 1;
|
|
79
|
+
timestamp: string;
|
|
80
|
+
url: string;
|
|
81
|
+
elementSelector: string;
|
|
82
|
+
elementText?: string;
|
|
83
|
+
comment: string;
|
|
84
|
+
source: SourceLocation;
|
|
85
|
+
metadata?: Record<string, unknown>;
|
|
86
|
+
sessionId?: string;
|
|
87
|
+
createdAt?: string;
|
|
88
|
+
updatedAt?: string;
|
|
89
|
+
};
|
|
90
|
+
type SessionWithAnnotationsV2 = Session & {
|
|
91
|
+
annotations: AnnotationV2[];
|
|
92
|
+
};
|
|
93
|
+
type ThreadMessage = {
|
|
94
|
+
id: string;
|
|
95
|
+
role: "human" | "agent";
|
|
96
|
+
content: string;
|
|
97
|
+
timestamp: number;
|
|
98
|
+
};
|
|
99
|
+
type AFSEventType = "annotation.created" | "annotation.updated" | "annotation.deleted" | "session.created" | "session.updated" | "session.closed" | "thread.message" | "action.requested";
|
|
100
|
+
type ActionRequest = {
|
|
101
|
+
sessionId: string;
|
|
102
|
+
annotations: Annotation[];
|
|
103
|
+
output: string;
|
|
104
|
+
timestamp: string;
|
|
105
|
+
};
|
|
106
|
+
type AFSEvent = {
|
|
107
|
+
type: AFSEventType;
|
|
108
|
+
timestamp: string;
|
|
109
|
+
sessionId: string;
|
|
110
|
+
sequence: number;
|
|
111
|
+
payload: Annotation | Session | ThreadMessage | ActionRequest;
|
|
112
|
+
};
|
|
113
|
+
type Organization = {
|
|
114
|
+
id: string;
|
|
115
|
+
name: string;
|
|
116
|
+
createdAt: string;
|
|
117
|
+
updatedAt?: string;
|
|
118
|
+
};
|
|
119
|
+
type UserRole = "owner" | "admin" | "member";
|
|
120
|
+
type User = {
|
|
121
|
+
id: string;
|
|
122
|
+
email: string;
|
|
123
|
+
orgId: string;
|
|
124
|
+
role: UserRole;
|
|
125
|
+
createdAt: string;
|
|
126
|
+
updatedAt?: string;
|
|
127
|
+
};
|
|
128
|
+
type ApiKey = {
|
|
129
|
+
id: string;
|
|
130
|
+
keyPrefix: string;
|
|
131
|
+
keyHash: string;
|
|
132
|
+
userId: string;
|
|
133
|
+
name: string;
|
|
134
|
+
createdAt: string;
|
|
135
|
+
expiresAt?: string;
|
|
136
|
+
lastUsedAt?: string;
|
|
137
|
+
};
|
|
138
|
+
type UserContext = {
|
|
139
|
+
userId: string;
|
|
140
|
+
orgId: string;
|
|
141
|
+
email?: string;
|
|
142
|
+
role?: UserRole;
|
|
143
|
+
};
|
|
144
|
+
interface AFSStore {
|
|
145
|
+
createSession(url: string, projectId?: string): Session;
|
|
146
|
+
getSession(id: string): Session | undefined;
|
|
147
|
+
getSessionWithAnnotations(id: string): SessionWithAnnotations | undefined;
|
|
148
|
+
getSessionWithAnnotationsV2(id: string): SessionWithAnnotationsV2 | undefined;
|
|
149
|
+
updateSessionStatus(id: string, status: SessionStatus): Session | undefined;
|
|
150
|
+
listSessions(): Session[];
|
|
151
|
+
addAnnotation(sessionId: string, data: Omit<Annotation, "id" | "sessionId" | "status" | "createdAt">): Annotation | undefined;
|
|
152
|
+
getAnnotation(id: string): Annotation | undefined;
|
|
153
|
+
updateAnnotation(id: string, data: Partial<Omit<Annotation, "id" | "sessionId" | "createdAt">>): Annotation | undefined;
|
|
154
|
+
updateAnnotationStatus(id: string, status: AnnotationStatus, resolvedBy?: "human" | "agent"): Annotation | undefined;
|
|
155
|
+
addThreadMessage(annotationId: string, role: "human" | "agent", content: string): Annotation | undefined;
|
|
156
|
+
getPendingAnnotations(sessionId: string): Annotation[];
|
|
157
|
+
getSessionAnnotations(sessionId: string): Annotation[];
|
|
158
|
+
deleteAnnotation(id: string): Annotation | undefined;
|
|
159
|
+
addAnnotationV2(sessionId: string, data: AnnotationV2): AnnotationV2 | undefined;
|
|
160
|
+
getAnnotationV2(id: string): AnnotationV2 | undefined;
|
|
161
|
+
updateAnnotationV2(id: string, data: Partial<Omit<AnnotationV2, "id" | "sessionId" | "createdAt">>): AnnotationV2 | undefined;
|
|
162
|
+
getSessionAnnotationsV2(sessionId: string): AnnotationV2[];
|
|
163
|
+
deleteAnnotationV2(id: string): AnnotationV2 | undefined;
|
|
164
|
+
getEventsSince(sessionId: string, sequence: number): AFSEvent[];
|
|
165
|
+
close(): void;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Store module - provides persistence for sessions and annotations.
|
|
170
|
+
*
|
|
171
|
+
* By default uses SQLite (~/.agentation/store.db).
|
|
172
|
+
* Falls back to in-memory storage if SQLite fails to initialize.
|
|
173
|
+
*
|
|
174
|
+
* Usage:
|
|
175
|
+
* import { store } from './store.js';
|
|
176
|
+
* const session = store.createSession('http://localhost:3000');
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Get the store instance. Lazily initializes on first access.
|
|
181
|
+
*/
|
|
182
|
+
declare function getStore(): AFSStore;
|
|
183
|
+
declare const store: {
|
|
184
|
+
readonly instance: AFSStore;
|
|
185
|
+
};
|
|
186
|
+
declare function createSession(url: string, projectId?: string): Session;
|
|
187
|
+
declare function getSession(id: string): Session | undefined;
|
|
188
|
+
declare function getSessionWithAnnotations(id: string): SessionWithAnnotations | undefined;
|
|
189
|
+
declare function updateSessionStatus(id: string, status: SessionStatus): Session | undefined;
|
|
190
|
+
declare function listSessions(): Session[];
|
|
191
|
+
declare function addAnnotation(sessionId: string, data: Omit<Annotation, "id" | "sessionId" | "status" | "createdAt">): Annotation | undefined;
|
|
192
|
+
declare function getAnnotation(id: string): Annotation | undefined;
|
|
193
|
+
declare function updateAnnotation(id: string, data: Partial<Omit<Annotation, "id" | "sessionId" | "createdAt">>): Annotation | undefined;
|
|
194
|
+
declare function updateAnnotationStatus(id: string, status: AnnotationStatus, resolvedBy?: "human" | "agent"): Annotation | undefined;
|
|
195
|
+
declare function addThreadMessage(annotationId: string, role: "human" | "agent", content: string): Annotation | undefined;
|
|
196
|
+
declare function getPendingAnnotations(sessionId: string): Annotation[];
|
|
197
|
+
declare function getSessionAnnotations(sessionId: string): Annotation[];
|
|
198
|
+
declare function deleteAnnotation(id: string): Annotation | undefined;
|
|
199
|
+
declare function getEventsSince(sessionId: string, sequence: number): AFSEvent[];
|
|
200
|
+
/**
|
|
201
|
+
* Clear all data and reset the store.
|
|
202
|
+
*/
|
|
203
|
+
declare function clearAll(): void;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* EventBus for real-time event distribution.
|
|
207
|
+
* Coordinates SSE streams, MCP notifications, and future webhooks.
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
type EventHandler = (event: AFSEvent) => void;
|
|
211
|
+
/**
|
|
212
|
+
* Simple pub/sub event bus for AFS events.
|
|
213
|
+
*/
|
|
214
|
+
declare class EventBus {
|
|
215
|
+
private handlers;
|
|
216
|
+
private sessionHandlers;
|
|
217
|
+
/**
|
|
218
|
+
* Subscribe to all events.
|
|
219
|
+
*/
|
|
220
|
+
subscribe(handler: EventHandler): () => void;
|
|
221
|
+
/**
|
|
222
|
+
* Subscribe to events for a specific session.
|
|
223
|
+
*/
|
|
224
|
+
subscribeToSession(sessionId: string, handler: EventHandler): () => void;
|
|
225
|
+
/**
|
|
226
|
+
* Emit an event to all subscribers.
|
|
227
|
+
*/
|
|
228
|
+
emit(type: AFSEventType, sessionId: string, payload: Annotation | Session | ThreadMessage | ActionRequest): AFSEvent;
|
|
229
|
+
/**
|
|
230
|
+
* Get current sequence number (for reconnect logic).
|
|
231
|
+
*/
|
|
232
|
+
getSequence(): number;
|
|
233
|
+
/**
|
|
234
|
+
* Set sequence from persisted state (for server restart).
|
|
235
|
+
*/
|
|
236
|
+
setSequence(seq: number): void;
|
|
237
|
+
}
|
|
238
|
+
declare const eventBus: EventBus;
|
|
239
|
+
/**
|
|
240
|
+
* User-scoped event bus that filters events by user ID.
|
|
241
|
+
* Prevents data leakage between users in multi-tenant environments.
|
|
242
|
+
*/
|
|
243
|
+
declare class UserEventBus {
|
|
244
|
+
private userHandlers;
|
|
245
|
+
private userSessionHandlers;
|
|
246
|
+
/**
|
|
247
|
+
* Subscribe to all events for a specific user.
|
|
248
|
+
*/
|
|
249
|
+
subscribeForUser(userId: string, handler: EventHandler): () => void;
|
|
250
|
+
/**
|
|
251
|
+
* Subscribe to events for a specific session of a specific user.
|
|
252
|
+
*/
|
|
253
|
+
subscribeToSessionForUser(userId: string, sessionId: string, handler: EventHandler): () => void;
|
|
254
|
+
/**
|
|
255
|
+
* Emit an event scoped to a specific user.
|
|
256
|
+
* Only handlers for that user will receive the event.
|
|
257
|
+
*/
|
|
258
|
+
emitForUser(userId: string, type: AFSEventType, sessionId: string, payload: Annotation | Session | ThreadMessage | ActionRequest): AFSEvent;
|
|
259
|
+
/**
|
|
260
|
+
* Check if a user has any active listeners.
|
|
261
|
+
*/
|
|
262
|
+
hasListenersForUser(userId: string): boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Get count of listeners for a user.
|
|
265
|
+
*/
|
|
266
|
+
getListenerCountForUser(userId: string): number;
|
|
267
|
+
}
|
|
268
|
+
declare const userEventBus: UserEventBus;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* SQLite-backed store for sessions, annotations, and events.
|
|
272
|
+
* Provides persistence across server restarts.
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
interface TenantStore {
|
|
276
|
+
createOrganization(name: string): Organization;
|
|
277
|
+
getOrganization(id: string): Organization | undefined;
|
|
278
|
+
createUser(email: string, orgId: string, role?: UserRole): User;
|
|
279
|
+
getUser(id: string): User | undefined;
|
|
280
|
+
getUserByEmail(email: string): User | undefined;
|
|
281
|
+
getUsersByOrg(orgId: string): User[];
|
|
282
|
+
createApiKey(userId: string, name: string, expiresAt?: string): {
|
|
283
|
+
apiKey: ApiKey;
|
|
284
|
+
rawKey: string;
|
|
285
|
+
};
|
|
286
|
+
getApiKeyByHash(hash: string): ApiKey | undefined;
|
|
287
|
+
listApiKeys(userId: string): ApiKey[];
|
|
288
|
+
deleteApiKey(id: string): boolean;
|
|
289
|
+
updateApiKeyLastUsed(id: string): void;
|
|
290
|
+
createSessionForUser(userId: string, url: string, projectId?: string): Session;
|
|
291
|
+
listSessionsForUser(userId: string): Session[];
|
|
292
|
+
getSessionForUser(userId: string, sessionId: string): Session | undefined;
|
|
293
|
+
getSessionWithAnnotationsForUser(userId: string, sessionId: string): SessionWithAnnotations | undefined;
|
|
294
|
+
getPendingAnnotationsForUser(userId: string, sessionId: string): Annotation[];
|
|
295
|
+
getAllPendingForUser(userId: string): Annotation[];
|
|
296
|
+
close(): void;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Get the tenant store instance. Lazily initializes on first access.
|
|
301
|
+
*/
|
|
302
|
+
declare function getTenantStore(): TenantStore;
|
|
303
|
+
/**
|
|
304
|
+
* Reset the tenant store singleton (for testing).
|
|
305
|
+
*/
|
|
306
|
+
declare function resetTenantStore(): void;
|
|
307
|
+
/**
|
|
308
|
+
* Hash an API key for lookup.
|
|
309
|
+
* Used by auth middleware to find the key in the database.
|
|
310
|
+
*/
|
|
311
|
+
declare function hashApiKey(rawKey: string): string;
|
|
312
|
+
/**
|
|
313
|
+
* Validate API key format.
|
|
314
|
+
*/
|
|
315
|
+
declare function isValidApiKeyFormat(key: string): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Create a UserContext from a User and Organization.
|
|
318
|
+
*/
|
|
319
|
+
declare function createUserContext(user: User): UserContext;
|
|
320
|
+
declare function createOrganization(name: string): Organization;
|
|
321
|
+
declare function getOrganization(id: string): Organization | undefined;
|
|
322
|
+
declare function createUser(email: string, orgId: string, role?: UserRole): User;
|
|
323
|
+
declare function getUser(id: string): User | undefined;
|
|
324
|
+
declare function getUserByEmail(email: string): User | undefined;
|
|
325
|
+
declare function getUsersByOrg(orgId: string): User[];
|
|
326
|
+
declare function createApiKey(userId: string, name: string, expiresAt?: string): {
|
|
327
|
+
apiKey: ApiKey;
|
|
328
|
+
rawKey: string;
|
|
329
|
+
};
|
|
330
|
+
declare function getApiKeyByHash(hash: string): ApiKey | undefined;
|
|
331
|
+
declare function listApiKeys(userId: string): ApiKey[];
|
|
332
|
+
declare function deleteApiKey(id: string): boolean;
|
|
333
|
+
declare function updateApiKeyLastUsed(id: string): void;
|
|
334
|
+
declare function createSessionForUser(userId: string, url: string, projectId?: string): Session;
|
|
335
|
+
declare function listSessionsForUser(userId: string): Session[];
|
|
336
|
+
declare function getSessionForUser(userId: string, sessionId: string): Session | undefined;
|
|
337
|
+
declare function getSessionWithAnnotationsForUser(userId: string, sessionId: string): SessionWithAnnotations | undefined;
|
|
338
|
+
declare function getPendingAnnotationsForUser(userId: string, sessionId: string): Annotation[];
|
|
339
|
+
declare function getAllPendingForUser(userId: string): Annotation[];
|
|
340
|
+
|
|
341
|
+
export { type AFSEvent, type AFSEventType, type AFSStore, type ActionRequest, type Annotation, type AnnotationIntent, type AnnotationSeverity, type AnnotationStatus, type ApiKey, type Organization, type Session, type SessionStatus, type SessionWithAnnotations, type TenantStore, type ThreadMessage, type User, type UserContext, type UserRole, addAnnotation, addThreadMessage, clearAll, createApiKey, createOrganization, createSession, createSessionForUser, createUser, createUserContext, deleteAnnotation, deleteApiKey, eventBus, getAllPendingForUser, getAnnotation, getApiKeyByHash, getEventsSince, getOrganization, getPendingAnnotations, getPendingAnnotationsForUser, getSession, getSessionAnnotations, getSessionForUser, getSessionWithAnnotations, getSessionWithAnnotationsForUser, getStore, getTenantStore, getUser, getUserByEmail, getUsersByOrg, hashApiKey, isValidApiKeyFormat, listApiKeys, listSessions, listSessionsForUser, resetTenantStore, startHttpServer, startMcpServer, store, updateAnnotation, updateAnnotationStatus, updateApiKeyLastUsed, updateSessionStatus, userEventBus };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create and start the HTTP server.
|
|
3
|
+
* @param port - Port to listen on
|
|
4
|
+
* @param apiKey - Optional API key for cloud storage mode
|
|
5
|
+
*/
|
|
6
|
+
declare function startHttpServer(port: number, apiKey?: string): void;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create and start the MCP server on stdio.
|
|
10
|
+
* @param baseUrl - Optional HTTP server URL to fetch from (default: http://localhost:4747)
|
|
11
|
+
*/
|
|
12
|
+
declare function startMcpServer(baseUrl?: string): Promise<void>;
|
|
13
|
+
|
|
14
|
+
type Annotation = {
|
|
15
|
+
id: string;
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
comment: string;
|
|
19
|
+
element: string;
|
|
20
|
+
elementPath: string;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
selectedText?: string;
|
|
23
|
+
boundingBox?: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
29
|
+
nearbyText?: string;
|
|
30
|
+
cssClasses?: string;
|
|
31
|
+
nearbyElements?: string;
|
|
32
|
+
computedStyles?: string;
|
|
33
|
+
fullPath?: string;
|
|
34
|
+
accessibility?: string;
|
|
35
|
+
isMultiSelect?: boolean;
|
|
36
|
+
isFixed?: boolean;
|
|
37
|
+
reactComponents?: string;
|
|
38
|
+
sessionId?: string;
|
|
39
|
+
url?: string;
|
|
40
|
+
intent?: AnnotationIntent;
|
|
41
|
+
severity?: AnnotationSeverity;
|
|
42
|
+
status?: AnnotationStatus;
|
|
43
|
+
thread?: ThreadMessage[];
|
|
44
|
+
createdAt?: string;
|
|
45
|
+
updatedAt?: string;
|
|
46
|
+
resolvedAt?: string;
|
|
47
|
+
resolvedBy?: "human" | "agent";
|
|
48
|
+
authorId?: string;
|
|
49
|
+
};
|
|
50
|
+
type AnnotationIntent = "fix" | "change" | "question" | "approve";
|
|
51
|
+
type AnnotationSeverity = "blocking" | "important" | "suggestion";
|
|
52
|
+
type AnnotationStatus = "pending" | "acknowledged" | "resolved" | "dismissed";
|
|
53
|
+
type Session = {
|
|
54
|
+
id: string;
|
|
55
|
+
url: string;
|
|
56
|
+
status: SessionStatus;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
updatedAt?: string;
|
|
59
|
+
projectId?: string;
|
|
60
|
+
metadata?: Record<string, unknown>;
|
|
61
|
+
};
|
|
62
|
+
type SessionStatus = "active" | "approved" | "closed";
|
|
63
|
+
type SessionWithAnnotations = Session & {
|
|
64
|
+
annotations: Annotation[];
|
|
65
|
+
};
|
|
66
|
+
type FrameworkKind = "vue" | "react" | "unknown";
|
|
67
|
+
type SourceLocation = {
|
|
68
|
+
framework: FrameworkKind;
|
|
69
|
+
componentName: string;
|
|
70
|
+
componentHierarchy?: string;
|
|
71
|
+
file: string;
|
|
72
|
+
line?: number;
|
|
73
|
+
column?: number;
|
|
74
|
+
resolver: string;
|
|
75
|
+
};
|
|
76
|
+
type AnnotationV2 = {
|
|
77
|
+
id: string;
|
|
78
|
+
schemaVersion: 1;
|
|
79
|
+
timestamp: string;
|
|
80
|
+
url: string;
|
|
81
|
+
elementSelector: string;
|
|
82
|
+
elementText?: string;
|
|
83
|
+
comment: string;
|
|
84
|
+
source: SourceLocation;
|
|
85
|
+
metadata?: Record<string, unknown>;
|
|
86
|
+
sessionId?: string;
|
|
87
|
+
createdAt?: string;
|
|
88
|
+
updatedAt?: string;
|
|
89
|
+
};
|
|
90
|
+
type SessionWithAnnotationsV2 = Session & {
|
|
91
|
+
annotations: AnnotationV2[];
|
|
92
|
+
};
|
|
93
|
+
type ThreadMessage = {
|
|
94
|
+
id: string;
|
|
95
|
+
role: "human" | "agent";
|
|
96
|
+
content: string;
|
|
97
|
+
timestamp: number;
|
|
98
|
+
};
|
|
99
|
+
type AFSEventType = "annotation.created" | "annotation.updated" | "annotation.deleted" | "session.created" | "session.updated" | "session.closed" | "thread.message" | "action.requested";
|
|
100
|
+
type ActionRequest = {
|
|
101
|
+
sessionId: string;
|
|
102
|
+
annotations: Annotation[];
|
|
103
|
+
output: string;
|
|
104
|
+
timestamp: string;
|
|
105
|
+
};
|
|
106
|
+
type AFSEvent = {
|
|
107
|
+
type: AFSEventType;
|
|
108
|
+
timestamp: string;
|
|
109
|
+
sessionId: string;
|
|
110
|
+
sequence: number;
|
|
111
|
+
payload: Annotation | Session | ThreadMessage | ActionRequest;
|
|
112
|
+
};
|
|
113
|
+
type Organization = {
|
|
114
|
+
id: string;
|
|
115
|
+
name: string;
|
|
116
|
+
createdAt: string;
|
|
117
|
+
updatedAt?: string;
|
|
118
|
+
};
|
|
119
|
+
type UserRole = "owner" | "admin" | "member";
|
|
120
|
+
type User = {
|
|
121
|
+
id: string;
|
|
122
|
+
email: string;
|
|
123
|
+
orgId: string;
|
|
124
|
+
role: UserRole;
|
|
125
|
+
createdAt: string;
|
|
126
|
+
updatedAt?: string;
|
|
127
|
+
};
|
|
128
|
+
type ApiKey = {
|
|
129
|
+
id: string;
|
|
130
|
+
keyPrefix: string;
|
|
131
|
+
keyHash: string;
|
|
132
|
+
userId: string;
|
|
133
|
+
name: string;
|
|
134
|
+
createdAt: string;
|
|
135
|
+
expiresAt?: string;
|
|
136
|
+
lastUsedAt?: string;
|
|
137
|
+
};
|
|
138
|
+
type UserContext = {
|
|
139
|
+
userId: string;
|
|
140
|
+
orgId: string;
|
|
141
|
+
email?: string;
|
|
142
|
+
role?: UserRole;
|
|
143
|
+
};
|
|
144
|
+
interface AFSStore {
|
|
145
|
+
createSession(url: string, projectId?: string): Session;
|
|
146
|
+
getSession(id: string): Session | undefined;
|
|
147
|
+
getSessionWithAnnotations(id: string): SessionWithAnnotations | undefined;
|
|
148
|
+
getSessionWithAnnotationsV2(id: string): SessionWithAnnotationsV2 | undefined;
|
|
149
|
+
updateSessionStatus(id: string, status: SessionStatus): Session | undefined;
|
|
150
|
+
listSessions(): Session[];
|
|
151
|
+
addAnnotation(sessionId: string, data: Omit<Annotation, "id" | "sessionId" | "status" | "createdAt">): Annotation | undefined;
|
|
152
|
+
getAnnotation(id: string): Annotation | undefined;
|
|
153
|
+
updateAnnotation(id: string, data: Partial<Omit<Annotation, "id" | "sessionId" | "createdAt">>): Annotation | undefined;
|
|
154
|
+
updateAnnotationStatus(id: string, status: AnnotationStatus, resolvedBy?: "human" | "agent"): Annotation | undefined;
|
|
155
|
+
addThreadMessage(annotationId: string, role: "human" | "agent", content: string): Annotation | undefined;
|
|
156
|
+
getPendingAnnotations(sessionId: string): Annotation[];
|
|
157
|
+
getSessionAnnotations(sessionId: string): Annotation[];
|
|
158
|
+
deleteAnnotation(id: string): Annotation | undefined;
|
|
159
|
+
addAnnotationV2(sessionId: string, data: AnnotationV2): AnnotationV2 | undefined;
|
|
160
|
+
getAnnotationV2(id: string): AnnotationV2 | undefined;
|
|
161
|
+
updateAnnotationV2(id: string, data: Partial<Omit<AnnotationV2, "id" | "sessionId" | "createdAt">>): AnnotationV2 | undefined;
|
|
162
|
+
getSessionAnnotationsV2(sessionId: string): AnnotationV2[];
|
|
163
|
+
deleteAnnotationV2(id: string): AnnotationV2 | undefined;
|
|
164
|
+
getEventsSince(sessionId: string, sequence: number): AFSEvent[];
|
|
165
|
+
close(): void;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Store module - provides persistence for sessions and annotations.
|
|
170
|
+
*
|
|
171
|
+
* By default uses SQLite (~/.agentation/store.db).
|
|
172
|
+
* Falls back to in-memory storage if SQLite fails to initialize.
|
|
173
|
+
*
|
|
174
|
+
* Usage:
|
|
175
|
+
* import { store } from './store.js';
|
|
176
|
+
* const session = store.createSession('http://localhost:3000');
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Get the store instance. Lazily initializes on first access.
|
|
181
|
+
*/
|
|
182
|
+
declare function getStore(): AFSStore;
|
|
183
|
+
declare const store: {
|
|
184
|
+
readonly instance: AFSStore;
|
|
185
|
+
};
|
|
186
|
+
declare function createSession(url: string, projectId?: string): Session;
|
|
187
|
+
declare function getSession(id: string): Session | undefined;
|
|
188
|
+
declare function getSessionWithAnnotations(id: string): SessionWithAnnotations | undefined;
|
|
189
|
+
declare function updateSessionStatus(id: string, status: SessionStatus): Session | undefined;
|
|
190
|
+
declare function listSessions(): Session[];
|
|
191
|
+
declare function addAnnotation(sessionId: string, data: Omit<Annotation, "id" | "sessionId" | "status" | "createdAt">): Annotation | undefined;
|
|
192
|
+
declare function getAnnotation(id: string): Annotation | undefined;
|
|
193
|
+
declare function updateAnnotation(id: string, data: Partial<Omit<Annotation, "id" | "sessionId" | "createdAt">>): Annotation | undefined;
|
|
194
|
+
declare function updateAnnotationStatus(id: string, status: AnnotationStatus, resolvedBy?: "human" | "agent"): Annotation | undefined;
|
|
195
|
+
declare function addThreadMessage(annotationId: string, role: "human" | "agent", content: string): Annotation | undefined;
|
|
196
|
+
declare function getPendingAnnotations(sessionId: string): Annotation[];
|
|
197
|
+
declare function getSessionAnnotations(sessionId: string): Annotation[];
|
|
198
|
+
declare function deleteAnnotation(id: string): Annotation | undefined;
|
|
199
|
+
declare function getEventsSince(sessionId: string, sequence: number): AFSEvent[];
|
|
200
|
+
/**
|
|
201
|
+
* Clear all data and reset the store.
|
|
202
|
+
*/
|
|
203
|
+
declare function clearAll(): void;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* EventBus for real-time event distribution.
|
|
207
|
+
* Coordinates SSE streams, MCP notifications, and future webhooks.
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
type EventHandler = (event: AFSEvent) => void;
|
|
211
|
+
/**
|
|
212
|
+
* Simple pub/sub event bus for AFS events.
|
|
213
|
+
*/
|
|
214
|
+
declare class EventBus {
|
|
215
|
+
private handlers;
|
|
216
|
+
private sessionHandlers;
|
|
217
|
+
/**
|
|
218
|
+
* Subscribe to all events.
|
|
219
|
+
*/
|
|
220
|
+
subscribe(handler: EventHandler): () => void;
|
|
221
|
+
/**
|
|
222
|
+
* Subscribe to events for a specific session.
|
|
223
|
+
*/
|
|
224
|
+
subscribeToSession(sessionId: string, handler: EventHandler): () => void;
|
|
225
|
+
/**
|
|
226
|
+
* Emit an event to all subscribers.
|
|
227
|
+
*/
|
|
228
|
+
emit(type: AFSEventType, sessionId: string, payload: Annotation | Session | ThreadMessage | ActionRequest): AFSEvent;
|
|
229
|
+
/**
|
|
230
|
+
* Get current sequence number (for reconnect logic).
|
|
231
|
+
*/
|
|
232
|
+
getSequence(): number;
|
|
233
|
+
/**
|
|
234
|
+
* Set sequence from persisted state (for server restart).
|
|
235
|
+
*/
|
|
236
|
+
setSequence(seq: number): void;
|
|
237
|
+
}
|
|
238
|
+
declare const eventBus: EventBus;
|
|
239
|
+
/**
|
|
240
|
+
* User-scoped event bus that filters events by user ID.
|
|
241
|
+
* Prevents data leakage between users in multi-tenant environments.
|
|
242
|
+
*/
|
|
243
|
+
declare class UserEventBus {
|
|
244
|
+
private userHandlers;
|
|
245
|
+
private userSessionHandlers;
|
|
246
|
+
/**
|
|
247
|
+
* Subscribe to all events for a specific user.
|
|
248
|
+
*/
|
|
249
|
+
subscribeForUser(userId: string, handler: EventHandler): () => void;
|
|
250
|
+
/**
|
|
251
|
+
* Subscribe to events for a specific session of a specific user.
|
|
252
|
+
*/
|
|
253
|
+
subscribeToSessionForUser(userId: string, sessionId: string, handler: EventHandler): () => void;
|
|
254
|
+
/**
|
|
255
|
+
* Emit an event scoped to a specific user.
|
|
256
|
+
* Only handlers for that user will receive the event.
|
|
257
|
+
*/
|
|
258
|
+
emitForUser(userId: string, type: AFSEventType, sessionId: string, payload: Annotation | Session | ThreadMessage | ActionRequest): AFSEvent;
|
|
259
|
+
/**
|
|
260
|
+
* Check if a user has any active listeners.
|
|
261
|
+
*/
|
|
262
|
+
hasListenersForUser(userId: string): boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Get count of listeners for a user.
|
|
265
|
+
*/
|
|
266
|
+
getListenerCountForUser(userId: string): number;
|
|
267
|
+
}
|
|
268
|
+
declare const userEventBus: UserEventBus;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* SQLite-backed store for sessions, annotations, and events.
|
|
272
|
+
* Provides persistence across server restarts.
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
interface TenantStore {
|
|
276
|
+
createOrganization(name: string): Organization;
|
|
277
|
+
getOrganization(id: string): Organization | undefined;
|
|
278
|
+
createUser(email: string, orgId: string, role?: UserRole): User;
|
|
279
|
+
getUser(id: string): User | undefined;
|
|
280
|
+
getUserByEmail(email: string): User | undefined;
|
|
281
|
+
getUsersByOrg(orgId: string): User[];
|
|
282
|
+
createApiKey(userId: string, name: string, expiresAt?: string): {
|
|
283
|
+
apiKey: ApiKey;
|
|
284
|
+
rawKey: string;
|
|
285
|
+
};
|
|
286
|
+
getApiKeyByHash(hash: string): ApiKey | undefined;
|
|
287
|
+
listApiKeys(userId: string): ApiKey[];
|
|
288
|
+
deleteApiKey(id: string): boolean;
|
|
289
|
+
updateApiKeyLastUsed(id: string): void;
|
|
290
|
+
createSessionForUser(userId: string, url: string, projectId?: string): Session;
|
|
291
|
+
listSessionsForUser(userId: string): Session[];
|
|
292
|
+
getSessionForUser(userId: string, sessionId: string): Session | undefined;
|
|
293
|
+
getSessionWithAnnotationsForUser(userId: string, sessionId: string): SessionWithAnnotations | undefined;
|
|
294
|
+
getPendingAnnotationsForUser(userId: string, sessionId: string): Annotation[];
|
|
295
|
+
getAllPendingForUser(userId: string): Annotation[];
|
|
296
|
+
close(): void;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Get the tenant store instance. Lazily initializes on first access.
|
|
301
|
+
*/
|
|
302
|
+
declare function getTenantStore(): TenantStore;
|
|
303
|
+
/**
|
|
304
|
+
* Reset the tenant store singleton (for testing).
|
|
305
|
+
*/
|
|
306
|
+
declare function resetTenantStore(): void;
|
|
307
|
+
/**
|
|
308
|
+
* Hash an API key for lookup.
|
|
309
|
+
* Used by auth middleware to find the key in the database.
|
|
310
|
+
*/
|
|
311
|
+
declare function hashApiKey(rawKey: string): string;
|
|
312
|
+
/**
|
|
313
|
+
* Validate API key format.
|
|
314
|
+
*/
|
|
315
|
+
declare function isValidApiKeyFormat(key: string): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Create a UserContext from a User and Organization.
|
|
318
|
+
*/
|
|
319
|
+
declare function createUserContext(user: User): UserContext;
|
|
320
|
+
declare function createOrganization(name: string): Organization;
|
|
321
|
+
declare function getOrganization(id: string): Organization | undefined;
|
|
322
|
+
declare function createUser(email: string, orgId: string, role?: UserRole): User;
|
|
323
|
+
declare function getUser(id: string): User | undefined;
|
|
324
|
+
declare function getUserByEmail(email: string): User | undefined;
|
|
325
|
+
declare function getUsersByOrg(orgId: string): User[];
|
|
326
|
+
declare function createApiKey(userId: string, name: string, expiresAt?: string): {
|
|
327
|
+
apiKey: ApiKey;
|
|
328
|
+
rawKey: string;
|
|
329
|
+
};
|
|
330
|
+
declare function getApiKeyByHash(hash: string): ApiKey | undefined;
|
|
331
|
+
declare function listApiKeys(userId: string): ApiKey[];
|
|
332
|
+
declare function deleteApiKey(id: string): boolean;
|
|
333
|
+
declare function updateApiKeyLastUsed(id: string): void;
|
|
334
|
+
declare function createSessionForUser(userId: string, url: string, projectId?: string): Session;
|
|
335
|
+
declare function listSessionsForUser(userId: string): Session[];
|
|
336
|
+
declare function getSessionForUser(userId: string, sessionId: string): Session | undefined;
|
|
337
|
+
declare function getSessionWithAnnotationsForUser(userId: string, sessionId: string): SessionWithAnnotations | undefined;
|
|
338
|
+
declare function getPendingAnnotationsForUser(userId: string, sessionId: string): Annotation[];
|
|
339
|
+
declare function getAllPendingForUser(userId: string): Annotation[];
|
|
340
|
+
|
|
341
|
+
export { type AFSEvent, type AFSEventType, type AFSStore, type ActionRequest, type Annotation, type AnnotationIntent, type AnnotationSeverity, type AnnotationStatus, type ApiKey, type Organization, type Session, type SessionStatus, type SessionWithAnnotations, type TenantStore, type ThreadMessage, type User, type UserContext, type UserRole, addAnnotation, addThreadMessage, clearAll, createApiKey, createOrganization, createSession, createSessionForUser, createUser, createUserContext, deleteAnnotation, deleteApiKey, eventBus, getAllPendingForUser, getAnnotation, getApiKeyByHash, getEventsSince, getOrganization, getPendingAnnotations, getPendingAnnotationsForUser, getSession, getSessionAnnotations, getSessionForUser, getSessionWithAnnotations, getSessionWithAnnotationsForUser, getStore, getTenantStore, getUser, getUserByEmail, getUsersByOrg, hashApiKey, isValidApiKeyFormat, listApiKeys, listSessions, listSessionsForUser, resetTenantStore, startHttpServer, startMcpServer, store, updateAnnotation, updateAnnotationStatus, updateApiKeyLastUsed, updateSessionStatus, userEventBus };
|