@modelprofile.com/browser-runtime 1.0.1 → 2.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 +1 -1
- package/changelog.md +10 -0
- package/dist_ts/00_commitinfo_data.js +3 -3
- package/dist_ts/actions.js +12 -3
- package/dist_ts/classes.artifactstore.d.ts +16 -7
- package/dist_ts/classes.artifactstore.js +167 -88
- package/dist_ts/classes.egressproxy.d.ts +2 -0
- package/dist_ts/classes.egressproxy.js +7 -2
- package/dist_ts/classes.flexprovider.js +4 -2
- package/dist_ts/classes.framed.d.ts +30 -3
- package/dist_ts/classes.framed.js +205 -30
- package/dist_ts/classes.runtime.d.ts +80 -22
- package/dist_ts/classes.runtime.js +876 -196
- package/dist_ts/errors.d.ts +1 -1
- package/dist_ts/errors.js +6 -3
- package/dist_ts/index.d.ts +2 -2
- package/dist_ts/interfaces.d.ts +102 -40
- package/dist_ts/internal.testing.d.ts +10 -1
- package/dist_ts/internal.testing.js +1 -1
- package/dist_ts/mcp.js +45 -11
- package/package.json +2 -2
- package/readme.hints.md +22 -18
- package/readme.md +69 -101
- package/ts/00_commitinfo_data.ts +2 -2
- package/ts/actions.ts +11 -2
- package/ts/classes.artifactstore.ts +239 -107
- package/ts/classes.egressproxy.ts +12 -1
- package/ts/classes.flexprovider.ts +5 -1
- package/ts/classes.framed.ts +246 -38
- package/ts/classes.runtime.ts +1145 -281
- package/ts/errors.ts +8 -2
- package/ts/index.ts +18 -6
- package/ts/interfaces.ts +127 -38
- package/ts/internal.testing.ts +12 -0
- package/ts/mcp.ts +67 -16
|
@@ -2,10 +2,10 @@ import * as plugins from './plugins.js';
|
|
|
2
2
|
import { BrowserArtifactStore } from './classes.artifactstore.js';
|
|
3
3
|
import { BrowserEgressProxy } from './classes.egressproxy.js';
|
|
4
4
|
import { type IBrowserRuntimeTestingOptions } from './internal.testing.js';
|
|
5
|
-
import type { IAttachTrustedFramedPeerOptions,
|
|
5
|
+
import type { IAttachTrustedFramedPeerOptions, IApplyBrowserAttachmentBindingRequest, IBrowserAttachmentBinding, TBrowserCapabilityDescriptor, TBrowserCapabilityAuthorizationRequest, IBrowserRuntimeFrameSubscription, IBrowserRuntimeOperationOptions, IBrowserRuntimeOptions, IBrowserResourceRegistration, IBrowserRuntimeState, ICreateBrowserResourceRequest, IRegisterBrowserResourceRequest, TIssueBrowserCapabilityRequest, TIssuedBrowserCapability, ILiveBrowserSessionLike, TBrowserActorRole, TBrowserAgentAction, TBrowserAgentActionResult, TBrowserRuntimeEvent } from './interfaces.js';
|
|
6
6
|
import { TransitionMutex } from './utils.js';
|
|
7
7
|
import { BrowserRuntimeFramedServerPeer } from './classes.framed.js';
|
|
8
|
-
|
|
8
|
+
type TCapabilityRecord = TBrowserCapabilityDescriptor & {
|
|
9
9
|
digest: plugins.Buffer;
|
|
10
10
|
state: 'active' | 'revoked' | 'expired';
|
|
11
11
|
expiryTimer: ReturnType<typeof setTimeout>;
|
|
@@ -16,18 +16,20 @@ interface ICapabilityRecord extends IBrowserCapabilityDescriptor {
|
|
|
16
16
|
revocationComplete?: boolean;
|
|
17
17
|
leaseCleanupComplete?: boolean;
|
|
18
18
|
disconnectComplete?: boolean;
|
|
19
|
-
|
|
19
|
+
revoking?: boolean;
|
|
20
|
+
};
|
|
20
21
|
interface ILeaseRecord {
|
|
21
22
|
leaseId: string;
|
|
22
|
-
capability:
|
|
23
|
+
capability: TCapabilityRecord;
|
|
23
24
|
digest: plugins.Buffer;
|
|
24
25
|
peerId: string;
|
|
25
26
|
role: TBrowserActorRole;
|
|
26
|
-
slot:
|
|
27
|
+
slot: IResourceSlot;
|
|
27
28
|
controller: AbortController;
|
|
28
29
|
released: boolean;
|
|
29
30
|
releasePromise?: Promise<void>;
|
|
30
31
|
releaseGeneration?: number;
|
|
32
|
+
releaseOwnsFence?: boolean;
|
|
31
33
|
}
|
|
32
34
|
interface IOperationRecord {
|
|
33
35
|
operationId: string;
|
|
@@ -46,12 +48,19 @@ interface IFrameSubscriptionRecord {
|
|
|
46
48
|
};
|
|
47
49
|
closed: boolean;
|
|
48
50
|
}
|
|
49
|
-
interface
|
|
51
|
+
interface IResourceSlot {
|
|
50
52
|
projectId: string;
|
|
53
|
+
browserResourceId: string;
|
|
54
|
+
registeredAt: number;
|
|
55
|
+
attachmentBinding: IBrowserAttachmentBinding;
|
|
51
56
|
mutex: TransitionMutex;
|
|
52
|
-
|
|
57
|
+
arbitrationGeneration: number;
|
|
58
|
+
incarnationGeneration: number;
|
|
53
59
|
fencingGeneration?: number;
|
|
54
60
|
permanentlyFenced: boolean;
|
|
61
|
+
retirementPending: boolean;
|
|
62
|
+
attachmentFenceCount: number;
|
|
63
|
+
attachmentRetryBinding?: IBrowserAttachmentBinding;
|
|
55
64
|
session?: ILiveBrowserSessionLike;
|
|
56
65
|
proxy?: BrowserEgressProxy;
|
|
57
66
|
profileDirectory?: string;
|
|
@@ -60,16 +69,18 @@ interface IProjectSlot {
|
|
|
60
69
|
operation?: IOperationRecord;
|
|
61
70
|
frameSubscription?: IFrameSubscriptionRecord;
|
|
62
71
|
idleTimer?: ReturnType<typeof setTimeout>;
|
|
72
|
+
lifecycleTail: Promise<void>;
|
|
73
|
+
lifecycleOperationCount: number;
|
|
74
|
+
terminationRequestGeneration: number;
|
|
75
|
+
terminationFenceGeneration?: number;
|
|
76
|
+
terminatePromise?: Promise<void>;
|
|
77
|
+
retirePromise?: Promise<void>;
|
|
78
|
+
attachmentOperations: Map<string, Promise<IBrowserResourceRegistration>>;
|
|
63
79
|
}
|
|
64
|
-
export
|
|
80
|
+
export type TAcquireBrowserRuntimeLeaseOptions = TBrowserCapabilityAuthorizationRequest & {
|
|
65
81
|
capabilityToken: string;
|
|
66
|
-
peerId: string;
|
|
67
|
-
expectedRole?: TBrowserActorRole;
|
|
68
|
-
expectedSource?: TBrowserCapabilitySource;
|
|
69
|
-
scopeId?: string;
|
|
70
|
-
sessionId?: string;
|
|
71
82
|
signal?: AbortSignal;
|
|
72
|
-
}
|
|
83
|
+
};
|
|
73
84
|
export declare class BrowserRuntime {
|
|
74
85
|
private readonly options;
|
|
75
86
|
private readonly profileRoot;
|
|
@@ -77,6 +88,8 @@ export declare class BrowserRuntime {
|
|
|
77
88
|
private readonly lockPath;
|
|
78
89
|
private readonly artifactStore;
|
|
79
90
|
private readonly slots;
|
|
91
|
+
private readonly retiredResourceIds;
|
|
92
|
+
private readonly retiredResourceKeys;
|
|
80
93
|
private readonly capabilitiesByDigest;
|
|
81
94
|
private readonly capabilitiesById;
|
|
82
95
|
private readonly failedRevocations;
|
|
@@ -92,15 +105,27 @@ export declare class BrowserRuntime {
|
|
|
92
105
|
private lifecycleController;
|
|
93
106
|
private pendingCapabilities;
|
|
94
107
|
private readonly pendingCapabilitiesByProject;
|
|
108
|
+
private readonly pendingCapabilitiesByResource;
|
|
109
|
+
private pendingLaunches;
|
|
110
|
+
private readonly pendingLaunchesByProject;
|
|
95
111
|
constructor(options: IBrowserRuntimeOptions | IBrowserRuntimeTestingOptions);
|
|
96
112
|
start(): Promise<void>;
|
|
97
113
|
stop(): Promise<void>;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
114
|
+
createResource(requestArg: ICreateBrowserResourceRequest): IBrowserResourceRegistration;
|
|
115
|
+
registerResource(requestArg: IRegisterBrowserResourceRequest): IBrowserResourceRegistration;
|
|
116
|
+
listResources(): IBrowserResourceRegistration[];
|
|
117
|
+
applyAttachmentBinding(requestArg: IApplyBrowserAttachmentBindingRequest): Promise<IBrowserResourceRegistration>;
|
|
118
|
+
terminateResource(projectIdArg: string, browserResourceIdArg: string): Promise<void>;
|
|
119
|
+
retireResource(projectIdArg: string, browserResourceIdArg: string): Promise<void>;
|
|
120
|
+
issueCapability(requestArg: TIssueBrowserCapabilityRequest): Promise<TIssuedBrowserCapability>;
|
|
121
|
+
acquireLease(optionsArg: TAcquireBrowserRuntimeLeaseOptions): Promise<BrowserRuntimeLease>;
|
|
122
|
+
authorizeCapability(capabilityTokenArg: string, expectedArg: TBrowserCapabilityAuthorizationRequest): TBrowserCapabilityDescriptor;
|
|
101
123
|
revokeCapability(capabilityIdArg: string): Promise<void>;
|
|
124
|
+
/** @internal */
|
|
125
|
+
revokeFramedCapability(capabilityIdArg: string): Promise<void>;
|
|
126
|
+
/** @internal */
|
|
127
|
+
beforeFramedPeerLeasePublication(): Promise<void>;
|
|
102
128
|
disconnectPeer(peerIdArg: string): Promise<void>;
|
|
103
|
-
retireProject(projectIdArg: string): Promise<void>;
|
|
104
129
|
attachTrustedFramedPeer(options: IAttachTrustedFramedPeerOptions): BrowserRuntimeFramedServerPeer;
|
|
105
130
|
getArtifactStore(): BrowserArtifactStore;
|
|
106
131
|
/** @internal */
|
|
@@ -136,7 +161,6 @@ export declare class BrowserRuntime {
|
|
|
136
161
|
private startInternal;
|
|
137
162
|
private stopInternal;
|
|
138
163
|
private requireRunning;
|
|
139
|
-
private getOrCreateSlot;
|
|
140
164
|
private acquireAgentLease;
|
|
141
165
|
private acquireHumanLease;
|
|
142
166
|
private createLeaseRecord;
|
|
@@ -144,27 +168,57 @@ export declare class BrowserRuntime {
|
|
|
144
168
|
private runOperation;
|
|
145
169
|
private executeAgentActionInternal;
|
|
146
170
|
private resolveSemanticTarget;
|
|
147
|
-
private
|
|
171
|
+
private resourceState;
|
|
148
172
|
private handleSessionEvent;
|
|
149
173
|
private pushToSubscription;
|
|
150
174
|
private closeFrameSubscription;
|
|
151
175
|
private acknowledgeFrameInBackground;
|
|
176
|
+
private handleFrameFailure;
|
|
177
|
+
private trackFrameCapabilityRevocation;
|
|
152
178
|
private requireValidLease;
|
|
153
179
|
private resolveCapability;
|
|
154
180
|
private describeCapability;
|
|
155
181
|
private revokeCapabilityRecord;
|
|
182
|
+
private invalidateCapabilityRecord;
|
|
156
183
|
private releaseLeaseRecord;
|
|
157
184
|
private releaseLeaseRecordInternal;
|
|
158
185
|
private closeFrameSubscriptionIfLease;
|
|
159
186
|
private quiesceSlot;
|
|
160
187
|
private enforceOperationQuiescence;
|
|
161
188
|
private terminateSlotSession;
|
|
162
|
-
private
|
|
189
|
+
private scheduleIdleTermination;
|
|
163
190
|
private stopProxyBounded;
|
|
164
|
-
private
|
|
191
|
+
private terminateRegisteredResourceInternal;
|
|
192
|
+
private retireRegisteredResourceInternal;
|
|
193
|
+
private framedPeersForResource;
|
|
165
194
|
private assertSlotAvailable;
|
|
166
195
|
private throwIfAcquisitionAborted;
|
|
167
196
|
private requireHuman;
|
|
197
|
+
private enqueueResourceLifecycle;
|
|
198
|
+
private notifyFramedLeaseEnded;
|
|
199
|
+
private applyAttachmentBindingInternal;
|
|
200
|
+
private attachmentBindingKey;
|
|
201
|
+
private tombstoneIndex;
|
|
202
|
+
private addRetiredTombstone;
|
|
203
|
+
private hasRetiredTombstone;
|
|
204
|
+
private resourceKey;
|
|
205
|
+
private validateIdentifier;
|
|
206
|
+
private validateResourceId;
|
|
207
|
+
private validateQualifiedSessionId;
|
|
208
|
+
private validateAttachmentBinding;
|
|
209
|
+
private bindingsEqual;
|
|
210
|
+
private sessionsEqual;
|
|
211
|
+
private resolveResourceRequest;
|
|
212
|
+
private getRegisteredSlot;
|
|
213
|
+
private describeResource;
|
|
214
|
+
private assertCapabilityBinding;
|
|
215
|
+
private assertCapabilityStillAttached;
|
|
216
|
+
private validateExpectedCapabilityBinding;
|
|
217
|
+
private describeCapabilityIdentity;
|
|
218
|
+
private capabilityIdentitiesEqual;
|
|
219
|
+
private capabilitiesForResource;
|
|
220
|
+
private reserveLaunch;
|
|
221
|
+
private releaseLaunchReservation;
|
|
168
222
|
private validateRole;
|
|
169
223
|
private validateSource;
|
|
170
224
|
private trackCleanup;
|
|
@@ -176,8 +230,12 @@ export declare class BrowserRuntimeLease {
|
|
|
176
230
|
/** @internal */
|
|
177
231
|
constructor(runtime: BrowserRuntime, record: ILeaseRecord);
|
|
178
232
|
get leaseId(): string;
|
|
233
|
+
get capabilityId(): string;
|
|
179
234
|
get role(): TBrowserActorRole;
|
|
180
235
|
get projectId(): string;
|
|
236
|
+
get browserResourceId(): string;
|
|
237
|
+
get attachmentAuthorityId(): string;
|
|
238
|
+
get attachmentRevision(): number;
|
|
181
239
|
getState(): IBrowserRuntimeState;
|
|
182
240
|
executeAgentAction(action: TBrowserAgentAction, options?: IBrowserRuntimeOperationOptions): Promise<TBrowserAgentActionResult>;
|
|
183
241
|
executeHumanAction(action: TBrowserAgentAction, options?: IBrowserRuntimeOperationOptions): Promise<TBrowserAgentActionResult>;
|