@phnx-labs/agents-cli 1.14.7 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -39
- package/README.md +74 -7
- package/dist/commands/alias.js +2 -2
- package/dist/commands/beta.js +6 -1
- package/dist/commands/browser-picker.d.ts +21 -0
- package/dist/commands/browser-picker.js +114 -0
- package/dist/commands/browser.js +546 -75
- package/dist/commands/commands.js +72 -22
- package/dist/commands/daemon.js +2 -2
- package/dist/commands/exec.js +9 -2
- package/dist/commands/fork.js +2 -2
- package/dist/commands/hooks.js +71 -26
- package/dist/commands/mcp.js +85 -43
- package/dist/commands/plugins.js +48 -15
- package/dist/commands/prune.d.ts +0 -20
- package/dist/commands/prune.js +291 -16
- package/dist/commands/pull.js +3 -3
- package/dist/commands/repo.js +1 -1
- package/dist/commands/routines.js +2 -2
- package/dist/commands/secrets.js +37 -1
- package/dist/commands/sessions.js +62 -19
- package/dist/commands/{init.d.ts → setup.d.ts} +7 -6
- package/dist/commands/{init.js → setup.js} +32 -21
- package/dist/commands/skills.js +60 -19
- package/dist/commands/subagents.js +41 -13
- package/dist/commands/teams.js +2 -3
- package/dist/commands/usage.js +6 -0
- package/dist/commands/utils.d.ts +16 -0
- package/dist/commands/utils.js +32 -0
- package/dist/commands/versions.js +8 -6
- package/dist/commands/view.js +61 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -20
- package/dist/lib/agents.js +2 -2
- package/dist/lib/auto-pull-worker.js +2 -3
- package/dist/lib/auto-pull.js +2 -2
- package/dist/lib/browser/cdp.d.ts +7 -1
- package/dist/lib/browser/cdp.js +29 -1
- package/dist/lib/browser/chrome.js +6 -3
- package/dist/lib/browser/devices.d.ts +4 -0
- package/dist/lib/browser/devices.js +27 -0
- package/dist/lib/browser/drivers/local.js +9 -4
- package/dist/lib/browser/drivers/ssh.d.ts +1 -0
- package/dist/lib/browser/drivers/ssh.js +32 -4
- package/dist/lib/browser/ipc.js +145 -23
- package/dist/lib/browser/profiles.d.ts +5 -2
- package/dist/lib/browser/profiles.js +77 -37
- package/dist/lib/browser/service.d.ts +84 -13
- package/dist/lib/browser/service.js +806 -122
- package/dist/lib/browser/types.d.ts +81 -3
- package/dist/lib/browser/types.js +16 -0
- package/dist/lib/cloud/rush.js +2 -2
- package/dist/lib/cloud/store.js +2 -2
- package/dist/lib/commands.d.ts +1 -0
- package/dist/lib/commands.js +6 -2
- package/dist/lib/daemon.js +6 -7
- package/dist/lib/doctor-diff.js +4 -4
- package/dist/lib/events.d.ts +94 -1
- package/dist/lib/events.js +264 -6
- package/dist/lib/exec.js +16 -10
- package/dist/lib/hooks.d.ts +11 -7
- package/dist/lib/hooks.js +125 -49
- package/dist/lib/migrate.d.ts +1 -1
- package/dist/lib/migrate.js +1178 -21
- package/dist/lib/models.js +2 -2
- package/dist/lib/permissions.d.ts +14 -11
- package/dist/lib/permissions.js +46 -42
- package/dist/lib/plugins.d.ts +30 -1
- package/dist/lib/plugins.js +75 -3
- package/dist/lib/pty-server.js +9 -10
- package/dist/lib/resources/hooks.d.ts +5 -1
- package/dist/lib/resources/hooks.js +21 -4
- package/dist/lib/rotate.js +3 -4
- package/dist/lib/routines.d.ts +15 -0
- package/dist/lib/routines.js +68 -0
- package/dist/lib/runner.js +9 -5
- package/dist/lib/secrets/index.d.ts +14 -11
- package/dist/lib/secrets/index.js +49 -21
- package/dist/lib/secrets/linux.d.ts +27 -0
- package/dist/lib/secrets/linux.js +161 -0
- package/dist/lib/session/active.d.ts +3 -0
- package/dist/lib/session/active.js +92 -6
- package/dist/lib/session/cloud.js +2 -2
- package/dist/lib/session/db.d.ts +4 -0
- package/dist/lib/session/db.js +34 -3
- package/dist/lib/session/discover.js +30 -15
- package/dist/lib/session/team-filter.js +2 -2
- package/dist/lib/shims.d.ts +2 -2
- package/dist/lib/shims.js +6 -6
- package/dist/lib/skills.js +6 -2
- package/dist/lib/state.d.ts +86 -14
- package/dist/lib/state.js +150 -23
- package/dist/lib/subagents.d.ts +28 -0
- package/dist/lib/subagents.js +98 -1
- package/dist/lib/sync-manifest.d.ts +1 -1
- package/dist/lib/sync-manifest.js +3 -3
- package/dist/lib/teams/persistence.js +15 -5
- package/dist/lib/teams/registry.js +2 -2
- package/dist/lib/types.d.ts +32 -3
- package/dist/lib/types.js +3 -3
- package/dist/lib/usage.d.ts +1 -1
- package/dist/lib/usage.js +15 -48
- package/dist/lib/versions.js +31 -21
- package/package.json +1 -1
- package/scripts/postinstall.js +37 -9
|
@@ -1,61 +1,101 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
1
|
import * as path from 'path';
|
|
3
|
-
import
|
|
4
|
-
import * as yaml from 'yaml';
|
|
5
|
-
import { getUserAgentsDir } from '../state.js';
|
|
6
|
-
export function getBrowserProfilesDir() {
|
|
7
|
-
return path.join(getUserAgentsDir(), 'browser', 'profiles');
|
|
8
|
-
}
|
|
2
|
+
import { getBrowserRuntimeDir as getBrowserRuntimeDirRoot, readMeta, writeMeta, } from '../state.js';
|
|
9
3
|
export function getBrowserRuntimeDir() {
|
|
10
|
-
|
|
11
|
-
return path.join(agentsDir, 'browser');
|
|
12
|
-
}
|
|
13
|
-
export function getProfilePath(name) {
|
|
14
|
-
return path.join(getBrowserProfilesDir(), `${name}.yaml`);
|
|
4
|
+
return getBrowserRuntimeDirRoot();
|
|
15
5
|
}
|
|
16
6
|
export function getProfileRuntimeDir(name) {
|
|
17
7
|
return path.join(getBrowserRuntimeDir(), name);
|
|
18
8
|
}
|
|
9
|
+
function configToProfile(name, config) {
|
|
10
|
+
return {
|
|
11
|
+
name,
|
|
12
|
+
description: config.description,
|
|
13
|
+
browser: config.browser,
|
|
14
|
+
binary: config.binary,
|
|
15
|
+
electron: config.electron,
|
|
16
|
+
endpoints: config.endpoints,
|
|
17
|
+
chrome: config.chrome,
|
|
18
|
+
secrets: config.secrets,
|
|
19
|
+
viewport: config.viewport,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function profileToConfig(profile) {
|
|
23
|
+
const config = {
|
|
24
|
+
browser: profile.browser,
|
|
25
|
+
endpoints: profile.endpoints,
|
|
26
|
+
};
|
|
27
|
+
if (profile.description)
|
|
28
|
+
config.description = profile.description;
|
|
29
|
+
if (profile.binary)
|
|
30
|
+
config.binary = profile.binary;
|
|
31
|
+
if (profile.electron)
|
|
32
|
+
config.electron = profile.electron;
|
|
33
|
+
if (profile.chrome)
|
|
34
|
+
config.chrome = profile.chrome;
|
|
35
|
+
if (profile.secrets)
|
|
36
|
+
config.secrets = profile.secrets;
|
|
37
|
+
if (profile.viewport)
|
|
38
|
+
config.viewport = profile.viewport;
|
|
39
|
+
return config;
|
|
40
|
+
}
|
|
19
41
|
export async function listProfiles() {
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
42
|
+
const meta = readMeta();
|
|
43
|
+
if (!meta.browser)
|
|
22
44
|
return [];
|
|
23
|
-
|
|
24
|
-
const profiles = [];
|
|
25
|
-
for (const file of files) {
|
|
26
|
-
const content = fs.readFileSync(path.join(dir, file), 'utf-8');
|
|
27
|
-
const profile = yaml.parse(content);
|
|
28
|
-
profiles.push(profile);
|
|
29
|
-
}
|
|
30
|
-
return profiles;
|
|
45
|
+
return Object.entries(meta.browser).map(([name, config]) => configToProfile(name, config));
|
|
31
46
|
}
|
|
32
47
|
export async function getProfile(name) {
|
|
33
|
-
const
|
|
34
|
-
|
|
48
|
+
const meta = readMeta();
|
|
49
|
+
const config = meta.browser?.[name];
|
|
50
|
+
if (!config)
|
|
35
51
|
return null;
|
|
36
|
-
|
|
37
|
-
return yaml.parse(content);
|
|
52
|
+
return configToProfile(name, config);
|
|
38
53
|
}
|
|
39
54
|
export async function createProfile(profile) {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const filePath = getProfilePath(profile.name);
|
|
43
|
-
if (fs.existsSync(filePath)) {
|
|
55
|
+
const meta = readMeta();
|
|
56
|
+
if (meta.browser?.[profile.name]) {
|
|
44
57
|
throw new Error(`Profile "${profile.name}" already exists`);
|
|
45
58
|
}
|
|
46
|
-
|
|
59
|
+
meta.browser = meta.browser ?? {};
|
|
60
|
+
meta.browser[profile.name] = profileToConfig(profile);
|
|
61
|
+
writeMeta(meta);
|
|
47
62
|
}
|
|
48
63
|
export async function updateProfile(profile) {
|
|
49
|
-
const
|
|
50
|
-
if (!
|
|
64
|
+
const meta = readMeta();
|
|
65
|
+
if (!meta.browser?.[profile.name]) {
|
|
51
66
|
throw new Error(`Profile "${profile.name}" does not exist`);
|
|
52
67
|
}
|
|
53
|
-
|
|
68
|
+
meta.browser[profile.name] = profileToConfig(profile);
|
|
69
|
+
writeMeta(meta);
|
|
54
70
|
}
|
|
55
71
|
export async function deleteProfile(name) {
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
72
|
+
const meta = readMeta();
|
|
73
|
+
if (!meta.browser?.[name]) {
|
|
58
74
|
throw new Error(`Profile "${name}" does not exist`);
|
|
59
75
|
}
|
|
60
|
-
|
|
76
|
+
delete meta.browser[name];
|
|
77
|
+
writeMeta(meta);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Extract the port intended by the profile's first endpoint.
|
|
81
|
+
* Returns undefined for endpoint shapes that don't carry a port (e.g. ws:// without one).
|
|
82
|
+
*/
|
|
83
|
+
export function extractConfiguredPort(profile) {
|
|
84
|
+
const endpoint = profile.endpoints[0];
|
|
85
|
+
if (!endpoint)
|
|
86
|
+
return undefined;
|
|
87
|
+
let url;
|
|
88
|
+
try {
|
|
89
|
+
url = new URL(endpoint);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
if (url.port)
|
|
95
|
+
return parseInt(url.port, 10);
|
|
96
|
+
if (url.protocol === 'cdp:')
|
|
97
|
+
return 9222;
|
|
98
|
+
if (url.protocol === 'ssh:')
|
|
99
|
+
return 9222;
|
|
100
|
+
return undefined;
|
|
61
101
|
}
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import { type TabInfo, type ProfileStatus } from './types.js';
|
|
1
|
+
import { type TabInfo, type ProfileStatus, type HistoricalTask } from './types.js';
|
|
2
2
|
import { type RefOpts, type RefNode } from './refs.js';
|
|
3
3
|
export declare class BrowserService {
|
|
4
4
|
private connections;
|
|
5
|
-
|
|
5
|
+
private forkingProfiles;
|
|
6
|
+
private consoleLogs;
|
|
7
|
+
private pageErrors;
|
|
8
|
+
private networkRequests;
|
|
9
|
+
private pendingDownloads;
|
|
10
|
+
private enabledSessions;
|
|
11
|
+
start(profileName: string, opts?: {
|
|
12
|
+
taskName?: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
}): Promise<{
|
|
6
15
|
task: string;
|
|
7
|
-
|
|
16
|
+
name: string;
|
|
17
|
+
tabId?: string;
|
|
18
|
+
windowId?: string;
|
|
8
19
|
}>;
|
|
9
|
-
stop(
|
|
20
|
+
stop(taskName: string): Promise<{
|
|
21
|
+
ok: boolean;
|
|
22
|
+
profile?: string;
|
|
23
|
+
}>;
|
|
24
|
+
done(taskName: string): Promise<{
|
|
10
25
|
ok: boolean;
|
|
11
26
|
profile?: string;
|
|
12
27
|
}>;
|
|
@@ -14,26 +29,80 @@ export declare class BrowserService {
|
|
|
14
29
|
navigate(taskId: string, url: string, profileName?: string): Promise<{
|
|
15
30
|
tabId: string;
|
|
16
31
|
url: string;
|
|
32
|
+
created: boolean;
|
|
17
33
|
}>;
|
|
34
|
+
tabAdd(taskId: string, url: string, profileName?: string): Promise<{
|
|
35
|
+
tabId: string;
|
|
36
|
+
url: string;
|
|
37
|
+
}>;
|
|
38
|
+
tabFocus(taskId: string, tabHint: string): Promise<{
|
|
39
|
+
tabId: string;
|
|
40
|
+
}>;
|
|
41
|
+
tabList(taskId: string): Promise<Array<{
|
|
42
|
+
id: string;
|
|
43
|
+
url: string;
|
|
44
|
+
title: string;
|
|
45
|
+
current: boolean;
|
|
46
|
+
}>>;
|
|
47
|
+
private resolveTabHint;
|
|
48
|
+
private resolveCurrentTab;
|
|
49
|
+
private getCdpTargetId;
|
|
18
50
|
tabs(taskId?: string, profileName?: string): Promise<TabInfo[]>;
|
|
19
|
-
|
|
20
|
-
evaluate(taskId: string,
|
|
21
|
-
screenshot(taskId: string,
|
|
51
|
+
tabClose(taskId: string, tabHint?: string): Promise<void>;
|
|
52
|
+
evaluate(taskId: string, tabHint: string | undefined, expression: string): Promise<unknown>;
|
|
53
|
+
screenshot(taskId: string, tabHint?: string, outputPath?: string): Promise<string>;
|
|
22
54
|
private refsCache;
|
|
23
|
-
refs(taskId: string,
|
|
55
|
+
refs(taskId: string, tabHint?: string, opts?: RefOpts): Promise<{
|
|
24
56
|
refs: string;
|
|
25
57
|
nodeMap: Map<number, RefNode>;
|
|
26
58
|
}>;
|
|
27
|
-
click(taskId: string,
|
|
28
|
-
type(taskId: string,
|
|
29
|
-
press(taskId: string,
|
|
30
|
-
hover(taskId: string,
|
|
59
|
+
click(taskId: string, ref: number, tabHint?: string): Promise<void>;
|
|
60
|
+
type(taskId: string, ref: number, text: string, tabHint?: string): Promise<void>;
|
|
61
|
+
press(taskId: string, key: string, tabHint?: string): Promise<void>;
|
|
62
|
+
hover(taskId: string, ref: number, tabHint?: string): Promise<void>;
|
|
31
63
|
status(profileName?: string): Promise<ProfileStatus[]>;
|
|
64
|
+
private reconcileFromDisk;
|
|
65
|
+
setViewport(taskId: string, width: number, height: number, options?: {
|
|
66
|
+
mobile?: boolean;
|
|
67
|
+
deviceScaleFactor?: number;
|
|
68
|
+
tabHint?: string;
|
|
69
|
+
}): Promise<void>;
|
|
70
|
+
setDevice(taskId: string, deviceName: string, tabHint?: string): Promise<void>;
|
|
71
|
+
private enableRuntimeForSession;
|
|
72
|
+
getConsoleLogs(taskId: string, options?: {
|
|
73
|
+
level?: string;
|
|
74
|
+
clear?: boolean;
|
|
75
|
+
tabHint?: string;
|
|
76
|
+
}): Promise<import('./types.js').ConsoleEntry[]>;
|
|
77
|
+
getErrors(taskId: string, options?: {
|
|
78
|
+
clear?: boolean;
|
|
79
|
+
tabHint?: string;
|
|
80
|
+
}): Promise<import('./types.js').ErrorEntry[]>;
|
|
81
|
+
private enableNetworkForSession;
|
|
82
|
+
getNetworkRequests(taskId: string, options?: {
|
|
83
|
+
filter?: string;
|
|
84
|
+
clear?: boolean;
|
|
85
|
+
tabHint?: string;
|
|
86
|
+
}): Promise<import('./types.js').NetworkRequest[]>;
|
|
87
|
+
getResponseBody(taskId: string, urlPattern: string, options?: {
|
|
88
|
+
timeout?: number;
|
|
89
|
+
maxChars?: number;
|
|
90
|
+
tabHint?: string;
|
|
91
|
+
}): Promise<string>;
|
|
92
|
+
wait(taskId: string, type: 'time' | 'selector' | 'url' | 'function' | 'load', value: string | number, options?: {
|
|
93
|
+
timeout?: number;
|
|
94
|
+
tabHint?: string;
|
|
95
|
+
}): Promise<void>;
|
|
96
|
+
setDownloadPath(taskId: string, downloadPath: string, tabHint?: string): Promise<void>;
|
|
97
|
+
waitForDownload(taskId: string, timeout?: number): Promise<string>;
|
|
98
|
+
private findTaskBySession;
|
|
32
99
|
shutdown(): Promise<void>;
|
|
100
|
+
private findAvailableFork;
|
|
101
|
+
private forkElectronProfile;
|
|
33
102
|
private connectProfile;
|
|
34
103
|
private connectEndpoint;
|
|
35
104
|
private enableDomains;
|
|
36
|
-
private
|
|
105
|
+
private getOrCreateWindow;
|
|
37
106
|
private findTask;
|
|
38
107
|
private getTabsForTask;
|
|
39
108
|
private getProfileStatus;
|
|
@@ -42,4 +111,6 @@ export declare class BrowserService {
|
|
|
42
111
|
private invalidateTargetCache;
|
|
43
112
|
private saveTaskState;
|
|
44
113
|
private loadTaskState;
|
|
114
|
+
private saveToHistory;
|
|
115
|
+
getHistory(limit?: number): Promise<HistoricalTask[]>;
|
|
45
116
|
}
|