@modelprofile.com/browser-runtime 1.0.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/.smartconfig.json +34 -0
- package/changelog.md +11 -0
- package/dist_ts/00_commitinfo_data.d.ts +8 -0
- package/dist_ts/00_commitinfo_data.js +9 -0
- package/dist_ts/actions.d.ts +3 -0
- package/dist_ts/actions.js +215 -0
- package/dist_ts/classes.artifactstore.d.ts +38 -0
- package/dist_ts/classes.artifactstore.js +344 -0
- package/dist_ts/classes.egressproxy.d.ts +67 -0
- package/dist_ts/classes.egressproxy.js +830 -0
- package/dist_ts/classes.flexprovider.d.ts +9 -0
- package/dist_ts/classes.flexprovider.js +117 -0
- package/dist_ts/classes.framed.d.ts +52 -0
- package/dist_ts/classes.framed.js +557 -0
- package/dist_ts/classes.runtime.d.ts +202 -0
- package/dist_ts/classes.runtime.js +1667 -0
- package/dist_ts/confinement.d.ts +2 -0
- package/dist_ts/confinement.js +63 -0
- package/dist_ts/errors.d.ts +7 -0
- package/dist_ts/errors.js +40 -0
- package/dist_ts/index.d.ts +11 -0
- package/dist_ts/index.js +9 -0
- package/dist_ts/interfaces.d.ts +287 -0
- package/dist_ts/interfaces.js +2 -0
- package/dist_ts/internal.testing.d.ts +9 -0
- package/dist_ts/internal.testing.js +2 -0
- package/dist_ts/mcp.d.ts +4 -0
- package/dist_ts/mcp.js +196 -0
- package/dist_ts/plugins.d.ts +20 -0
- package/dist_ts/plugins.js +24 -0
- package/dist_ts/utils.d.ts +25 -0
- package/dist_ts/utils.js +143 -0
- package/license.md +21 -0
- package/package.json +59 -0
- package/readme.hints.md +35 -0
- package/readme.md +181 -0
- package/ts/00_commitinfo_data.ts +8 -0
- package/ts/actions.ts +241 -0
- package/ts/classes.artifactstore.ts +432 -0
- package/ts/classes.egressproxy.ts +1005 -0
- package/ts/classes.flexprovider.ts +134 -0
- package/ts/classes.framed.ts +649 -0
- package/ts/classes.runtime.ts +2135 -0
- package/ts/confinement.ts +90 -0
- package/ts/errors.ts +63 -0
- package/ts/index.ts +52 -0
- package/ts/interfaces.ts +375 -0
- package/ts/internal.testing.ts +18 -0
- package/ts/mcp.ts +230 -0
- package/ts/plugins.ts +28 -0
- package/ts/utils.ts +188 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import { BrowserArtifactStore } from './classes.artifactstore.js';
|
|
3
|
+
import { BrowserEgressProxy } from './classes.egressproxy.js';
|
|
4
|
+
import { type IBrowserRuntimeTestingOptions } from './internal.testing.js';
|
|
5
|
+
import type { IAttachTrustedFramedPeerOptions, IBrowserCapabilityDescriptor, IBrowserRuntimeFrameSubscription, IBrowserRuntimeOperationOptions, IBrowserRuntimeOptions, IBrowserRuntimeState, IIssueBrowserCapabilityRequest, IIssuedBrowserCapability, ILiveBrowserSessionLike, TBrowserActorRole, TBrowserAgentAction, TBrowserAgentActionResult, TBrowserCapabilitySource, TBrowserRuntimeEvent } from './interfaces.js';
|
|
6
|
+
import { TransitionMutex } from './utils.js';
|
|
7
|
+
import { BrowserRuntimeFramedServerPeer } from './classes.framed.js';
|
|
8
|
+
interface ICapabilityRecord extends IBrowserCapabilityDescriptor {
|
|
9
|
+
digest: plugins.Buffer;
|
|
10
|
+
state: 'active' | 'revoked' | 'expired';
|
|
11
|
+
expiryTimer: ReturnType<typeof setTimeout>;
|
|
12
|
+
disconnect?: (signal: AbortSignal) => Promise<void> | void;
|
|
13
|
+
lease?: ILeaseRecord;
|
|
14
|
+
revocationPromise?: Promise<void>;
|
|
15
|
+
revocationInvokeDisconnect?: boolean;
|
|
16
|
+
revocationComplete?: boolean;
|
|
17
|
+
leaseCleanupComplete?: boolean;
|
|
18
|
+
disconnectComplete?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface ILeaseRecord {
|
|
21
|
+
leaseId: string;
|
|
22
|
+
capability: ICapabilityRecord;
|
|
23
|
+
digest: plugins.Buffer;
|
|
24
|
+
peerId: string;
|
|
25
|
+
role: TBrowserActorRole;
|
|
26
|
+
slot: IProjectSlot;
|
|
27
|
+
controller: AbortController;
|
|
28
|
+
released: boolean;
|
|
29
|
+
releasePromise?: Promise<void>;
|
|
30
|
+
releaseGeneration?: number;
|
|
31
|
+
}
|
|
32
|
+
interface IOperationRecord {
|
|
33
|
+
operationId: string;
|
|
34
|
+
lease: ILeaseRecord;
|
|
35
|
+
controller: AbortController;
|
|
36
|
+
action: string;
|
|
37
|
+
startedAt: number;
|
|
38
|
+
promise: Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
interface IFrameSubscriptionRecord {
|
|
41
|
+
lease: ILeaseRecord;
|
|
42
|
+
listener: (event: TBrowserRuntimeEvent) => void;
|
|
43
|
+
outstanding?: {
|
|
44
|
+
acknowledgement: plugins.smartpuppeteer.ILiveBrowserFrameAcknowledgementRequest;
|
|
45
|
+
timer: ReturnType<typeof setTimeout>;
|
|
46
|
+
};
|
|
47
|
+
closed: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface IProjectSlot {
|
|
50
|
+
projectId: string;
|
|
51
|
+
mutex: TransitionMutex;
|
|
52
|
+
generation: number;
|
|
53
|
+
fencingGeneration?: number;
|
|
54
|
+
permanentlyFenced: boolean;
|
|
55
|
+
session?: ILiveBrowserSessionLike;
|
|
56
|
+
proxy?: BrowserEgressProxy;
|
|
57
|
+
profileDirectory?: string;
|
|
58
|
+
unsubscribeSession?: () => void;
|
|
59
|
+
lease?: ILeaseRecord;
|
|
60
|
+
operation?: IOperationRecord;
|
|
61
|
+
frameSubscription?: IFrameSubscriptionRecord;
|
|
62
|
+
idleTimer?: ReturnType<typeof setTimeout>;
|
|
63
|
+
}
|
|
64
|
+
export interface IAcquireBrowserRuntimeLeaseOptions {
|
|
65
|
+
capabilityToken: string;
|
|
66
|
+
peerId: string;
|
|
67
|
+
expectedRole?: TBrowserActorRole;
|
|
68
|
+
expectedSource?: TBrowserCapabilitySource;
|
|
69
|
+
scopeId?: string;
|
|
70
|
+
sessionId?: string;
|
|
71
|
+
signal?: AbortSignal;
|
|
72
|
+
}
|
|
73
|
+
export declare class BrowserRuntime {
|
|
74
|
+
private readonly options;
|
|
75
|
+
private readonly profileRoot;
|
|
76
|
+
private readonly artifactRoot;
|
|
77
|
+
private readonly lockPath;
|
|
78
|
+
private readonly artifactStore;
|
|
79
|
+
private readonly slots;
|
|
80
|
+
private readonly capabilitiesByDigest;
|
|
81
|
+
private readonly capabilitiesById;
|
|
82
|
+
private readonly failedRevocations;
|
|
83
|
+
private readonly capabilityMutex;
|
|
84
|
+
private readonly cleanupOperations;
|
|
85
|
+
private readonly framedPeers;
|
|
86
|
+
private lockHandle?;
|
|
87
|
+
private lockHandleClosed;
|
|
88
|
+
private startPromise?;
|
|
89
|
+
private stopPromise?;
|
|
90
|
+
private lifecycleState;
|
|
91
|
+
private lifecycleEpoch;
|
|
92
|
+
private lifecycleController;
|
|
93
|
+
private pendingCapabilities;
|
|
94
|
+
private readonly pendingCapabilitiesByProject;
|
|
95
|
+
constructor(options: IBrowserRuntimeOptions | IBrowserRuntimeTestingOptions);
|
|
96
|
+
start(): Promise<void>;
|
|
97
|
+
stop(): Promise<void>;
|
|
98
|
+
issueCapability(requestArg: IIssueBrowserCapabilityRequest): Promise<IIssuedBrowserCapability>;
|
|
99
|
+
acquireLease(optionsArg: IAcquireBrowserRuntimeLeaseOptions): Promise<BrowserRuntimeLease>;
|
|
100
|
+
authorizeCapability(capabilityTokenArg: string, peerIdArg: string, role: TBrowserActorRole, source: TBrowserCapabilitySource): IBrowserCapabilityDescriptor;
|
|
101
|
+
revokeCapability(capabilityIdArg: string): Promise<void>;
|
|
102
|
+
disconnectPeer(peerIdArg: string): Promise<void>;
|
|
103
|
+
retireProject(projectIdArg: string): Promise<void>;
|
|
104
|
+
attachTrustedFramedPeer(options: IAttachTrustedFramedPeerOptions): BrowserRuntimeFramedServerPeer;
|
|
105
|
+
getArtifactStore(): BrowserArtifactStore;
|
|
106
|
+
/** @internal */
|
|
107
|
+
getLeaseState(lease: ILeaseRecord): IBrowserRuntimeState;
|
|
108
|
+
/** @internal */
|
|
109
|
+
executeLeaseAgentAction(lease: ILeaseRecord, actionArg: unknown, operationOptions?: IBrowserRuntimeOperationOptions): Promise<TBrowserAgentActionResult>;
|
|
110
|
+
/** @internal */
|
|
111
|
+
leaseCreateTab(lease: ILeaseRecord, options?: plugins.smartpuppeteer.ILiveBrowserCreateTabOptions, operationOptions?: IBrowserRuntimeOperationOptions): Promise<IBrowserRuntimeState>;
|
|
112
|
+
/** @internal */
|
|
113
|
+
leaseActivateTab(lease: ILeaseRecord, tabIdArg: string, operationOptions?: IBrowserRuntimeOperationOptions): Promise<IBrowserRuntimeState>;
|
|
114
|
+
/** @internal */
|
|
115
|
+
leaseCloseTab(lease: ILeaseRecord, tabIdArg: string, operationOptions?: IBrowserRuntimeOperationOptions): Promise<IBrowserRuntimeState>;
|
|
116
|
+
/** @internal */
|
|
117
|
+
leaseHistory(lease: ILeaseRecord, action: 'back' | 'forward' | 'reload', options?: plugins.smartpuppeteer.ILiveBrowserNavigationOptions, operationOptions?: IBrowserRuntimeOperationOptions): Promise<IBrowserRuntimeState>;
|
|
118
|
+
/** @internal */
|
|
119
|
+
leaseHumanAgentAction(lease: ILeaseRecord, actionArg: unknown, operationOptions?: IBrowserRuntimeOperationOptions): Promise<TBrowserAgentActionResult>;
|
|
120
|
+
/** @internal */
|
|
121
|
+
leaseSetViewport(lease: ILeaseRecord, viewport: plugins.smartpuppeteer.ILiveBrowserViewport, operationOptions?: IBrowserRuntimeOperationOptions): Promise<void>;
|
|
122
|
+
/** @internal */
|
|
123
|
+
leaseDispatchRawInput(lease: ILeaseRecord, action: 'dispatchMouse' | 'dispatchWheel' | 'dispatchKey' | 'insertText', input: plugins.smartpuppeteer.ILiveBrowserMouseInput | plugins.smartpuppeteer.ILiveBrowserWheelInput | plugins.smartpuppeteer.ILiveBrowserKeyInput | plugins.smartpuppeteer.ILiveBrowserInsertTextInput, operationOptions?: IBrowserRuntimeOperationOptions): Promise<void>;
|
|
124
|
+
/** @internal */
|
|
125
|
+
subscribeLeaseEvents(lease: ILeaseRecord, listener: (event: TBrowserRuntimeEvent) => void): Promise<IBrowserRuntimeFrameSubscription>;
|
|
126
|
+
/** @internal */
|
|
127
|
+
acknowledgeLeaseFrame(lease: ILeaseRecord, acknowledgement: plugins.smartpuppeteer.ILiveBrowserFrameAcknowledgementRequest): Promise<boolean>;
|
|
128
|
+
/** @internal */
|
|
129
|
+
readLeaseArtifact(lease: ILeaseRecord, artifactId: string): Promise<Uint8Array>;
|
|
130
|
+
/** @internal */
|
|
131
|
+
deleteLeaseArtifact(lease: ILeaseRecord, artifactId: string): Promise<void>;
|
|
132
|
+
/** @internal */
|
|
133
|
+
cancelLeaseOperation(lease: ILeaseRecord): boolean;
|
|
134
|
+
/** @internal */
|
|
135
|
+
releaseLease(lease: ILeaseRecord): Promise<void>;
|
|
136
|
+
private startInternal;
|
|
137
|
+
private stopInternal;
|
|
138
|
+
private requireRunning;
|
|
139
|
+
private getOrCreateSlot;
|
|
140
|
+
private acquireAgentLease;
|
|
141
|
+
private acquireHumanLease;
|
|
142
|
+
private createLeaseRecord;
|
|
143
|
+
private ensureSession;
|
|
144
|
+
private runOperation;
|
|
145
|
+
private executeAgentActionInternal;
|
|
146
|
+
private resolveSemanticTarget;
|
|
147
|
+
private projectState;
|
|
148
|
+
private handleSessionEvent;
|
|
149
|
+
private pushToSubscription;
|
|
150
|
+
private closeFrameSubscription;
|
|
151
|
+
private acknowledgeFrameInBackground;
|
|
152
|
+
private requireValidLease;
|
|
153
|
+
private resolveCapability;
|
|
154
|
+
private describeCapability;
|
|
155
|
+
private revokeCapabilityRecord;
|
|
156
|
+
private releaseLeaseRecord;
|
|
157
|
+
private releaseLeaseRecordInternal;
|
|
158
|
+
private closeFrameSubscriptionIfLease;
|
|
159
|
+
private quiesceSlot;
|
|
160
|
+
private enforceOperationQuiescence;
|
|
161
|
+
private terminateSlotSession;
|
|
162
|
+
private scheduleIdleRetirement;
|
|
163
|
+
private stopProxyBounded;
|
|
164
|
+
private retireSlot;
|
|
165
|
+
private assertSlotAvailable;
|
|
166
|
+
private throwIfAcquisitionAborted;
|
|
167
|
+
private requireHuman;
|
|
168
|
+
private validateRole;
|
|
169
|
+
private validateSource;
|
|
170
|
+
private trackCleanup;
|
|
171
|
+
private emitAudit;
|
|
172
|
+
}
|
|
173
|
+
export declare class BrowserRuntimeLease {
|
|
174
|
+
private readonly runtime;
|
|
175
|
+
private readonly record;
|
|
176
|
+
/** @internal */
|
|
177
|
+
constructor(runtime: BrowserRuntime, record: ILeaseRecord);
|
|
178
|
+
get leaseId(): string;
|
|
179
|
+
get role(): TBrowserActorRole;
|
|
180
|
+
get projectId(): string;
|
|
181
|
+
getState(): IBrowserRuntimeState;
|
|
182
|
+
executeAgentAction(action: TBrowserAgentAction, options?: IBrowserRuntimeOperationOptions): Promise<TBrowserAgentActionResult>;
|
|
183
|
+
executeHumanAction(action: TBrowserAgentAction, options?: IBrowserRuntimeOperationOptions): Promise<TBrowserAgentActionResult>;
|
|
184
|
+
createTab(options?: plugins.smartpuppeteer.ILiveBrowserCreateTabOptions, operationOptions?: IBrowserRuntimeOperationOptions): Promise<IBrowserRuntimeState>;
|
|
185
|
+
activateTab(tabId: string, operationOptions?: IBrowserRuntimeOperationOptions): Promise<IBrowserRuntimeState>;
|
|
186
|
+
closeTab(tabId: string, operationOptions?: IBrowserRuntimeOperationOptions): Promise<IBrowserRuntimeState>;
|
|
187
|
+
back(options?: plugins.smartpuppeteer.ILiveBrowserNavigationOptions, operationOptions?: IBrowserRuntimeOperationOptions): Promise<IBrowserRuntimeState>;
|
|
188
|
+
forward(options?: plugins.smartpuppeteer.ILiveBrowserNavigationOptions, operationOptions?: IBrowserRuntimeOperationOptions): Promise<IBrowserRuntimeState>;
|
|
189
|
+
reload(options?: plugins.smartpuppeteer.ILiveBrowserNavigationOptions, operationOptions?: IBrowserRuntimeOperationOptions): Promise<IBrowserRuntimeState>;
|
|
190
|
+
setViewport(viewport: plugins.smartpuppeteer.ILiveBrowserViewport, operationOptions?: IBrowserRuntimeOperationOptions): Promise<void>;
|
|
191
|
+
dispatchMouse(input: plugins.smartpuppeteer.ILiveBrowserMouseInput, operationOptions?: IBrowserRuntimeOperationOptions): Promise<void>;
|
|
192
|
+
dispatchWheel(input: plugins.smartpuppeteer.ILiveBrowserWheelInput, operationOptions?: IBrowserRuntimeOperationOptions): Promise<void>;
|
|
193
|
+
dispatchKey(input: plugins.smartpuppeteer.ILiveBrowserKeyInput, operationOptions?: IBrowserRuntimeOperationOptions): Promise<void>;
|
|
194
|
+
insertText(input: plugins.smartpuppeteer.ILiveBrowserInsertTextInput, operationOptions?: IBrowserRuntimeOperationOptions): Promise<void>;
|
|
195
|
+
subscribeEvents(listener: (event: TBrowserRuntimeEvent) => void): Promise<IBrowserRuntimeFrameSubscription>;
|
|
196
|
+
acknowledgeFrame(acknowledgement: plugins.smartpuppeteer.ILiveBrowserFrameAcknowledgementRequest): Promise<boolean>;
|
|
197
|
+
readArtifact(artifactId: string): Promise<Uint8Array>;
|
|
198
|
+
deleteArtifact(artifactId: string): Promise<void>;
|
|
199
|
+
cancelActiveOperation(): boolean;
|
|
200
|
+
release(): Promise<void>;
|
|
201
|
+
}
|
|
202
|
+
export {};
|