pi-lean-portal 0.2.4 → 0.3.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/README.md +35 -7
- package/backends/playwright-base/playwright-plugin.ts +1 -1
- package/backends/python-adapter.ts +3 -3
- package/backends/python-base/pi_browser_bridge/__init__.py +2 -4
- package/backends/python-base/pi_browser_bridge/playwright_base.py +572 -81
- package/browser-profile.ts +2 -3
- package/browser-toggle.ts +168 -385
- package/core/fetch-backend.ts +10 -30
- package/core/guides.ts +14 -18
- package/core/router.ts +2 -20
- package/core/shared/bot-detection.ts +19 -30
- package/core/shared/browser-data.ts +4 -4
- package/core/shared/nav-settle.ts +2 -2
- package/core/shared/paths.ts +16 -2
- package/core/shared/settings-reader.ts +2 -7
- package/core/shared/snapshot-cache.ts +1 -1
- package/index.ts +8 -1
- package/package.json +2 -1
- package/tools/web-learn.ts +1 -4
- package/backends/python-base/pi_browser_bridge/bridge.py +0 -525
- package/core/shared/url-safety.ts +0 -164
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ The browser tools are **enabled by default**. You can:
|
|
|
61
61
|
|
|
62
62
|
## Extending it
|
|
63
63
|
|
|
64
|
-
Beyond the toggle,
|
|
64
|
+
Beyond the toggle, three surfaces are extensible or shared rather than hardcoded:
|
|
65
65
|
|
|
66
66
|
- **Navigation guides** — `web-learn` saves site-specific playbooks that
|
|
67
67
|
auto-match by domain and resurface in later sessions. See
|
|
@@ -71,6 +71,14 @@ Beyond the toggle, two surfaces are user-extensible rather than hardcoded:
|
|
|
71
71
|
and drive a patched engine like [Camoufox](https://github.com/daijro/camoufox)
|
|
72
72
|
yourself. The full flow lives in [Backend Architecture](#backend-architecture)
|
|
73
73
|
and [`contributed/README.md`](./contributed/README.md).
|
|
74
|
+
- **Toolset toggles** — the `/web` toggle is powered by the shared
|
|
75
|
+
[`pi-tool-masking`](https://github.com/coreyryanhanson/pi-tool-masking/) peer dep,
|
|
76
|
+
which handles active-set masking, sibling-tool union math, and the
|
|
77
|
+
`TOOLSET_EVENTS` protocol that keeps the `browser`/`search` status-bar
|
|
78
|
+
glyphs in sync across extensions. It's published as a general toggle
|
|
79
|
+
mechanism — any extension that hides/shows its own tools can build on the
|
|
80
|
+
same scheme so masking and glyph events stay consistent across the whole
|
|
81
|
+
agent, rather than each toggle reinventing its own.
|
|
74
82
|
|
|
75
83
|
---
|
|
76
84
|
|
|
@@ -265,6 +273,28 @@ HTML to Markdown. It does **not** create a browser session.
|
|
|
265
273
|
| `pagination` | On-demand | Next buttons, infinite scroll, pages |
|
|
266
274
|
| `search` | On-demand | Search boxes, comboboxes, result lists |
|
|
267
275
|
|
|
276
|
+
### Overriding Built-in Guides
|
|
277
|
+
|
|
278
|
+
A same-named `.md` file in `~/.pi/agent/pi-lean-portal/web-guides/` (e.g.
|
|
279
|
+
`bot-detection.md`) **shadows the builtin entirely** — the whole guide is
|
|
280
|
+
replaced, not field-merged. To keep a pattern guide firing, include
|
|
281
|
+
`trigger.signal: botDetected` (or `dialogDetected`) in the frontmatter;
|
|
282
|
+
omitting it disables the trigger.
|
|
283
|
+
|
|
284
|
+
```yaml
|
|
285
|
+
---
|
|
286
|
+
category: pattern
|
|
287
|
+
trigger.signal: botDetected
|
|
288
|
+
icon: 🤖
|
|
289
|
+
shortName: my bot guide
|
|
290
|
+
---
|
|
291
|
+
Custom guidance text for bot challenges.
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Site guides and pattern guides live in **disjoint namespaces** — a site guide
|
|
295
|
+
for `www.botdetection.com` does not collide with the `bot-detection` pattern
|
|
296
|
+
guide; both fire when applicable.
|
|
297
|
+
|
|
268
298
|
### Viewing Guides
|
|
269
299
|
|
|
270
300
|
```text
|
|
@@ -661,12 +691,10 @@ When creating navigation guides with `web-learn`:
|
|
|
661
691
|
|
|
662
692
|
### Security
|
|
663
693
|
|
|
664
|
-
- URLs are
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
`javascript:`, `vbscript:`
|
|
669
|
-
- Secrets in URLs are detected heuristically
|
|
694
|
+
- URLs are parsed with `new URL()` as input validation — malformed
|
|
695
|
+
URLs are rejected, but no SSRF boundary is enforced (a coding agent
|
|
696
|
+
already has filesystem and shell access, so blocking localhost or
|
|
697
|
+
private IPs would be theater)
|
|
670
698
|
- Profile state is stored with restricted file permissions (0700 dirs,
|
|
671
699
|
0600 files)
|
|
672
700
|
|
|
@@ -491,7 +491,7 @@ export abstract class PlaywrightPluginBase implements BrowserPlugin {
|
|
|
491
491
|
);
|
|
492
492
|
// checkPage handles all three: title (challenge phrases),
|
|
493
493
|
// body (challenge phrases + CDN patterns), and HTML (CAPTCHA embeds).
|
|
494
|
-
return checkPage(title, bodyText, html)
|
|
494
|
+
return checkPage(title, bodyText, html);
|
|
495
495
|
} catch {
|
|
496
496
|
return false;
|
|
497
497
|
}
|
|
@@ -148,7 +148,7 @@ export interface QuirksDescriptor extends ResultBase {
|
|
|
148
148
|
// ─── PythonPluginAdapter ──────────────────────────────────────────────
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
|
-
* Adapts a Python browser backend (running the `
|
|
151
|
+
* Adapts a Python browser backend (running the `PlaywrightBridge` protocol)
|
|
152
152
|
* to the TypeScript `BrowserPlugin` interface.
|
|
153
153
|
*/
|
|
154
154
|
export class PythonPluginAdapter implements BrowserPlugin {
|
|
@@ -322,7 +322,7 @@ export class PythonPluginAdapter implements BrowserPlugin {
|
|
|
322
322
|
env: {
|
|
323
323
|
...process.env,
|
|
324
324
|
PYTHONUNBUFFERED: "1",
|
|
325
|
-
//
|
|
325
|
+
// Make the shared `pi_browser_bridge` library
|
|
326
326
|
// importable from any venv the user points `pythonPath`
|
|
327
327
|
// at, without requiring a `pip install` of the bridge.
|
|
328
328
|
// Appended to any existing PYTHONPATH so user entries keep
|
|
@@ -418,7 +418,7 @@ export class PythonPluginAdapter implements BrowserPlugin {
|
|
|
418
418
|
try {
|
|
419
419
|
await this._directRpcCall("ping", {}, PING_TIMEOUT_MS);
|
|
420
420
|
|
|
421
|
-
// ── Forward plugin config to the bridge
|
|
421
|
+
// ── Forward plugin config to the bridge ──
|
|
422
422
|
// Sent exactly once, immediately after the ping handshake and
|
|
423
423
|
// before any other RPC, so stealth subclasses can read launch
|
|
424
424
|
// options from `self.plugin_config.get("launch", {})` at
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"""
|
|
2
2
|
pi_browser_bridge — Shared Python bridge library for pi-lean-portal.
|
|
3
|
-
Provides
|
|
3
|
+
Provides PlaywrightBridge base class for Python browser backends.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from .
|
|
7
|
-
from .playwright_base import PlaywrightBridge
|
|
6
|
+
from .playwright_base import PlaywrightBridge, SessionNotFoundError, InvalidParamsError
|
|
8
7
|
from .accessibility import (
|
|
9
8
|
AriaCachedNode,
|
|
10
9
|
AriaParseResult,
|
|
@@ -16,7 +15,6 @@ from .accessibility import (
|
|
|
16
15
|
from .bot_detection import check_bot_detection
|
|
17
16
|
|
|
18
17
|
__all__ = [
|
|
19
|
-
"BrowserBridge",
|
|
20
18
|
"PlaywrightBridge",
|
|
21
19
|
"SessionNotFoundError",
|
|
22
20
|
"InvalidParamsError",
|