@revoengine/cli 1.0.31 → 1.0.34
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/CHANGELOG.md +25 -0
- package/README.md +152 -24
- package/dist/src/argument-contract.d.ts +17 -0
- package/dist/src/argument-contract.js +359 -0
- package/dist/src/automation-contract.generated.d.ts +56 -22
- package/dist/src/automation-contract.generated.js +68 -26
- package/dist/src/cli.js +15 -13
- package/dist/src/client.d.ts +34 -2
- package/dist/src/client.js +76 -13
- package/dist/src/commands/agents.js +5 -1
- package/dist/src/commands/auth.js +2 -0
- package/dist/src/commands/component.js +34 -17
- package/dist/src/commands/database-tables.js +15 -4
- package/dist/src/commands/database-views.js +5 -1
- package/dist/src/commands/endpoints.js +5 -1
- package/dist/src/commands/env.js +5 -1
- package/dist/src/commands/events.js +5 -1
- package/dist/src/commands/groups.js +5 -1
- package/dist/src/commands/info.js +2 -0
- package/dist/src/commands/job-templates.js +5 -1
- package/dist/src/commands/metadata.js +2 -0
- package/dist/src/commands/migrate.d.ts +2 -2
- package/dist/src/commands/migrate.js +33 -7
- package/dist/src/commands/project.js +19 -14
- package/dist/src/commands/request.js +2 -0
- package/dist/src/commands/role-groups.js +5 -1
- package/dist/src/commands/schedules.js +5 -1
- package/dist/src/commands/search.js +2 -0
- package/dist/src/commands/service-accounts.js +5 -1
- package/dist/src/commands/studio.js +2 -0
- package/dist/src/commands/terminal-browser-central-profile.d.ts +65 -0
- package/dist/src/commands/terminal-browser-central-profile.js +203 -0
- package/dist/src/commands/terminal-browser-human-input.d.ts +3 -1
- package/dist/src/commands/terminal-browser-human-input.js +3 -1
- package/dist/src/commands/terminal-browser-interaction.js +1 -1
- package/dist/src/commands/terminal-browser-live-protocol.d.ts +34 -2
- package/dist/src/commands/terminal-browser-live-protocol.js +28 -12
- package/dist/src/commands/terminal-browser-live-transport.d.ts +1 -0
- package/dist/src/commands/terminal-browser-live-transport.js +9 -5
- package/dist/src/commands/terminal-browser-live.d.ts +24 -3
- package/dist/src/commands/terminal-browser-live.js +199 -30
- package/dist/src/commands/terminal-browser-page-input.d.ts +4 -1
- package/dist/src/commands/terminal-browser-page-input.js +46 -1
- package/dist/src/commands/terminal-browser-profile-crypto.d.ts +30 -0
- package/dist/src/commands/terminal-browser-profile-crypto.js +101 -0
- package/dist/src/commands/terminal-browser-profile-import-runner.d.ts +31 -0
- package/dist/src/commands/terminal-browser-profile-import-runner.js +112 -0
- package/dist/src/commands/terminal-browser-profile-import.d.ts +28 -0
- package/dist/src/commands/terminal-browser-profile-import.js +125 -0
- package/dist/src/commands/terminal-browser-profile-import.protocol.d.ts +50 -0
- package/dist/src/commands/terminal-browser-profile-import.protocol.js +52 -0
- package/dist/src/commands/terminal-browser-profile-preferences.d.ts +1 -0
- package/dist/src/commands/terminal-browser-profile-preferences.js +16 -0
- package/dist/src/commands/terminal-browser-profile-sync.d.ts +14 -0
- package/dist/src/commands/terminal-browser-profile-sync.js +169 -0
- package/dist/src/commands/terminal-browser-profile-sync.protocol.d.ts +50 -0
- package/dist/src/commands/terminal-browser-profile-sync.protocol.js +19 -0
- package/dist/src/commands/terminal-browser-profile.d.ts +10 -1
- package/dist/src/commands/terminal-browser-profile.js +30 -4
- package/dist/src/commands/terminal-browser-recording.d.ts +39 -0
- package/dist/src/commands/terminal-browser-recording.js +74 -0
- package/dist/src/commands/terminal-browser-recording.protocol.d.ts +49 -0
- package/dist/src/commands/terminal-browser-recording.protocol.js +16 -0
- package/dist/src/commands/terminal-browser.d.ts +14 -1
- package/dist/src/commands/terminal-browser.js +98 -33
- package/dist/src/commands/terminal-file-descriptor.d.ts +9 -0
- package/dist/src/commands/terminal-file-descriptor.js +39 -0
- package/dist/src/commands/terminal-file.js +41 -6
- package/dist/src/commands/terminal-image.js +3 -31
- package/dist/src/commands/terminal-output-buffer.d.ts +18 -1
- package/dist/src/commands/terminal-output-buffer.js +95 -8
- package/dist/src/commands/terminal-process-group.d.ts +25 -0
- package/dist/src/commands/terminal-process-group.js +144 -0
- package/dist/src/commands/terminal.d.ts +3 -1
- package/dist/src/commands/terminal.js +366 -80
- package/dist/src/commands/tests.js +2 -0
- package/dist/src/component-lock.d.ts +15 -1
- package/dist/src/component-lock.js +96 -10
- package/dist/src/env-sync.js +12 -6
- package/dist/src/migration.d.ts +7 -0
- package/dist/src/migration.js +39 -21
- package/dist/src/planning-snapshot.d.ts +3 -0
- package/dist/src/planning-snapshot.js +60 -2
- package/dist/src/project.d.ts +1 -0
- package/dist/src/project.js +7 -8
- package/dist/src/resource-syncs/agent-sync.js +76 -24
- package/dist/src/resource-syncs/database-table-sync.d.ts +8 -1
- package/dist/src/resource-syncs/database-table-sync.js +66 -32
- package/dist/src/resource-syncs/database-view-sync.js +41 -28
- package/dist/src/resource-syncs/endpoint-sync.js +90 -18
- package/dist/src/resource-syncs/event-sync.js +33 -14
- package/dist/src/resource-syncs/group-sync.js +21 -11
- package/dist/src/resource-syncs/job-template-sync.js +98 -37
- package/dist/src/resource-syncs/role-group-sync.js +22 -11
- package/dist/src/resource-syncs/schedule-sync.js +26 -11
- package/dist/src/resource-syncs/service-account-sync.js +22 -11
- package/dist/src/reviewed-plan.js +3 -0
- package/dist/src/runtime-view.js +2 -18
- package/dist/src/sync-omit-command.d.ts +6 -0
- package/dist/src/sync-omit-command.js +49 -0
- package/dist/src/sync-omit-write-fence.d.ts +10 -0
- package/dist/src/sync-omit-write-fence.js +134 -0
- package/dist/src/sync-omit.d.ts +59 -0
- package/dist/src/sync-omit.js +469 -0
- package/dist/src/sync-output.d.ts +3 -3
- package/dist/src/ui.js +11 -5
- package/dist/src/update-notifier.d.ts +1 -1
- package/dist/src/update-notifier.js +2 -1
- package/dist/src/utils.js +46 -17
- package/dist/src/workspace-prune.js +11 -3
- package/dist/src/workspace-write-lock.d.ts +7 -0
- package/dist/src/workspace-write-lock.js +144 -0
- package/package.json +6 -5
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { BrowserProfileKeyScope, BrowserProfileSealedKey } from './terminal-browser-profile-crypto.ts';
|
|
2
|
+
/** Private runner channel only. Never forward grants, keys or transfer URLs into execution output. */
|
|
3
|
+
export type BrowserProfileRunnerGrant = {
|
|
4
|
+
profile: {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
scope: BrowserProfileKeyScope;
|
|
9
|
+
sealedKey: BrowserProfileSealedKey;
|
|
10
|
+
revision: number;
|
|
11
|
+
leaseRemainingMs: number;
|
|
12
|
+
download: {
|
|
13
|
+
url: string;
|
|
14
|
+
size: number;
|
|
15
|
+
digest: string;
|
|
16
|
+
} | null;
|
|
17
|
+
};
|
|
18
|
+
export type BrowserProfileSyncRequest = {
|
|
19
|
+
type: 'browser_profile_sync';
|
|
20
|
+
requestId: string;
|
|
21
|
+
connectionId: string;
|
|
22
|
+
browserSessionId: string;
|
|
23
|
+
operation: 'renew' | 'upload' | 'commit' | 'readback' | 'release';
|
|
24
|
+
expectedRevision?: number;
|
|
25
|
+
size?: number;
|
|
26
|
+
digest?: string;
|
|
27
|
+
uploadId?: string;
|
|
28
|
+
};
|
|
29
|
+
export type BrowserProfileSyncResult = {
|
|
30
|
+
type: 'browser_profile_sync_result';
|
|
31
|
+
requestId: string;
|
|
32
|
+
connectionId: string;
|
|
33
|
+
ok: boolean;
|
|
34
|
+
error?: string;
|
|
35
|
+
leaseRemainingMs?: number;
|
|
36
|
+
revision?: number;
|
|
37
|
+
keyVersion?: string;
|
|
38
|
+
download?: {
|
|
39
|
+
url: string;
|
|
40
|
+
size: number;
|
|
41
|
+
digest: string;
|
|
42
|
+
} | null;
|
|
43
|
+
upload?: {
|
|
44
|
+
uploadId: string;
|
|
45
|
+
url: string;
|
|
46
|
+
method: 'PUT' | 'POST';
|
|
47
|
+
headers: Record<string, string>;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export declare function validBrowserProfileSyncRequest(value: unknown): value is BrowserProfileSyncRequest;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const UUID = /^[a-f\d]{8}-(?:[a-f\d]{4}-){3}[a-f\d]{12}$/iu;
|
|
2
|
+
const HEX = /^[a-f\d]{64}$/u;
|
|
3
|
+
export function validBrowserProfileSyncRequest(value) {
|
|
4
|
+
const v = value;
|
|
5
|
+
if (!v || v.type !== 'browser_profile_sync' || !UUID.test(v.requestId) || !UUID.test(v.connectionId)
|
|
6
|
+
|| !HEX.test(v.browserSessionId) || !['renew', 'upload', 'commit', 'readback', 'release'].includes(v.operation))
|
|
7
|
+
return false;
|
|
8
|
+
const base = ['type', 'requestId', 'connectionId', 'browserSessionId', 'operation'];
|
|
9
|
+
if (v.operation === 'upload')
|
|
10
|
+
return Object.keys(v).every(key => [...base, 'expectedRevision', 'size', 'digest'].includes(key))
|
|
11
|
+
&& Number.isSafeInteger(v.expectedRevision) && v.expectedRevision >= 0 && v.expectedRevision < 2147483647
|
|
12
|
+
&& Number.isSafeInteger(v.size) && v.size >= 28 && v.size <= 8388636 && HEX.test(v.digest);
|
|
13
|
+
if (v.operation === 'commit')
|
|
14
|
+
return UUID.test(v.uploadId) && Object.keys(v).every(key => [...base, 'uploadId'].includes(key));
|
|
15
|
+
if (v.operation === 'readback')
|
|
16
|
+
return Number.isSafeInteger(v.expectedRevision) && v.expectedRevision >= 0
|
|
17
|
+
&& v.expectedRevision < 2147483647 && Object.keys(v).every(key => [...base, 'expectedRevision'].includes(key));
|
|
18
|
+
return Object.keys(v).every(key => base.includes(key));
|
|
19
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { spawn, spawnSync } from 'node:child_process';
|
|
2
2
|
import type { BrowserContext } from 'playwright-core';
|
|
3
3
|
export type BrowserProfileState = Awaited<ReturnType<BrowserContext['storageState']>>;
|
|
4
|
+
export interface BrowserProfilePersistenceLease {
|
|
5
|
+
readonly state?: BrowserProfileState;
|
|
6
|
+
save(state: BrowserProfileState): void | Promise<void>;
|
|
7
|
+
release(): void | Promise<void>;
|
|
8
|
+
}
|
|
4
9
|
export type BrowserProfileScope = {
|
|
5
10
|
name: string;
|
|
6
11
|
baseUrl: string;
|
|
@@ -24,6 +29,7 @@ type KeychainExec = typeof spawnSync;
|
|
|
24
29
|
export declare function macOSBrowserProfileKeyStore(platform?: NodeJS.Platform, execute?: KeychainExec, executeAsync?: typeof spawn): BrowserProfileKeyStore;
|
|
25
30
|
export declare class BrowserProfileLease {
|
|
26
31
|
private released;
|
|
32
|
+
private forgotten;
|
|
27
33
|
readonly state: BrowserProfileState | undefined;
|
|
28
34
|
private revision;
|
|
29
35
|
private readonly file;
|
|
@@ -31,10 +37,13 @@ export declare class BrowserProfileLease {
|
|
|
31
37
|
private readonly key;
|
|
32
38
|
private readonly releaseLock;
|
|
33
39
|
private readonly assertLock;
|
|
34
|
-
|
|
40
|
+
private readonly removeKey?;
|
|
41
|
+
constructor(file: string, scopeId: string, key: Buffer, releaseLock: () => void, assertLock: () => void, removeKey?: () => Promise<void>);
|
|
35
42
|
private aad;
|
|
36
43
|
private read;
|
|
37
44
|
save(state: BrowserProfileState): void;
|
|
45
|
+
/** Explicit migration cleanup while the imported source still owns its writer lock. */
|
|
46
|
+
forget(): Promise<void>;
|
|
38
47
|
release(): void;
|
|
39
48
|
}
|
|
40
49
|
export declare class BrowserAuthProfileStore {
|
|
@@ -137,6 +137,7 @@ function snapshotFiles(file) {
|
|
|
137
137
|
}
|
|
138
138
|
export class BrowserProfileLease {
|
|
139
139
|
released = false;
|
|
140
|
+
forgotten = false;
|
|
140
141
|
state;
|
|
141
142
|
revision = 0;
|
|
142
143
|
file;
|
|
@@ -144,12 +145,14 @@ export class BrowserProfileLease {
|
|
|
144
145
|
key;
|
|
145
146
|
releaseLock;
|
|
146
147
|
assertLock;
|
|
147
|
-
|
|
148
|
+
removeKey;
|
|
149
|
+
constructor(file, scopeId, key, releaseLock, assertLock, removeKey) {
|
|
148
150
|
this.file = file;
|
|
149
151
|
this.scopeId = scopeId;
|
|
150
152
|
this.key = key;
|
|
151
153
|
this.releaseLock = releaseLock;
|
|
152
154
|
this.assertLock = assertLock;
|
|
155
|
+
this.removeKey = removeKey;
|
|
153
156
|
const snapshot = this.read();
|
|
154
157
|
if (snapshot) {
|
|
155
158
|
this.revision = snapshot.revision;
|
|
@@ -202,7 +205,7 @@ export class BrowserProfileLease {
|
|
|
202
205
|
}
|
|
203
206
|
}
|
|
204
207
|
save(state) {
|
|
205
|
-
if (this.released)
|
|
208
|
+
if (this.released || this.forgotten)
|
|
206
209
|
throw new Error('browser_profile_closed');
|
|
207
210
|
this.assertLock();
|
|
208
211
|
if ((this.read()?.revision ?? 0) !== this.revision)
|
|
@@ -247,6 +250,19 @@ export class BrowserProfileLease {
|
|
|
247
250
|
fs.rmSync(temp, { force: true });
|
|
248
251
|
}
|
|
249
252
|
}
|
|
253
|
+
/** Explicit migration cleanup while the imported source still owns its writer lock. */
|
|
254
|
+
async forget() {
|
|
255
|
+
if (this.released || this.forgotten || !this.removeKey)
|
|
256
|
+
throw new Error('browser_profile_closed');
|
|
257
|
+
this.assertLock();
|
|
258
|
+
if ((this.read()?.revision ?? 0) !== this.revision)
|
|
259
|
+
throw new Error('browser_profile_changed');
|
|
260
|
+
this.forgotten = true;
|
|
261
|
+
for (const snapshot of snapshotFiles(this.file))
|
|
262
|
+
fs.unlinkSync(snapshot.file);
|
|
263
|
+
await this.removeKey();
|
|
264
|
+
this.assertLock();
|
|
265
|
+
}
|
|
250
266
|
release() {
|
|
251
267
|
if (this.released)
|
|
252
268
|
return;
|
|
@@ -362,7 +378,12 @@ export class BrowserAuthProfileStore {
|
|
|
362
378
|
}
|
|
363
379
|
if (key.length !== 32)
|
|
364
380
|
throw new Error('browser_profile_keystore_unavailable');
|
|
365
|
-
return new BrowserProfileLease(file, id, key, lock.release, lock.assert)
|
|
381
|
+
return new BrowserProfileLease(file, id, key, lock.release, lock.assert, async () => {
|
|
382
|
+
if (this.keys.removeAsync)
|
|
383
|
+
await this.keys.removeAsync(id);
|
|
384
|
+
else
|
|
385
|
+
this.keys.remove(id);
|
|
386
|
+
});
|
|
366
387
|
}
|
|
367
388
|
catch (error) {
|
|
368
389
|
key?.fill(0);
|
|
@@ -393,7 +414,12 @@ export class BrowserAuthProfileStore {
|
|
|
393
414
|
lock.assert();
|
|
394
415
|
if (key.length !== 32)
|
|
395
416
|
throw new Error('browser_profile_keystore_unavailable');
|
|
396
|
-
return new BrowserProfileLease(file, id, key, lock.release, lock.assert)
|
|
417
|
+
return new BrowserProfileLease(file, id, key, lock.release, lock.assert, async () => {
|
|
418
|
+
if (this.keys.removeAsync)
|
|
419
|
+
await this.keys.removeAsync(id);
|
|
420
|
+
else
|
|
421
|
+
this.keys.remove(id);
|
|
422
|
+
});
|
|
397
423
|
}
|
|
398
424
|
catch (error) {
|
|
399
425
|
key?.fill(0);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { BrowserLiveRecording } from './terminal-browser-live.ts';
|
|
2
|
+
import type { BrowserSessionRecordingGrant } from './terminal-browser-recording.protocol.ts';
|
|
3
|
+
import { transferWorkspaceFile } from './terminal-file.ts';
|
|
4
|
+
type Descriptor = {
|
|
5
|
+
uploadUrl?: string;
|
|
6
|
+
headers?: Array<{
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}>;
|
|
10
|
+
expiresAt?: number;
|
|
11
|
+
storageEntryId?: string;
|
|
12
|
+
};
|
|
13
|
+
type Options = {
|
|
14
|
+
grant: BrowserSessionRecordingGrant;
|
|
15
|
+
terminalId: string;
|
|
16
|
+
directory: string;
|
|
17
|
+
isAuthorized: () => boolean;
|
|
18
|
+
request: (route: string, token: string, body: {
|
|
19
|
+
size: number;
|
|
20
|
+
}) => Promise<Descriptor>;
|
|
21
|
+
onStatus: (status: 'saved' | 'failed' | 'backpressure', recordingId: string) => void;
|
|
22
|
+
transfer?: typeof transferWorkspaceFile;
|
|
23
|
+
};
|
|
24
|
+
/** Session-owned single-attempt PUT queue. No viewer/socket, transcript payload, cookies or raw credentials. */
|
|
25
|
+
export declare class BrowserSessionRecordingSink {
|
|
26
|
+
private chain;
|
|
27
|
+
private pending;
|
|
28
|
+
private pendingBytes;
|
|
29
|
+
private failed;
|
|
30
|
+
private readonly options;
|
|
31
|
+
constructor(options: Options);
|
|
32
|
+
get authorized(): boolean;
|
|
33
|
+
refresh(grant: BrowserSessionRecordingGrant, isAuthorized: () => boolean): void;
|
|
34
|
+
accept(recording: BrowserLiveRecording): boolean;
|
|
35
|
+
settled(): Promise<void>;
|
|
36
|
+
private assertAuthorized;
|
|
37
|
+
private save;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { transferWorkspaceFile, validateFileTransfer } from "./terminal-file.js";
|
|
4
|
+
/** Session-owned single-attempt PUT queue. No viewer/socket, transcript payload, cookies or raw credentials. */
|
|
5
|
+
export class BrowserSessionRecordingSink {
|
|
6
|
+
chain = Promise.resolve();
|
|
7
|
+
pending = 0;
|
|
8
|
+
pendingBytes = 0;
|
|
9
|
+
failed = false;
|
|
10
|
+
options;
|
|
11
|
+
constructor(options) { this.options = options; }
|
|
12
|
+
get authorized() { return this.options.isAuthorized() && this.options.grant.expiresAt > Date.now(); }
|
|
13
|
+
refresh(grant, isAuthorized) {
|
|
14
|
+
if (grant.browserSessionId !== this.options.grant.browserSessionId)
|
|
15
|
+
throw new Error('browser_recording_scope_invalid');
|
|
16
|
+
this.options.grant = grant;
|
|
17
|
+
this.options.isAuthorized = isAuthorized;
|
|
18
|
+
}
|
|
19
|
+
accept(recording) {
|
|
20
|
+
if (recording.mode === 'local')
|
|
21
|
+
return true;
|
|
22
|
+
if (this.failed)
|
|
23
|
+
return false;
|
|
24
|
+
if (this.pending >= 4 || this.pendingBytes + recording.size > 256 * 1024 * 1024) {
|
|
25
|
+
this.options.onStatus('backpressure', recording.recordingId);
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
this.pending++;
|
|
29
|
+
this.pendingBytes += recording.size;
|
|
30
|
+
this.chain = this.chain.then(() => this.save(recording)).catch(() => {
|
|
31
|
+
this.failed = true;
|
|
32
|
+
this.options.onStatus('failed', recording.recordingId);
|
|
33
|
+
}).finally(() => { this.pending--; this.pendingBytes -= recording.size; });
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
async settled() { await this.chain; }
|
|
37
|
+
assertAuthorized() {
|
|
38
|
+
if (!this.authorized)
|
|
39
|
+
throw new Error('browser_recording_scope_expired');
|
|
40
|
+
}
|
|
41
|
+
async save(recording) {
|
|
42
|
+
this.assertAuthorized();
|
|
43
|
+
if (path.dirname(recording.path) !== this.options.directory)
|
|
44
|
+
throw new Error('browser_recording_path_invalid');
|
|
45
|
+
const source = await fs.lstat(recording.path);
|
|
46
|
+
if (!source.isFile() || source.isSymbolicLink() || source.size !== recording.size)
|
|
47
|
+
throw new Error('browser_recording_source_changed');
|
|
48
|
+
const { grant, terminalId, request } = this.options;
|
|
49
|
+
const route = `/agents/terminals/${terminalId}/browser-recording-runner/${grant.grantId}/${recording.recordingId}`;
|
|
50
|
+
const descriptor = await request(`${route}/provision`, grant.token, { size: recording.size });
|
|
51
|
+
this.assertAuthorized();
|
|
52
|
+
if (!descriptor.storageEntryId) {
|
|
53
|
+
if (!descriptor.expiresAt || descriptor.expiresAt > grant.expiresAt || descriptor.expiresAt <= Date.now())
|
|
54
|
+
throw new Error('browser_recording_upload_invalid');
|
|
55
|
+
const transfer = { path: recording.path, url: descriptor.uploadUrl, headers: descriptor.headers, overwrite: false, offset: null, length: null };
|
|
56
|
+
if (!validateFileTransfer(transfer))
|
|
57
|
+
throw new Error('browser_recording_upload_invalid');
|
|
58
|
+
// A transport failure may mean the provider accepted the PUT. Check finalization, never repeat it.
|
|
59
|
+
try {
|
|
60
|
+
const result = await (this.options.transfer || transferWorkspaceFile)(this.options.directory, 'upload_file', transfer, AbortSignal.timeout(Math.max(1, descriptor.expiresAt - Date.now())));
|
|
61
|
+
if (!result.complete)
|
|
62
|
+
throw new Error('browser_recording_upload_unconfirmed');
|
|
63
|
+
}
|
|
64
|
+
catch { /* Exact-size provider verification below resolves an uncertain PUT without replay. */ }
|
|
65
|
+
this.assertAuthorized();
|
|
66
|
+
const finalized = await request(`${route}/finalize`, grant.token, { size: recording.size });
|
|
67
|
+
if (!finalized.storageEntryId)
|
|
68
|
+
throw new Error('browser_recording_upload_unconfirmed');
|
|
69
|
+
}
|
|
70
|
+
this.options.onStatus('saved', recording.recordingId);
|
|
71
|
+
if (recording.mode === 'storage')
|
|
72
|
+
await fs.unlink(recording.path);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Backend-owned destination. Not accepted from the runner or model. */
|
|
2
|
+
export type BrowserRecordingStorageScope = {
|
|
3
|
+
kind: 'private';
|
|
4
|
+
namespace: string;
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'agent';
|
|
7
|
+
namespace: 'agents' | 'explorer';
|
|
8
|
+
agentId: string;
|
|
9
|
+
agentRunId: string;
|
|
10
|
+
rootStorageEntryId: string;
|
|
11
|
+
};
|
|
12
|
+
/** Private execute channel only. Tokens and signed upload targets must never enter model output or logs. */
|
|
13
|
+
export type BrowserSessionRecordingGrant = {
|
|
14
|
+
grantId: string;
|
|
15
|
+
token: string;
|
|
16
|
+
browserSessionId: string;
|
|
17
|
+
expiresAt: number;
|
|
18
|
+
settings: {
|
|
19
|
+
fps: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
alwaysRecord: boolean;
|
|
23
|
+
recordingMode: 'local' | 'storage' | 'both';
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type BrowserSessionRecordingAuthority = Omit<BrowserSessionRecordingGrant, 'token'> & {
|
|
27
|
+
/** Older personal grants may omit this; Agent uploads always require a pinned scope. */
|
|
28
|
+
storageScope?: BrowserRecordingStorageScope;
|
|
29
|
+
tokenHash: string;
|
|
30
|
+
instanceId: string;
|
|
31
|
+
actorUserId: string;
|
|
32
|
+
threadId: string;
|
|
33
|
+
agentTerminalId: string;
|
|
34
|
+
agentTerminalWorkspaceId: string;
|
|
35
|
+
connectionId: string;
|
|
36
|
+
grantRevision: number;
|
|
37
|
+
connectionRevision: number;
|
|
38
|
+
browserProfileId?: string;
|
|
39
|
+
executionId: string;
|
|
40
|
+
network?: {
|
|
41
|
+
source: 'once' | 'lease' | 'thread';
|
|
42
|
+
authorizationId: string;
|
|
43
|
+
expiresAt: number | null;
|
|
44
|
+
access: 'local' | 'full';
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare const browserRecordingAuthorityKey: (id: string) => string;
|
|
48
|
+
export declare const browserRecordingConsentKey: (id: string) => string;
|
|
49
|
+
export declare function validBrowserRecordingGrant(value: unknown): value is BrowserSessionRecordingGrant;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const browserRecordingAuthorityKey = (id) => `terminal:browser-recording-authority:${id}`;
|
|
2
|
+
export const browserRecordingConsentKey = (id) => `terminal:browser-recording-consent:${id}`;
|
|
3
|
+
export function validBrowserRecordingGrant(value) {
|
|
4
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
5
|
+
return false;
|
|
6
|
+
const grant = value, settings = grant.settings;
|
|
7
|
+
return /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/iu.test(grant.grantId)
|
|
8
|
+
&& /^[A-Za-z0-9_-]{43}$/u.test(grant.token) && /^[a-f0-9]{64}$/iu.test(grant.browserSessionId)
|
|
9
|
+
&& Number.isSafeInteger(grant.expiresAt) && grant.expiresAt > Date.now() && grant.expiresAt <= Date.now() + 65 * 60000
|
|
10
|
+
&& !!settings && typeof settings === 'object' && !Array.isArray(settings)
|
|
11
|
+
&& Number.isInteger(settings.fps) && settings.fps >= 5 && settings.fps <= 60
|
|
12
|
+
&& Number.isInteger(settings.width) && settings.width >= 320 && settings.width <= 3840
|
|
13
|
+
&& Number.isInteger(settings.height) && settings.height >= 480 && settings.height <= 2160
|
|
14
|
+
&& typeof settings.alwaysRecord === 'boolean'
|
|
15
|
+
&& ['local', 'storage', 'both'].includes(settings.recordingMode);
|
|
16
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BrowserAuthProfileStore, type BrowserProfileScope } from './terminal-browser-profile.ts';
|
|
1
|
+
import { type BrowserAuthProfileStore, type BrowserProfilePersistenceLease, type BrowserProfileScope } from './terminal-browser-profile.ts';
|
|
2
2
|
import { type BrowserInteraction, type BrowserObservation } from './terminal-browser-interaction.ts';
|
|
3
3
|
import { BrowserLiveHandle, type BrowserLiveOptions } from './terminal-browser-live.ts';
|
|
4
4
|
export type BrowserAction = 'navigate' | 'dom' | 'click' | 'fill' | 'check' | 'select' | 'press' | 'scroll' | 'interact' | 'wait_for' | 'screenshot' | 'tabs' | 'new_tab' | 'select_tab' | 'close_tab' | 'close' | 'read_public';
|
|
@@ -42,6 +42,16 @@ export type BrowserActionInput = {
|
|
|
42
42
|
store: BrowserAuthProfileStore;
|
|
43
43
|
scope: BrowserProfileScope;
|
|
44
44
|
};
|
|
45
|
+
centralProfile?: {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
lease: BrowserProfilePersistenceLease;
|
|
49
|
+
};
|
|
50
|
+
recording?: {
|
|
51
|
+
options: BrowserLiveOptions;
|
|
52
|
+
networkAccessExpiresAt: number | null;
|
|
53
|
+
policyGrantRevision: number;
|
|
54
|
+
};
|
|
45
55
|
resolveAuthProfile?: () => BrowserActionInput['authProfile'] | Promise<BrowserActionInput['authProfile']>;
|
|
46
56
|
};
|
|
47
57
|
export type BrowserTab = {
|
|
@@ -49,6 +59,7 @@ export type BrowserTab = {
|
|
|
49
59
|
title: string;
|
|
50
60
|
url: string;
|
|
51
61
|
active: boolean;
|
|
62
|
+
popup?: boolean;
|
|
52
63
|
};
|
|
53
64
|
export type BrowserActionResult = {
|
|
54
65
|
dom: string;
|
|
@@ -90,6 +101,8 @@ export declare function threadBrowserScopes(): Array<{
|
|
|
90
101
|
export declare function closeThreadBrowserSession(browserSessionId: string): Promise<void>;
|
|
91
102
|
export declare function browserSessionIds(): string[];
|
|
92
103
|
export declare function hasBrowserSessions(): boolean;
|
|
104
|
+
/** Revocation closes only this central context and never checkpoints its authentication. */
|
|
105
|
+
export declare function revokeBrowserProfileSession(browserSessionId: string, profileId: string): Promise<void>;
|
|
93
106
|
export declare function writePrivateScreenshot(file: string, bytes: Buffer): void;
|
|
94
107
|
export declare function runBrowserAction(input: BrowserActionInput): Promise<BrowserActionResult>;
|
|
95
108
|
export declare function fillBrowserSecret(input: {
|