pi-web-search 1.2.0 โ†’ 1.2.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 CHANGED
@@ -1,95 +1,48 @@
1
1
  # pi-web-search
2
2
 
3
- A pi extension that provides provider-native web search across Google Gemini, OpenAI, and Anthropic, plus Gemini-native URL Context analysis.
3
+ Provider-native web search for [pi](https://github.com/earendil-works/pi-coding-agent), across Google Gemini, OpenAI, and Anthropic, plus Gemini-only URL Context analysis.
4
4
 
5
- ## Features
5
+ ## Tools
6
6
 
7
- - **๐Ÿ” Web Search** - Provider-native web search across Google Gemini, OpenAI Responses, and Anthropic Messages
8
- - **๐Ÿ“„ URL Context** - Gemini-native analysis of up to 20 public URLs, including web pages, documents, images, and YouTube videos
9
- - **๐Ÿงพ Search telemetry** - Tool results include provider, search queries, result URLs, citations, and whether native search metadata was actually observed
10
- - **๐Ÿ”— Canonicalized Google grounding links** - Gemini grounding redirect URLs are resolved to their underlying destination URLs when possible
7
+ ### `web_search`
11
8
 
12
- ## Installation
9
+ Search the web using your currently selected model. Automatically picks the right provider API:
13
10
 
14
- ```bash
15
- pi install npm:pi-web-search
16
- ```
17
-
18
- ## Release highlights for v1.2.0
19
-
20
- - `web_search` now follows the current model across Google Gemini, OpenAI Responses, and Anthropic Messages
21
- - `url_context` is explicitly Gemini-only and is removed from the active tool set for non-Gemini models
22
- - Provider-native search telemetry now exposes queries, URLs, citations, and verification metadata in tool `details`
23
- - Gemini grounding redirect URLs are resolved to canonical destination URLs when possible
24
- - Real test scripts now read configuration from `.env` / `.env.example`
25
- - The package now ships source-only TypeScript entrypoints for pi; no `dist/` build output is required in the project or published package
26
-
27
- ## Behavior notes
28
-
29
- - `web_search` follows the **currently selected model** when that model exposes a supported native search API.
30
- - `web_search` supports Google Gemini, OpenAI Responses, Anthropic Messages, and compatible proxy providers exposing those APIs.
31
- - `url_context` is intentionally **Gemini-only**. When the current model is not Gemini-compatible, the extension removes `url_context` from the active tool set and the executor also fast-fails with a clear unsupported-provider message as a second safety net.
32
- - If `web_search` returns only plain text and does **not** return native search metadata, the tool output includes a warning and marks the result as ungrounded in `details`.
33
- - If `url_context` does not return verified URL-context metadata, the tool output includes an explicit warning so the caller can distinguish a best-effort summary from a verified retrieval.
34
- - For Gemini grounding results, the extension attempts to resolve Google redirect URLs to the final destination URL before returning `sources` / `searchResults`.
35
-
36
- ## Tool matrix
37
-
38
- | Tool | Google Gemini | OpenAI Responses | Anthropic Messages | Proxy providers exposing those APIs |
39
- |---|---|---|---|---|
40
- | `web_search` | โœ… | โœ… | โœ… | โœ… |
41
- | `url_context` | โœ… | โŒ | โŒ | โœ…, but only when the selected model is Gemini-compatible |
11
+ | Provider | API |
12
+ |---|---|
13
+ | Google Gemini | Grounding with Google Search |
14
+ | OpenAI | Responses API web search |
15
+ | Anthropic | Messages API web search |
42
16
 
43
- ## Configuration
17
+ Supports passing up to 20 additional URLs to analyze alongside the query.
44
18
 
45
- No special configuration required. Configure or login to any of the following model providers in pi, and it will be automatically detected and used:
19
+ ### `url_context`
46
20
 
47
- ### For `web_search`
21
+ Gemini-only. Analyze up to 20 public URLs โ€” web pages, documents, images, and YouTube videos. Uses Gemini's native URL Context retrieval with verified metadata.
48
22
 
49
- - google
50
- - google-generative-ai
51
- - openai
52
- - anthropic
53
- - compatible proxy providers whose selected model API is OpenAI Responses, Anthropic Messages, or Google Generative AI
23
+ When using `google-generative-ai`, YouTube URLs are passed as `file_data` for native video understanding.
54
24
 
55
- ### For `url_context`
56
-
57
- - google
58
- - google-generative-ai
59
- - compatible proxy providers whose selected model API is Google Generative AI
60
-
61
- ## Verification scripts
62
-
63
- Create a local `.env` first, ideally by copying `.env.example`. Real-test scripts read all configuration from environment variables instead of hardcoding any provider or extension.
25
+ ## Install
64
26
 
65
27
  ```bash
66
- # Mock/unit parsing tests
67
- npm test
28
+ pi install npm:pi-web-search
29
+ ```
68
30
 
69
- # Real multi-provider web_search verification using models from .env
70
- node tests/real-web-search.mjs
31
+ ## Usage
71
32
 
72
- # Real Gemini url_context verification using model from .env
73
- # Passes when url_context either returns verified metadata/URLs
74
- # or emits the explicit unverified-warning path.
75
- node tests/real-url-context.mjs
76
- ```
33
+ No extra config needed. Just configure any supported provider in pi and the tools auto-detect it.
34
+
35
+ `url_context` is automatically removed from active tools when using a non-Gemini model.
77
36
 
78
- Example `.env` keys:
37
+ ## Test
79
38
 
80
39
  ```bash
81
- PI_BIN=pi
82
- PI_WEB_SEARCH_EXTENSION=./src/index.ts
83
- PI_PROVIDER_EXTENSIONS=/path/to/provider-extension.ts
84
- PI_WEB_SEARCH_MODEL_OPENAI=provider/model-openai
85
- PI_WEB_SEARCH_MODEL_ANTHROPIC=provider/model-anthropic
86
- PI_WEB_SEARCH_MODEL_GOOGLE=provider/model-google
87
- PI_URL_CONTEXT_MODEL=provider/model-google
40
+ cp .env.example .env # edit with your models
41
+ npm test # unit tests
42
+ npm run test:real:web-search
43
+ npm run test:real:url-context
88
44
  ```
89
45
 
90
- Recommended setup:
46
+ ## License
91
47
 
92
- ```bash
93
- cp .env.example .env
94
- # then edit .env with models/extensions available in your local pi setup
95
- ```
48
+ MIT
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "pi-web-search",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Provider-native web search for pi across Google Gemini, OpenAI, and Anthropic, plus Gemini URL Context",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "keywords": [
8
8
  "pi",
9
9
  "pi-extension",
10
+ "pi-package",
10
11
  "web-search",
11
12
  "gemini",
12
13
  "google",
@@ -38,13 +39,18 @@
38
39
  "devDependencies": {
39
40
  "@earendil-works/pi-ai": "^0.75.4",
40
41
  "@earendil-works/pi-coding-agent": "^0.75.4",
41
- "@sinclair/typebox": "^0.34.49",
42
42
  "@types/node": "^25.9.1",
43
+ "typebox": "^1.1.38",
43
44
  "typescript": "^6.0.3"
44
45
  },
45
46
  "pi": {
46
47
  "extensions": [
47
48
  "./src/index.ts"
48
49
  ]
50
+ },
51
+ "peerDependencies": {
52
+ "@earendil-works/pi-ai": "*",
53
+ "@earendil-works/pi-coding-agent": "*",
54
+ "typebox": "*"
49
55
  }
50
56
  }
package/src/index.ts CHANGED
@@ -77,7 +77,6 @@ export default function (pi: ExtensionAPI) {
77
77
 
78
78
  const toolManager = createModelScopedToolManager(pi);
79
79
  pi.on("session_start", (_event, ctx) => toolManager.sync(ctx.model));
80
- pi.on("session_switch", (_event, ctx) => toolManager.sync(ctx.model));
81
80
  pi.on("session_tree", (_event, ctx) => toolManager.sync(ctx.model));
82
81
  pi.on("model_select", (event) => toolManager.sync(event.model));
83
82
  }
@@ -1,5 +1,5 @@
1
1
  import type { ExtensionContext, AgentToolUpdateCallback } from "@earendil-works/pi-coding-agent";
2
- import { Type, type Static } from "@sinclair/typebox";
2
+ import { Type, type Static } from "typebox";
3
3
  import { callApiStream, getConfig, applyCitations } from "./api.ts";
4
4
  import { getModel, missingConfigResult, errorResult, formatResult } from "./utils.ts";
5
5
 
package/src/web_search.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ExtensionContext, AgentToolUpdateCallback } from "@earendil-works/pi-coding-agent";
2
- import { Type, type Static } from "@sinclair/typebox";
2
+ import { Type, type Static } from "typebox";
3
3
  import { callApiStream, getConfig, applyCitations } from "./api.ts";
4
4
  import { getModel, missingConfigResult, errorResult, formatResult } from "./utils.ts";
5
5