dsh-querit 1.0.0 → 1.0.2

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 CHANGED
@@ -76,8 +76,8 @@ dsh plugin --profile web add ./dsh-querit-<版本号>.tgz
76
76
 
77
77
  | 键 | 默认值 | 说明 |
78
78
  |---|---|---|
79
- | `apiKey` | 无 | 字面量 Querit API key(优先用 `apiKeyEnv`,避免密钥进配置文件) |
80
- | `apiKeyEnv` | `QUERIT_API_KEY` | 每次调用经凭据服务解析的凭据引用;缺失时调用失败为 `WEB_PROVIDER_CREDENTIAL_MISSING` |
79
+ | `apiKey` | 无 | 字面量 Querit API key(优先用 `apiKeyEnv`,避免密钥进配置文件;两者同时设置时 `apiKeyEnv` 环境变量优先) |
80
+ | `apiKeyEnv` | `QUERIT_API_KEY` | 每次调用按“启动环境中的同名变量 → 凭据服务 → 行内 `apiKey`”解析;缺失时调用失败为 `WEB_PROVIDER_CREDENTIAL_MISSING` |
81
81
  | `baseURL` | `https://api.querit.ai` | API 基地址;可被 `$QUERIT_BASE_URL` 环境变量覆盖 |
82
82
  | `timeoutMs` | `70000` | 单请求超时(毫秒) |
83
83
  | `count` | `5` | 无 `maxResults` 约束时的结果数(1–20) |
package/README.md CHANGED
@@ -19,7 +19,7 @@ If the plugin loads without any resolvable key, the host log prints a one-time w
19
19
 
20
20
  There is no settings-page UI for out-of-tree plugins in the current harness version (the web settings API serves a fixed namespace whitelist), so all configuration is the composition patch plus the credentials store.
21
21
 
22
- This is an **implementation** package: it registers one search provider and one fetch provider into `ctx.web`, resolves the API key per operation through the optional `ctx.credentials` seam (environment fallback), and reuses [`@deepseek-ai/dsh-tool-web`](https://www.npmjs.com/package/@deepseek-ai/dsh-tool-web)'s `applyWebFetchTool` to register the model-facing `web_fetch` tool. That last step exists because in the web app the host `tool-web` row is disabled and the shipped presets keep `fetch: false` — this package is the one place that turns page retrieval on. Both providers share the stable id `querit`.
22
+ This is an **implementation** package: it registers one search provider and one fetch provider into `ctx.web`. Per operation, it resolves the API key from the launching environment first, then the optional `ctx.credentials` seam, then literal config. It does not register the model-facing `web_search` tool (the agent preset does); by default, it reuses [`@deepseek-ai/dsh-tool-web`](https://www.npmjs.com/package/@deepseek-ai/dsh-tool-web)'s `applyWebFetchTool` to register `web_fetch`. That last step exists because in the web app the host `tool-web` row is disabled and the shipped presets keep `fetch: false` — this package is the one place that turns page retrieval on. Both providers share the stable id `querit`.
23
23
 
24
24
  ## Install and update
25
25
 
@@ -82,8 +82,8 @@ If a preset ever registers `web_fetch` itself (its `tool-web` row with `fetch: t
82
82
 
83
83
  | Key | Default | Meaning |
84
84
  |---|---|---|
85
- | `apiKey` | omitted | Literal Querit API key. Prefer `apiKeyEnv` so no secret enters configuration; a non-empty literal wins. |
86
- | `apiKeyEnv` | `QUERIT_API_KEY` | Credential reference resolved per operation through `ctx.credentials`, or from the process environment when that seam is absent. A missing value fails the call as `WEB_PROVIDER_CREDENTIAL_MISSING`. |
85
+ | `apiKey` | omitted | Literal Querit API key. Prefer `apiKeyEnv` so no secret enters configuration. The `apiKeyEnv` environment variable wins when both are set. |
86
+ | `apiKeyEnv` | `QUERIT_API_KEY` | Credential reference resolved per operation from the launching environment first, then through `ctx.credentials`; a literal `apiKey` is the final fallback. A missing value fails the call as `WEB_PROVIDER_CREDENTIAL_MISSING`. |
87
87
  | `baseURL` | `https://api.querit.ai` | Querit API base; `/v1/search` and `/v1/contents` are appended. Falls back to `$QUERIT_BASE_URL` from any environment layer. An unparseable value makes both providers unavailable. |
88
88
  | `timeoutMs` | `70000` | Per-request timeout in ms (minimum 1000). |
89
89
  | `count` | `5` | Result count used when the seam passes no `maxResults` bound (1–20; the API caps at 20). The `dsh-tool-web` layer always bounds searches, so this mainly serves direct seam callers. |
package/lib/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Register Querit-backed search and fetch providers in `ctx.web`.
3
3
  * Both providers call the public Querit API (`POST /v1/search`,
4
- * `POST /v1/contents`) with a Bearer key resolved per operation through the
5
- * optional `ctx.credentials` seam, falling back to the launching environment.
6
- * The model-facing `web_search` / `web_fetch` tools keep routing through the
7
- * seam; this package never registers a tool.
4
+ * `POST /v1/contents`) with a Bearer key resolved per operation from the
5
+ * launching environment, then optional `ctx.credentials`, then literal config.
6
+ * The agent preset registers model-facing `web_search`; this package does not.
7
+ * By default, it reuses the official `applyWebFetchTool` helper to register
8
+ * `web_fetch`, and both tools route through the seam.
8
9
  * @module dsh-querit
9
10
  */
10
11
  import type { Context } from "@deepseek-ai/cordis";
@@ -76,9 +77,11 @@ export declare function resolveOptions(ctx: Context, config: Config): QueritProv
76
77
  /** Register both Querit providers with `ctx.web`, the `web_fetch` tool, and the first-load key check. */
77
78
  export declare function apply(ctx: Context, config: Config): Promise<void>;
78
79
  /**
79
- * Resolve the Querit API key for one operation in priority order: literal row
80
- * `apiKey`, then the credentials service (which itself reads the inherited
81
- * environment before the managed document), then the launching environment.
80
+ * Resolve the Querit API key for one operation in priority order: the
81
+ * launching environment (so one exported `QUERIT_API_KEY` overrides
82
+ * everything for testing), then the credentials service (which itself reads
83
+ * the inherited environment before the managed document), then a literal row
84
+ * `apiKey`.
82
85
  */
83
86
  export declare function resolveQueritApiKey(ctx: Context, apiKeyEnv: CredentialRef, literalApiKey: string | undefined): Promise<string | undefined>;
84
87
  /**
package/lib/index.js CHANGED
@@ -49,7 +49,6 @@ export function resolveOptions(ctx, config) {
49
49
  : undefined;
50
50
  const environment = launchEnvironmentOf(ctx);
51
51
  return {
52
- ...(literalApiKey === undefined ? {} : { apiKey: literalApiKey }),
53
52
  resolveApiKey: () => resolveQueritApiKey(ctx, apiKeyEnv, literalApiKey),
54
53
  apiKeyEnv,
55
54
  baseURL: (config.baseURL ?? environment.get(BASE_URL_ENV)?.value ?? QUERIT_API_BASE_URL).replace(/\/+$/, ""),
@@ -107,18 +106,23 @@ export async function apply(ctx, config) {
107
106
  }
108
107
  }
109
108
  /**
110
- * Resolve the Querit API key for one operation in priority order: literal row
111
- * `apiKey`, then the credentials service (which itself reads the inherited
112
- * environment before the managed document), then the launching environment.
109
+ * Resolve the Querit API key for one operation in priority order: the
110
+ * launching environment (so one exported `QUERIT_API_KEY` overrides
111
+ * everything for testing), then the credentials service (which itself reads
112
+ * the inherited environment before the managed document), then a literal row
113
+ * `apiKey`.
113
114
  */
114
115
  export async function resolveQueritApiKey(ctx, apiKeyEnv, literalApiKey) {
115
- if (literalApiKey !== undefined && literalApiKey.length > 0)
116
- return literalApiKey;
117
- const credentials = ctx.get("credentials");
118
- if (credentials !== undefined)
119
- return (await credentials.resolve(apiKeyEnv))?.value;
120
116
  const ambient = launchEnvironmentOf(ctx).get(apiKeyEnv);
121
- return ambient !== undefined && ambient.value.length > 0 ? ambient.value : undefined;
117
+ if (ambient !== undefined && ambient.value.length > 0)
118
+ return ambient.value;
119
+ const credentials = ctx.get("credentials");
120
+ if (credentials !== undefined) {
121
+ const stored = await credentials.resolve(apiKeyEnv);
122
+ if (stored !== undefined && stored.value.length > 0)
123
+ return stored.value;
124
+ }
125
+ return literalApiKey !== undefined && literalApiKey.length > 0 ? literalApiKey : undefined;
122
126
  }
123
127
  /**
124
128
  * Reject a resolved settings section this plugin could not act on, for
package/lib/provider.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebError } from "@deepseek-ai/dsh-web";
2
- import { DEFAULT_REQUEST_TIMEOUT_MS, QueritApiError, QueritClient, } from "./client.js";
2
+ import { QueritApiError, QueritClient, } from "./client.js";
3
3
  /** Stable id both providers register under. */
4
4
  export const QUERIT_PROVIDER_ID = "querit";
5
5
  export const COUNTRY_VALUES = [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-querit",
3
3
  "description": "Querit-backed search and fetch providers for the DeepSeek Harness web capability seam (ctx.web)",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",