@lincoln504/pi-research 1.6.5 → 1.6.6
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 +13 -9
- package/agent-skill/pi-research/README.md +5 -4
- package/agent-skill/pi-research/SKILL.md +1 -1
- package/dist/cli.mjs +587 -149
- package/dist/pdf-extract-worker.mjs +1289 -0
- package/dist/prompts/research-tool-usage.md +2 -1
- package/dist/prompts/researcher.md +1 -1
- package/dist/prompts/system-coordinator.md +2 -2
- package/dist/prompts/system-lead-router.md +1 -1
- package/docs/AGENT-SKILL.md +6 -6
- package/docs/ARCHITECTURE.md +24 -22
- package/docs/CHANGELOG.md +54 -0
- package/docs/CONFIGURATION.md +3 -2
- package/docs/SDK.md +7 -12
- package/package.json +7 -4
- package/scripts/build.cjs +35 -0
- package/scripts/setup.cjs +12 -10
- package/src/cleanup/research-cleanup.ts +11 -5
- package/src/cli.ts +7 -5
- package/src/config.ts +9 -3
- package/src/core/interfaces/knowledge-interfaces.ts +8 -0
- package/src/core/interfaces/orchestration-interfaces.ts +1 -1
- package/src/core/interfaces/research-plan-types.ts +6 -0
- package/src/core/llm/agentic-repair.ts +40 -3
- package/src/core/llm/llm-utils.ts +93 -5
- package/src/core/llm/model-registry-factory.ts +2 -15
- package/src/core/pi-ai-skew.ts +351 -0
- package/src/core/pi-version.ts +1 -1
- package/src/core/planning-service.ts +110 -15
- package/src/core/planning-utils.ts +3 -0
- package/src/core/service-registry.ts +8 -6
- package/src/index.ts +14 -0
- package/src/infrastructure/browser/config.ts +6 -7
- package/src/infrastructure/browser/ensure-browser.ts +14 -7
- package/src/infrastructure/browser/thread-worker-browser.ts +18 -19
- package/src/knowledge/chunker.ts +22 -4
- package/src/knowledge/embedder-init.ts +41 -1
- package/src/knowledge/store.ts +68 -1
- package/src/observers/research-observer-impl.ts +4 -1
- package/src/orchestration/deep-research-orchestrator.ts +3 -3
- package/src/orchestration/headless-observer.ts +33 -0
- package/src/orchestration/quick-research-orchestrator.ts +17 -3
- package/src/orchestration/research-orchestration-service.ts +27 -4
- package/src/orchestration/session-state.ts +36 -7
- package/src/prompts/research-tool-usage.md +2 -1
- package/src/prompts/researcher.md +1 -1
- package/src/prompts/system-coordinator.md +2 -2
- package/src/prompts/system-lead-router.md +1 -1
- package/src/sdk.ts +12 -4
- package/src/tools/research-knowledge-search.ts +23 -7
- package/src/tools/research-tool-definition.ts +1 -1
- package/src/tools/scrape.ts +12 -9
- package/src/tools/search.ts +12 -6
- package/src/tools/security.ts +6 -1
- package/src/tools/stackexchange.ts +6 -1
- package/src/utils/cancellation.ts +34 -1
- package/src/utils/llm-usage.ts +8 -0
- package/src/utils/log-utils.ts +1 -1
- package/src/web-research/browser-search.ts +6 -5
- package/src/web-research/pdf-extract-worker.mjs +1289 -0
- package/src/web-research/pdf-extract-worker.ts +42 -0
- package/src/web-research/pdf-extraction.ts +392 -0
- package/src/web-research/web-scraper.ts +3 -111
package/src/utils/llm-usage.ts
CHANGED
|
@@ -67,6 +67,14 @@ function warnIfUnpriced(model: Model<any>, tokens: number, cost: number): void {
|
|
|
67
67
|
* `tokens > 0 || cost > 0`, so a response whose usage is all-zero across the board
|
|
68
68
|
* emits nothing — harmless in practice because cache fields are summed into `tokens`,
|
|
69
69
|
* so a reported cache split implies a nonzero total.
|
|
70
|
+
*
|
|
71
|
+
* Accuracy note: for the openai-completions API family (which includes OpenRouter),
|
|
72
|
+
* pi-ai's usage normalization ALWAYS sets cacheRead/cacheWrite, defaulting missing
|
|
73
|
+
* upstream fields to 0 — so on those providers a route without prompt caching shows the
|
|
74
|
+
* counter at 0 rather than omitting it. The 0-vs-absent distinction only holds for APIs
|
|
75
|
+
* that omit the fields outright. A run showing llm_cache_read_tokens_total stuck at 0
|
|
76
|
+
* with nonzero input tokens is therefore most simply read as "this route reports no
|
|
77
|
+
* cached tokens", not "our prompts defeat the cache".
|
|
70
78
|
*/
|
|
71
79
|
function recordCacheTokens(parsed: Partial<TokenUsage>, labels: Record<string, string>): void {
|
|
72
80
|
if (typeof parsed.cacheRead === 'number') {
|
package/src/utils/log-utils.ts
CHANGED
|
@@ -38,7 +38,7 @@ export function buildDefaultDebugLogPath(): string {
|
|
|
38
38
|
* Check whether debug/verbose logging is enabled.
|
|
39
39
|
*
|
|
40
40
|
* Reads PI_RESEARCH_DEBUG env var. Config SAVES sync config.DEBUG into this
|
|
41
|
-
* env var (see config.ts
|
|
41
|
+
* env var (see the DEBUG → PI_RESEARCH_DEBUG bridge in config.ts createConfig); plain config LOADS do not mutate
|
|
42
42
|
* process.env, so a DEBUG=true line in config.env enables verbose logging for
|
|
43
43
|
* a process only after a save has run in it — export PI_RESEARCH_DEBUG=true
|
|
44
44
|
* in the environment to guarantee it from process start.
|
|
@@ -331,11 +331,12 @@ export async function performSearch(
|
|
|
331
331
|
metrics.increment('browser_search_total_failures_total', 1, { cause: 'native_binding' });
|
|
332
332
|
throw new Error(
|
|
333
333
|
`Search completely failed: ${reason}, all with a missing native module. ` +
|
|
334
|
-
`This is an incomplete install, not a network problem:
|
|
335
|
-
`
|
|
336
|
-
`
|
|
337
|
-
`npm install -g @
|
|
338
|
-
`
|
|
334
|
+
`This is an incomplete install, not a network problem: better-sqlite3 13 ` +
|
|
335
|
+
`ships prebuilt bindings for every supported platform and loads them at ` +
|
|
336
|
+
`runtime, so a missing binding means an old or broken npm install. ` +
|
|
337
|
+
`Upgrade npm to ≥12 (npm install -g npm@12) and reinstall this package — ` +
|
|
338
|
+
`modern npm skips the needless recompile that fails on toolchain-less ` +
|
|
339
|
+
`machines, and the prebuilt binding then loads as-is.` +
|
|
339
340
|
(sampleWorkerError ? ` Last worker error: ${sampleWorkerError}` : '')
|
|
340
341
|
);
|
|
341
342
|
}
|