webclaw-shared 0.1.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/LICENSE +21 -0
- package/dist/__tests__/message.test.d.ts +2 -0
- package/dist/__tests__/message.test.d.ts.map +1 -0
- package/dist/__tests__/message.test.js +83 -0
- package/dist/__tests__/message.test.js.map +1 -0
- package/dist/__tests__/ref.test.d.ts +2 -0
- package/dist/__tests__/ref.test.d.ts.map +1 -0
- package/dist/__tests__/ref.test.js +68 -0
- package/dist/__tests__/ref.test.js.map +1 -0
- package/dist/__tests__/schemas.test.d.ts +2 -0
- package/dist/__tests__/schemas.test.d.ts.map +1 -0
- package/dist/__tests__/schemas.test.js +171 -0
- package/dist/__tests__/schemas.test.js.map +1 -0
- package/dist/__tests__/snapshot-formatter.test.d.ts +2 -0
- package/dist/__tests__/snapshot-formatter.test.d.ts.map +1 -0
- package/dist/__tests__/snapshot-formatter.test.js +73 -0
- package/dist/__tests__/snapshot-formatter.test.js.map +1 -0
- package/dist/constants.d.ts +18 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +18 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/message.d.ts +15 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +49 -0
- package/dist/message.js.map +1 -0
- package/dist/ref.d.ts +18 -0
- package/dist/ref.d.ts.map +1 -0
- package/dist/ref.js +40 -0
- package/dist/ref.js.map +1 -0
- package/dist/schemas.d.ts +151 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +63 -0
- package/dist/schemas.js.map +1 -0
- package/dist/snapshot-formatter.d.ts +12 -0
- package/dist/snapshot-formatter.d.ts.map +1 -0
- package/dist/snapshot-formatter.js +50 -0
- package/dist/snapshot-formatter.js.map +1 -0
- package/dist/types/bridge.d.ts +44 -0
- package/dist/types/bridge.d.ts.map +1 -0
- package/dist/types/bridge.js +6 -0
- package/dist/types/bridge.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mcp-tools.d.ts +56 -0
- package/dist/types/mcp-tools.d.ts.map +1 -0
- package/dist/types/mcp-tools.js +5 -0
- package/dist/types/mcp-tools.js.map +1 -0
- package/dist/types/snapshot.d.ts +32 -0
- package/dist/types/snapshot.d.ts.map +1 -0
- package/dist/types/snapshot.js +5 -0
- package/dist/types/snapshot.js.map +1 -0
- package/dist/types/webmcp.d.ts +39 -0
- package/dist/types/webmcp.d.ts.map +1 -0
- package/dist/types/webmcp.js +6 -0
- package/dist/types/webmcp.js.map +1 -0
- package/package.json +37 -0
package/dist/ref.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ref encoding utilities for compact snapshot element references.
|
|
3
|
+
*
|
|
4
|
+
* Each interactive element in a snapshot is assigned a unique @ref like @e1, @e2, etc.
|
|
5
|
+
* Refs are scoped to a single snapshot and reset on each new snapshot.
|
|
6
|
+
*/
|
|
7
|
+
/** Generate a ref string from a numeric index (1-based) */
|
|
8
|
+
export declare function encodeRef(index: number): string;
|
|
9
|
+
/** Extract the numeric index from a ref string, or null if invalid */
|
|
10
|
+
export declare function decodeRef(ref: string): number | null;
|
|
11
|
+
/** Check if a string is a valid @ref */
|
|
12
|
+
export declare function isValidRef(ref: string): boolean;
|
|
13
|
+
/** Create a ref counter for generating sequential refs within a snapshot */
|
|
14
|
+
export declare function createRefCounter(): {
|
|
15
|
+
next(): string;
|
|
16
|
+
count(): number;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../src/ref.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIpD;AAED,wCAAwC;AACxC,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,IAAI;IAAE,IAAI,IAAI,MAAM,CAAC;IAAC,KAAK,IAAI,MAAM,CAAA;CAAE,CAWtE"}
|
package/dist/ref.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ref encoding utilities for compact snapshot element references.
|
|
3
|
+
*
|
|
4
|
+
* Each interactive element in a snapshot is assigned a unique @ref like @e1, @e2, etc.
|
|
5
|
+
* Refs are scoped to a single snapshot and reset on each new snapshot.
|
|
6
|
+
*/
|
|
7
|
+
const REF_PREFIX = '@e';
|
|
8
|
+
const REF_PATTERN = /^@e(\d+)$/;
|
|
9
|
+
/** Generate a ref string from a numeric index (1-based) */
|
|
10
|
+
export function encodeRef(index) {
|
|
11
|
+
if (index < 1) {
|
|
12
|
+
throw new Error(`Ref index must be >= 1, got ${index}`);
|
|
13
|
+
}
|
|
14
|
+
return `${REF_PREFIX}${index}`;
|
|
15
|
+
}
|
|
16
|
+
/** Extract the numeric index from a ref string, or null if invalid */
|
|
17
|
+
export function decodeRef(ref) {
|
|
18
|
+
const match = ref.match(REF_PATTERN);
|
|
19
|
+
if (!match)
|
|
20
|
+
return null;
|
|
21
|
+
return parseInt(match[1], 10);
|
|
22
|
+
}
|
|
23
|
+
/** Check if a string is a valid @ref */
|
|
24
|
+
export function isValidRef(ref) {
|
|
25
|
+
return REF_PATTERN.test(ref);
|
|
26
|
+
}
|
|
27
|
+
/** Create a ref counter for generating sequential refs within a snapshot */
|
|
28
|
+
export function createRefCounter() {
|
|
29
|
+
let counter = 0;
|
|
30
|
+
return {
|
|
31
|
+
next() {
|
|
32
|
+
counter++;
|
|
33
|
+
return encodeRef(counter);
|
|
34
|
+
},
|
|
35
|
+
count() {
|
|
36
|
+
return counter;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=ref.js.map
|
package/dist/ref.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref.js","sourceRoot":"","sources":["../src/ref.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,WAAW,GAAG,WAAW,CAAC;AAEhC,2DAA2D;AAC3D,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,GAAG,UAAU,GAAG,KAAK,EAAE,CAAC;AACjC,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACrC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB;IAC9B,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,OAAO;QACL,IAAI;YACF,OAAO,EAAE,CAAC;YACV,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;QACD,KAAK;YACH,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for message validation.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export declare const bridgeMessageSchema: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
type: z.ZodEnum<["request", "response", "ack", "error"]>;
|
|
8
|
+
method: z.ZodString;
|
|
9
|
+
payload: z.ZodUnknown;
|
|
10
|
+
timestamp: z.ZodNumber;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
type: "request" | "response" | "ack" | "error";
|
|
13
|
+
id: string;
|
|
14
|
+
method: string;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
payload?: unknown;
|
|
17
|
+
}, {
|
|
18
|
+
type: "request" | "response" | "ack" | "error";
|
|
19
|
+
id: string;
|
|
20
|
+
method: string;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
payload?: unknown;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const bridgeErrorPayloadSchema: z.ZodObject<{
|
|
25
|
+
code: z.ZodString;
|
|
26
|
+
message: z.ZodString;
|
|
27
|
+
details: z.ZodOptional<z.ZodUnknown>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
code: string;
|
|
30
|
+
message: string;
|
|
31
|
+
details?: unknown;
|
|
32
|
+
}, {
|
|
33
|
+
code: string;
|
|
34
|
+
message: string;
|
|
35
|
+
details?: unknown;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const chunkedMessageSchema: z.ZodObject<{
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
chunkIndex: z.ZodNumber;
|
|
40
|
+
totalChunks: z.ZodNumber;
|
|
41
|
+
data: z.ZodString;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
id: string;
|
|
44
|
+
chunkIndex: number;
|
|
45
|
+
totalChunks: number;
|
|
46
|
+
data: string;
|
|
47
|
+
}, {
|
|
48
|
+
id: string;
|
|
49
|
+
chunkIndex: number;
|
|
50
|
+
totalChunks: number;
|
|
51
|
+
data: string;
|
|
52
|
+
}>;
|
|
53
|
+
export declare const navigateToSchema: z.ZodObject<{
|
|
54
|
+
url: z.ZodString;
|
|
55
|
+
tabId: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
url: string;
|
|
58
|
+
tabId?: number | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
url: string;
|
|
61
|
+
tabId?: number | undefined;
|
|
62
|
+
}>;
|
|
63
|
+
export declare const pageSnapshotSchema: z.ZodObject<{
|
|
64
|
+
tabId: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
tabId?: number | undefined;
|
|
68
|
+
maxTokens?: number | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
tabId?: number | undefined;
|
|
71
|
+
maxTokens?: number | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
export declare const clickSchema: z.ZodObject<{
|
|
74
|
+
ref: z.ZodString;
|
|
75
|
+
snapshotId: z.ZodString;
|
|
76
|
+
tabId: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
ref: string;
|
|
79
|
+
snapshotId: string;
|
|
80
|
+
tabId?: number | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
ref: string;
|
|
83
|
+
snapshotId: string;
|
|
84
|
+
tabId?: number | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
export declare const typeTextSchema: z.ZodObject<{
|
|
87
|
+
ref: z.ZodString;
|
|
88
|
+
text: z.ZodString;
|
|
89
|
+
snapshotId: z.ZodString;
|
|
90
|
+
clearFirst: z.ZodOptional<z.ZodBoolean>;
|
|
91
|
+
tabId: z.ZodOptional<z.ZodNumber>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
ref: string;
|
|
94
|
+
snapshotId: string;
|
|
95
|
+
text: string;
|
|
96
|
+
tabId?: number | undefined;
|
|
97
|
+
clearFirst?: boolean | undefined;
|
|
98
|
+
}, {
|
|
99
|
+
ref: string;
|
|
100
|
+
snapshotId: string;
|
|
101
|
+
text: string;
|
|
102
|
+
tabId?: number | undefined;
|
|
103
|
+
clearFirst?: boolean | undefined;
|
|
104
|
+
}>;
|
|
105
|
+
export declare const selectOptionSchema: z.ZodObject<{
|
|
106
|
+
ref: z.ZodString;
|
|
107
|
+
value: z.ZodString;
|
|
108
|
+
snapshotId: z.ZodString;
|
|
109
|
+
tabId: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
}, "strip", z.ZodTypeAny, {
|
|
111
|
+
value: string;
|
|
112
|
+
ref: string;
|
|
113
|
+
snapshotId: string;
|
|
114
|
+
tabId?: number | undefined;
|
|
115
|
+
}, {
|
|
116
|
+
value: string;
|
|
117
|
+
ref: string;
|
|
118
|
+
snapshotId: string;
|
|
119
|
+
tabId?: number | undefined;
|
|
120
|
+
}>;
|
|
121
|
+
export declare const listWebMCPToolsSchema: z.ZodObject<{
|
|
122
|
+
tabId: z.ZodOptional<z.ZodNumber>;
|
|
123
|
+
}, "strip", z.ZodTypeAny, {
|
|
124
|
+
tabId?: number | undefined;
|
|
125
|
+
}, {
|
|
126
|
+
tabId?: number | undefined;
|
|
127
|
+
}>;
|
|
128
|
+
export declare const invokeWebMCPToolSchema: z.ZodObject<{
|
|
129
|
+
toolName: z.ZodString;
|
|
130
|
+
args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
131
|
+
tabId: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
toolName: string;
|
|
134
|
+
args: Record<string, unknown>;
|
|
135
|
+
tabId?: number | undefined;
|
|
136
|
+
}, {
|
|
137
|
+
toolName: string;
|
|
138
|
+
args: Record<string, unknown>;
|
|
139
|
+
tabId?: number | undefined;
|
|
140
|
+
}>;
|
|
141
|
+
export declare const screenshotSchema: z.ZodObject<{
|
|
142
|
+
tabId: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
fullPage: z.ZodOptional<z.ZodBoolean>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
tabId?: number | undefined;
|
|
146
|
+
fullPage?: boolean | undefined;
|
|
147
|
+
}, {
|
|
148
|
+
tabId?: number | undefined;
|
|
149
|
+
fullPage?: boolean | undefined;
|
|
150
|
+
}>;
|
|
151
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;EAM9B,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAInC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;EAK/B,CAAC;AAGH,eAAO,MAAM,gBAAgB;;;;;;;;;EAG3B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;EAG7B,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;EAItB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;EAMzB,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAK7B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;EAEhC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;EAIjC,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;EAG3B,CAAC"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for message validation.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
// Bridge message schemas
|
|
6
|
+
export const bridgeMessageSchema = z.object({
|
|
7
|
+
id: z.string().min(1),
|
|
8
|
+
type: z.enum(['request', 'response', 'ack', 'error']),
|
|
9
|
+
method: z.string().min(1),
|
|
10
|
+
payload: z.unknown(),
|
|
11
|
+
timestamp: z.number(),
|
|
12
|
+
});
|
|
13
|
+
export const bridgeErrorPayloadSchema = z.object({
|
|
14
|
+
code: z.string(),
|
|
15
|
+
message: z.string(),
|
|
16
|
+
details: z.unknown().optional(),
|
|
17
|
+
});
|
|
18
|
+
export const chunkedMessageSchema = z.object({
|
|
19
|
+
id: z.string().min(1),
|
|
20
|
+
chunkIndex: z.number().int().min(0),
|
|
21
|
+
totalChunks: z.number().int().min(1),
|
|
22
|
+
data: z.string(),
|
|
23
|
+
});
|
|
24
|
+
// MCP tool parameter schemas
|
|
25
|
+
export const navigateToSchema = z.object({
|
|
26
|
+
url: z.string().url(),
|
|
27
|
+
tabId: z.number().int().optional(),
|
|
28
|
+
});
|
|
29
|
+
export const pageSnapshotSchema = z.object({
|
|
30
|
+
tabId: z.number().int().optional(),
|
|
31
|
+
maxTokens: z.number().int().positive().optional(),
|
|
32
|
+
});
|
|
33
|
+
export const clickSchema = z.object({
|
|
34
|
+
ref: z.string().regex(/^@e\d+$/),
|
|
35
|
+
snapshotId: z.string().min(1),
|
|
36
|
+
tabId: z.number().int().optional(),
|
|
37
|
+
});
|
|
38
|
+
export const typeTextSchema = z.object({
|
|
39
|
+
ref: z.string().regex(/^@e\d+$/),
|
|
40
|
+
text: z.string(),
|
|
41
|
+
snapshotId: z.string().min(1),
|
|
42
|
+
clearFirst: z.boolean().optional(),
|
|
43
|
+
tabId: z.number().int().optional(),
|
|
44
|
+
});
|
|
45
|
+
export const selectOptionSchema = z.object({
|
|
46
|
+
ref: z.string().regex(/^@e\d+$/),
|
|
47
|
+
value: z.string(),
|
|
48
|
+
snapshotId: z.string().min(1),
|
|
49
|
+
tabId: z.number().int().optional(),
|
|
50
|
+
});
|
|
51
|
+
export const listWebMCPToolsSchema = z.object({
|
|
52
|
+
tabId: z.number().int().optional(),
|
|
53
|
+
});
|
|
54
|
+
export const invokeWebMCPToolSchema = z.object({
|
|
55
|
+
toolName: z.string().min(1),
|
|
56
|
+
args: z.record(z.unknown()),
|
|
57
|
+
tabId: z.number().int().optional(),
|
|
58
|
+
});
|
|
59
|
+
export const screenshotSchema = z.object({
|
|
60
|
+
tabId: z.number().int().optional(),
|
|
61
|
+
fullPage: z.boolean().optional(),
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,yBAAyB;AACzB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACrD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,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,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAClC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a SnapshotNode tree into the compact text representation.
|
|
3
|
+
*/
|
|
4
|
+
import type { SnapshotNode } from './types/snapshot.js';
|
|
5
|
+
/** Format a snapshot tree into compact text */
|
|
6
|
+
export declare function formatSnapshot(node: SnapshotNode, indent?: number): string;
|
|
7
|
+
/**
|
|
8
|
+
* Estimate the token count for a string.
|
|
9
|
+
* Rough approximation: ~4 chars per token for English text.
|
|
10
|
+
*/
|
|
11
|
+
export declare function estimateTokens(text: string): number;
|
|
12
|
+
//# sourceMappingURL=snapshot-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-formatter.d.ts","sourceRoot":"","sources":["../src/snapshot-formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,+CAA+C;AAC/C,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAI7E;AAuDD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** Format a snapshot tree into compact text */
|
|
2
|
+
export function formatSnapshot(node, indent = 0) {
|
|
3
|
+
const lines = [];
|
|
4
|
+
formatNode(node, indent, lines);
|
|
5
|
+
return lines.join('\n');
|
|
6
|
+
}
|
|
7
|
+
function formatNode(node, indent, lines) {
|
|
8
|
+
const pad = ' '.repeat(indent);
|
|
9
|
+
let line = `${pad}[`;
|
|
10
|
+
if (node.ref) {
|
|
11
|
+
line += `${node.ref} `;
|
|
12
|
+
}
|
|
13
|
+
line += node.role;
|
|
14
|
+
if (node.name) {
|
|
15
|
+
line += ` "${node.name}"`;
|
|
16
|
+
}
|
|
17
|
+
line += ']';
|
|
18
|
+
if (node.value !== undefined) {
|
|
19
|
+
line += ` ${node.value}`;
|
|
20
|
+
}
|
|
21
|
+
if (node.checked !== undefined) {
|
|
22
|
+
line += node.checked ? ' (checked)' : ' (unchecked)';
|
|
23
|
+
}
|
|
24
|
+
if (node.disabled) {
|
|
25
|
+
line += ' (disabled)';
|
|
26
|
+
}
|
|
27
|
+
if (node.expanded !== undefined) {
|
|
28
|
+
line += node.expanded ? ' (expanded)' : ' (collapsed)';
|
|
29
|
+
}
|
|
30
|
+
if (node.selected !== undefined) {
|
|
31
|
+
line += node.selected ? ' (selected)' : ' (unselected)';
|
|
32
|
+
}
|
|
33
|
+
if (node.pressed !== undefined) {
|
|
34
|
+
line += node.pressed ? ' (pressed)' : ' (unpressed)';
|
|
35
|
+
}
|
|
36
|
+
lines.push(line);
|
|
37
|
+
if (node.children) {
|
|
38
|
+
for (const child of node.children) {
|
|
39
|
+
formatNode(child, indent + 1, lines);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Estimate the token count for a string.
|
|
45
|
+
* Rough approximation: ~4 chars per token for English text.
|
|
46
|
+
*/
|
|
47
|
+
export function estimateTokens(text) {
|
|
48
|
+
return Math.ceil(text.length / 4);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=snapshot-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-formatter.js","sourceRoot":"","sources":["../src/snapshot-formatter.ts"],"names":[],"mappings":"AAKA,+CAA+C;AAC/C,MAAM,UAAU,cAAc,CAAC,IAAkB,EAAE,SAAiB,CAAC;IACnE,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAChC,OAAO,KAAK,CAAC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AC/B,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal message protocol between MCP Server and Chrome Extension.
|
|
3
|
+
* Messages are sent via Chrome Native Messaging (32-bit length-prefixed JSON).
|
|
4
|
+
*/
|
|
5
|
+
export type BridgeMessageType = 'request' | 'response' | 'ack' | 'error';
|
|
6
|
+
/** Base bridge message */
|
|
7
|
+
export interface BridgeMessage {
|
|
8
|
+
id: string;
|
|
9
|
+
type: BridgeMessageType;
|
|
10
|
+
method: string;
|
|
11
|
+
payload: unknown;
|
|
12
|
+
timestamp: number;
|
|
13
|
+
}
|
|
14
|
+
/** Request from MCP Server to Extension */
|
|
15
|
+
export interface BridgeRequest extends BridgeMessage {
|
|
16
|
+
type: 'request';
|
|
17
|
+
}
|
|
18
|
+
/** Successful response from Extension to MCP Server */
|
|
19
|
+
export interface BridgeResponse extends BridgeMessage {
|
|
20
|
+
type: 'response';
|
|
21
|
+
}
|
|
22
|
+
/** Acknowledgment of request receipt */
|
|
23
|
+
export interface BridgeAck extends BridgeMessage {
|
|
24
|
+
type: 'ack';
|
|
25
|
+
}
|
|
26
|
+
/** Error response */
|
|
27
|
+
export interface BridgeError extends BridgeMessage {
|
|
28
|
+
type: 'error';
|
|
29
|
+
payload: {
|
|
30
|
+
code: string;
|
|
31
|
+
message: string;
|
|
32
|
+
details?: unknown;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** All bridge method names for type-safe dispatch */
|
|
36
|
+
export type BridgeMethod = 'navigate' | 'snapshot' | 'click' | 'typeText' | 'selectOption' | 'listWebMCPTools' | 'invokeWebMCPTool' | 'screenshot' | 'ping';
|
|
37
|
+
/** Chunked message for large payloads (>1MB Native Messaging limit) */
|
|
38
|
+
export interface ChunkedMessage {
|
|
39
|
+
id: string;
|
|
40
|
+
chunkIndex: number;
|
|
41
|
+
totalChunks: number;
|
|
42
|
+
data: string;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,OAAO,CAAC;AAEzE,0BAA0B;AAC1B,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,2CAA2C;AAC3C,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,uDAAuD;AACvD,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,wCAAwC;AACxC,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,IAAI,EAAE,KAAK,CAAC;CACb;AAED,qBAAqB;AACrB,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED,qDAAqD;AACrD,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,UAAU,GACV,OAAO,GACP,UAAU,GACV,cAAc,GACd,iBAAiB,GACjB,kBAAkB,GAClB,YAAY,GACZ,MAAM,CAAC;AAEX,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool definitions for the WebClaw server.
|
|
3
|
+
*/
|
|
4
|
+
/** Parameters for navigate_to tool */
|
|
5
|
+
export interface NavigateToParams {
|
|
6
|
+
url: string;
|
|
7
|
+
tabId?: number;
|
|
8
|
+
}
|
|
9
|
+
/** Parameters for page_snapshot tool */
|
|
10
|
+
export interface PageSnapshotParams {
|
|
11
|
+
tabId?: number;
|
|
12
|
+
maxTokens?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Parameters for click tool */
|
|
15
|
+
export interface ClickParams {
|
|
16
|
+
ref: string;
|
|
17
|
+
snapshotId: string;
|
|
18
|
+
tabId?: number;
|
|
19
|
+
}
|
|
20
|
+
/** Parameters for type_text tool */
|
|
21
|
+
export interface TypeTextParams {
|
|
22
|
+
ref: string;
|
|
23
|
+
text: string;
|
|
24
|
+
snapshotId: string;
|
|
25
|
+
clearFirst?: boolean;
|
|
26
|
+
tabId?: number;
|
|
27
|
+
}
|
|
28
|
+
/** Parameters for select_option tool */
|
|
29
|
+
export interface SelectOptionParams {
|
|
30
|
+
ref: string;
|
|
31
|
+
value: string;
|
|
32
|
+
snapshotId: string;
|
|
33
|
+
tabId?: number;
|
|
34
|
+
}
|
|
35
|
+
/** Parameters for list_webmcp_tools tool */
|
|
36
|
+
export interface ListWebMCPToolsParams {
|
|
37
|
+
tabId?: number;
|
|
38
|
+
}
|
|
39
|
+
/** Parameters for invoke_webmcp_tool tool */
|
|
40
|
+
export interface InvokeWebMCPToolParams {
|
|
41
|
+
toolName: string;
|
|
42
|
+
args: Record<string, unknown>;
|
|
43
|
+
tabId?: number;
|
|
44
|
+
}
|
|
45
|
+
/** Parameters for screenshot tool */
|
|
46
|
+
export interface ScreenshotParams {
|
|
47
|
+
tabId?: number;
|
|
48
|
+
fullPage?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/** Screenshot result */
|
|
51
|
+
export interface ScreenshotResult {
|
|
52
|
+
dataUrl: string;
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=mcp-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tools.d.ts","sourceRoot":"","sources":["../../src/types/mcp-tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,sCAAsC;AACtC,MAAM,WAAW,gBA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
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tools.js","sourceRoot":"","sources":["../../src/types/mcp-tools.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact A11y tree snapshot types with @ref support.
|
|
3
|
+
*/
|
|
4
|
+
/** A node in the compact snapshot tree */
|
|
5
|
+
export interface SnapshotNode {
|
|
6
|
+
role: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
ref?: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
checked?: boolean;
|
|
11
|
+
selected?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
expanded?: boolean;
|
|
14
|
+
pressed?: boolean;
|
|
15
|
+
children?: SnapshotNode[];
|
|
16
|
+
}
|
|
17
|
+
/** Complete page snapshot */
|
|
18
|
+
export interface PageSnapshot {
|
|
19
|
+
snapshotId: string;
|
|
20
|
+
url: string;
|
|
21
|
+
title: string;
|
|
22
|
+
tree: SnapshotNode;
|
|
23
|
+
timestamp: number;
|
|
24
|
+
}
|
|
25
|
+
/** Options for snapshot generation */
|
|
26
|
+
export interface SnapshotOptions {
|
|
27
|
+
/** Maximum token budget for the snapshot text (default: 4000) */
|
|
28
|
+
maxTokens?: number;
|
|
29
|
+
/** Include only interactive elements */
|
|
30
|
+
interactiveOnly?: boolean;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/types/snapshot.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,0CAA0C;AAC1C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;CAC3B;AAED,6BAA6B;AAC7B,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,sCAAsC;AACtC,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/types/snapshot.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebMCP (Web Model Context Protocol) type definitions.
|
|
3
|
+
* Based on the W3C WebMCP specification (Chrome 146+).
|
|
4
|
+
*/
|
|
5
|
+
/** JSON Schema type for tool input definitions */
|
|
6
|
+
export interface JSONSchema {
|
|
7
|
+
type?: string;
|
|
8
|
+
properties?: Record<string, JSONSchema>;
|
|
9
|
+
required?: string[];
|
|
10
|
+
items?: JSONSchema;
|
|
11
|
+
enum?: unknown[];
|
|
12
|
+
description?: string;
|
|
13
|
+
default?: unknown;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
/** Source of a WebMCP tool discovery */
|
|
17
|
+
export type WebMCPToolSource = 'webmcp-native' | 'synthesized-form' | 'synthesized-button' | 'synthesized-link' | 'synthesized-input';
|
|
18
|
+
/** A tool discovered via WebMCP or auto-synthesis */
|
|
19
|
+
export interface WebMCPTool {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
inputSchema: JSONSchema;
|
|
23
|
+
source: WebMCPToolSource;
|
|
24
|
+
tabId: number;
|
|
25
|
+
elementRef?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Result of invoking a WebMCP tool */
|
|
28
|
+
export interface WebMCPToolResult {
|
|
29
|
+
success: boolean;
|
|
30
|
+
content?: unknown;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
/** WebMCP server declaration from a page */
|
|
34
|
+
export interface WebMCPServerInfo {
|
|
35
|
+
name: string;
|
|
36
|
+
version: string;
|
|
37
|
+
tools: WebMCPTool[];
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=webmcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webmcp.d.ts","sourceRoot":"","sources":["../../src/types/webmcp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kDAAkD;AAClD,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wCAAwC;AACxC,MAAM,MAAM,gBAAgB,GACxB,eAAe,GACf,kBAAkB,GAClB,oBAAoB,GACpB,kBAAkB,GAClB,mBAAmB,CAAC;AAExB,qDAAqD;AACrD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;IACxB,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,uCAAuC;AACvC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webmcp.js","sourceRoot":"","sources":["../../src/types/webmcp.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|