@aluvia/sdk 1.4.1 → 2.0.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +194 -0
  2. package/README.md +162 -477
  3. package/dist/cjs/api/apiUtils.js +4 -1
  4. package/dist/cjs/client/AluviaClient.js +30 -32
  5. package/dist/cjs/client/BlockDetection.js +69 -87
  6. package/dist/cjs/client/rules.js +12 -2
  7. package/dist/cjs/connect.js +2 -2
  8. package/dist/cjs/index.js +12 -1
  9. package/dist/cjs/session/lock.js +40 -4
  10. package/dist/esm/api/apiUtils.js +4 -1
  11. package/dist/esm/client/AluviaClient.js +38 -40
  12. package/dist/esm/client/BlockDetection.js +69 -87
  13. package/dist/esm/client/rules.js +12 -2
  14. package/dist/esm/connect.js +2 -2
  15. package/dist/esm/index.js +6 -4
  16. package/dist/esm/session/lock.js +40 -4
  17. package/dist/types/client/AluviaClient.d.ts +2 -2
  18. package/dist/types/client/BlockDetection.d.ts +4 -4
  19. package/dist/types/client/types.d.ts +11 -11
  20. package/dist/types/index.d.ts +9 -7
  21. package/package.json +15 -23
  22. package/dist/cjs/bin/account.js +0 -31
  23. package/dist/cjs/bin/api-helpers.js +0 -58
  24. package/dist/cjs/bin/cli-adapter.js +0 -16
  25. package/dist/cjs/bin/cli.js +0 -245
  26. package/dist/cjs/bin/close.js +0 -120
  27. package/dist/cjs/bin/geos.js +0 -10
  28. package/dist/cjs/bin/mcp-helpers.js +0 -57
  29. package/dist/cjs/bin/open.js +0 -317
  30. package/dist/cjs/bin/session.js +0 -259
  31. package/dist/esm/bin/account.js +0 -28
  32. package/dist/esm/bin/api-helpers.js +0 -53
  33. package/dist/esm/bin/cli-adapter.js +0 -8
  34. package/dist/esm/bin/cli.js +0 -242
  35. package/dist/esm/bin/close.js +0 -117
  36. package/dist/esm/bin/geos.js +0 -7
  37. package/dist/esm/bin/mcp-helpers.js +0 -51
  38. package/dist/esm/bin/open.js +0 -280
  39. package/dist/esm/bin/session.js +0 -252
  40. package/dist/types/bin/account.d.ts +0 -1
  41. package/dist/types/bin/api-helpers.d.ts +0 -20
  42. package/dist/types/bin/cli-adapter.d.ts +0 -8
  43. package/dist/types/bin/cli.d.ts +0 -2
  44. package/dist/types/bin/close.d.ts +0 -1
  45. package/dist/types/bin/geos.d.ts +0 -1
  46. package/dist/types/bin/mcp-helpers.d.ts +0 -28
  47. package/dist/types/bin/open.d.ts +0 -21
  48. package/dist/types/bin/session.d.ts +0 -11
package/CHANGELOG.md ADDED
@@ -0,0 +1,194 @@
1
+ # Changelog
2
+
3
+ ## [2.0.1] - 2026-03-16
4
+
5
+ ### Changed
6
+ - Updated all geo-targeting documentation and examples to use country codes (e.g., `us`, `gb`, `de`) instead of subregion codes (e.g., `us_ca`, `us_ny`).
7
+ - Clarified that geo codes are now country-level only; subregion codes are no longer shown in docs or examples.
8
+
9
+ All notable changes to `@aluvia/sdk` are documented in this file.
10
+
11
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
12
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
13
+
14
+ ## [2.0.0] - 2026-02-20
15
+
16
+ ### Removed
17
+ - CLI extracted to separate package `@aluvia/cli`. Subpath `@aluvia/sdk/cli` has been removed. For CLI commands use `npm install -g @aluvia/cli` (run `aluvia session start`, etc.). For programmatic use (e.g. MCP), import from `@aluvia/cli`.
18
+
19
+ ## [1.4.1] - 2026-02-17
20
+
21
+ ### Fixed
22
+ - Fix CLI hanging indefinitely on `session start` due to unresolved Promise in `handleOpen`.
23
+ - Fix reliability issue when spawning daemon process by resolving CLI path absolutely (replaces brittle `process.argv[1]` usage).
24
+
25
+ ## [1.3.0] - 2026-02-13
26
+
27
+ ### Added
28
+ - `--auto-unblock` CLI flag to enable automatic block detection and page reload through Aluvia proxy.
29
+ - Multi-session CLI support. Multiple browser sessions can now run in parallel, each with an auto-generated name (e.g. `swift-falcon`, `calm-river`). Use `--browser-session <name>` to specify a custom name.
30
+ - Full CLI command surface for agent workflows: `session start`, `session close`, `session list`, `session get`, `session rotate-ip`, `session set-geo`, `session set-rules`, `account`, `account usage`, `geos`, `help`.
31
+ - `--all` flag on `session close` command to stop all sessions at once.
32
+ - `--run <script>` option on `session start` to execute a script with `page`, `browser`, `context` injected as globals.
33
+ - `connect()` helper for AI agents to attach to running browser sessions via CDP.
34
+ - `--help` / `-h` flag support at all command levels.
35
+
36
+ ### Changed
37
+ - Overhaul website block detection with weighted scoring system. Replaces binary keyword/status matching with probabilistic signal combination across 8 detector types (HTTP status, WAF headers, title keywords, challenge selectors, visible text, text-to-HTML ratio, redirect chains, meta refresh). Adds two-pass analysis (fast pass at `domcontentloaded`, full pass after `networkidle`), SPA navigation detection, word-boundary matching to prevent false positives, and hostname-level persistent block escalation. Detection results now include `blockStatus` (`blocked`/`suspected`/`clear`), `score`, and `signals` array.
38
+ - `onDetection` callback now fires on every page analysis, including `clear` results. Previously only fired for `blocked` and `suspected` results.
39
+ - Add `autoUnblock` option to `BlockDetectionConfig` (default: `false`). Set to `true` to automatically add blocked hostnames to routing rules and reload the page. When `false` (the default), detection-only mode lets agents receive scores via `onDetection` and decide how to respond.
40
+ - Rename `pageLoadDetection` option to `blockDetection` and `PageLoadDetectionConfig`/`PageLoadDetectionResult` types to `BlockDetectionConfig`/`BlockDetectionResult` for clarity.
41
+ - Restructure CLI: replace `open`/`close`/`status` with `session start`/`session close`/`session list`/`session get` and add `session rotate-ip`, `session set-geo`, `session set-rules` subcommands.
42
+ - Lock files are now per-session (`cli-<name>.lock`) instead of a single `cli.lock`.
43
+ - `session close` now returns exit code 1 when no sessions are found.
44
+ - `session set-rules` now deduplicates rules on append and errors when both positional rules and `--remove` are specified.
45
+
46
+ ### Fixed
47
+ - Fix control-flow bug in `close` command where missing `return` before `output()` calls caused fall-through execution, potentially sending SIGTERM to undefined PIDs.
48
+ - Fix `handleOpen` crash when `spawn` throws (e.g. invalid executable path).
49
+ - Fix invalid session names causing a 60-second timeout instead of an immediate error.
50
+ - Fix `connect()` error messages referencing removed `open` and `status` commands.
51
+ - Fix `--connection-id` validation missing in daemon argument parser.
52
+
53
+ ### Removed
54
+ - Remove gateway mode (`localProxy: false`). The SDK now always runs a local proxy on `127.0.0.1`. The `localProxy` option has been removed from `AluviaClientOptions`.
55
+
56
+ ## [1.2.0] - 2026-02-11
57
+
58
+ ### Added
59
+ - Auto reload a page on block detection. See [docs](https://docs.aluvia.io/aluvia-client/auto-unblock) for details.
60
+ - CLI for managing browser sessions: `npx @aluvia/sdk session start <url>` and `npx @aluvia/sdk session close`.
61
+ - Daemon mode: browser runs as a detached background process that survives terminal close.
62
+ - CDP (Chrome DevTools Protocol) endpoint exposed via `--remote-debugging-port`, enabling external tools to connect with `connectOverCDP()` and share browser contexts/pages.
63
+ - `cdpUrl` field on `AluviaClientConnection` for programmatic CDP access.
64
+ - `headless` option on `AluviaClientOptions` (default: `true`). CLI flag `--headful` to launch a visible browser.
65
+ - `--connection-id <id>` flag on CLI `session start` command to reuse an existing connection.
66
+ - Lock file (`/tmp/aluvia-sdk/cli-<name>.lock`) for per-session state persistence with full session metadata.
67
+ - JSON output by default on all CLI commands for AI agent consumption.
68
+ - `help` command with plain-text output.
69
+
70
+ ### Changed
71
+ - Playwright browser launch uses `chromium.launch()` with `--remote-debugging-port` instead of `chromium.launchServer()` + `connect()`, enabling shared browser state across CDP connections.
72
+
73
+
74
+ ## [1.1.0] - 2026-01-26
75
+
76
+ ### Added
77
+ - Option for the client to launch Playwright browser instances directly with built-in proxy settings.
78
+
79
+
80
+ ## [1.0.0] - 2025-01-12
81
+
82
+ ### Added
83
+ - Initial release of `@aluvia/sdk`
84
+ - `AluviaClient` — main entry point for SDK
85
+ - Client proxy mode (default) — local proxy on `127.0.0.1`
86
+ - Gateway mode — direct gateway proxy settings
87
+ - `connection.asPlaywright()` — Playwright proxy configuration
88
+ - `connection.asPuppeteer()` — Puppeteer proxy arguments
89
+ - `connection.asSelenium()` — Selenium proxy arguments
90
+ - `connection.asAxiosConfig()` — Axios HTTP client configuration
91
+ - `connection.asGotOptions()` — Got HTTP client configuration
92
+ - `connection.asNodeAgents()` — Node.js HTTP/HTTPS agents
93
+ - `connection.asUndiciDispatcher()` — Undici dispatcher
94
+ - `connection.asUndiciFetch()` — Fetch function via Undici
95
+ - `client.updateRules()` — update routing rules at runtime
96
+ - `client.updateSessionId()` — update upstream session
97
+ - `client.updateTargetGeo()` — update geo targeting
98
+ - `AluviaApi` — typed wrapper for Aluvia REST API
99
+ - Hostname-based routing rules with wildcard support
100
+ - ETag-based config polling for live updates
101
+ - Error classes: `MissingApiKeyError`, `InvalidApiKeyError`, `ApiError`, `ProxyStartError`
102
+
103
+ ---
104
+
105
+ ## Changelog Policy
106
+
107
+ ### When to Update
108
+
109
+ Update this changelog for **every release**. Add entries to `[Unreleased]` during development.
110
+
111
+ ### Categories
112
+
113
+ Use these categories (in order):
114
+
115
+ | Category | Description |
116
+ |----------|-------------|
117
+ | **Added** | New features |
118
+ | **Changed** | Changes to existing functionality |
119
+ | **Deprecated** | Features that will be removed |
120
+ | **Removed** | Features that were removed |
121
+ | **Fixed** | Bug fixes |
122
+ | **Security** | Security vulnerability fixes |
123
+
124
+ ### Entry Format
125
+
126
+ Each entry should:
127
+ - Start with a verb (Add, Fix, Change, Remove, etc.)
128
+ - Be concise but descriptive
129
+ - Reference issues/PRs when relevant
130
+
131
+ **Good:**
132
+ ```markdown
133
+ - Add `updateTargetGeo()` method for geo targeting (#42)
134
+ - Fix hostname extraction for origin-form URLs
135
+ - Change default poll interval from 10s to 5s
136
+ ```
137
+
138
+ **Bad:**
139
+ ```markdown
140
+ - updateTargetGeo
141
+ - Fixed bug
142
+ - Changes
143
+ ```
144
+
145
+ ### Release Process
146
+
147
+ 1. Move entries from `[Unreleased]` to new version section
148
+ 2. Add release date
149
+ 3. Commit changelog with version bump
150
+ 4. Tag release
151
+
152
+ ### Conventional Commits
153
+
154
+ We use Conventional Commits for commit messages. The changelog can be auto-generated from commits:
155
+
156
+ ```bash
157
+ # Install standard-version (optional)
158
+ npm install -D standard-version
159
+
160
+ # Generate changelog from commits
161
+ npx standard-version
162
+ ```
163
+
164
+ Commit types map to changelog categories:
165
+
166
+ | Commit Type | Changelog Category |
167
+ |-------------|-------------------|
168
+ | `feat:` | Added |
169
+ | `fix:` | Fixed |
170
+ | `perf:` | Changed |
171
+ | `refactor:` | Changed |
172
+ | `docs:` | (usually not included) |
173
+ | `chore:` | (usually not included) |
174
+ | `BREAKING CHANGE:` | Changed (major version) |
175
+
176
+ ### Version Links
177
+
178
+ At the bottom of the file, add comparison links:
179
+
180
+ ```markdown
181
+ [Unreleased]: https://github.com/aluvia-connect/sdk-node/compare/v1.0.0...HEAD
182
+ [1.0.0]: https://github.com/aluvia-connect/sdk-node/releases/tag/v1.0.0
183
+ ```
184
+
185
+ ---
186
+
187
+ [Unreleased]: https://github.com/aluvia-connect/sdk-node/compare/v2.0.0...HEAD
188
+ [2.0.0]: https://github.com/aluvia-connect/sdk-node/compare/v1.4.1...v2.0.0
189
+ [1.4.1]: https://github.com/aluvia-connect/sdk-node/compare/v1.4.0...v1.4.1
190
+ [1.4.0]: https://github.com/aluvia-connect/sdk-node/compare/v1.3.0...v1.4.0
191
+ [1.3.0]: https://github.com/aluvia-connect/sdk-node/compare/v1.2.0...v1.3.0
192
+ [1.2.0]: https://github.com/aluvia-connect/sdk-node/compare/v1.1.0...v1.2.0
193
+ [1.1.0]: https://github.com/aluvia-connect/sdk-node/compare/v1.0.0...v1.1.0
194
+ [1.0.0]: https://github.com/aluvia-connect/sdk-node/releases/tag/v1.0.0