@pi-oxide/extension-js 0.12.3 → 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.
Files changed (145) hide show
  1. package/content-script/action-result.d.ts +4 -0
  2. package/content-script/dom-tree.d.ts +28 -0
  3. package/content-script/dom-utils.d.ts +37 -0
  4. package/content-script/file-resolution.d.ts +22 -0
  5. package/content-script/form-validation.d.ts +12 -0
  6. package/content-script/handlers.d.ts +3 -0
  7. package/content-script/index.d.ts +6 -0
  8. package/content-script/listbox.d.ts +7 -0
  9. package/content-script/logger.d.ts +12 -0
  10. package/content-script/message-router.d.ts +1 -0
  11. package/content-script/observation-lease.d.ts +55 -0
  12. package/content-script/registry.d.ts +24 -0
  13. package/content-script/schemas.d.ts +5 -0
  14. package/content-script/snapshot.d.ts +3 -0
  15. package/content-script.js +3 -3
  16. package/extension_js.d.ts +11 -3
  17. package/extension_js.js +25949 -16750
  18. package/index.js +2242 -1773
  19. package/main/index.d.ts +8 -0
  20. package/main/runner/chrome/internals.d.ts +9 -0
  21. package/main/runner/chrome/native.d.ts +6 -0
  22. package/main/runner/command.d.ts +3 -0
  23. package/main/runner/dom/snapshot.d.ts +8 -0
  24. package/main/runner/fetch.d.ts +4 -0
  25. package/main/runner/host.d.ts +3 -0
  26. package/main/runner/index.d.ts +2 -0
  27. package/main/runner/lib/constants.d.ts +14 -0
  28. package/main/runner/lib/host-registry.d.ts +6 -0
  29. package/main/runner/lib/network-tracker.d.ts +16 -0
  30. package/main/runner/lib/params-helpers.d.ts +2 -0
  31. package/main/runner/lib/params.d.ts +5 -0
  32. package/main/runner/lib/types.d.ts +116 -0
  33. package/main/runner/runtime.d.ts +15 -0
  34. package/main/runner/sidepanel/dom.d.ts +6 -0
  35. package/main/runner/snapshot-merge.d.ts +8 -0
  36. package/main/runner/tab/execute.d.ts +24 -0
  37. package/main/runner/tools/aliases.d.ts +1 -0
  38. package/main/runner/tools/chrome/action.d.ts +1 -0
  39. package/main/runner/tools/chrome/alarms.d.ts +1 -0
  40. package/main/runner/tools/chrome/bookmarks.d.ts +1 -0
  41. package/main/runner/tools/chrome/browsing-data.d.ts +1 -0
  42. package/main/runner/tools/chrome/capability.d.ts +30 -0
  43. package/main/runner/tools/chrome/context-menus.d.ts +1 -0
  44. package/main/runner/tools/chrome/cookies.d.ts +1 -0
  45. package/main/runner/tools/chrome/declarative-net-request.d.ts +1 -0
  46. package/main/runner/tools/chrome/desktop-capture.d.ts +1 -0
  47. package/main/runner/tools/chrome/downloads.d.ts +1 -0
  48. package/main/runner/tools/chrome/history.d.ts +1 -0
  49. package/main/runner/tools/chrome/identity.d.ts +1 -0
  50. package/main/runner/tools/chrome/idle.d.ts +1 -0
  51. package/main/runner/tools/chrome/index.d.ts +1 -0
  52. package/main/runner/tools/chrome/management.d.ts +1 -0
  53. package/main/runner/tools/chrome/notifications.d.ts +1 -0
  54. package/main/runner/tools/chrome/offscreen.d.ts +1 -0
  55. package/main/runner/tools/chrome/page-capture.d.ts +1 -0
  56. package/main/runner/tools/chrome/permissions.d.ts +1 -0
  57. package/main/runner/tools/chrome/register-helpers.d.ts +9 -0
  58. package/main/runner/tools/chrome/runtime.d.ts +1 -0
  59. package/main/runner/tools/chrome/scripting.d.ts +1 -0
  60. package/main/runner/tools/chrome/sessions.d.ts +1 -0
  61. package/main/runner/tools/chrome/side-panel.d.ts +1 -0
  62. package/main/runner/tools/chrome/system.d.ts +1 -0
  63. package/main/runner/tools/chrome/tab-groups.d.ts +1 -0
  64. package/main/runner/tools/chrome/tabs.d.ts +1 -0
  65. package/main/runner/tools/chrome/top-sites.d.ts +1 -0
  66. package/main/runner/tools/chrome/windows.d.ts +1 -0
  67. package/main/runner/tools/chrome-storage.d.ts +1 -0
  68. package/main/runner/tools/clipboard.d.ts +1 -0
  69. package/main/runner/tools/dom.d.ts +1 -0
  70. package/main/runner/tools/host-call.d.ts +1 -0
  71. package/main/runner/tools/network.d.ts +1 -0
  72. package/main/runner/tools/page.d.ts +1 -0
  73. package/main/runner/tools/sidepanel.d.ts +1 -0
  74. package/main/runner/tools/storage.d.ts +1 -0
  75. package/main/runner/tools/tab.d.ts +1 -0
  76. package/main/session/extension-session.d.ts +106 -0
  77. package/main/tab-context.d.ts +12 -0
  78. package/package.json +5 -2
  79. package/shared/array-buffer.d.ts +4 -0
  80. package/shared/collect-inline-snapshot.d.ts +50 -0
  81. package/shared/cross/agent-errors.d.ts +28 -0
  82. package/shared/cross/array-buffer.d.ts +4 -0
  83. package/shared/cross/collect-inline-snapshot.d.ts +58 -0
  84. package/shared/cross/content-script-actions.d.ts +7 -0
  85. package/shared/cross/content-script-tools.d.ts +3 -0
  86. package/shared/cross/dispatch.d.ts +5 -0
  87. package/shared/cross/fetch-response.d.ts +12 -0
  88. package/shared/cross/format-types.d.ts +43 -0
  89. package/shared/cross/fs-types.d.ts +81 -0
  90. package/shared/cross/generated.d.ts +328 -0
  91. package/shared/cross/manifest.d.ts +130 -0
  92. package/shared/cross/normalize-agent-error.d.ts +17 -0
  93. package/shared/cross/page-specs.d.ts +7 -0
  94. package/shared/cross/schemas/chrome.d.ts +56 -0
  95. package/shared/cross/schemas/clipboard.d.ts +19 -0
  96. package/shared/cross/schemas/fs.d.ts +65 -0
  97. package/shared/cross/schemas/helpers.d.ts +71 -0
  98. package/shared/cross/schemas/host.d.ts +15 -0
  99. package/shared/cross/schemas/network.d.ts +34 -0
  100. package/shared/cross/schemas/page.d.ts +494 -0
  101. package/shared/cross/schemas/returns.d.ts +8791 -0
  102. package/shared/cross/schemas/sidepanel.d.ts +284 -0
  103. package/shared/cross/schemas/snapshot.d.ts +272 -0
  104. package/shared/cross/schemas/storage.d.ts +60 -0
  105. package/shared/cross/schemas/tab.d.ts +597 -0
  106. package/shared/cross/schemas.d.ts +12 -0
  107. package/shared/cross/snapshot-filter.d.ts +15 -0
  108. package/shared/cross/tab-specs.d.ts +3 -0
  109. package/shared/cross/types.d.ts +12 -0
  110. package/shared/cross/zod-to-docs.d.ts +28 -0
  111. package/shared/cs/ref-id.d.ts +5 -0
  112. package/shared/cs/snapshot-dom.d.ts +47 -0
  113. package/shared/fetch-response.d.ts +12 -0
  114. package/shared/fs-types.d.ts +81 -0
  115. package/shared/generated.d.ts +241 -0
  116. package/shared/log-levels.d.ts +5 -0
  117. package/shared/logger.d.ts +18 -0
  118. package/shared/main/content-script-response.d.ts +5 -0
  119. package/shared/main/define-content-script-tool.d.ts +7 -0
  120. package/shared/main/log-levels.d.ts +5 -0
  121. package/shared/main/logger.d.ts +18 -0
  122. package/shared/main/routes.d.ts +14 -0
  123. package/shared/main/tool-registry.d.ts +19 -0
  124. package/shared/ref-id.d.ts +5 -0
  125. package/shared/registry/agent-errors.d.ts +27 -0
  126. package/shared/registry/content-script-actions.d.ts +7 -0
  127. package/shared/registry/content-script-response.d.ts +5 -0
  128. package/shared/registry/content-script-tools.d.ts +13 -0
  129. package/shared/registry/define-content-script-tool.d.ts +7 -0
  130. package/shared/registry/dispatch.d.ts +5 -0
  131. package/shared/registry/manifest.d.ts +130 -0
  132. package/shared/registry/normalize-agent-error.d.ts +17 -0
  133. package/shared/registry/routes.d.ts +14 -0
  134. package/shared/registry/types.d.ts +12 -0
  135. package/shared/registry/zod-to-docs.d.ts +28 -0
  136. package/shared/schemas.d.ts +10663 -0
  137. package/shared/snapshot-dom.d.ts +47 -0
  138. package/shared/snapshot-filter.d.ts +15 -0
  139. package/shared/tool-registry.d.ts +19 -0
  140. package/worker/binary-blob-store.d.ts +12 -0
  141. package/worker/fetch-store.d.ts +1 -0
  142. package/worker/resolve-set-files.d.ts +22 -0
  143. package/worker/vfs-write-cache.d.ts +3 -0
  144. package/worker/worker.d.ts +84 -0
  145. package/worker.js +1852 -1695
@@ -0,0 +1,47 @@
1
+ /** Shared DOM helpers for inline snapshots (content script + MAIN-world injection). */
2
+ export { allocateRefId, getNextRefId, syncRefIdCounterFromDom, } from './ref-id.js';
3
+ export declare const INTERACTIVE_SELECTOR = "input, textarea, select, button, a, [role=\"button\"], [role=\"link\"]";
4
+ export declare function readFormFields(el: Element): {
5
+ value?: string;
6
+ checked?: boolean;
7
+ disabled?: boolean;
8
+ readOnly?: boolean;
9
+ selected?: boolean;
10
+ required?: boolean;
11
+ valid?: boolean;
12
+ invalid?: boolean;
13
+ validationMessage?: string;
14
+ errorMessage?: string;
15
+ };
16
+ export declare function readErrorMessage(el: Element): string | undefined;
17
+ export declare function enrichFormNode(el: Element, node: {
18
+ value?: string;
19
+ checked?: boolean;
20
+ disabled?: boolean;
21
+ readOnly?: boolean;
22
+ selected?: boolean;
23
+ required?: boolean;
24
+ valid?: boolean;
25
+ invalid?: boolean;
26
+ validationMessage?: string;
27
+ errorMessage?: string;
28
+ }): void;
29
+ export declare function resolveAbsoluteUrl(attr: string | null): string | undefined;
30
+ export declare function resolveContainerRefId(el: Element): string | undefined;
31
+ export declare function resolvePermalinkLink(el: Element): HTMLAnchorElement | null;
32
+ export declare function getAccessibleRole(el: Element): string;
33
+ export declare function hasDirectTextContent(el: Element): boolean;
34
+ export declare function getOwnVisibleText(el: Element, maxLen?: number): string;
35
+ export declare function isSelfOrAncestorHidden(el: Element): boolean;
36
+ /** Include if the element would remain visible in a Markdown rendering. */
37
+ export declare function isMarkdownVisible(el: Element): boolean;
38
+ export declare function getAccessibleName(el: Element): string;
39
+ export declare function shouldInclude(el: Element): boolean;
40
+ /** Detect a hidden validation-shim input inside a combobox wrapper (react-select).
41
+ * These inputs carry required/aria-required for form validation but are not
42
+ * user-visible; they must appear in the snapshot labeled as validation-proxy. */
43
+ export declare function isValidationProxyInput(el: Element): boolean;
44
+ /** Resolve a human-readable field label from <label> element associations.
45
+ * Tries: accessible name → label[for=id] → wrapping <label> → preceding sibling
46
+ * <label> → parent's first <label> child. Falls back to the refId. */
47
+ export declare function resolveFieldLabel(el: Element | null, fallback: string): string;
@@ -0,0 +1,12 @@
1
+ export type FetchValue = {
2
+ status: number;
3
+ ok: boolean;
4
+ headers: Record<string, string>;
5
+ body: string;
6
+ bodyEncoding: "text" | "base64";
7
+ byteLength: number;
8
+ contentType: string;
9
+ finalUrl: string;
10
+ };
11
+ /** Encode a fetch Response for page.fetch / web.fetch with binary-safe handling. */
12
+ export declare function encodeFetchResponse(resp: Response): Promise<FetchValue>;
@@ -0,0 +1,81 @@
1
+ import { FsBoolResult, FsCopyParams, FsExistsResult, FsHashParams, FsHashResult, FsListResult, FsPathParams, FsReadRangeDataParams, FsReadRangeParams, FsStatResult, FsStringResult, FsWriteParams, FsWriteResult } from '../../pkg/extension_js.js';
2
+
3
+ export type FsActionMap = {
4
+ exists: {
5
+ params: FsPathParams;
6
+ result: FsExistsResult;
7
+ };
8
+ stat: {
9
+ params: FsPathParams;
10
+ result: FsStatResult;
11
+ };
12
+ read: {
13
+ params: FsPathParams;
14
+ result: FsStringResult;
15
+ };
16
+ readText: {
17
+ params: FsPathParams;
18
+ result: FsStringResult;
19
+ };
20
+ readBase64: {
21
+ params: FsPathParams;
22
+ result: FsStringResult;
23
+ };
24
+ list: {
25
+ params: FsPathParams;
26
+ result: FsListResult;
27
+ };
28
+ mkdir: {
29
+ params: FsPathParams;
30
+ result: FsBoolResult;
31
+ };
32
+ delete: {
33
+ params: FsPathParams;
34
+ result: FsBoolResult;
35
+ };
36
+ copy: {
37
+ params: FsCopyParams;
38
+ result: FsBoolResult;
39
+ };
40
+ move: {
41
+ params: FsCopyParams;
42
+ result: FsBoolResult;
43
+ };
44
+ write: {
45
+ params: FsWriteParams;
46
+ result: FsWriteResult;
47
+ };
48
+ writeText: {
49
+ params: FsWriteParams;
50
+ result: FsWriteResult;
51
+ };
52
+ writeBase64: {
53
+ params: FsWriteParams;
54
+ result: FsWriteResult;
55
+ };
56
+ append: {
57
+ params: FsWriteParams;
58
+ result: FsWriteResult;
59
+ };
60
+ appendText: {
61
+ params: FsWriteParams;
62
+ result: FsWriteResult;
63
+ };
64
+ appendBase64: {
65
+ params: FsWriteParams;
66
+ result: FsWriteResult;
67
+ };
68
+ readRange: {
69
+ params: FsReadRangeParams;
70
+ result: FsStringResult;
71
+ };
72
+ update: {
73
+ params: FsReadRangeDataParams;
74
+ result: FsBoolResult;
75
+ };
76
+ hash: {
77
+ params: FsHashParams;
78
+ result: FsHashResult;
79
+ };
80
+ };
81
+ export type FsAction = keyof FsActionMap;
@@ -0,0 +1,241 @@
1
+ import { TreeSnapshot } from '@pi-oxide/dom-semantic-tree';
2
+
3
+ export type CommandParams = FetchParams | SleepParams | PageClickParams | PageDblClickParams | PageFillParams | PageTypeParams | PagePressParams | PageSelectParams | PageSelectOptionParams | PageCheckParams | PageHoverParams | PageScrollParams | PageScrollToParams | PageGotoParams | PageFindParams | PageWaitForParams | PageExtractParams | PageAppendParams | PageWaitParams | StorageGetParams | StorageSetParams | StorageDeleteParams | DomSnapshotParams | DomFormatParams | TabClickParams | TabFillParams | TabEvaluateParams | TabBackParams | TabWaitForLoadParams | TabScrollToParams | TabTypeParams | TabPressParams | TabSelectParams | TabSelectOptionParams | TabCheckParams | TabHoverParams | TabUnhoverParams | TabScrollParams | TabDblClickParams | FsWriteParams | FsPathParams | FsCopyParams | FsUpdateParams | FsHashParams | FsReadRangeParams;
4
+ export type AsyncCommand = {
5
+ call_id: number;
6
+ action: string;
7
+ params: CommandParams;
8
+ run_id?: string;
9
+ };
10
+ export type CellError = {
11
+ kind: "compile";
12
+ name: string | null;
13
+ message: string;
14
+ line: number | null;
15
+ } | {
16
+ kind: "runtime";
17
+ name: string | null;
18
+ message: string;
19
+ line: number | null;
20
+ action: string | null;
21
+ code: string | null;
22
+ stack: string | null;
23
+ } | {
24
+ kind: "fuel_exhausted";
25
+ } | {
26
+ kind: "internal";
27
+ message: string;
28
+ };
29
+ export type CellStatus = "done" | "async_pending";
30
+ export type DomSnapshotParams = {
31
+ interactive_only: boolean;
32
+ max_nodes: bigint;
33
+ };
34
+ export type DomFormatParams = {
35
+ snapshot: TreeSnapshot;
36
+ format?: string;
37
+ };
38
+ export type FetchParams = {
39
+ url: string;
40
+ method: string;
41
+ headers: Record<string, string>;
42
+ body: string | null;
43
+ timeout: bigint;
44
+ };
45
+ export type FsCopyParams = {
46
+ from: string;
47
+ to: string;
48
+ };
49
+ export type FsHashParams = {
50
+ path: string;
51
+ algo: string;
52
+ };
53
+ export type FsPathParams = {
54
+ path: string;
55
+ };
56
+ export type FsReadRangeParams = {
57
+ path: string;
58
+ offset: bigint;
59
+ len: number;
60
+ };
61
+ export type FsUpdateParams = {
62
+ path: string;
63
+ offset: bigint;
64
+ data: string;
65
+ };
66
+ export type FsWriteParams = {
67
+ path: string;
68
+ data: string;
69
+ };
70
+ export type PageAppendParams = {
71
+ refId?: string;
72
+ label?: string;
73
+ text: string;
74
+ };
75
+ export type PageCheckParams = {
76
+ refId?: string;
77
+ label?: string;
78
+ checked: boolean;
79
+ };
80
+ export type PageClickParams = {
81
+ refId?: string;
82
+ label?: string;
83
+ };
84
+ export type PageDblClickParams = {
85
+ refId?: string;
86
+ label?: string;
87
+ };
88
+ export type PageExtractParams = {
89
+ fields: string[];
90
+ };
91
+ export type PageFillParams = {
92
+ refId?: string;
93
+ label?: string;
94
+ value: string;
95
+ };
96
+ export type PageFindParams = {
97
+ selector: string;
98
+ };
99
+ export type PageGotoParams = {
100
+ url: string;
101
+ };
102
+ export type PageHoverParams = {
103
+ refId?: string;
104
+ label?: string;
105
+ };
106
+ export type PageSubmitParams = {
107
+ refId?: string;
108
+ label?: string;
109
+ };
110
+ export type PageCheckRadioParams = {
111
+ name: string;
112
+ value: string;
113
+ };
114
+ export type PagePressParams = {
115
+ refId?: string;
116
+ label?: string;
117
+ key: string;
118
+ };
119
+ export type PageScrollParams = {
120
+ direction: string;
121
+ amount: number;
122
+ };
123
+ export type PageScrollToParams = {
124
+ refId?: string;
125
+ label?: string;
126
+ x?: number;
127
+ y?: number;
128
+ };
129
+ export type PageSelectParams = {
130
+ refId?: string;
131
+ label?: string;
132
+ value: string | string[];
133
+ };
134
+ export type PageSelectOptionParams = {
135
+ refId?: string;
136
+ label?: string;
137
+ value: string;
138
+ };
139
+ export type PageTypeParams = {
140
+ refId?: string;
141
+ label?: string;
142
+ text: string;
143
+ };
144
+ export type PageWaitForParams = {
145
+ selector: string;
146
+ timeout: bigint;
147
+ };
148
+ export type PageWaitParams = {
149
+ duration: bigint;
150
+ };
151
+ export type RunResult = {
152
+ stdout: string[];
153
+ stderr: string[];
154
+ result: string | null;
155
+ error: CellError | null;
156
+ commands: CommandParams[];
157
+ fuel_exhausted: boolean;
158
+ execution_count: number;
159
+ status: CellStatus;
160
+ pending_commands: AsyncCommand[];
161
+ };
162
+ export type SleepParams = {
163
+ duration: bigint;
164
+ };
165
+ export type StorageDeleteParams = {
166
+ key: string;
167
+ };
168
+ export type StorageGetParams = {
169
+ key: string;
170
+ };
171
+ export type StorageSetParams = {
172
+ key: string;
173
+ value: string;
174
+ };
175
+ export type TabBackParams = {
176
+ tabId: bigint;
177
+ };
178
+ export type TabCheckParams = {
179
+ tabId: bigint;
180
+ refId: string;
181
+ checked: boolean;
182
+ };
183
+ export type TabClickParams = {
184
+ tabId: bigint;
185
+ refId: string;
186
+ };
187
+ export type TabDblClickParams = {
188
+ tabId: bigint;
189
+ refId: string;
190
+ };
191
+ export type TabEvaluateParams = {
192
+ tabId: bigint;
193
+ script: string;
194
+ };
195
+ export type TabFillParams = {
196
+ tabId: bigint;
197
+ refId: string;
198
+ value: string;
199
+ };
200
+ export type TabHoverParams = {
201
+ tabId: bigint;
202
+ refId: string;
203
+ };
204
+ export type TabPressParams = {
205
+ tabId: bigint;
206
+ key: string;
207
+ };
208
+ export type TabScrollParams = {
209
+ tabId: bigint;
210
+ direction: string;
211
+ amount: number;
212
+ };
213
+ export type TabScrollToParams = {
214
+ tabId: bigint;
215
+ x?: number;
216
+ y?: number;
217
+ refId?: string;
218
+ label?: string;
219
+ };
220
+ export type TabSelectParams = {
221
+ tabId: bigint;
222
+ refId: string;
223
+ value: string;
224
+ };
225
+ export type TabSelectOptionParams = {
226
+ tabId: bigint;
227
+ refId: string;
228
+ value: string;
229
+ };
230
+ export type TabTypeParams = {
231
+ tabId: bigint;
232
+ refId: string;
233
+ text: string;
234
+ };
235
+ export type TabUnhoverParams = {
236
+ tabId: bigint;
237
+ };
238
+ export type TabWaitForLoadParams = {
239
+ tabId: bigint;
240
+ timeout: bigint;
241
+ };
@@ -0,0 +1,5 @@
1
+ import { LogLevel } from './logger.js';
2
+
3
+ /** Numeric levels shared by JS logger and Rust WASM tracing filter. */
4
+ export declare const LOG_LEVEL_NUMERIC: Record<LogLevel, number>;
5
+ export declare function numericToLogLevel(level: number): LogLevel;
@@ -0,0 +1,18 @@
1
+ export type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "none";
2
+ export { LOG_LEVEL_NUMERIC, numericToLogLevel } from './log-levels.js';
3
+ export declare function setLogLevel(level: LogLevel): void;
4
+ export declare function getLogLevel(): LogLevel;
5
+ export declare function registerWasmSetLogLevel(fn: (level: number) => void): void;
6
+ export declare class Logger {
7
+ private namespace;
8
+ constructor(namespace?: string);
9
+ private log;
10
+ trace(event: string, ...rest: unknown[]): void;
11
+ debug(event: string, ...rest: unknown[]): void;
12
+ info(event: string, ...rest: unknown[]): void;
13
+ warn(event: string, ...rest: unknown[]): void;
14
+ error(event: string, ...rest: unknown[]): void;
15
+ child(namespace: string): Logger;
16
+ timer(event: string, metadata?: Record<string, unknown>, level?: LogLevel): (finishMetadata?: Record<string, unknown>) => void;
17
+ }
18
+ export declare const logger: Logger;
@@ -0,0 +1,5 @@
1
+ import { AsyncError, AsyncResponse } from '../cross/manifest.js';
2
+
3
+ /** Preserve structured content-script errors; fall back for legacy string/malformed shapes. */
4
+ export declare function parseAsyncError(raw: unknown, fallback?: AsyncError): AsyncError;
5
+ export declare function unwrapContentScriptMessage(result: unknown): AsyncResponse;
@@ -0,0 +1,7 @@
1
+ import { ContentScriptToolSpec } from '../cross/content-script-tools.js';
2
+
3
+ /** Register a content-script tool on the main thread.
4
+ * - Adds a manifest entry via registerContentScriptJsCall
5
+ * - Adds the action to the dynamic content-script action set
6
+ * Does NOT call registerContentScriptSpec (content script registers its own specs). */
7
+ export declare function defineContentScriptTool<P, R>(spec: ContentScriptToolSpec<P, R>): void;
@@ -0,0 +1,5 @@
1
+ import { LogLevel } from './logger.js';
2
+
3
+ /** Numeric levels shared by JS logger and Rust WASM tracing filter. */
4
+ export declare const LOG_LEVEL_NUMERIC: Record<LogLevel, number>;
5
+ export declare function numericToLogLevel(level: number): LogLevel;
@@ -0,0 +1,18 @@
1
+ export type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "none";
2
+ export { LOG_LEVEL_NUMERIC, numericToLogLevel } from './log-levels.js';
3
+ export declare function setLogLevel(level: LogLevel): void;
4
+ export declare function getLogLevel(): LogLevel;
5
+ export declare function registerWasmSetLogLevel(fn: (level: number) => void): void;
6
+ export declare class Logger {
7
+ private namespace;
8
+ constructor(namespace?: string);
9
+ private log;
10
+ trace(event: string, ...rest: unknown[]): void;
11
+ debug(event: string, ...rest: unknown[]): void;
12
+ info(event: string, ...rest: unknown[]): void;
13
+ warn(event: string, ...rest: unknown[]): void;
14
+ error(event: string, ...rest: unknown[]): void;
15
+ child(namespace: string): Logger;
16
+ timer(event: string, metadata?: Record<string, unknown>, level?: LogLevel): (finishMetadata?: Record<string, unknown>) => void;
17
+ }
18
+ export declare const logger: Logger;
@@ -0,0 +1,14 @@
1
+ import { ExecutionContextId } from '../cross/manifest.js';
2
+ import { Route, TabPolicy } from '../cross/types.js';
3
+
4
+ export declare function setRoute(action: string, route: Route): void;
5
+ export declare function getRoute(action: string): Route | undefined;
6
+ export declare function clearRoutes(): void;
7
+ export declare function inferTabPolicy(action: string): TabPolicy;
8
+ export declare function inferEndpoint(owner: ExecutionContextId): Route["endpoint"];
9
+ export declare function inferOwner(action: string, owner: ExecutionContextId): ExecutionContextId;
10
+ export declare function routeFromOwner(action: string, owner: ExecutionContextId): Route;
11
+ export declare function populateRoutesFromManifest(entries: Array<{
12
+ action: string;
13
+ owner: ExecutionContextId;
14
+ }>): void;
@@ -0,0 +1,19 @@
1
+ import { AsyncResponse, JsCallSpec, SerializableJsCallManifestEntry, ToolDefinition, ToolDoc } from '../cross/manifest.js';
2
+
3
+ export type { AsyncError, AsyncResponse, CallContext, Command, ExecutionContextId, JsCallSpec, SerializableJsCallManifestEntry, ToolDefinition, ToolDoc, ToolDocParam, } from '../cross/manifest.js';
4
+ export { coerceWasmParams, manifestEntryToWasm } from '../cross/manifest.js';
5
+ export declare function setRunnerAbortController(controller: AbortController | null): void;
6
+ export declare function getRunnerSignal(): AbortSignal | undefined;
7
+ export declare function throwIfAborted(): void;
8
+ /** Manifest-only registration for actions executed in the content script. */
9
+ export declare function registerContentScriptJsCall<P, R>(spec: Omit<JsCallSpec<P, R>, "owner" | "handler">): void;
10
+ export declare function registerJsCall<P, R>(spec: JsCallSpec<P, R>): void;
11
+ export declare function getTool(action: string): ToolDefinition<unknown, unknown> | undefined;
12
+ /** Test-only helper: remove a tool from the tool registry without touching the JS registry. */
13
+ export declare function removeToolForTest(action: string): boolean;
14
+ export declare function clearRegistry(): void;
15
+ export declare function freezeJsRegistry(): void;
16
+ export declare function clearJsRegistry(): void;
17
+ export declare function getSerializableJsManifest(): SerializableJsCallManifestEntry[];
18
+ export declare function dispatchTool(action: string, params: unknown, callId?: number, runId?: string, signal?: AbortSignal): Promise<AsyncResponse>;
19
+ export declare function listTools(): ToolDoc[];
@@ -0,0 +1,5 @@
1
+ /** Monotonic refId allocator synced from existing DOM data-ref-id attributes. */
2
+ export declare function syncRefIdCounterFromDom(): void;
3
+ export declare function allocateRefId(el: Element): string;
4
+ /** @deprecated Use allocateRefId after syncRefIdCounterFromDom */
5
+ export declare function getNextRefId(): string;
@@ -0,0 +1,27 @@
1
+ import { AsyncError } from './manifest.js';
2
+
3
+ export declare function contentScriptMissingError(tabId?: number, url?: string): AsyncError;
4
+ export declare function noTabError(action: string): AsyncError;
5
+ export type StaleRefCandidate = {
6
+ refId: string;
7
+ role?: string;
8
+ name?: string;
9
+ };
10
+ export declare function staleRefError(refId: string, options?: {
11
+ label?: string;
12
+ candidates?: StaleRefCandidate[];
13
+ }): AsyncError;
14
+ export declare function notInteractableError(action: string, refId: string, details?: Record<string, unknown>): AsyncError;
15
+ export declare function observationRequiredError(action: string): AsyncError;
16
+ export declare function ambiguousTargetError(label: string): AsyncError;
17
+ export declare function isContentScriptConnectionError(msg: string): boolean;
18
+ export declare function throwStructuredAgentError(error: AsyncError): never;
19
+ export declare function labelNotFoundError(label: string, candidates?: StaleRefCandidate[], extra?: {
20
+ searchedIds?: string[];
21
+ ignoredIds?: string[];
22
+ targetRefId?: string;
23
+ targetName?: string;
24
+ ariaControlsBefore?: string | null;
25
+ ariaControlsAfter?: string | null;
26
+ isDropdown?: boolean;
27
+ }): AsyncError;
@@ -0,0 +1,7 @@
1
+ export declare function addContentScriptAction(action: string): void;
2
+ export declare function isContentScriptAction(action: string): boolean;
3
+ export declare function getContentScriptActions(): string[];
4
+ /** Test-only helper: clear the dynamic content-script action set. */
5
+ export declare function clearContentScriptActions(): void;
6
+ /** Map registry action (page_click) to content-script handler key (click). */
7
+ export declare function toHandlerAction(action: string): string;
@@ -0,0 +1,5 @@
1
+ import { AsyncError, AsyncResponse } from './manifest.js';
2
+
3
+ /** Preserve structured content-script errors; fall back for legacy string/malformed shapes. */
4
+ export declare function parseAsyncError(raw: unknown, fallback?: AsyncError): AsyncError;
5
+ export declare function unwrapContentScriptMessage(result: unknown): AsyncResponse;
@@ -0,0 +1,13 @@
1
+ import { JsCallSpec } from './manifest.js';
2
+
3
+ export type ContentScriptToolSpec<P = unknown, R = unknown> = Omit<JsCallSpec<P, R>, "owner" | "handler"> & {
4
+ handlerKey: string;
5
+ };
6
+ /** Static build-time list of content-script tool specs.
7
+ * Both main-thread and content-script IIFE bundles import this at build time.
8
+ * Single source of truth for content-script registry tools (page + web.tab).
9
+ *
10
+ * TODO: Mutation returnDoc strings are hand-written pseudo-type-signatures.
11
+ * When PageActionResultSchema changes, update all mutation returnDoc strings
12
+ * to match, or generate them from the schema shape to eliminate drift. */
13
+ export declare const CONTENT_SCRIPT_TOOL_SPECS: readonly ContentScriptToolSpec[];
@@ -0,0 +1,7 @@
1
+ import { ContentScriptToolSpec } from './content-script-tools.js';
2
+
3
+ /** Register a content-script tool on the main thread.
4
+ * - Adds a manifest entry via registerContentScriptJsCall
5
+ * - Adds the action to the dynamic content-script action set
6
+ * Does NOT call registerContentScriptSpec (content script registers its own specs). */
7
+ export declare function defineContentScriptTool<P, R>(spec: ContentScriptToolSpec<P, R>): void;
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ import { AsyncResponse } from './manifest.js';
3
+
4
+ export declare function formatValidationError(action: string, schema: z.ZodTypeAny, issues: z.ZodIssue[], params?: unknown): string;
5
+ export declare function dispatchValidated<P, R>(paramsSchema: z.ZodSchema<P>, returnsSchema: z.ZodSchema<R>, handler: (params: P) => Promise<R> | R, params: unknown, action: string): Promise<AsyncResponse<R>>;