@ineerajrajeev/aios-web-sdk 0.1.1
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/README.md +278 -0
- package/dist/index.cjs +732 -0
- package/dist/index.d.cts +303 -0
- package/dist/index.d.ts +303 -0
- package/dist/index.js +698 -0
- package/package.json +39 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/** Protocol version shared with the Safari extension content script. */
|
|
2
|
+
declare const PROTOCOL_VERSION: "1";
|
|
3
|
+
type PageCapability = "read" | "write" | "execute" | "summarize";
|
|
4
|
+
type ComponentCapability = "readable" | "summarizable" | "clickable" | "writable" | "selectable" | "scrollable" | "draggable" | "focusable" | "hidden";
|
|
5
|
+
type PageType = "job_application" | "checkout" | "account_settings" | "inbox" | "document" | "form" | "dashboard" | "search_results" | "generic";
|
|
6
|
+
type ExportMode = "structured-only" | "dom-allowed";
|
|
7
|
+
type TrustTier = "verified-sdk" | "partial" | "unverified";
|
|
8
|
+
type SeekInputType = "text" | "boolean" | "date" | "file" | "choice" | "number";
|
|
9
|
+
interface PageCapabilities {
|
|
10
|
+
read?: boolean;
|
|
11
|
+
write?: boolean;
|
|
12
|
+
execute?: boolean;
|
|
13
|
+
summarize?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface PagePolicy {
|
|
16
|
+
/** When false the extension must block all agent access on this page. */
|
|
17
|
+
allowed: boolean;
|
|
18
|
+
reason?: string;
|
|
19
|
+
userMessage?: string;
|
|
20
|
+
capabilities?: PageCapabilities;
|
|
21
|
+
exportMode?: ExportMode;
|
|
22
|
+
}
|
|
23
|
+
interface SeekField {
|
|
24
|
+
/** Stable identifier, e.g. "work_authorization". */
|
|
25
|
+
id: string;
|
|
26
|
+
/** Short label shown in consent UI and agent prompts. */
|
|
27
|
+
label: string;
|
|
28
|
+
/** Why the agent needs this from the user. */
|
|
29
|
+
description: string;
|
|
30
|
+
inputType: SeekInputType;
|
|
31
|
+
required?: boolean;
|
|
32
|
+
choices?: string[];
|
|
33
|
+
sensitive?: boolean;
|
|
34
|
+
/** Optional link to a writable component id on the page. */
|
|
35
|
+
mapsToComponentId?: string;
|
|
36
|
+
}
|
|
37
|
+
interface PageContext {
|
|
38
|
+
pageType: PageType;
|
|
39
|
+
title: string;
|
|
40
|
+
description: string;
|
|
41
|
+
/** High-level instruction for the agent, e.g. how to help on a job application. */
|
|
42
|
+
agentIntent: string;
|
|
43
|
+
/** Fields the agent should seek from the user via askUser, not scrape. */
|
|
44
|
+
seekFromUser?: SeekField[];
|
|
45
|
+
policy: PagePolicy;
|
|
46
|
+
}
|
|
47
|
+
type ComponentKind = "button" | "textfield" | "textarea" | "text" | "link" | "select" | "checkbox" | "radio" | "scrollable" | "draggable" | "file" | "custom";
|
|
48
|
+
interface ComponentDescriptor {
|
|
49
|
+
id: string;
|
|
50
|
+
kind: ComponentKind;
|
|
51
|
+
label?: string;
|
|
52
|
+
/** What this control does — reduces agent mistakes. */
|
|
53
|
+
description?: string;
|
|
54
|
+
capabilities: ComponentCapability[];
|
|
55
|
+
value?: string | number | boolean | Record<string, unknown> | null;
|
|
56
|
+
placeholder?: string;
|
|
57
|
+
required?: boolean;
|
|
58
|
+
sensitive?: boolean;
|
|
59
|
+
selector?: string;
|
|
60
|
+
visible?: boolean;
|
|
61
|
+
inputType?: string;
|
|
62
|
+
href?: string;
|
|
63
|
+
trusted?: boolean;
|
|
64
|
+
actionIntent?: "submit" | "cancel" | "navigate" | "download" | string;
|
|
65
|
+
options?: Array<{
|
|
66
|
+
id: string;
|
|
67
|
+
label: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
}>;
|
|
70
|
+
childComponentIds?: string[];
|
|
71
|
+
mapsToSeekField?: string;
|
|
72
|
+
schema?: string;
|
|
73
|
+
}
|
|
74
|
+
interface ContentZones {
|
|
75
|
+
/** CSS selector for primary app content. */
|
|
76
|
+
primary?: string;
|
|
77
|
+
/** Selectors excluded from agent read/summarize/execute. */
|
|
78
|
+
excluded?: string[];
|
|
79
|
+
}
|
|
80
|
+
interface ConsentRecord {
|
|
81
|
+
approvalId: string;
|
|
82
|
+
approvedAt: number;
|
|
83
|
+
approvedBy: "user";
|
|
84
|
+
rememberSite?: boolean;
|
|
85
|
+
}
|
|
86
|
+
interface ConsentPreview {
|
|
87
|
+
title: string;
|
|
88
|
+
message: string;
|
|
89
|
+
pageType: PageType;
|
|
90
|
+
pageTitle: string;
|
|
91
|
+
agentIntent: string;
|
|
92
|
+
seekFromUser: SeekField[];
|
|
93
|
+
sensitiveFieldCount: number;
|
|
94
|
+
componentCount: number;
|
|
95
|
+
capabilities: PageCapabilities;
|
|
96
|
+
}
|
|
97
|
+
interface ConsentRequestOptions {
|
|
98
|
+
title?: string;
|
|
99
|
+
message?: string;
|
|
100
|
+
/** If true, user can opt to remember approval for this origin. */
|
|
101
|
+
allowRememberSite?: boolean;
|
|
102
|
+
}
|
|
103
|
+
interface StructuredPagePayload {
|
|
104
|
+
version: typeof PROTOCOL_VERSION;
|
|
105
|
+
appId: string;
|
|
106
|
+
route: string;
|
|
107
|
+
url: string;
|
|
108
|
+
page: PageContext;
|
|
109
|
+
data: Record<string, unknown>;
|
|
110
|
+
components: ComponentDescriptor[];
|
|
111
|
+
zones?: ContentZones;
|
|
112
|
+
meta: {
|
|
113
|
+
generatedAt: number;
|
|
114
|
+
source: "sdk";
|
|
115
|
+
trust: TrustTier;
|
|
116
|
+
consent: ConsentRecord;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
interface InitOptions {
|
|
120
|
+
appId: string;
|
|
121
|
+
/** Require user consent before any payload reaches the extension. Default: true. */
|
|
122
|
+
requireConsent?: boolean;
|
|
123
|
+
/** SDK protocol version sent during handshake. */
|
|
124
|
+
version?: string;
|
|
125
|
+
}
|
|
126
|
+
interface ExportOptions {
|
|
127
|
+
schema?: string;
|
|
128
|
+
data?: Record<string, unknown>;
|
|
129
|
+
components?: ComponentDescriptor[];
|
|
130
|
+
page?: Partial<PageContext>;
|
|
131
|
+
zones?: ContentZones;
|
|
132
|
+
}
|
|
133
|
+
interface MarkComponentInput extends Omit<ComponentDescriptor, "id"> {
|
|
134
|
+
id?: string;
|
|
135
|
+
}
|
|
136
|
+
/** Messages posted from the page to the extension content script. */
|
|
137
|
+
type BridgeMessageType = "aios-sdk:init" | "aios-sdk:policy" | "aios-sdk:context" | "aios-sdk:zones" | "aios-sdk:components" | "aios-sdk:export" | "aios-sdk:ping" | "aios-sdk:presence-query";
|
|
138
|
+
/** Events the extension emits so integrated apps can detect AI agent usage. */
|
|
139
|
+
type ExtensionEventType = "extension:present" | "extension:status" | "agent:session-start" | "agent:active" | "agent:session-end" | "agent:data-access";
|
|
140
|
+
interface ExtensionPresentPayload {
|
|
141
|
+
extensionVersion: string;
|
|
142
|
+
contentScriptVersion: string;
|
|
143
|
+
}
|
|
144
|
+
interface ExtensionStatusPayload {
|
|
145
|
+
present: boolean;
|
|
146
|
+
agentSessionActive: boolean;
|
|
147
|
+
lastAgentActivityAt: number | null;
|
|
148
|
+
sessionId: string | null;
|
|
149
|
+
sdkConnected: boolean;
|
|
150
|
+
appId: string | null;
|
|
151
|
+
}
|
|
152
|
+
interface AgentSessionPayload {
|
|
153
|
+
sessionId: string;
|
|
154
|
+
route: string;
|
|
155
|
+
}
|
|
156
|
+
interface AgentActivePayload {
|
|
157
|
+
sessionId: string;
|
|
158
|
+
action: string;
|
|
159
|
+
capability: PageCapability | "navigate" | "unknown";
|
|
160
|
+
route: string;
|
|
161
|
+
appId: string | null;
|
|
162
|
+
sdkIntegrated: boolean;
|
|
163
|
+
success: boolean;
|
|
164
|
+
blocked?: boolean;
|
|
165
|
+
error?: string | null;
|
|
166
|
+
timestamp: number;
|
|
167
|
+
}
|
|
168
|
+
interface AgentDataAccessPayload {
|
|
169
|
+
sessionId: string | null;
|
|
170
|
+
route: string;
|
|
171
|
+
appId: string | null;
|
|
172
|
+
approvalId?: string;
|
|
173
|
+
source: "user-consent" | "agent-read";
|
|
174
|
+
action?: string;
|
|
175
|
+
}
|
|
176
|
+
type ExtensionEventPayload = ExtensionPresentPayload | ExtensionStatusPayload | AgentSessionPayload | AgentActivePayload | AgentDataAccessPayload;
|
|
177
|
+
interface ExtensionEvent<T extends ExtensionEventPayload = ExtensionEventPayload> {
|
|
178
|
+
type: ExtensionEventType;
|
|
179
|
+
timestamp: number;
|
|
180
|
+
version: string;
|
|
181
|
+
payload: T;
|
|
182
|
+
}
|
|
183
|
+
type ExtensionEventHandler = (event: ExtensionEvent) => void;
|
|
184
|
+
interface ExtensionStatus {
|
|
185
|
+
extensionPresent: boolean;
|
|
186
|
+
extensionVersion?: string;
|
|
187
|
+
contentScriptVersion?: string;
|
|
188
|
+
agentSessionActive: boolean;
|
|
189
|
+
lastAgentActivityAt: number | null;
|
|
190
|
+
sessionId: string | null;
|
|
191
|
+
sdkConnected: boolean;
|
|
192
|
+
appId: string | null;
|
|
193
|
+
}
|
|
194
|
+
interface BridgeMessage<T = unknown> {
|
|
195
|
+
source: "aios-sdk";
|
|
196
|
+
type: BridgeMessageType;
|
|
197
|
+
appId: string;
|
|
198
|
+
version: string;
|
|
199
|
+
timestamp: number;
|
|
200
|
+
payload: T;
|
|
201
|
+
}
|
|
202
|
+
declare global {
|
|
203
|
+
interface Window {
|
|
204
|
+
__aiOS_sdk__?: {
|
|
205
|
+
version: string;
|
|
206
|
+
appId: string;
|
|
207
|
+
connected: boolean;
|
|
208
|
+
extensionPresent?: boolean;
|
|
209
|
+
agentSessionActive?: boolean;
|
|
210
|
+
};
|
|
211
|
+
__aiOS_policy__?: PagePolicy;
|
|
212
|
+
__aiOS_context__?: PageContext;
|
|
213
|
+
__aiOS_zones__?: ContentZones;
|
|
214
|
+
__aiOS_components__?: Record<string, ComponentDescriptor>;
|
|
215
|
+
__aiOS_structured_data__?: StructuredPagePayload;
|
|
216
|
+
__aiOS_pending_export__?: StructuredPagePayload;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
declare class AIOSClient {
|
|
221
|
+
private appId;
|
|
222
|
+
private initialized;
|
|
223
|
+
private requireConsent;
|
|
224
|
+
private pageContext;
|
|
225
|
+
private zones;
|
|
226
|
+
private components;
|
|
227
|
+
private pageData;
|
|
228
|
+
private schema;
|
|
229
|
+
private pendingExport;
|
|
230
|
+
private lastApprovedExport;
|
|
231
|
+
private readonly events;
|
|
232
|
+
init(options: InitOptions): this;
|
|
233
|
+
setPagePolicy(policy: Partial<PagePolicy>): this;
|
|
234
|
+
setPageContext(context: Partial<PageContext>): this;
|
|
235
|
+
defineZones(zones: ContentZones): this;
|
|
236
|
+
markComponent(id: string, component: MarkComponentInput): this;
|
|
237
|
+
unmarkComponent(id: string): this;
|
|
238
|
+
exportPageData(options?: ExportOptions): this;
|
|
239
|
+
prepareExport(options?: ExportOptions): StructuredPagePayload;
|
|
240
|
+
buildConsentPreview(): ConsentPreview;
|
|
241
|
+
requestConsent(options?: ConsentRequestOptions): Promise<boolean>;
|
|
242
|
+
flushApprovedExport(options?: {
|
|
243
|
+
rememberSite?: boolean;
|
|
244
|
+
}): Promise<boolean>;
|
|
245
|
+
/**
|
|
246
|
+
* Convenience path: prepare payload, ask the user, and send only if approved.
|
|
247
|
+
*/
|
|
248
|
+
publish(options?: ExportOptions & ConsentRequestOptions): Promise<boolean>;
|
|
249
|
+
getPendingExport(): StructuredPagePayload | null;
|
|
250
|
+
getApprovedExport(): StructuredPagePayload | null;
|
|
251
|
+
getPageContext(): PageContext;
|
|
252
|
+
getComponents(): ComponentDescriptor[];
|
|
253
|
+
ping(): void;
|
|
254
|
+
/**
|
|
255
|
+
* Subscribe to extension / agent lifecycle events (exam proctoring, compliance, UX).
|
|
256
|
+
* Returns an unsubscribe function.
|
|
257
|
+
*/
|
|
258
|
+
onEvent(type: ExtensionEventType, handler: ExtensionEventHandler): () => void;
|
|
259
|
+
/** Fires when the aiOS browser extension content script is active on this page. */
|
|
260
|
+
onExtensionPresent(handler: ExtensionEventHandler): () => void;
|
|
261
|
+
/** Fires when the local aiOS agent performs any tool action on this page. */
|
|
262
|
+
onAgentActive(handler: ExtensionEventHandler): () => void;
|
|
263
|
+
/** Subscribe to every extension event. */
|
|
264
|
+
onAnyExtensionEvent(handler: ExtensionEventHandler): () => void;
|
|
265
|
+
offEvent(type: ExtensionEventType, handler: ExtensionEventHandler): void;
|
|
266
|
+
/** Latest extension + agent session snapshot (updated as events arrive). */
|
|
267
|
+
getExtensionStatus(): ExtensionStatus;
|
|
268
|
+
/** Ask the extension to respond with `extension:status` (also sent on init). */
|
|
269
|
+
queryExtensionPresence(): void;
|
|
270
|
+
private syncExtensionGlobals;
|
|
271
|
+
private buildPayload;
|
|
272
|
+
private syncState;
|
|
273
|
+
private assertInitialized;
|
|
274
|
+
private rememberConsentForSite;
|
|
275
|
+
private hasRememberedConsent;
|
|
276
|
+
}
|
|
277
|
+
declare const aiOS: AIOSClient;
|
|
278
|
+
|
|
279
|
+
declare const EXTENSION_MESSAGE_SOURCE: "aios-extension";
|
|
280
|
+
declare class ExtensionEventBus {
|
|
281
|
+
private listening;
|
|
282
|
+
private status;
|
|
283
|
+
private handlers;
|
|
284
|
+
private wildcardHandlers;
|
|
285
|
+
startListening(): void;
|
|
286
|
+
stopListening(): void;
|
|
287
|
+
on(type: ExtensionEventType, handler: ExtensionEventHandler): () => void;
|
|
288
|
+
onAny(handler: ExtensionEventHandler): () => void;
|
|
289
|
+
off(type: ExtensionEventType, handler: ExtensionEventHandler): void;
|
|
290
|
+
getStatus(): ExtensionStatus;
|
|
291
|
+
queryPresence(appId: string): void;
|
|
292
|
+
private onWindowMessage;
|
|
293
|
+
private onCustomEvent;
|
|
294
|
+
private ingestWireMessage;
|
|
295
|
+
private applyStatus;
|
|
296
|
+
private emit;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
declare const DEFAULT_PAGE_POLICY: PagePolicy;
|
|
300
|
+
declare const DEFAULT_UNINTEGRATED_POLICY: PagePolicy;
|
|
301
|
+
declare function createDefaultPageContext(title?: string): PageContext;
|
|
302
|
+
|
|
303
|
+
export { AIOSClient, type AgentActivePayload, type AgentDataAccessPayload, type AgentSessionPayload, type BridgeMessage, type BridgeMessageType, type ComponentCapability, type ComponentDescriptor, type ComponentKind, type ConsentPreview, type ConsentRecord, type ConsentRequestOptions, type ContentZones, DEFAULT_PAGE_POLICY, DEFAULT_UNINTEGRATED_POLICY, EXTENSION_MESSAGE_SOURCE, type ExportMode, type ExportOptions, type ExtensionEvent, ExtensionEventBus, type ExtensionEventHandler, type ExtensionEventPayload, type ExtensionEventType, type ExtensionPresentPayload, type ExtensionStatus, type ExtensionStatusPayload, type InitOptions, type MarkComponentInput, PROTOCOL_VERSION, type PageCapabilities, type PageContext, type PagePolicy, type PageType, type SeekField, type SeekInputType, type StructuredPagePayload, type TrustTier, aiOS, createDefaultPageContext };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/** Protocol version shared with the Safari extension content script. */
|
|
2
|
+
declare const PROTOCOL_VERSION: "1";
|
|
3
|
+
type PageCapability = "read" | "write" | "execute" | "summarize";
|
|
4
|
+
type ComponentCapability = "readable" | "summarizable" | "clickable" | "writable" | "selectable" | "scrollable" | "draggable" | "focusable" | "hidden";
|
|
5
|
+
type PageType = "job_application" | "checkout" | "account_settings" | "inbox" | "document" | "form" | "dashboard" | "search_results" | "generic";
|
|
6
|
+
type ExportMode = "structured-only" | "dom-allowed";
|
|
7
|
+
type TrustTier = "verified-sdk" | "partial" | "unverified";
|
|
8
|
+
type SeekInputType = "text" | "boolean" | "date" | "file" | "choice" | "number";
|
|
9
|
+
interface PageCapabilities {
|
|
10
|
+
read?: boolean;
|
|
11
|
+
write?: boolean;
|
|
12
|
+
execute?: boolean;
|
|
13
|
+
summarize?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface PagePolicy {
|
|
16
|
+
/** When false the extension must block all agent access on this page. */
|
|
17
|
+
allowed: boolean;
|
|
18
|
+
reason?: string;
|
|
19
|
+
userMessage?: string;
|
|
20
|
+
capabilities?: PageCapabilities;
|
|
21
|
+
exportMode?: ExportMode;
|
|
22
|
+
}
|
|
23
|
+
interface SeekField {
|
|
24
|
+
/** Stable identifier, e.g. "work_authorization". */
|
|
25
|
+
id: string;
|
|
26
|
+
/** Short label shown in consent UI and agent prompts. */
|
|
27
|
+
label: string;
|
|
28
|
+
/** Why the agent needs this from the user. */
|
|
29
|
+
description: string;
|
|
30
|
+
inputType: SeekInputType;
|
|
31
|
+
required?: boolean;
|
|
32
|
+
choices?: string[];
|
|
33
|
+
sensitive?: boolean;
|
|
34
|
+
/** Optional link to a writable component id on the page. */
|
|
35
|
+
mapsToComponentId?: string;
|
|
36
|
+
}
|
|
37
|
+
interface PageContext {
|
|
38
|
+
pageType: PageType;
|
|
39
|
+
title: string;
|
|
40
|
+
description: string;
|
|
41
|
+
/** High-level instruction for the agent, e.g. how to help on a job application. */
|
|
42
|
+
agentIntent: string;
|
|
43
|
+
/** Fields the agent should seek from the user via askUser, not scrape. */
|
|
44
|
+
seekFromUser?: SeekField[];
|
|
45
|
+
policy: PagePolicy;
|
|
46
|
+
}
|
|
47
|
+
type ComponentKind = "button" | "textfield" | "textarea" | "text" | "link" | "select" | "checkbox" | "radio" | "scrollable" | "draggable" | "file" | "custom";
|
|
48
|
+
interface ComponentDescriptor {
|
|
49
|
+
id: string;
|
|
50
|
+
kind: ComponentKind;
|
|
51
|
+
label?: string;
|
|
52
|
+
/** What this control does — reduces agent mistakes. */
|
|
53
|
+
description?: string;
|
|
54
|
+
capabilities: ComponentCapability[];
|
|
55
|
+
value?: string | number | boolean | Record<string, unknown> | null;
|
|
56
|
+
placeholder?: string;
|
|
57
|
+
required?: boolean;
|
|
58
|
+
sensitive?: boolean;
|
|
59
|
+
selector?: string;
|
|
60
|
+
visible?: boolean;
|
|
61
|
+
inputType?: string;
|
|
62
|
+
href?: string;
|
|
63
|
+
trusted?: boolean;
|
|
64
|
+
actionIntent?: "submit" | "cancel" | "navigate" | "download" | string;
|
|
65
|
+
options?: Array<{
|
|
66
|
+
id: string;
|
|
67
|
+
label: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
}>;
|
|
70
|
+
childComponentIds?: string[];
|
|
71
|
+
mapsToSeekField?: string;
|
|
72
|
+
schema?: string;
|
|
73
|
+
}
|
|
74
|
+
interface ContentZones {
|
|
75
|
+
/** CSS selector for primary app content. */
|
|
76
|
+
primary?: string;
|
|
77
|
+
/** Selectors excluded from agent read/summarize/execute. */
|
|
78
|
+
excluded?: string[];
|
|
79
|
+
}
|
|
80
|
+
interface ConsentRecord {
|
|
81
|
+
approvalId: string;
|
|
82
|
+
approvedAt: number;
|
|
83
|
+
approvedBy: "user";
|
|
84
|
+
rememberSite?: boolean;
|
|
85
|
+
}
|
|
86
|
+
interface ConsentPreview {
|
|
87
|
+
title: string;
|
|
88
|
+
message: string;
|
|
89
|
+
pageType: PageType;
|
|
90
|
+
pageTitle: string;
|
|
91
|
+
agentIntent: string;
|
|
92
|
+
seekFromUser: SeekField[];
|
|
93
|
+
sensitiveFieldCount: number;
|
|
94
|
+
componentCount: number;
|
|
95
|
+
capabilities: PageCapabilities;
|
|
96
|
+
}
|
|
97
|
+
interface ConsentRequestOptions {
|
|
98
|
+
title?: string;
|
|
99
|
+
message?: string;
|
|
100
|
+
/** If true, user can opt to remember approval for this origin. */
|
|
101
|
+
allowRememberSite?: boolean;
|
|
102
|
+
}
|
|
103
|
+
interface StructuredPagePayload {
|
|
104
|
+
version: typeof PROTOCOL_VERSION;
|
|
105
|
+
appId: string;
|
|
106
|
+
route: string;
|
|
107
|
+
url: string;
|
|
108
|
+
page: PageContext;
|
|
109
|
+
data: Record<string, unknown>;
|
|
110
|
+
components: ComponentDescriptor[];
|
|
111
|
+
zones?: ContentZones;
|
|
112
|
+
meta: {
|
|
113
|
+
generatedAt: number;
|
|
114
|
+
source: "sdk";
|
|
115
|
+
trust: TrustTier;
|
|
116
|
+
consent: ConsentRecord;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
interface InitOptions {
|
|
120
|
+
appId: string;
|
|
121
|
+
/** Require user consent before any payload reaches the extension. Default: true. */
|
|
122
|
+
requireConsent?: boolean;
|
|
123
|
+
/** SDK protocol version sent during handshake. */
|
|
124
|
+
version?: string;
|
|
125
|
+
}
|
|
126
|
+
interface ExportOptions {
|
|
127
|
+
schema?: string;
|
|
128
|
+
data?: Record<string, unknown>;
|
|
129
|
+
components?: ComponentDescriptor[];
|
|
130
|
+
page?: Partial<PageContext>;
|
|
131
|
+
zones?: ContentZones;
|
|
132
|
+
}
|
|
133
|
+
interface MarkComponentInput extends Omit<ComponentDescriptor, "id"> {
|
|
134
|
+
id?: string;
|
|
135
|
+
}
|
|
136
|
+
/** Messages posted from the page to the extension content script. */
|
|
137
|
+
type BridgeMessageType = "aios-sdk:init" | "aios-sdk:policy" | "aios-sdk:context" | "aios-sdk:zones" | "aios-sdk:components" | "aios-sdk:export" | "aios-sdk:ping" | "aios-sdk:presence-query";
|
|
138
|
+
/** Events the extension emits so integrated apps can detect AI agent usage. */
|
|
139
|
+
type ExtensionEventType = "extension:present" | "extension:status" | "agent:session-start" | "agent:active" | "agent:session-end" | "agent:data-access";
|
|
140
|
+
interface ExtensionPresentPayload {
|
|
141
|
+
extensionVersion: string;
|
|
142
|
+
contentScriptVersion: string;
|
|
143
|
+
}
|
|
144
|
+
interface ExtensionStatusPayload {
|
|
145
|
+
present: boolean;
|
|
146
|
+
agentSessionActive: boolean;
|
|
147
|
+
lastAgentActivityAt: number | null;
|
|
148
|
+
sessionId: string | null;
|
|
149
|
+
sdkConnected: boolean;
|
|
150
|
+
appId: string | null;
|
|
151
|
+
}
|
|
152
|
+
interface AgentSessionPayload {
|
|
153
|
+
sessionId: string;
|
|
154
|
+
route: string;
|
|
155
|
+
}
|
|
156
|
+
interface AgentActivePayload {
|
|
157
|
+
sessionId: string;
|
|
158
|
+
action: string;
|
|
159
|
+
capability: PageCapability | "navigate" | "unknown";
|
|
160
|
+
route: string;
|
|
161
|
+
appId: string | null;
|
|
162
|
+
sdkIntegrated: boolean;
|
|
163
|
+
success: boolean;
|
|
164
|
+
blocked?: boolean;
|
|
165
|
+
error?: string | null;
|
|
166
|
+
timestamp: number;
|
|
167
|
+
}
|
|
168
|
+
interface AgentDataAccessPayload {
|
|
169
|
+
sessionId: string | null;
|
|
170
|
+
route: string;
|
|
171
|
+
appId: string | null;
|
|
172
|
+
approvalId?: string;
|
|
173
|
+
source: "user-consent" | "agent-read";
|
|
174
|
+
action?: string;
|
|
175
|
+
}
|
|
176
|
+
type ExtensionEventPayload = ExtensionPresentPayload | ExtensionStatusPayload | AgentSessionPayload | AgentActivePayload | AgentDataAccessPayload;
|
|
177
|
+
interface ExtensionEvent<T extends ExtensionEventPayload = ExtensionEventPayload> {
|
|
178
|
+
type: ExtensionEventType;
|
|
179
|
+
timestamp: number;
|
|
180
|
+
version: string;
|
|
181
|
+
payload: T;
|
|
182
|
+
}
|
|
183
|
+
type ExtensionEventHandler = (event: ExtensionEvent) => void;
|
|
184
|
+
interface ExtensionStatus {
|
|
185
|
+
extensionPresent: boolean;
|
|
186
|
+
extensionVersion?: string;
|
|
187
|
+
contentScriptVersion?: string;
|
|
188
|
+
agentSessionActive: boolean;
|
|
189
|
+
lastAgentActivityAt: number | null;
|
|
190
|
+
sessionId: string | null;
|
|
191
|
+
sdkConnected: boolean;
|
|
192
|
+
appId: string | null;
|
|
193
|
+
}
|
|
194
|
+
interface BridgeMessage<T = unknown> {
|
|
195
|
+
source: "aios-sdk";
|
|
196
|
+
type: BridgeMessageType;
|
|
197
|
+
appId: string;
|
|
198
|
+
version: string;
|
|
199
|
+
timestamp: number;
|
|
200
|
+
payload: T;
|
|
201
|
+
}
|
|
202
|
+
declare global {
|
|
203
|
+
interface Window {
|
|
204
|
+
__aiOS_sdk__?: {
|
|
205
|
+
version: string;
|
|
206
|
+
appId: string;
|
|
207
|
+
connected: boolean;
|
|
208
|
+
extensionPresent?: boolean;
|
|
209
|
+
agentSessionActive?: boolean;
|
|
210
|
+
};
|
|
211
|
+
__aiOS_policy__?: PagePolicy;
|
|
212
|
+
__aiOS_context__?: PageContext;
|
|
213
|
+
__aiOS_zones__?: ContentZones;
|
|
214
|
+
__aiOS_components__?: Record<string, ComponentDescriptor>;
|
|
215
|
+
__aiOS_structured_data__?: StructuredPagePayload;
|
|
216
|
+
__aiOS_pending_export__?: StructuredPagePayload;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
declare class AIOSClient {
|
|
221
|
+
private appId;
|
|
222
|
+
private initialized;
|
|
223
|
+
private requireConsent;
|
|
224
|
+
private pageContext;
|
|
225
|
+
private zones;
|
|
226
|
+
private components;
|
|
227
|
+
private pageData;
|
|
228
|
+
private schema;
|
|
229
|
+
private pendingExport;
|
|
230
|
+
private lastApprovedExport;
|
|
231
|
+
private readonly events;
|
|
232
|
+
init(options: InitOptions): this;
|
|
233
|
+
setPagePolicy(policy: Partial<PagePolicy>): this;
|
|
234
|
+
setPageContext(context: Partial<PageContext>): this;
|
|
235
|
+
defineZones(zones: ContentZones): this;
|
|
236
|
+
markComponent(id: string, component: MarkComponentInput): this;
|
|
237
|
+
unmarkComponent(id: string): this;
|
|
238
|
+
exportPageData(options?: ExportOptions): this;
|
|
239
|
+
prepareExport(options?: ExportOptions): StructuredPagePayload;
|
|
240
|
+
buildConsentPreview(): ConsentPreview;
|
|
241
|
+
requestConsent(options?: ConsentRequestOptions): Promise<boolean>;
|
|
242
|
+
flushApprovedExport(options?: {
|
|
243
|
+
rememberSite?: boolean;
|
|
244
|
+
}): Promise<boolean>;
|
|
245
|
+
/**
|
|
246
|
+
* Convenience path: prepare payload, ask the user, and send only if approved.
|
|
247
|
+
*/
|
|
248
|
+
publish(options?: ExportOptions & ConsentRequestOptions): Promise<boolean>;
|
|
249
|
+
getPendingExport(): StructuredPagePayload | null;
|
|
250
|
+
getApprovedExport(): StructuredPagePayload | null;
|
|
251
|
+
getPageContext(): PageContext;
|
|
252
|
+
getComponents(): ComponentDescriptor[];
|
|
253
|
+
ping(): void;
|
|
254
|
+
/**
|
|
255
|
+
* Subscribe to extension / agent lifecycle events (exam proctoring, compliance, UX).
|
|
256
|
+
* Returns an unsubscribe function.
|
|
257
|
+
*/
|
|
258
|
+
onEvent(type: ExtensionEventType, handler: ExtensionEventHandler): () => void;
|
|
259
|
+
/** Fires when the aiOS browser extension content script is active on this page. */
|
|
260
|
+
onExtensionPresent(handler: ExtensionEventHandler): () => void;
|
|
261
|
+
/** Fires when the local aiOS agent performs any tool action on this page. */
|
|
262
|
+
onAgentActive(handler: ExtensionEventHandler): () => void;
|
|
263
|
+
/** Subscribe to every extension event. */
|
|
264
|
+
onAnyExtensionEvent(handler: ExtensionEventHandler): () => void;
|
|
265
|
+
offEvent(type: ExtensionEventType, handler: ExtensionEventHandler): void;
|
|
266
|
+
/** Latest extension + agent session snapshot (updated as events arrive). */
|
|
267
|
+
getExtensionStatus(): ExtensionStatus;
|
|
268
|
+
/** Ask the extension to respond with `extension:status` (also sent on init). */
|
|
269
|
+
queryExtensionPresence(): void;
|
|
270
|
+
private syncExtensionGlobals;
|
|
271
|
+
private buildPayload;
|
|
272
|
+
private syncState;
|
|
273
|
+
private assertInitialized;
|
|
274
|
+
private rememberConsentForSite;
|
|
275
|
+
private hasRememberedConsent;
|
|
276
|
+
}
|
|
277
|
+
declare const aiOS: AIOSClient;
|
|
278
|
+
|
|
279
|
+
declare const EXTENSION_MESSAGE_SOURCE: "aios-extension";
|
|
280
|
+
declare class ExtensionEventBus {
|
|
281
|
+
private listening;
|
|
282
|
+
private status;
|
|
283
|
+
private handlers;
|
|
284
|
+
private wildcardHandlers;
|
|
285
|
+
startListening(): void;
|
|
286
|
+
stopListening(): void;
|
|
287
|
+
on(type: ExtensionEventType, handler: ExtensionEventHandler): () => void;
|
|
288
|
+
onAny(handler: ExtensionEventHandler): () => void;
|
|
289
|
+
off(type: ExtensionEventType, handler: ExtensionEventHandler): void;
|
|
290
|
+
getStatus(): ExtensionStatus;
|
|
291
|
+
queryPresence(appId: string): void;
|
|
292
|
+
private onWindowMessage;
|
|
293
|
+
private onCustomEvent;
|
|
294
|
+
private ingestWireMessage;
|
|
295
|
+
private applyStatus;
|
|
296
|
+
private emit;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
declare const DEFAULT_PAGE_POLICY: PagePolicy;
|
|
300
|
+
declare const DEFAULT_UNINTEGRATED_POLICY: PagePolicy;
|
|
301
|
+
declare function createDefaultPageContext(title?: string): PageContext;
|
|
302
|
+
|
|
303
|
+
export { AIOSClient, type AgentActivePayload, type AgentDataAccessPayload, type AgentSessionPayload, type BridgeMessage, type BridgeMessageType, type ComponentCapability, type ComponentDescriptor, type ComponentKind, type ConsentPreview, type ConsentRecord, type ConsentRequestOptions, type ContentZones, DEFAULT_PAGE_POLICY, DEFAULT_UNINTEGRATED_POLICY, EXTENSION_MESSAGE_SOURCE, type ExportMode, type ExportOptions, type ExtensionEvent, ExtensionEventBus, type ExtensionEventHandler, type ExtensionEventPayload, type ExtensionEventType, type ExtensionPresentPayload, type ExtensionStatus, type ExtensionStatusPayload, type InitOptions, type MarkComponentInput, PROTOCOL_VERSION, type PageCapabilities, type PageContext, type PagePolicy, type PageType, type SeekField, type SeekInputType, type StructuredPagePayload, type TrustTier, aiOS, createDefaultPageContext };
|