vite-plugin-ai-annotator 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -0
- package/dist/annotator/detectors.d.ts +33 -0
- package/dist/annotator/inspection.d.ts +10 -0
- package/dist/annotator/selection.d.ts +24 -0
- package/dist/annotator-toolbar.d.ts +67 -0
- package/dist/annotator-toolbar.js +8066 -0
- package/dist/index.cjs +448 -0
- package/dist/index.d.ts +2 -0
- package/dist/inspector/ai.d.ts +20 -0
- package/dist/inspector/console.d.ts +20 -0
- package/dist/inspector/detectors.d.ts +33 -0
- package/dist/inspector/inspection.d.ts +10 -0
- package/dist/inspector/logger.d.ts +11 -0
- package/dist/inspector/selection.d.ts +24 -0
- package/dist/inspector/style.d.ts +13 -0
- package/dist/inspector-toolbar.js +6705 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/rpc/client.generated.d.ts +82 -0
- package/dist/rpc/define.d.ts +81 -0
- package/dist/rpc/server.generated.d.ts +82 -0
- package/dist/rpc/types.generated.d.ts +21 -0
- package/dist/shared/schemas.d.ts +119 -0
- package/dist/shared/types.d.ts +1 -0
- package/dist/trpc/context.d.ts +28 -0
- package/dist/trpc/router.d.ts +195 -0
- package/dist/trpc-server.d.ts +14 -0
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/sourcemap.d.ts +72 -0
- package/dist/utils/xpath.d.ts +54 -0
- package/dist/vite-plugin.d.ts +25 -0
- package/dist/vite-plugin.js +219 -0
- package/dist/vite-plugin.js.map +7 -0
- package/dist/ws-server.d.ts +26 -0
- package/package.json +86 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE - IT IS AUTO-GENERATED ⚠️
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated client RPC from define.ts
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* const client = createRpcClient(socket);
|
|
8
|
+
* client.handle.eventName(async (data) => { ... });
|
|
9
|
+
* client.server.methodName(args);
|
|
10
|
+
* client.dispose();
|
|
11
|
+
*
|
|
12
|
+
* To regenerate: bunx socketrpc-gen /Volumes/Data/Projects/instantcode/app/src/rpc/define.ts
|
|
13
|
+
*/
|
|
14
|
+
import type { Socket } from "socket.io-client";
|
|
15
|
+
import type { RpcError } from "./types.generated";
|
|
16
|
+
import type { BrowserSession, PageContext, ElementData, SelectionResult, ScreenshotResult, InjectResult, ConsoleEntry } from "./define";
|
|
17
|
+
/** Handler registration methods - implement these to handle calls from server */
|
|
18
|
+
export interface RpcClientHandle {
|
|
19
|
+
/** Register handler for 'getPageContext' - called by server */
|
|
20
|
+
getPageContext: (handler: () => Promise<PageContext | RpcError>) => void;
|
|
21
|
+
/** Register handler for 'getSelectedElements' - called by server */
|
|
22
|
+
getSelectedElements: (handler: () => Promise<ElementData[] | RpcError>) => void;
|
|
23
|
+
/** Register handler for 'triggerSelection' - called by server */
|
|
24
|
+
triggerSelection: (handler: (mode: "inspect" | "selector", selector: string | undefined, selectorType: "css" | "xpath" | undefined) => Promise<SelectionResult | RpcError>) => void;
|
|
25
|
+
/** Register handler for 'captureScreenshot' - called by server */
|
|
26
|
+
captureScreenshot: (handler: (type: "viewport" | "element", selector: string | undefined, format: "png" | "jpeg" | undefined, quality: number | undefined) => Promise<ScreenshotResult | RpcError>) => void;
|
|
27
|
+
/** Register handler for 'clearSelection' - called by server */
|
|
28
|
+
clearSelection: (handler: () => Promise<void | RpcError>) => void;
|
|
29
|
+
/** Register handler for 'injectCSS' - called by server */
|
|
30
|
+
injectCSS: (handler: (css: string) => Promise<InjectResult | RpcError>) => void;
|
|
31
|
+
/** Register handler for 'injectJS' - called by server */
|
|
32
|
+
injectJS: (handler: (code: string) => Promise<InjectResult | RpcError>) => void;
|
|
33
|
+
/** Register handler for 'getConsole' - called by server */
|
|
34
|
+
getConsole: (handler: (clear: boolean | undefined) => Promise<ConsoleEntry[] | RpcError>) => void;
|
|
35
|
+
/** Register handler for 'ping' - called by server */
|
|
36
|
+
ping: (handler: () => Promise<string | RpcError>) => void;
|
|
37
|
+
/** Register handler for RPC errors */
|
|
38
|
+
rpcError: (handler: (error: RpcError) => void) => void;
|
|
39
|
+
}
|
|
40
|
+
/** Methods to call server */
|
|
41
|
+
export interface RpcClientServer {
|
|
42
|
+
/** Call server's 'getSessions' method */
|
|
43
|
+
getSessions: (timeout?: number) => Promise<BrowserSession[] | RpcError>;
|
|
44
|
+
/** Call server's 'ping' method */
|
|
45
|
+
ping: (timeout?: number) => Promise<string | RpcError>;
|
|
46
|
+
}
|
|
47
|
+
/** Client RPC interface with ergonomic API. */
|
|
48
|
+
/** Use `.handle` to register handlers, `.server` to call server methods, and `.dispose()` to cleanup. */
|
|
49
|
+
export interface RpcClient {
|
|
50
|
+
/** Register handlers for calls from server */
|
|
51
|
+
readonly handle: RpcClientHandle;
|
|
52
|
+
/** Call server methods */
|
|
53
|
+
readonly server: RpcClientServer;
|
|
54
|
+
/** The underlying socket instance */
|
|
55
|
+
readonly socket: Socket;
|
|
56
|
+
/** Whether this instance has been disposed */
|
|
57
|
+
readonly disposed: boolean;
|
|
58
|
+
/** Cleanup all registered handlers. Call this when done (e.g., in onBeforeUnmount or useEffect cleanup). */
|
|
59
|
+
dispose(): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a client RPC instance.
|
|
63
|
+
*
|
|
64
|
+
* Usage:
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const client = createRpcClient(socket);
|
|
67
|
+
*
|
|
68
|
+
* // Register handlers for calls from server
|
|
69
|
+
* client.handle.getPageContext(async (data) => {
|
|
70
|
+
* // handle event
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* // Call server methods
|
|
74
|
+
* const result = await client.server.getSessions();
|
|
75
|
+
*
|
|
76
|
+
* // Cleanup when done
|
|
77
|
+
* client.dispose();
|
|
78
|
+
* ```
|
|
79
|
+
* @param socket The socket instance
|
|
80
|
+
* @returns RpcClient instance with .handle, .server, and .dispose()
|
|
81
|
+
*/
|
|
82
|
+
export declare function createRpcClient(socket: Socket): RpcClient;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Socket RPC Interface Definitions for InstantCode
|
|
3
|
+
*
|
|
4
|
+
* Server: WebSocket server running on port 7318
|
|
5
|
+
* Client: Browser annotator toolbar
|
|
6
|
+
*/
|
|
7
|
+
export interface PageContext {
|
|
8
|
+
url: string;
|
|
9
|
+
title: string;
|
|
10
|
+
selectionCount: number;
|
|
11
|
+
isInspecting: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ElementData {
|
|
14
|
+
index: number;
|
|
15
|
+
tagName: string;
|
|
16
|
+
xpath: string;
|
|
17
|
+
cssSelector: string;
|
|
18
|
+
textContent: string;
|
|
19
|
+
attributes: Record<string, string>;
|
|
20
|
+
imagePath?: string;
|
|
21
|
+
comment?: string;
|
|
22
|
+
computedStyles?: {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
fontSize: string;
|
|
26
|
+
fontFamily: string;
|
|
27
|
+
color?: string;
|
|
28
|
+
backgroundColor?: string;
|
|
29
|
+
display?: string;
|
|
30
|
+
position?: string;
|
|
31
|
+
};
|
|
32
|
+
componentData?: {
|
|
33
|
+
componentLocation: string;
|
|
34
|
+
componentName?: string;
|
|
35
|
+
framework?: 'vue' | 'react' | 'angular' | 'svelte' | 'vanilla';
|
|
36
|
+
};
|
|
37
|
+
children: ElementData[];
|
|
38
|
+
}
|
|
39
|
+
export interface ScreenshotResult {
|
|
40
|
+
success: boolean;
|
|
41
|
+
base64?: string;
|
|
42
|
+
filePath?: string;
|
|
43
|
+
error?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ConsoleEntry {
|
|
46
|
+
type: 'log' | 'info' | 'warn' | 'error' | 'debug';
|
|
47
|
+
args: string[];
|
|
48
|
+
timestamp: number;
|
|
49
|
+
}
|
|
50
|
+
export interface InjectResult {
|
|
51
|
+
success: boolean;
|
|
52
|
+
result?: unknown;
|
|
53
|
+
error?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface SelectionResult {
|
|
56
|
+
success: boolean;
|
|
57
|
+
count: number;
|
|
58
|
+
error?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface BrowserSession {
|
|
61
|
+
id: string;
|
|
62
|
+
url: string;
|
|
63
|
+
title: string;
|
|
64
|
+
connectedAt: number;
|
|
65
|
+
lastActivity: number;
|
|
66
|
+
}
|
|
67
|
+
export interface ServerFunctions {
|
|
68
|
+
getSessions: () => BrowserSession[];
|
|
69
|
+
ping: () => string;
|
|
70
|
+
}
|
|
71
|
+
export interface ClientFunctions {
|
|
72
|
+
getPageContext: () => PageContext;
|
|
73
|
+
getSelectedElements: () => ElementData[];
|
|
74
|
+
triggerSelection: (mode: 'inspect' | 'selector', selector?: string, selectorType?: 'css' | 'xpath') => SelectionResult;
|
|
75
|
+
captureScreenshot: (type: 'viewport' | 'element', selector?: string, format?: 'png' | 'jpeg', quality?: number) => ScreenshotResult;
|
|
76
|
+
clearSelection: () => void;
|
|
77
|
+
injectCSS: (css: string) => InjectResult;
|
|
78
|
+
injectJS: (code: string) => InjectResult;
|
|
79
|
+
getConsole: (clear?: boolean) => ConsoleEntry[];
|
|
80
|
+
ping: () => string;
|
|
81
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE - IT IS AUTO-GENERATED ⚠️
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated server RPC from define.ts
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* const server = createRpcServer(socket);
|
|
8
|
+
* server.handle.eventName(async (data) => { ... });
|
|
9
|
+
* server.client.methodName(args);
|
|
10
|
+
* server.dispose();
|
|
11
|
+
*
|
|
12
|
+
* To regenerate: bunx socketrpc-gen /Volumes/Data/Projects/instantcode/app/src/rpc/define.ts
|
|
13
|
+
*/
|
|
14
|
+
import type { Socket } from "socket.io";
|
|
15
|
+
import type { RpcError } from "./types.generated";
|
|
16
|
+
import type { BrowserSession, PageContext, ElementData, SelectionResult, ScreenshotResult, InjectResult, ConsoleEntry } from "./define";
|
|
17
|
+
/** Handler registration methods - implement these to handle calls from client */
|
|
18
|
+
export interface RpcServerHandle {
|
|
19
|
+
/** Register handler for 'getSessions' - called by client */
|
|
20
|
+
getSessions: (handler: () => Promise<BrowserSession[] | RpcError>) => void;
|
|
21
|
+
/** Register handler for 'ping' - called by client */
|
|
22
|
+
ping: (handler: () => Promise<string | RpcError>) => void;
|
|
23
|
+
/** Register handler for RPC errors */
|
|
24
|
+
rpcError: (handler: (error: RpcError) => void) => void;
|
|
25
|
+
}
|
|
26
|
+
/** Methods to call client */
|
|
27
|
+
export interface RpcServerClient {
|
|
28
|
+
/** Call client's 'getPageContext' method */
|
|
29
|
+
getPageContext: (timeout?: number) => Promise<PageContext | RpcError>;
|
|
30
|
+
/** Call client's 'getSelectedElements' method */
|
|
31
|
+
getSelectedElements: (timeout?: number) => Promise<ElementData[] | RpcError>;
|
|
32
|
+
/** Call client's 'triggerSelection' method */
|
|
33
|
+
triggerSelection: (mode: "inspect" | "selector", selector: string | undefined, selectorType: "css" | "xpath" | undefined, timeout?: number) => Promise<SelectionResult | RpcError>;
|
|
34
|
+
/** Call client's 'captureScreenshot' method */
|
|
35
|
+
captureScreenshot: (type: "viewport" | "element", selector: string | undefined, format: "png" | "jpeg" | undefined, quality: number | undefined, timeout?: number) => Promise<ScreenshotResult | RpcError>;
|
|
36
|
+
/** Call client's 'clearSelection' method */
|
|
37
|
+
clearSelection: () => void;
|
|
38
|
+
/** Call client's 'injectCSS' method */
|
|
39
|
+
injectCSS: (css: string, timeout?: number) => Promise<InjectResult | RpcError>;
|
|
40
|
+
/** Call client's 'injectJS' method */
|
|
41
|
+
injectJS: (code: string, timeout?: number) => Promise<InjectResult | RpcError>;
|
|
42
|
+
/** Call client's 'getConsole' method */
|
|
43
|
+
getConsole: (clear: boolean | undefined, timeout?: number) => Promise<ConsoleEntry[] | RpcError>;
|
|
44
|
+
/** Call client's 'ping' method */
|
|
45
|
+
ping: (timeout?: number) => Promise<string | RpcError>;
|
|
46
|
+
}
|
|
47
|
+
/** Server RPC interface with ergonomic API. */
|
|
48
|
+
/** Use `.handle` to register handlers, `.client` to call client methods, and `.dispose()` to cleanup. */
|
|
49
|
+
export interface RpcServer {
|
|
50
|
+
/** Register handlers for calls from client */
|
|
51
|
+
readonly handle: RpcServerHandle;
|
|
52
|
+
/** Call client methods */
|
|
53
|
+
readonly client: RpcServerClient;
|
|
54
|
+
/** The underlying socket instance */
|
|
55
|
+
readonly socket: Socket;
|
|
56
|
+
/** Whether this instance has been disposed */
|
|
57
|
+
readonly disposed: boolean;
|
|
58
|
+
/** Cleanup all registered handlers. Call this when done (e.g., in onBeforeUnmount or useEffect cleanup). */
|
|
59
|
+
dispose(): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a server RPC instance.
|
|
63
|
+
*
|
|
64
|
+
* Usage:
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const server = createRpcServer(socket);
|
|
67
|
+
*
|
|
68
|
+
* // Register handlers for calls from client
|
|
69
|
+
* server.handle.getSessions(async (data) => {
|
|
70
|
+
* // handle event
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* // Call client methods
|
|
74
|
+
* const result = await server.client.getPageContext();
|
|
75
|
+
*
|
|
76
|
+
* // Cleanup when done
|
|
77
|
+
* server.dispose();
|
|
78
|
+
* ```
|
|
79
|
+
* @param socket The socket instance
|
|
80
|
+
* @returns RpcServer instance with .handle, .client, and .dispose()
|
|
81
|
+
*/
|
|
82
|
+
export declare function createRpcServer(socket: Socket): RpcServer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE - IT IS AUTO-GENERATED ⚠️
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated types for the RPC package
|
|
5
|
+
*
|
|
6
|
+
* To regenerate this file, run:
|
|
7
|
+
* bunx socketrpc-gen /Volumes/Data/Projects/instantcode/app/src/rpc/define.ts
|
|
8
|
+
*/
|
|
9
|
+
/** Function to unsubscribe from an event listener. Call this to clean up the listener. */
|
|
10
|
+
export type UnsubscribeFunction = () => void;
|
|
11
|
+
/** Represents an error that occurred during an RPC call. */
|
|
12
|
+
export interface RpcError {
|
|
13
|
+
/** The error message. */
|
|
14
|
+
message: string;
|
|
15
|
+
/** The error code. */
|
|
16
|
+
code: string;
|
|
17
|
+
/** The error data. */
|
|
18
|
+
data: any;
|
|
19
|
+
}
|
|
20
|
+
/** Type guard to check if an object is an RpcError. */
|
|
21
|
+
export declare function isRpcError(obj: any): obj is RpcError;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const WSMessageSchema: z.ZodObject<{
|
|
3
|
+
type: z.ZodEnum<{
|
|
4
|
+
request: "request";
|
|
5
|
+
response: "response";
|
|
6
|
+
event: "event";
|
|
7
|
+
}>;
|
|
8
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
action: z.ZodString;
|
|
10
|
+
payload: z.ZodOptional<z.ZodUnknown>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type WSMessage = z.infer<typeof WSMessageSchema>;
|
|
13
|
+
export declare const WSActionSchema: z.ZodEnum<{
|
|
14
|
+
ping: "ping";
|
|
15
|
+
get_page_context: "get_page_context";
|
|
16
|
+
get_selected_elements: "get_selected_elements";
|
|
17
|
+
trigger_selection: "trigger_selection";
|
|
18
|
+
select_by_selector: "select_by_selector";
|
|
19
|
+
capture_screenshot: "capture_screenshot";
|
|
20
|
+
clear_selection: "clear_selection";
|
|
21
|
+
}>;
|
|
22
|
+
export type WSAction = z.infer<typeof WSActionSchema>;
|
|
23
|
+
export declare const PageContextSchema: z.ZodObject<{
|
|
24
|
+
url: z.ZodString;
|
|
25
|
+
title: z.ZodString;
|
|
26
|
+
selectionCount: z.ZodNumber;
|
|
27
|
+
isInspecting: z.ZodBoolean;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type PageContext = z.infer<typeof PageContextSchema>;
|
|
30
|
+
export declare const ScreenshotOptionsSchema: z.ZodObject<{
|
|
31
|
+
type: z.ZodDefault<z.ZodEnum<{
|
|
32
|
+
viewport: "viewport";
|
|
33
|
+
element: "element";
|
|
34
|
+
}>>;
|
|
35
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
36
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
37
|
+
png: "png";
|
|
38
|
+
jpeg: "jpeg";
|
|
39
|
+
}>>;
|
|
40
|
+
quality: z.ZodDefault<z.ZodNumber>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export type ScreenshotOptions = z.infer<typeof ScreenshotOptionsSchema>;
|
|
43
|
+
export declare const SelectionTriggerSchema: z.ZodObject<{
|
|
44
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
45
|
+
inspect: "inspect";
|
|
46
|
+
selector: "selector";
|
|
47
|
+
}>>;
|
|
48
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
49
|
+
selectorType: z.ZodDefault<z.ZodEnum<{
|
|
50
|
+
css: "css";
|
|
51
|
+
xpath: "xpath";
|
|
52
|
+
}>>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export type SelectionTrigger = z.infer<typeof SelectionTriggerSchema>;
|
|
55
|
+
export declare const BrowserSessionSchema: z.ZodObject<{
|
|
56
|
+
id: z.ZodString;
|
|
57
|
+
url: z.ZodString;
|
|
58
|
+
title: z.ZodString;
|
|
59
|
+
connectedAt: z.ZodNumber;
|
|
60
|
+
lastActivity: z.ZodNumber;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type BrowserSession = z.infer<typeof BrowserSessionSchema>;
|
|
63
|
+
declare const ElementDataBaseSchema: z.ZodObject<{
|
|
64
|
+
index: z.ZodNumber;
|
|
65
|
+
tagName: z.ZodString;
|
|
66
|
+
xpath: z.ZodString;
|
|
67
|
+
cssSelector: z.ZodString;
|
|
68
|
+
textContent: z.ZodString;
|
|
69
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
70
|
+
imagePath: z.ZodOptional<z.ZodString>;
|
|
71
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
72
|
+
computedStyles: z.ZodOptional<z.ZodObject<{
|
|
73
|
+
width: z.ZodNumber;
|
|
74
|
+
height: z.ZodNumber;
|
|
75
|
+
fontSize: z.ZodString;
|
|
76
|
+
fontFamily: z.ZodString;
|
|
77
|
+
color: z.ZodOptional<z.ZodString>;
|
|
78
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
79
|
+
display: z.ZodOptional<z.ZodString>;
|
|
80
|
+
position: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>>;
|
|
82
|
+
componentData: z.ZodOptional<z.ZodObject<{
|
|
83
|
+
componentLocation: z.ZodString;
|
|
84
|
+
componentName: z.ZodOptional<z.ZodString>;
|
|
85
|
+
elementLocation: z.ZodOptional<z.ZodObject<{
|
|
86
|
+
file: z.ZodString;
|
|
87
|
+
line: z.ZodNumber;
|
|
88
|
+
column: z.ZodNumber;
|
|
89
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
endColumn: z.ZodOptional<z.ZodNumber>;
|
|
91
|
+
source: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
framework: z.ZodOptional<z.ZodEnum<{
|
|
94
|
+
vue: "vue";
|
|
95
|
+
react: "react";
|
|
96
|
+
angular: "angular";
|
|
97
|
+
svelte: "svelte";
|
|
98
|
+
vanilla: "vanilla";
|
|
99
|
+
}>>;
|
|
100
|
+
sourceMap: z.ZodOptional<z.ZodObject<{
|
|
101
|
+
originalLine: z.ZodNumber;
|
|
102
|
+
originalColumn: z.ZodNumber;
|
|
103
|
+
originalSource: z.ZodString;
|
|
104
|
+
originalName: z.ZodOptional<z.ZodString>;
|
|
105
|
+
}, z.core.$strip>>;
|
|
106
|
+
sourceHierarchy: z.ZodOptional<z.ZodString>;
|
|
107
|
+
}, z.core.$strip>>;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
type ElementDataType = z.infer<typeof ElementDataBaseSchema> & {
|
|
110
|
+
children: ElementDataType[];
|
|
111
|
+
};
|
|
112
|
+
export declare const ElementDataSchema: z.ZodType<ElementDataType>;
|
|
113
|
+
export declare const PageInfoSchema: z.ZodObject<{
|
|
114
|
+
url: z.ZodString;
|
|
115
|
+
title: z.ZodString;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
export type ElementData = z.infer<typeof ElementDataSchema>;
|
|
118
|
+
export type PageInfo = z.infer<typeof PageInfoSchema>;
|
|
119
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ElementData, PageInfo, } from './schemas';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CreateExpressContextOptions } from '@trpc/server/adapters/express';
|
|
2
|
+
import type { CreateWSSContextFnOptions } from '@trpc/server/adapters/ws';
|
|
3
|
+
/**
|
|
4
|
+
* Inner context - always available in procedures
|
|
5
|
+
* Used for shared data like database connections
|
|
6
|
+
*/
|
|
7
|
+
export declare function createContextInner(verbose?: boolean): Promise<{
|
|
8
|
+
verbose: boolean;
|
|
9
|
+
logger: import("../utils/logger").Logger;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Context for Express HTTP requests
|
|
13
|
+
*/
|
|
14
|
+
export declare function createContext(opts: CreateExpressContextOptions, verbose?: boolean): Promise<{
|
|
15
|
+
req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
16
|
+
res: import("express").Response<any, Record<string, any>>;
|
|
17
|
+
verbose: boolean;
|
|
18
|
+
logger: import("../utils/logger").Logger;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Context for WebSocket connections
|
|
22
|
+
*/
|
|
23
|
+
export declare function createWSSContext(opts: CreateWSSContextFnOptions, verbose?: boolean): Promise<{
|
|
24
|
+
req: import("http").IncomingMessage;
|
|
25
|
+
verbose: boolean;
|
|
26
|
+
logger: import("../utils/logger").Logger;
|
|
27
|
+
}>;
|
|
28
|
+
export type Context = Awaited<ReturnType<typeof createContextInner>>;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
export declare const router: import("@trpc/server").TRPCRouterBuilder<{
|
|
2
|
+
ctx: {
|
|
3
|
+
verbose: boolean;
|
|
4
|
+
logger: import("../utils/logger").Logger;
|
|
5
|
+
};
|
|
6
|
+
meta: object;
|
|
7
|
+
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
8
|
+
transformer: true;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const publicProcedure: import("@trpc/server").TRPCProcedureBuilder<{
|
|
11
|
+
verbose: boolean;
|
|
12
|
+
logger: import("../utils/logger").Logger;
|
|
13
|
+
}, object, object, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
|
|
14
|
+
export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
15
|
+
ctx: {
|
|
16
|
+
verbose: boolean;
|
|
17
|
+
logger: import("../utils/logger").Logger;
|
|
18
|
+
};
|
|
19
|
+
meta: object;
|
|
20
|
+
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
21
|
+
transformer: true;
|
|
22
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
23
|
+
health: import("@trpc/server").TRPCQueryProcedure<{
|
|
24
|
+
input: void;
|
|
25
|
+
output: {
|
|
26
|
+
status: string;
|
|
27
|
+
timestamp: string;
|
|
28
|
+
};
|
|
29
|
+
meta: object;
|
|
30
|
+
}>;
|
|
31
|
+
newChat: import("@trpc/server").TRPCMutationProcedure<{
|
|
32
|
+
input: void;
|
|
33
|
+
output: {
|
|
34
|
+
success: boolean;
|
|
35
|
+
};
|
|
36
|
+
meta: object;
|
|
37
|
+
}>;
|
|
38
|
+
sendMessage: import("@trpc/server").TRPCSubscriptionProcedure<{
|
|
39
|
+
input: {
|
|
40
|
+
userPrompt: string;
|
|
41
|
+
selectedElements: {
|
|
42
|
+
index: number;
|
|
43
|
+
tagName: string;
|
|
44
|
+
xpath: string;
|
|
45
|
+
cssSelector: string;
|
|
46
|
+
textContent: string;
|
|
47
|
+
attributes: Record<string, string>;
|
|
48
|
+
children: any[];
|
|
49
|
+
imagePath?: string | undefined;
|
|
50
|
+
computedStyles?: {
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
fontSize: string;
|
|
54
|
+
fontFamily: string;
|
|
55
|
+
color?: string | undefined;
|
|
56
|
+
backgroundColor?: string | undefined;
|
|
57
|
+
display?: string | undefined;
|
|
58
|
+
position?: string | undefined;
|
|
59
|
+
} | undefined;
|
|
60
|
+
componentData?: {
|
|
61
|
+
componentLocation: string;
|
|
62
|
+
componentName?: string | undefined;
|
|
63
|
+
elementLocation?: {
|
|
64
|
+
file: string;
|
|
65
|
+
line: number;
|
|
66
|
+
column: number;
|
|
67
|
+
endLine?: number | undefined;
|
|
68
|
+
endColumn?: number | undefined;
|
|
69
|
+
source?: string | undefined;
|
|
70
|
+
} | undefined;
|
|
71
|
+
framework?: "vue" | "react" | "angular" | "svelte" | "vanilla" | undefined;
|
|
72
|
+
sourceMap?: {
|
|
73
|
+
originalLine: number;
|
|
74
|
+
originalColumn: number;
|
|
75
|
+
originalSource: string;
|
|
76
|
+
originalName?: string | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
sourceHierarchy?: string | undefined;
|
|
79
|
+
} | undefined;
|
|
80
|
+
}[];
|
|
81
|
+
pageInfo: {
|
|
82
|
+
url: string;
|
|
83
|
+
title: string;
|
|
84
|
+
};
|
|
85
|
+
cwd?: string | undefined;
|
|
86
|
+
sessionId?: string | undefined;
|
|
87
|
+
consoleErrors?: string[] | undefined;
|
|
88
|
+
consoleWarnings?: string[] | undefined;
|
|
89
|
+
consoleInfo?: string[] | undefined;
|
|
90
|
+
};
|
|
91
|
+
output: AsyncIterable<{
|
|
92
|
+
type: "system";
|
|
93
|
+
subtype: "init";
|
|
94
|
+
apiKeySource: "user" | "project" | "org" | "temporary";
|
|
95
|
+
cwd: string;
|
|
96
|
+
session_id: string;
|
|
97
|
+
tools: string[];
|
|
98
|
+
mcp_servers: {
|
|
99
|
+
name: string;
|
|
100
|
+
status: string;
|
|
101
|
+
}[];
|
|
102
|
+
model: string;
|
|
103
|
+
permissionMode: "default" | "acceptEdits" | "bypassPermissions" | "plan";
|
|
104
|
+
slash_commands: string[];
|
|
105
|
+
} | {
|
|
106
|
+
type: "assistant";
|
|
107
|
+
message: {
|
|
108
|
+
id: string;
|
|
109
|
+
type: "message";
|
|
110
|
+
role: "assistant";
|
|
111
|
+
model: string;
|
|
112
|
+
content: {
|
|
113
|
+
type: string;
|
|
114
|
+
text?: string | undefined;
|
|
115
|
+
id?: string | undefined;
|
|
116
|
+
name?: string | undefined;
|
|
117
|
+
input?: Record<string, unknown> | undefined;
|
|
118
|
+
}[];
|
|
119
|
+
stop_reason?: string | null | undefined;
|
|
120
|
+
stop_sequence?: string | null | undefined;
|
|
121
|
+
usage?: {
|
|
122
|
+
input_tokens: number;
|
|
123
|
+
output_tokens: number;
|
|
124
|
+
cache_creation_input_tokens?: number | undefined;
|
|
125
|
+
cache_read_input_tokens?: number | undefined;
|
|
126
|
+
} | undefined;
|
|
127
|
+
};
|
|
128
|
+
parent_tool_use_id: string | null;
|
|
129
|
+
session_id: string;
|
|
130
|
+
} | {
|
|
131
|
+
type: "user";
|
|
132
|
+
message: {
|
|
133
|
+
role: "user";
|
|
134
|
+
content: {
|
|
135
|
+
type: string;
|
|
136
|
+
content?: string | undefined;
|
|
137
|
+
tool_use_id?: string | undefined;
|
|
138
|
+
}[];
|
|
139
|
+
};
|
|
140
|
+
parent_tool_use_id: string | null;
|
|
141
|
+
session_id: string;
|
|
142
|
+
} | {
|
|
143
|
+
type: "result";
|
|
144
|
+
subtype: "success";
|
|
145
|
+
duration_ms: number;
|
|
146
|
+
duration_api_ms: number;
|
|
147
|
+
is_error: false;
|
|
148
|
+
num_turns: number;
|
|
149
|
+
result: string;
|
|
150
|
+
session_id: string;
|
|
151
|
+
total_cost_usd: number;
|
|
152
|
+
usage: {
|
|
153
|
+
input_tokens: number;
|
|
154
|
+
cache_creation_input_tokens: number;
|
|
155
|
+
cache_read_input_tokens: number;
|
|
156
|
+
output_tokens: number;
|
|
157
|
+
};
|
|
158
|
+
permission_denials: {
|
|
159
|
+
tool_name: string;
|
|
160
|
+
tool_use_id: string;
|
|
161
|
+
tool_input: Record<string, unknown>;
|
|
162
|
+
}[];
|
|
163
|
+
} | {
|
|
164
|
+
type: "result";
|
|
165
|
+
subtype: "error_max_turns" | "error_during_execution";
|
|
166
|
+
duration_ms: number;
|
|
167
|
+
duration_api_ms: number;
|
|
168
|
+
is_error: true;
|
|
169
|
+
num_turns: number;
|
|
170
|
+
session_id: string;
|
|
171
|
+
total_cost_usd: number;
|
|
172
|
+
usage: {
|
|
173
|
+
input_tokens: number;
|
|
174
|
+
cache_creation_input_tokens: number;
|
|
175
|
+
cache_read_input_tokens: number;
|
|
176
|
+
output_tokens: number;
|
|
177
|
+
};
|
|
178
|
+
permission_denials: {
|
|
179
|
+
tool_name: string;
|
|
180
|
+
tool_use_id: string;
|
|
181
|
+
tool_input: Record<string, unknown>;
|
|
182
|
+
}[];
|
|
183
|
+
} | {
|
|
184
|
+
type: "result";
|
|
185
|
+
subtype: "error";
|
|
186
|
+
is_error: true;
|
|
187
|
+
duration_ms: number;
|
|
188
|
+
duration_api_ms: number;
|
|
189
|
+
result: string;
|
|
190
|
+
session_id?: string | undefined;
|
|
191
|
+
}, void, any>;
|
|
192
|
+
meta: object;
|
|
193
|
+
}>;
|
|
194
|
+
}>>;
|
|
195
|
+
export type AppRouter = typeof appRouter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Express } from 'express';
|
|
2
|
+
import type { Server } from 'node:http';
|
|
3
|
+
import { WebSocketServer } from 'ws';
|
|
4
|
+
export interface ServerInstance {
|
|
5
|
+
app: Express;
|
|
6
|
+
server: Server;
|
|
7
|
+
wss: WebSocketServer;
|
|
8
|
+
port: number;
|
|
9
|
+
listenAddress: string;
|
|
10
|
+
publicAddress: string;
|
|
11
|
+
verbose: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function startServer(port: number, listenAddress: string, publicAddress: string, verbose?: boolean): Promise<ServerInstance>;
|
|
14
|
+
export declare function stopServer(serverInstance: ServerInstance): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side logging utility
|
|
3
|
+
*/
|
|
4
|
+
export interface Logger {
|
|
5
|
+
log(...args: any[]): void;
|
|
6
|
+
info(...args: any[]): void;
|
|
7
|
+
warn(...args: any[]): void;
|
|
8
|
+
error(...args: any[]): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createLogger(verbose: boolean): Logger;
|
|
11
|
+
export declare function createSilentLogger(): Logger;
|