opencode-querit 1.0.0 → 1.0.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-zh.md +3 -3
- package/README.md +3 -3
- package/lib/config.d.ts +9 -4
- package/lib/config.js +13 -6
- package/lib/index.js +2 -2
- package/package.json +1 -1
package/README-zh.md
CHANGED
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
2. 按优先级配置 Querit API key:
|
|
34
|
-
-
|
|
35
|
-
- `
|
|
34
|
+
- `QUERIT_API_KEY` 环境变量(默认;可通过 `apiKeyEnv` 修改变量名)——环境变量始终优先,导出一次即可覆盖所有插件配置,或
|
|
35
|
+
- 插件选项元组中的 `apiKey`(`["opencode-querit", { "apiKey": "..." }]`;最不推荐,密钥不应写入配置文件)。
|
|
36
36
|
3. 重启 OpenCode。未配置 key 时工具调用会失败,并给出两种配置方式的提示。
|
|
37
37
|
|
|
38
38
|
两个工具为 `web_search`(带引用的实时搜索)和 `web_fetch`(抓取最多 10 个 URL 的完整页面内容)。它们是新增工具,不会覆盖 OpenCode 自带的 `websearch`/`webfetch`;如需引导模型使用 Querit,可在 [权限](https://opencode.ai/docs/permissions/) 中限制内置工具。
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
|
|
58
58
|
| Key | 默认值 | 含义 |
|
|
59
59
|
|---|---|---|
|
|
60
|
-
| `apiKey` | 无 | 字面量 Querit API key。优先使用 `apiKeyEnv
|
|
60
|
+
| `apiKey` | 无 | 字面量 Querit API key。优先使用 `apiKeyEnv`,密钥不要写进配置;两者同时设置时,`apiKeyEnv` 环境变量始终优先。 |
|
|
61
61
|
| `apiKeyEnv` | `QUERIT_API_KEY` | 存放 Querit API key 的环境变量名。未配置时工具调用失败并给出提示。 |
|
|
62
62
|
| `baseURL` | `https://api.querit.ai` | Querit API 基础地址;自动追加 `/v1/search` 与 `/v1/contents`。也支持 `$QUERIT_BASE_URL` 环境变量回退。 |
|
|
63
63
|
| `timeoutMs` | `70000` | 单次请求超时(毫秒,最小 1000)。 |
|
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ Sign up on [Querit.ai](https://www.querit.ai) to get an API key with **1,000 fre
|
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
2. Configure your Querit API key in priority order:
|
|
21
|
-
- `
|
|
22
|
-
-
|
|
21
|
+
- the `QUERIT_API_KEY` environment variable (default; override the name with `apiKeyEnv`) — the environment always wins, so one exported key overrides plugin options everywhere, or
|
|
22
|
+
- `apiKey` in the plugin options tuple (`["opencode-querit", { "apiKey": "..." }]`; least preferred — secrets should not live in config files).
|
|
23
23
|
3. Restart OpenCode. A tool call without a key fails with a message that spells out both options.
|
|
24
24
|
|
|
25
25
|
The two tools are `web_search` (live web search with cited results) and `web_fetch` (full page content for up to 10 URLs). They are additive: OpenCode's built-in `websearch`/`webfetch` tools stay available. To steer the model to Querit, mention the tools or restrict the built-ins through [permissions](https://opencode.ai/docs/permissions/).
|
|
@@ -57,7 +57,7 @@ Options go in the plugin tuple in `opencode.json`:
|
|
|
57
57
|
|
|
58
58
|
| Key | Default | Meaning |
|
|
59
59
|
|---|---|---|
|
|
60
|
-
| `apiKey` | omitted | Literal Querit API key. Prefer `apiKeyEnv` so no secret enters configuration
|
|
60
|
+
| `apiKey` | omitted | Literal Querit API key. Prefer `apiKeyEnv` so no secret enters configuration. The `apiKeyEnv` environment variable always wins when both are set. |
|
|
61
61
|
| `apiKeyEnv` | `QUERIT_API_KEY` | Environment variable holding the Querit API key. A missing value fails the tool call with an actionable message. |
|
|
62
62
|
| `baseURL` | `https://api.querit.ai` | Querit API base; `/v1/search` and `/v1/contents` are appended. Falls back to `$QUERIT_BASE_URL`. |
|
|
63
63
|
| `timeoutMs` | `70000` | Per-request timeout in ms (minimum 1000). |
|
package/lib/config.d.ts
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* file); every value is validated, normalized, and defaulted here so the
|
|
5
5
|
* tools only ever see a fully resolved `QueritConfig`.
|
|
6
6
|
*
|
|
7
|
-
* API-key resolution happens per tool call in priority order:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* API-key resolution happens per tool call in priority order: the
|
|
8
|
+
* environment variable named by `apiKeyEnv` (default `QUERIT_API_KEY`), then
|
|
9
|
+
* a literal `apiKey` option. The environment wins so a single exported key
|
|
10
|
+
* overrides plugin config everywhere.
|
|
10
11
|
* @module opencode-querit/config
|
|
11
12
|
*/
|
|
12
13
|
export declare const COUNTRY_VALUES: readonly ["argentina", "australia", "brazil", "canada", "colombia", "france", "germany", "india", "indonesia", "japan", "mexico", "nigeria", "philippines", "south korea", "spain", "united kingdom", "united states"];
|
|
@@ -91,5 +92,9 @@ export declare function normalizeHostname(value: string): string | undefined;
|
|
|
91
92
|
* silently changing behavior.
|
|
92
93
|
*/
|
|
93
94
|
export declare function resolveConfig(options?: OpenCodeQueritOptions, env?: NodeJS.ProcessEnv): QueritConfig;
|
|
94
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Resolve the Querit API key for one operation: the environment variable
|
|
97
|
+
* named by `apiKeyEnv` first (so `QUERIT_API_KEY` overrides everything for
|
|
98
|
+
* testing), then the literal `apiKey` plugin option.
|
|
99
|
+
*/
|
|
95
100
|
export declare function resolveQueritApiKey(config: QueritConfig, env?: NodeJS.ProcessEnv): string | undefined;
|
package/lib/config.js
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* file); every value is validated, normalized, and defaulted here so the
|
|
5
5
|
* tools only ever see a fully resolved `QueritConfig`.
|
|
6
6
|
*
|
|
7
|
-
* API-key resolution happens per tool call in priority order:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* API-key resolution happens per tool call in priority order: the
|
|
8
|
+
* environment variable named by `apiKeyEnv` (default `QUERIT_API_KEY`), then
|
|
9
|
+
* a literal `apiKey` option. The environment wins so a single exported key
|
|
10
|
+
* overrides plugin config everywhere.
|
|
10
11
|
* @module opencode-querit/config
|
|
11
12
|
*/
|
|
12
13
|
export const COUNTRY_VALUES = [
|
|
@@ -153,12 +154,18 @@ export function resolveConfig(options = {}, env = process.env) {
|
|
|
153
154
|
maxOutputChars,
|
|
154
155
|
};
|
|
155
156
|
}
|
|
156
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* Resolve the Querit API key for one operation: the environment variable
|
|
159
|
+
* named by `apiKeyEnv` first (so `QUERIT_API_KEY` overrides everything for
|
|
160
|
+
* testing), then the literal `apiKey` plugin option.
|
|
161
|
+
*/
|
|
157
162
|
export function resolveQueritApiKey(config, env = process.env) {
|
|
163
|
+
const ambient = env[config.apiKeyEnv]?.trim();
|
|
164
|
+
if (ambient !== undefined && ambient.length > 0)
|
|
165
|
+
return ambient;
|
|
158
166
|
if (config.apiKey !== undefined && config.apiKey.length > 0)
|
|
159
167
|
return config.apiKey;
|
|
160
|
-
|
|
161
|
-
return ambient !== undefined && ambient.length > 0 ? ambient : undefined;
|
|
168
|
+
return undefined;
|
|
162
169
|
}
|
|
163
170
|
function normalizeEnumList(values, allowed, field) {
|
|
164
171
|
if (values === undefined)
|
package/lib/index.js
CHANGED
|
@@ -42,7 +42,7 @@ export const QueritPlugin = async (_input, rawOptions = {}) => {
|
|
|
42
42
|
const config = resolveConfig(options);
|
|
43
43
|
const apiKey = resolveQueritApiKey(config);
|
|
44
44
|
if (!apiKey) {
|
|
45
|
-
throw new Error(`Querit is not configured. Set the ${config.apiKeyEnv} environment variable or pass "apiKey" in the opencode-querit plugin options.`);
|
|
45
|
+
throw new Error(`Querit is not configured. Set the ${config.apiKeyEnv} environment variable (recommended) or pass "apiKey" in the opencode-querit plugin options.`);
|
|
46
46
|
}
|
|
47
47
|
const query = args.query.trim();
|
|
48
48
|
if (!query)
|
|
@@ -98,7 +98,7 @@ export const QueritPlugin = async (_input, rawOptions = {}) => {
|
|
|
98
98
|
const config = resolveConfig(options);
|
|
99
99
|
const apiKey = resolveQueritApiKey(config);
|
|
100
100
|
if (!apiKey) {
|
|
101
|
-
throw new Error(`Querit is not configured. Set the ${config.apiKeyEnv} environment variable or pass "apiKey" in the opencode-querit plugin options.`);
|
|
101
|
+
throw new Error(`Querit is not configured. Set the ${config.apiKeyEnv} environment variable (recommended) or pass "apiKey" in the opencode-querit plugin options.`);
|
|
102
102
|
}
|
|
103
103
|
const client = createClient(apiKey, config, options);
|
|
104
104
|
const response = await client.contents({
|