@lincoln504/pi-research 1.7.21 → 1.7.23
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/agent-skill/pi-research/SKILL.md +1 -1
- package/dist/cli.mjs +399 -163
- package/dist/thread-worker.mjs +77 -31
- package/docs/CHANGELOG.md +46 -0
- package/docs/CONFIGURATION.md +8 -3
- package/docs/THIRD-PARTY-NOTICES.md +29 -13
- package/docs/TROUBLESHOOTING.md +16 -0
- package/package.json +12 -9
- package/scripts/ddg-socks-proxy.mjs +279 -0
- package/scripts/lib/npm-cmd.cjs +66 -0
- package/scripts/lib/private-addresses.mjs +143 -0
- package/src/config.ts +75 -2
- package/src/core/interfaces/steering-interfaces.ts +11 -0
- package/src/core/llm/coordinator-model.ts +104 -0
- package/src/core/planning-service.ts +24 -0
- package/src/index.ts +7 -1
- package/src/infrastructure/browser/proxy-prefs.ts +124 -0
- package/src/infrastructure/browser/thread-worker-browser.ts +5 -21
- package/src/infrastructure/browser/thread-worker-messaging.ts +9 -4
- package/src/infrastructure/browser/thread-worker.mjs +77 -31
- package/src/knowledge/embedder-utils.ts +1 -1
- package/src/knowledge/sql-utils.ts +15 -0
- package/src/knowledge/store-operations.ts +3 -2
- package/src/knowledge/store.ts +15 -14
- package/src/orchestration/deep-research-orchestrator.ts +71 -2
- package/src/orchestration/research-synthesis-service.ts +14 -1
- package/src/orchestration/researcher-executor.ts +33 -33
- package/src/orchestration/session-state.ts +155 -7
- package/src/tools/read-guard.ts +23 -4
- package/src/tui/tui-controller.ts +25 -1
- package/src/utils/provider-errors.ts +149 -0
- package/src/web-research/retry-utils.ts +22 -3
package/dist/thread-worker.mjs
CHANGED
|
@@ -891,7 +891,7 @@ var init_stdio_capture = __esm({
|
|
|
891
891
|
});
|
|
892
892
|
|
|
893
893
|
// src/logger.ts
|
|
894
|
-
import { appendFileSync, existsSync as
|
|
894
|
+
import { appendFileSync, existsSync as existsSync3, mkdirSync, openSync as openSync2, closeSync as closeSync2 } from "node:fs";
|
|
895
895
|
import { appendFile as appendFile2 } from "node:fs/promises";
|
|
896
896
|
import { AsyncLocalStorage as AsyncLocalStorage3 } from "node:async_hooks";
|
|
897
897
|
import * as path3 from "node:path";
|
|
@@ -1047,7 +1047,7 @@ var init_logger = __esm({
|
|
|
1047
1047
|
this.rotation = new LogRotation(this);
|
|
1048
1048
|
this.diskSpaceChecker = new DiskSpaceChecker();
|
|
1049
1049
|
try {
|
|
1050
|
-
if (!
|
|
1050
|
+
if (!existsSync3(this.logDir)) {
|
|
1051
1051
|
mkdirSync(this.logDir, { recursive: true, mode: 448 });
|
|
1052
1052
|
}
|
|
1053
1053
|
try {
|
|
@@ -1721,8 +1721,8 @@ async function disposeSsrfSafeFetcher() {
|
|
|
1721
1721
|
const pending = cachedSsrfFetcher;
|
|
1722
1722
|
cachedSsrfFetcher = void 0;
|
|
1723
1723
|
if (pending === void 0) return;
|
|
1724
|
-
const
|
|
1725
|
-
const closable =
|
|
1724
|
+
const cached2 = await pending.catch(() => null);
|
|
1725
|
+
const closable = cached2?.dispatcher;
|
|
1726
1726
|
if (!closable?.close) return;
|
|
1727
1727
|
try {
|
|
1728
1728
|
await closable.close();
|
|
@@ -2102,8 +2102,57 @@ function createKillHandler() {
|
|
|
2102
2102
|
|
|
2103
2103
|
// src/infrastructure/browser/thread-worker-browser.ts
|
|
2104
2104
|
import { platform as platform2 } from "node:os";
|
|
2105
|
-
|
|
2106
|
-
|
|
2105
|
+
|
|
2106
|
+
// src/infrastructure/browser/proxy-prefs.ts
|
|
2107
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2108
|
+
import { homedir } from "node:os";
|
|
2109
|
+
function proxyConfigPath() {
|
|
2110
|
+
return process.env["PI_RESEARCH_PROXY_JSON"] || `${homedir()}/.pi/research/proxy.json`;
|
|
2111
|
+
}
|
|
2112
|
+
var cached;
|
|
2113
|
+
var cachedAt = 0;
|
|
2114
|
+
var CACHE_TTL_MS = 1e4;
|
|
2115
|
+
function getSocksProxyEndpoint() {
|
|
2116
|
+
const now = Date.now();
|
|
2117
|
+
if (cached !== void 0 && now - cachedAt < CACHE_TTL_MS) return cached;
|
|
2118
|
+
cachedAt = now;
|
|
2119
|
+
try {
|
|
2120
|
+
const file = proxyConfigPath();
|
|
2121
|
+
if (!existsSync(file)) {
|
|
2122
|
+
cached = null;
|
|
2123
|
+
return cached;
|
|
2124
|
+
}
|
|
2125
|
+
const cfg = JSON.parse(readFileSync(file, "utf8"));
|
|
2126
|
+
const host = cfg.host === void 0 ? "127.0.0.1" : typeof cfg.host === "string" ? cfg.host.trim() : "";
|
|
2127
|
+
const port = cfg.port === void 0 ? 1080 : Number.isInteger(cfg.port) ? cfg.port : -1;
|
|
2128
|
+
if (host === "" || port < 1 || port > 65535) {
|
|
2129
|
+
cached = null;
|
|
2130
|
+
return cached;
|
|
2131
|
+
}
|
|
2132
|
+
cached = { host, port };
|
|
2133
|
+
return cached;
|
|
2134
|
+
} catch {
|
|
2135
|
+
cached = null;
|
|
2136
|
+
return cached;
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
function loadSocksProxyPrefs() {
|
|
2140
|
+
const endpoint = getSocksProxyEndpoint();
|
|
2141
|
+
if (!endpoint) return {};
|
|
2142
|
+
return {
|
|
2143
|
+
"network.proxy.type": 1,
|
|
2144
|
+
"network.proxy.socks": endpoint.host,
|
|
2145
|
+
"network.proxy.socks_port": endpoint.port,
|
|
2146
|
+
"network.proxy.socks_remote_dns": true,
|
|
2147
|
+
"network.proxy.socks_version": 5,
|
|
2148
|
+
"network.proxy.no_proxies_on": ""
|
|
2149
|
+
};
|
|
2150
|
+
}
|
|
2151
|
+
function isProxyHopAddress(ip, proxy = getSocksProxyEndpoint()) {
|
|
2152
|
+
if (!proxy) return false;
|
|
2153
|
+
const addr = ip.trim().toLowerCase().replace(/^\[|\]$/g, "");
|
|
2154
|
+
return addr === "" || addr === "0.0.0.0" || addr === "::" || addr === "::0";
|
|
2155
|
+
}
|
|
2107
2156
|
|
|
2108
2157
|
// src/infrastructure/browser/thread-worker-messaging.ts
|
|
2109
2158
|
init_log_utils();
|
|
@@ -2403,8 +2452,8 @@ function getCachedSubresourceVerdict(reqUrl, validate) {
|
|
|
2403
2452
|
return Promise.resolve(e instanceof Error ? e : new Error(String(e)));
|
|
2404
2453
|
}
|
|
2405
2454
|
const now = Date.now();
|
|
2406
|
-
const
|
|
2407
|
-
if (
|
|
2455
|
+
const cached2 = subresourceDnsVerdicts.get(hostname);
|
|
2456
|
+
if (cached2 && cached2.expires > now) return cached2.verdict;
|
|
2408
2457
|
const verdict = validate(reqUrl).then(
|
|
2409
2458
|
() => null,
|
|
2410
2459
|
(e) => e instanceof Error ? e : new Error(String(e))
|
|
@@ -2565,6 +2614,7 @@ async function executeScrapeTask(_context, url, signal) {
|
|
|
2565
2614
|
const check = Promise.resolve(resp.serverAddr()).then((addr) => {
|
|
2566
2615
|
const ip = addr?.ipAddress;
|
|
2567
2616
|
if (!ip || poisonedError) return;
|
|
2617
|
+
if (isProxyHopAddress(ip)) return;
|
|
2568
2618
|
try {
|
|
2569
2619
|
validateForWorkerSync(ip.includes(":") ? `http://[${ip}]/` : `http://${ip}/`);
|
|
2570
2620
|
} catch (cause) {
|
|
@@ -2602,7 +2652,7 @@ async function executeScrapeTask(_context, url, signal) {
|
|
|
2602
2652
|
return await readPdfDownload(pendingDownload, url, page, pendingAddrChecks, () => poisonedError);
|
|
2603
2653
|
}
|
|
2604
2654
|
const serverAddr = await response?.serverAddr().catch(() => null);
|
|
2605
|
-
if (serverAddr?.ipAddress) {
|
|
2655
|
+
if (serverAddr?.ipAddress && !isProxyHopAddress(serverAddr.ipAddress)) {
|
|
2606
2656
|
const ip = serverAddr.ipAddress;
|
|
2607
2657
|
validateForWorkerSync(ip.includes(":") ? `http://[${ip}]/` : `http://${ip}/`);
|
|
2608
2658
|
}
|
|
@@ -2671,7 +2721,7 @@ async function executeScrapeTask(_context, url, signal) {
|
|
|
2671
2721
|
const jitter = process.env["PI_RESEARCH_MOCK_SCRAPE"] === "true" ? 0 : Math.floor(Math.random() * 1e3) + 500;
|
|
2672
2722
|
if (jitter > 0) await new Promise((r) => setTimeout(r, jitter));
|
|
2673
2723
|
const finalAddr = await finalMainFrameAddr;
|
|
2674
|
-
if (finalAddr?.ipAddress) {
|
|
2724
|
+
if (finalAddr?.ipAddress && !isProxyHopAddress(finalAddr.ipAddress)) {
|
|
2675
2725
|
const fip = finalAddr.ipAddress;
|
|
2676
2726
|
validateForWorkerSync(fip.includes(":") ? `http://[${fip}]/` : `http://${fip}/`);
|
|
2677
2727
|
}
|
|
@@ -2749,7 +2799,7 @@ function shouldResetBrowser(errorMsg) {
|
|
|
2749
2799
|
init_log_utils();
|
|
2750
2800
|
|
|
2751
2801
|
// src/infrastructure/browser/config.ts
|
|
2752
|
-
import { platform, homedir } from "node:os";
|
|
2802
|
+
import { platform, homedir as homedir2 } from "node:os";
|
|
2753
2803
|
|
|
2754
2804
|
// src/config.ts
|
|
2755
2805
|
init_logger();
|
|
@@ -11368,9 +11418,24 @@ var ConfigSchema = typebox_exports.Object({
|
|
|
11368
11418
|
* When set, this governs the evaluator/synthesis rounds and the researcher
|
|
11369
11419
|
* sub-agents (both deep and quick) and the knowledge synthesis background LLM.
|
|
11370
11420
|
* The initial coordinator (round 1 planning) uses the parent chat's model (ctx.model)
|
|
11371
|
-
* for prompt-cache continuity with the conversation that triggered
|
|
11421
|
+
* by DEFAULT, for prompt-cache continuity with the conversation that triggered
|
|
11422
|
+
* research; COORDINATOR_MODEL overrides that decision (see below).
|
|
11372
11423
|
*/
|
|
11373
11424
|
RESEARCH_MODEL: typebox_exports.Optional(typebox_exports.String()),
|
|
11425
|
+
/**
|
|
11426
|
+
* Which model runs the INITIAL coordinator (round-1 planning), the one call that
|
|
11427
|
+
* otherwise uses the parent chat's model (`ctx.model`) for prompt-cache continuity:
|
|
11428
|
+
* • `host` (default) — the chat's model, current behaviour.
|
|
11429
|
+
* • `research` — the RESEARCH_MODEL / researcher model, same as every later round.
|
|
11430
|
+
* • `provider/id` (or a bare id) — that model.
|
|
11431
|
+
*
|
|
11432
|
+
* Exists because the chat model is not always a good planner: a local single-seat
|
|
11433
|
+
* server (llama-swap `concurrencyLimit: 1`, 4k output) turns the coordinator call into
|
|
11434
|
+
* minutes of wall clock and can 429 the owner's own next prompt, while a hosted
|
|
11435
|
+
* research model plans the same query in seconds. The cache-lineage benefit is real
|
|
11436
|
+
* but must be opt-out-able. Unset = `host`.
|
|
11437
|
+
*/
|
|
11438
|
+
COORDINATOR_MODEL: typebox_exports.Optional(typebox_exports.String()),
|
|
11374
11439
|
/** Explicit directory for the knowledge store database (overrides default) */
|
|
11375
11440
|
KNOWLEDGE_STORE_DIR: typebox_exports.Optional(typebox_exports.String()),
|
|
11376
11441
|
/** Directory for transient browser profile data. Defaults to a disk-backed
|
|
@@ -11428,25 +11493,6 @@ var CONTEXT_CREATION_TIMEOUT_MS = 3e4;
|
|
|
11428
11493
|
var COLD_START_ALLOWANCE_MS = BROWSER_LAUNCH_TIMEOUT_MS + CONTEXT_CREATION_TIMEOUT_MS;
|
|
11429
11494
|
|
|
11430
11495
|
// src/infrastructure/browser/thread-worker-browser.ts
|
|
11431
|
-
function loadSocksProxyPrefs() {
|
|
11432
|
-
try {
|
|
11433
|
-
const p = `${homedir2()}/.pi/research/proxy.json`;
|
|
11434
|
-
if (!existsSync3(p)) return {};
|
|
11435
|
-
const cfg = JSON.parse(readFileSync(p, "utf8"));
|
|
11436
|
-
const host = cfg.host ?? "127.0.0.1";
|
|
11437
|
-
const port = cfg.port ?? 1080;
|
|
11438
|
-
return {
|
|
11439
|
-
"network.proxy.type": 1,
|
|
11440
|
-
"network.proxy.socks": host,
|
|
11441
|
-
"network.proxy.socks_port": port,
|
|
11442
|
-
"network.proxy.socks_remote_dns": true,
|
|
11443
|
-
"network.proxy.socks_version": 5,
|
|
11444
|
-
"network.proxy.no_proxies_on": ""
|
|
11445
|
-
};
|
|
11446
|
-
} catch {
|
|
11447
|
-
return {};
|
|
11448
|
-
}
|
|
11449
|
-
}
|
|
11450
11496
|
var browser = null;
|
|
11451
11497
|
var initPromise = null;
|
|
11452
11498
|
var workerId3 = "";
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,52 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.7.23] - 2026-10-26
|
|
9
|
+
|
|
10
|
+
### Security
|
|
11
|
+
|
|
12
|
+
- **The `undici` floor admits three advisories for consumers.** `package.json` declared `undici ^8.11.2` (and the `jsdom` override `^8.10.2`), and the ranges `>=8.0.0 <8.12.2` carry GHSA-xjj6-f33q-929c (unhandled error on excessive content-encodings, CVSS 7.5), GHSA-4qv8-2p9j-2685 (unbounded memory in the EventSource parser) and GHSA-f72v-6w45-q472 (SRI bypass). This repo's own lock was already at 8.12.3, but the tarball ships no lockfile and npm `overrides` do not reach consumers — a consumer's hoisted `undici` only has to Satisfy `^8.11.2`, and the scraper uses `undici`'s `fetch` against hostile servers, so the content-encoding crash is reachable there. The floor is now `^8.12.2` in both places.
|
|
13
|
+
- **`SECURITY.md` claimed `*.key` files are refused; the read guard did not refuse them.** The `DENIED_BASENAME` list had no `key` extension, so `server.key`, `private.key` and `tls.key` were readable by a researcher session — the exfiltration path the guard exists to close. The list now covers `*.key`, the `id_*_sk` key forms (`id_ecdsa_sk`, `id_rsa_sk` — the `id_*` pattern only accepted a dot suffix), `.dockerconfigjson`, and the `.terraform` directory (credential directory, now in `DENIED_SEGMENTS`). Tests: `test/unit/tools/read-guard.test.ts`.
|
|
14
|
+
- **The standalone SOCKS proxy's IPv6 guard had drifted from the TS classifier.** `scripts/lib/private-addresses.mjs` claims to mirror `isPrivateIpv6` in `src/web-research/scraper-utils.ts`, but was missing the IPv4-tunneling ranges: site-local `fec0::/10`, 6to4 `2002::/16`, Teredo `2001:0::/32` and NAT64 `64:ff9b::/96` — literals like `64:ff9b::a9fe:a9fe` (the cloud-metadata address via NAT64) passed the guard. With the proxy the only SSRF backstop for proxied traffic, that was a live hole. The ranges are now ported with parity tests, and the port also fixed a pre-existing gap the TS classifier does not have: the `fc00::/7` check only covered `fc::` and missed `fd::`. Teredo is checked as `2001:0::/32` (second hextet zero), NOT the whole `2001::/32`, so public DNS like `2001:4860:4860::8888` stays allowed.
|
|
15
|
+
- **The browser's rebinding backstop exempted the proxy host itself.** `isProxyHopAddress` treated an origin address equal to the configured proxy host (normally `127.0.0.1`) as "the hop" and skipped the check — but with the proxy on loopback, an origin of `127.0.0.1` is indistinguishable from a genuine loopback origin, which the guard must poison. Measured camoufox behaviour reports the hop as `0.0.0.0`, which the unspecified-address exemption still covers, so dropping the host equality loses no legitimate scrape. `getSocksProxyEndpoint` now also type-checks `host`/`port` from the JSON (a numeric host or an out-of-range port means "no proxy", not a nonsense endpoint). Tests: `test/unit/infrastructure/thread-worker-ssrf-subresource.test.ts`.
|
|
16
|
+
- **The SOCKS proxy leaked memory and file descriptors, and its logs were injectable.** (a) The handshake `data` listener stayed attached after the handshake, so `buf` grew without bound for the lifetime of every long-lived proxied connection — it is now detached at the handshake's end and capped at 4096 bytes (a well-formed SOCKS request is under 300 bytes). (b) `client.pipe(upstream)` / `upstream.pipe(client)` left the upstream socket open on a client RST (fd leak); `stream.pipeline` now destroys both ends when either ends. (c) `targetHost` is raw domain bytes from a SOCKS client and can carry newlines into the cron log (CodeQL `js/log-injection`); it is now `JSON.stringify`-ed. (d) A refused connection to ANY host rotated the DuckDuckGo pin index, shifting pin order for unrelated destinations; rotation now only applies to DDG hosts. Tests: `test/unit/scripts/ddg-socks-proxy-guard.test.ts`, `test/unit/scripts/private-addresses.test.ts`.
|
|
17
|
+
- **Seven open CodeQL alerts, all now fixed.** `js/log-injection` ×2 in `scripts/ddg-socks-proxy.mjs` (the log-injection above), `js/insecure-temporary-file` in `test/unit/infrastructure/thread-worker-ssrf-subresource.test.ts` (the proxy-config temp file now uses `mkdtemp` at 0700 + a 0600 write), and `js/unused-local-variable` ×4 in `scripts/lib/private-addresses.mjs` (the hextet destructure now takes only the hextets it uses).
|
|
18
|
+
- **Hand-rolled SQL quoting, in eight places, is now one helper.** Every DataFusion string literal in the knowledge store was built by a local `.replace(/'/g, "''")` on attacker-influenced input (stored URLs, workspace paths, ingestion types). `src/knowledge/sql-utils.ts` `sqlString()` is now the single escaping rule, used at all nine sites (`store.ts`, `store-operations.ts`), with tests pinning the doubled-quote rule and the absence of any backslash/backtick/newline rule. `test/unit/knowledge/sql-utils.test.ts`.
|
|
19
|
+
- **The guarded `read` had a check-then-use TOCTOU.** `assertReadAllowed` resolves symlinks, then `readFile(p)` runs a moment later: a local attacker with write access to the project can swap `p` for a symlink in between. The read now opens with `O_NOFOLLOW` (a final-component symlink is refused at open with `ELOOP`), stats the fd (only regular files are read), and reads through the fd, so the bytes come from the file the fd points at. The residual gap — an *intermediate* path component swapped for a directory symlink — cannot be closed with Node's public API (no `openat` walk); it requires a local attacker with write access to the project and no read access elsewhere, and is rated Low and documented in `SECURITY.md`. Test: the final-component-symlink backstop in `test/unit/tools/read-guard.test.ts`.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- **The `retry-utils` jitter comment was wrong.** It said "±50% jitter"; the code applies `0–50%` positive jitter. The comment now says so.
|
|
24
|
+
- **CI scripts no longer build shell strings — and now resolve npm as the CLI bundled in the Node distribution.** `scripts/ensure-native-deps.cjs` (two sites) and `scripts/use-npm12.cjs` interpolated `spec` / the npm prefix into `execSync` / `execFileSync` shell strings; both now use argv arrays, so a value read from an installed `package.json` or a `RUNNER_TEMP` path with spaces is never parsed by a shell. The argv arrays exposed a Windows-only failure the shell strings had masked: a bare `npm` in a shell-less spawn is unresolvable on Windows (the npm on PATH is a `.cmd` shim, so `ENOENT`; direct `.cmd` spawns are rejected outright with `EINVAL` since the CVE-2024-27980 hardening in Node 18.20.2 / 20.12.2 / 21.7.3, so `npm.cmd` is not a fix; `shell: true` would re-parse the arguments the hardening removed). `scripts/lib/npm-cmd.cjs` resolves the npm CLI bundled inside the Node distribution (`<node-dir>/node_modules/npm/bin/npm-cli.js` — the nodejs.org/CI layout — or `<node-dir>/../lib/node_modules/npm/bin/npm-cli.js` — the nvm/Homebrew layout) and runs it directly with the Node binary: no PATH lookup, no shim, no shell, arguments stay a clean argv array. `scripts/use-npm12.cjs` (the "Use npm 12" step of every CI leg — the step that was dying with `spawnSync npm ENOENT` on both windows-latest legs) and `scripts/ensure-native-deps.cjs` use it. Test: `test/unit/scripts/npm-cmd.test.ts`.
|
|
25
|
+
- **`madge` is a devDependency, not an `npx --yes` fetch.** The `dep-graph` CI job ran `npx --yes madge@8.0.0` with `contents: write` permissions and `persist-credentials: false`; the unlocked transitive tree of an `npx` fetch is the one uncontrolled install in that job. `deps:generate` now runs the pinned devDependency.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **`@typescript-eslint` recommended ruleset enabled.** The ESLint config applied `@typescript-eslint/no-unused-vars` only; the full recommended ruleset (23 rules) now runs over `src/`. The three `ban-ts-comment` findings it surfaced were dead `@ts-ignore` suppressions (the suppressed lines are error-free, which is why `@ts-ignore` and not `@ts-expect-error` was used) — removed, leaving the explanatory text as plain comments. `no-explicit-any` is set to **warn**, not off: 333 sites across 70 files, each a boundary type (camoufox/Playwright JSON, LLM responses) needing a deliberate shape decision. It is a tracked warning surfaced by every lint run, not a silenced rule; the full `any → unknown + narrowing` pass is its own project and must not ride on a security release.
|
|
30
|
+
- **`youtubei.js` 18.2.0 → 18.3.0** (lock refresh; the range was already `^18.0.0`), **`webgpu` 0.6.0 → 0.6.2** (the `^0.6.0` range resolved forward on the refresh), and the local `node_modules` was re-synced to the lock (`impit` was at 0.14.6 against 0.14.7 in `package.json` and the lock).
|
|
31
|
+
|
|
32
|
+
### Documentation
|
|
33
|
+
|
|
34
|
+
- **Four env vars were read by the code but undocumented in `.env.example` and `docs/CONFIGURATION.md`:** `PI_RESEARCH_PROXY_JSON` (SOCKS proxy config file path), `DDG_SOCKS_PORT` and `DDG_PIN_IPS` (the local SOCKS proxy's port and pinned DuckDuckGo front-doors, read by `scripts/ddg-socks-proxy.mjs`), and `PI_CODING_AGENT_DIR` (the pi agent directory the standalone engine/launcher reads host config from).
|
|
35
|
+
- **`docs/THIRD-PARTY-NOTICES.md` corrected in two places.** (a) The notice said "no third-party code is inlined"; the browser worker bundle (`dist/thread-worker.mjs` and its shipped copy) inlines `typebox` (MIT) — that is now documented. (b) The `ua-parser-js` section claimed the `overrides` pin keeps "this MIT-licensed package free of AGPL-licensed code in its dependency tree"; an npm `overrides` field only applies to the package that carries it, so a consumer's install resolves camoufox's `^2.0.2` declaration itself and typically installs the 2.x (AGPL) copy. The notice now states that the pin protects this repo's own tree only, that no AGPL code is bundled into or redistributed by this package, and why the pin is behavior-neutral.
|
|
36
|
+
|
|
37
|
+
## [1.7.22] - 2026-10-25
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
- **A long-lived session kept the `RESEARCH_MODEL` it read at startup, for days.** `getConfig()` cached by working directory only, with no invalidation, so an edit to `~/.pi/research/config.env` made from anywhere else — an editor, `sed`, a second pi session, the standalone CLI — was invisible to a process that was already running. Measured here: pi pid 3347489 started 2026-10-22 18:30, `config.env` switched from `inclusionai/ling-3.0-flash` to `~deepseek/deepseek-flash-latest` at 20:13, and every process started after the switch used deepseek while 3347489 kept ling-3.0-flash for the next 60 hours and lost two runs (`run-73affa30`, `run-bfe347c3`) to that model's upstream rate limit. The cache entry now carries a fingerprint of the files it was built from (`config.env`, the interface overlay, the legacy `.pi-research.env`, the project-settings registry — `mtimeMs:size`, `absent` for a missing file) and reloads when it moves; `setConfig` pins the fingerprint of the current files so its override survives until a real on-disk change, and `resetConfig` clears both maps. Test: `test/unit/config.test.ts` `config-file change invalidation`.
|
|
41
|
+
- **A rate limit burned the researcher retry budget in seven seconds.** A 429 is the one capacity signal seen most often in the retained logs, and it was the only one with no long-wait path: four attempts spaced 1s/2s/4s — about 100s end to end, of which only 7s was waiting — against a shared upstream pool that stays exhausted for minutes. On 2026-10-25 two of three researchers lost every attempt to DeepInfra's `engine_overloaded` for `inclusionai/ling-3.0-flash` while the pool was still refusing requests six minutes later. The loop now recognizes the 429 class (`/\b429\b/`, `rate limit`, `rate-limited`, `too many requests`, `engine_overloaded`, `provider_overloaded` — matched on provider wording, never a bare number that can appear in an unrelated payload) and waits 15s/30s/60s with ±20% jitter, honoring a provider `Retry-After` when the error carries one. The jitter matters: simultaneous researchers retried on the same second in lockstep and failed in cadence. The ordinary 1s curve is unchanged for every other transient class, and `PI_RESEARCH_RETRY_DELAY_MS` (ceiling 10s, tunable down to 100ms) still caps the ORDINARY step only, so a user cannot shrink a provider-mandated wait. Shared classifier and backoff: `src/utils/provider-errors.ts`; tests `test/unit/utils/provider-errors.test.ts`.
|
|
42
|
+
- **An out-of-credits 429 was treated as provider capacity, which is the opposite of true.** `isRateLimitError` matched any message containing `429`, and a spent account routinely answers 429 (OpenAI: `insufficient_quota`; OpenRouter: 402 "requires more credits"). The balance does not refill between attempts, so two consequences were both wrong: the loop spent the rate-limit backoff on it, and the capacity exclusion then dropped it from the stop threshold — so a run kept going through its remaining rounds, paying a full search burst each round, against an account that could not pay for a single call. The spent-account class is now excluded from the capacity classifier (`insufficient_quota`, `insufficient credits`, `requires more credits`, `exceeded your current quota`, `out of credits`), and `isUnretriableResearcherError` now delegates to it, so the two cannot drift again — before, a 429 worded "exceeded your current quota" was retried on the ordinary curve while the capacity classifier already refused to call it capacity. A spent account is now unretriable, counted toward the stop threshold immediately, and reported as a real failure. Test: `test/unit/utils/provider-errors.test.ts` (`does NOT treat a 429 out-of-quota as capacity`).
|
|
43
|
+
- **An upstream rate-limit outage could end a run whose other researchers were healthy.** `shouldStopResearch` counted every failed researcher, so the default threshold (2) tripped on two 429s and stopped a run that had already collected a full report from the third — exactly the 2026-10-25 run, which returned a raw compilation covering one third of its angle set. Capacity failures (429 / in-flight budget) are still recorded — the summary and the zero-report gate need them — but no longer count toward the stop threshold; a genuine quality failure still does, and a missing reason still counts conservatively. The run stays bounded by its round budget and `PI_RESEARCH_TIMEOUT_MS`. Test: `test/unit/utils/session-state.test.ts`.
|
|
44
|
+
- **The capacity exclusion had no bound, so a total outage would run every remaining round.** Excluding capacity failures from the stop threshold fixes one busy upstream ending a healthy run, but it also means a provider that refuses EVERY request never trips anything: the run keeps planning and searching for its full budget against a pool that cannot answer. One round that produced no new report while every recorded failure was a capacity failure is now tolerated — the outage may clear, and a round already spends about 100s inside the researcher retries — and a second consecutive one stops the run with the same `RESEARCH_STOPPED` outcome as the threshold (fallback synthesis from whatever was collected, or an honest failure when nothing was). The stop message was also split: it used to say "3 researcher(s) did not return a usable report" when only two counted, and to lead with "try a more capable model" even when every failure was the provider refusing to serve. It now reports the counted failures in the headline, lists capacity failures separately under their own heading, and, when every recorded failure was capacity, says the provider would not serve the request instead of sending the user to buy a different model. The capacity headline is worded about what is RECORDED ("no report was collected, and every recorded failure was a provider-capacity failure"), never about one round: the failure list is run-scoped and de-duplicated, so a round that failed the same researchers again adds nothing to it. Tests: `test/unit/utils/session-state.test.ts`, `test/unit/orchestration/deep-research-orchestrator.test.ts`.
|
|
45
|
+
- **Every proxied browser scrape was rejected as an SSRF rebinding attack.** The SOCKS proxy (`~/.pi/research/proxy.json`, added 2026-09-03) landed two months after the `serverAddr()` rebinding backstop (2026-07-01) and nobody reconciled them. Firefox cannot report an origin address when a SOCKS5 proxy resolves and connects on its behalf, and reports `0.0.0.0` instead — measured 2026-10-25 with camoufox 0.5.8: proxied `https://example.com` reports `0.0.0.0`, unproxied the real origin IP. `0.0.0.0` is in `isPrivateIp`'s reserved set, so the scrape was poisoned with 'Fetch blocked: a response was served from a private/reserved address' — every browser-fallback scrape, and the browser fallback is the path that reads sites which 403 a plain fetch (Stack Overflow, developer.android.com, DeepWiki were the ones failing in the observed runs; some fallbacks also fail for unrelated reasons, so this was the largest single cause, not the only one). The first SSRF-poisoning warning in the entire log history is 2026-09-04T00:50Z, 2.5 hours after the proxy commit; there are none before it. The backstop now treats the configured proxy's own address and an unspecified address as 'origin not observable' and skips the check for those, while still blocking every real private address (10.0.0.0/8, 127.0.0.1 as an ORIGIN, `169.254.169.254`, and `0.0.0.0` when no proxy is configured). `src/infrastructure/browser/proxy-prefs.ts` is the single reader of the proxy file, shared by the launcher and the scrape path. **Honest limitation, documented in `docs/TROUBLESHOOTING.md`:** with a SOCKS proxy in the path the browser has no origin address to report, so the connect-time rebinding backstop cannot run for proxied hosts. Request-time DNS validation still applies, and `scripts/ddg-socks-proxy.mjs` now refuses to CONNECT to a loopback / private / link-local / CGNAT / multicast / reserved destination, judged on both the requested host and every address it resolves to (`scripts/lib/private-addresses.mjs`, plain JS so the proxy still runs standalone under cron). That restores the guarantee for the proxy this project's instructions set up; a third-party SOCKS proxy you point `proxy.json` at has no such guard. The guard judges a host:port in two stages for a reason worth stating: an IP literal (and `localhost`/`*.localhost`) is decided before DNS, and a hostname is decided by the addresses it resolves to — handing a HOSTNAME to an address classifier refuses everything, because a hostname is unparseable as an address, and Firefox sends domain-type requests for every hop (`socks_remote_dns: true`). That failure was caught on a live SOCKS handshake before release, not by the unit tests, so both stages now have tests, including a wire-level one. Tests: `test/unit/infrastructure/thread-worker-ssrf-subresource.test.ts`, `test/unit/scripts/private-addresses.test.ts`, `test/unit/scripts/ddg-socks-proxy-guard.test.ts`.
|
|
46
|
+
- **The coordinator, the round router and the synthesizer gave up on a rate limit within seconds.** `retryWithBackoff`'s ordinary step (1s/2s, capped at `LLM_RETRY_MAX_DELAY_MS` = 8s) is right for a dropped socket and wrong for a shared-pool 429: on 2026-10-25 the round-2 router failed three times in about four seconds (`retrying in 1098ms`, `2738ms` in the log) and the orchestrator degraded to "continue the prior agenda" while the same pool was still refusing requests six minutes later. The researcher loop had already been given a 15s/30s/60s rate-limit path; the highest-value calls in a run had not. `RetryOptions` gains an optional `delayFor(nextAttempt, error)` hook, and `planning-service` returns the shared 15s/30s/60s ±20% jitter (honoring `Retry-After`) for a rate-limit error, `null` otherwise — so the ordinary curve, and `maxDelay`'s bound over it, are untouched for every other error class, and a provider-mandated wait is never capped by a step-size limit. `parseRetryAfterMs` moved from `researcher-executor` to `src/utils/provider-errors.ts` so the two callers cannot drift (`core/` importing `orchestration/` would also break the layering rule). Tests: `test/unit/web-research/retry-utils.test.ts`.
|
|
47
|
+
- **A round that would be aborted still ran its whole search burst first.** The stop threshold was checked in `runResearchers`, i.e. after the planner and the search phase: on 2026-10-25 round 2 fanned out 36 searches (296 results) that were then discarded. The check now also runs at the top of the round, before the search burst, and raises the same `RESEARCH_STOPPED` error so the outcome (fallback synthesis from the reports already collected) is unchanged.
|
|
48
|
+
- **The fallback synthesis labelled round 1's third researcher "Researcher 1.1.3".** Reports are keyed `${round}.${researcherId}` and planner-assigned ids are frequently dotted themselves, so the raw key double-counted the round and read as a researcher that never existed. The label now prints the round and the id separately: `Researcher 1.3 (round 1)`. Test: `test/unit/orchestration/research-synthesis-service.test.ts`.
|
|
49
|
+
- **A steering message popped into pi lost its status as an instruction when Esc cancelled the research.** Alt+P hands a queued research steering message to pi as `deliverAs: 'steer'`, and pi holds it in its own queue until the next agent step. While streaming, pi's Esc handler is `restoreQueuedMessagesToEditor({abort: true})` (verified in pi's bundled TUI): it clears both of pi's queues, joins the queued texts into the **editor**, and aborts the turn. The global TUI controller deliberately let Esc fall through to that handler, so the cancelled run also un-queued the message — it was never delivered as an instruction, and any later editor clear (Ctrl+C, a new submission) lost it. Esc now consumes the key when this session has a popped message pi has accepted and not yet necessarily delivered: research still cancels (`abortAllSessions`), the research tool returns into pi's turn, and pi drains its steering queue at the next step. Steering that was NOT popped never reached pi's queue and is still dropped with the run. Accepted cost: pi does not abort its own turn for that one Esc, so panic-cancel is one keystroke further away — a second Esc, with no research active, falls through untouched. Tracking: `forwardedToPiAt` on `SteeringMessage`, `markSteeringForwardedToPi` / `hasForwardedSteering` in `src/orchestration/session-state.ts` (cleared when a new run starts, and by a failed forward that requeues the message). Tests: `test/unit/utils/steering.test.ts` and `test/unit/tui/tui-controller.test.ts`.
|
|
50
|
+
- **Round-1 planning model is now configurable (`PI_RESEARCH_COORDINATOR_MODEL`).** The initial coordinator still defaults to the pi session's model for prompt-cache continuity, but that is the wrong default when the chat model is not a planner: on this host the chat model is a local single-seat llama-swap server, and round-1 planning alone took 2m07s (4,886 tokens) while the hosted research model planned the same query in seconds — and a single-seat server also refuses the owner's own concurrent request. Values: `host` (default), `research` (same model as every later round and all researchers), or an explicit `provider/id`. An unresolvable value falls back to the research model, never to the chat model, so a typo cannot silently restore the behaviour the setting exists to replace — and the lookup is now strict (`findModelByReference`), because the resolver first used for it (`resolveResearchModel`) always returns a model, so a typo would have run on an arbitrary available one while the warning it was supposed to trigger never fired. Also added to `docs/CONFIGURATION.md` and `.env.example`; the translated config tables carry the two corrected retry rows but not this new key (they are partial tables and omit `PI_RESEARCH_MODEL` too).
|
|
51
|
+
- **The retry documentation was corrected in five places.** `PI_RESEARCH_RETRY_DELAY_MS` is now documented as the ordinary-step base AND ceiling only, explicitly not bounding a provider-mandated rate-limit wait, and `PI_RESEARCH_MAX_FAILED_RESEARCHERS` as excluding capacity failures — in `docs/CONFIGURATION.md`, `.env.example`, and the ES/JA/ZH docs.
|
|
52
|
+
- **One flaky unit test (the only failure in a 3,366-test run).** The async-flush test waited a fixed 50ms for the setImmediate → flush → appendFile chain, which regularly exceeds that under the parallel suite (it passes in isolation). It now polls to a 5s deadline, so it still fails on a real regression but no longer on machine load.
|
|
53
|
+
|
|
8
54
|
## [1.7.21] - 2026-10-24
|
|
9
55
|
|
|
10
56
|
### Fixed
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -83,13 +83,14 @@ Research
|
|
|
83
83
|
| `PI_RESEARCH_MAX_SCRAPE_URLS` | `8` | 1–20 | Maximum URLs fetched per scrape batch. URLs past the cap are listed under "Not Fetched — Over Batch Cap" and must be requested in a later batch. |
|
|
84
84
|
| `PI_RESEARCH_SCRAPE_SECOND_PAGE` | `false` | true/false | Also fetch DuckDuckGo results page 2 for every search query, roughly doubling the candidate links each query contributes. Each query's page-2 fetch degrades gracefully — if page 2 fails or does not exist, the page-1 results are kept. |
|
|
85
85
|
| `PI_RESEARCH_MAX_RETRIES` | `2` | 0–5 | Retries per researcher request. |
|
|
86
|
-
| `PI_RESEARCH_RETRY_DELAY_MS` | `2000` | 100–10000 | Base delay between retries. |
|
|
87
|
-
| `PI_RESEARCH_MAX_FAILED_RESEARCHERS` | `2` | 1–10 | Unique researcher failures that abort the whole run. Raise to let slower, still-in-flight researchers finish before giving up. |
|
|
86
|
+
| `PI_RESEARCH_RETRY_DELAY_MS` | `2000` | 100–10000 | Base delay between retries, and the ceiling for the ordinary exponential step (1s, 2s, 4s…). It does **not** bound a provider-mandated wait: a rate limit (HTTP 429 / upstream pool exhausted) is retried after 15s, 30s, then 60s with ±20% jitter, or after the provider's own `Retry-After` when the error carries one (`src/utils/provider-errors.ts`). The 10000 ceiling therefore cannot shorten a rate-limit wait. |
|
|
87
|
+
| `PI_RESEARCH_MAX_FAILED_RESEARCHERS` | `2` | 1–10 | Unique researcher failures that abort the whole run. Raise to let slower, still-in-flight researchers finish before giving up. Provider-**capacity** failures (a 429 or an exhausted in-flight budget) are recorded and reported but do not count toward this threshold: the same model produces a report once the provider's pool frees up, so one upstream outage must not end a run whose other researchers are healthy. |
|
|
88
88
|
| `PI_RESEARCH_WORKER_THREADS` | `4` | 1–10 | Browser worker processes. Higher = more throughput, more CPU/RAM. It sets how *fast* a search burst drains, not how large a burst may be — a burst larger than the pool waits its turn rather than being trimmed or timing out. |
|
|
89
89
|
| `PI_RESEARCH_WORKER_CONCURRENCY` | `2` | 1–10 | Tasks per worker process. |
|
|
90
90
|
| `PI_RESEARCH_MAX_CONCURRENT_RUNS` | `3` | ≥1 | Machine-wide cap on research runs executing at the same time, across **every** process (CLI, agent skill, pi extension, SDK). Runs beyond the cap queue rather than fail. All concurrent runs share one leader-elected browser/embedding pool, so oversubscribing it degrades every run at once. |
|
|
91
91
|
| `PI_RESEARCH_RUN_ACQUIRE_TIMEOUT_MS` | `600000` | ≥0 | How long a run queues for a free slot before failing with "maximum concurrent research runs reached" (CLI exit `75`). `0` = fail immediately instead of queueing. |
|
|
92
|
-
| `PI_RESEARCH_MODEL` | _(pi: session model; CLI/skill: required)_ | — | The model research runs on. **Required for the standalone CLI / agent skill** — they use only this configured model (never the model selected inside the pi extension) and refuse to start without one (the CLI's per-run `--model` flag also satisfies this). On the SDK it selects the session model when no `model` option is given. In the pi extension it overrides the evaluator/synthesis rounds and researcher sub-agents and knowledge synthesis. The initial coordinator (round 1 planning) uses the pi session model for prompt-cache continuity with the conversation that triggered research
|
|
92
|
+
| `PI_RESEARCH_MODEL` | _(pi: session model; CLI/skill: required)_ | — | The model research runs on. **Required for the standalone CLI / agent skill** — they use only this configured model (never the model selected inside the pi extension) and refuse to start without one (the CLI's per-run `--model` flag also satisfies this). On the SDK it selects the session model when no `model` option is given. In the pi extension it overrides the evaluator/synthesis rounds and researcher sub-agents and knowledge synthesis. The initial coordinator (round 1 planning) uses the pi session model for prompt-cache continuity with the conversation that triggered research — override that with `PI_RESEARCH_COORDINATOR_MODEL`. Accepts `provider/id` or a bare model id. |
|
|
93
|
+
| `PI_RESEARCH_COORDINATOR_MODEL` | _(host model)_ | `host` · `research` · `provider/id` | Which model runs the **initial coordinator** (round-1 planning), the only research call that does not use the research model. `host` (default) uses the pi session's model so the coordinator prompt shares the conversation's prompt cache. `research` uses the same model as every later round and all researchers. An explicit `provider/id` pins that model. Set this when the chat model is a poor or single-seat planner — a local server with `concurrencyLimit: 1` turns round-1 planning into minutes of wall clock and can refuse the user's own concurrent request. An unresolvable value falls back to the **research** model, never to the chat model. |
|
|
93
94
|
| `PI_RESEARCH_DISABLED_TOOLS` | _(none)_ | — | Comma-separated research tools to disable for a run (`search`, `scrape`, `security_search`, `stackexchange`, `youtube_transcript`, `grep`, `read`). Removed from every researcher's toolset (`read` is already confined to the project directory and refuses secret files; disabling it removes local reads entirely) and named in the coordinator and research-lead prompts. Strictly additive — it can only remove capabilities, never grant one, and it stacks on top of the default exclusions rather than replacing them. An unrecognized name excludes nothing and is warned about rather than failing the run. |
|
|
94
95
|
| `PI_RESEARCH_REPORT_EXPORT_ENABLED` (TUI) | `false` | — | Front-ends write a Markdown report to disk and surface its path. |
|
|
95
96
|
| `PI_RESEARCH_REPORT_EXPORT_DIR` | _(smart cwd)_ | — | Pin exported reports to a fixed directory, bypassing the cwd-relative resolution. Useful for the agent skill, which runs from the host agent's arbitrary directory. |
|
|
@@ -178,6 +179,10 @@ Diagnostics & platform
|
|
|
178
179
|
| `PLAYWRIGHT_INSTALL_DEPS` | _(unset)_ | Linux only. Set `true` during `npm install` to also install system libraries via `npx playwright install-deps` (same as `npm run install:system-deps`). |
|
|
179
180
|
| `PI_RESEARCH_STRICT_SETUP` | _(unset)_ | Read by the bundled `scripts/setup.cjs` during `npm install`. Set `1`/`true` to make a failed browser download fail the install instead of deferring it to first use. |
|
|
180
181
|
| `PI_RESEARCH_CONFIG_DIR_NAME` | `.pi` | Override the host config-directory name under your home dir (advanced; e.g. set to share another harness's config root). |
|
|
182
|
+
| `PI_RESEARCH_PROXY_JSON` | `~/.pi/research/proxy.json` | Path of the SOCKS proxy config file the browser workers read (`{"host":"127.0.0.1","port":1080}`), routing every browser request through the local SOCKS proxy. Read fresh per scrape, so toggling needs no restart. See [Troubleshooting](TROUBLESHOOTING.md). |
|
|
183
|
+
| `DDG_SOCKS_PORT` | `1080` | Port the local SOCKS proxy (`scripts/ddg-socks-proxy.mjs`, run under cron) listens on. Read by the proxy script, not the main runtime. |
|
|
184
|
+
| `DDG_PIN_IPS` | `52.250.42.157,40.89.244.232` | Pinned DuckDuckGo front-door IPs for the local SOCKS proxy (comma-separated). The proxy rotates past any address that stalls, so the list self-heals; change it only for a different egress path. |
|
|
185
|
+
| `PI_CODING_AGENT_DIR` | `~/.pi/agent` | Override the pi agent directory the standalone engine/launcher looks in for host config (settings.json, models.json). |
|
|
181
186
|
|
|
182
187
|
Testing only — never enable in production
|
|
183
188
|
|
|
@@ -5,10 +5,12 @@ license covers this project's own source code only.
|
|
|
5
5
|
|
|
6
6
|
This package depends on third-party software distributed under its own license
|
|
7
7
|
terms. Dependencies are resolved and installed by npm at install time (by
|
|
8
|
-
reference); they are **not** bundled into this package's published artifacts, with the
|
|
9
|
-
below
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
reference); they are **not** bundled into this package's published artifacts, with the
|
|
9
|
+
two exceptions below: `@lancedb/lancedb` is redistributed in the tarball, and the
|
|
10
|
+
esbuild-bundled browser worker `dist/thread-worker.mjs` (and its copy shipped at
|
|
11
|
+
`src/infrastructure/browser/thread-worker.mjs`) inlines exactly one third-party
|
|
12
|
+
package, `typebox` (MIT — see below). `dist/cli.mjs` inlines no third-party code,
|
|
13
|
+
and the remaining `dist/` files are copied first-party sources.
|
|
12
14
|
|
|
13
15
|
### Bundled third-party code: `@lancedb/lancedb`
|
|
14
16
|
|
|
@@ -24,6 +26,17 @@ resolve its pinned `@huggingface/transformers` 3.0.2 and `sharp` 0.33.5 (see `do
|
|
|
24
26
|
license file in the bundle. The per-platform LanceDB native bindings are NOT bundled; npm installs
|
|
25
27
|
them separately.
|
|
26
28
|
|
|
29
|
+
### Inlined third-party code: `typebox`
|
|
30
|
+
|
|
31
|
+
The browser worker bundle (`dist/thread-worker.mjs`, and the copy of it shipped at
|
|
32
|
+
`src/infrastructure/browser/thread-worker.mjs`) inlines exactly one third-party
|
|
33
|
+
package: `typebox`, **MIT**, Copyright the TypeBox authors (https://github.com/sinclairtypebox/typebox).
|
|
34
|
+
The worker is a poolifier cluster child: a plain Node process that gets no help from
|
|
35
|
+
pi's extension loader (which aliases the peer `typebox` for in-process code only),
|
|
36
|
+
and `pi install` never installs peers — so `typebox` is bundled into the worker
|
|
37
|
+
rather than resolved at runtime. (`dist/cli.mjs` inlines nothing; only the worker
|
|
38
|
+
bundle does.)
|
|
39
|
+
|
|
27
40
|
### Notable dependency licensing
|
|
28
41
|
|
|
29
42
|
camoufox / Camoufox browser
|
|
@@ -40,16 +53,19 @@ own license.
|
|
|
40
53
|
|
|
41
54
|
ua-parser-js
|
|
42
55
|
|
|
43
|
-
`ua-parser-js` 2.x is licensed under AGPL-3.0-or-later.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
`ua-parser-js` 2.x is licensed under AGPL-3.0-or-later. `package.json`
|
|
57
|
+
`overrides` pins `ua-parser-js` to the `1.x` line (MIT) **in this package's own
|
|
58
|
+
install tree** — i.e. this repository and its CI. The pin does NOT reach
|
|
59
|
+
consumers: an npm `overrides` field only applies to the package that carries it,
|
|
60
|
+
and the published tarball ships no lockfile, so a consumer's install resolves
|
|
61
|
+
camoufox's declared `ua-parser-js ^2.0.2` itself and typically installs the 2.x
|
|
62
|
+
(AGPL) copy alongside it. That is a property of the consumer's dependency tree,
|
|
63
|
+
not of this package's artifacts: camoufox calls only
|
|
48
64
|
`new UAParser(ua).getBrowser().name` and `.getOS().name`, both present in 1.x and
|
|
49
|
-
|
|
50
|
-
package
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
2.x, so the pin is behavior-neutral here, and no AGPL code is bundled into, or
|
|
66
|
+
redistributed by, this package. Re-check that call surface on every `camoufox`
|
|
67
|
+
bump: a 2.x-only call would make the pin a runtime break, not just a licensing
|
|
68
|
+
choice.
|
|
53
69
|
|
|
54
70
|
youtubei.js / bgutils-js / jsdom (YouTube transcripts)
|
|
55
71
|
|
package/docs/TROUBLESHOOTING.md
CHANGED
|
@@ -62,6 +62,22 @@ npm install -g @earendil-works/pi-coding-agent
|
|
|
62
62
|
npm install -g @lincoln504/pi-research
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
## Every browser scrape fails with "a response was served from a private/reserved address"
|
|
66
|
+
|
|
67
|
+
This was a bug in releases before the one that ships `src/infrastructure/browser/proxy-prefs.ts`, and it only affects hosts that route the browser through the local SOCKS proxy (`~/.pi/research/proxy.json`). Through a SOCKS5 proxy Firefox cannot report the origin's address and reports `0.0.0.0`, which the SSRF rebinding backstop classified as reserved, so every browser-fallback scrape was refused — the only path that reads sites which answer plain fetches with `403`.
|
|
68
|
+
|
|
69
|
+
Updating fixes it. To confirm the cause on an affected build, disable the proxy (rename `proxy.json`) and retry the same URL: if it now succeeds, that is this bug. The log signature is a `WARN` line `SSRF rebinding defense: a response connected to a private/reserved address; poisoning scrape of <url>` immediately followed by `Browser fallback did not yield content`.
|
|
70
|
+
|
|
71
|
+
**What the fix does and does not cover.** The check it exempts compares the address Firefox actually connected to against the address the hostname resolves to — that comparison is what catches DNS rebinding. A SOCKS5 proxy makes it impossible: Firefox never sees the origin address. So with a proxy configured, a page that rebinds a public hostname to an internal address is not caught at bake time. Two things still apply. Request-time DNS validation still runs on every navigation and every subresource the page pulls in, and rejects a hostname that resolves into private space before the request is allowed out. And `scripts/ddg-socks-proxy.mjs` (the proxy this project ships instructions for) now refuses to CONNECT to a loopback, private, link-local, CGNAT, multicast or reserved destination, checking both the requested host and every address it resolves to. A third-party SOCKS proxy you point `proxy.json` at does not have that guard — do not route through one you do not trust.
|
|
72
|
+
|
|
73
|
+
## The SOCKS proxy refuses a URL with "connection not allowed by ruleset"
|
|
74
|
+
|
|
75
|
+
That is `scripts/ddg-socks-proxy.mjs` blocking an SSRF attempt, not a bug: the destination was loopback, private, link-local (`169.254.169.254` metadata included), CGNAT, multicast or reserved, spelled either as the host or as the address it resolves to. The log line names it: `[ddg-socks] refused private/reserved destination <host>:<port>` or `refused <host> — resolves to private/reserved <addr>`. A research run never needs such a destination. If you added the proxy for a private mirror, run that request without the proxy.
|
|
76
|
+
|
|
77
|
+
## A research run used a different model than `~/.pi/research/config.env` says
|
|
78
|
+
|
|
79
|
+
Before the release that fingerprints the config sources, `getConfig()` cached configuration for the life of the process and never re-read it. Editing `config.env` from another shell, editor or pi session therefore did not affect a session that was already running, however long it lived. Restart pi (the loaded code and the loaded config are both fixed at start-up) or set the value through `/research-config`, which calls `resetConfig()`. Confirm what a run actually used: the report footer names the model, and the log carries `Using model for researcher <id>: <provider>/<model>`.
|
|
80
|
+
|
|
65
81
|
## The first scrape takes minutes, or install downloads over a gigabyte
|
|
66
82
|
|
|
67
83
|
The stealth browser (about 1 GB installed) is fetched by the `postinstall` script on npm 10 through
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincoln504/pi-research",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.23",
|
|
4
4
|
"description": "Web research for your agents with smart and safe tooling + knowledge store",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -40,6 +40,8 @@
|
|
|
40
40
|
"scripts/cleanup.cjs",
|
|
41
41
|
"scripts/camoufox-layout.cjs",
|
|
42
42
|
"scripts/build.cjs",
|
|
43
|
+
"scripts/ddg-socks-proxy.mjs",
|
|
44
|
+
"scripts/lib/",
|
|
43
45
|
"scripts/bare-imports.cjs",
|
|
44
46
|
"scripts/prepare.cjs",
|
|
45
47
|
"LICENSE",
|
|
@@ -110,7 +112,7 @@
|
|
|
110
112
|
"install:system-deps": "node scripts/setup.cjs --system-deps",
|
|
111
113
|
"//deps:check": "dependency-cruiser 18.5 refuses Node 25 (supports ^22 || ^24 || >=26) while engines allows >=22.22.2: run this script under Node 22 or 24 (see .nvmrc).",
|
|
112
114
|
"deps:check": "depcruise --config config/tooling/dependency-cruiser.cjs --output-type err-long src",
|
|
113
|
-
"deps:generate": "
|
|
115
|
+
"deps:generate": "madge --image docs/deps.svg src/index.ts",
|
|
114
116
|
"verify:changelog": "node scripts/verify-changelog.cjs",
|
|
115
117
|
"lock:restore-stubs": "node scripts/restore-lock-stubs.cjs",
|
|
116
118
|
"analyze:dependencies": "ncu",
|
|
@@ -137,8 +139,8 @@
|
|
|
137
139
|
"pdf-oxide-wasm": "^0.3.77",
|
|
138
140
|
"playwright-core": "1.62.1",
|
|
139
141
|
"poolifier": "^6.0.1",
|
|
140
|
-
"undici": "^8.
|
|
141
|
-
"youtubei.js": "^18.
|
|
142
|
+
"undici": "^8.12.2",
|
|
143
|
+
"youtubei.js": "^18.3.0"
|
|
142
144
|
},
|
|
143
145
|
"bundleDependencies": [
|
|
144
146
|
"@lancedb/lancedb",
|
|
@@ -147,14 +149,14 @@
|
|
|
147
149
|
],
|
|
148
150
|
"optionalDependencies": {
|
|
149
151
|
"@huggingface/transformers": "4.3.1",
|
|
150
|
-
"webgpu": "^0.6.0",
|
|
151
152
|
"@lancedb/lancedb-darwin-arm64": "0.40.0",
|
|
152
|
-
"@lancedb/lancedb-linux-x64-gnu": "0.40.0",
|
|
153
153
|
"@lancedb/lancedb-linux-arm64-gnu": "0.40.0",
|
|
154
|
-
"@lancedb/lancedb-linux-x64-musl": "0.40.0",
|
|
155
154
|
"@lancedb/lancedb-linux-arm64-musl": "0.40.0",
|
|
155
|
+
"@lancedb/lancedb-linux-x64-gnu": "0.40.0",
|
|
156
|
+
"@lancedb/lancedb-linux-x64-musl": "0.40.0",
|
|
157
|
+
"@lancedb/lancedb-win32-arm64-msvc": "0.40.0",
|
|
156
158
|
"@lancedb/lancedb-win32-x64-msvc": "0.40.0",
|
|
157
|
-
"
|
|
159
|
+
"webgpu": "^0.6.0"
|
|
158
160
|
},
|
|
159
161
|
"peerDependencies": {
|
|
160
162
|
"@earendil-works/pi-ai": ">=0.99.0 <2",
|
|
@@ -170,7 +172,7 @@
|
|
|
170
172
|
"vite": "^8.3.1",
|
|
171
173
|
"adm-zip": "^0.6.1",
|
|
172
174
|
"jsdom": {
|
|
173
|
-
"undici": "^8.
|
|
175
|
+
"undici": "^8.12.2"
|
|
174
176
|
},
|
|
175
177
|
"sharp": "^0.35.0",
|
|
176
178
|
"@lancedb/lancedb": {
|
|
@@ -189,6 +191,7 @@
|
|
|
189
191
|
"dependency-cruiser": "^18.5.0",
|
|
190
192
|
"depngn": "^0.6.0",
|
|
191
193
|
"eslint": "10.13.0",
|
|
194
|
+
"madge": "^8.0.0",
|
|
192
195
|
"npm-check-updates": "^23.1.0",
|
|
193
196
|
"typebox": "1.3.27",
|
|
194
197
|
"typescript": ">=6.0.3 <6.1.0",
|