@phnx-labs/agents-cli 1.22.103 → 1.22.105
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 +39 -0
- package/README.md +1 -1
- package/dist/commands/accounts.js +2 -2
- package/dist/commands/computer.d.ts +100 -79
- package/dist/commands/computer.js +290 -830
- package/dist/commands/run-device-picker.d.ts +58 -0
- package/dist/commands/run-device-picker.js +222 -0
- package/dist/commands/setup-computer.js +20 -1
- package/dist/commands/setup-secrets.d.ts +2 -2
- package/dist/commands/setup-secrets.js +1 -1
- package/dist/commands/view.js +4 -6
- package/dist/lib/account-catalog.d.ts +22 -1
- package/dist/lib/account-catalog.js +72 -38
- package/dist/lib/accounting/usage.js +18 -14
- package/dist/lib/agent-spec/agents.d.ts +1 -0
- package/dist/lib/agent-spec/agents.js +1 -1
- package/dist/lib/browser/drivers/ssh.js +1 -1
- package/dist/lib/computer/context.d.ts +83 -0
- package/dist/lib/computer/context.js +91 -0
- package/dist/lib/computer/policy.d.ts +46 -0
- package/dist/lib/computer/policy.js +160 -0
- package/dist/lib/computer/record.d.ts +38 -0
- package/dist/lib/computer/record.js +86 -0
- package/dist/lib/computer/sessions-list.js +6 -6
- package/dist/lib/computer-client.d.ts +150 -0
- package/dist/lib/computer-client.js +222 -0
- package/dist/lib/exec.js +35 -1
- package/dist/lib/harness/adapters/claude.d.ts +37 -0
- package/dist/lib/harness/adapters/claude.js +69 -0
- package/dist/lib/helper-download.d.ts +1 -1
- package/dist/lib/helper-download.js +1 -1
- package/dist/lib/helper-versions.d.ts +9 -4
- package/dist/lib/helper-versions.js +8 -8
- package/dist/lib/installations/shims.js +8 -4
- package/dist/lib/menubar/download-menubar.d.ts +2 -1
- package/dist/lib/menubar/download-menubar.js +2 -1
- package/dist/lib/secrets-client.d.ts +3 -3
- package/dist/lib/secrets-client.js +15 -38
- package/dist/lib/session/db.js +1 -1
- package/dist/lib/sha256-asset.d.ts +2 -1
- package/dist/lib/sha256-asset.js +2 -1
- package/dist/lib/ssh-tunnel.d.ts +61 -0
- package/dist/lib/ssh-tunnel.js +105 -0
- package/dist/lib/summarizer/summarize.d.ts +2 -2
- package/dist/lib/summarizer/summarize.js +10 -3
- package/package.json +2 -3
- package/dist/commands/computer-actions.d.ts +0 -55
- package/dist/commands/computer-actions.js +0 -594
- package/dist/computer.d.ts +0 -2
- package/dist/computer.js +0 -7
- package/dist/lib/computer/actions.d.ts +0 -36
- package/dist/lib/computer/actions.js +0 -162
- package/dist/lib/computer/computer-rpc.d.ts +0 -39
- package/dist/lib/computer/computer-rpc.js +0 -447
- package/dist/lib/computer/des.d.ts +0 -1
- package/dist/lib/computer/des.js +0 -114
- package/dist/lib/computer/dispatch.d.ts +0 -10
- package/dist/lib/computer/dispatch.js +0 -133
- package/dist/lib/computer/download.d.ts +0 -54
- package/dist/lib/computer/download.js +0 -83
- package/dist/lib/computer/loop.d.ts +0 -62
- package/dist/lib/computer/loop.js +0 -98
- package/dist/lib/computer/model.d.ts +0 -44
- package/dist/lib/computer/model.js +0 -157
- package/dist/lib/computer/rfb-client.d.ts +0 -53
- package/dist/lib/computer/rfb-client.js +0 -562
- package/dist/lib/computer/ssh-tunnel.d.ts +0 -189
- package/dist/lib/computer/ssh-tunnel.js +0 -584
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared SSH port-forward tunnel + remote computer-helper provisioning.
|
|
3
|
-
*
|
|
4
|
-
* Two layers live here:
|
|
5
|
-
*
|
|
6
|
-
* 1. `startSSHTunnel` — the generic `ssh -L localPort:127.0.0.1:remotePort -N`
|
|
7
|
-
* spawn, extracted verbatim from the browser CDP driver so both the browser
|
|
8
|
-
* and `agents computer --device` reach a remote loopback service through one
|
|
9
|
-
* hardened tunnel. Behavior for the browser caller is unchanged (default,
|
|
10
|
-
* foreground, stderr-captured).
|
|
11
|
-
*
|
|
12
|
-
* 2. Remote computer-helper orchestration — resolve a registered device to an
|
|
13
|
-
* ssh target, push the cross-published Windows daemon exe, register it as a
|
|
14
|
-
* LOGON scheduled task (interactive session so real-desktop UIA/screenshot
|
|
15
|
-
* works and it survives the ssh disconnect), and open a tunnel the TS RPC
|
|
16
|
-
* client drives via TCP. Everything rides the existing `ssh-exec` /
|
|
17
|
-
* `devices/connect` primitives — no parallel SSH implementation.
|
|
18
|
-
*/
|
|
19
|
-
import { type ChildProcess } from 'child_process';
|
|
20
|
-
import { type DeviceProfile } from '../devices/registry.js';
|
|
21
|
-
export interface StartTunnelOptions {
|
|
22
|
-
/**
|
|
23
|
-
* Detach the tunnel so it OUTLIVES this CLI process. Used by
|
|
24
|
-
* `agents computer start --device` — the tunnel must persist across separate
|
|
25
|
-
* verb invocations (`apps`, `click`, …) until `stop --device` tears it down.
|
|
26
|
-
* The browser driver leaves this false: it holds the tunnel for the lifetime
|
|
27
|
-
* of one CDP session and kills it on cleanup.
|
|
28
|
-
*/
|
|
29
|
-
detached?: boolean;
|
|
30
|
-
extraSshArgs?: string[];
|
|
31
|
-
}
|
|
32
|
-
/** Build the ssh argv (after the `ssh` program name) for an `-L` tunnel. Pure.
|
|
33
|
-
*
|
|
34
|
-
* Composes the shared hardened baseline (`SSH_OPTS`) rather than re-listing it,
|
|
35
|
-
* so the tunnel inherits the same options — crucially the keepalive, which lets
|
|
36
|
-
* a dropped `-N` tunnel exit instead of lingering as a zombie on the laptop. */
|
|
37
|
-
export declare function buildTunnelArgs(user: string, host: string, localPort: number, remotePort: number, extraSshArgs?: string[]): string[];
|
|
38
|
-
/**
|
|
39
|
-
* Spawn `ssh -L localPort:127.0.0.1:remotePort -N user@host`.
|
|
40
|
-
*
|
|
41
|
-
* Foreground (default): stderr is captured so a tunnel that dies inside 500ms
|
|
42
|
-
* rejects with the ssh error — the browser driver's original contract. Detached
|
|
43
|
-
* mode ignores stdio and `unref`s the child so the parent can exit while the
|
|
44
|
-
* tunnel lives; liveness is then confirmed by the caller probing the service.
|
|
45
|
-
*/
|
|
46
|
-
export declare function startSSHTunnel(user: string, host: string, localPort: number, remotePort: number, opts?: StartTunnelOptions): Promise<ChildProcess>;
|
|
47
|
-
/** Loopback TCP port the Windows daemon binds on the remote (Program.cs default). */
|
|
48
|
-
export declare const REMOTE_HELPER_PORT = 8765;
|
|
49
|
-
/** Task Scheduler task name for the daemon. Stable so setup/stop pair up. */
|
|
50
|
-
export declare const REMOTE_TASK_NAME = "AgentsComputerHelper";
|
|
51
|
-
/** Basename of the cross-published exe under native/computer-win/dist. */
|
|
52
|
-
export declare const WIN_HELPER_EXE = "computer-helper-win.exe";
|
|
53
|
-
/** Basename of the daemon's shared-secret token file under %LOCALAPPDATA%\agents. */
|
|
54
|
-
export declare const WIN_HELPER_TOKEN_FILE = "helper-token";
|
|
55
|
-
/**
|
|
56
|
-
* Locate a locally built Windows daemon exe — a repo-checkout build output from
|
|
57
|
-
* `scripts/build-win.sh`, or one bundled next to the package. Local paths are
|
|
58
|
-
* only the first candidate; npm-installed CLIs have neither and fall through to
|
|
59
|
-
* the release-asset download (`ensureWinHelperExe`).
|
|
60
|
-
*/
|
|
61
|
-
export declare function resolveWinHelperExe(): string | null;
|
|
62
|
-
/** GitHub repo whose `computer-win/v<version>` releases carry the exe as an asset. */
|
|
63
|
-
export declare const WIN_HELPER_RELEASE_REPO = "phnx-labs/agi-cli";
|
|
64
|
-
/** Cache dir for downloaded helper exes, one subdir per release tag. */
|
|
65
|
-
export declare function winHelperCacheDir(version: string): string;
|
|
66
|
-
/** Release-asset URLs for the exe + its checksum at one exact `computer-win/v<version>` tag. */
|
|
67
|
-
export declare function winHelperAssetUrls(version: string): {
|
|
68
|
-
exe: string;
|
|
69
|
-
sha256: string;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Parse the published `.sha256` asset — `sha256sum` format (`<hex> <name>`) or
|
|
73
|
-
* a bare hex digest. Throws on anything that does not lead with 64 hex chars.
|
|
74
|
-
*/
|
|
75
|
-
/**
|
|
76
|
-
* Download the exe release asset for this HELPER version, verify its sha256
|
|
77
|
-
* against the published `.sha256` asset, and cache it under the agents cache
|
|
78
|
-
* dir. Only the exact `computer-win/v<version>` tag is consulted — a missing
|
|
79
|
-
* asset is a hard error naming that tag, never a silent fallback to another
|
|
80
|
-
* release. The version is the HELPER's own, not the CLI's.
|
|
81
|
-
*/
|
|
82
|
-
export declare function downloadWinHelperExe(version: string): Promise<string>;
|
|
83
|
-
/**
|
|
84
|
-
* Resolve the helper exe for `setup --device`: local build outputs first (repo
|
|
85
|
-
* checkout / bundled), then the checksum-verified release-asset download for
|
|
86
|
-
* the running CLI version. Throws with the tag it checked when neither exists.
|
|
87
|
-
*/
|
|
88
|
-
export declare function ensureWinHelperExe(version?: string): Promise<string>;
|
|
89
|
-
/** Persisted per-device tunnel state so verbs can reconnect after `start --device`. */
|
|
90
|
-
export interface RemoteTunnelState {
|
|
91
|
-
device: string;
|
|
92
|
-
target: string;
|
|
93
|
-
localPort: number;
|
|
94
|
-
remotePort: number;
|
|
95
|
-
tunnelPid: number;
|
|
96
|
-
token: string | null;
|
|
97
|
-
taskName: string;
|
|
98
|
-
startedAt: number;
|
|
99
|
-
}
|
|
100
|
-
/** State file path for a device. Device names are ssh-alias safe (validated). */
|
|
101
|
-
export declare function remoteStatePath(device: string): string;
|
|
102
|
-
export declare function readRemoteState(device: string): RemoteTunnelState | null;
|
|
103
|
-
export declare function writeRemoteState(state: RemoteTunnelState): void;
|
|
104
|
-
export declare function clearRemoteState(device: string): void;
|
|
105
|
-
/**
|
|
106
|
-
* Local file holding the shared-secret token for a device's helper daemon.
|
|
107
|
-
* Written at `setup --device` (0600), read at `start --device` so the RPC client
|
|
108
|
-
* authenticates. The remote daemon reads the same value from its own
|
|
109
|
-
* `--token-file`; the CLI is the source of truth and never round-trips it back.
|
|
110
|
-
*/
|
|
111
|
-
export declare function helperTokenPath(device: string): string;
|
|
112
|
-
export declare function readHelperToken(device: string): string | null;
|
|
113
|
-
export declare function writeHelperToken(device: string, token: string): void;
|
|
114
|
-
export declare function clearHelperToken(device: string): void;
|
|
115
|
-
/** Resolve a registered device to its ssh pieces, or throw a clear error. */
|
|
116
|
-
export declare function resolveRemoteDevice(name: string): Promise<{
|
|
117
|
-
device: DeviceProfile;
|
|
118
|
-
target: string;
|
|
119
|
-
user: string;
|
|
120
|
-
host: string;
|
|
121
|
-
}>;
|
|
122
|
-
/**
|
|
123
|
-
* PowerShell that resolves the destination under %LOCALAPPDATA%\agents and
|
|
124
|
-
* stops any running instance first so the file is not locked. The caller copies
|
|
125
|
-
* the exe with scp and then verifies the byte count separately.
|
|
126
|
-
*/
|
|
127
|
-
export declare function buildPushScript(): string;
|
|
128
|
-
/** PowerShell that verifies scp wrote the expected number of bytes. */
|
|
129
|
-
export declare function buildVerifyPushScript(remotePath: string, expectedBytes: number): string;
|
|
130
|
-
/**
|
|
131
|
-
* PowerShell that registers the daemon as a LOGON scheduled task. Interactive
|
|
132
|
-
* logon type + Highest run level so the daemon runs in the real desktop session
|
|
133
|
-
* (UIAutomation and ScreenCapture need a live session, not Session 0) and
|
|
134
|
-
* survives ssh disconnect — the same rationale as the browser WMI launch. The
|
|
135
|
-
* task is started immediately so the caller need not log out/in.
|
|
136
|
-
*/
|
|
137
|
-
/**
|
|
138
|
-
* PowerShell that writes the shared-secret token under %LOCALAPPDATA%\agents
|
|
139
|
-
* with an owner-only ACL (inheritance removed, read granted only to the current
|
|
140
|
-
* user) and echoes the resolved path so the caller can pass it to `--token-file`.
|
|
141
|
-
*/
|
|
142
|
-
export declare function buildWriteTokenScript(token: string): string;
|
|
143
|
-
export declare function buildRegisterTaskScript(port: number, taskName: string, tokenPath: string): string;
|
|
144
|
-
/** PowerShell that unregisters the task and stops any running daemon process. */
|
|
145
|
-
export declare function buildUnregisterTaskScript(taskName: string): string;
|
|
146
|
-
/** Convert a Windows path returned by PowerShell into the scp/SFTP path form. */
|
|
147
|
-
export declare function scpRemotePath(remotePath: string): string;
|
|
148
|
-
/**
|
|
149
|
-
* Build the scp argv used for the helper exe transfer. Exported so tests can
|
|
150
|
-
* assert the real binary copy path keeps BatchMode and does not route bytes
|
|
151
|
-
* through a PowerShell decoder.
|
|
152
|
-
*/
|
|
153
|
-
export declare function buildScpArgs(target: string, remotePath: string, filePath: string, extraSshArgs?: string[]): string[];
|
|
154
|
-
/**
|
|
155
|
-
* `setup --device`: push the exe, then register + start the LOGON task. Remote
|
|
156
|
-
* PowerShell hops go through `sshExec` (BatchMode key auth — the same hardening
|
|
157
|
-
* the browser driver and `agents ssh` use), and the large exe rides a binary
|
|
158
|
-
* scp transfer. Throws with the remote stderr on any failure.
|
|
159
|
-
*/
|
|
160
|
-
export declare function setupRemoteHelper(name: string): Promise<{
|
|
161
|
-
target: string;
|
|
162
|
-
taskName: string;
|
|
163
|
-
}>;
|
|
164
|
-
/** Reserve a free local TCP port by binding :0 and reading the assigned port. */
|
|
165
|
-
export declare function pickFreePort(): Promise<number>;
|
|
166
|
-
/**
|
|
167
|
-
* `start --device`: open a detached ssh -L tunnel to the remote daemon, verify it
|
|
168
|
-
* answers over TCP, and persist the tunnel state so verbs can reconnect. Returns
|
|
169
|
-
* the state (and leaves the tunnel running in the background).
|
|
170
|
-
*/
|
|
171
|
-
export declare function startRemoteTunnel(name: string): Promise<RemoteTunnelState>;
|
|
172
|
-
/**
|
|
173
|
-
* `stop --device`: kill the local tunnel, unregister the remote task (best-effort
|
|
174
|
-
* — the box may be offline), and clear the persisted state.
|
|
175
|
-
*/
|
|
176
|
-
export declare function stopRemoteHelper(name: string): Promise<{
|
|
177
|
-
tunnelKilled: boolean;
|
|
178
|
-
taskRemoved: boolean;
|
|
179
|
-
}>;
|
|
180
|
-
/**
|
|
181
|
-
* Point this process's RPC client at a device's live tunnel by setting
|
|
182
|
-
* COMPUTER_HELPER_TCP / COMPUTER_HELPER_TOKEN from persisted state. Called for
|
|
183
|
-
* remote verbs (`apps --device`, `click --device`, …) so the shared
|
|
184
|
-
* openComputerClient() transparently selects the TcpClient transport — no
|
|
185
|
-
* per-verb wiring. Exits with guidance when there is no active tunnel.
|
|
186
|
-
*/
|
|
187
|
-
export declare function hydrateRemoteEnvFromState(name: string): void;
|
|
188
|
-
/** Generate a shared-secret token (reserved for token-file provisioning). */
|
|
189
|
-
export declare function generateToken(): string;
|