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