@revoengine/cli 1.0.13 → 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.
Files changed (37) hide show
  1. package/README.md +26 -12
  2. package/dist/src/cli.js +4 -0
  3. package/dist/src/client.d.ts +5 -11
  4. package/dist/src/client.js +41 -74
  5. package/dist/src/commands/component.js +26 -25
  6. package/dist/src/commands/env.js +1 -5
  7. package/dist/src/commands/migrate.js +10 -0
  8. package/dist/src/commands/terminal-browser.d.ts +41 -6
  9. package/dist/src/commands/terminal-browser.js +503 -20
  10. package/dist/src/commands/terminal-image.js +59 -1
  11. package/dist/src/commands/terminal-operational-log.d.ts +18 -0
  12. package/dist/src/commands/terminal-operational-log.js +119 -0
  13. package/dist/src/commands/terminal-policy.d.ts +29 -0
  14. package/dist/src/commands/terminal-policy.js +67 -0
  15. package/dist/src/commands/terminal-pty.d.ts +4 -0
  16. package/dist/src/commands/terminal-pty.js +41 -0
  17. package/dist/src/commands/terminal-reconnect-grace.d.ts +30 -0
  18. package/dist/src/commands/terminal-reconnect-grace.js +87 -0
  19. package/dist/src/commands/terminal-sandbox.d.ts +5 -1
  20. package/dist/src/commands/terminal-sandbox.js +19 -5
  21. package/dist/src/commands/terminal-secure-browser.d.ts +25 -0
  22. package/dist/src/commands/terminal-secure-browser.js +58 -0
  23. package/dist/src/commands/terminal-service.d.ts +4 -3
  24. package/dist/src/commands/terminal-service.js +19 -15
  25. package/dist/src/commands/terminal.d.ts +22 -3
  26. package/dist/src/commands/terminal.js +622 -95
  27. package/dist/src/config.d.ts +0 -3
  28. package/dist/src/config.js +0 -2
  29. package/dist/src/migration.js +10 -11
  30. package/dist/src/request-queue.d.ts +20 -0
  31. package/dist/src/request-queue.js +80 -0
  32. package/dist/src/resource-inventory.js +9 -10
  33. package/dist/src/resource-syncs/database-view-sync.d.ts +0 -1
  34. package/dist/src/resource-syncs/database-view-sync.js +1 -12
  35. package/dist/src/resource-syncs/endpoint-sync.js +12 -46
  36. package/dist/src/types.d.ts +2 -0
  37. package/package.json +5 -3
@@ -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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
13
13
  .replace(/"/g, '&quot;').replace(/'/g, '&apos;');
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
- ...(options.envName && options.envName !== 'default' ? ['--project', options.envName] : [])];
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
- ...(options.envName && options.envName !== 'default' ? ['--project', options.envName] : [])];
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
- return fs.existsSync(terminalSystemdPaths(workspace, envName, os.homedir(), process.env.XDG_CONFIG_HOME).unit);
110
- return fs.existsSync(terminalServicePaths(workspace, envName).plist);
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
- import { type TerminalSandbox } from './terminal-sandbox.ts';
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;
@@ -10,6 +22,7 @@ type CommandResult = {
10
22
  truncated: boolean;
11
23
  logTruncated: boolean;
12
24
  logPath: string;
25
+ policyExpired?: boolean;
13
26
  };
14
27
  export type RunningProcess = {
15
28
  pid: number | undefined;
@@ -17,8 +30,10 @@ export type RunningProcess = {
17
30
  closeStdin: (chars: string) => void;
18
31
  resize: (cols: number, rows: number) => void;
19
32
  terminate: () => void;
33
+ updatePolicyDeadline?: (deadline: number | null) => void;
20
34
  };
21
35
  export declare function childEnvironment(source: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
36
+ export declare function acquireRunnerLock(agentTerminalId: string): () => void;
22
37
  export declare function resolveWorkspaceDirectory(root: string, requested: string): string;
23
38
  export declare function boundResultFrame(frame: Record<string, unknown>): Record<string, unknown>;
24
39
  export declare function runCommand(input: {
@@ -27,7 +42,8 @@ export declare function runCommand(input: {
27
42
  workspace: string;
28
43
  timeoutMs: number;
29
44
  sandbox?: TerminalSandbox;
30
- networkAllowed?: boolean;
45
+ networkAccess?: TerminalNetworkAccess;
46
+ policyDeadlineMs?: number | null;
31
47
  tty?: boolean;
32
48
  cols?: number;
33
49
  rows?: number;
@@ -38,12 +54,15 @@ export declare function runWorkspacePatch(input: {
38
54
  patch: string;
39
55
  workspace: string;
40
56
  allowDelete: boolean;
57
+ policyDeadlineMs?: number | null;
41
58
  }, onDone: (result: {
42
59
  executed: boolean;
43
60
  exitCode: number | null;
44
61
  stdout: string;
45
62
  stderr: string;
46
63
  timedOut: boolean;
47
- }) => void): ChildProcess;
64
+ }) => void): ChildProcess & {
65
+ updatePolicyDeadline: (deadline: number | null) => void;
66
+ };
48
67
  export declare function handleTerminalCommand(argv: string[]): Promise<void>;
49
68
  export {};