vite-plugin-ai-annotator 1.14.13 → 1.14.16

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "vite-plugin-ai-annotator",
3
- "version": "1.14.13",
3
+ "version": "1.14.16",
4
4
  "description": "AI-powered element annotator for Vite - Pick elements and get instant AI code modifications",
5
5
  "type": "module",
6
6
  "main": "dist/vite-plugin.js",
7
7
  "types": "dist/vite-plugin.d.ts",
8
8
  "bin": {
9
- "vite-plugin-ai-annotator": "./dist/index.cjs"
9
+ "vite-plugin-ai-annotator": "dist/index.cjs"
10
10
  },
11
11
  "exports": {
12
12
  ".": {
@@ -1,10 +0,0 @@
1
- export interface AutoSetupMcpOptions {
2
- projectRoot: string;
3
- serverUrl: string;
4
- verbose?: boolean;
5
- }
6
- export interface AutoSetupResult {
7
- updated: string[];
8
- alreadyConfigured: string[];
9
- }
10
- export declare function autoSetupMcp(options: AutoSetupMcpOptions): AutoSetupResult;
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * InstantCode MCP Server
4
- *
5
- * Provides MCP tools for Claude Desktop/Claude Code to interact with
6
- * browser elements through the InstantCode inspector.
7
- */
8
- export {};
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * AI Annotator MCP CLI
4
- *
5
- * Stdio-based MCP server that connects to AI Annotator server via socket.io
6
- * and forwards tool calls to browser sessions.
7
- *
8
- * Usage:
9
- * node mcp-stdio.js [--server <url>]
10
- *
11
- * Options:
12
- * --server, -s Server URL (default: http://localhost:7318)
13
- * Can also use AI_ANNOTATOR_SERVER env var
14
- */
15
- export {};
@@ -1,25 +0,0 @@
1
- /**
2
- * Shared MCP tool definitions for AI Annotator
3
- *
4
- * Registers all 9 MCP tools on a McpServer instance.
5
- * Used by both ws-server.ts (HTTP MCP) and mcp-stdio.ts (stdio MCP).
6
- */
7
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
8
- import type { BrowserSession, PageContext, ElementData, SelectionResult, ScreenshotResult, InjectResult, ConsoleEntry } from './rpc/define';
9
- import type { RpcError } from './rpc/types.generated';
10
- export interface AnnotatorConnection {
11
- sessionId: string;
12
- getPageContext(timeout?: number): Promise<PageContext | RpcError>;
13
- getSelectedElements(timeout?: number): Promise<ElementData[] | RpcError>;
14
- triggerSelection(mode: 'inspect' | 'selector', selector?: string, selectorType?: 'css' | 'xpath', timeout?: number): Promise<SelectionResult | RpcError>;
15
- captureScreenshot(type: 'viewport' | 'element', selector?: string, quality?: number, timeout?: number): Promise<ScreenshotResult | RpcError>;
16
- clearSelection(): void;
17
- injectCSS(css: string, timeout?: number): Promise<InjectResult | RpcError>;
18
- injectJS(code: string, timeout?: number): Promise<InjectResult | RpcError>;
19
- getConsole(clear?: boolean, timeout?: number): Promise<ConsoleEntry[] | RpcError>;
20
- }
21
- export type GetConnection = (sessionId?: string) => AnnotatorConnection | {
22
- error: string;
23
- };
24
- export type ListSessions = () => Promise<BrowserSession[]>;
25
- export declare function registerMcpTools(mcp: McpServer, listSessions: ListSessions, getConnection: GetConnection): void;
@@ -1,119 +0,0 @@
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 {};
@@ -1 +0,0 @@
1
- export type { ElementData, PageInfo, } from './schemas';
@@ -1,28 +0,0 @@
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>>;
@@ -1,195 +0,0 @@
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;
@@ -1,14 +0,0 @@
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>;
@@ -1,7 +0,0 @@
1
- /**
2
- * HTML utilities for safe text handling and string hashing
3
- */
4
- export declare class HtmlUtils {
5
- static escapeHtml(text: string): string;
6
- static hashString(content: string): string;
7
- }
@@ -1,72 +0,0 @@
1
- /**
2
- * Source Map utilities for mapping runtime elements back to source code
3
- */
4
- export interface SourceMapPosition {
5
- line: number;
6
- column: number;
7
- source?: string;
8
- name?: string;
9
- }
10
- export interface SourceMapInfo {
11
- file: string;
12
- line: number;
13
- column: number;
14
- endLine?: number;
15
- endColumn?: number;
16
- originalSource?: string;
17
- sourcesContent?: string[];
18
- }
19
- /**
20
- * Basic source map consumer for parsing VLQ-encoded mappings
21
- * Note: This is a simplified implementation. For production use,
22
- * consider using the 'source-map' library for full compatibility.
23
- */
24
- export declare class BasicSourceMapConsumer {
25
- private sources;
26
- private sourcesContent?;
27
- constructor(sourceMap: any);
28
- /**
29
- * Find original position for generated position
30
- * This is a simplified implementation that looks for approximate mappings
31
- */
32
- originalPositionFor(line: number, column: number): SourceMapPosition | null;
33
- /**
34
- * Get source content for a given source file
35
- */
36
- sourceContentFor(source: string): string | null;
37
- /**
38
- * Get all available sources
39
- */
40
- getSources(): string[];
41
- }
42
- /**
43
- * Attempt to find and parse source maps from various sources
44
- */
45
- export declare class SourceMapResolver {
46
- private sourceMapCache;
47
- /**
48
- * Try to find source map for a given file URL
49
- */
50
- findSourceMapForFile(fileUrl: string): Promise<BasicSourceMapConsumer | null>;
51
- /**
52
- * Resolve original position from generated position using source maps
53
- */
54
- resolvePosition(fileUrl: string, line: number, column: number): Promise<SourceMapPosition | null>;
55
- /**
56
- * Get enhanced location info by combining runtime data with source maps
57
- */
58
- getEnhancedLocationInfo(fileUrl: string, line: number, column: number): Promise<SourceMapInfo | null>;
59
- /**
60
- * Clear the source map cache
61
- */
62
- clearCache(): void;
63
- }
64
- export declare const sourceMapResolver: SourceMapResolver;
65
- /**
66
- * Helper function to extract source location from browser stack traces
67
- */
68
- export declare function extractLocationFromStackTrace(error: Error): {
69
- file: string;
70
- line: number;
71
- column: number;
72
- } | null;