agentic-browser 2.3.0 → 2.4.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.
@@ -0,0 +1,928 @@
1
+
2
+ import WebSocket, { WebSocket as WebSocket$1 } from "ws";
3
+ import { z } from "zod";
4
+
5
+ //#region src/session/browser-controller.d.ts
6
+ type InteractAction = "click" | "type" | "press" | "waitFor" | "evaluate" | "scroll" | "hover" | "select" | "toggle" | "goBack" | "goForward" | "refresh" | "dialog";
7
+ interface InteractPayload {
8
+ action: InteractAction;
9
+ selector?: string;
10
+ fallbackSelectors?: string[];
11
+ text?: string;
12
+ key?: string;
13
+ value?: string;
14
+ scrollX?: number;
15
+ scrollY?: number;
16
+ timeoutMs?: number;
17
+ }
18
+ type PageContentMode = "title" | "text" | "html" | "a11y" | "summary";
19
+ interface PageContentOptions {
20
+ mode: PageContentMode;
21
+ selector?: string;
22
+ maxChars?: number;
23
+ }
24
+ interface PageContentResult {
25
+ mode: PageContentMode;
26
+ content: string;
27
+ truncated?: boolean;
28
+ originalLength?: number;
29
+ structuredContent?: Record<string, unknown>;
30
+ }
31
+ type InteractiveElementRole = "link" | "button" | "input" | "select" | "textarea" | "checkbox" | "radio" | "contenteditable" | "custom";
32
+ type ElementAction = "click" | "type" | "select" | "toggle" | "press";
33
+ interface InteractiveElement {
34
+ selector: string;
35
+ fallbackSelectors?: string[];
36
+ role: InteractiveElementRole;
37
+ tagName: string;
38
+ text: string;
39
+ actions: ElementAction[];
40
+ visible: boolean;
41
+ enabled: boolean;
42
+ href?: string;
43
+ inputType?: string;
44
+ ariaLabel?: string;
45
+ placeholder?: string;
46
+ currentValue?: string;
47
+ }
48
+ interface InteractiveElementsOptions {
49
+ roles?: InteractiveElementRole[];
50
+ visibleOnly?: boolean;
51
+ limit?: number;
52
+ selector?: string;
53
+ }
54
+ interface InteractiveElementsResult {
55
+ elements: InteractiveElement[];
56
+ totalFound: number;
57
+ truncated: boolean;
58
+ }
59
+ interface LaunchOptions {
60
+ executablePath?: string;
61
+ userProfileDir?: string;
62
+ headless?: boolean;
63
+ userAgent?: string;
64
+ }
65
+ interface DismissCookieBannerResult {
66
+ dismissed: boolean;
67
+ method?: "a11y" | "selector" | "text";
68
+ detail?: string;
69
+ }
70
+ type ErrorCode = "SELECTOR_NOT_FOUND" | "ELEMENT_COVERED" | "ELEMENT_NOT_EDITABLE" | "NAVIGATION_TIMEOUT" | "NAVIGATION_FAILED" | "CDP_DISCONNECTED" | "SESSION_DEAD" | "DIALOG_BLOCKING" | "TIMEOUT" | "UNKNOWN";
71
+ interface ScreenshotOptions {
72
+ format?: "jpeg" | "png";
73
+ quality?: number;
74
+ fullPage?: boolean;
75
+ }
76
+ interface ScreenshotResult {
77
+ data: string;
78
+ mimeType: string;
79
+ }
80
+ interface BrowserController {
81
+ launch(sessionId: string, options?: LaunchOptions): Promise<{
82
+ pid: number;
83
+ cdpUrl: string;
84
+ targetWsUrl: string;
85
+ }>;
86
+ connect(cdpUrl: string, options?: {
87
+ userAgent?: string;
88
+ }): Promise<{
89
+ pid: number;
90
+ cdpUrl: string;
91
+ targetWsUrl: string;
92
+ }>;
93
+ navigate(targetWsUrl: string, url: string): Promise<string>;
94
+ interact(targetWsUrl: string, payload: InteractPayload): Promise<string>;
95
+ getContent(targetWsUrl: string, options: PageContentOptions): Promise<PageContentResult>;
96
+ getInteractiveElements(targetWsUrl: string, options: InteractiveElementsOptions): Promise<InteractiveElementsResult>;
97
+ dismissCookieBanner(targetWsUrl: string): Promise<DismissCookieBannerResult>;
98
+ screenshot(targetWsUrl: string, options?: ScreenshotOptions): Promise<ScreenshotResult>;
99
+ getCurrentUrl(targetWsUrl: string): Promise<string>;
100
+ terminate(pid: number): void;
101
+ closeConnection?(targetWsUrl: string): void;
102
+ }
103
+ //#endregion
104
+ //#region src/memory/memory-schemas.d.ts
105
+ declare const InsightFreshnessSchema: z.ZodEnum<{
106
+ fresh: "fresh";
107
+ suspect: "suspect";
108
+ stale: "stale";
109
+ }>;
110
+ declare const TaskStepSchema: z.ZodObject<{
111
+ type: z.ZodEnum<{
112
+ navigate: "navigate";
113
+ interact: "interact";
114
+ assert: "assert";
115
+ }>;
116
+ summary: z.ZodString;
117
+ selector: z.ZodOptional<z.ZodString>;
118
+ payload: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
119
+ }, z.core.$strip>;
120
+ declare const SelectorAliasSchema: z.ZodObject<{
121
+ alias: z.ZodString;
122
+ selector: z.ZodString;
123
+ fallbackSelectors: z.ZodDefault<z.ZodArray<z.ZodString>>;
124
+ }, z.core.$strip>;
125
+ declare const TaskInsightSchema: z.ZodObject<{
126
+ insightId: z.ZodString;
127
+ taskIntent: z.ZodString;
128
+ siteDomain: z.ZodString;
129
+ sitePathPattern: z.ZodString;
130
+ actionRecipe: z.ZodArray<z.ZodObject<{
131
+ type: z.ZodEnum<{
132
+ navigate: "navigate";
133
+ interact: "interact";
134
+ assert: "assert";
135
+ }>;
136
+ summary: z.ZodString;
137
+ selector: z.ZodOptional<z.ZodString>;
138
+ payload: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
139
+ }, z.core.$strip>>;
140
+ expectedOutcome: z.ZodString;
141
+ confidence: z.ZodNumber;
142
+ successCount: z.ZodNumber;
143
+ failureCount: z.ZodNumber;
144
+ useCount: z.ZodNumber;
145
+ freshness: z.ZodEnum<{
146
+ fresh: "fresh";
147
+ suspect: "suspect";
148
+ stale: "stale";
149
+ }>;
150
+ staleStrikeCount: z.ZodNumber;
151
+ lastVerifiedAt: z.ZodString;
152
+ createdAt: z.ZodString;
153
+ updatedAt: z.ZodString;
154
+ supersedes: z.ZodOptional<z.ZodString>;
155
+ evidence: z.ZodArray<z.ZodObject<{
156
+ evidenceId: z.ZodString;
157
+ commandId: z.ZodString;
158
+ result: z.ZodEnum<{
159
+ success: "success";
160
+ failure: "failure";
161
+ }>;
162
+ reason: z.ZodOptional<z.ZodString>;
163
+ selector: z.ZodOptional<z.ZodString>;
164
+ url: z.ZodOptional<z.ZodString>;
165
+ recordedAt: z.ZodString;
166
+ }, z.core.$strip>>;
167
+ selectorAliases: z.ZodDefault<z.ZodArray<z.ZodObject<{
168
+ alias: z.ZodString;
169
+ selector: z.ZodString;
170
+ fallbackSelectors: z.ZodDefault<z.ZodArray<z.ZodString>>;
171
+ }, z.core.$strip>>>;
172
+ }, z.core.$strip>;
173
+ declare const SelectorPatternSchema: z.ZodObject<{
174
+ pattern: z.ZodString;
175
+ frequency: z.ZodNumber;
176
+ lastSeenAt: z.ZodString;
177
+ }, z.core.$strip>;
178
+ declare const PageLayoutFingerprintSchema: z.ZodObject<{
179
+ pathPattern: z.ZodString;
180
+ headings: z.ZodDefault<z.ZodArray<z.ZodString>>;
181
+ landmarks: z.ZodDefault<z.ZodArray<z.ZodString>>;
182
+ lastSeenAt: z.ZodString;
183
+ }, z.core.$strip>;
184
+ declare const SiteProfileSchema: z.ZodObject<{
185
+ domain: z.ZodString;
186
+ selectorPatterns: z.ZodDefault<z.ZodArray<z.ZodObject<{
187
+ pattern: z.ZodString;
188
+ frequency: z.ZodNumber;
189
+ lastSeenAt: z.ZodString;
190
+ }, z.core.$strip>>>;
191
+ layoutFingerprints: z.ZodDefault<z.ZodArray<z.ZodObject<{
192
+ pathPattern: z.ZodString;
193
+ headings: z.ZodDefault<z.ZodArray<z.ZodString>>;
194
+ landmarks: z.ZodDefault<z.ZodArray<z.ZodString>>;
195
+ lastSeenAt: z.ZodString;
196
+ }, z.core.$strip>>>;
197
+ navigationPaths: z.ZodDefault<z.ZodArray<z.ZodString>>;
198
+ cookieBanner: z.ZodOptional<z.ZodObject<{
199
+ detected: z.ZodBoolean;
200
+ autoDismissed: z.ZodOptional<z.ZodBoolean>;
201
+ method: z.ZodOptional<z.ZodString>;
202
+ }, z.core.$strip>>;
203
+ visitCount: z.ZodDefault<z.ZodNumber>;
204
+ lastVisitAt: z.ZodString;
205
+ createdAt: z.ZodString;
206
+ }, z.core.$strip>;
207
+ type InsightFreshness = z.infer<typeof InsightFreshnessSchema>;
208
+ type TaskStep = z.infer<typeof TaskStepSchema>;
209
+ type SelectorAlias = z.infer<typeof SelectorAliasSchema>;
210
+ type TaskInsight = z.infer<typeof TaskInsightSchema>;
211
+ type SelectorPattern = z.infer<typeof SelectorPatternSchema>;
212
+ type PageLayoutFingerprint = z.infer<typeof PageLayoutFingerprintSchema>;
213
+ type SiteProfile = z.infer<typeof SiteProfileSchema>;
214
+ interface SiteProfileSummary {
215
+ selectorPatterns: SelectorPattern[];
216
+ layoutFingerprints: PageLayoutFingerprint[];
217
+ cookieBanner?: {
218
+ detected: boolean;
219
+ autoDismissed?: boolean;
220
+ method?: string;
221
+ };
222
+ visitCount: number;
223
+ }
224
+ interface MemorySearchResult {
225
+ insightId: string;
226
+ taskIntent: string;
227
+ siteDomain: string;
228
+ confidence: number;
229
+ freshness: InsightFreshness;
230
+ lastVerifiedAt: string;
231
+ selectorHints: string[];
232
+ selectorAliases: SelectorAlias[];
233
+ score: number;
234
+ siteProfile?: SiteProfileSummary;
235
+ }
236
+ //#endregion
237
+ //#region src/lib/domain-schemas.d.ts
238
+ declare const SessionStatusSchema: z.ZodEnum<{
239
+ starting: "starting";
240
+ ready: "ready";
241
+ disconnected: "disconnected";
242
+ failed: "failed";
243
+ terminated: "terminated";
244
+ }>;
245
+ declare const CommandTypeSchema: z.ZodEnum<{
246
+ navigate: "navigate";
247
+ interact: "interact";
248
+ restart: "restart";
249
+ terminate: "terminate";
250
+ }>;
251
+ declare const SessionSchema: z.ZodObject<{
252
+ sessionId: z.ZodString;
253
+ status: z.ZodEnum<{
254
+ starting: "starting";
255
+ ready: "ready";
256
+ disconnected: "disconnected";
257
+ failed: "failed";
258
+ terminated: "terminated";
259
+ }>;
260
+ browserType: z.ZodLiteral<"chrome">;
261
+ startedAt: z.ZodString;
262
+ endedAt: z.ZodOptional<z.ZodString>;
263
+ authTokenRef: z.ZodString;
264
+ }, z.core.$strip>;
265
+ declare const CommandSchema: z.ZodObject<{
266
+ commandId: z.ZodString;
267
+ sessionId: z.ZodString;
268
+ type: z.ZodEnum<{
269
+ navigate: "navigate";
270
+ interact: "interact";
271
+ restart: "restart";
272
+ terminate: "terminate";
273
+ }>;
274
+ payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
275
+ submittedAt: z.ZodString;
276
+ completedAt: z.ZodOptional<z.ZodString>;
277
+ resultStatus: z.ZodOptional<z.ZodEnum<{
278
+ failed: "failed";
279
+ success: "success";
280
+ timed_out: "timed_out";
281
+ }>>;
282
+ resultMessage: z.ZodOptional<z.ZodString>;
283
+ }, z.core.$strip>;
284
+ declare const SessionEventSchema: z.ZodObject<{
285
+ eventId: z.ZodString;
286
+ sessionId: z.ZodString;
287
+ category: z.ZodEnum<{
288
+ lifecycle: "lifecycle";
289
+ security: "security";
290
+ command: "command";
291
+ }>;
292
+ message: z.ZodString;
293
+ createdAt: z.ZodString;
294
+ severity: z.ZodEnum<{
295
+ error: "error";
296
+ info: "info";
297
+ warning: "warning";
298
+ }>;
299
+ }, z.core.$strip>;
300
+ type SessionStatus = z.infer<typeof SessionStatusSchema>;
301
+ type CommandType = z.infer<typeof CommandTypeSchema>;
302
+ type Session = z.infer<typeof SessionSchema>;
303
+ type Command = z.infer<typeof CommandSchema>;
304
+ type SessionEvent = z.infer<typeof SessionEventSchema>;
305
+ //#endregion
306
+ //#region src/lib/config.d.ts
307
+ interface AppConfig {
308
+ host: string;
309
+ wsPort: number;
310
+ dataDir: string;
311
+ browserExecutablePath?: string;
312
+ commandTimeoutMs: number;
313
+ cdpUrl?: string;
314
+ userProfileDir?: string;
315
+ headless?: boolean;
316
+ userAgent?: string;
317
+ }
318
+ declare function loadConfig(env?: NodeJS.ProcessEnv): AppConfig;
319
+ //#endregion
320
+ //#region src/observability/logger.d.ts
321
+ interface LogContext {
322
+ [key: string]: unknown;
323
+ }
324
+ declare class Logger {
325
+ private readonly namespace;
326
+ constructor(namespace: string);
327
+ private emit;
328
+ info(message: string, context?: LogContext): void;
329
+ warning(message: string, context?: LogContext): void;
330
+ error(message: string, context?: LogContext): void;
331
+ }
332
+ //#endregion
333
+ //#region src/observability/event-store.d.ts
334
+ declare class EventStore {
335
+ private readonly events;
336
+ private readonly filePath;
337
+ private readonly bufferedLines;
338
+ private flushTimer;
339
+ private flushInFlight;
340
+ constructor(baseDir: string);
341
+ append(event: SessionEvent): void;
342
+ list(sessionId: string, limit?: number): SessionEvent[];
343
+ clear(sessionId: string): void;
344
+ private flushSoon;
345
+ private flushAsync;
346
+ private readonly flushSync;
347
+ }
348
+ //#endregion
349
+ //#region src/auth/session-token.d.ts
350
+ declare class SessionTokenService {
351
+ private readonly tokens;
352
+ issue(sessionId: string): string;
353
+ validate(sessionId: string, token: string): boolean;
354
+ revoke(sessionId: string): void;
355
+ get(sessionId: string): string | undefined;
356
+ seed(sessionId: string, token: string): void;
357
+ }
358
+ //#endregion
359
+ //#region src/transport/ws-server.d.ts
360
+ interface WsServerOptions {
361
+ host: string;
362
+ port: number;
363
+ tokenService: SessionTokenService;
364
+ }
365
+ declare class AuthenticatedWsServer {
366
+ private readonly options;
367
+ private readonly logger;
368
+ private server?;
369
+ constructor(options: WsServerOptions);
370
+ start(onMessage: (socket: WebSocket$1, data: unknown) => void): void;
371
+ stop(): void;
372
+ }
373
+ //#endregion
374
+ //#region src/memory/memory-service.d.ts
375
+ interface MemorySearchInput {
376
+ taskIntent: string;
377
+ siteDomain?: string;
378
+ limit?: number;
379
+ }
380
+ interface RecordExecutionInput {
381
+ commandId: string;
382
+ taskIntent: string;
383
+ siteDomain: string;
384
+ sitePathPattern: string;
385
+ step: TaskStep;
386
+ expectedOutcome: string;
387
+ url?: string;
388
+ selector?: string;
389
+ }
390
+ declare class MemoryService {
391
+ private readonly store;
392
+ private readonly profileStore;
393
+ private readonly index;
394
+ /** Simple TTL cache for search results keyed by intent+domain+limit. */
395
+ private searchCache;
396
+ constructor(baseDir: string);
397
+ /** Force an immediate synchronous flush of pending writes. */
398
+ flushSync(): void;
399
+ search(input: MemorySearchInput): MemorySearchResult[];
400
+ /** Invalidate search cache when data changes. */
401
+ private invalidateSearchCache;
402
+ inspect(insightId: string): TaskInsight;
403
+ stats(): {
404
+ total: number;
405
+ fresh: number;
406
+ suspect: number;
407
+ stale: number;
408
+ topDomains: Array<{
409
+ domain: string;
410
+ count: number;
411
+ }>;
412
+ };
413
+ verify(insightId: string): TaskInsight;
414
+ recordSuccess(input: RecordExecutionInput): TaskInsight;
415
+ recordFailure(input: RecordExecutionInput, errorMessage: string): TaskInsight | undefined;
416
+ /** Update site profile from page content (call after getContent with mode="summary"). */
417
+ updateProfileFromContent(domain: string, pathPattern: string, structuredContent: {
418
+ headings?: string[];
419
+ landmarks?: string[];
420
+ }): void;
421
+ /** Update site profile with cookie banner behavior. */
422
+ updateProfileCookieBanner(domain: string, result: {
423
+ dismissed: boolean;
424
+ method?: string;
425
+ detail?: string;
426
+ }): void;
427
+ /** Look up a site profile by domain. */
428
+ getSiteProfile(domain: string): SiteProfile | undefined;
429
+ private updateSiteProfile;
430
+ private createEmptyProfile;
431
+ private classifySelectorPattern;
432
+ private findBestExactMatch;
433
+ private scoreExactMatch;
434
+ private sameFirstPathSegment;
435
+ private createEvidence;
436
+ private maybeGenerateAliases;
437
+ private deriveAliasName;
438
+ private mergeRecipe;
439
+ }
440
+ //#endregion
441
+ //#region src/cli/app.d.ts
442
+ interface AppContext {
443
+ config: ReturnType<typeof loadConfig>;
444
+ logger: Logger;
445
+ eventStore: EventStore;
446
+ tokenService: SessionTokenService;
447
+ wsServer: AuthenticatedWsServer;
448
+ memoryService: MemoryService;
449
+ }
450
+ //#endregion
451
+ //#region src/session/session-store.d.ts
452
+ interface StoredSessionRecord {
453
+ session: Session;
454
+ cdpUrl: string;
455
+ targetWsUrl: string;
456
+ pid: number;
457
+ lastUrl?: string;
458
+ }
459
+ //#endregion
460
+ //#region src/session/session-manager.d.ts
461
+ interface CreateSessionInput {
462
+ browser: "chrome";
463
+ }
464
+ interface ExecuteCommandInput$1 {
465
+ commandId: string;
466
+ type: CommandType;
467
+ payload: Record<string, unknown>;
468
+ }
469
+ interface CleanupInput {
470
+ maxAgeDays?: number;
471
+ dryRun?: boolean;
472
+ }
473
+ interface CleanupResult {
474
+ removedSessionIds: string[];
475
+ removedProfileDirs: string[];
476
+ keptActiveSessionId?: string;
477
+ dryRun: boolean;
478
+ }
479
+ declare class SessionManager {
480
+ private readonly ctx;
481
+ private readonly browser;
482
+ private readonly store;
483
+ constructor(ctx: AppContext, browser: BrowserController);
484
+ createSession(input: CreateSessionInput): Promise<Session>;
485
+ getSession(sessionId: string): Session;
486
+ /** Return a healthy session, recovering automatically if needed. */
487
+ ensureSession(sessionId: string): Promise<StoredSessionRecord>;
488
+ executeCommand(sessionId: string, input: ExecuteCommandInput$1): Promise<Command>;
489
+ getContent(sessionId: string, options: PageContentOptions): Promise<PageContentResult>;
490
+ getInteractiveElements(sessionId: string, options: InteractiveElementsOptions): Promise<InteractiveElementsResult>;
491
+ screenshot(sessionId: string, options?: ScreenshotOptions): Promise<ScreenshotResult>;
492
+ getCurrentUrl(sessionId: string): Promise<string>;
493
+ dismissCookieBanner(sessionId: string): Promise<DismissCookieBannerResult>;
494
+ setStatus(status: SessionStatus, reason: string): Session;
495
+ terminateSession(sessionId: string): Promise<Session>;
496
+ restartSession(sessionId: string): Promise<Session>;
497
+ getAuthToken(sessionId: string): string;
498
+ rotateAuthToken(sessionId: string): string;
499
+ listEvents(sessionId: string, limit?: number): SessionEvent[];
500
+ searchMemory(input: {
501
+ taskIntent: string;
502
+ siteDomain?: string;
503
+ limit?: number;
504
+ }): MemorySearchResult[];
505
+ inspectMemory(insightId: string): {
506
+ insightId: string;
507
+ taskIntent: string;
508
+ siteDomain: string;
509
+ sitePathPattern: string;
510
+ actionRecipe: {
511
+ type: "navigate" | "interact" | "assert";
512
+ summary: string;
513
+ payload: Record<string, unknown>;
514
+ selector?: string | undefined;
515
+ }[];
516
+ expectedOutcome: string;
517
+ confidence: number;
518
+ successCount: number;
519
+ failureCount: number;
520
+ useCount: number;
521
+ freshness: "fresh" | "suspect" | "stale";
522
+ staleStrikeCount: number;
523
+ lastVerifiedAt: string;
524
+ createdAt: string;
525
+ updatedAt: string;
526
+ evidence: {
527
+ evidenceId: string;
528
+ commandId: string;
529
+ result: "success" | "failure";
530
+ recordedAt: string;
531
+ reason?: string | undefined;
532
+ selector?: string | undefined;
533
+ url?: string | undefined;
534
+ }[];
535
+ selectorAliases: {
536
+ alias: string;
537
+ selector: string;
538
+ fallbackSelectors: string[];
539
+ }[];
540
+ supersedes?: string | undefined;
541
+ };
542
+ verifyMemory(insightId: string): {
543
+ insightId: string;
544
+ taskIntent: string;
545
+ siteDomain: string;
546
+ sitePathPattern: string;
547
+ actionRecipe: {
548
+ type: "navigate" | "interact" | "assert";
549
+ summary: string;
550
+ payload: Record<string, unknown>;
551
+ selector?: string | undefined;
552
+ }[];
553
+ expectedOutcome: string;
554
+ confidence: number;
555
+ successCount: number;
556
+ failureCount: number;
557
+ useCount: number;
558
+ freshness: "fresh" | "suspect" | "stale";
559
+ staleStrikeCount: number;
560
+ lastVerifiedAt: string;
561
+ createdAt: string;
562
+ updatedAt: string;
563
+ evidence: {
564
+ evidenceId: string;
565
+ commandId: string;
566
+ result: "success" | "failure";
567
+ recordedAt: string;
568
+ reason?: string | undefined;
569
+ selector?: string | undefined;
570
+ url?: string | undefined;
571
+ }[];
572
+ selectorAliases: {
573
+ alias: string;
574
+ selector: string;
575
+ fallbackSelectors: string[];
576
+ }[];
577
+ supersedes?: string | undefined;
578
+ };
579
+ memoryStats(): {
580
+ total: number;
581
+ fresh: number;
582
+ suspect: number;
583
+ stale: number;
584
+ topDomains: Array<{
585
+ domain: string;
586
+ count: number;
587
+ }>;
588
+ };
589
+ cleanupSessions(input: CleanupInput): CleanupResult;
590
+ /** Quick health check — probe the CDP connection with a lightweight evaluate. */
591
+ private isSessionAlive;
592
+ /** Force-terminate a session record, cleaning up process, connection, and store. */
593
+ private forceTerminate;
594
+ private mustGetRecord;
595
+ private recordEvent;
596
+ private buildMemoryContext;
597
+ private parseUrl;
598
+ }
599
+ //#endregion
600
+ //#region src/transport/control-api.d.ts
601
+ declare class ControlApi {
602
+ private readonly sessions;
603
+ private readonly eventStore;
604
+ constructor(sessions: SessionManager, eventStore: EventStore);
605
+ createSession(input: {
606
+ browser: "chrome";
607
+ }): Promise<{
608
+ sessionId: string;
609
+ status: "starting" | "ready" | "disconnected" | "failed" | "terminated";
610
+ browserType: "chrome";
611
+ startedAt: string;
612
+ authTokenRef: string;
613
+ endedAt?: string | undefined;
614
+ }>;
615
+ getSession(sessionId: string): {
616
+ sessionId: string;
617
+ status: "starting" | "ready" | "disconnected" | "failed" | "terminated";
618
+ browserType: "chrome";
619
+ startedAt: string;
620
+ authTokenRef: string;
621
+ endedAt?: string | undefined;
622
+ };
623
+ terminateSession(sessionId: string): Promise<void>;
624
+ executeCommand(sessionId: string, input: {
625
+ commandId: string;
626
+ type: "navigate" | "interact" | "restart" | "terminate";
627
+ payload: Record<string, unknown>;
628
+ }): Promise<{
629
+ commandId: string;
630
+ sessionId: string;
631
+ type: "navigate" | "interact" | "restart" | "terminate";
632
+ payload: Record<string, unknown>;
633
+ submittedAt: string;
634
+ completedAt?: string | undefined;
635
+ resultStatus?: "failed" | "success" | "timed_out" | undefined;
636
+ resultMessage?: string | undefined;
637
+ }>;
638
+ restartSession(sessionId: string): Promise<{
639
+ sessionId: string;
640
+ status: "starting" | "ready" | "disconnected" | "failed" | "terminated";
641
+ browserType: "chrome";
642
+ startedAt: string;
643
+ authTokenRef: string;
644
+ endedAt?: string | undefined;
645
+ }>;
646
+ rotateSessionToken(sessionId: string): string;
647
+ getContent(sessionId: string, options: {
648
+ mode: "title" | "text" | "html" | "a11y" | "summary";
649
+ selector?: string;
650
+ maxChars?: number;
651
+ }): Promise<PageContentResult>;
652
+ getInteractiveElements(sessionId: string, options: InteractiveElementsOptions): Promise<InteractiveElementsResult>;
653
+ dismissCookieBanner(sessionId: string): Promise<DismissCookieBannerResult>;
654
+ screenshot(sessionId: string, options?: ScreenshotOptions): Promise<ScreenshotResult>;
655
+ getCurrentUrl(sessionId: string): Promise<string>;
656
+ listEvents(sessionId: string, limit?: number): {
657
+ events: {
658
+ eventId: string;
659
+ sessionId: string;
660
+ category: "lifecycle" | "security" | "command";
661
+ message: string;
662
+ createdAt: string;
663
+ severity: "error" | "info" | "warning";
664
+ }[];
665
+ };
666
+ searchMemory(input: {
667
+ taskIntent: string;
668
+ siteDomain?: string;
669
+ limit?: number;
670
+ }): {
671
+ results: MemorySearchResult[];
672
+ };
673
+ inspectMemory(insightId: string): {
674
+ insightId: string;
675
+ taskIntent: string;
676
+ siteDomain: string;
677
+ sitePathPattern: string;
678
+ actionRecipe: {
679
+ type: "navigate" | "interact" | "assert";
680
+ summary: string;
681
+ payload: Record<string, unknown>;
682
+ selector?: string | undefined;
683
+ }[];
684
+ expectedOutcome: string;
685
+ confidence: number;
686
+ successCount: number;
687
+ failureCount: number;
688
+ useCount: number;
689
+ freshness: "fresh" | "suspect" | "stale";
690
+ staleStrikeCount: number;
691
+ lastVerifiedAt: string;
692
+ createdAt: string;
693
+ updatedAt: string;
694
+ evidence: {
695
+ evidenceId: string;
696
+ commandId: string;
697
+ result: "success" | "failure";
698
+ recordedAt: string;
699
+ reason?: string | undefined;
700
+ selector?: string | undefined;
701
+ url?: string | undefined;
702
+ }[];
703
+ selectorAliases: {
704
+ alias: string;
705
+ selector: string;
706
+ fallbackSelectors: string[];
707
+ }[];
708
+ supersedes?: string | undefined;
709
+ };
710
+ verifyMemory(insightId: string): {
711
+ insightId: string;
712
+ taskIntent: string;
713
+ siteDomain: string;
714
+ sitePathPattern: string;
715
+ actionRecipe: {
716
+ type: "navigate" | "interact" | "assert";
717
+ summary: string;
718
+ payload: Record<string, unknown>;
719
+ selector?: string | undefined;
720
+ }[];
721
+ expectedOutcome: string;
722
+ confidence: number;
723
+ successCount: number;
724
+ failureCount: number;
725
+ useCount: number;
726
+ freshness: "fresh" | "suspect" | "stale";
727
+ staleStrikeCount: number;
728
+ lastVerifiedAt: string;
729
+ createdAt: string;
730
+ updatedAt: string;
731
+ evidence: {
732
+ evidenceId: string;
733
+ commandId: string;
734
+ result: "success" | "failure";
735
+ recordedAt: string;
736
+ reason?: string | undefined;
737
+ selector?: string | undefined;
738
+ url?: string | undefined;
739
+ }[];
740
+ selectorAliases: {
741
+ alias: string;
742
+ selector: string;
743
+ fallbackSelectors: string[];
744
+ }[];
745
+ supersedes?: string | undefined;
746
+ };
747
+ memoryStats(): {
748
+ total: number;
749
+ fresh: number;
750
+ suspect: number;
751
+ stale: number;
752
+ topDomains: Array<{
753
+ domain: string;
754
+ count: number;
755
+ }>;
756
+ };
757
+ cleanupSessions(input: {
758
+ maxAgeDays?: number;
759
+ dryRun?: boolean;
760
+ }): CleanupResult;
761
+ }
762
+ //#endregion
763
+ //#region src/cli/runtime.d.ts
764
+ interface AgenticBrowserCoreOptions {
765
+ env?: NodeJS.ProcessEnv;
766
+ browserController?: BrowserController;
767
+ }
768
+ interface ExecuteCommandInput {
769
+ sessionId: string;
770
+ commandId?: string;
771
+ type: CommandType;
772
+ payload: Record<string, unknown>;
773
+ }
774
+ declare class AgenticBrowserCore {
775
+ readonly context: AppContext;
776
+ readonly sessions: SessionManager;
777
+ readonly api: ControlApi;
778
+ constructor(context: AppContext, browserController: BrowserController);
779
+ startSession(input?: {
780
+ browser: "chrome";
781
+ }): Promise<{
782
+ sessionId: string;
783
+ status: "starting" | "ready" | "disconnected" | "failed" | "terminated";
784
+ browserType: "chrome";
785
+ startedAt: string;
786
+ authTokenRef: string;
787
+ endedAt?: string | undefined;
788
+ }>;
789
+ getSession(sessionId: string): {
790
+ sessionId: string;
791
+ status: "starting" | "ready" | "disconnected" | "failed" | "terminated";
792
+ browserType: "chrome";
793
+ startedAt: string;
794
+ authTokenRef: string;
795
+ endedAt?: string | undefined;
796
+ };
797
+ runCommand(input: ExecuteCommandInput): Promise<{
798
+ commandId: string;
799
+ sessionId: string;
800
+ type: "navigate" | "interact" | "restart" | "terminate";
801
+ payload: Record<string, unknown>;
802
+ submittedAt: string;
803
+ completedAt?: string | undefined;
804
+ resultStatus?: "failed" | "success" | "timed_out" | undefined;
805
+ resultMessage?: string | undefined;
806
+ }>;
807
+ getPageContent(input: {
808
+ sessionId: string;
809
+ mode: "title" | "text" | "html" | "a11y" | "summary";
810
+ selector?: string;
811
+ maxChars?: number;
812
+ }): Promise<PageContentResult>;
813
+ getInteractiveElements(input: {
814
+ sessionId: string;
815
+ roles?: InteractiveElementRole[];
816
+ visibleOnly?: boolean;
817
+ limit?: number;
818
+ selector?: string;
819
+ }): Promise<InteractiveElementsResult>;
820
+ dismissCookieBanner(sessionId: string): Promise<DismissCookieBannerResult>;
821
+ screenshot(sessionId: string, options?: ScreenshotOptions): Promise<ScreenshotResult>;
822
+ getCurrentUrl(sessionId: string): Promise<string>;
823
+ restartSession(sessionId: string): Promise<{
824
+ sessionId: string;
825
+ status: "starting" | "ready" | "disconnected" | "failed" | "terminated";
826
+ browserType: "chrome";
827
+ startedAt: string;
828
+ authTokenRef: string;
829
+ endedAt?: string | undefined;
830
+ }>;
831
+ stopSession(sessionId: string): Promise<void>;
832
+ rotateSessionToken(sessionId: string): string;
833
+ searchMemory(input: {
834
+ taskIntent: string;
835
+ siteDomain?: string;
836
+ limit?: number;
837
+ }): {
838
+ results: MemorySearchResult[];
839
+ };
840
+ inspectMemory(insightId: string): {
841
+ insightId: string;
842
+ taskIntent: string;
843
+ siteDomain: string;
844
+ sitePathPattern: string;
845
+ actionRecipe: {
846
+ type: "navigate" | "interact" | "assert";
847
+ summary: string;
848
+ payload: Record<string, unknown>;
849
+ selector?: string | undefined;
850
+ }[];
851
+ expectedOutcome: string;
852
+ confidence: number;
853
+ successCount: number;
854
+ failureCount: number;
855
+ useCount: number;
856
+ freshness: "fresh" | "suspect" | "stale";
857
+ staleStrikeCount: number;
858
+ lastVerifiedAt: string;
859
+ createdAt: string;
860
+ updatedAt: string;
861
+ evidence: {
862
+ evidenceId: string;
863
+ commandId: string;
864
+ result: "success" | "failure";
865
+ recordedAt: string;
866
+ reason?: string | undefined;
867
+ selector?: string | undefined;
868
+ url?: string | undefined;
869
+ }[];
870
+ selectorAliases: {
871
+ alias: string;
872
+ selector: string;
873
+ fallbackSelectors: string[];
874
+ }[];
875
+ supersedes?: string | undefined;
876
+ };
877
+ verifyMemory(insightId: string): {
878
+ insightId: string;
879
+ taskIntent: string;
880
+ siteDomain: string;
881
+ sitePathPattern: string;
882
+ actionRecipe: {
883
+ type: "navigate" | "interact" | "assert";
884
+ summary: string;
885
+ payload: Record<string, unknown>;
886
+ selector?: string | undefined;
887
+ }[];
888
+ expectedOutcome: string;
889
+ confidence: number;
890
+ successCount: number;
891
+ failureCount: number;
892
+ useCount: number;
893
+ freshness: "fresh" | "suspect" | "stale";
894
+ staleStrikeCount: number;
895
+ lastVerifiedAt: string;
896
+ createdAt: string;
897
+ updatedAt: string;
898
+ evidence: {
899
+ evidenceId: string;
900
+ commandId: string;
901
+ result: "success" | "failure";
902
+ recordedAt: string;
903
+ reason?: string | undefined;
904
+ selector?: string | undefined;
905
+ url?: string | undefined;
906
+ }[];
907
+ selectorAliases: {
908
+ alias: string;
909
+ selector: string;
910
+ fallbackSelectors: string[];
911
+ }[];
912
+ supersedes?: string | undefined;
913
+ };
914
+ memoryStats(): {
915
+ total: number;
916
+ fresh: number;
917
+ suspect: number;
918
+ stale: number;
919
+ topDomains: Array<{
920
+ domain: string;
921
+ count: number;
922
+ }>;
923
+ };
924
+ }
925
+ declare function createAgenticBrowserCore(options?: AgenticBrowserCoreOptions): AgenticBrowserCore;
926
+ declare function createMockAgenticBrowserCore(env: NodeJS.ProcessEnv): AgenticBrowserCore;
927
+ //#endregion
928
+ export { AgenticBrowserCore, type AgenticBrowserCoreOptions, type DismissCookieBannerResult, type ElementAction, type ErrorCode, type ExecuteCommandInput, type InteractiveElement, type InteractiveElementRole, type InteractiveElementsOptions, type InteractiveElementsResult, type LaunchOptions, type ScreenshotOptions, type ScreenshotResult, createAgenticBrowserCore, createMockAgenticBrowserCore };