@pi-oxide/extension-js 0.12.4 → 0.13.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/action-result.d.ts +4 -0
- package/content-script/dom-tree.d.ts +28 -0
- package/content-script/dom-utils.d.ts +37 -0
- package/content-script/file-resolution.d.ts +22 -0
- package/content-script/form-validation.d.ts +12 -0
- package/content-script/handlers.d.ts +3 -0
- package/content-script/index.d.ts +6 -0
- package/content-script/listbox.d.ts +7 -0
- package/content-script/logger.d.ts +12 -0
- package/content-script/message-router.d.ts +1 -0
- package/content-script/observation-lease.d.ts +55 -0
- package/content-script/registry.d.ts +24 -0
- package/content-script/schemas.d.ts +5 -0
- package/content-script/snapshot.d.ts +3 -0
- package/content-script.js +3 -3
- package/extension_js.d.ts +11 -3
- package/extension_js.js +25785 -16587
- package/index.js +2227 -1774
- package/main/index.d.ts +8 -0
- package/main/runner/chrome/internals.d.ts +9 -0
- package/main/runner/chrome/native.d.ts +6 -0
- package/main/runner/command.d.ts +3 -0
- package/main/runner/dom/snapshot.d.ts +8 -0
- package/main/runner/fetch.d.ts +4 -0
- package/main/runner/host.d.ts +3 -0
- package/main/runner/index.d.ts +2 -0
- package/main/runner/lib/constants.d.ts +14 -0
- package/main/runner/lib/host-registry.d.ts +6 -0
- package/main/runner/lib/network-tracker.d.ts +16 -0
- package/main/runner/lib/params-helpers.d.ts +2 -0
- package/main/runner/lib/params.d.ts +5 -0
- package/main/runner/lib/types.d.ts +116 -0
- package/main/runner/runtime.d.ts +15 -0
- package/main/runner/sidepanel/dom.d.ts +6 -0
- package/main/runner/snapshot-merge.d.ts +8 -0
- package/main/runner/tab/execute.d.ts +24 -0
- package/main/runner/tools/aliases.d.ts +1 -0
- package/main/runner/tools/chrome/action.d.ts +1 -0
- package/main/runner/tools/chrome/alarms.d.ts +1 -0
- package/main/runner/tools/chrome/bookmarks.d.ts +1 -0
- package/main/runner/tools/chrome/browsing-data.d.ts +1 -0
- package/main/runner/tools/chrome/capability.d.ts +30 -0
- package/main/runner/tools/chrome/context-menus.d.ts +1 -0
- package/main/runner/tools/chrome/cookies.d.ts +1 -0
- package/main/runner/tools/chrome/declarative-net-request.d.ts +1 -0
- package/main/runner/tools/chrome/desktop-capture.d.ts +1 -0
- package/main/runner/tools/chrome/downloads.d.ts +1 -0
- package/main/runner/tools/chrome/history.d.ts +1 -0
- package/main/runner/tools/chrome/identity.d.ts +1 -0
- package/main/runner/tools/chrome/idle.d.ts +1 -0
- package/main/runner/tools/chrome/index.d.ts +1 -0
- package/main/runner/tools/chrome/management.d.ts +1 -0
- package/main/runner/tools/chrome/notifications.d.ts +1 -0
- package/main/runner/tools/chrome/offscreen.d.ts +1 -0
- package/main/runner/tools/chrome/page-capture.d.ts +1 -0
- package/main/runner/tools/chrome/permissions.d.ts +1 -0
- package/main/runner/tools/chrome/register-helpers.d.ts +9 -0
- package/main/runner/tools/chrome/runtime.d.ts +1 -0
- package/main/runner/tools/chrome/scripting.d.ts +1 -0
- package/main/runner/tools/chrome/sessions.d.ts +1 -0
- package/main/runner/tools/chrome/side-panel.d.ts +1 -0
- package/main/runner/tools/chrome/system.d.ts +1 -0
- package/main/runner/tools/chrome/tab-groups.d.ts +1 -0
- package/main/runner/tools/chrome/tabs.d.ts +1 -0
- package/main/runner/tools/chrome/top-sites.d.ts +1 -0
- package/main/runner/tools/chrome/windows.d.ts +1 -0
- package/main/runner/tools/chrome-storage.d.ts +1 -0
- package/main/runner/tools/clipboard.d.ts +1 -0
- package/main/runner/tools/dom.d.ts +1 -0
- package/main/runner/tools/host-call.d.ts +1 -0
- package/main/runner/tools/network.d.ts +1 -0
- package/main/runner/tools/page.d.ts +1 -0
- package/main/runner/tools/sidepanel.d.ts +1 -0
- package/main/runner/tools/storage.d.ts +1 -0
- package/main/runner/tools/tab.d.ts +1 -0
- package/main/session/extension-session.d.ts +106 -0
- package/main/tab-context.d.ts +12 -0
- package/package.json +5 -2
- package/shared/array-buffer.d.ts +4 -0
- package/shared/collect-inline-snapshot.d.ts +50 -0
- package/shared/cross/agent-errors.d.ts +28 -0
- package/shared/cross/array-buffer.d.ts +4 -0
- package/shared/cross/collect-inline-snapshot.d.ts +58 -0
- package/shared/cross/content-script-actions.d.ts +7 -0
- package/shared/cross/content-script-tools.d.ts +3 -0
- package/shared/cross/dispatch.d.ts +5 -0
- package/shared/cross/fetch-response.d.ts +12 -0
- package/shared/cross/format-types.d.ts +43 -0
- package/shared/cross/fs-types.d.ts +81 -0
- package/shared/cross/generated.d.ts +328 -0
- package/shared/cross/manifest.d.ts +130 -0
- package/shared/cross/normalize-agent-error.d.ts +17 -0
- package/shared/cross/page-specs.d.ts +7 -0
- package/shared/cross/schemas/chrome.d.ts +56 -0
- package/shared/cross/schemas/clipboard.d.ts +19 -0
- package/shared/cross/schemas/fs.d.ts +65 -0
- package/shared/cross/schemas/helpers.d.ts +71 -0
- package/shared/cross/schemas/host.d.ts +15 -0
- package/shared/cross/schemas/network.d.ts +34 -0
- package/shared/cross/schemas/page.d.ts +494 -0
- package/shared/cross/schemas/returns.d.ts +8791 -0
- package/shared/cross/schemas/sidepanel.d.ts +284 -0
- package/shared/cross/schemas/snapshot.d.ts +272 -0
- package/shared/cross/schemas/storage.d.ts +60 -0
- package/shared/cross/schemas/tab.d.ts +597 -0
- package/shared/cross/schemas.d.ts +12 -0
- package/shared/cross/snapshot-filter.d.ts +15 -0
- package/shared/cross/tab-specs.d.ts +3 -0
- package/shared/cross/types.d.ts +12 -0
- package/shared/cross/zod-to-docs.d.ts +28 -0
- package/shared/cs/ref-id.d.ts +5 -0
- package/shared/cs/snapshot-dom.d.ts +47 -0
- package/shared/fetch-response.d.ts +12 -0
- package/shared/fs-types.d.ts +81 -0
- package/shared/generated.d.ts +241 -0
- package/shared/log-levels.d.ts +5 -0
- package/shared/logger.d.ts +18 -0
- package/shared/main/content-script-response.d.ts +5 -0
- package/shared/main/define-content-script-tool.d.ts +7 -0
- package/shared/main/log-levels.d.ts +5 -0
- package/shared/main/logger.d.ts +18 -0
- package/shared/main/routes.d.ts +14 -0
- package/shared/main/tool-registry.d.ts +19 -0
- package/shared/ref-id.d.ts +5 -0
- package/shared/registry/agent-errors.d.ts +27 -0
- package/shared/registry/content-script-actions.d.ts +7 -0
- package/shared/registry/content-script-response.d.ts +5 -0
- package/shared/registry/content-script-tools.d.ts +13 -0
- package/shared/registry/define-content-script-tool.d.ts +7 -0
- package/shared/registry/dispatch.d.ts +5 -0
- package/shared/registry/manifest.d.ts +130 -0
- package/shared/registry/normalize-agent-error.d.ts +17 -0
- package/shared/registry/routes.d.ts +14 -0
- package/shared/registry/types.d.ts +12 -0
- package/shared/registry/zod-to-docs.d.ts +28 -0
- package/shared/schemas.d.ts +10663 -0
- package/shared/snapshot-dom.d.ts +47 -0
- package/shared/snapshot-filter.d.ts +15 -0
- package/shared/tool-registry.d.ts +19 -0
- package/worker/binary-blob-store.d.ts +12 -0
- package/worker/fetch-store.d.ts +1 -0
- package/worker/resolve-set-files.d.ts +22 -0
- package/worker/vfs-write-cache.d.ts +3 -0
- package/worker/worker.d.ts +84 -0
- package/worker.js +1756 -1615
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PageActionResult } from '../shared/cross/schemas.js';
|
|
2
|
+
|
|
3
|
+
export declare function makeActionResult(action: string, el: Element | null, extras?: Record<string, unknown>): PageActionResult;
|
|
4
|
+
export declare function assertFillEffect(action: string, el: Element, refId: string, requested: string): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type DomNode = {
|
|
2
|
+
refId?: string;
|
|
3
|
+
tag: string;
|
|
4
|
+
role?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
text?: string;
|
|
7
|
+
attributes?: Record<string, string>;
|
|
8
|
+
hidden?: boolean;
|
|
9
|
+
hiddenReason?: "display-none" | "visibility-hidden" | "aria-hidden" | "opacity-zero" | "hidden-attr" | "inert";
|
|
10
|
+
value?: string;
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
readOnly?: boolean;
|
|
14
|
+
href?: string;
|
|
15
|
+
src?: string;
|
|
16
|
+
alt?: string;
|
|
17
|
+
accept?: string;
|
|
18
|
+
filesCount?: number;
|
|
19
|
+
controlType?: string;
|
|
20
|
+
recommendedAction?: string;
|
|
21
|
+
controls?: string;
|
|
22
|
+
expanded?: boolean;
|
|
23
|
+
children?: DomNode[];
|
|
24
|
+
};
|
|
25
|
+
export declare function buildDomNode(el: Element, depth: number, includeHidden: boolean, observed?: Array<{
|
|
26
|
+
refId: string;
|
|
27
|
+
element: Element;
|
|
28
|
+
}>): DomNode | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { enrichFormNode, getAccessibleName, getAccessibleRole, shouldInclude } from '../shared/cs/snapshot-dom.js';
|
|
2
|
+
|
|
3
|
+
export { enrichFormNode, getAccessibleName, getAccessibleRole, shouldInclude };
|
|
4
|
+
/**
|
|
5
|
+
* Find an element by its opaque reference ID.
|
|
6
|
+
* @param refId — opaque element ref in 'e{N}' format (e.g. 'e2'). Must match schema regex ^e\d+$.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getElementByRefId(refId: string): Element | null;
|
|
9
|
+
export declare function assertInteractable(el: Element, action: string): void;
|
|
10
|
+
export declare function findElementByLabel(query: string): Element | null;
|
|
11
|
+
export declare function findCandidateLabels(query: string): string[];
|
|
12
|
+
export type SemanticCandidate = {
|
|
13
|
+
refId: string;
|
|
14
|
+
role?: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function findSemanticCandidates(query: string): SemanticCandidate[];
|
|
18
|
+
export declare function asRecord(obj: unknown): Record<string, unknown>;
|
|
19
|
+
export declare function getStringParam(params: unknown, key: string): string;
|
|
20
|
+
export declare function getNumberParam(params: unknown, key: string, fallback: number): number;
|
|
21
|
+
export declare function findCandidatesByRefId(refId: string): SemanticCandidate[];
|
|
22
|
+
export declare function throwElementNotFound(refId: string | undefined, label: string | undefined, includeCandidates?: boolean): never;
|
|
23
|
+
/**
|
|
24
|
+
* Resolve an element by refId (raw querySelector) with a label fallback.
|
|
25
|
+
*
|
|
26
|
+
* INTENTIONAL non-lease path: this deliberately bypasses the observation lease
|
|
27
|
+
* (requireTarget / requireTargetByLabel). The handlers that use this — type,
|
|
28
|
+
* append, select, check, hover, dblclick, set_files, scroll_to — mutate stable
|
|
29
|
+
* elements that rarely change between snapshot and action, so the lease's
|
|
30
|
+
* stale-element / fingerprint strictness is unnecessary here and would reject
|
|
31
|
+
* valid targets. Only `click` (and fill's refId path) use lease validation.
|
|
32
|
+
*
|
|
33
|
+
* Do NOT "unify" these handlers onto requireTarget — that changes behavior the
|
|
34
|
+
* project has explicitly chosen. If you need lease-validated resolution, use
|
|
35
|
+
* requireTarget/requireTargetByLabel directly (as click does).
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveTargetRaw(refId: string | undefined, label: string | undefined): Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-input resolution for `set_files`. Resolves worker-processed file
|
|
3
|
+
* payloads (base64 bytes or fetched URL) into real `File` objects and
|
|
4
|
+
* verifies they landed on the input.
|
|
5
|
+
*/
|
|
6
|
+
export type ResolvedBytesFile = {
|
|
7
|
+
kind: "bytes";
|
|
8
|
+
name: string;
|
|
9
|
+
data: string;
|
|
10
|
+
mimeType?: string;
|
|
11
|
+
};
|
|
12
|
+
export type ResolvedUrlFile = {
|
|
13
|
+
kind: "url";
|
|
14
|
+
url: string;
|
|
15
|
+
name: string;
|
|
16
|
+
mimeType?: string;
|
|
17
|
+
};
|
|
18
|
+
export type ResolvedSetFile = ResolvedBytesFile | ResolvedUrlFile;
|
|
19
|
+
export declare function parseResolvedFiles(params: unknown): ResolvedSetFile[];
|
|
20
|
+
export declare function fileFromBytes(file: ResolvedBytesFile): File;
|
|
21
|
+
export declare function fileFromUrl(file: ResolvedUrlFile): Promise<File>;
|
|
22
|
+
export declare function assertSetFilesEffect(el: HTMLInputElement, refId: string, expectedNames: string[]): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type InvalidFormControl = {
|
|
2
|
+
refId: string | undefined;
|
|
3
|
+
tag: string;
|
|
4
|
+
role: string;
|
|
5
|
+
name: string | undefined;
|
|
6
|
+
field: string | undefined;
|
|
7
|
+
error: string;
|
|
8
|
+
value: string | undefined;
|
|
9
|
+
required: boolean;
|
|
10
|
+
validationMessage: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare function invalidFormControls(form: HTMLFormElement): InvalidFormControl[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const logger: {
|
|
2
|
+
debug: (event: string, meta?: Record<string, unknown>) => void;
|
|
3
|
+
info: (event: string, meta?: Record<string, unknown>) => void;
|
|
4
|
+
warn: (event: string, meta?: Record<string, unknown>) => void;
|
|
5
|
+
error: (event: string, meta?: Record<string, unknown>) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function initContentScriptLogger(): void;
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
__jsNotebookSetLogLevel?: (level: string) => void;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function installMessageListener(): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { InlineSnapshotNode, InlineSnapshotResult } from '../shared/cross/collect-inline-snapshot.js';
|
|
2
|
+
|
|
3
|
+
export interface ObservedTarget {
|
|
4
|
+
element: Element;
|
|
5
|
+
fingerprint: TargetFingerprint;
|
|
6
|
+
}
|
|
7
|
+
export interface TargetFingerprint {
|
|
8
|
+
tag: string;
|
|
9
|
+
role: string;
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
/** Reset state — used by tests and on content-script load. */
|
|
13
|
+
export declare function resetLease(): void;
|
|
14
|
+
/**
|
|
15
|
+
* A snapshot succeeded; the page is now observed. Returns the new observationId.
|
|
16
|
+
* Pass the refId→element mapping so requireTarget can re-validate identity later.
|
|
17
|
+
*/
|
|
18
|
+
export declare function grantObservation(observed?: ReadonlyArray<{
|
|
19
|
+
refId: string;
|
|
20
|
+
element: Element;
|
|
21
|
+
}>): string;
|
|
22
|
+
/** Page state may have diverged; require a fresh observation before any action. */
|
|
23
|
+
export declare function invalidateLease(): void;
|
|
24
|
+
export declare function hasActiveObservation(): boolean;
|
|
25
|
+
export declare function currentObservationId(): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Re-validate the target at action time. Throws a structured agent error if:
|
|
28
|
+
* - the lease has no active observation
|
|
29
|
+
* - the refId is not part of the latest observation
|
|
30
|
+
* - the element was disconnected or replaced
|
|
31
|
+
* - the semantic fingerprint changed (role/name/tag rewrite)
|
|
32
|
+
*
|
|
33
|
+
* Returns the validated element on success.
|
|
34
|
+
*/
|
|
35
|
+
export declare function requireTarget(refId: string, action: string): Element;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve a label against the latest observation. Throws E_AMBIGUOUS_TARGET
|
|
38
|
+
* if multiple observed targets share the label. Returns the unique element.
|
|
39
|
+
*/
|
|
40
|
+
export declare function requireTargetByLabel(label: string, action: string): Element;
|
|
41
|
+
/** Re-grant snapshot attached to lease-violation errors. */
|
|
42
|
+
export interface RefreshSnapshot {
|
|
43
|
+
nodes: InlineSnapshotNode[];
|
|
44
|
+
observationId: string;
|
|
45
|
+
url: string;
|
|
46
|
+
title: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Collect an inline snapshot and grant the lease over every refId-bearing
|
|
50
|
+
* element it produced. Shared logic for snapshot-time grant and error-path
|
|
51
|
+
* refresh so the collect→resolve→grant sequence has one definition.
|
|
52
|
+
*/
|
|
53
|
+
export declare function grantFromInlineSnapshot(maxNodes: number): InlineSnapshotResult & {
|
|
54
|
+
observationId: string;
|
|
55
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export type ContentScriptHandler = (params: unknown, signal?: AbortSignal) => unknown | Promise<unknown>;
|
|
4
|
+
export type ContentScriptHandlerSpec = {
|
|
5
|
+
registryAction: string;
|
|
6
|
+
handlerKey: string;
|
|
7
|
+
params: z.ZodSchema<unknown>;
|
|
8
|
+
returns: z.ZodSchema<unknown>;
|
|
9
|
+
};
|
|
10
|
+
export declare function registerContentScriptSpec(spec: ContentScriptHandlerSpec): void;
|
|
11
|
+
export declare function getContentScriptSpec(registryAction: string): ContentScriptHandlerSpec | undefined;
|
|
12
|
+
/** Register content-script handler specs and announce readiness to the host. */
|
|
13
|
+
export declare function registerContentScriptSpecs(specs: ContentScriptHandlerSpec[]): void;
|
|
14
|
+
export declare function cancelContentScriptCall(callId: string): boolean;
|
|
15
|
+
export declare function dispatchContentScriptCall(registryAction: string, _handlerKey: string, handler: ContentScriptHandler, params: unknown, callId?: string): Promise<{
|
|
16
|
+
ok: true;
|
|
17
|
+
value: unknown;
|
|
18
|
+
} | {
|
|
19
|
+
ok: false;
|
|
20
|
+
error: {
|
|
21
|
+
message: string;
|
|
22
|
+
code: string;
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ContentScriptHandlerSpec } from './registry.js';
|
|
2
|
+
|
|
3
|
+
/** Infra-only schemas for non-registryCall messages (ping connectivity probe). */
|
|
4
|
+
export declare function buildInfraContentScriptSpecs(): ContentScriptHandlerSpec[];
|
|
5
|
+
export declare function buildContentScriptSpecs(): ContentScriptHandlerSpec[];
|