pi-better-web-search 0.1.1 → 0.1.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.4
4
+
5
+ - Return `Failed: This tool is not available in this conversation.` when all
6
+ search providers fail during execution, preventing leaking internal provider
7
+ attempt errors to the model.
8
+ - Return `Failed: URL fetch is not available in this conversation.` when URL
9
+ fetching is requested but no URL-capable provider is available.
10
+ - Technical attempt errors and provider routing remain recorded in
11
+ `details.attempts` for logs and UI inspection.
12
+
13
+ ## 0.1.3
14
+
15
+ - Simplify error message when no supported provider is available: return
16
+ `Failed: This tool is not available in this conversation.` instead of exposing
17
+ internal provider and credential configuration instructions to the model.
18
+
19
+ ## 0.1.2
20
+
21
+ - Remove provider/model routing metadata from the model-facing JSON output
22
+ (`search` and `fetched[]`). Routing metadata remains in `details` for UI and
23
+ logs and is not sent to the model.
24
+ - Update the architecture diagram to show all 10 supported provider classes
25
+ plus Anthropic Messages.
26
+ - Refresh the README, Chinese README, design notes, and architecture docs for the
27
+ new output shape.
28
+ - Verification: 116 tests pass, and the package contents pass verification.
29
+
3
30
  ## 0.1.1
4
31
 
5
32
  - Align directory structure with Pi extension conventions (`extensions/index.ts` and `lib/`), eliminating the `:src` suffix in Pi's startup banner.
package/README.md CHANGED
@@ -222,8 +222,6 @@ this:
222
222
  {
223
223
  "query": "the query",
224
224
  "search": {
225
- "provider": "deepseek",
226
- "model": "deepseek-chat",
227
225
  "answer": "provider text when available",
228
226
  "results": "the provider's raw results",
229
227
  "citations": "the provider's raw citations",
@@ -233,8 +231,6 @@ this:
233
231
  "fetched": [
234
232
  {
235
233
  "url": "https://example.com",
236
- "provider": "deepseek",
237
- "model": "deepseek-chat",
238
234
  "data": "the provider's raw fetch payload"
239
235
  }
240
236
  ]
@@ -1,6 +1,6 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" width="1200" height="640" viewBox="0 0 1200 640" role="img" aria-labelledby="title desc">
2
2
  <title id="title">pi-better-web-search architecture</title>
3
- <desc id="desc">One web_search tool routes to provider-native search APIs, falls back across authenticated providers, and returns raw provider JSON with a size guard.</desc>
3
+ <desc id="desc">One web_search tool routes across ten provider classes, falls back across authenticated providers, and returns raw provider JSON with a size guard.</desc>
4
4
  <defs>
5
5
  <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
6
6
  <path d="M 0 0 L 10 5 L 0 10 z" fill="#52525b"/>
@@ -16,8 +16,13 @@
16
16
  .h { font: 700 18px Arial, Helvetica, sans-serif; fill: #18181b; }
17
17
  .t { font: 400 15px Arial, Helvetica, sans-serif; fill: #3f3f46; }
18
18
  .muted { font: 400 14px Arial, Helvetica, sans-serif; fill: #71717a; }
19
+ .p { font: 700 13px Arial, Helvetica, sans-serif; fill: #18181b; }
20
+ .d { font: 400 10.5px Arial, Helvetica, sans-serif; fill: #71717a; }
19
21
  .inv-h { font: 700 18px Arial, Helvetica, sans-serif; fill: #ffffff; }
20
22
  .inv-t { font: 400 14px Arial, Helvetica, sans-serif; fill: #e4e4e7; }
23
+ .inv-p { font: 700 13px Arial, Helvetica, sans-serif; fill: #ffffff; }
24
+ .inv-d { font: 400 10.5px Arial, Helvetica, sans-serif; fill: #e4e4e7; }
25
+ .note { font: 400 11px Arial, Helvetica, sans-serif; fill: #71717a; }
21
26
  .arrow { stroke: #52525b; stroke-width: 2; fill: none; marker-end: url(#arrow); }
22
27
  .label { font: 600 13px Arial, Helvetica, sans-serif; fill: #52525b; }
23
28
  .footer { font: 400 14px Arial, Helvetica, sans-serif; fill: #71717a; }
@@ -28,57 +33,80 @@
28
33
  <rect class="panel" x="20" y="20" width="1160" height="600" rx="22"/>
29
34
 
30
35
  <text class="title" x="56" y="82">pi-better-web-search</text>
31
- <text class="subtitle" x="56" y="116">one tool · provider-native search · raw results</text>
36
+ <text class="subtitle" x="56" y="116">one tool · 10 provider classes · raw results</text>
32
37
 
33
- <rect class="box" x="56" y="166" width="226" height="136" rx="16"/>
34
- <text class="h" x="78" y="198">Current pi model</text>
35
- <text class="t" x="78" y="226">supports search?</text>
36
- <text class="muted" x="78" y="252">yes → use it first</text>
37
- <text class="muted" x="78" y="274">no → fallback</text>
38
+ <rect class="box" x="56" y="150" width="220" height="124" rx="16"/>
39
+ <text class="h" x="76" y="180">Current pi model</text>
40
+ <text class="t" x="76" y="208">supports search?</text>
41
+ <text class="muted" x="76" y="234">yes → use it first</text>
42
+ <text class="muted" x="76" y="256">no → fallback</text>
38
43
 
39
- <path class="arrow" d="M 286 234 L 334 234"/>
40
- <text class="label" x="292" y="222">route</text>
44
+ <path class="arrow" d="M 276 212 L 306 212"/>
45
+ <text class="label" x="280" y="200">route</text>
41
46
 
42
- <rect class="box" x="342" y="166" width="248" height="136" rx="16"/>
43
- <text class="h" x="364" y="198">Candidate router</text>
44
- <text class="t" x="364" y="226">current → cached →</text>
45
- <text class="t" x="364" y="248">family priority</text>
46
- <text class="muted" x="364" y="274">fingerprint-aware cache</text>
47
+ <rect class="box" x="312" y="150" width="250" height="124" rx="16"/>
48
+ <text class="h" x="332" y="180">Candidate router</text>
49
+ <text class="t" x="332" y="208">current → cached →</text>
50
+ <text class="t" x="332" y="230">family priority</text>
51
+ <text class="muted" x="332" y="256">fingerprint-aware cache</text>
47
52
 
48
- <path class="arrow" d="M 594 234 L 642 234"/>
49
- <text class="label" x="600" y="222">try in order</text>
53
+ <path class="arrow" d="M 562 212 L 598 212"/>
54
+ <text class="label" x="568" y="200">try in order</text>
50
55
 
51
- <text class="h" x="650" y="126">provider adapters</text>
52
- <rect class="dash" x="642" y="140" width="258" height="318" rx="18"/>
56
+ <rect class="dash" x="604" y="112" width="340" height="350" rx="18"/>
57
+ <text class="h" x="624" y="142">provider adapters</text>
58
+ <text class="muted" x="920" y="142" text-anchor="end">10 classes</text>
53
59
 
54
- <rect class="accent" x="654" y="152" width="234" height="52" rx="12"/>
55
- <text class="inv-h" x="672" y="175">DeepSeek</text>
56
- <text class="inv-t" x="672" y="194">native search + fetch</text>
60
+ <rect class="accent" x="616" y="154" width="152" height="46" rx="10"/>
61
+ <text class="inv-p" x="630" y="172">DeepSeek</text>
62
+ <text class="inv-d" x="630" y="187">native search + fetch</text>
57
63
 
58
- <rect class="box" x="654" y="214" width="234" height="52" rx="12"/>
59
- <text class="h" x="672" y="237">Ollama Cloud</text>
60
- <text class="t" x="672" y="256">search + fetch</text>
64
+ <rect class="box" x="616" y="208" width="152" height="46" rx="10"/>
65
+ <text class="p" x="630" y="226">Google Gemini</text>
66
+ <text class="d" x="630" y="241">search + URL context</text>
61
67
 
62
- <rect class="box" x="654" y="276" width="234" height="52" rx="12"/>
63
- <text class="h" x="672" y="299">Google Gemini</text>
64
- <text class="t" x="672" y="318">search + URL context</text>
68
+ <rect class="box" x="616" y="262" width="152" height="46" rx="10"/>
69
+ <text class="p" x="630" y="280">Google Antigravity</text>
70
+ <text class="d" x="630" y="295">search + URL context</text>
65
71
 
66
- <rect class="box" x="654" y="338" width="234" height="52" rx="12"/>
67
- <text class="h" x="672" y="361">OpenAI / xAI</text>
68
- <text class="t" x="672" y="380">Responses web search</text>
72
+ <rect class="box" x="616" y="316" width="152" height="46" rx="10"/>
73
+ <text class="p" x="630" y="334">Ollama Cloud</text>
74
+ <text class="d" x="630" y="349">search + fetch</text>
69
75
 
70
- <rect class="box" x="654" y="400" width="234" height="52" rx="12"/>
71
- <text class="h" x="672" y="423">Anthropic</text>
72
- <text class="t" x="672" y="442">Messages web search</text>
76
+ <rect class="box" x="616" y="370" width="152" height="46" rx="10"/>
77
+ <text class="p" x="630" y="388">OpenAI</text>
78
+ <text class="d" x="630" y="403">Responses web search</text>
73
79
 
74
- <path class="arrow" d="M 906 234 L 954 234"/>
75
- <text class="label" x="912" y="222">raw</text>
80
+ <rect class="box" x="776" y="154" width="152" height="46" rx="10"/>
81
+ <text class="p" x="790" y="172">Azure OpenAI</text>
82
+ <text class="d" x="790" y="187">Azure Responses</text>
76
83
 
77
- <rect class="box" x="962" y="166" width="178" height="136" rx="16"/>
78
- <text class="h" x="982" y="198">Tool result</text>
79
- <text class="t" x="982" y="226">raw JSON</text>
80
- <text class="muted" x="982" y="252">no cleanup</text>
81
- <text class="muted" x="982" y="274">64k char guard</text>
84
+ <rect class="box" x="776" y="208" width="152" height="46" rx="10"/>
85
+ <text class="p" x="790" y="226">OpenAI Codex</text>
86
+ <text class="d" x="790" y="241">Codex Responses</text>
87
+
88
+ <rect class="box" x="776" y="262" width="152" height="46" rx="10"/>
89
+ <text class="p" x="790" y="280">GitHub Copilot</text>
90
+ <text class="d" x="790" y="295">Copilot Responses</text>
91
+
92
+ <rect class="box" x="776" y="316" width="152" height="46" rx="10"/>
93
+ <text class="p" x="790" y="334">OpenCode</text>
94
+ <text class="d" x="790" y="349">OpenCode Responses</text>
95
+
96
+ <rect class="box" x="776" y="370" width="152" height="46" rx="10"/>
97
+ <text class="p" x="790" y="388">xAI Grok</text>
98
+ <text class="d" x="790" y="403">Grok Responses</text>
99
+
100
+ <text class="note" x="624" y="446">plus Anthropic Messages · native Messages web search</text>
101
+
102
+ <path class="arrow" d="M 944 212 L 974 212"/>
103
+ <text class="label" x="948" y="200">raw</text>
104
+
105
+ <rect class="box" x="980" y="150" width="160" height="124" rx="16"/>
106
+ <text class="h" x="1000" y="180">Tool result</text>
107
+ <text class="t" x="1000" y="208">raw JSON</text>
108
+ <text class="muted" x="1000" y="234">no cleanup</text>
109
+ <text class="muted" x="1000" y="256">64k char guard</text>
82
110
 
83
111
  <rect class="panel" x="56" y="492" width="1084" height="94" rx="16"/>
84
112
  <text class="h" x="78" y="522">Exposure &amp; memory</text>
@@ -189,8 +189,6 @@ Provider 数据放在 JSON 外层中返回,不做清理。示例:
189
189
  {
190
190
  "query": "the query",
191
191
  "search": {
192
- "provider": "deepseek",
193
- "model": "deepseek-chat",
194
192
  "answer": "provider text when available",
195
193
  "results": "the provider's raw results",
196
194
  "citations": "the provider's raw citations",
@@ -200,8 +198,6 @@ Provider 数据放在 JSON 外层中返回,不做清理。示例:
200
198
  "fetched": [
201
199
  {
202
200
  "url": "https://example.com",
203
- "provider": "deepseek",
204
- "model": "deepseek-chat",
205
201
  "data": "the provider's raw fetch payload"
206
202
  }
207
203
  ]
@@ -136,8 +136,6 @@ The result is a JSON wrapper:
136
136
  {
137
137
  query?: string;
138
138
  search?: {
139
- provider: ProviderFamily;
140
- model: string;
141
139
  answer?: string;
142
140
  results?: unknown;
143
141
  citations?: unknown;
@@ -147,8 +145,6 @@ The result is a JSON wrapper:
147
145
  };
148
146
  fetched?: Array<{
149
147
  url: string;
150
- provider?: ProviderFamily;
151
- model?: string;
152
148
  data?: unknown;
153
149
  error?: string;
154
150
  }>;
@@ -30,7 +30,7 @@ local `pi-web-search` reference checkout, `.env` files, and `DESIGN.md`.
30
30
  npm run build
31
31
  ```
32
32
 
33
- This produces `dist/pi-better-web-search-0.1.0.tgz`. The tarball is not
33
+ This produces `dist/pi-better-web-search-0.1.4.tgz`. The tarball is not
34
34
  committed.
35
35
 
36
36
  ## Publish
@@ -42,7 +42,7 @@ npm publish --access public
42
42
  Alternatively, publish the verified tarball directly:
43
43
 
44
44
  ```bash
45
- npm publish dist/pi-better-web-search-0.1.0.tgz --access public
45
+ npm publish dist/pi-better-web-search-0.1.4.tgz --access public
46
46
  ```
47
47
 
48
48
  `prepublishOnly` reruns the checks, tests, and package verification. npm may
@@ -51,10 +51,10 @@ require browser or OTP authentication.
51
51
  ## Tag and release
52
52
 
53
53
  ```bash
54
- git tag -a v0.1.0 -m "v0.1.0"
55
- git push origin v0.1.0
56
- gh release create v0.1.0 dist/pi-better-web-search-0.1.0.tgz \
57
- --title "v0.1.0" \
54
+ git tag -a v0.1.4 -m "v0.1.4"
55
+ git push origin v0.1.4
56
+ gh release create v0.1.4 dist/pi-better-web-search-0.1.4.tgz \
57
+ --title "v0.1.4" \
58
58
  --notes-file /path/to/release-notes.md
59
59
  ```
60
60
 
package/lib/format.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
2
- import type { ProviderFamily } from "./providers/types.ts";
3
2
 
4
3
  const configuredOutputLimit = Number(process.env.PI_BETTER_WEB_SEARCH_MAX_CHARS);
5
4
  export const MAX_OUTPUT_CHARS =
@@ -10,8 +9,6 @@ export const MAX_OUTPUT_CHARS =
10
9
  export interface WebSearchOutput {
11
10
  query?: string;
12
11
  search?: {
13
- provider: ProviderFamily;
14
- model: string;
15
12
  answer?: string;
16
13
  results?: unknown;
17
14
  citations?: unknown;
@@ -21,8 +18,6 @@ export interface WebSearchOutput {
21
18
  };
22
19
  fetched?: Array<{
23
20
  url: string;
24
- provider?: ProviderFamily;
25
- model?: string;
26
21
  data?: unknown;
27
22
  error?: string;
28
23
  }>;
package/lib/search.ts CHANGED
@@ -377,8 +377,6 @@ function fetchOutput(states: FetchState[], urlErrors: UrlValidationError[]): Non
377
377
  if (state.data !== undefined && state.provider) {
378
378
  return {
379
379
  url: state.url,
380
- provider: state.provider.family,
381
- model: state.provider.model.id,
382
380
  data: state.data,
383
381
  };
384
382
  }
@@ -418,26 +416,20 @@ export async function runWebSearch(
418
416
  if (searchRequested) {
419
417
  const candidates = getSearchCandidates(resolution);
420
418
  if (candidates.length === 0) {
421
- const message =
422
- "No supported web search provider is available. Configure a supported model or credentials and try again.";
419
+ const message = "This tool is not available in this conversation.";
423
420
  return formatError(message, { attempts, error: message });
424
421
  }
425
422
 
426
423
  searchSuccess = await runSearch(resolution, query, signal, onUpdate, attempts);
427
424
  if (!searchSuccess) {
428
- const failure = attemptSummary(attempts, "search") || "No provider returned a result.";
429
- const message = `Web search failed. ${failure}`;
425
+ const message = "This tool is not available in this conversation.";
430
426
  return formatError(message, { attempts, error: message });
431
427
  }
432
428
  }
433
429
 
434
430
  const fetchCandidates = validFetchRequested ? getFetchCandidates(resolution) : [];
435
431
  if (validFetchRequested && fetchCandidates.length === 0) {
436
- const requestedUrls = [
437
- ...urls,
438
- ...urlErrors.map((entry) => `${entry.url} (${entry.error})`),
439
- ];
440
- const message = `URL fetch failed. No URL fetch provider is available for: ${requestedUrls.join(", ")}`;
432
+ const message = "URL fetch is not available in this conversation.";
441
433
  // The search half succeeded; remember it even though the URL half did not.
442
434
  const cache = nextCache(resolution, searchSuccess?.candidate, undefined);
443
435
  if (cache) writeCache(cache);
@@ -474,11 +466,7 @@ export async function runWebSearch(
474
466
  const output: WebSearchOutput = {};
475
467
  if (query) output.query = query;
476
468
  if (searchSuccess) {
477
- output.search = {
478
- ...searchSuccess.result,
479
- provider: searchSuccess.candidate.family,
480
- model: searchSuccess.candidate.model.id,
481
- };
469
+ output.search = { ...searchSuccess.result };
482
470
  }
483
471
  if (fetchRequested) {
484
472
  output.fetched = fetchOutput(states, urlErrors);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-web-search",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "A better provider-native web_search tool for pi: raw results, automatic provider fallback, URL analysis, and native DeepSeek Search/Fetch.",
5
5
  "type": "module",
6
6
  "license": "MIT",