@vforsh/argus 0.1.18 → 0.1.20

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 (116) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/argus.js +3008 -572
  3. package/dist/cli/plugins/pluginHost.d.ts.map +1 -1
  4. package/dist/cli/plugins/pluginHost.js +1 -0
  5. package/dist/cli/plugins/pluginHost.js.map +1 -1
  6. package/dist/cli/register/extensionCommands.d.ts.map +1 -1
  7. package/dist/cli/register/extensionCommands.js +131 -6
  8. package/dist/cli/register/extensionCommands.js.map +1 -1
  9. package/dist/cli/register/index.d.ts.map +1 -1
  10. package/dist/cli/register/index.js +6 -0
  11. package/dist/cli/register/index.js.map +1 -1
  12. package/dist/cli/register/recordCommands.d.ts +3 -0
  13. package/dist/cli/register/recordCommands.d.ts.map +1 -0
  14. package/dist/cli/register/recordCommands.js +90 -0
  15. package/dist/cli/register/recordCommands.js.map +1 -0
  16. package/dist/cli/register/skillCommands.d.ts +3 -0
  17. package/dist/cli/register/skillCommands.d.ts.map +1 -0
  18. package/dist/cli/register/skillCommands.js +13 -0
  19. package/dist/cli/register/skillCommands.js.map +1 -0
  20. package/dist/commands/domDrag.d.ts +21 -0
  21. package/dist/commands/domDrag.d.ts.map +1 -0
  22. package/dist/commands/domDrag.js +179 -0
  23. package/dist/commands/domDrag.js.map +1 -0
  24. package/dist/commands/extension/attach.d.ts +2 -0
  25. package/dist/commands/extension/attach.d.ts.map +1 -1
  26. package/dist/commands/extension/attach.js +31 -6
  27. package/dist/commands/extension/attach.js.map +1 -1
  28. package/dist/commands/extension/doctor.d.ts +6 -0
  29. package/dist/commands/extension/doctor.d.ts.map +1 -0
  30. package/dist/commands/extension/doctor.js +185 -0
  31. package/dist/commands/extension/doctor.js.map +1 -0
  32. package/dist/commands/extension/extensionId.d.ts +27 -0
  33. package/dist/commands/extension/extensionId.d.ts.map +1 -0
  34. package/dist/commands/extension/extensionId.js +37 -0
  35. package/dist/commands/extension/extensionId.js.map +1 -0
  36. package/dist/commands/extension/extensionPath.d.ts +15 -0
  37. package/dist/commands/extension/extensionPath.d.ts.map +1 -0
  38. package/dist/commands/extension/extensionPath.js +61 -0
  39. package/dist/commands/extension/extensionPath.js.map +1 -0
  40. package/dist/commands/extension/install.d.ts +16 -0
  41. package/dist/commands/extension/install.d.ts.map +1 -0
  42. package/dist/commands/extension/install.js +154 -0
  43. package/dist/commands/extension/install.js.map +1 -0
  44. package/dist/commands/extension/select.d.ts +7 -0
  45. package/dist/commands/extension/select.d.ts.map +1 -0
  46. package/dist/commands/extension/select.js +73 -0
  47. package/dist/commands/extension/select.js.map +1 -0
  48. package/dist/commands/extension/setup.d.ts +2 -1
  49. package/dist/commands/extension/setup.d.ts.map +1 -1
  50. package/dist/commands/extension/setup.js +5 -2
  51. package/dist/commands/extension/setup.js.map +1 -1
  52. package/dist/commands/extension/show.d.ts +4 -0
  53. package/dist/commands/extension/show.d.ts.map +1 -1
  54. package/dist/commands/extension/show.js +12 -88
  55. package/dist/commands/extension/show.js.map +1 -1
  56. package/dist/commands/extension/tabAttach.d.ts +28 -0
  57. package/dist/commands/extension/tabAttach.d.ts.map +1 -0
  58. package/dist/commands/extension/tabAttach.js +106 -0
  59. package/dist/commands/extension/tabAttach.js.map +1 -0
  60. package/dist/commands/extension/tabWatcher.d.ts +22 -0
  61. package/dist/commands/extension/tabWatcher.d.ts.map +1 -0
  62. package/dist/commands/extension/tabWatcher.js +89 -0
  63. package/dist/commands/extension/tabWatcher.js.map +1 -0
  64. package/dist/commands/extension/targetSelection.d.ts +62 -0
  65. package/dist/commands/extension/targetSelection.d.ts.map +1 -0
  66. package/dist/commands/extension/targetSelection.js +210 -0
  67. package/dist/commands/extension/targetSelection.js.map +1 -0
  68. package/dist/commands/extension/targets.d.ts +7 -0
  69. package/dist/commands/extension/targets.d.ts.map +1 -0
  70. package/dist/commands/extension/targets.js +73 -0
  71. package/dist/commands/extension/targets.js.map +1 -0
  72. package/dist/commands/extension/use.d.ts +13 -0
  73. package/dist/commands/extension/use.d.ts.map +1 -0
  74. package/dist/commands/extension/use.js +66 -0
  75. package/dist/commands/extension/use.js.map +1 -0
  76. package/dist/commands/record.d.ts +35 -0
  77. package/dist/commands/record.d.ts.map +1 -0
  78. package/dist/commands/record.js +210 -0
  79. package/dist/commands/record.js.map +1 -0
  80. package/dist/commands/skill.d.ts +6 -0
  81. package/dist/commands/skill.d.ts.map +1 -0
  82. package/dist/commands/skill.js +42 -0
  83. package/dist/commands/skill.js.map +1 -0
  84. package/dist/commands/watcherNativeHost.js +48 -1
  85. package/dist/commands/watcherNativeHost.js.map +1 -1
  86. package/dist/extension/dist/background/auth-header-monitor.js +77 -0
  87. package/dist/extension/dist/background/bridge-client.js +120 -0
  88. package/dist/extension/dist/background/cdp-proxy.js +201 -0
  89. package/dist/extension/dist/background/debugger-manager.js +296 -0
  90. package/dist/extension/dist/background/service-worker.js +2004 -0
  91. package/dist/extension/dist/background/service-worker.js.map +7 -0
  92. package/dist/extension/dist/popup/popup.js +730 -0
  93. package/dist/extension/dist/popup/popup.js.map +7 -0
  94. package/dist/extension/dist/popup/tabMarkup.js +104 -0
  95. package/dist/extension/dist/popup/viewState.js +60 -0
  96. package/dist/extension/dist/types/messages.js +5 -0
  97. package/dist/extension/icons/icon-128.png +0 -0
  98. package/dist/extension/icons/icon-16.png +0 -0
  99. package/dist/extension/icons/icon-48.png +0 -0
  100. package/dist/extension/manifest.json +26 -0
  101. package/dist/extension/src/popup/popup.html +756 -0
  102. package/dist/skill/argus/SKILL.md +202 -0
  103. package/dist/skill/argus/reference/CAPTURE.md +77 -0
  104. package/dist/skill/argus/reference/DIALOG.md +31 -0
  105. package/dist/skill/argus/reference/EVAL.md +137 -0
  106. package/dist/skill/argus/reference/EXTENSION.md +43 -0
  107. package/dist/skill/argus/reference/EXTENSION_IFRAME_EVAL.md +58 -0
  108. package/dist/skill/argus/reference/IFRAMES.md +46 -0
  109. package/dist/skill/argus/reference/INJECT.md +145 -0
  110. package/dist/skill/argus/reference/INSPECT.md +175 -0
  111. package/dist/skill/argus/reference/NET.md +108 -0
  112. package/dist/skill/argus/reference/PLUGINS.md +172 -0
  113. package/dist/skill/argus/reference/RUNTIME_CODE.md +42 -0
  114. package/dist/skill/argus/reference/START.md +120 -0
  115. package/dist/skill/argus/start-watcher.ts +108 -0
  116. 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.18",
3
+ "version": "0.1.20",
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 && node ../../scripts/copy-argus-extension.mjs",
40
40
  "typecheck": "tsc -b --pretty false",
41
41
  "chrome:start": "bun src/bin.ts chrome start"
42
42
  }