@trawlme/cli 3.15.0 → 3.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/README.md +10 -0
- package/dist/commands/admin.d.ts +2 -0
- package/dist/commands/admin.js +35 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,6 +132,16 @@ trawl scraps account session capture <id> [--chrome <path>] [--json]
|
|
|
132
132
|
|
|
133
133
|
`account session capture <id>` is the one-command version of the same idea: it opens a real, visible Chrome window at the scrap's target URL, waits for **you** to log in there — 2FA included — then reads the resulting session over the Chrome DevTools Protocol (cookies **and** per-origin localStorage) and uploads it. You stay authenticated as yourself; Trawl never sees your credentials, and responsibility for lawful use of the captured session stays with you. The capture is scoped to the scrap's own target host by RFC 6265 domain-matching, the same rule a real browser uses to decide which cookies to send: a cookie explicitly scoped to a domain (e.g. `Domain=example.com`) is in scope for that host and its subdomains, while a host-only cookie (no `Domain` attribute) is in scope only for the exact host it was set on — never a sibling subdomain, even one sharing a parent domain, and never another tenant on the same multi-tenant hosting domain (e.g. a different `*.github.io` site). localStorage follows the same anchor: an origin is in scope only if it's the target host itself or a subdomain of it. The one deliberate gap: a host-only cookie set on a sibling host (e.g. `auth.example.com` while the scrap targets `app.example.com`) is excluded — a real browser would never send it to the target host either, so nothing replay-relevant is lost unless the scrap script itself later navigates to that sibling. Completion is explicit: press Enter in the terminal once you're signed in — the primary path, and the only one guaranteed cross-platform. Closing the Chrome window also completes the capture (cookies only, not localStorage) when Chrome itself stays running after its last window closes, which this CLI verified on macOS; on a platform where closing the last window quits Chrome entirely, the command reports that fact instead of a session, and pressing Enter is the reliable path there. This command needs a local interactive terminal with a real display; it does not work headless, in CI, or over a plain SSH session, and auto-detects a system Chrome/Chromium (override with `--chrome <path>` or `TRAWL_CHROME_PATH`). Never prints the captured session itself, in any mode — `--json` echoes only the server's response plus capture counts.
|
|
134
134
|
|
|
135
|
+
### Platform admin (read-only)
|
|
136
|
+
|
|
137
|
+
Three read-only views for a platform admin. They need an API key with the `trawl:admin:read` scope whose owner is a platform admin (or an admin session); otherwise the API answers 403. Output is always JSON.
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
trawl admin orgs [--window 7d|30d|90d] Per-organization health and churn signals
|
|
141
|
+
trawl admin series [--window 7d|30d|90d] Platform-wide runs per day
|
|
142
|
+
trawl admin costs [--period day|week|month] Aggregate costs over a period
|
|
143
|
+
```
|
|
144
|
+
|
|
135
145
|
### Claude Code skills
|
|
136
146
|
|
|
137
147
|
The CLI bundles 5 Claude Code skills that teach Claude how to use `trawl`. Once installed, Claude can manage scraps for you via prompts.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Command, Option } from 'commander';
|
|
2
|
+
import { ApiError, api } from '../lib/api.js';
|
|
3
|
+
import { json } from '../lib/format.js';
|
|
4
|
+
const FORBIDDEN_HINT = 'Forbidden: this key needs the trawl:admin:read scope and a platform-admin owner (or log in as an admin).';
|
|
5
|
+
async function getAdmin(path, query) {
|
|
6
|
+
const qs = new URLSearchParams(Object.entries(query).filter(([, v]) => v !== undefined)).toString();
|
|
7
|
+
try {
|
|
8
|
+
json(await api.get(qs ? `${path}?${qs}` : path));
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
if (err instanceof ApiError && err.status === 403)
|
|
12
|
+
throw new ApiError(403, `${FORBIDDEN_HINT} (${err.message})`);
|
|
13
|
+
throw err;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const windowOption = () => new Option('--window <window>', 'Time window (7d|30d|90d)').choices(['7d', '30d', '90d']);
|
|
17
|
+
export const admin = new Command('admin').description('Platform-admin read-only views (needs trawl:admin:read + an admin owner)');
|
|
18
|
+
admin
|
|
19
|
+
.command('orgs')
|
|
20
|
+
.description('Per-organization health and churn signals (GET /api/admin/monitoring/organizations)')
|
|
21
|
+
.addOption(windowOption())
|
|
22
|
+
.option('--json', 'Output as JSON (default: on)', true)
|
|
23
|
+
.action((opts) => getAdmin('/api/admin/monitoring/organizations', { window: opts.window }));
|
|
24
|
+
admin
|
|
25
|
+
.command('series')
|
|
26
|
+
.description('Platform-wide runs per day (GET /api/admin/monitoring/series)')
|
|
27
|
+
.addOption(windowOption())
|
|
28
|
+
.option('--json', 'Output as JSON (default: on)', true)
|
|
29
|
+
.action((opts) => getAdmin('/api/admin/monitoring/series', { window: opts.window }));
|
|
30
|
+
admin
|
|
31
|
+
.command('costs')
|
|
32
|
+
.description('Aggregate costs over a period (GET /api/admin/costs)')
|
|
33
|
+
.addOption(new Option('--period <period>', 'Reporting period (day|week|month)').choices(['day', 'week', 'month']))
|
|
34
|
+
.option('--json', 'Output as JSON (default: on)', true)
|
|
35
|
+
.action((opts) => getAdmin('/api/admin/costs', { period: opts.period }));
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { upgrade } from './commands/upgrade.js';
|
|
|
13
13
|
import { create } from './commands/create.js';
|
|
14
14
|
import { whoami } from './commands/whoami.js';
|
|
15
15
|
import { ping } from './commands/ping.js';
|
|
16
|
+
import { admin } from './commands/admin.js';
|
|
16
17
|
import { spec } from './commands/spec.js';
|
|
17
18
|
import { autoUpdateInstalledSkills } from './lib/skills.js';
|
|
18
19
|
import { maybeSuggestSkillsInstall } from './lib/skillsNudge.js';
|
|
@@ -70,6 +71,7 @@ export function createProgram() {
|
|
|
70
71
|
program.commandsGroup(MANAGEMENT_GROUP);
|
|
71
72
|
program.addCommand(scraps);
|
|
72
73
|
program.addCommand(skills);
|
|
74
|
+
program.addCommand(admin);
|
|
73
75
|
program.addCommand(login);
|
|
74
76
|
program.addCommand(logout);
|
|
75
77
|
program.addCommand(telemetry);
|