@web-auto/camo 0.1.26 → 0.2.1
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/LICENSE +21 -21
- package/README.md +586 -586
- package/bin/browser-service.mjs +11 -11
- package/bin/camo.mjs +22 -22
- package/package.json +48 -48
- package/scripts/build.mjs +19 -19
- package/scripts/bump-version.mjs +34 -34
- package/scripts/check-file-size.mjs +80 -80
- package/scripts/file-size-policy.json +12 -2
- package/scripts/install.mjs +76 -76
- package/scripts/release.sh +54 -54
- package/src/autoscript/action-providers/index.mjs +6 -6
- package/src/autoscript/impact-engine.mjs +78 -78
- package/src/autoscript/runtime.mjs +1017 -1017
- package/src/autoscript/schema.mjs +376 -376
- package/src/cli.mjs +405 -405
- package/src/commands/attach.mjs +141 -141
- package/src/commands/autoscript.mjs +1011 -1011
- package/src/commands/browser.mjs +1255 -1257
- package/src/commands/container.mjs +401 -401
- package/src/commands/cookies.mjs +69 -69
- package/src/commands/create.mjs +98 -98
- package/src/commands/devtools.mjs +349 -349
- package/src/commands/events.mjs +152 -152
- package/src/commands/highlight-mode.mjs +24 -24
- package/src/commands/init.mjs +68 -68
- package/src/commands/lifecycle.mjs +275 -275
- package/src/commands/mouse.mjs +45 -45
- package/src/commands/profile.mjs +46 -46
- package/src/commands/record.mjs +115 -115
- package/src/commands/system.mjs +14 -14
- package/src/commands/window.mjs +123 -123
- package/src/container/change-notifier.mjs +362 -362
- package/src/container/element-filter.mjs +143 -143
- package/src/container/index.mjs +3 -3
- package/src/container/runtime-core/checkpoint.mjs +209 -209
- package/src/container/runtime-core/index.mjs +21 -21
- package/src/container/runtime-core/operations/index.mjs +774 -774
- package/src/container/runtime-core/operations/selector-scripts.mjs +277 -277
- package/src/container/runtime-core/operations/tab-pool.mjs +746 -746
- package/src/container/runtime-core/operations/viewport.mjs +189 -189
- package/src/container/runtime-core/search.mjs +190 -190
- package/src/container/runtime-core/subscription.mjs +224 -224
- package/src/container/runtime-core/utils.mjs +94 -94
- package/src/container/runtime-core/validation.mjs +127 -184
- package/src/container/runtime-core.mjs +1 -1
- package/src/container/subscription-registry.mjs +459 -459
- package/src/core/actions.mjs +561 -561
- package/src/core/browser.mjs +266 -266
- package/src/core/index.mjs +52 -52
- package/src/core/utils.mjs +91 -91
- package/src/events/daemon-entry.mjs +33 -33
- package/src/events/daemon.mjs +80 -80
- package/src/events/progress-log.mjs +109 -109
- package/src/events/ws-server.mjs +239 -239
- package/src/lib/client.mjs +200 -200
- package/src/lifecycle/cleanup.mjs +83 -83
- package/src/lifecycle/lock.mjs +126 -126
- package/src/lifecycle/session-registry.mjs +279 -279
- package/src/lifecycle/session-view.mjs +76 -76
- package/src/lifecycle/session-watchdog.mjs +281 -281
- package/src/services/browser-service/index.js +671 -674
- package/src/services/browser-service/internal/BrowserSession.input.test.js +389 -389
- package/src/services/browser-service/internal/BrowserSession.js +325 -336
- package/src/services/browser-service/internal/ElementRegistry.js +60 -60
- package/src/services/browser-service/internal/ProfileLock.js +84 -84
- package/src/services/browser-service/internal/SessionManager.js +184 -184
- package/src/services/browser-service/internal/SessionManager.test.js +39 -39
- package/src/services/browser-service/internal/browser-session/cookies.js +144 -144
- package/src/services/browser-service/internal/browser-session/input-ops.js +222 -219
- package/src/services/browser-service/internal/browser-session/input-pipeline.js +144 -144
- package/src/services/browser-service/internal/browser-session/logging.js +46 -46
- package/src/services/browser-service/internal/browser-session/navigation.js +38 -38
- package/src/services/browser-service/internal/browser-session/page-hooks.js +442 -442
- package/src/services/browser-service/internal/browser-session/page-management.js +302 -336
- package/src/services/browser-service/internal/browser-session/page-management.test.js +148 -148
- package/src/services/browser-service/internal/browser-session/recording.js +198 -198
- package/src/services/browser-service/internal/browser-session/runtime-events.js +61 -61
- package/src/services/browser-service/internal/browser-session/session-core.js +84 -84
- package/src/services/browser-service/internal/browser-session/session-state.js +38 -38
- package/src/services/browser-service/internal/browser-session/types.js +14 -14
- package/src/services/browser-service/internal/browser-session/utils.js +95 -95
- package/src/services/browser-service/internal/browser-session/viewport-manager.js +46 -46
- package/src/services/browser-service/internal/browser-session/viewport.js +215 -215
- package/src/services/browser-service/internal/container-matcher.js +851 -851
- package/src/services/browser-service/internal/container-registry.js +182 -182
- package/src/services/browser-service/internal/engine-manager.js +259 -259
- package/src/services/browser-service/internal/fingerprint.js +203 -203
- package/src/services/browser-service/internal/heartbeat.js +137 -137
- package/src/services/browser-service/internal/logging.js +46 -46
- package/src/services/browser-service/internal/page-runtime/runtime.js +1317 -1317
- package/src/services/browser-service/internal/pageRuntime.js +28 -28
- package/src/services/browser-service/internal/runtimeInjector.js +31 -31
- package/src/services/browser-service/internal/service-process-logger.js +140 -140
- package/src/services/browser-service/internal/state-bus.js +45 -45
- package/src/services/browser-service/internal/storage-paths.js +42 -42
- package/src/services/browser-service/internal/ws-server.js +1194 -1194
- package/src/services/browser-service/internal/ws-server.test.js +58 -58
- package/src/services/browser-service/server.mjs +6 -6
- package/src/services/controller/cli-bridge.js +93 -93
- package/src/services/controller/container-index.js +50 -50
- package/src/services/controller/container-storage.js +36 -36
- package/src/services/controller/controller-actions.js +207 -207
- package/src/services/controller/controller.js +1138 -1138
- package/src/services/controller/selectors.js +54 -54
- package/src/services/controller/transport.js +125 -125
- package/src/utils/args.mjs +26 -26
- package/src/utils/browser-service.mjs +544 -544
- package/src/utils/command-log.mjs +64 -64
- package/src/utils/config.mjs +214 -214
- package/src/utils/fingerprint.mjs +181 -181
- package/src/utils/help.mjs +216 -216
- package/src/utils/js-policy.mjs +13 -13
- package/src/utils/ws-client.mjs +30 -30
- package/src/container/runtime-core/operations/tab-pool.mjs.bak +0 -762
- package/src/container/runtime-core/operations/tab-pool.mjs.syntax-error +0 -762
- package/src/services/browser-service/index.js.bak +0 -671
package/src/utils/help.mjs
CHANGED
|
@@ -1,216 +1,216 @@
|
|
|
1
|
-
export function printHelp() {
|
|
2
|
-
console.log(`
|
|
3
|
-
camo CLI - Camoufox browser controller
|
|
4
|
-
|
|
5
|
-
USAGE:
|
|
6
|
-
camo <command> [options]
|
|
7
|
-
|
|
8
|
-
PROFILE MANAGEMENT:
|
|
9
|
-
profiles List profiles with default profile
|
|
10
|
-
profile [list] List profiles (same as profiles)
|
|
11
|
-
profile create <profileId> Create a profile
|
|
12
|
-
profile delete <profileId> Delete a profile
|
|
13
|
-
profile default [profileId] Get or set default profile
|
|
14
|
-
|
|
15
|
-
INITIALIZATION:
|
|
16
|
-
init Ensure camoufox + browser-service
|
|
17
|
-
init geoip Download GeoIP database
|
|
18
|
-
init list List available OS and region options
|
|
19
|
-
create fingerprint --os <os> --region <r> Create browser fingerprint
|
|
20
|
-
create profile <profileId> Create a new profile
|
|
21
|
-
|
|
22
|
-
CONFIG:
|
|
23
|
-
config repo-root [path] Get or set persisted camo repo root
|
|
24
|
-
highlight-mode [status|on|off] Global highlight mode for click/type/scroll (default: on)
|
|
25
|
-
attach <profileId|sessionId> Attach to session via WS; read JSON commands from stdin
|
|
26
|
-
|
|
27
|
-
BROWSER CONTROL:
|
|
28
|
-
init Ensure camoufox + ensure browser-service daemon
|
|
29
|
-
start [profileId] [--url <url>] [--no-headless|--visible] [--devtools] [--record] [--record-name <name>] [--record-output <path>] [--record-overlay|--no-record-overlay] [--alias <name>] [--idle-timeout <duration>] [--width <w> --height <h>
|
|
30
|
-
stop [profileId]
|
|
31
|
-
stop --id <instanceId> Stop by instance id
|
|
32
|
-
stop --alias <alias> Stop by alias
|
|
33
|
-
stop idle Stop all idle sessions
|
|
34
|
-
stop all Stop all sessions
|
|
35
|
-
status [profileId] Show resolved per-profile session view
|
|
36
|
-
list Alias of status
|
|
37
|
-
|
|
38
|
-
LIFECYCLE & CLEANUP:
|
|
39
|
-
instances List resolved session view (live + registered + idle state)
|
|
40
|
-
sessions List resolved session view for all profiles
|
|
41
|
-
cleanup [profileId] Cleanup only one profile (remote stop + local registry/lock/watchdog)
|
|
42
|
-
cleanup all Cleanup all active sessions
|
|
43
|
-
cleanup locks Cleanup stale lock files
|
|
44
|
-
force-stop [profileId] Force stop only one profile session (no alias/id targeting)
|
|
45
|
-
lock list List active session locks
|
|
46
|
-
lock [profileId] Show lock info for profile
|
|
47
|
-
unlock [profileId] Release lock for profile
|
|
48
|
-
|
|
49
|
-
NAVIGATION:
|
|
50
|
-
goto [profileId] <url> Navigate to URL (uses default if profileId omitted)
|
|
51
|
-
back [profileId] Navigate back (uses default)
|
|
52
|
-
screenshot [profileId] [--output <file>] [--full]
|
|
53
|
-
|
|
54
|
-
INTERACTION:
|
|
55
|
-
scroll [profileId] [--down|--up|--left|--right] [--amount <px>] [--selector <css>] [--highlight|--no-highlight]
|
|
56
|
-
click [profileId] <selector> [--highlight|--no-highlight] Click visible element by CSS selector
|
|
57
|
-
type [profileId] <selector> <text> [--highlight|--no-highlight] Type into visible input element
|
|
58
|
-
highlight [profileId] <selector> Highlight element (red border, 2s)
|
|
59
|
-
clear-highlight [profileId] Clear all highlights
|
|
60
|
-
viewport [profileId] --width <w> --height <h>
|
|
61
|
-
|
|
62
|
-
PAGES:
|
|
63
|
-
new-page [profileId] [--url <url>]
|
|
64
|
-
close-page [profileId] [index]
|
|
65
|
-
switch-page [profileId] <index>
|
|
66
|
-
list-pages [profileId] List pages only when that profile is live
|
|
67
|
-
|
|
68
|
-
DEVTOOLS:
|
|
69
|
-
devtools logs [profileId] [--limit 120] [--since <unix_ms>] [--levels error,warn] [--clear]
|
|
70
|
-
devtools eval [profileId] <expression> [--profile <id>]
|
|
71
|
-
devtools clear [profileId]
|
|
72
|
-
|
|
73
|
-
RECORDING:
|
|
74
|
-
record start [profileId] [--name <name>] [--output <file>] [--overlay|--no-overlay]
|
|
75
|
-
record stop [profileId] [--reason <text>]
|
|
76
|
-
record status [profileId]
|
|
77
|
-
|
|
78
|
-
COOKIES:
|
|
79
|
-
cookies get [profileId] Get all cookies for profile
|
|
80
|
-
cookies save [profileId] --path <file> Save cookies to file
|
|
81
|
-
cookies load [profileId] --path <file> Load cookies from file
|
|
82
|
-
cookies auto start [profileId] [--interval <ms>] Start auto-saving cookies
|
|
83
|
-
cookies auto stop [profileId] Stop auto-saving
|
|
84
|
-
cookies auto status [profileId] Check auto-save status
|
|
85
|
-
|
|
86
|
-
WINDOW:
|
|
87
|
-
window move [profileId] --x <x> --y <y> Move browser window
|
|
88
|
-
window resize [profileId] --width <w> --height <h> Resize browser window
|
|
89
|
-
|
|
90
|
-
MOUSE:
|
|
91
|
-
mouse click [profileId] --x <x> --y <y> [--button left|right|middle] [--clicks <n>] [--delay <ms>] Click at coordinates
|
|
92
|
-
mouse wheel [profileId] [--deltax <px>] [--deltay <px>] Scroll wheel
|
|
93
|
-
|
|
94
|
-
SYSTEM:
|
|
95
|
-
system display Show display metrics
|
|
96
|
-
|
|
97
|
-
SYSTEM:
|
|
98
|
-
shutdown Shutdown browser-service (stops all sessions)
|
|
99
|
-
version | --version | -v Print camo CLI version
|
|
100
|
-
help
|
|
101
|
-
|
|
102
|
-
EXAMPLES:
|
|
103
|
-
camo init
|
|
104
|
-
camo init geoip
|
|
105
|
-
camo init list
|
|
106
|
-
camo create fingerprint --os mac --region us
|
|
107
|
-
camo create fingerprint --os windows --region uk
|
|
108
|
-
camo profile create myprofile
|
|
109
|
-
camo profile default myprofile
|
|
110
|
-
camo start --url https://example.com --alias main
|
|
111
|
-
camo start worker-1 --alias shard1 --idle-timeout 45m
|
|
112
|
-
camo start worker-1 --visible --devtools
|
|
113
|
-
camo start worker-1 --record --record-name xhs-debug --record-output ./logs/xhs-debug.jsonl --record-overlay
|
|
114
|
-
camo start myprofile --width 1920 --height 1020
|
|
115
|
-
camo highlight-mode on
|
|
116
|
-
camo devtools eval myprofile "document.title"
|
|
117
|
-
camo devtools logs myprofile --levels error,warn --limit 50
|
|
118
|
-
camo record start myprofile --name session-a --output ./logs/session-a.jsonl
|
|
119
|
-
camo record status myprofile
|
|
120
|
-
camo record stop myprofile
|
|
121
|
-
camo stop --id inst_xxxxxxxx
|
|
122
|
-
camo stop --alias shard1
|
|
123
|
-
camo stop idle
|
|
124
|
-
camo close all
|
|
125
|
-
camo goto https://www.xiaohongshu.com
|
|
126
|
-
camo scroll --down --amount 500 --selector ".feed-list"
|
|
127
|
-
camo click "#search-input" --highlight
|
|
128
|
-
camo type "#search-input" "hello world" --highlight
|
|
129
|
-
camo highlight ".post-card"
|
|
130
|
-
camo viewport --width 1920 --height 1080
|
|
131
|
-
camo cookies get
|
|
132
|
-
camo cookies save --path /tmp/cookies.json
|
|
133
|
-
camo cookies load --path /tmp/cookies.json
|
|
134
|
-
camo cookies auto start --interval 5000
|
|
135
|
-
camo window move --x 100 --y 100
|
|
136
|
-
camo window resize --width 1920 --height 1080
|
|
137
|
-
camo mouse click --x 500 --y 300 --button left
|
|
138
|
-
camo mouse wheel --deltay -300
|
|
139
|
-
camo system display
|
|
140
|
-
camo sessions
|
|
141
|
-
camo instances
|
|
142
|
-
camo cleanup myprofile
|
|
143
|
-
camo force-stop myprofile
|
|
144
|
-
camo lock list
|
|
145
|
-
camo unlock myprofile
|
|
146
|
-
camo stop
|
|
147
|
-
echo '{"action":"stop","args":{"profileId":"myprofile"}}' | camo attach myprofile
|
|
148
|
-
|
|
149
|
-
CONTAINER FILTER & SUBSCRIPTION:
|
|
150
|
-
container init [--source <dir>] [--force] Initialize subscription dir + migrate container sets
|
|
151
|
-
container sets [--site <siteKey>] List migrated subscription sets
|
|
152
|
-
container register [profileId] <setId...> Register targets (path / url+dom markers) for profile
|
|
153
|
-
container targets [profileId] Show registered subscription targets
|
|
154
|
-
container filter [profileId] <selector...> Filter DOM elements by CSS selector
|
|
155
|
-
container watch [profileId] [--selector <css>] Watch for element changes (or use registered selectors)
|
|
156
|
-
container list [profileId] List visible elements in viewport
|
|
157
|
-
|
|
158
|
-
AUTOSCRIPT (STRATEGY LAYER):
|
|
159
|
-
autoscript validate <file> Validate autoscript schema and references
|
|
160
|
-
autoscript explain <file> Print normalized graph and defaults
|
|
161
|
-
autoscript snapshot <jsonl-file> [--out <snapshot-file>] Build resumable snapshot from run JSONL
|
|
162
|
-
autoscript replay <jsonl-file> [--summary-file <path>] Rebuild summary from run JSONL
|
|
163
|
-
autoscript run <file> [--profile <id>] [--jsonl-file <path>] [--summary-file <path>] Run autoscript runtime
|
|
164
|
-
autoscript resume <file> --snapshot <snapshot-file> [--from-node <nodeId>] [--profile <id>] [--jsonl-file <path>] [--summary-file <path>]
|
|
165
|
-
autoscript mock-run <file> --fixture <fixture.json> [--profile <id>] [--jsonl-file <path>] [--summary-file <path>]
|
|
166
|
-
|
|
167
|
-
PROGRESS EVENTS:
|
|
168
|
-
events serve [--host 127.0.0.1] [--port 7788] Start progress websocket server (/events)
|
|
169
|
-
events tail [filters...] Tail progress events via websocket
|
|
170
|
-
events recent [--limit 50] Show recent persisted events
|
|
171
|
-
events emit --event <name> Emit a manual test event
|
|
172
|
-
(non-events commands auto-start daemon by default)
|
|
173
|
-
|
|
174
|
-
ENV:
|
|
175
|
-
CAMO_BROWSER_URL Default: http://127.0.0.1:7704
|
|
176
|
-
CAMO_INSTALL_DIR Optional @web-auto/camo install dir
|
|
177
|
-
CAMO_REPO_ROOT Optional camo repo root (dev mode)
|
|
178
|
-
CAMO_DATA_ROOT / CAMO_HOME Optional data root (Windows default D:\\camo)
|
|
179
|
-
CAMO_PROFILE_ROOT Optional profile dir override
|
|
180
|
-
CAMO_ROOT Legacy data root (auto-appends .camo if needed)
|
|
181
|
-
CAMO_WS_URL Optional ws://host:port override
|
|
182
|
-
CAMO_WS_HOST / CAMO_WS_PORT WS host/port for browser-service
|
|
183
|
-
CAMO_BRING_TO_FRONT_MODE Bring-to-front policy: auto (default) | never
|
|
184
|
-
CAMO_SKIP_BRING_TO_FRONT Legacy alias for CAMO_BRING_TO_FRONT_MODE=never
|
|
185
|
-
CAMO_PROGRESS_EVENTS_FILE Optional path override for progress jsonl
|
|
186
|
-
CAMO_PROGRESS_WS_HOST / CAMO_PROGRESS_WS_PORT Progress daemon host/port (defaults: 127.0.0.1:7788)
|
|
187
|
-
|
|
188
|
-
SESSION ISOLATION:
|
|
189
|
-
- profile is the lifecycle primary key. browser-service, lock, watchdog, registry all bind to the same profileId.
|
|
190
|
-
- camo start/stop/cleanup/force-stop <profileId> only targets that exact profile and must not affect other profiles.
|
|
191
|
-
- stop --id / stop --alias are convenience selectors for stop only; cleanup/force-stop never accept alias or instance id.
|
|
192
|
-
- status/sessions/instances all read the same resolved session view with these fields:
|
|
193
|
-
live: browser-service currently has this profile session
|
|
194
|
-
registered: local registry has metadata for this profile
|
|
195
|
-
orphaned: registry exists but service session is gone
|
|
196
|
-
needsRecovery: registry says active but service no longer has that profile
|
|
197
|
-
- list-pages requires live=true for that profile; otherwise camo will fail fast instead of probing other profiles.
|
|
198
|
-
|
|
199
|
-
ISOLATION EXAMPLES:
|
|
200
|
-
camo sessions
|
|
201
|
-
camo status finger
|
|
202
|
-
camo stop finger
|
|
203
|
-
camo status xhs-qa-1
|
|
204
|
-
camo cleanup finger
|
|
205
|
-
camo force-stop finger
|
|
206
|
-
invalid: camo cleanup --alias shard1
|
|
207
|
-
invalid: camo force-stop --id inst_xxxxxxxx
|
|
208
|
-
`);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export function printProfilesAndHint(listProfiles, getDefaultProfile) {
|
|
212
|
-
const profiles = listProfiles();
|
|
213
|
-
const defaultProfile = getDefaultProfile();
|
|
214
|
-
console.log(JSON.stringify({ ok: true, profiles, defaultProfile, count: profiles.length }, null, 2));
|
|
215
|
-
console.log('\\nRun \`camo help\` for usage.');
|
|
216
|
-
}
|
|
1
|
+
export function printHelp() {
|
|
2
|
+
console.log(`
|
|
3
|
+
camo CLI - Camoufox browser controller
|
|
4
|
+
|
|
5
|
+
USAGE:
|
|
6
|
+
camo <command> [options]
|
|
7
|
+
|
|
8
|
+
PROFILE MANAGEMENT:
|
|
9
|
+
profiles List profiles with default profile
|
|
10
|
+
profile [list] List profiles (same as profiles)
|
|
11
|
+
profile create <profileId> Create a profile
|
|
12
|
+
profile delete <profileId> Delete a profile
|
|
13
|
+
profile default [profileId] Get or set default profile
|
|
14
|
+
|
|
15
|
+
INITIALIZATION:
|
|
16
|
+
init Ensure camoufox + browser-service
|
|
17
|
+
init geoip Download GeoIP database
|
|
18
|
+
init list List available OS and region options
|
|
19
|
+
create fingerprint --os <os> --region <r> Create browser fingerprint
|
|
20
|
+
create profile <profileId> Create a new profile
|
|
21
|
+
|
|
22
|
+
CONFIG:
|
|
23
|
+
config repo-root [path] Get or set persisted camo repo root
|
|
24
|
+
highlight-mode [status|on|off] Global highlight mode for click/type/scroll (default: on)
|
|
25
|
+
attach <profileId|sessionId> Attach to session via WS; read JSON commands from stdin
|
|
26
|
+
|
|
27
|
+
BROWSER CONTROL:
|
|
28
|
+
init Ensure camoufox + ensure browser-service daemon
|
|
29
|
+
start [profileId] [--url <url>] [--no-headless|--visible] [--devtools] [--record] [--record-name <name>] [--record-output <path>] [--record-overlay|--no-record-overlay] [--alias <name>] [--idle-timeout <duration>] [--width <w> --height <h>]
|
|
30
|
+
stop [profileId]
|
|
31
|
+
stop --id <instanceId> Stop by instance id
|
|
32
|
+
stop --alias <alias> Stop by alias
|
|
33
|
+
stop idle Stop all idle sessions
|
|
34
|
+
stop all Stop all sessions
|
|
35
|
+
status [profileId] Show resolved per-profile session view
|
|
36
|
+
list Alias of status
|
|
37
|
+
|
|
38
|
+
LIFECYCLE & CLEANUP:
|
|
39
|
+
instances List resolved session view (live + registered + idle state)
|
|
40
|
+
sessions List resolved session view for all profiles
|
|
41
|
+
cleanup [profileId] Cleanup only one profile (remote stop + local registry/lock/watchdog)
|
|
42
|
+
cleanup all Cleanup all active sessions
|
|
43
|
+
cleanup locks Cleanup stale lock files
|
|
44
|
+
force-stop [profileId] Force stop only one profile session (no alias/id targeting)
|
|
45
|
+
lock list List active session locks
|
|
46
|
+
lock [profileId] Show lock info for profile
|
|
47
|
+
unlock [profileId] Release lock for profile
|
|
48
|
+
|
|
49
|
+
NAVIGATION:
|
|
50
|
+
goto [profileId] <url> Navigate to URL (uses default if profileId omitted)
|
|
51
|
+
back [profileId] Navigate back (uses default)
|
|
52
|
+
screenshot [profileId] [--output <file>] [--full]
|
|
53
|
+
|
|
54
|
+
INTERACTION:
|
|
55
|
+
scroll [profileId] [--down|--up|--left|--right] [--amount <px>] [--selector <css>] [--highlight|--no-highlight]
|
|
56
|
+
click [profileId] <selector> [--highlight|--no-highlight] Click visible element by CSS selector
|
|
57
|
+
type [profileId] <selector> <text> [--highlight|--no-highlight] Type into visible input element
|
|
58
|
+
highlight [profileId] <selector> Highlight element (red border, 2s)
|
|
59
|
+
clear-highlight [profileId] Clear all highlights
|
|
60
|
+
viewport [profileId] --width <w> --height <h>
|
|
61
|
+
|
|
62
|
+
PAGES:
|
|
63
|
+
new-page [profileId] [--url <url>]
|
|
64
|
+
close-page [profileId] [index]
|
|
65
|
+
switch-page [profileId] <index>
|
|
66
|
+
list-pages [profileId] List pages only when that profile is live
|
|
67
|
+
|
|
68
|
+
DEVTOOLS:
|
|
69
|
+
devtools logs [profileId] [--limit 120] [--since <unix_ms>] [--levels error,warn] [--clear]
|
|
70
|
+
devtools eval [profileId] <expression> [--profile <id>]
|
|
71
|
+
devtools clear [profileId]
|
|
72
|
+
|
|
73
|
+
RECORDING:
|
|
74
|
+
record start [profileId] [--name <name>] [--output <file>] [--overlay|--no-overlay]
|
|
75
|
+
record stop [profileId] [--reason <text>]
|
|
76
|
+
record status [profileId]
|
|
77
|
+
|
|
78
|
+
COOKIES:
|
|
79
|
+
cookies get [profileId] Get all cookies for profile
|
|
80
|
+
cookies save [profileId] --path <file> Save cookies to file
|
|
81
|
+
cookies load [profileId] --path <file> Load cookies from file
|
|
82
|
+
cookies auto start [profileId] [--interval <ms>] Start auto-saving cookies
|
|
83
|
+
cookies auto stop [profileId] Stop auto-saving
|
|
84
|
+
cookies auto status [profileId] Check auto-save status
|
|
85
|
+
|
|
86
|
+
WINDOW:
|
|
87
|
+
window move [profileId] --x <x> --y <y> Move browser window
|
|
88
|
+
window resize [profileId] --width <w> --height <h> Resize browser window
|
|
89
|
+
|
|
90
|
+
MOUSE:
|
|
91
|
+
mouse click [profileId] --x <x> --y <y> [--button left|right|middle] [--clicks <n>] [--delay <ms>] Click at coordinates
|
|
92
|
+
mouse wheel [profileId] [--deltax <px>] [--deltay <px>] Scroll wheel
|
|
93
|
+
|
|
94
|
+
SYSTEM:
|
|
95
|
+
system display Show display metrics
|
|
96
|
+
|
|
97
|
+
SYSTEM:
|
|
98
|
+
shutdown Shutdown browser-service (stops all sessions)
|
|
99
|
+
version | --version | -v Print camo CLI version
|
|
100
|
+
help
|
|
101
|
+
|
|
102
|
+
EXAMPLES:
|
|
103
|
+
camo init
|
|
104
|
+
camo init geoip
|
|
105
|
+
camo init list
|
|
106
|
+
camo create fingerprint --os mac --region us
|
|
107
|
+
camo create fingerprint --os windows --region uk
|
|
108
|
+
camo profile create myprofile
|
|
109
|
+
camo profile default myprofile
|
|
110
|
+
camo start --url https://example.com --alias main
|
|
111
|
+
camo start worker-1 --alias shard1 --idle-timeout 45m
|
|
112
|
+
camo start worker-1 --visible --devtools
|
|
113
|
+
camo start worker-1 --record --record-name xhs-debug --record-output ./logs/xhs-debug.jsonl --record-overlay
|
|
114
|
+
camo start myprofile --width 1920 --height 1020
|
|
115
|
+
camo highlight-mode on
|
|
116
|
+
camo devtools eval myprofile "document.title"
|
|
117
|
+
camo devtools logs myprofile --levels error,warn --limit 50
|
|
118
|
+
camo record start myprofile --name session-a --output ./logs/session-a.jsonl
|
|
119
|
+
camo record status myprofile
|
|
120
|
+
camo record stop myprofile
|
|
121
|
+
camo stop --id inst_xxxxxxxx
|
|
122
|
+
camo stop --alias shard1
|
|
123
|
+
camo stop idle
|
|
124
|
+
camo close all
|
|
125
|
+
camo goto https://www.xiaohongshu.com
|
|
126
|
+
camo scroll --down --amount 500 --selector ".feed-list"
|
|
127
|
+
camo click "#search-input" --highlight
|
|
128
|
+
camo type "#search-input" "hello world" --highlight
|
|
129
|
+
camo highlight ".post-card"
|
|
130
|
+
camo viewport --width 1920 --height 1080
|
|
131
|
+
camo cookies get
|
|
132
|
+
camo cookies save --path /tmp/cookies.json
|
|
133
|
+
camo cookies load --path /tmp/cookies.json
|
|
134
|
+
camo cookies auto start --interval 5000
|
|
135
|
+
camo window move --x 100 --y 100
|
|
136
|
+
camo window resize --width 1920 --height 1080
|
|
137
|
+
camo mouse click --x 500 --y 300 --button left
|
|
138
|
+
camo mouse wheel --deltay -300
|
|
139
|
+
camo system display
|
|
140
|
+
camo sessions
|
|
141
|
+
camo instances
|
|
142
|
+
camo cleanup myprofile
|
|
143
|
+
camo force-stop myprofile
|
|
144
|
+
camo lock list
|
|
145
|
+
camo unlock myprofile
|
|
146
|
+
camo stop
|
|
147
|
+
echo '{"action":"stop","args":{"profileId":"myprofile"}}' | camo attach myprofile
|
|
148
|
+
|
|
149
|
+
CONTAINER FILTER & SUBSCRIPTION:
|
|
150
|
+
container init [--source <dir>] [--force] Initialize subscription dir + migrate container sets
|
|
151
|
+
container sets [--site <siteKey>] List migrated subscription sets
|
|
152
|
+
container register [profileId] <setId...> Register targets (path / url+dom markers) for profile
|
|
153
|
+
container targets [profileId] Show registered subscription targets
|
|
154
|
+
container filter [profileId] <selector...> Filter DOM elements by CSS selector
|
|
155
|
+
container watch [profileId] [--selector <css>] Watch for element changes (or use registered selectors)
|
|
156
|
+
container list [profileId] List visible elements in viewport
|
|
157
|
+
|
|
158
|
+
AUTOSCRIPT (STRATEGY LAYER):
|
|
159
|
+
autoscript validate <file> Validate autoscript schema and references
|
|
160
|
+
autoscript explain <file> Print normalized graph and defaults
|
|
161
|
+
autoscript snapshot <jsonl-file> [--out <snapshot-file>] Build resumable snapshot from run JSONL
|
|
162
|
+
autoscript replay <jsonl-file> [--summary-file <path>] Rebuild summary from run JSONL
|
|
163
|
+
autoscript run <file> [--profile <id>] [--jsonl-file <path>] [--summary-file <path>] Run autoscript runtime
|
|
164
|
+
autoscript resume <file> --snapshot <snapshot-file> [--from-node <nodeId>] [--profile <id>] [--jsonl-file <path>] [--summary-file <path>]
|
|
165
|
+
autoscript mock-run <file> --fixture <fixture.json> [--profile <id>] [--jsonl-file <path>] [--summary-file <path>]
|
|
166
|
+
|
|
167
|
+
PROGRESS EVENTS:
|
|
168
|
+
events serve [--host 127.0.0.1] [--port 7788] Start progress websocket server (/events)
|
|
169
|
+
events tail [filters...] Tail progress events via websocket
|
|
170
|
+
events recent [--limit 50] Show recent persisted events
|
|
171
|
+
events emit --event <name> Emit a manual test event
|
|
172
|
+
(non-events commands auto-start daemon by default)
|
|
173
|
+
|
|
174
|
+
ENV:
|
|
175
|
+
CAMO_BROWSER_URL Default: http://127.0.0.1:7704
|
|
176
|
+
CAMO_INSTALL_DIR Optional @web-auto/camo install dir
|
|
177
|
+
CAMO_REPO_ROOT Optional camo repo root (dev mode)
|
|
178
|
+
CAMO_DATA_ROOT / CAMO_HOME Optional data root (Windows default D:\\camo)
|
|
179
|
+
CAMO_PROFILE_ROOT Optional profile dir override
|
|
180
|
+
CAMO_ROOT Legacy data root (auto-appends .camo if needed)
|
|
181
|
+
CAMO_WS_URL Optional ws://host:port override
|
|
182
|
+
CAMO_WS_HOST / CAMO_WS_PORT WS host/port for browser-service
|
|
183
|
+
CAMO_BRING_TO_FRONT_MODE Bring-to-front policy: auto (default) | never
|
|
184
|
+
CAMO_SKIP_BRING_TO_FRONT Legacy alias for CAMO_BRING_TO_FRONT_MODE=never
|
|
185
|
+
CAMO_PROGRESS_EVENTS_FILE Optional path override for progress jsonl
|
|
186
|
+
CAMO_PROGRESS_WS_HOST / CAMO_PROGRESS_WS_PORT Progress daemon host/port (defaults: 127.0.0.1:7788)
|
|
187
|
+
|
|
188
|
+
SESSION ISOLATION:
|
|
189
|
+
- profile is the lifecycle primary key. browser-service, lock, watchdog, registry all bind to the same profileId.
|
|
190
|
+
- camo start/stop/cleanup/force-stop <profileId> only targets that exact profile and must not affect other profiles.
|
|
191
|
+
- stop --id / stop --alias are convenience selectors for stop only; cleanup/force-stop never accept alias or instance id.
|
|
192
|
+
- status/sessions/instances all read the same resolved session view with these fields:
|
|
193
|
+
live: browser-service currently has this profile session
|
|
194
|
+
registered: local registry has metadata for this profile
|
|
195
|
+
orphaned: registry exists but service session is gone
|
|
196
|
+
needsRecovery: registry says active but service no longer has that profile
|
|
197
|
+
- list-pages requires live=true for that profile; otherwise camo will fail fast instead of probing other profiles.
|
|
198
|
+
|
|
199
|
+
ISOLATION EXAMPLES:
|
|
200
|
+
camo sessions
|
|
201
|
+
camo status finger
|
|
202
|
+
camo stop finger
|
|
203
|
+
camo status xhs-qa-1
|
|
204
|
+
camo cleanup finger
|
|
205
|
+
camo force-stop finger
|
|
206
|
+
invalid: camo cleanup --alias shard1
|
|
207
|
+
invalid: camo force-stop --id inst_xxxxxxxx
|
|
208
|
+
`);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function printProfilesAndHint(listProfiles, getDefaultProfile) {
|
|
212
|
+
const profiles = listProfiles();
|
|
213
|
+
const defaultProfile = getDefaultProfile();
|
|
214
|
+
console.log(JSON.stringify({ ok: true, profiles, defaultProfile, count: profiles.length }, null, 2));
|
|
215
|
+
console.log('\\nRun \`camo help\` for usage.');
|
|
216
|
+
}
|
package/src/utils/js-policy.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
function isTruthy(value) {
|
|
2
|
-
const text = String(value || '').trim().toLowerCase();
|
|
3
|
-
return ['1', 'true', 'yes', 'on'].includes(text);
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function isJsExecutionEnabled() {
|
|
7
|
-
return isTruthy(process.env.CAMO_ALLOW_JS);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function ensureJsExecutionEnabled(scope = 'JavaScript execution') {
|
|
11
|
-
if (isJsExecutionEnabled()) return;
|
|
12
|
-
throw new Error(`${scope} is disabled by default. Re-run with --js to enable.`);
|
|
13
|
-
}
|
|
1
|
+
function isTruthy(value) {
|
|
2
|
+
const text = String(value || '').trim().toLowerCase();
|
|
3
|
+
return ['1', 'true', 'yes', 'on'].includes(text);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function isJsExecutionEnabled() {
|
|
7
|
+
return isTruthy(process.env.CAMO_ALLOW_JS);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function ensureJsExecutionEnabled(scope = 'JavaScript execution') {
|
|
11
|
+
if (isJsExecutionEnabled()) return;
|
|
12
|
+
throw new Error(`${scope} is disabled by default. Re-run with --js to enable.`);
|
|
13
|
+
}
|
package/src/utils/ws-client.mjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export function resolveWsUrl() {
|
|
2
|
-
const explicit = String(process.env.CAMO_WS_URL || '').trim();
|
|
3
|
-
if (explicit) return explicit;
|
|
4
|
-
const host = String(process.env.CAMO_WS_HOST || '127.0.0.1').trim() || '127.0.0.1';
|
|
5
|
-
const port = Number(process.env.CAMO_WS_PORT || 8765) || 8765;
|
|
6
|
-
return `ws://${host}:${port}`;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export async function ensureWsClient(wsUrl = resolveWsUrl()) {
|
|
10
|
-
if (typeof WebSocket !== 'function') {
|
|
11
|
-
throw new Error('Global WebSocket is unavailable in this Node runtime');
|
|
12
|
-
}
|
|
13
|
-
return new Promise((resolve, reject) => {
|
|
14
|
-
const socket = new WebSocket(wsUrl);
|
|
15
|
-
const timer = setTimeout(() => {
|
|
16
|
-
try { socket.close(); } catch {}
|
|
17
|
-
reject(new Error(`WebSocket connect timeout: ${wsUrl}`));
|
|
18
|
-
}, 8000);
|
|
19
|
-
|
|
20
|
-
socket.addEventListener('open', () => {
|
|
21
|
-
clearTimeout(timer);
|
|
22
|
-
resolve(socket);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
socket.addEventListener('error', (err) => {
|
|
26
|
-
clearTimeout(timer);
|
|
27
|
-
reject(new Error(`WebSocket connect failed: ${err?.message || String(err)}`));
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
1
|
+
export function resolveWsUrl() {
|
|
2
|
+
const explicit = String(process.env.CAMO_WS_URL || '').trim();
|
|
3
|
+
if (explicit) return explicit;
|
|
4
|
+
const host = String(process.env.CAMO_WS_HOST || '127.0.0.1').trim() || '127.0.0.1';
|
|
5
|
+
const port = Number(process.env.CAMO_WS_PORT || 8765) || 8765;
|
|
6
|
+
return `ws://${host}:${port}`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function ensureWsClient(wsUrl = resolveWsUrl()) {
|
|
10
|
+
if (typeof WebSocket !== 'function') {
|
|
11
|
+
throw new Error('Global WebSocket is unavailable in this Node runtime');
|
|
12
|
+
}
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const socket = new WebSocket(wsUrl);
|
|
15
|
+
const timer = setTimeout(() => {
|
|
16
|
+
try { socket.close(); } catch {}
|
|
17
|
+
reject(new Error(`WebSocket connect timeout: ${wsUrl}`));
|
|
18
|
+
}, 8000);
|
|
19
|
+
|
|
20
|
+
socket.addEventListener('open', () => {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
resolve(socket);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
socket.addEventListener('error', (err) => {
|
|
26
|
+
clearTimeout(timer);
|
|
27
|
+
reject(new Error(`WebSocket connect failed: ${err?.message || String(err)}`));
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|