@pi-oxide/extension-js 0.2.4 → 0.3.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/content-script.d.ts +6 -43
- package/content-script.js +2 -2
- package/extension_js.d.ts +306 -224
- package/extension_js.js +61685 -60860
- package/generated.d.ts +45 -2
- package/index.d.ts +5 -91
- package/index.js +3678 -3914
- package/package.json +1 -1
- package/runner.d.ts +2 -1
- package/schemas.d.ts +209 -20
- package/tool-registry.d.ts +60 -3
- package/worker.js +401 -121
package/package.json
CHANGED
package/runner.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ declare global {
|
|
|
9
9
|
type HostHandler<T = unknown, R = unknown> = (params: T) => Promise<R>;
|
|
10
10
|
export declare function registerHostHandler<T, R>(action: string, handler: (params: T) => Promise<R>): void;
|
|
11
11
|
export declare function registerHostHandlers(handlers: Record<string, HostHandler>): void;
|
|
12
|
+
export declare function isValidMainThreadAction(action: string): boolean;
|
|
12
13
|
export declare function normalizeParams(action: string, params: unknown): unknown;
|
|
13
|
-
export declare function executeMainThreadCommand(command: Command): Promise<AsyncResponse>;
|
|
14
|
+
export declare function executeMainThreadCommand(command: Command, relaySignal?: AbortSignal): Promise<AsyncResponse>;
|
|
14
15
|
export declare function getActiveTabId(): number | null;
|
|
15
16
|
export declare function initExtensionListeners(): void;
|
|
16
17
|
export declare function removeExtensionListeners(): void;
|
package/schemas.d.ts
CHANGED
|
@@ -113,10 +113,70 @@ export declare const PageWaitParamsSchema: z.ZodObject<{
|
|
|
113
113
|
}, {
|
|
114
114
|
duration?: number | bigint | undefined;
|
|
115
115
|
}>;
|
|
116
|
-
export declare const PageClickParamsSchema: z.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
export declare const PageClickParamsSchema: z.ZodEffects<z.ZodObject<{
|
|
117
|
+
refId: z.ZodOptional<z.ZodString>;
|
|
118
|
+
label: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
refId?: string | undefined;
|
|
121
|
+
label?: string | undefined;
|
|
122
|
+
}, {
|
|
123
|
+
refId?: string | undefined;
|
|
124
|
+
label?: string | undefined;
|
|
125
|
+
}>, {
|
|
126
|
+
refId?: string | undefined;
|
|
127
|
+
label?: string | undefined;
|
|
128
|
+
}, {
|
|
129
|
+
refId?: string | undefined;
|
|
130
|
+
label?: string | undefined;
|
|
131
|
+
}>;
|
|
132
|
+
export declare const PageFillParamsSchema: z.ZodEffects<z.ZodObject<{
|
|
133
|
+
refId: z.ZodOptional<z.ZodString>;
|
|
134
|
+
label: z.ZodOptional<z.ZodString>;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
refId?: string | undefined;
|
|
137
|
+
label?: string | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
refId?: string | undefined;
|
|
140
|
+
label?: string | undefined;
|
|
141
|
+
}>, {
|
|
142
|
+
refId?: string | undefined;
|
|
143
|
+
label?: string | undefined;
|
|
144
|
+
}, {
|
|
145
|
+
refId?: string | undefined;
|
|
146
|
+
label?: string | undefined;
|
|
147
|
+
}>;
|
|
148
|
+
export declare const PageTypeParamsSchema: z.ZodEffects<z.ZodObject<{
|
|
149
|
+
refId: z.ZodOptional<z.ZodString>;
|
|
150
|
+
label: z.ZodOptional<z.ZodString>;
|
|
151
|
+
}, "strip", z.ZodTypeAny, {
|
|
152
|
+
refId?: string | undefined;
|
|
153
|
+
label?: string | undefined;
|
|
154
|
+
}, {
|
|
155
|
+
refId?: string | undefined;
|
|
156
|
+
label?: string | undefined;
|
|
157
|
+
}>, {
|
|
158
|
+
refId?: string | undefined;
|
|
159
|
+
label?: string | undefined;
|
|
160
|
+
}, {
|
|
161
|
+
refId?: string | undefined;
|
|
162
|
+
label?: string | undefined;
|
|
163
|
+
}>;
|
|
164
|
+
export declare const PageAppendParamsSchema: z.ZodEffects<z.ZodObject<{
|
|
165
|
+
refId: z.ZodOptional<z.ZodString>;
|
|
166
|
+
label: z.ZodOptional<z.ZodString>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
refId?: string | undefined;
|
|
169
|
+
label?: string | undefined;
|
|
170
|
+
}, {
|
|
171
|
+
refId?: string | undefined;
|
|
172
|
+
label?: string | undefined;
|
|
173
|
+
}>, {
|
|
174
|
+
refId?: string | undefined;
|
|
175
|
+
label?: string | undefined;
|
|
176
|
+
}, {
|
|
177
|
+
refId?: string | undefined;
|
|
178
|
+
label?: string | undefined;
|
|
179
|
+
}>;
|
|
120
180
|
export declare const PagePressParamsSchema: z.ZodObject<{
|
|
121
181
|
key: z.ZodString;
|
|
122
182
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -124,9 +184,27 @@ export declare const PagePressParamsSchema: z.ZodObject<{
|
|
|
124
184
|
}, {
|
|
125
185
|
key: string;
|
|
126
186
|
}>;
|
|
127
|
-
export declare const PageSelectParamsSchema: z.
|
|
128
|
-
|
|
129
|
-
|
|
187
|
+
export declare const PageSelectParamsSchema: z.ZodObject<{
|
|
188
|
+
refId: z.ZodString;
|
|
189
|
+
}, "strip", z.ZodTypeAny, {
|
|
190
|
+
refId: string;
|
|
191
|
+
}, {
|
|
192
|
+
refId: string;
|
|
193
|
+
}>;
|
|
194
|
+
export declare const PageCheckParamsSchema: z.ZodObject<{
|
|
195
|
+
refId: z.ZodString;
|
|
196
|
+
}, "strip", z.ZodTypeAny, {
|
|
197
|
+
refId: string;
|
|
198
|
+
}, {
|
|
199
|
+
refId: string;
|
|
200
|
+
}>;
|
|
201
|
+
export declare const PageHoverParamsSchema: z.ZodObject<{
|
|
202
|
+
refId: z.ZodString;
|
|
203
|
+
}, "strip", z.ZodTypeAny, {
|
|
204
|
+
refId: string;
|
|
205
|
+
}, {
|
|
206
|
+
refId: string;
|
|
207
|
+
}>;
|
|
130
208
|
export declare const PageUnhoverParamsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
131
209
|
export declare const PageScrollParamsSchema: z.ZodObject<{
|
|
132
210
|
direction: z.ZodDefault<z.ZodString>;
|
|
@@ -138,8 +216,20 @@ export declare const PageScrollParamsSchema: z.ZodObject<{
|
|
|
138
216
|
direction?: string | undefined;
|
|
139
217
|
amount?: number | undefined;
|
|
140
218
|
}>;
|
|
141
|
-
export declare const PageScrollToParamsSchema: z.
|
|
142
|
-
|
|
219
|
+
export declare const PageScrollToParamsSchema: z.ZodObject<{
|
|
220
|
+
refId: z.ZodString;
|
|
221
|
+
}, "strip", z.ZodTypeAny, {
|
|
222
|
+
refId: string;
|
|
223
|
+
}, {
|
|
224
|
+
refId: string;
|
|
225
|
+
}>;
|
|
226
|
+
export declare const PageDblClickParamsSchema: z.ZodObject<{
|
|
227
|
+
refId: z.ZodString;
|
|
228
|
+
}, "strip", z.ZodTypeAny, {
|
|
229
|
+
refId: string;
|
|
230
|
+
}, {
|
|
231
|
+
refId: string;
|
|
232
|
+
}>;
|
|
143
233
|
export declare const PageFindParamsSchema: z.ZodObject<{
|
|
144
234
|
selector: z.ZodString;
|
|
145
235
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -171,17 +261,116 @@ export declare const TabCreateParamsSchema: z.ZodRecord<z.ZodString, z.ZodUnknow
|
|
|
171
261
|
export declare const TabActivateParamsSchema: z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodUnknown, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
172
262
|
export declare const TabCloseParamsSchema: z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodUnknown, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
173
263
|
export declare const TabExecuteScriptParamsSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
174
|
-
export declare const TabClickParamsSchema: z.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
export declare const
|
|
264
|
+
export declare const TabClickParamsSchema: z.ZodObject<{
|
|
265
|
+
refId: z.ZodString;
|
|
266
|
+
tabId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
|
|
267
|
+
}, "strip", z.ZodTypeAny, {
|
|
268
|
+
refId: string;
|
|
269
|
+
tabId?: number | bigint | undefined;
|
|
270
|
+
}, {
|
|
271
|
+
refId: string;
|
|
272
|
+
tabId?: number | bigint | undefined;
|
|
273
|
+
}>;
|
|
274
|
+
export declare const TabFillParamsSchema: z.ZodObject<{
|
|
275
|
+
refId: z.ZodString;
|
|
276
|
+
tabId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
|
|
277
|
+
}, "strip", z.ZodTypeAny, {
|
|
278
|
+
refId: string;
|
|
279
|
+
tabId?: number | bigint | undefined;
|
|
280
|
+
}, {
|
|
281
|
+
refId: string;
|
|
282
|
+
tabId?: number | bigint | undefined;
|
|
283
|
+
}>;
|
|
284
|
+
export declare const TabScrollToParamsSchema: z.ZodObject<{
|
|
285
|
+
refId: z.ZodString;
|
|
286
|
+
tabId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
|
|
287
|
+
}, "strip", z.ZodTypeAny, {
|
|
288
|
+
refId: string;
|
|
289
|
+
tabId?: number | bigint | undefined;
|
|
290
|
+
}, {
|
|
291
|
+
refId: string;
|
|
292
|
+
tabId?: number | bigint | undefined;
|
|
293
|
+
}>;
|
|
294
|
+
export declare const TabTypeParamsSchema: z.ZodObject<{
|
|
295
|
+
refId: z.ZodString;
|
|
296
|
+
tabId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
|
|
297
|
+
}, "strip", z.ZodTypeAny, {
|
|
298
|
+
refId: string;
|
|
299
|
+
tabId?: number | bigint | undefined;
|
|
300
|
+
}, {
|
|
301
|
+
refId: string;
|
|
302
|
+
tabId?: number | bigint | undefined;
|
|
303
|
+
}>;
|
|
304
|
+
export declare const TabPressParamsSchema: z.ZodObject<{
|
|
305
|
+
key: z.ZodString;
|
|
306
|
+
tabId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
|
|
307
|
+
}, "strip", z.ZodTypeAny, {
|
|
308
|
+
key: string;
|
|
309
|
+
tabId?: number | bigint | undefined;
|
|
310
|
+
}, {
|
|
311
|
+
key: string;
|
|
312
|
+
tabId?: number | bigint | undefined;
|
|
313
|
+
}>;
|
|
314
|
+
export declare const TabSelectParamsSchema: z.ZodObject<{
|
|
315
|
+
refId: z.ZodString;
|
|
316
|
+
tabId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
|
|
317
|
+
}, "strip", z.ZodTypeAny, {
|
|
318
|
+
refId: string;
|
|
319
|
+
tabId?: number | bigint | undefined;
|
|
320
|
+
}, {
|
|
321
|
+
refId: string;
|
|
322
|
+
tabId?: number | bigint | undefined;
|
|
323
|
+
}>;
|
|
324
|
+
export declare const TabCheckParamsSchema: z.ZodObject<{
|
|
325
|
+
refId: z.ZodString;
|
|
326
|
+
tabId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
|
|
327
|
+
}, "strip", z.ZodTypeAny, {
|
|
328
|
+
refId: string;
|
|
329
|
+
tabId?: number | bigint | undefined;
|
|
330
|
+
}, {
|
|
331
|
+
refId: string;
|
|
332
|
+
tabId?: number | bigint | undefined;
|
|
333
|
+
}>;
|
|
334
|
+
export declare const TabHoverParamsSchema: z.ZodObject<{
|
|
335
|
+
refId: z.ZodString;
|
|
336
|
+
tabId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
|
|
337
|
+
}, "strip", z.ZodTypeAny, {
|
|
338
|
+
refId: string;
|
|
339
|
+
tabId?: number | bigint | undefined;
|
|
340
|
+
}, {
|
|
341
|
+
refId: string;
|
|
342
|
+
tabId?: number | bigint | undefined;
|
|
343
|
+
}>;
|
|
344
|
+
export declare const TabUnhoverParamsSchema: z.ZodObject<{
|
|
345
|
+
tabId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
|
|
346
|
+
}, "strip", z.ZodTypeAny, {
|
|
347
|
+
tabId?: number | bigint | undefined;
|
|
348
|
+
}, {
|
|
349
|
+
tabId?: number | bigint | undefined;
|
|
350
|
+
}>;
|
|
351
|
+
export declare const TabScrollParamsSchema: z.ZodObject<{
|
|
352
|
+
direction: z.ZodDefault<z.ZodString>;
|
|
353
|
+
amount: z.ZodDefault<z.ZodNumber>;
|
|
354
|
+
tabId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
|
|
355
|
+
}, "strip", z.ZodTypeAny, {
|
|
356
|
+
direction: string;
|
|
357
|
+
amount: number;
|
|
358
|
+
tabId?: number | bigint | undefined;
|
|
359
|
+
}, {
|
|
360
|
+
direction?: string | undefined;
|
|
361
|
+
amount?: number | undefined;
|
|
362
|
+
tabId?: number | bigint | undefined;
|
|
363
|
+
}>;
|
|
364
|
+
export declare const TabDblClickParamsSchema: z.ZodObject<{
|
|
365
|
+
refId: z.ZodString;
|
|
366
|
+
tabId: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>>;
|
|
367
|
+
}, "strip", z.ZodTypeAny, {
|
|
368
|
+
refId: string;
|
|
369
|
+
tabId?: number | bigint | undefined;
|
|
370
|
+
}, {
|
|
371
|
+
refId: string;
|
|
372
|
+
tabId?: number | bigint | undefined;
|
|
373
|
+
}>;
|
|
185
374
|
export declare const TabEvaluateParamsSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
186
375
|
export declare const TabBackParamsSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
187
376
|
export declare const TabWaitForLoadParamsSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
package/tool-registry.d.ts
CHANGED
|
@@ -42,17 +42,74 @@ export interface ToolDefinition<P, R> {
|
|
|
42
42
|
description: string;
|
|
43
43
|
params: z.ZodSchema<P>;
|
|
44
44
|
returns: z.ZodSchema<R>;
|
|
45
|
-
handler: (params: P) => Promise<R>;
|
|
45
|
+
handler: (params: P, callId?: number, runId?: string, signal?: AbortSignal) => Promise<R>;
|
|
46
46
|
paramTypes: ToolDocParam[];
|
|
47
47
|
returnType?: string;
|
|
48
48
|
returnDoc: string;
|
|
49
49
|
errorCode: string;
|
|
50
50
|
errorCategory?: string;
|
|
51
51
|
}
|
|
52
|
+
export type ExecutionContextId = string;
|
|
53
|
+
export type CallContext = {
|
|
54
|
+
action: string;
|
|
55
|
+
callId?: number;
|
|
56
|
+
runId?: string;
|
|
57
|
+
signal?: AbortSignal;
|
|
58
|
+
};
|
|
59
|
+
export type JsCallSpec<P, R> = {
|
|
60
|
+
action: string;
|
|
61
|
+
namespace: string;
|
|
62
|
+
name: string;
|
|
63
|
+
description: string;
|
|
64
|
+
params: z.ZodSchema<P>;
|
|
65
|
+
returns: z.ZodSchema<R>;
|
|
66
|
+
fields?: string[];
|
|
67
|
+
aliases?: Array<{
|
|
68
|
+
namespace: string;
|
|
69
|
+
name: string;
|
|
70
|
+
fields?: string[];
|
|
71
|
+
}>;
|
|
72
|
+
owner: ExecutionContextId;
|
|
73
|
+
handler: (params: P, ctx: CallContext) => Promise<R>;
|
|
74
|
+
errorCode: string;
|
|
75
|
+
errorCategory?: string;
|
|
76
|
+
paramTypes?: ToolDocParam[];
|
|
77
|
+
returnType?: string;
|
|
78
|
+
returnDoc?: string;
|
|
79
|
+
};
|
|
80
|
+
export type SerializableJsCallManifestEntry = {
|
|
81
|
+
action: string;
|
|
82
|
+
namespace: string;
|
|
83
|
+
name: string;
|
|
84
|
+
publicName: string;
|
|
85
|
+
description: string;
|
|
86
|
+
fields: string[] | null;
|
|
87
|
+
aliases: Array<{
|
|
88
|
+
namespace: string;
|
|
89
|
+
name: string;
|
|
90
|
+
fields: string[] | null;
|
|
91
|
+
}> | null;
|
|
92
|
+
owner: ExecutionContextId;
|
|
93
|
+
paramsDoc: ToolDocParam[];
|
|
94
|
+
returnsDoc: {
|
|
95
|
+
type: string;
|
|
96
|
+
description: string;
|
|
97
|
+
};
|
|
98
|
+
errorCode: string;
|
|
99
|
+
errorCategory?: string;
|
|
100
|
+
};
|
|
52
101
|
export declare function setRunnerAbortController(controller: AbortController | null): void;
|
|
102
|
+
export declare function getRunnerSignal(): AbortSignal | undefined;
|
|
53
103
|
export declare function throwIfAborted(): void;
|
|
54
|
-
export declare function
|
|
104
|
+
export declare function registerJsCall<P, R>(spec: JsCallSpec<P, R>): void;
|
|
55
105
|
export declare function getTool(action: string): ToolDefinition<unknown, unknown> | undefined;
|
|
56
106
|
export declare function clearRegistry(): void;
|
|
57
|
-
export declare function
|
|
107
|
+
export declare function freezeJsRegistry(): void;
|
|
108
|
+
export declare function clearJsRegistry(): void;
|
|
109
|
+
export declare function getSerializableJsManifest(): SerializableJsCallManifestEntry[];
|
|
110
|
+
/** Convert a serializable manifest entry to the shape expected by WASM registerJsCall/registerJsCallBatch. */
|
|
111
|
+
export declare function manifestEntryToWasm(entry: SerializableJsCallManifestEntry): Record<string, unknown>;
|
|
112
|
+
/** Rust/WASM often passes BTreeMap params as a JS Map; Zod object schemas need plain objects. */
|
|
113
|
+
export declare function coerceWasmParams(params: unknown): unknown;
|
|
114
|
+
export declare function dispatchTool(action: string, params: unknown, callId?: number, runId?: string, signal?: AbortSignal): Promise<AsyncResponse>;
|
|
58
115
|
export declare function listTools(): ToolDoc[];
|