pi-all-search 1.0.12 → 1.0.13
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/extensions/index.ts +3 -3
- package/package.json +1 -1
- package/src/config.ts +18 -11
package/extensions/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { registerWebSearchTool } from "
|
|
3
|
-
import { registerExtractTool } from "
|
|
4
|
-
import { registerGetSubDomainsTool } from "
|
|
2
|
+
import { registerWebSearchTool } from "../src/web-search.js";
|
|
3
|
+
import { registerExtractTool } from "../src/extract.js";
|
|
4
|
+
import { registerGetSubDomainsTool } from "../src/get-sub-domains.js";
|
|
5
5
|
|
|
6
6
|
export default function (pi: ExtensionAPI) {
|
|
7
7
|
registerWebSearchTool(pi);
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -7,27 +7,34 @@ const CONFIG_PATH = join(homedir(), ".pi", "pi-all-search.json");
|
|
|
7
7
|
|
|
8
8
|
export interface SearchConfig {
|
|
9
9
|
apiKeys: Record<string, string>;
|
|
10
|
+
provider?: string;
|
|
11
|
+
cacheTtlMs?: number;
|
|
12
|
+
maxResults?: number;
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
export function loadConfig(): SearchConfig {
|
|
13
16
|
const apiKeys: Record<string, string> = {};
|
|
17
|
+
const env = process.env;
|
|
18
|
+
|
|
19
|
+
for (const meta of PROVIDERS) {
|
|
20
|
+
const key = env[meta.envVar];
|
|
21
|
+
if (key) apiKeys[meta.name] = key;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let provider: string | undefined;
|
|
25
|
+
let cacheTtlMs: number | undefined;
|
|
26
|
+
let maxResults: number | undefined;
|
|
14
27
|
|
|
15
28
|
try {
|
|
16
29
|
const config = JSON.parse(readFileSync(CONFIG_PATH, "utf8"));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
30
|
+
provider = config.provider;
|
|
31
|
+
cacheTtlMs = config.cacheTtlMs;
|
|
32
|
+
maxResults = config.maxResults;
|
|
21
33
|
} catch {
|
|
22
|
-
//
|
|
23
|
-
const env = process.env;
|
|
24
|
-
for (const meta of PROVIDERS) {
|
|
25
|
-
const key = env[meta.envVar];
|
|
26
|
-
if (key) apiKeys[meta.name] = key;
|
|
27
|
-
}
|
|
34
|
+
// use defaults
|
|
28
35
|
}
|
|
29
36
|
|
|
30
|
-
return { apiKeys };
|
|
37
|
+
return { apiKeys, provider, cacheTtlMs, maxResults };
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
export function resolveApiKey(name: string, envVar: string, config: SearchConfig): string | undefined {
|