@revoengine/cli 1.0.14 → 1.0.15
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 +13 -13
- package/dist/src/client.d.ts +0 -11
- package/dist/src/client.js +0 -32
- package/dist/src/commands/env.js +1 -5
- package/dist/src/commands/terminal-browser.d.ts +1 -0
- package/dist/src/commands/terminal-browser.js +23 -1
- package/dist/src/commands/terminal-policy.d.ts +6 -0
- package/dist/src/commands/terminal-policy.js +19 -0
- package/dist/src/commands/terminal-pty.js +2 -0
- package/dist/src/commands/terminal-reconnect-grace.d.ts +19 -0
- package/dist/src/commands/terminal-reconnect-grace.js +58 -0
- package/dist/src/commands/terminal-service.d.ts +4 -3
- package/dist/src/commands/terminal-service.js +19 -15
- package/dist/src/commands/terminal.d.ts +17 -1
- package/dist/src/commands/terminal.js +390 -78
- package/dist/src/config.d.ts +0 -3
- package/dist/src/config.js +0 -2
- package/dist/src/migration.js +0 -1
- package/dist/src/resource-syncs/database-view-sync.d.ts +0 -1
- package/dist/src/resource-syncs/database-view-sync.js +1 -12
- package/package.json +5 -4
- package/scripts/ensure-pty-helper.mjs +0 -9
package/README.md
CHANGED
|
@@ -77,26 +77,26 @@ revo terminal status
|
|
|
77
77
|
An approved terminal can run as a per-user background service on macOS or Linux. The service uses the active project at installation, or an explicit `--project <name>`; use the same project when uninstalling after a switch.
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
|
-
revo terminal service install --workspace "$HOME/projects/my-project"
|
|
81
|
-
revo terminal service uninstall --workspace "$HOME/projects/my-project"
|
|
82
|
-
revo terminal disconnect --workspace "$HOME/projects/my-project"
|
|
80
|
+
revo terminal service install --workspace "$HOME/projects/my-project" --name "Work Mac"
|
|
81
|
+
revo terminal service uninstall --workspace "$HOME/projects/my-project" --name "Work Mac"
|
|
82
|
+
revo terminal disconnect --workspace "$HOME/projects/my-project" --name "Work Mac"
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
The service starts at login, reconnects automatically, and pins the selected project profile at installation
|
|
85
|
+
Stop the foreground runner before installing its service. The service starts at login, reconnects automatically, and pins the selected terminal UUID and project profile at installation. Multiple terminals can share one machine and workspace when they have distinct names; pass the same `--name` to `connect`, `service install|uninstall`, and `disconnect`. Without `--name`, the CLI uses the machine hostname. If two registrations have the same name, the CLI refuses an ambiguous choice; use `revo terminal status` to find the UUID and pass `--terminal-id <uuid>`. A legacy workspace service must be uninstalled before installing a terminal-specific service. Uninstall stops the selected service but keeps its grant and local registration. `disconnect` revokes only the selected grant and removes its local credential; uninstall its service first. On macOS, service logs are in `~/Library/Logs/RevoEngine/`. On Linux, inspect them with `journalctl --user -u <unit-name>`; `install` prints the unit name. Linux user services normally stop after logout unless an administrator enables user lingering.
|
|
86
86
|
|
|
87
87
|
Runner credentials are stored in `runner.json` beside the CLI configuration. Each executed shell command writes raw output to a private `runner-logs/<executionId>.log` there, capped at 10 MB per file. Logs older than 24 hours are removed when the next command starts; a runner left idle does not perform timed cleanup. Optional CLI HTTP tracing writes sanitized request metadata under the project `.revoengine/logs/http-trace/`. These are separate from the Assistant's server-side tool history and do not form a complete local transcript. Treat runner logs as sensitive because command output may contain secrets.
|
|
88
88
|
|
|
89
89
|
Terminal connection and execution metadata is also written under the CLI configuration at `logs/terminal/<agentTerminalId>/debug.log`. Each line has `[ISO UTC timestamp][severity][assistantThreadId][assistantMessageId] event` followed by allowlisted metadata such as the execution ID, operation, sandbox, exit code, and reconnect delay. Commands, browser URLs, input, output, and credentials are excluded. On the first write after UTC midnight or after a restart, the completed day moves to `YYYY-MM-DD-debug.log.gz`; archives older than 30 days are removed. The log directory is private (`0700`) and files are `0600`. Runner/service stderr remains available for startup failures that occur before this operational log is ready.
|
|
90
90
|
|
|
91
|
-
The Agent terminal has independent command and network grants. Grants are ceilings; each execution frame carries the requested sandbox and `networkAccess=none|local|full`, so a Full grant does not silently widen a workspace or local-only call. Workspace commands keep writes inside the registered workspace and a private temporary directory; a workspace shell with external networking uses `workspace-network`. An explicit `unrestricted` command requests host file access without adding network access. A localhost development server must request Local network access to bind its port. macOS uses Seatbelt for workspace isolation and host plus local-only network; Linux uses `bwrap` and fails closed for shell Local access because enforceable localhost-only isolation is unavailable there. Missing isolation support fails closed. The runner requires a complete `terminal_policy_v2` execution frame from Realtime, including requested command/network modes, grant revision and optional expiry. Temporary scope expiry stops affected work and closes Browser sessions using that scope. Workspace patches and stdin for a running process are supported. A personal API key is required.
|
|
91
|
+
The Agent terminal has independent command and network grants. Grants are ceilings; each execution frame carries the requested sandbox and `networkAccess=none|local|full`, so a Full grant does not silently widen a workspace or local-only call. Workspace commands keep writes inside the registered workspace and a private temporary directory; a workspace shell with external networking uses `workspace-network`. An explicit `unrestricted` command requests host file access without adding network access. A localhost development server must request Local network access to bind its port. macOS uses Seatbelt for workspace isolation and host plus local-only network; Linux uses `bwrap` and fails closed for shell Local access because enforceable localhost-only isolation is unavailable there. Missing isolation support fails closed. The runner requires a complete `terminal_policy_v2` execution frame from Realtime, including requested command/network modes, grant revision and optional expiry. New runners advertise `terminal_policy_selective_v1`: an increased grant takes effect on subsequent calls without disconnecting; a reduced grant stops only commands and Browser sessions no longer covered by the current grant or an unexpired temporary scope. Temporary scope expiry stops affected work and closes Browser sessions using that scope. Workspace patches and stdin for a running process are supported. A personal API key is required.
|
|
92
92
|
|
|
93
|
-
Browser actions use Playwright's Chromium headless shell. The CLI's npm install downloads
|
|
93
|
+
Browser actions use Playwright's Chromium headless shell. The CLI's npm install downloads that browser into Playwright's per-user cache without requiring Python 3; a separate Chrome installation is not required. If npm scripts were disabled or the download was interrupted, reinstall the CLI with scripts enabled before using Browser. Linux hosts still need Playwright's system libraries; an administrator can install them with `npx playwright install-deps chromium`.
|
|
94
94
|
|
|
95
95
|
The runner keeps a separate browser context for each connected assistant chat, so navigation, DOM inspection, clicks, form controls, waiting, scrolling, and screenshots share that chat's cookies and page state. It follows an SSO popup opened by a click or key press and returns to its opener when the popup closes. Browser sessions expire after 10 minutes idle (up to four per runner), on a Local or Full network lease expiry, or when the runner stops or its access is revoked. A one-time Browser network approval closes its context immediately after that action finishes. DOM results include bounded selector hints for interactive elements without their field values. The Browser action supports `fill`, `check`, `select`, `press`, `scroll`, and `wait_for` as well as navigation, DOM, and click. Ordinary `fill` rejects password and secret-like controls; the Assistant may request a one-time secure credential dialog, which encrypts the value to this runner and fills it in memory without sending it in model tool arguments. Screenshots can capture the viewport (default), the full page, one selected element, or a bounded viewport crop. For viewport capture, an optional selector limits only the returned DOM text; the image still covers the viewport. Element capture requires a selector. Full-page and crop capture reject selectors. A screenshot is uploaded and attached automatically; calling `save_image` on its local path uploads a second copy. For custom Playwright E2E scripts, run them as ordinary terminal commands in the project, using the requested sandbox and network grant; the Browser action does not execute arbitrary JavaScript.
|
|
96
96
|
|
|
97
|
-
Interactive PTY commands
|
|
97
|
+
Interactive PTY commands use the optional native `node-pty` package. An unavailable native build does not block CLI installation; PTY requests return `pty_unavailable` until the optional package can be installed. To skip native installation when PTY is not needed, install locally with `npm install --omit=optional @revoengine/cli` and run `npx revo`; npm 11.9 may still install the optional dependency during a global installation. On macOS, the runner verifies the spawn helper's executable permission when a PTY starts. Ordinary commands and local development servers run with pipes.
|
|
98
98
|
|
|
99
|
-
Local Browser mode filters HTTP and WebSocket requests and disables WebRTC, WebTransport, Worker and SharedWorker before page scripts. Worker-dependent pages may not work in this mode; Chromium is not enclosed in an OS network sandbox. A temporary Local or Full network lease closes the Browser context at expiry, including before a queued secure credential fill. A lost WebSocket connection retains running processes and Browser contexts for one two-minute reconnect period; repeated failures do not renew it.
|
|
99
|
+
Local Browser mode filters HTTP and WebSocket requests and disables WebRTC, WebTransport, Worker and SharedWorker before page scripts. Worker-dependent pages may not work in this mode; Chromium is not enclosed in an OS network sandbox. A temporary Local or Full network lease closes the Browser context at expiry when the current permanent grant does not cover it, including before a queued secure credential fill. A lost WebSocket connection, a controlled Realtime restart, or a temporary dependency outage retains running processes and Browser contexts for one two-minute reconnect period; repeated failures do not renew it. Receiving `ready` alone does not reset that period while executions still await resume confirmation. Handshake, ready and execution resume each have a ten-second transport deadline. Access revocation and malformed runner frames stop the runner and its processes. Grant revision changes reject older execute frames and stop only work outside the remaining permanent or temporary scope. A network upgrade preserves the original temporary lease for a subsequent downgrade.
|
|
100
100
|
|
|
101
101
|
`save_image` validates the canonical path of the opened file descriptor and reads the image from that same descriptor (up to 30 MiB). It rejects the upload if the descriptor path cannot be verified, including when `lsof` is unavailable on macOS or `/proc/self/fd` cannot be resolved on Linux.
|
|
102
102
|
|
|
@@ -144,7 +144,7 @@ Avoid putting tokens directly in shell history. Prefer environment variables for
|
|
|
144
144
|
|
|
145
145
|
### Cross-environment migration
|
|
146
146
|
|
|
147
|
-
Saved projects are required by `revo migrate --from/--to` and are also accepted through `--project` or the compatible `--env` alias. Examples use `source` and `target` for migration roles. Both may use the production API URL shown below, with separate API keys for their respective instances; the profile name itself does not select an API
|
|
147
|
+
Saved projects are required by `revo migrate --from/--to` and are also accepted through `--project` or the compatible `--env` alias. Examples use `source` and `target` for migration roles. Both may use the production API URL shown below, with separate API keys for their respective instances; the profile name itself does not select an API.
|
|
148
148
|
|
|
149
149
|
```bash
|
|
150
150
|
revo projects add source --url https://api.revoengine.com
|
|
@@ -152,9 +152,7 @@ revo projects add target --url https://api.revoengine.com
|
|
|
152
152
|
revo projects list
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
`projects add` prompts for an API key
|
|
156
|
-
|
|
157
|
-
A production profile requires an interactive confirmation before the first remote write in every invocation. `--yes`, `--force`, and non-interactive CI do not bypass this guard.
|
|
155
|
+
`projects add` prompts for an API key and validates the profile. Use `--token <apiKey>` to supply the key directly or `--offline` to skip validation. Remove an unused profile with `revo projects remove <name>`.
|
|
158
156
|
|
|
159
157
|
Runtime configuration precedence is:
|
|
160
158
|
|
|
@@ -329,7 +327,7 @@ revo migrate plan --from source --to target --skip-groups
|
|
|
329
327
|
revo migrate run --from source --to target --skip-groups --yes
|
|
330
328
|
```
|
|
331
329
|
|
|
332
|
-
The migration model is source-wins upsert. Missing target resources are created and changed resources are updated. Target-only resources are reported as exclusions and are not deleted. A failed phase prevents all later phases from writing; earlier verified writes are not rolled back. Named migration includes Materialized View and access-group writes in its selected scope without the additional repository force gates; destructive column removal still requires `--force`.
|
|
330
|
+
The migration model is source-wins upsert. Missing target resources are created and changed resources are updated. Target-only resources are reported as exclusions and are not deleted. A failed phase prevents all later phases from writing; earlier verified writes are not rolled back. Named migration includes Materialized View and access-group writes in its selected scope without the additional repository force gates; destructive column removal still requires `--force`.
|
|
333
331
|
|
|
334
332
|
Plans project earlier phase results into later dependencies: a Schedule can plan against a Job Template or Materialized View that an earlier phase will create. After each phase verifies its writes, the next phase resolves the actual target UUIDs and versions again before writing. A failed readback stops subsequent phases; `verify` uses a fresh source pull to detect remaining changes.
|
|
335
333
|
|
|
@@ -351,6 +349,8 @@ Full pull, deployment, and migration use this fixed dependency order:
|
|
|
351
349
|
| 8 | `group` | `groups` | `Groups/` | Group owners use Stable Keys; users and memberships remain target-local. |
|
|
352
350
|
| 9 | `role-group` | `role-groups` | `RoleGroups/` | Role assignments run last; members and user identifiers remain target-local. |
|
|
353
351
|
|
|
352
|
+
Active Materialized View refresh Schedules are reported in Database View plans but do not block push, repository deployment, or named migration. Updating a view preserves Schedule activation; API write failures and readback verification failures are still reported.
|
|
353
|
+
|
|
354
354
|
`--resources all` selects all nine families. Singular, plural, and common compact aliases are accepted where the command parser documents them, but the selectors above are the canonical values.
|
|
355
355
|
|
|
356
356
|
Existing `database-schema` selectors and `revo database-schemas` commands remain accepted as compatibility aliases. New table manifests use `DatabaseTables/**/database-table.json`; older `DatabaseSchemas/**/database-schema.json` files remain readable and are relocated by the next successful table pull. A locally edited manifest still needs `--force` before pull replaces it. The manifest `kind` and `databaseSchemas` lock and plan keys retain their existing schema names for format compatibility.
|
package/dist/src/client.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export type RequestOptions = {
|
|
|
6
6
|
headers?: HeadersInit;
|
|
7
7
|
authGuard?: boolean;
|
|
8
8
|
spinnerLabel?: string;
|
|
9
|
-
productionWrite?: boolean;
|
|
10
9
|
timeoutMs?: number;
|
|
11
10
|
queueTimeoutMs?: number;
|
|
12
11
|
signal?: AbortSignal;
|
|
@@ -279,13 +278,7 @@ export type ClientOptions = {
|
|
|
279
278
|
token?: string;
|
|
280
279
|
envName?: string;
|
|
281
280
|
environmentName?: string;
|
|
282
|
-
production?: true;
|
|
283
281
|
fetch?: typeof fetch;
|
|
284
|
-
confirmProductionWrite?: (details: {
|
|
285
|
-
baseUrl: string;
|
|
286
|
-
method: string;
|
|
287
|
-
path: string;
|
|
288
|
-
}) => Promise<boolean>;
|
|
289
282
|
trustedServiceOrigins?: string[];
|
|
290
283
|
maxRetries?: number;
|
|
291
284
|
retryDelayMs?: number;
|
|
@@ -323,11 +316,8 @@ export declare class RevoClient {
|
|
|
323
316
|
baseUrl: string;
|
|
324
317
|
instance: string;
|
|
325
318
|
token: string;
|
|
326
|
-
production: boolean;
|
|
327
319
|
environmentName: string;
|
|
328
320
|
fetchImpl: typeof fetch | undefined;
|
|
329
|
-
private productionWriteConfirmed;
|
|
330
|
-
private confirmProductionWrite;
|
|
331
321
|
private trustedServiceOrigins;
|
|
332
322
|
private maxRetries;
|
|
333
323
|
private retryDelayMs;
|
|
@@ -348,7 +338,6 @@ export declare class RevoClient {
|
|
|
348
338
|
profile: unknown;
|
|
349
339
|
}>;
|
|
350
340
|
request(method: string, path: string, options?: RequestOptions): Promise<ApiResponse>;
|
|
351
|
-
private assertProductionWriteConfirmed;
|
|
352
341
|
requestData<T = unknown>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
353
342
|
me(options?: {
|
|
354
343
|
force?: boolean;
|
package/dist/src/client.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { setTimeout as waitForDelay } from 'node:timers/promises';
|
|
2
2
|
import { AUTH_VALIDATION_TTL_MS, buildAuthValidationKey, DEFAULT_BASE_URL, readAuthValidationState, resolveRuntimeConfig, saveAuthValidationState, } from "./config.js";
|
|
3
3
|
import { beginHttpTraceRequest, completeHttpTraceRequest, responseSize, } from "./http-trace.js";
|
|
4
|
-
import { isInteractiveTerminal, promptConfirm } from "./prompt.js";
|
|
5
4
|
import { currentRequestQueue, RequestQueue } from "./request-queue.js";
|
|
6
5
|
import { createSpinner } from "./spinner.js";
|
|
7
6
|
import { mapWithConcurrency } from "./utils.js";
|
|
@@ -263,12 +262,6 @@ function normalizeToken(token) {
|
|
|
263
262
|
}
|
|
264
263
|
return token.startsWith('Bearer ') ? token : `Bearer ${token}`;
|
|
265
264
|
}
|
|
266
|
-
async function confirmProductionWriteInTerminal(details) {
|
|
267
|
-
if (!isInteractiveTerminal()) {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
return promptConfirm(`PRODUCTION: send ${details.method} ${details.path} to ${details.baseUrl}?`, false);
|
|
271
|
-
}
|
|
272
265
|
function defaultSpinnerLabel(method, path) {
|
|
273
266
|
const upperMethod = method.toUpperCase();
|
|
274
267
|
if (path === '/api/v1/me') {
|
|
@@ -412,11 +405,8 @@ export class RevoClient {
|
|
|
412
405
|
baseUrl;
|
|
413
406
|
instance;
|
|
414
407
|
token;
|
|
415
|
-
production;
|
|
416
408
|
environmentName;
|
|
417
409
|
fetchImpl;
|
|
418
|
-
productionWriteConfirmed = false;
|
|
419
|
-
confirmProductionWrite;
|
|
420
410
|
trustedServiceOrigins;
|
|
421
411
|
maxRetries;
|
|
422
412
|
retryDelayMs;
|
|
@@ -426,10 +416,8 @@ export class RevoClient {
|
|
|
426
416
|
this.baseUrl = config.baseUrl;
|
|
427
417
|
this.instance = config.instance || '';
|
|
428
418
|
this.token = config.token;
|
|
429
|
-
this.production = options.production === true || config.production === true;
|
|
430
419
|
this.environmentName = options.environmentName || options.envName || '';
|
|
431
420
|
this.fetchImpl = options.fetch || globalThis.fetch;
|
|
432
|
-
this.confirmProductionWrite = options.confirmProductionWrite || confirmProductionWriteInTerminal;
|
|
433
421
|
this.trustedServiceOrigins = resolveTrustedServiceOrigins(options.trustedServiceOrigins);
|
|
434
422
|
this.maxRetries = options.maxRetries ?? 0;
|
|
435
423
|
this.retryDelayMs = options.retryDelayMs ?? 100;
|
|
@@ -502,9 +490,6 @@ export class RevoClient {
|
|
|
502
490
|
}
|
|
503
491
|
async request(method, path, options = {}) {
|
|
504
492
|
this.assertReady();
|
|
505
|
-
if (options.productionWrite !== false) {
|
|
506
|
-
await this.assertProductionWriteConfirmed(method, path);
|
|
507
|
-
}
|
|
508
493
|
if (options.authGuard !== false && path !== '/api/v1/me') {
|
|
509
494
|
await this.validateSession();
|
|
510
495
|
}
|
|
@@ -663,21 +648,6 @@ export class RevoClient {
|
|
|
663
648
|
spinner.stop();
|
|
664
649
|
}
|
|
665
650
|
}
|
|
666
|
-
async assertProductionWriteConfirmed(method, path) {
|
|
667
|
-
const normalizedMethod = method.toUpperCase();
|
|
668
|
-
if (!this.production || this.productionWriteConfirmed || !['POST', 'PUT', 'PATCH', 'DELETE'].includes(normalizedMethod)) {
|
|
669
|
-
return;
|
|
670
|
-
}
|
|
671
|
-
const confirmed = await this.confirmProductionWrite({
|
|
672
|
-
baseUrl: this.baseUrl,
|
|
673
|
-
method: normalizedMethod,
|
|
674
|
-
path,
|
|
675
|
-
});
|
|
676
|
-
if (!confirmed) {
|
|
677
|
-
throw new Error('Production write cancelled. Confirm the operation in an interactive terminal.');
|
|
678
|
-
}
|
|
679
|
-
this.productionWriteConfirmed = true;
|
|
680
|
-
}
|
|
681
651
|
async requestData(method, path, options = {}) {
|
|
682
652
|
const response = await this.request(method, path, options);
|
|
683
653
|
return response.data;
|
|
@@ -935,7 +905,6 @@ export class RevoClient {
|
|
|
935
905
|
try {
|
|
936
906
|
return await this.requestData('POST', '/api/v1/databases/views/preview', {
|
|
937
907
|
body,
|
|
938
|
-
productionWrite: false,
|
|
939
908
|
spinnerLabel: 'Previewing Database View',
|
|
940
909
|
timeoutMs: 30_000,
|
|
941
910
|
});
|
|
@@ -1069,7 +1038,6 @@ export class RevoClient {
|
|
|
1069
1038
|
}
|
|
1070
1039
|
async *debugComponentStream(requestPath, body) {
|
|
1071
1040
|
this.assertReady();
|
|
1072
|
-
await this.assertProductionWriteConfirmed('POST', requestPath);
|
|
1073
1041
|
await this.validateSession();
|
|
1074
1042
|
const url = buildUrl(this.baseUrl, requestPath);
|
|
1075
1043
|
assertCredentialDestination(this.baseUrl, url, true, this.trustedServiceOrigins);
|
package/dist/src/commands/env.js
CHANGED
|
@@ -160,13 +160,11 @@ async function handleEnvAdd(context) {
|
|
|
160
160
|
await probe.validateSession({ force: true });
|
|
161
161
|
instance = probe.instance;
|
|
162
162
|
}
|
|
163
|
-
const production = await promptConfirm('Is this a production project?', existing?.production === true);
|
|
164
163
|
const existed = Boolean(existing);
|
|
165
164
|
saveEnvironmentProfile(name, {
|
|
166
165
|
baseUrl,
|
|
167
166
|
token,
|
|
168
167
|
...(instance ? { instance } : {}),
|
|
169
|
-
...(production ? { production: true } : {}),
|
|
170
168
|
}, { activate: true });
|
|
171
169
|
println(`${existed ? 'Updated' : 'Saved'} project "${name}" in ${getConfigDir()}.`);
|
|
172
170
|
println(`Active project: ${name}.`);
|
|
@@ -180,7 +178,6 @@ function handleEnvList(context) {
|
|
|
180
178
|
print(Object.fromEntries(Object.keys(profiles).sort().map((name) => [name, {
|
|
181
179
|
baseUrl: profiles[name].baseUrl,
|
|
182
180
|
instance: profiles[name].instance || null,
|
|
183
|
-
...(profiles[name].production ? { production: true } : {}),
|
|
184
181
|
tokenConfigured: Boolean(profiles[name].token),
|
|
185
182
|
}])));
|
|
186
183
|
return;
|
|
@@ -189,8 +186,7 @@ function handleEnvList(context) {
|
|
|
189
186
|
for (const name of names) {
|
|
190
187
|
const profile = name === DEFAULT_ENV_NAME ? defaultRuntime : profiles[name];
|
|
191
188
|
const instanceSuffix = profile.instance ? ` (instance ${profile.instance})` : '';
|
|
192
|
-
|
|
193
|
-
println(`${name === active ? '*' : ' '} ${paint(name.padEnd(16), ANSI.bold + ANSI.cyan)} ${profile.baseUrl}${instanceSuffix}${productionSuffix}`);
|
|
189
|
+
println(`${name === active ? '*' : ' '} ${paint(name.padEnd(16), ANSI.bold + ANSI.cyan)} ${profile.baseUrl}${instanceSuffix}`);
|
|
194
190
|
}
|
|
195
191
|
}
|
|
196
192
|
function handleEnvSet(context) {
|
|
@@ -37,6 +37,7 @@ export declare function browserUrl(value: string): string;
|
|
|
37
37
|
export declare function localBrowserUrl(value: string): string;
|
|
38
38
|
export declare function validateBrowserActionInput(input: BrowserActionInput): void;
|
|
39
39
|
export declare function closeBrowserSessions(): Promise<void>;
|
|
40
|
+
export declare function reconcileBrowserSessions(networkMode: 'restricted' | 'sandbox' | 'external'): Promise<number>;
|
|
40
41
|
export declare function hasBrowserSessions(): boolean;
|
|
41
42
|
export declare function writePrivateScreenshot(file: string, bytes: Buffer): void;
|
|
42
43
|
export declare function runBrowserAction(input: BrowserActionInput): Promise<BrowserActionResult>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { chromium } from 'playwright-core';
|
|
5
4
|
const MAX_BROWSER_SESSIONS = 4;
|
|
6
5
|
const BROWSER_SESSION_IDLE_MS = 10 * 60_000;
|
|
7
6
|
const browserSessions = new Map();
|
|
@@ -13,6 +12,7 @@ const PRESS_KEYS = new Set(['Enter', 'Tab', 'Escape', 'Backspace',
|
|
|
13
12
|
'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']);
|
|
14
13
|
let cleanupTimer;
|
|
15
14
|
let sessionEpoch = 0;
|
|
15
|
+
let permanentNetworkMode;
|
|
16
16
|
export function browserUrl(value) {
|
|
17
17
|
const parsed = new URL(value);
|
|
18
18
|
if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password)
|
|
@@ -114,6 +114,10 @@ function setNetworkLease(id, session, expiresAt) {
|
|
|
114
114
|
clearTimeout(session.networkLeaseTimer);
|
|
115
115
|
session.networkLeaseTimer = undefined;
|
|
116
116
|
session.networkAccessExpiresAt = expiresAt;
|
|
117
|
+
const permanent = session.localOnly ? permanentNetworkMode === 'sandbox' || permanentNetworkMode === 'external'
|
|
118
|
+
: permanentNetworkMode === 'external';
|
|
119
|
+
if (permanent)
|
|
120
|
+
return;
|
|
117
121
|
if (expiresAt === null)
|
|
118
122
|
return;
|
|
119
123
|
if (!Number.isSafeInteger(expiresAt) || expiresAt <= Date.now())
|
|
@@ -138,11 +142,25 @@ function startIdleCleanup() {
|
|
|
138
142
|
}
|
|
139
143
|
export async function closeBrowserSessions() {
|
|
140
144
|
sessionEpoch++;
|
|
145
|
+
permanentNetworkMode = undefined;
|
|
141
146
|
if (cleanupTimer)
|
|
142
147
|
clearInterval(cleanupTimer);
|
|
143
148
|
cleanupTimer = undefined;
|
|
144
149
|
await Promise.all([...browserSessions.keys()].map(id => closeSession(id)));
|
|
145
150
|
}
|
|
151
|
+
export async function reconcileBrowserSessions(networkMode) {
|
|
152
|
+
permanentNetworkMode = networkMode;
|
|
153
|
+
const now = Date.now();
|
|
154
|
+
const closed = [...browserSessions].filter(([id, session]) => {
|
|
155
|
+
const permanent = session.localOnly ? networkMode !== 'restricted' : networkMode === 'external';
|
|
156
|
+
if (!permanent && (session.networkAccessExpiresAt === null || session.networkAccessExpiresAt <= now))
|
|
157
|
+
return true;
|
|
158
|
+
setNetworkLease(id, session, session.networkAccessExpiresAt);
|
|
159
|
+
return false;
|
|
160
|
+
}).map(([id]) => id);
|
|
161
|
+
await Promise.all(closed.map(id => closeSession(id)));
|
|
162
|
+
return closed.length;
|
|
163
|
+
}
|
|
146
164
|
export function hasBrowserSessions() { return browserSessions.size > 0; }
|
|
147
165
|
async function createSession(id, url, localOnly, width, height, signal, onNavigationAttempt) {
|
|
148
166
|
await pruneIdleSessions();
|
|
@@ -150,6 +168,10 @@ async function createSession(id, url, localOnly, width, height, signal, onNaviga
|
|
|
150
168
|
throw new Error('browser_session_limit');
|
|
151
169
|
creatingSessions.add(id);
|
|
152
170
|
const epoch = sessionEpoch;
|
|
171
|
+
const { chromium } = await import('playwright-core').catch(error => {
|
|
172
|
+
creatingSessions.delete(id);
|
|
173
|
+
throw error;
|
|
174
|
+
});
|
|
153
175
|
const browser = await chromium.launch({ headless: true,
|
|
154
176
|
args: localOnly ? ['--disable-background-networking',
|
|
155
177
|
'--host-resolver-rules=MAP localhost 127.0.0.1'] : [] }).catch(error => {
|
|
@@ -9,6 +9,12 @@ export type TerminalExecutePolicy = {
|
|
|
9
9
|
networkAccessOnce?: boolean;
|
|
10
10
|
policyGrantRevision: number;
|
|
11
11
|
};
|
|
12
|
+
export type TerminalGrantPolicy = {
|
|
13
|
+
mode: 'review' | 'full';
|
|
14
|
+
networkMode: 'restricted' | 'sandbox' | 'external';
|
|
15
|
+
};
|
|
16
|
+
export declare function executionAllowedByGrant(policy: TerminalExecutePolicy, grant: TerminalGrantPolicy, now?: number): boolean;
|
|
17
|
+
export declare function remainingPolicyDeadline(policy: TerminalExecutePolicy, grant: TerminalGrantPolicy): number | null;
|
|
12
18
|
type PolicyFrame = Partial<TerminalExecutePolicy> & {
|
|
13
19
|
operation?: 'shell' | 'apply_patch' | 'browser' | 'save_image';
|
|
14
20
|
sandbox?: TerminalSandbox;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
export function executionAllowedByGrant(policy, grant, now = Date.now()) {
|
|
2
|
+
const networkRank = { none: 0, local: 1, full: 2 };
|
|
3
|
+
const permanentNetwork = grant.networkMode === 'external' ? 2 : grant.networkMode === 'sandbox' ? 1 : 0;
|
|
4
|
+
const commandAllowed = policy.commandAccess !== 'host' || grant.mode === 'full'
|
|
5
|
+
|| policy.commandAccessExpiresAt !== null && policy.commandAccessExpiresAt > now;
|
|
6
|
+
const networkAllowed = networkRank[policy.networkAccess] <= permanentNetwork
|
|
7
|
+
|| policy.networkAccessExpiresAt !== null && policy.networkAccessExpiresAt > now;
|
|
8
|
+
return commandAllowed && networkAllowed;
|
|
9
|
+
}
|
|
10
|
+
export function remainingPolicyDeadline(policy, grant) {
|
|
11
|
+
const deadlines = [
|
|
12
|
+
...(policy.commandAccess === 'host' && grant.mode !== 'full' && policy.commandAccessExpiresAt !== null
|
|
13
|
+
? [policy.commandAccessExpiresAt] : []),
|
|
14
|
+
...(policy.networkAccess !== 'none' && grant.networkMode !== 'external'
|
|
15
|
+
&& !(policy.networkAccess === 'local' && grant.networkMode === 'sandbox')
|
|
16
|
+
&& policy.networkAccessExpiresAt !== null ? [policy.networkAccessExpiresAt] : []),
|
|
17
|
+
];
|
|
18
|
+
return deadlines.length ? Math.min(...deadlines) : null;
|
|
19
|
+
}
|
|
1
20
|
function validDeadline(value) {
|
|
2
21
|
return value === null || Number.isSafeInteger(value) && Number(value) > 0;
|
|
3
22
|
}
|
|
@@ -35,5 +35,7 @@ export function ensurePtyHelperExecutable(packageRoot = path.dirname(require.res
|
|
|
35
35
|
export function normalizePtyStartError(error) {
|
|
36
36
|
const message = error instanceof Error ? error.message : String(error);
|
|
37
37
|
return message === 'posix_spawnp failed.' || /^pty_helper_(?:invalid|missing|not_executable)$/u.test(message)
|
|
38
|
+
|| (['MODULE_NOT_FOUND', 'ERR_MODULE_NOT_FOUND'].includes(error?.code || '')
|
|
39
|
+
&& /node-pty|pty\.node/u.test(message))
|
|
38
40
|
? new Error('pty_unavailable') : error instanceof Error ? error : new Error(message);
|
|
39
41
|
}
|
|
@@ -9,3 +9,22 @@ export declare class TerminalReconnectGrace {
|
|
|
9
9
|
start(hasRunningWork: boolean): void;
|
|
10
10
|
clear(): void;
|
|
11
11
|
}
|
|
12
|
+
/** A transport is recovered only after ready and every pending execution resume. */
|
|
13
|
+
export declare class TerminalTransportRecovery {
|
|
14
|
+
private timer?;
|
|
15
|
+
private readonly pending;
|
|
16
|
+
private readyReceived;
|
|
17
|
+
private recovered;
|
|
18
|
+
private readonly onTimeout;
|
|
19
|
+
private readonly onRecovered;
|
|
20
|
+
private readonly delayMs;
|
|
21
|
+
private readonly scheduleTimer;
|
|
22
|
+
private readonly clearTimer;
|
|
23
|
+
constructor(onTimeout: () => void, onRecovered: () => void, delayMs?: number, scheduleTimer?: typeof setTimeout, clearTimer?: typeof clearTimeout);
|
|
24
|
+
ready(executionIds: Iterable<string>): void;
|
|
25
|
+
accepted(executionId: string): void;
|
|
26
|
+
close(): void;
|
|
27
|
+
private complete;
|
|
28
|
+
private arm;
|
|
29
|
+
}
|
|
30
|
+
export declare function isRunnerTransportHeartbeat(frame: unknown, connectionId: string): boolean;
|
|
@@ -27,3 +27,61 @@ export class TerminalReconnectGrace {
|
|
|
27
27
|
this.timer = undefined;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
/** A transport is recovered only after ready and every pending execution resume. */
|
|
31
|
+
export class TerminalTransportRecovery {
|
|
32
|
+
timer;
|
|
33
|
+
pending = new Set();
|
|
34
|
+
readyReceived = false;
|
|
35
|
+
recovered = false;
|
|
36
|
+
onTimeout;
|
|
37
|
+
onRecovered;
|
|
38
|
+
delayMs;
|
|
39
|
+
scheduleTimer;
|
|
40
|
+
clearTimer;
|
|
41
|
+
constructor(onTimeout, onRecovered, delayMs = 10_000, scheduleTimer = setTimeout, clearTimer = clearTimeout) {
|
|
42
|
+
this.onTimeout = onTimeout;
|
|
43
|
+
this.onRecovered = onRecovered;
|
|
44
|
+
this.delayMs = delayMs;
|
|
45
|
+
this.scheduleTimer = scheduleTimer;
|
|
46
|
+
this.clearTimer = clearTimer;
|
|
47
|
+
this.arm();
|
|
48
|
+
}
|
|
49
|
+
ready(executionIds) {
|
|
50
|
+
this.close();
|
|
51
|
+
this.readyReceived = true;
|
|
52
|
+
for (const id of executionIds)
|
|
53
|
+
this.pending.add(id);
|
|
54
|
+
if (this.pending.size)
|
|
55
|
+
this.arm();
|
|
56
|
+
else
|
|
57
|
+
this.complete();
|
|
58
|
+
}
|
|
59
|
+
accepted(executionId) {
|
|
60
|
+
if (!this.pending.delete(executionId))
|
|
61
|
+
return;
|
|
62
|
+
if (!this.pending.size)
|
|
63
|
+
this.complete();
|
|
64
|
+
}
|
|
65
|
+
close() {
|
|
66
|
+
if (this.timer)
|
|
67
|
+
this.clearTimer(this.timer);
|
|
68
|
+
this.timer = undefined;
|
|
69
|
+
}
|
|
70
|
+
complete() {
|
|
71
|
+
if (!this.readyReceived || this.recovered)
|
|
72
|
+
return;
|
|
73
|
+
this.recovered = true;
|
|
74
|
+
this.close();
|
|
75
|
+
this.onRecovered();
|
|
76
|
+
}
|
|
77
|
+
arm() {
|
|
78
|
+
this.timer = this.scheduleTimer(this.onTimeout, this.delayMs);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function isRunnerTransportHeartbeat(frame, connectionId) {
|
|
82
|
+
if (!connectionId || !frame || typeof frame !== 'object')
|
|
83
|
+
return false;
|
|
84
|
+
const heartbeat = frame;
|
|
85
|
+
return heartbeat.type === 'heartbeat'
|
|
86
|
+
&& (heartbeat.connectionId === undefined || heartbeat.connectionId === connectionId);
|
|
87
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
type Launchctl = (args: string[]) => void;
|
|
2
2
|
type ServiceOptions = {
|
|
3
3
|
workspace: string;
|
|
4
|
+
terminalId?: string;
|
|
4
5
|
envName?: string;
|
|
5
6
|
home?: string;
|
|
6
7
|
entrypoint?: string;
|
|
@@ -12,20 +13,20 @@ type ServiceOptions = {
|
|
|
12
13
|
launchctl?: Launchctl;
|
|
13
14
|
systemctl?: (args: string[]) => void;
|
|
14
15
|
};
|
|
15
|
-
export declare function terminalServicePaths(workspace: string, envName?: string, home?: string): {
|
|
16
|
+
export declare function terminalServicePaths(workspace: string, envName?: string, home?: string, terminalId?: string): {
|
|
16
17
|
label: string;
|
|
17
18
|
plist: string;
|
|
18
19
|
logDirectory: string;
|
|
19
20
|
stdout: string;
|
|
20
21
|
stderr: string;
|
|
21
22
|
};
|
|
22
|
-
export declare function terminalSystemdPaths(workspace: string, envName?: string, home?: string, configHome?: string): {
|
|
23
|
+
export declare function terminalSystemdPaths(workspace: string, envName?: string, home?: string, configHome?: string, terminalId?: string): {
|
|
23
24
|
label: string;
|
|
24
25
|
unit: string;
|
|
25
26
|
};
|
|
26
27
|
export declare function renderTerminalSystemdUnit(options: ServiceOptions): string;
|
|
27
28
|
export declare function renderTerminalServicePlist(options: ServiceOptions): string;
|
|
28
|
-
export declare function terminalServiceInstalled(workspace: string, envName?: string): boolean;
|
|
29
|
+
export declare function terminalServiceInstalled(workspace: string, envName?: string, terminalId?: string): boolean;
|
|
29
30
|
export declare function installTerminalService(options: ServiceOptions): {
|
|
30
31
|
label: string;
|
|
31
32
|
serviceFile: string;
|
|
@@ -12,8 +12,8 @@ function xml(value) {
|
|
|
12
12
|
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
13
13
|
.replace(/"/g, '"').replace(/'/g, ''');
|
|
14
14
|
}
|
|
15
|
-
export function terminalServicePaths(workspace, envName = 'default', home = os.homedir()) {
|
|
16
|
-
const hash = createHash('sha256').update(`${workspace}\0${envName}`).digest('hex').slice(0, 16);
|
|
15
|
+
export function terminalServicePaths(workspace, envName = 'default', home = os.homedir(), terminalId) {
|
|
16
|
+
const hash = createHash('sha256').update(`${workspace}\0${envName}${terminalId ? `\0${terminalId}` : ''}`).digest('hex').slice(0, 16);
|
|
17
17
|
const label = `com.revoengine.terminal.${hash}`;
|
|
18
18
|
return {
|
|
19
19
|
label,
|
|
@@ -23,10 +23,10 @@ export function terminalServicePaths(workspace, envName = 'default', home = os.h
|
|
|
23
23
|
stderr: path.join(home, 'Library', 'Logs', 'RevoEngine', `${label}.err.log`),
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
export function terminalSystemdPaths(workspace, envName = 'default', home = os.homedir(), configHome = path.join(home, '.config')) {
|
|
26
|
+
export function terminalSystemdPaths(workspace, envName = 'default', home = os.homedir(), configHome = path.join(home, '.config'), terminalId) {
|
|
27
27
|
if (!path.isAbsolute(configHome))
|
|
28
28
|
throw new Error('XDG_CONFIG_HOME must be an absolute path.');
|
|
29
|
-
const hash = createHash('sha256').update(`${workspace}\0${envName}`).digest('hex').slice(0, 16);
|
|
29
|
+
const hash = createHash('sha256').update(`${workspace}\0${envName}${terminalId ? `\0${terminalId}` : ''}`).digest('hex').slice(0, 16);
|
|
30
30
|
const label = `revo-terminal-${hash}.service`;
|
|
31
31
|
return { label, unit: path.join(configHome, 'systemd', 'user', label) };
|
|
32
32
|
}
|
|
@@ -44,7 +44,8 @@ export function renderTerminalSystemdUnit(options) {
|
|
|
44
44
|
if (!entrypoint || !path.isAbsolute(node) || !path.isAbsolute(entrypoint))
|
|
45
45
|
throw new Error('Cannot resolve absolute Node.js and revo executable paths for systemd.');
|
|
46
46
|
const args = [node, entrypoint, 'terminal', 'connect', '--workspace', options.workspace,
|
|
47
|
-
|
|
47
|
+
'--project', options.envName || 'default',
|
|
48
|
+
...(options.terminalId ? ['--terminal-id', options.terminalId] : [])];
|
|
48
49
|
const env = [
|
|
49
50
|
...(options.pathValue ? [`Environment=${systemdQuote(`PATH=${options.pathValue}`)}`] : []),
|
|
50
51
|
...(options.configHome ? [`Environment=${systemdQuote(`XDG_CONFIG_HOME=${options.configHome}`)}`] : []),
|
|
@@ -52,13 +53,14 @@ export function renderTerminalSystemdUnit(options) {
|
|
|
52
53
|
return `[Unit]\nDescription=RevoEngine Agent Terminal\n\n[Service]\nType=simple\nExecStart=${args.map(arg => systemdQuote(arg, true)).join(' ')}\nRestart=always\nRestartSec=30s\n${env.join('\n')}${env.length ? '\n' : ''}UnsetEnvironment=${AUTH_ENV_KEYS.join(' ')}\n\n[Install]\nWantedBy=default.target\n`;
|
|
53
54
|
}
|
|
54
55
|
export function renderTerminalServicePlist(options) {
|
|
55
|
-
const paths = terminalServicePaths(options.workspace, options.envName, options.home);
|
|
56
|
+
const paths = terminalServicePaths(options.workspace, options.envName, options.home, options.terminalId);
|
|
56
57
|
const node = options.nodePath || process.execPath;
|
|
57
58
|
const entrypoint = options.entrypoint || (process.argv[1] && fs.realpathSync(process.argv[1]));
|
|
58
59
|
if (!entrypoint || !path.isAbsolute(node) || !path.isAbsolute(entrypoint))
|
|
59
60
|
throw new Error('Cannot resolve absolute Node.js and revo executable paths for LaunchAgent.');
|
|
60
61
|
const args = [node, entrypoint, 'terminal', 'connect', '--workspace', options.workspace,
|
|
61
|
-
|
|
62
|
+
'--project', options.envName || 'default',
|
|
63
|
+
...(options.terminalId ? ['--terminal-id', options.terminalId] : [])];
|
|
62
64
|
const lines = args.map(arg => ` <string>${xml(arg)}</string>`).join('\n');
|
|
63
65
|
const env = [];
|
|
64
66
|
if (options.pathValue)
|
|
@@ -104,13 +106,15 @@ function isLoaded(options, uid, label) {
|
|
|
104
106
|
return false;
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
|
-
export function terminalServiceInstalled(workspace, envName = 'default') {
|
|
108
|
-
if (process.platform === 'linux')
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
export function terminalServiceInstalled(workspace, envName = 'default', terminalId) {
|
|
110
|
+
if (process.platform === 'linux') {
|
|
111
|
+
const configHome = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config');
|
|
112
|
+
return fs.existsSync(terminalSystemdPaths(workspace, envName, os.homedir(), configHome, terminalId).unit);
|
|
113
|
+
}
|
|
114
|
+
return fs.existsSync(terminalServicePaths(workspace, envName, os.homedir(), terminalId).plist);
|
|
111
115
|
}
|
|
112
116
|
function installLinuxTerminalService(options) {
|
|
113
|
-
const paths = terminalSystemdPaths(options.workspace, options.envName, options.home, options.configHome || path.join(options.home || os.homedir(), '.config'));
|
|
117
|
+
const paths = terminalSystemdPaths(options.workspace, options.envName, options.home, options.configHome || path.join(options.home || os.homedir(), '.config'), options.terminalId);
|
|
114
118
|
const content = renderTerminalSystemdUnit(options);
|
|
115
119
|
fs.mkdirSync(path.dirname(paths.unit), { recursive: true, mode: 0o700 });
|
|
116
120
|
if (fs.existsSync(paths.unit)) {
|
|
@@ -155,7 +159,7 @@ export function installTerminalService(options) {
|
|
|
155
159
|
if (ensureSupported(options) === 'linux')
|
|
156
160
|
return installLinuxTerminalService(options);
|
|
157
161
|
const uid = ensureMac(options);
|
|
158
|
-
const paths = terminalServicePaths(options.workspace, options.envName, options.home);
|
|
162
|
+
const paths = terminalServicePaths(options.workspace, options.envName, options.home, options.terminalId);
|
|
159
163
|
const content = renderTerminalServicePlist(options);
|
|
160
164
|
fs.mkdirSync(path.dirname(paths.plist), { recursive: true, mode: 0o700 });
|
|
161
165
|
fs.mkdirSync(paths.logDirectory, { recursive: true, mode: 0o700 });
|
|
@@ -191,7 +195,7 @@ export function installTerminalService(options) {
|
|
|
191
195
|
}
|
|
192
196
|
export function uninstallTerminalService(options) {
|
|
193
197
|
if (ensureSupported(options) === 'linux') {
|
|
194
|
-
const paths = terminalSystemdPaths(options.workspace, options.envName, options.home, options.configHome || path.join(options.home || os.homedir(), '.config'));
|
|
198
|
+
const paths = terminalSystemdPaths(options.workspace, options.envName, options.home, options.configHome || path.join(options.home || os.homedir(), '.config'), options.terminalId);
|
|
195
199
|
if (!fs.existsSync(paths.unit))
|
|
196
200
|
return { label: paths.label, removed: false };
|
|
197
201
|
systemctl(options, ['disable', '--now', paths.label]);
|
|
@@ -200,7 +204,7 @@ export function uninstallTerminalService(options) {
|
|
|
200
204
|
return { label: paths.label, removed: true };
|
|
201
205
|
}
|
|
202
206
|
const uid = ensureMac(options);
|
|
203
|
-
const paths = terminalServicePaths(options.workspace, options.envName, options.home);
|
|
207
|
+
const paths = terminalServicePaths(options.workspace, options.envName, options.home, options.terminalId);
|
|
204
208
|
const exists = fs.existsSync(paths.plist);
|
|
205
209
|
if (isLoaded(options, uid, paths.label))
|
|
206
210
|
launchctl(options, ['bootout', `gui/${uid}/${paths.label}`]);
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { type ChildProcess } from 'node:child_process';
|
|
2
2
|
import { type TerminalNetworkAccess, type TerminalSandbox } from './terminal-sandbox.ts';
|
|
3
|
+
type TerminalGrant = {
|
|
4
|
+
agentTerminalId: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
workspace?: string;
|
|
7
|
+
status: 'pending' | 'approved' | 'revoked';
|
|
8
|
+
mode: 'review' | 'full';
|
|
9
|
+
networkMode?: 'restricted' | 'sandbox' | 'external';
|
|
10
|
+
};
|
|
11
|
+
export declare function selectRegisteredTerminal<T extends {
|
|
12
|
+
agentTerminalId: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}>(devices: T[], grants: TerminalGrant[], name: string, terminalId?: string): T | undefined;
|
|
3
15
|
export declare const MAX_TERMINAL_PROCESS_MS: number;
|
|
4
16
|
type CommandResult = {
|
|
5
17
|
executed: boolean;
|
|
@@ -18,8 +30,10 @@ export type RunningProcess = {
|
|
|
18
30
|
closeStdin: (chars: string) => void;
|
|
19
31
|
resize: (cols: number, rows: number) => void;
|
|
20
32
|
terminate: () => void;
|
|
33
|
+
updatePolicyDeadline?: (deadline: number | null) => void;
|
|
21
34
|
};
|
|
22
35
|
export declare function childEnvironment(source: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
36
|
+
export declare function acquireRunnerLock(agentTerminalId: string): () => void;
|
|
23
37
|
export declare function resolveWorkspaceDirectory(root: string, requested: string): string;
|
|
24
38
|
export declare function boundResultFrame(frame: Record<string, unknown>): Record<string, unknown>;
|
|
25
39
|
export declare function runCommand(input: {
|
|
@@ -47,6 +61,8 @@ export declare function runWorkspacePatch(input: {
|
|
|
47
61
|
stdout: string;
|
|
48
62
|
stderr: string;
|
|
49
63
|
timedOut: boolean;
|
|
50
|
-
}) => void): ChildProcess
|
|
64
|
+
}) => void): ChildProcess & {
|
|
65
|
+
updatePolicyDeadline: (deadline: number | null) => void;
|
|
66
|
+
};
|
|
51
67
|
export declare function handleTerminalCommand(argv: string[]): Promise<void>;
|
|
52
68
|
export {};
|