pi-lean-portal 0.3.3 → 0.4.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 +20 -45
- package/browser-toggle.ts +10 -101
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -115,17 +115,10 @@ toggles guide-saving mode, and manages browser profiles.
|
|
|
115
115
|
### Persistence
|
|
116
116
|
|
|
117
117
|
The toggle state is stored in the conversation's branch history. A fresh
|
|
118
|
-
conversation starts with the default from `settings.json`
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
> replaced by the `pi-tool-masking` library's `toolsetDefaults` block in an
|
|
123
|
-
> upcoming release — **that block is not read yet**, so keep the legacy key
|
|
124
|
-
> until the replacement ships. See
|
|
125
|
-
> [Configuration (`settings.json`)](#configuration-settingsjson) for the
|
|
126
|
-
> future shape and how to pre-add it harmlessly. A migration warning fires on
|
|
127
|
-
> session start once the legacy key is present and the web default hasn't yet
|
|
128
|
-
> been mirrored into `toolsetDefaults`.
|
|
118
|
+
conversation starts with the default from `settings.json` — the
|
|
119
|
+
`pi-tool-masking` library's `toolsetDefaults` block (see
|
|
120
|
+
[Configuration (`settings.json`)](#configuration-settingsjson)), falling back
|
|
121
|
+
to the toolset's packaged default (`true` for `web`).
|
|
129
122
|
|
|
130
123
|
---
|
|
131
124
|
|
|
@@ -615,48 +608,30 @@ a `profile` parameter:
|
|
|
615
608
|
}
|
|
616
609
|
```
|
|
617
610
|
|
|
618
|
-
### `
|
|
611
|
+
### `toolsetDefaults` *(settings-based toolset defaults)*
|
|
619
612
|
|
|
620
|
-
Whether browser tools are enabled on fresh conversations.
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
**that block is not read yet**, so keep this key until the replacement ships.
|
|
613
|
+
Whether browser tools are enabled on fresh conversations. Read by the
|
|
614
|
+
`pi-tool-masking` library at restore time, between the chat-branch tier and
|
|
615
|
+
the toolset's packaged default:
|
|
624
616
|
|
|
625
617
|
```jsonc
|
|
626
618
|
{
|
|
627
|
-
"
|
|
628
|
-
"
|
|
619
|
+
"toolsetDefaults": {
|
|
620
|
+
"toolset-state:pi-lean-dimension.web": { "enabled": true },
|
|
621
|
+
"toolset-state:pi-lean-dimension.web-learn": { "enabled": false },
|
|
622
|
+
"toolset-state:pi-lean-dimension.search": { "enabled": true }
|
|
629
623
|
}
|
|
630
624
|
}
|
|
631
625
|
```
|
|
632
626
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
>
|
|
639
|
-
>
|
|
640
|
-
>
|
|
641
|
-
> {
|
|
642
|
-
> "browserToggle": { "defaultEnabled": true },
|
|
643
|
-
> "toolsetDefaults": {
|
|
644
|
-
> "toolset-state:pi-lean-dimension.web": { "enabled": true },
|
|
645
|
-
> "toolset-state:pi-lean-dimension.web-learn": { "enabled": false },
|
|
646
|
-
> "toolset-state:pi-lean-dimension.search": { "enabled": true }
|
|
647
|
-
> }
|
|
648
|
-
> }
|
|
649
|
-
> ```
|
|
650
|
-
>
|
|
651
|
-
> - Keys are the toolsets' `persistKey` values (`toolset-state:<id>`).
|
|
652
|
-
> - Omit a `toolsetDefaults` key to use the toolset's packaged default (`web`
|
|
653
|
-
> and `search` default `true`; `web-learn` defaults `false`).
|
|
654
|
-
> - The `search` key only applies when `pi-lean-search` is installed.
|
|
655
|
-
>
|
|
656
|
-
> Once the offload ships and the legacy read is removed, delete the
|
|
657
|
-
> `browserToggle` block. Until then, a migration warning fires on session
|
|
658
|
-
> start when the legacy key is present and the web default hasn't yet been
|
|
659
|
-
> mirrored into `toolsetDefaults`; mirroring it suppresses the warning.
|
|
627
|
+
- Keys are the toolsets' `persistKey` values (`toolset-state:<id>`).
|
|
628
|
+
- Omit a `toolsetDefaults` key to use the toolset's packaged default (`web`
|
|
629
|
+
and `search` default `true`; `web-learn` defaults `false`).
|
|
630
|
+
- The `search` key only applies when `pi-lean-search` is installed.
|
|
631
|
+
|
|
632
|
+
> The legacy `browserToggle.defaultEnabled` key is **removed in 0.4.0** — it
|
|
633
|
+
> is no longer read. If you pinned it, move the value into the matching
|
|
634
|
+
> `toolsetDefaults` entry above.
|
|
660
635
|
|
|
661
636
|
### `browser.maxStorageStateSize`
|
|
662
637
|
|
package/browser-toggle.ts
CHANGED
|
@@ -9,24 +9,12 @@ import {
|
|
|
9
9
|
getDefaultResolutionMode,
|
|
10
10
|
} from "pi-tool-masking";
|
|
11
11
|
import type { ToolsetSpec } from "pi-tool-masking";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// ships in pi-tool-masking 1.2.0), so the string cast is load-bearing: an
|
|
17
|
-
// allowlist-capable consumer sharing the `globalThis` module state writes
|
|
18
|
-
// `"allowlist"` into it, and this consumer reads that value back at runtime
|
|
19
|
-
// even though its own bundled type doesn't name the mode. On published
|
|
20
|
-
// versions no caller ever writes `"allowlist"`, so this is a no-op for
|
|
21
|
-
// ordinary users — it only activates when an allowlist-capable
|
|
22
|
-
// pi-tool-masking consumer is in play.
|
|
23
|
-
//
|
|
24
|
-
// Cleanup at the ^1.2.0 bump: once `DefaultResolutionMode` names
|
|
25
|
-
// `"allowlist"`, drop the `as string` cast here and in pi-lean-search's
|
|
26
|
-
// co-activation mirror — the type system can then check the comparison
|
|
27
|
-
// directly and the cast becomes a suppressor of a check it should perform.
|
|
12
|
+
|
|
13
|
+
// Focus-mode guard: refuse actuating subcommands while the library holds the
|
|
14
|
+
// line — inclusion mode or allowlist focus (an upstream pi-tool-masking
|
|
15
|
+
// consumer).
|
|
28
16
|
function isFocusHolding(): boolean {
|
|
29
|
-
const mode = getDefaultResolutionMode()
|
|
17
|
+
const mode = getDefaultResolutionMode();
|
|
30
18
|
return mode === "inclusion" || mode === "allowlist";
|
|
31
19
|
}
|
|
32
20
|
|
|
@@ -154,86 +142,13 @@ function renderBrowserGlyph(
|
|
|
154
142
|
}
|
|
155
143
|
}
|
|
156
144
|
|
|
157
|
-
// ---- Legacy settings migration warning ---------------------------
|
|
158
|
-
//
|
|
159
|
-
// The portal currently seeds the web toolset's fresh-session default from
|
|
160
|
-
// `browserToggle.defaultEnabled` in settings.json. An upcoming pi-tool-masking
|
|
161
|
-
// release takes over settings-based toolset defaults and reads a new
|
|
162
|
-
// `toolsetDefaults` block instead. Warn users who pinned the legacy key so
|
|
163
|
-
// they can migrate before the offload lands and the legacy read is removed.
|
|
164
|
-
//
|
|
165
|
-
// ponytail: warn-only — we still honor the legacy key for backward compat
|
|
166
|
-
// until pi-tool-masking owns the settings tier; then delete this helper and
|
|
167
|
-
// the `browserToggle` read below. Ceiling: a silent default shift for users
|
|
168
|
-
// who ignore the warning; upgrade path is the pi-tool-masking bump.
|
|
169
|
-
const TOOLSET_DEFAULTS_MIGRATION_MSG =
|
|
170
|
-
"⚠️ pi-lean-portal: settings-based toolset defaults are moving to the " +
|
|
171
|
-
"pi-tool-masking library. The `browserToggle.defaultEnabled` key in your " +
|
|
172
|
-
"settings.json will stop being read in an upcoming release. It still works " +
|
|
173
|
-
"today — KEEP it until the replacement ships, and add the new " +
|
|
174
|
-
"`toolsetDefaults` block alongside it so your config is ready (the new " +
|
|
175
|
-
"block is not read yet, but is harmless now and will take effect " +
|
|
176
|
-
"automatically once the offload lands):\n\n" +
|
|
177
|
-
"{\n" +
|
|
178
|
-
' "browserToggle": { "defaultEnabled": true },\n' +
|
|
179
|
-
' "toolsetDefaults": {\n' +
|
|
180
|
-
' "toolset-state:pi-lean-dimension.web": { "enabled": true },\n' +
|
|
181
|
-
' "toolset-state:pi-lean-dimension.web-learn": { "enabled": true },\n' +
|
|
182
|
-
' "toolset-state:pi-lean-dimension.search": { "enabled": true }\n' +
|
|
183
|
-
" }\n" +
|
|
184
|
-
"}\n" +
|
|
185
|
-
"(omit a `toolsetDefaults` key to use the toolset's packaged default; the " +
|
|
186
|
-
"`search` key only applies when pi-lean-search is installed). Mirror your " +
|
|
187
|
-
"web default into `toolset-state:pi-lean-dimension.web` to silence this " +
|
|
188
|
-
"warning.";
|
|
189
|
-
|
|
190
|
-
function hasLegacyToolsetDefault(merged: Record<string, unknown>): boolean {
|
|
191
|
-
const seg = merged["browserToggle"];
|
|
192
|
-
if (!seg || typeof seg !== "object" || Array.isArray(seg)) return false;
|
|
193
|
-
return (
|
|
194
|
-
typeof (seg as Record<string, unknown>)["defaultEnabled"] === "boolean"
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// The new `toolsetDefaults` block the pi-tool-masking offload will read.
|
|
199
|
-
// When the user has already migrated the web toolset's default into it,
|
|
200
|
-
// the warning is redundant even if the legacy `browserToggle.defaultEnabled`
|
|
201
|
-
// key is still sitting on disk — suppress so a migrated settings file stays
|
|
202
|
-
// quiet. Only the web persist key gates this: it's the one the legacy key
|
|
203
|
-
// controlled, so its presence means the user acted on the migration.
|
|
204
|
-
const WEB_TOOLSET_PERSIST_KEY = "toolset-state:pi-lean-dimension.web";
|
|
205
|
-
function hasMigratedToolsetDefault(merged: Record<string, unknown>): boolean {
|
|
206
|
-
const td = merged["toolsetDefaults"];
|
|
207
|
-
if (!td || typeof td !== "object" || Array.isArray(td)) return false;
|
|
208
|
-
const entry = (td as Record<string, unknown>)[WEB_TOOLSET_PERSIST_KEY];
|
|
209
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return false;
|
|
210
|
-
return typeof (entry as Record<string, unknown>)["enabled"] === "boolean";
|
|
211
|
-
}
|
|
212
|
-
|
|
213
145
|
// ---- Toggle initializer ------------------------------------------
|
|
214
146
|
|
|
215
147
|
export default function initBrowserToggle(pi: ExtensionAPI) {
|
|
216
|
-
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
// key is dead weight — no need to nag.
|
|
221
|
-
const legacyDefaultPinned =
|
|
222
|
-
hasLegacyToolsetDefault(merged) && !hasMigratedToolsetDefault(merged);
|
|
223
|
-
const browserToggleSegment = (merged as Record<string, unknown>)[
|
|
224
|
-
"browserToggle"
|
|
225
|
-
] as Record<string, unknown> | undefined;
|
|
226
|
-
const webDefault =
|
|
227
|
-
browserToggleSegment &&
|
|
228
|
-
typeof browserToggleSegment["defaultEnabled"] === "boolean"
|
|
229
|
-
? (browserToggleSegment["defaultEnabled"] as boolean)
|
|
230
|
-
: true;
|
|
231
|
-
|
|
232
|
-
const webSpec: ToolsetSpec = {
|
|
233
|
-
...PORTAL_WEB_SPEC,
|
|
234
|
-
defaultEnabled: webDefault,
|
|
235
|
-
};
|
|
236
|
-
const webToolset = defineToolset(pi, webSpec);
|
|
148
|
+
// Settings-based toolset defaults (`toolsetDefaults` tier) are read by
|
|
149
|
+
// pi-tool-masking itself inside defineToolset/restore — pass the packaged
|
|
150
|
+
// spec straight through.
|
|
151
|
+
const webToolset = defineToolset(pi, PORTAL_WEB_SPEC);
|
|
237
152
|
const learnToolset = defineToolset(pi, PORTAL_LEARN_SPEC);
|
|
238
153
|
|
|
239
154
|
// ── Keep cached state in sync with library events ─────────
|
|
@@ -267,8 +182,7 @@ export default function initBrowserToggle(pi: ExtensionAPI) {
|
|
|
267
182
|
// unguarded, matching the focus controller's treatment of its own
|
|
268
183
|
// read-only commands.
|
|
269
184
|
if (["on", "off", "learn"].includes(cmd) && isFocusHolding()) {
|
|
270
|
-
const inInclusion =
|
|
271
|
-
(getDefaultResolutionMode() as string) === "inclusion";
|
|
185
|
+
const inInclusion = getDefaultResolutionMode() === "inclusion";
|
|
272
186
|
ctx.ui.notify(
|
|
273
187
|
inInclusion
|
|
274
188
|
? "Another plugin has active inclusion mode — this toolset can't be toggled while inclusion is holding the line. Deactivate it there first."
|
|
@@ -348,11 +262,6 @@ export default function initBrowserToggle(pi: ExtensionAPI) {
|
|
|
348
262
|
restoreProfile(pi, ctx);
|
|
349
263
|
_lastCtx = ctx;
|
|
350
264
|
syncCachedState();
|
|
351
|
-
// One-time-per-session migration warning when the legacy
|
|
352
|
-
// `browserToggle.defaultEnabled` pin is still on disk.
|
|
353
|
-
if (legacyDefaultPinned) {
|
|
354
|
-
ctx.ui.notify(TOOLSET_DEFAULTS_MIGRATION_MSG, "warning");
|
|
355
|
-
}
|
|
356
265
|
});
|
|
357
266
|
|
|
358
267
|
pi.on("session_tree", async (_event, ctx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-lean-portal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Pi extension. Interactive web browsing for Pi — a /web toggle removes the tools from context when switched off, Playwright Chromium/Firefox deliver accessibility-tree snapshots, persistent profiles, cookies, and domain-matched guides; custom/stealth backends (Camoufox) plug in when a site blocks the shipped browsers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"node-html-parser": "^6.1.0",
|
|
59
|
-
"pi-tool-masking": "^1.
|
|
59
|
+
"pi-tool-masking": "^1.2.0",
|
|
60
60
|
"playwright": "^1.60.0",
|
|
61
61
|
"turndown": "^7.2.0"
|
|
62
62
|
},
|