pi-querit 1.0.3 → 1.1.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 CHANGED
@@ -1,214 +1,186 @@
1
- # pi-querit
2
-
3
- [![npm version](https://img.shields.io/npm/v/pi-querit?color=blue)](https://www.npmjs.com/package/pi-querit)
4
- [![downloads](https://img.shields.io/npm/dm/pi-querit)](https://www.npmjs.com/package/pi-querit)
5
- [![license](https://img.shields.io/npm/l/pi-querit)](./LICENSE)
6
- ![platform](https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey)
7
- ![pi](https://img.shields.io/badge/pi-extension-orange)
8
-
9
- A focused [Pi](https://github.com/earendil-works/pi) extension that gives your agent live web search and page fetching through [Querit](https://www.querit.ai).
10
-
11
- ## Why Querit?
12
-
13
- LLMs are limited by their training data — complex or real-time queries lead to hallucinations and stale answers. Querit is a retrieval system built specifically for generative LLM invocation scenarios, delivering real-time, authoritative web search results that integrate directly into LLM applications:
14
-
15
- - **Comprehensive content** — a massive global index spanning nearly 20 countries and 10 languages with hundreds of billions of web pages.
16
- - **Strong capabilities** — flexible retrieval options (time range, region, language, and domain filters) so results can be tuned for specific scenarios.
17
- - **Excellent results** — accurate, authoritative, high-quality content coverage.
18
-
19
- Sign up on [Querit.ai](https://www.querit.ai) to get an API key with **1,000 free API calls per month** — no credit card required.
20
-
21
- ## Quick Start
22
-
23
- **1. Install**
24
-
25
- ```bash
26
- pi install npm:pi-querit
27
- ```
28
-
29
- **2. Configure**
30
-
31
- Start Pi interactively and run the setup wizard:
32
-
33
- ```text
34
- /querit-setup
35
- ```
36
-
37
- The wizard walks you through API key entry, search defaults, and an optional summary model. Every step after the API key can be skipped.
38
-
39
- **3. Search**
40
-
41
- Just ask your agent anything that needs the web — it calls `web_search` and `fetch_content` automatically:
42
-
43
- ```text
44
- > What changed in the Rust 2024 edition?
45
- ```
46
-
47
- > **Note:** Do not enable this package together with another extension that also registers `web_search` or `fetch_content`; Pi tool names must be unique.
48
-
49
- ## How It Works
50
-
51
- ```
52
- ┌──────────────────────────────────────────────────────────┐
53
- │ Pi Agent │
54
- │ │
55
- │ web_search(query, count?, workflow?) │
56
- │ │ │
57
- │ ▼ │
58
- │ ┌─────────────┐ persistent defaults ┌─────────┐ │
59
- │ │ Querit API │◄── (timeRange, countries, │ querit- │ │
60
- │ │ /v1/search │ languages, domains…) │ search. │ │
61
- │ └──────┬──────┘ from /querit-setup │ json │ │
62
- │ │ └─────────┘ │
63
- │ ▼ │
64
- │ workflow = raw?──► return cited results to outer model │
65
- │ │ │
66
- │ workflow = summary? │
67
- │ │ │
68
- │ ▼ │
69
- │ ┌──────────────────┐ │
70
- │ │ Fixed Pi model │ nested LLM call │
71
- │ │ (from setup) │ → concise summary + sources │
72
- │ └──────────────────┘ + key excerpts │
73
- │ │
74
- │ fetch_content(url/urls, format?) │
75
- │ │ │
76
- │ ▼ │
77
- │ ┌──────────────────┐ │
78
- │ │ Querit API │ │
79
- │ │ /v1/contents │──► markdown / text / HTML │
80
- │ └──────────────────┘ (up to 10 URLs per call) │
81
- └──────────────────────────────────────────────────────────┘
82
- ```
83
-
84
- The extension registers two tools and one slash command:
85
-
86
- | Surface | Purpose |
87
- |---|---|
88
- | `web_search` | Live web search with cited results; optionally pre-summarized by a fixed Pi model |
89
- | `fetch_content` | Full page content (markdown, text, or HTML) for up to 10 URLs per call |
90
- | `/querit-setup` | Interactive configuration of the API key, persistent search defaults, workflow, and summary model |
91
-
92
- **`raw` vs `summary` workflow:**
93
-
94
- - **`raw`** (recommended) — Pi's outer model receives the cited Querit results and answers normally.
95
- - **`summary`** — one additional nested LLM call using the fixed model selected in `/querit-setup` produces a concise summary (preserving version numbers, API signatures, error messages, and verbatim quotes), followed by a Sources list and a `## Key excerpts` section with the top five results' raw snippets. If the fixed model is missing, unauthenticated, times out (30 s), or returns empty output, the tool falls back to raw results and reports the reason.
96
-
97
- ## Configuration
98
-
99
- Run `/querit-setup` in Pi's interactive mode. Configuration is stored in `~/.pi/agent/querit-search.json` (respects `PI_CODING_AGENT_DIR`).
100
-
101
- ### First-time setup flow
102
-
103
- 1. **API key** — masked input prompt; validated with a one-result search request.
104
- 2. **Search defaults** — each step can be skipped (see table below).
105
- 3. **Workflow** — choose `raw` or `summary` as the default.
106
- 4. **Summary model** *(summary only)* — interactive model picker (five per page, arrow-key navigation, type-to-filter fuzzy matching, active model first), then a thinking intensity selector filtered to the levels the chosen model supports.
107
-
108
- ### Re-configuration menu
109
-
110
- When a key is already configured, `/querit-setup` opens a menu:
111
-
112
- | Option | Effect |
113
- |---|---|
114
- | **Replace API key (full re-setup)** | Prompts for a new key, validates it, re-runs the full flow. The old key is overwritten locally; revoke it in the Querit dashboard if needed. |
115
- | **Change search defaults** | Edits the persistent search filters without touching the saved key. |
116
- | **Change summary settings** | Edits the default workflow, the fixed summary model, and its thinking intensity. |
117
-
118
- ### Search default options
119
-
120
- These are persistent defaults applied to every `web_search` call. They are stored under the `search` key in `querit-search.json` and are **not** per-call parameters.
121
-
122
- | Option | Values | Default | Description |
123
- |---|---|---|---|
124
- | `count` | `1` – `20` | API default (`5`) | Number of results per search. Can be overridden per call via the `count` parameter. |
125
- | `timeRange` | `d7` · `w2` · `m3` · `y1` | *(none — all time)* | Restrict results to the past 7 days, 2 weeks, 3 months, or 1 year. |
126
- | `includeContent` | `yes` / `no` | `no` | Include sentence-level content excerpts in results for richer context. |
127
- | `chunksPerDoc` | `1` – `3` | API default (`1`) | Content chunks requested per result. This advanced option is configured by editing `querit-search.json`; it is not exposed in the setup wizard. |
128
- | `countries` | `argentina` · `australia` · `brazil` · `canada` · `colombia` · `france` · `germany` · `india` · `indonesia` · `japan` · `mexico` · `nigeria` · `philippines` · `south korea` · `spain` · `united kingdom` · `united states` | *(none — global)* | Bias results toward specific countries. Comma-separated, multi-select. |
129
- | `languages` | `english` · `japanese` · `korean` · `german` · `french` · `spanish` · `portuguese` | *(none — all)* | Filter results by language. Comma-separated, multi-select. |
130
- | `includeDomains` | domain list | *(none — unrestricted)* | **Whitelist** — only these domains return results. |
131
- | `excludeDomains` | domain list | *(none)* | **Blacklist** — these domains are excluded. Ships with a built-in **Noise blockers** preset: `pinterest.com`, `facebook.com`, `instagram.com`, `tiktok.com`. |
132
-
133
- ### Summary settings
134
-
135
- | Option | Values | Description |
136
- |---|---|---|
137
- | `defaultWorkflow` | `raw` · `summary` | Default workflow for `web_search`. Can be overridden per call via the `workflow` parameter. |
138
- | `summaryModel` | any Pi model reference | Fixed model used for the nested summary call (e.g. `anthropic/claude-sonnet-4-20250514`). |
139
- | `summaryThinkingLevel` | model-dependent | Thinking intensity for the summary model (e.g. `off`, `low`, `medium`, `high`). Defaults to `medium`; the picker only shows levels the chosen model supports. |
140
-
141
- ### Configuration file example
142
-
143
- ```json
144
- {
145
- "apiKey": "your-api-key",
146
- "defaultWorkflow": "raw",
147
- "summaryModel": "provider/model-id",
148
- "summaryThinkingLevel": "medium",
149
- "search": {
150
- "count": 5,
151
- "chunksPerDoc": 1,
152
- "timeRange": "m3",
153
- "includeContent": false,
154
- "countries": ["united states"],
155
- "languages": ["english"],
156
- "includeDomains": ["github.com"],
157
- "excludeDomains": ["pinterest.com"]
158
- }
159
- }
160
- ```
161
-
162
- The extension applies mode `0600` on POSIX systems. On Windows, the file remains protected by the user profile's filesystem ACLs. The key is never included in tool results or logs.
163
-
164
- For CI or ephemeral use, set `QUERIT_API_KEY`. The environment variable takes precedence when both are present.
165
-
166
- ## Tools
167
-
168
- ### `web_search`
169
-
170
- Required:
171
-
172
- - `query`
173
-
174
- Optional:
175
-
176
- - `count` (`1..20`) — overrides the configured default for one call (API default: `5`)
177
- - `workflow`: `raw` or `summary`; overrides the setup default for one call
178
-
179
- Domains, time range, countries, languages, and content excerpts are persistent defaults configured in `/querit-setup` (stored under `search` in `querit-search.json`), not per-call parameters. Skipping the domain lists leaves search unrestricted; the include list is a whitelist (only those domains return results), the exclude list is a blacklist.
180
-
181
- Results include explicit title, URL, snippet, source metadata, and optional sentence excerpts. Duplicate and non-HTTP(S) result URLs are removed.
182
-
183
- ### `fetch_content`
184
-
185
- Pass `url`, `urls`, or both (at most 10 unique HTTP(S) URLs).
186
-
187
- Optional:
188
-
189
- - `format`: `markdown` (default), `text`, or `html`
190
- - `crawl_timeout`: `1..60` seconds (default `10`)
191
- - `include_metadata`: default `true`
192
-
193
- Both tools mark remote data as untrusted, propagate Pi cancellation, enforce response-size limits, and cap model-visible output at Pi's 50KB/2000-line limit. If formatted output is truncated, the complete output is written to a unique temporary file and its path is returned.
194
-
195
- ## Development
196
-
197
- Requires Node.js 22.19 or newer.
198
-
199
- ```bash
200
- npm install
201
- npm run check
202
- npm test
203
- npm run pack:check
204
- ```
205
-
206
- A live smoke test reads the same JSON configuration (or `QUERIT_API_KEY`) and exercises both APIs without printing the key or fetched content:
207
-
208
- ```bash
209
- npm run test:live
210
- ```
211
-
212
- ## License
213
-
214
- MIT
1
+ # pi-querit
2
+
3
+ [![npm version](https://img.shields.io/npm/v/pi-querit?color=blue)](https://www.npmjs.com/package/pi-querit)
4
+ [![downloads](https://img.shields.io/npm/dm/pi-querit)](https://www.npmjs.com/package/pi-querit)
5
+ [![license](https://img.shields.io/npm/l/pi-querit)](./LICENSE)
6
+ ![platform](https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey)
7
+ ![pi](https://img.shields.io/badge/pi-extension-orange)
8
+
9
+ A focused [Pi](https://github.com/earendil-works/pi) extension that gives your agent live web search and page fetching through [Querit](https://www.querit.ai).
10
+
11
+ ## Why Querit?
12
+
13
+ LLMs are limited by their training data — complex or real-time queries lead to hallucinations and stale answers. Querit is a retrieval system built specifically for generative LLM invocation scenarios, delivering real-time, authoritative web search results that integrate directly into LLM applications:
14
+
15
+ - **Comprehensive content** — a massive global index spanning nearly 20 countries and 10 languages with hundreds of billions of web pages.
16
+ - **Strong capabilities** — flexible retrieval options (time range, region, language, and domain filters) so results can be tuned for specific scenarios.
17
+ - **Excellent results** — accurate, authoritative, high-quality content coverage.
18
+
19
+ Sign up on [Querit.ai](https://www.querit.ai) to get an API key with **1,000 free API calls per month** — no credit card required.
20
+
21
+ ## Quick Start
22
+
23
+ **1. Install**
24
+
25
+ ```bash
26
+ pi install npm:pi-querit
27
+ ```
28
+
29
+ **2. Configure**
30
+
31
+ Start Pi interactively and run the setup wizard:
32
+
33
+ ```text
34
+ /querit-setup
35
+ ```
36
+
37
+ The wizard walks you through API key entry and search defaults. Every step after the API key can be skipped.
38
+
39
+ **3. Search**
40
+
41
+ Just ask your agent anything that needs the web — it calls `web_search` and `fetch_content` automatically:
42
+
43
+ ```text
44
+ > What changed in the Rust 2024 edition?
45
+ ```
46
+
47
+ > **Note:** Do not enable this package together with another extension that also registers `web_search` or `fetch_content`; Pi tool names must be unique.
48
+
49
+ ## How It Works
50
+
51
+ ```
52
+ ┌──────────────────────────────────────────────────────────┐
53
+ │ Pi Agent │
54
+ │ │
55
+ │ web_search(query, count?) │
56
+ │ │ │
57
+ │ ▼ │
58
+ │ ┌─────────────┐ persistent defaults ┌─────────┐ │
59
+ │ │ Querit API │◄── (timeRange, countries, │ querit- │ │
60
+ │ │ /v1/search │ languages, domains…) │ search. │ │
61
+ │ └──────┬──────┘ from /querit-setup │ json │ │
62
+ │ │ └─────────┘ │
63
+ │ ▼ │
64
+ │ return cited results to the model │
65
+ │ │
66
+ │ fetch_content(url/urls, format?) │
67
+ │ │ │
68
+ │ ▼ │
69
+ │ ┌──────────────────┐ │
70
+ │ │ Querit API │ │
71
+ │ │ /v1/contents │──► markdown / text / HTML │
72
+ │ └──────────────────┘ (up to 10 URLs per call) │
73
+ └──────────────────────────────────────────────────────────┘
74
+ ```
75
+
76
+ The extension registers two tools and one slash command:
77
+
78
+ | Surface | Purpose |
79
+ |---|---|
80
+ | `web_search` | Live web search with cited results |
81
+ | `fetch_content` | Full page content (markdown, text, or HTML) for up to 10 URLs per call |
82
+ | `/querit-setup` | Interactive configuration of the API key and persistent search defaults |
83
+
84
+ ## Configuration
85
+
86
+ Run `/querit-setup` in Pi's interactive mode. Configuration is stored in `~/.pi/agent/querit-search.json` (respects `PI_CODING_AGENT_DIR`).
87
+
88
+ ### First-time setup flow
89
+
90
+ 1. **API key** — masked input prompt; validated with a one-result search request.
91
+ 2. **Search defaults** — each step can be skipped (see table below).
92
+
93
+ ### Re-configuration menu
94
+
95
+ When a key is already configured, `/querit-setup` opens a menu:
96
+
97
+ | Option | Effect |
98
+ |---|---|
99
+ | **Replace API key (full re-setup)** | Prompts for a new key, validates it, re-runs the full flow. The old key is overwritten locally; revoke it in the Querit dashboard if needed. |
100
+ | **Change search defaults** | Edits the persistent search filters without touching the saved key. |
101
+
102
+ ### Search default options
103
+
104
+ These are persistent defaults applied to every `web_search` call. They are stored under the `search` key in `querit-search.json` and are **not** per-call parameters.
105
+
106
+ | Option | Values | Default | Description |
107
+ |---|---|---|---|
108
+ | `count` | `1` – `20` | API default (`5`) | Number of results per search. Can be overridden per call via the `count` parameter. |
109
+ | `timeRange` | `d7` · `w2` · `m3` · `y1` | *(none — all time)* | Restrict results to the past 7 days, 2 weeks, 3 months, or 1 year. |
110
+ | `includeContent` | `yes` / `no` | `no` | Include sentence-level content excerpts in results for richer context. |
111
+ | `chunksPerDoc` | `1` – `3` | API default (`1`) | Content chunks requested per result. This advanced option is configured by editing `querit-search.json`; it is not exposed in the setup wizard. |
112
+ | `countries` | `argentina` · `australia` · `brazil` · `canada` · `colombia` · `france` · `germany` · `india` · `indonesia` · `japan` · `mexico` · `nigeria` · `philippines` · `south korea` · `spain` · `united kingdom` · `united states` | *(none — global)* | Bias results toward specific countries. Comma-separated, multi-select. |
113
+ | `languages` | `english` · `japanese` · `korean` · `german` · `french` · `spanish` · `portuguese` | *(none — all)* | Filter results by language. Comma-separated, multi-select. |
114
+ | `includeDomains` | domain list | *(none — unrestricted)* | **Whitelist** — only these domains return results. |
115
+ | `excludeDomains` | domain list | *(none)* | **Blacklist** — these domains are excluded. Ships with a built-in **Noise blockers** preset: `pinterest.com`, `facebook.com`, `instagram.com`, `tiktok.com`. |
116
+
117
+ ### Configuration file example
118
+
119
+ ```json
120
+ {
121
+ "apiKey": "your-api-key",
122
+ "search": {
123
+ "count": 5,
124
+ "chunksPerDoc": 1,
125
+ "timeRange": "m3",
126
+ "includeContent": false,
127
+ "countries": ["united states"],
128
+ "languages": ["english"],
129
+ "includeDomains": ["github.com"],
130
+ "excludeDomains": ["pinterest.com"]
131
+ }
132
+ }
133
+ ```
134
+
135
+ The extension applies mode `0600` on POSIX systems. On Windows, the file remains protected by the user profile's filesystem ACLs. The key is never included in tool results or logs.
136
+
137
+ For CI or ephemeral use, set `QUERIT_API_KEY`. The environment variable takes precedence when both are present.
138
+
139
+ ## Tools
140
+
141
+ ### `web_search`
142
+
143
+ Required:
144
+
145
+ - `query`
146
+
147
+ Optional:
148
+
149
+ - `count` (`1..20`) — overrides the configured default for one call (API default: `5`)
150
+
151
+ Domains, time range, countries, languages, and content excerpts are persistent defaults configured in `/querit-setup` (stored under `search` in `querit-search.json`), not per-call parameters. Skipping the domain lists leaves search unrestricted; the include list is a whitelist (only those domains return results), the exclude list is a blacklist.
152
+
153
+ Results include explicit title, URL, snippet, source metadata, and optional sentence excerpts. Duplicate and non-HTTP(S) result URLs are removed.
154
+
155
+ ### `fetch_content`
156
+
157
+ Pass `url`, `urls`, or both (at most 10 unique HTTP(S) URLs).
158
+
159
+ Optional:
160
+
161
+ - `format`: `markdown` (default), `text`, or `html`
162
+ - `crawl_timeout`: `1..60` seconds (default `10`)
163
+ - `include_metadata`: default `true`
164
+
165
+ Both tools mark remote data as untrusted, propagate Pi cancellation, enforce response-size limits, and cap model-visible output at Pi's 50KB/2000-line limit. If formatted output is truncated, the complete output is written to a uniquely named file inside a single shared temp folder (`pi-querit` in the OS temp directory). To keep search content private, that folder never accumulates files: the files a Pi process creates are deleted when that session shuts down (with a process-exit fallback), and leftovers from crashed runs are swept the next time the extension loads.
166
+
167
+ ## Development
168
+
169
+ Requires Node.js 22.19 or newer.
170
+
171
+ ```bash
172
+ npm install
173
+ npm run check
174
+ npm test
175
+ npm run pack:check
176
+ ```
177
+
178
+ A live smoke test reads the same JSON configuration (or `QUERIT_API_KEY`) and exercises both APIs without printing the key or fetched content:
179
+
180
+ ```bash
181
+ npm run test:live
182
+ ```
183
+
184
+ ## License
185
+
186
+ MIT
package/package.json CHANGED
@@ -1,63 +1,63 @@
1
- {
2
- "name": "pi-querit",
3
- "version": "1.0.3",
4
- "description": "Querit web search and content retrieval tools for the Pi coding agent",
5
- "type": "module",
6
- "license": "MIT",
7
- "author": "QUERIT PRIVATE LIMITED",
8
- "homepage": "https://www.querit.ai",
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/querit-ai/querit-plugins.git"
12
- },
13
- "bugs": {
14
- "url": "https://github.com/querit-ai/querit-plugins/issues"
15
- },
16
- "keywords": [
17
- "pi-package",
18
- "pi-extension",
19
- "querit",
20
- "web-search",
21
- "ai",
22
- "llm"
23
- ],
24
- "files": [
25
- "src",
26
- "README.md",
27
- "LICENSE"
28
- ],
29
- "pi": {
30
- "extensions": [
31
- "./src/index.ts"
32
- ]
33
- },
34
- "scripts": {
35
- "check": "tsc --noEmit",
36
- "test": "vitest run tests",
37
- "test:live": "tsx scripts/live-smoke.ts",
38
- "pack:check": "npm pack --dry-run",
39
- "prepack": "npm run check && npm test"
40
- },
41
- "peerDependencies": {
42
- "@earendil-works/pi-ai": "*",
43
- "@earendil-works/pi-coding-agent": "*",
44
- "@earendil-works/pi-tui": "*",
45
- "typebox": "*"
46
- },
47
- "devDependencies": {
48
- "@earendil-works/pi-ai": "^0.83.0",
49
- "@earendil-works/pi-coding-agent": "^0.83.0",
50
- "@earendil-works/pi-tui": "^0.83.0",
51
- "@types/node": "^24.0.0",
52
- "tsx": "^4.20.0",
53
- "typebox": "^1.3.7",
54
- "typescript": "^5.9.0",
55
- "vitest": "^4.1.0"
56
- },
57
- "engines": {
58
- "node": ">=22.19.0"
59
- },
60
- "publishConfig": {
61
- "access": "public"
62
- }
63
- }
1
+ {
2
+ "name": "pi-querit",
3
+ "version": "1.1.0",
4
+ "description": "Querit web search and content retrieval tools for the Pi coding agent",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "QUERIT PRIVATE LIMITED",
8
+ "homepage": "https://www.querit.ai",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/querit-ai/querit-plugins.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/querit-ai/querit-plugins/issues"
15
+ },
16
+ "keywords": [
17
+ "pi-package",
18
+ "pi-extension",
19
+ "querit",
20
+ "web-search",
21
+ "ai",
22
+ "llm"
23
+ ],
24
+ "files": [
25
+ "src",
26
+ "README.md",
27
+ "LICENSE"
28
+ ],
29
+ "pi": {
30
+ "extensions": [
31
+ "./src/index.ts"
32
+ ]
33
+ },
34
+ "scripts": {
35
+ "check": "tsc --noEmit",
36
+ "test": "vitest run tests",
37
+ "test:live": "tsx scripts/live-smoke.ts",
38
+ "pack:check": "npm pack --dry-run",
39
+ "prepack": "npm run check && npm test"
40
+ },
41
+ "peerDependencies": {
42
+ "@earendil-works/pi-ai": "*",
43
+ "@earendil-works/pi-coding-agent": "*",
44
+ "@earendil-works/pi-tui": "*",
45
+ "typebox": "*"
46
+ },
47
+ "devDependencies": {
48
+ "@earendil-works/pi-ai": "^0.83.0",
49
+ "@earendil-works/pi-coding-agent": "^0.83.0",
50
+ "@earendil-works/pi-tui": "^0.83.0",
51
+ "@types/node": "^24.0.0",
52
+ "tsx": "^4.20.0",
53
+ "typebox": "^1.3.7",
54
+ "typescript": "^5.9.0",
55
+ "vitest": "^4.1.0"
56
+ },
57
+ "engines": {
58
+ "node": ">=22.19.0"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
62
+ }
63
+ }
package/src/config.ts CHANGED
@@ -4,20 +4,6 @@ import { getAgentDir, withFileMutationQueue } from "@earendil-works/pi-coding-ag
4
4
 
5
5
  export const QUERIT_CONFIG_FILE = "querit-search.json";
6
6
 
7
- export type SearchWorkflow = "raw" | "summary";
8
-
9
- export const THINKING_LEVEL_VALUES = [
10
- "off",
11
- "minimal",
12
- "low",
13
- "medium",
14
- "high",
15
- "xhigh",
16
- "max",
17
- ] as const;
18
-
19
- export type QueritThinkingLevel = (typeof THINKING_LEVEL_VALUES)[number];
20
-
21
7
  export const COUNTRY_VALUES = [
22
8
  "argentina",
23
9
  "australia",
@@ -64,16 +50,10 @@ export interface QueritSearchDefaults {
64
50
 
65
51
  export interface QueritConfig {
66
52
  apiKey: string;
67
- defaultWorkflow?: SearchWorkflow;
68
- summaryModel?: string;
69
- summaryThinkingLevel?: QueritThinkingLevel;
70
53
  search?: QueritSearchDefaults;
71
54
  }
72
55
 
73
56
  export interface QueritConfigSettings {
74
- defaultWorkflow?: SearchWorkflow;
75
- summaryModel?: string;
76
- summaryThinkingLevel?: QueritThinkingLevel;
77
57
  search?: QueritSearchDefaults;
78
58
  }
79
59
 
@@ -108,20 +88,10 @@ export async function loadQueritConfig(configPath = getQueritConfigPath()): Prom
108
88
  throw new Error(`Querit configuration at ${configPath} must contain a non-empty "apiKey" string.`);
109
89
  }
110
90
 
111
- const defaultWorkflow = parsed.defaultWorkflow === "raw" || parsed.defaultWorkflow === "summary"
112
- ? parsed.defaultWorkflow
113
- : undefined;
114
- const summaryModel = typeof parsed.summaryModel === "string" && isModelReference(parsed.summaryModel)
115
- ? parsed.summaryModel.trim()
116
- : undefined;
117
- const summaryThinkingLevel = isThinkingLevel(parsed.summaryThinkingLevel) ? parsed.summaryThinkingLevel : undefined;
118
91
  const search = parseSearchDefaults(parsed.search);
119
92
 
120
93
  return {
121
94
  apiKey: parsed.apiKey.trim(),
122
- ...(defaultWorkflow === undefined ? {} : { defaultWorkflow }),
123
- ...(summaryModel === undefined ? {} : { summaryModel }),
124
- ...(summaryThinkingLevel === undefined ? {} : { summaryThinkingLevel }),
125
95
  ...(search === undefined ? {} : { search }),
126
96
  };
127
97
  }
@@ -141,23 +111,9 @@ export async function saveQueritConfig(
141
111
  ): Promise<void> {
142
112
  const normalizedKey = apiKey.trim();
143
113
  if (!normalizedKey) throw new Error("Cannot save an empty Querit API key.");
144
- if (settings.defaultWorkflow !== undefined && settings.defaultWorkflow !== "raw" && settings.defaultWorkflow !== "summary") {
145
- throw new Error("Cannot save an invalid Querit default workflow.");
146
- }
147
- const summaryModel = settings.summaryModel?.trim();
148
- if (summaryModel !== undefined && !isModelReference(summaryModel)) {
149
- throw new Error("Cannot save an invalid Querit summary model reference.");
150
- }
151
- const summaryThinkingLevel = settings.summaryThinkingLevel;
152
- if (summaryThinkingLevel !== undefined && !isThinkingLevel(summaryThinkingLevel)) {
153
- throw new Error("Cannot save an invalid Querit summary thinking level.");
154
- }
155
114
  const search = settings.search === undefined ? undefined : parseSearchDefaults(settings.search);
156
115
  const serializedConfig: QueritConfig = {
157
116
  apiKey: normalizedKey,
158
- ...(settings.defaultWorkflow === undefined ? {} : { defaultWorkflow: settings.defaultWorkflow }),
159
- ...(summaryModel === undefined ? {} : { summaryModel }),
160
- ...(summaryThinkingLevel === undefined ? {} : { summaryThinkingLevel }),
161
117
  ...(search === undefined ? {} : { search }),
162
118
  };
163
119
 
@@ -179,16 +135,6 @@ export async function saveQueritConfig(
179
135
  });
180
136
  }
181
137
 
182
- function isModelReference(value: string): boolean {
183
- const normalized = value.trim();
184
- const slash = normalized.indexOf("/");
185
- return slash > 0 && slash < normalized.length - 1 && !/\s/u.test(normalized);
186
- }
187
-
188
- function isThinkingLevel(value: unknown): value is QueritThinkingLevel {
189
- return typeof value === "string" && (THINKING_LEVEL_VALUES as readonly string[]).includes(value);
190
- }
191
-
192
138
  export function parseSearchDefaults(value: unknown): QueritSearchDefaults | undefined {
193
139
  if (!isRecord(value)) return undefined;
194
140
  const defaults: QueritSearchDefaults = {};