@vforsh/argus 0.1.18 → 0.1.19
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/dist/.tsbuildinfo +1 -1
- package/dist/argus.js +2802 -564
- package/dist/cli/plugins/pluginHost.d.ts.map +1 -1
- package/dist/cli/plugins/pluginHost.js +1 -0
- package/dist/cli/plugins/pluginHost.js.map +1 -1
- package/dist/cli/register/extensionCommands.d.ts.map +1 -1
- package/dist/cli/register/extensionCommands.js +103 -3
- package/dist/cli/register/extensionCommands.js.map +1 -1
- package/dist/cli/register/index.d.ts.map +1 -1
- package/dist/cli/register/index.js +6 -0
- package/dist/cli/register/index.js.map +1 -1
- package/dist/cli/register/recordCommands.d.ts +3 -0
- package/dist/cli/register/recordCommands.d.ts.map +1 -0
- package/dist/cli/register/recordCommands.js +90 -0
- package/dist/cli/register/recordCommands.js.map +1 -0
- package/dist/cli/register/skillCommands.d.ts +3 -0
- package/dist/cli/register/skillCommands.d.ts.map +1 -0
- package/dist/cli/register/skillCommands.js +13 -0
- package/dist/cli/register/skillCommands.js.map +1 -0
- package/dist/commands/domDrag.d.ts +21 -0
- package/dist/commands/domDrag.d.ts.map +1 -0
- package/dist/commands/domDrag.js +179 -0
- package/dist/commands/domDrag.js.map +1 -0
- package/dist/commands/extension/attach.d.ts +2 -0
- package/dist/commands/extension/attach.d.ts.map +1 -1
- package/dist/commands/extension/attach.js +31 -6
- package/dist/commands/extension/attach.js.map +1 -1
- package/dist/commands/extension/doctor.d.ts +6 -0
- package/dist/commands/extension/doctor.d.ts.map +1 -0
- package/dist/commands/extension/doctor.js +185 -0
- package/dist/commands/extension/doctor.js.map +1 -0
- package/dist/commands/extension/select.d.ts +7 -0
- package/dist/commands/extension/select.d.ts.map +1 -0
- package/dist/commands/extension/select.js +73 -0
- package/dist/commands/extension/select.js.map +1 -0
- package/dist/commands/extension/show.d.ts +4 -0
- package/dist/commands/extension/show.d.ts.map +1 -1
- package/dist/commands/extension/show.js +12 -88
- package/dist/commands/extension/show.js.map +1 -1
- package/dist/commands/extension/tabAttach.d.ts +28 -0
- package/dist/commands/extension/tabAttach.d.ts.map +1 -0
- package/dist/commands/extension/tabAttach.js +106 -0
- package/dist/commands/extension/tabAttach.js.map +1 -0
- package/dist/commands/extension/tabWatcher.d.ts +22 -0
- package/dist/commands/extension/tabWatcher.d.ts.map +1 -0
- package/dist/commands/extension/tabWatcher.js +89 -0
- package/dist/commands/extension/tabWatcher.js.map +1 -0
- package/dist/commands/extension/targetSelection.d.ts +62 -0
- package/dist/commands/extension/targetSelection.d.ts.map +1 -0
- package/dist/commands/extension/targetSelection.js +210 -0
- package/dist/commands/extension/targetSelection.js.map +1 -0
- package/dist/commands/extension/targets.d.ts +7 -0
- package/dist/commands/extension/targets.d.ts.map +1 -0
- package/dist/commands/extension/targets.js +73 -0
- package/dist/commands/extension/targets.js.map +1 -0
- package/dist/commands/extension/use.d.ts +13 -0
- package/dist/commands/extension/use.d.ts.map +1 -0
- package/dist/commands/extension/use.js +66 -0
- package/dist/commands/extension/use.js.map +1 -0
- package/dist/commands/record.d.ts +35 -0
- package/dist/commands/record.d.ts.map +1 -0
- package/dist/commands/record.js +210 -0
- package/dist/commands/record.js.map +1 -0
- package/dist/commands/skill.d.ts +6 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +42 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/watcherNativeHost.js +48 -1
- package/dist/commands/watcherNativeHost.js.map +1 -1
- package/dist/skill/argus/SKILL.md +200 -0
- package/dist/skill/argus/reference/CAPTURE.md +77 -0
- package/dist/skill/argus/reference/DIALOG.md +31 -0
- package/dist/skill/argus/reference/EVAL.md +137 -0
- package/dist/skill/argus/reference/EXTENSION.md +38 -0
- package/dist/skill/argus/reference/EXTENSION_IFRAME_EVAL.md +58 -0
- package/dist/skill/argus/reference/IFRAMES.md +46 -0
- package/dist/skill/argus/reference/INJECT.md +145 -0
- package/dist/skill/argus/reference/INSPECT.md +175 -0
- package/dist/skill/argus/reference/NET.md +108 -0
- package/dist/skill/argus/reference/PLUGINS.md +172 -0
- package/dist/skill/argus/reference/RUNTIME_CODE.md +42 -0
- package/dist/skill/argus/reference/START.md +120 -0
- package/dist/skill/argus/start-watcher.ts +108 -0
- package/package.json +2 -2
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
## Start And Watcher Lifecycle
|
|
2
|
+
|
|
3
|
+
Use CDP startup when an isolated/debuggable Chrome is acceptable. Use extension-control instead when the task needs the user's normal browser profile, cookies, local storage, saved logins, or already-open tabs.
|
|
4
|
+
|
|
5
|
+
Long-running commands must run in the background in agent shells:
|
|
6
|
+
|
|
7
|
+
- `argus start`
|
|
8
|
+
- `argus chrome start`
|
|
9
|
+
- `argus watcher start`
|
|
10
|
+
- `argus logs tail`
|
|
11
|
+
- `argus net tail`
|
|
12
|
+
|
|
13
|
+
## Start (Chrome + Watcher)
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
argus start --id app --url localhost:3000
|
|
17
|
+
argus start --id app --auth-from extension-2
|
|
18
|
+
argus start --id app --auth-from extension-2 --url https://target.app/
|
|
19
|
+
argus start --id app --url localhost:3000 --dev-tools
|
|
20
|
+
argus start --id app --url localhost:3000 --profile temp
|
|
21
|
+
argus start --id app --type page --headless
|
|
22
|
+
argus start --id app --url localhost:3000 --inject ./debug.js
|
|
23
|
+
argus start --id app --url localhost:3000 --no-page-indicator
|
|
24
|
+
argus start --id app --url localhost:3000 --json
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`--url` opens in Chrome and matches the watcher target. `--auth-from` clones cookies and storage from another watcher into a fresh temp Chrome session before attach; add `--url` to override the final destination after hydration. `argus start` accepts Chrome options (`--profile`, `--dev-tools`, `--headless`) and watcher options (`--type`, `--origin`, `--target`, `--parent`, `--inject`, `--artifacts`, `--no-page-indicator`).
|
|
28
|
+
|
|
29
|
+
## Chrome Start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
argus chrome start --url http://localhost:3000
|
|
33
|
+
argus chrome start --from-watcher app
|
|
34
|
+
argus chrome start --dev-tools
|
|
35
|
+
argus chrome start --headless
|
|
36
|
+
argus chrome start --auth-state auth.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`--from-watcher` reads the URL from a registered watcher config. `--auth-state` hydrates cookies/storage into a fresh Chrome profile before opening the page.
|
|
40
|
+
|
|
41
|
+
## Watcher Start
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
argus watcher start --id app --url localhost:3000
|
|
45
|
+
argus watcher start --id app --url localhost:3000 --chrome-port 9222
|
|
46
|
+
argus watcher start --id app --type iframe --url localhost:3007
|
|
47
|
+
argus watcher start --id app --type iframe --parent example.com
|
|
48
|
+
argus watcher start --id app --origin https://localhost:3007
|
|
49
|
+
argus watcher start --id app --target CC1135709D9AC3B9CC0446F8B58CC344
|
|
50
|
+
argus watcher start --id app --url localhost:3000 --inject ./debug.js
|
|
51
|
+
argus watcher start --id app --url localhost:3000 --no-page-indicator
|
|
52
|
+
argus watcher start --id app --source extension
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`--url` matches a target URL substring. `--origin` matches protocol+host+port. `--target` connects to a specific Chrome target id. `--type` filters target type (`page`, `iframe`, `worker`). `--parent` filters by parent target URL. `--inject` runs a JS file on attach and navigation. `--no-page-indicator` hides the in-page overlay, useful before screenshots.
|
|
56
|
+
|
|
57
|
+
## Targets / Pages
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
argus page ls --id app
|
|
61
|
+
argus page ls --type iframe --id app
|
|
62
|
+
argus page ls --tree --id app
|
|
63
|
+
argus page open --url http://example.com --id app
|
|
64
|
+
argus page reload --id app
|
|
65
|
+
argus page reload <targetId> --param foo=bar
|
|
66
|
+
argus page activate <targetId>
|
|
67
|
+
argus page close <targetId>
|
|
68
|
+
argus reload app
|
|
69
|
+
argus reload app --ignore-cache
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Config Defaults
|
|
73
|
+
|
|
74
|
+
Load defaults for `argus start`, `argus chrome start`, and `argus watcher start` from config files.
|
|
75
|
+
|
|
76
|
+
Auto-discovery:
|
|
77
|
+
|
|
78
|
+
- `.argus/config.json`
|
|
79
|
+
- `.config/argus.json`
|
|
80
|
+
- `argus.config.json`
|
|
81
|
+
- `argus/config.json`
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"chrome": {
|
|
86
|
+
"start": { "url": "http://localhost:3000", "devTools": true }
|
|
87
|
+
},
|
|
88
|
+
"watcher": {
|
|
89
|
+
"start": {
|
|
90
|
+
"id": "app",
|
|
91
|
+
"url": "localhost:3000",
|
|
92
|
+
"chromePort": 9222,
|
|
93
|
+
"artifacts": "./artifacts",
|
|
94
|
+
"inject": { "file": "./scripts/debug.js" }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
CLI flags override config. `argus config init` creates a starter config. Script injection runs custom JS on attach and page navigation; see [INJECT.md](./INJECT.md).
|
|
101
|
+
|
|
102
|
+
## Programmatic Watcher (Node API)
|
|
103
|
+
|
|
104
|
+
Use `@vforsh/argus-watcher` to create watchers from code.
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
import { startWatcher } from '@vforsh/argus-watcher'
|
|
108
|
+
|
|
109
|
+
const { watcher, events, close } = await startWatcher({
|
|
110
|
+
id: 'app',
|
|
111
|
+
match: { url: 'localhost:3000' },
|
|
112
|
+
chrome: { host: '127.0.0.1', port: 9222 },
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
events.on('cdpAttached', ({ target }) => {
|
|
116
|
+
console.log(`Attached to ${target?.title}`)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
await close()
|
|
120
|
+
```
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: start an Argus watcher programmatically via `@vforsh/argus-watcher`.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { startWatcher } from '@vforsh/argus-watcher'
|
|
6
|
+
|
|
7
|
+
const main = async (): Promise<void> => {
|
|
8
|
+
const id = process.env.WATCHER_ID ?? 'app'
|
|
9
|
+
const matchUrl = process.env.MATCH_URL ?? 'localhost:3000'
|
|
10
|
+
|
|
11
|
+
const chromeHost = process.env.CHROME_HOST ?? '127.0.0.1'
|
|
12
|
+
const chromePort = parsePort(process.env.CHROME_PORT, 9222)
|
|
13
|
+
|
|
14
|
+
const bindHost = process.env.WATCHER_HOST ?? '127.0.0.1'
|
|
15
|
+
const bindPort = parsePort(process.env.WATCHER_PORT, 0)
|
|
16
|
+
|
|
17
|
+
const artifactsBase = process.env.ARTIFACTS_BASE
|
|
18
|
+
const fileLogsEnabled = parseBool(process.env.FILE_LOGS_ENABLED, false)
|
|
19
|
+
|
|
20
|
+
const { watcher, events, close } = await startWatcher({
|
|
21
|
+
id,
|
|
22
|
+
match: { url: matchUrl },
|
|
23
|
+
chrome: { host: chromeHost, port: chromePort },
|
|
24
|
+
host: bindHost,
|
|
25
|
+
port: bindPort,
|
|
26
|
+
artifacts: artifactsBase
|
|
27
|
+
? {
|
|
28
|
+
base: artifactsBase,
|
|
29
|
+
logs: { enabled: fileLogsEnabled },
|
|
30
|
+
}
|
|
31
|
+
: { logs: { enabled: fileLogsEnabled } },
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
console.log(`Watcher started: id=${watcher.id} url=http://${watcher.host}:${watcher.port}`)
|
|
35
|
+
|
|
36
|
+
events.on('cdpAttached', ({ target }) => {
|
|
37
|
+
console.log(`CDP attached: ${target?.title ?? '(unknown title)'} ${target?.url ?? ''}`.trim())
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
events.on('cdpDetached', ({ reason }) => {
|
|
41
|
+
console.log(`CDP detached: ${reason}`)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
installShutdownHandlers(async () => {
|
|
45
|
+
console.log('Shutting down watcher...')
|
|
46
|
+
await close()
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const parsePort = (raw: string | undefined, fallback: number): number => {
|
|
51
|
+
if (raw === undefined || raw === null || raw.trim() === '') {
|
|
52
|
+
return fallback
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const n = Number(raw)
|
|
56
|
+
if (!Number.isInteger(n) || n < 0 || n > 65535) {
|
|
57
|
+
throw new Error(`Invalid port: ${raw}`)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return n
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const parseBool = (raw: string | undefined, fallback: boolean): boolean => {
|
|
64
|
+
if (raw === undefined || raw === null || raw.trim() === '') {
|
|
65
|
+
return fallback
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
switch (raw.trim().toLowerCase()) {
|
|
69
|
+
case '1':
|
|
70
|
+
case 'true':
|
|
71
|
+
case 'yes':
|
|
72
|
+
case 'y':
|
|
73
|
+
case 'on':
|
|
74
|
+
return true
|
|
75
|
+
case '0':
|
|
76
|
+
case 'false':
|
|
77
|
+
case 'no':
|
|
78
|
+
case 'n':
|
|
79
|
+
case 'off':
|
|
80
|
+
return false
|
|
81
|
+
default:
|
|
82
|
+
throw new Error(`Invalid boolean: ${raw}`)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const installShutdownHandlers = (shutdown: () => Promise<void>): void => {
|
|
87
|
+
let closed = false
|
|
88
|
+
const closeOnce = async () => {
|
|
89
|
+
if (closed) {
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
closed = true
|
|
93
|
+
await shutdown()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
process.once('SIGINT', () => void closeOnce())
|
|
97
|
+
process.once('SIGTERM', () => void closeOnce())
|
|
98
|
+
process.once('uncaughtException', (err) => {
|
|
99
|
+
console.error(err)
|
|
100
|
+
void closeOnce()
|
|
101
|
+
})
|
|
102
|
+
process.once('unhandledRejection', (err) => {
|
|
103
|
+
console.error(err)
|
|
104
|
+
void closeOnce()
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
await main()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vforsh/argus",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/vforsh/argus.git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"clean": "node ../../scripts/clean-dist.mjs",
|
|
38
38
|
"build": "npm run clean && tsc -b && bun run bundle",
|
|
39
|
-
"bundle": "bun build dist/bin.js --outfile dist/argus.js --target node --external esbuild",
|
|
39
|
+
"bundle": "bun build dist/bin.js --outfile dist/argus.js --target node --external esbuild && node ../../scripts/copy-argus-skill.mjs",
|
|
40
40
|
"typecheck": "tsc -b --pretty false",
|
|
41
41
|
"chrome:start": "bun src/bin.ts chrome start"
|
|
42
42
|
}
|