@nodetool-ai/agents 0.7.0-rc.11
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/dist/agent-executor.d.ts +62 -0
- package/dist/agent-executor.d.ts.map +1 -0
- package/dist/agent-executor.js +324 -0
- package/dist/agent-executor.js.map +1 -0
- package/dist/agent-step-executor.d.ts +28 -0
- package/dist/agent-step-executor.d.ts.map +1 -0
- package/dist/agent-step-executor.js +99 -0
- package/dist/agent-step-executor.js.map +1 -0
- package/dist/agent-workflow-runner.d.ts +31 -0
- package/dist/agent-workflow-runner.d.ts.map +1 -0
- package/dist/agent-workflow-runner.js +124 -0
- package/dist/agent-workflow-runner.js.map +1 -0
- package/dist/agent.d.ts +115 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +587 -0
- package/dist/agent.js.map +1 -0
- package/dist/base-agent.d.ts +42 -0
- package/dist/base-agent.d.ts.map +1 -0
- package/dist/base-agent.js +29 -0
- package/dist/base-agent.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -0
- package/dist/graph-builder.d.ts +49 -0
- package/dist/graph-builder.d.ts.map +1 -0
- package/dist/graph-builder.js +206 -0
- package/dist/graph-builder.js.map +1 -0
- package/dist/graph-planner.d.ts +56 -0
- package/dist/graph-planner.d.ts.map +1 -0
- package/dist/graph-planner.js +311 -0
- package/dist/graph-planner.js.map +1 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +81 -0
- package/dist/index.js.map +1 -0
- package/dist/js-sandbox.d.ts +84 -0
- package/dist/js-sandbox.d.ts.map +1 -0
- package/dist/js-sandbox.js +654 -0
- package/dist/js-sandbox.js.map +1 -0
- package/dist/multi-mode-agent.d.ts +86 -0
- package/dist/multi-mode-agent.d.ts.map +1 -0
- package/dist/multi-mode-agent.js +476 -0
- package/dist/multi-mode-agent.js.map +1 -0
- package/dist/output-format.d.ts +10 -0
- package/dist/output-format.d.ts.map +1 -0
- package/dist/output-format.js +17 -0
- package/dist/output-format.js.map +1 -0
- package/dist/parallel-task-executor.d.ts +87 -0
- package/dist/parallel-task-executor.d.ts.map +1 -0
- package/dist/parallel-task-executor.js +332 -0
- package/dist/parallel-task-executor.js.map +1 -0
- package/dist/prompts/graph-planner-prompt.d.ts +48 -0
- package/dist/prompts/graph-planner-prompt.d.ts.map +1 -0
- package/dist/prompts/graph-planner-prompt.js +180 -0
- package/dist/prompts/graph-planner-prompt.js.map +1 -0
- package/dist/reject-agentic-provider.d.ts +21 -0
- package/dist/reject-agentic-provider.d.ts.map +1 -0
- package/dist/reject-agentic-provider.js +32 -0
- package/dist/reject-agentic-provider.js.map +1 -0
- package/dist/simple-agent.d.ts +29 -0
- package/dist/simple-agent.d.ts.map +1 -0
- package/dist/simple-agent.js +54 -0
- package/dist/simple-agent.js.map +1 -0
- package/dist/step-executor.d.ts +162 -0
- package/dist/step-executor.d.ts.map +1 -0
- package/dist/step-executor.js +1114 -0
- package/dist/step-executor.js.map +1 -0
- package/dist/sub-agent-planner.d.ts +33 -0
- package/dist/sub-agent-planner.d.ts.map +1 -0
- package/dist/sub-agent-planner.js +203 -0
- package/dist/sub-agent-planner.js.map +1 -0
- package/dist/task-executor.d.ts +89 -0
- package/dist/task-executor.d.ts.map +1 -0
- package/dist/task-executor.js +359 -0
- package/dist/task-executor.js.map +1 -0
- package/dist/task-planner.d.ts +44 -0
- package/dist/task-planner.d.ts.map +1 -0
- package/dist/task-planner.js +532 -0
- package/dist/task-planner.js.map +1 -0
- package/dist/team/db-task-board.d.ts +54 -0
- package/dist/team/db-task-board.d.ts.map +1 -0
- package/dist/team/db-task-board.js +361 -0
- package/dist/team/db-task-board.js.map +1 -0
- package/dist/team/edge-message-bus.d.ts +51 -0
- package/dist/team/edge-message-bus.d.ts.map +1 -0
- package/dist/team/edge-message-bus.js +169 -0
- package/dist/team/edge-message-bus.js.map +1 -0
- package/dist/team/edge-task-board.d.ts +77 -0
- package/dist/team/edge-task-board.d.ts.map +1 -0
- package/dist/team/edge-task-board.js +140 -0
- package/dist/team/edge-task-board.js.map +1 -0
- package/dist/team/index.d.ts +16 -0
- package/dist/team/index.d.ts.map +1 -0
- package/dist/team/index.js +17 -0
- package/dist/team/index.js.map +1 -0
- package/dist/team/message-bus.d.ts +58 -0
- package/dist/team/message-bus.d.ts.map +1 -0
- package/dist/team/message-bus.js +151 -0
- package/dist/team/message-bus.js.map +1 -0
- package/dist/team/task-board.d.ts +106 -0
- package/dist/team/task-board.d.ts.map +1 -0
- package/dist/team/task-board.js +370 -0
- package/dist/team/task-board.js.map +1 -0
- package/dist/team/team-executor.d.ts +72 -0
- package/dist/team/team-executor.d.ts.map +1 -0
- package/dist/team/team-executor.js +466 -0
- package/dist/team/team-executor.js.map +1 -0
- package/dist/team/team-tools.d.ts +252 -0
- package/dist/team/team-tools.d.ts.map +1 -0
- package/dist/team/team-tools.js +412 -0
- package/dist/team/team-tools.js.map +1 -0
- package/dist/team/types.d.ts +198 -0
- package/dist/team/types.d.ts.map +1 -0
- package/dist/team/types.js +8 -0
- package/dist/team/types.js.map +1 -0
- package/dist/tools/add-edge-tool.d.ts +18 -0
- package/dist/tools/add-edge-tool.d.ts.map +1 -0
- package/dist/tools/add-edge-tool.js +92 -0
- package/dist/tools/add-edge-tool.js.map +1 -0
- package/dist/tools/add-node-tool.d.ts +22 -0
- package/dist/tools/add-node-tool.d.ts.map +1 -0
- package/dist/tools/add-node-tool.js +128 -0
- package/dist/tools/add-node-tool.js.map +1 -0
- package/dist/tools/asset-tools.d.ts +58 -0
- package/dist/tools/asset-tools.d.ts.map +1 -0
- package/dist/tools/asset-tools.js +191 -0
- package/dist/tools/asset-tools.js.map +1 -0
- package/dist/tools/base-tool.d.ts +25 -0
- package/dist/tools/base-tool.d.ts.map +1 -0
- package/dist/tools/base-tool.js +24 -0
- package/dist/tools/base-tool.js.map +1 -0
- package/dist/tools/browser-tools.d.ts +32 -0
- package/dist/tools/browser-tools.d.ts.map +1 -0
- package/dist/tools/browser-tools.js +208 -0
- package/dist/tools/browser-tools.js.map +1 -0
- package/dist/tools/calculator-tool.d.ts +24 -0
- package/dist/tools/calculator-tool.d.ts.map +1 -0
- package/dist/tools/calculator-tool.js +64 -0
- package/dist/tools/calculator-tool.js.map +1 -0
- package/dist/tools/claude-code-tools.d.ts +96 -0
- package/dist/tools/claude-code-tools.d.ts.map +1 -0
- package/dist/tools/claude-code-tools.js +463 -0
- package/dist/tools/claude-code-tools.js.map +1 -0
- package/dist/tools/code-tools.d.ts +26 -0
- package/dist/tools/code-tools.d.ts.map +1 -0
- package/dist/tools/code-tools.js +82 -0
- package/dist/tools/code-tools.js.map +1 -0
- package/dist/tools/control-tool.d.ts +47 -0
- package/dist/tools/control-tool.d.ts.map +1 -0
- package/dist/tools/control-tool.js +101 -0
- package/dist/tools/control-tool.js.map +1 -0
- package/dist/tools/create-plan-tool.d.ts +29 -0
- package/dist/tools/create-plan-tool.d.ts.map +1 -0
- package/dist/tools/create-plan-tool.js +355 -0
- package/dist/tools/create-plan-tool.js.map +1 -0
- package/dist/tools/create-task-tool.d.ts +28 -0
- package/dist/tools/create-task-tool.d.ts.map +1 -0
- package/dist/tools/create-task-tool.js +254 -0
- package/dist/tools/create-task-tool.js.map +1 -0
- package/dist/tools/dataseo-tools.d.ts +38 -0
- package/dist/tools/dataseo-tools.d.ts.map +1 -0
- package/dist/tools/dataseo-tools.js +329 -0
- package/dist/tools/dataseo-tools.js.map +1 -0
- package/dist/tools/email-tools.d.ts +76 -0
- package/dist/tools/email-tools.d.ts.map +1 -0
- package/dist/tools/email-tools.js +259 -0
- package/dist/tools/email-tools.js.map +1 -0
- package/dist/tools/filesystem-tools.d.ts +77 -0
- package/dist/tools/filesystem-tools.d.ts.map +1 -0
- package/dist/tools/filesystem-tools.js +334 -0
- package/dist/tools/filesystem-tools.js.map +1 -0
- package/dist/tools/find-model-tool.d.ts +25 -0
- package/dist/tools/find-model-tool.d.ts.map +1 -0
- package/dist/tools/find-model-tool.js +236 -0
- package/dist/tools/find-model-tool.js.map +1 -0
- package/dist/tools/finish-graph-tool.d.ts +23 -0
- package/dist/tools/finish-graph-tool.d.ts.map +1 -0
- package/dist/tools/finish-graph-tool.js +46 -0
- package/dist/tools/finish-graph-tool.js.map +1 -0
- package/dist/tools/finish-step-tool.d.ts +16 -0
- package/dist/tools/finish-step-tool.d.ts.map +1 -0
- package/dist/tools/finish-step-tool.js +68 -0
- package/dist/tools/finish-step-tool.js.map +1 -0
- package/dist/tools/google-tools.d.ts +44 -0
- package/dist/tools/google-tools.d.ts.map +1 -0
- package/dist/tools/google-tools.js +176 -0
- package/dist/tools/google-tools.js.map +1 -0
- package/dist/tools/http-tools.d.ts +56 -0
- package/dist/tools/http-tools.d.ts.map +1 -0
- package/dist/tools/http-tools.js +180 -0
- package/dist/tools/http-tools.js.map +1 -0
- package/dist/tools/js-code-tool.d.ts +30 -0
- package/dist/tools/js-code-tool.d.ts.map +1 -0
- package/dist/tools/js-code-tool.js +98 -0
- package/dist/tools/js-code-tool.js.map +1 -0
- package/dist/tools/local-get-node-info-tool.d.ts +19 -0
- package/dist/tools/local-get-node-info-tool.d.ts.map +1 -0
- package/dist/tools/local-get-node-info-tool.js +75 -0
- package/dist/tools/local-get-node-info-tool.js.map +1 -0
- package/dist/tools/local-list-nodes-tool.d.ts +19 -0
- package/dist/tools/local-list-nodes-tool.d.ts.map +1 -0
- package/dist/tools/local-list-nodes-tool.js +69 -0
- package/dist/tools/local-list-nodes-tool.js.map +1 -0
- package/dist/tools/local-search-nodes-tool.d.ts +21 -0
- package/dist/tools/local-search-nodes-tool.d.ts.map +1 -0
- package/dist/tools/local-search-nodes-tool.js +111 -0
- package/dist/tools/local-search-nodes-tool.js.map +1 -0
- package/dist/tools/math-tools.d.ts +156 -0
- package/dist/tools/math-tools.d.ts.map +1 -0
- package/dist/tools/math-tools.js +422 -0
- package/dist/tools/math-tools.js.map +1 -0
- package/dist/tools/mcp-tools.d.ts +413 -0
- package/dist/tools/mcp-tools.d.ts.map +1 -0
- package/dist/tools/mcp-tools.js +618 -0
- package/dist/tools/mcp-tools.js.map +1 -0
- package/dist/tools/media-tools.d.ts +277 -0
- package/dist/tools/media-tools.d.ts.map +1 -0
- package/dist/tools/media-tools.js +682 -0
- package/dist/tools/media-tools.js.map +1 -0
- package/dist/tools/model-tools.d.ts +25 -0
- package/dist/tools/model-tools.d.ts.map +1 -0
- package/dist/tools/model-tools.js +48 -0
- package/dist/tools/model-tools.js.map +1 -0
- package/dist/tools/openai-tools.d.ts +73 -0
- package/dist/tools/openai-tools.d.ts.map +1 -0
- package/dist/tools/openai-tools.js +193 -0
- package/dist/tools/openai-tools.js.map +1 -0
- package/dist/tools/pdf-tools.d.ts +152 -0
- package/dist/tools/pdf-tools.d.ts.map +1 -0
- package/dist/tools/pdf-tools.js +339 -0
- package/dist/tools/pdf-tools.js.map +1 -0
- package/dist/tools/plan-builder-tools.d.ts +72 -0
- package/dist/tools/plan-builder-tools.d.ts.map +1 -0
- package/dist/tools/plan-builder-tools.js +438 -0
- package/dist/tools/plan-builder-tools.js.map +1 -0
- package/dist/tools/search-tools.d.ts +39 -0
- package/dist/tools/search-tools.d.ts.map +1 -0
- package/dist/tools/search-tools.js +218 -0
- package/dist/tools/search-tools.js.map +1 -0
- package/dist/tools/serp-providers/dataforseo-provider.d.ts +14 -0
- package/dist/tools/serp-providers/dataforseo-provider.d.ts.map +1 -0
- package/dist/tools/serp-providers/dataforseo-provider.js +114 -0
- package/dist/tools/serp-providers/dataforseo-provider.js.map +1 -0
- package/dist/tools/serp-providers/index.d.ts +35 -0
- package/dist/tools/serp-providers/index.d.ts.map +1 -0
- package/dist/tools/serp-providers/index.js +14 -0
- package/dist/tools/serp-providers/index.js.map +1 -0
- package/dist/tools/serp-providers/serpapi-provider.d.ts +18 -0
- package/dist/tools/serp-providers/serpapi-provider.d.ts.map +1 -0
- package/dist/tools/serp-providers/serpapi-provider.js +66 -0
- package/dist/tools/serp-providers/serpapi-provider.js.map +1 -0
- package/dist/tools/tool-registry.d.ts +9 -0
- package/dist/tools/tool-registry.d.ts.map +1 -0
- package/dist/tools/tool-registry.js +17 -0
- package/dist/tools/tool-registry.js.map +1 -0
- package/dist/tools/vector-tools.d.ts +224 -0
- package/dist/tools/vector-tools.d.ts.map +1 -0
- package/dist/tools/vector-tools.js +582 -0
- package/dist/tools/vector-tools.js.map +1 -0
- package/dist/tools/workspace-tools.d.ts +58 -0
- package/dist/tools/workspace-tools.d.ts.map +1 -0
- package/dist/tools/workspace-tools.js +152 -0
- package/dist/tools/workspace-tools.js.map +1 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/json-parser.d.ts +15 -0
- package/dist/utils/json-parser.d.ts.map +1 -0
- package/dist/utils/json-parser.js +78 -0
- package/dist/utils/json-parser.js.map +1 -0
- package/dist/utils/remove-base64-images.d.ts +12 -0
- package/dist/utils/remove-base64-images.d.ts.map +1 -0
- package/dist/utils/remove-base64-images.js +20 -0
- package/dist/utils/remove-base64-images.js.map +1 -0
- package/dist/utils/wrap-generators-parallel.d.ts +11 -0
- package/dist/utils/wrap-generators-parallel.d.ts.map +1 -0
- package/dist/utils/wrap-generators-parallel.js +38 -0
- package/dist/utils/wrap-generators-parallel.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web search tools using the SerpAPI service.
|
|
3
|
+
*
|
|
4
|
+
* Port of src/nodetool/agents/tools/serp_tools.py (GoogleSearchTool,
|
|
5
|
+
* GoogleNewsTool, GoogleImagesTool).
|
|
6
|
+
*
|
|
7
|
+
* Internally delegates to the SerpApiProvider abstraction when available.
|
|
8
|
+
*/
|
|
9
|
+
import { Tool } from "./base-tool.js";
|
|
10
|
+
import { SerpApiProvider } from "./serp-providers/serpapi-provider.js";
|
|
11
|
+
/* ------------------------------------------------------------------ */
|
|
12
|
+
/* Helpers */
|
|
13
|
+
/* ------------------------------------------------------------------ */
|
|
14
|
+
async function getSerpApiKey(context) {
|
|
15
|
+
// Try context secret resolver first, then fall back to env var.
|
|
16
|
+
const fromCtx = await context.getSecret("SERPAPI_API_KEY");
|
|
17
|
+
if (fromCtx)
|
|
18
|
+
return fromCtx;
|
|
19
|
+
const fromEnv = process.env.SERPAPI_API_KEY;
|
|
20
|
+
if (fromEnv)
|
|
21
|
+
return fromEnv;
|
|
22
|
+
throw new Error("SERPAPI_API_KEY is not configured. Set it as an environment variable or via the secret resolver.");
|
|
23
|
+
}
|
|
24
|
+
async function serpApiFetch(params) {
|
|
25
|
+
const url = new URL("https://serpapi.com/search");
|
|
26
|
+
for (const [k, v] of Object.entries(params)) {
|
|
27
|
+
if (v !== undefined)
|
|
28
|
+
url.searchParams.set(k, String(v));
|
|
29
|
+
}
|
|
30
|
+
const res = await fetch(url.toString());
|
|
31
|
+
if (!res.ok) {
|
|
32
|
+
const text = await res.text();
|
|
33
|
+
throw new Error(`SerpAPI request failed (${res.status}): ${text}`);
|
|
34
|
+
}
|
|
35
|
+
return res.json();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve a SerpProvider. If an explicit provider is supplied, use it;
|
|
39
|
+
* otherwise create a SerpApiProvider from the context's API key.
|
|
40
|
+
*/
|
|
41
|
+
async function resolveProvider(context, provider) {
|
|
42
|
+
if (provider)
|
|
43
|
+
return provider;
|
|
44
|
+
const apiKey = await getSerpApiKey(context);
|
|
45
|
+
return new SerpApiProvider(apiKey);
|
|
46
|
+
}
|
|
47
|
+
/* ------------------------------------------------------------------ */
|
|
48
|
+
/* GoogleSearchTool */
|
|
49
|
+
/* ------------------------------------------------------------------ */
|
|
50
|
+
export class GoogleSearchTool extends Tool {
|
|
51
|
+
name = "google_search";
|
|
52
|
+
description = "Search Google to retrieve organic search results via SerpAPI.";
|
|
53
|
+
inputSchema = {
|
|
54
|
+
type: "object",
|
|
55
|
+
properties: {
|
|
56
|
+
keyword: {
|
|
57
|
+
type: "string",
|
|
58
|
+
description: "The keyword to search for."
|
|
59
|
+
},
|
|
60
|
+
num_results: {
|
|
61
|
+
type: "integer",
|
|
62
|
+
description: "Number of results to retrieve.",
|
|
63
|
+
default: 10
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
required: ["keyword"]
|
|
67
|
+
};
|
|
68
|
+
_provider;
|
|
69
|
+
constructor(provider) {
|
|
70
|
+
super();
|
|
71
|
+
this._provider = provider;
|
|
72
|
+
}
|
|
73
|
+
async process(context, params) {
|
|
74
|
+
const keyword = params.keyword;
|
|
75
|
+
if (!keyword)
|
|
76
|
+
return { error: "keyword is required" };
|
|
77
|
+
const numResults = params.num_results ?? 10;
|
|
78
|
+
if (this._provider) {
|
|
79
|
+
const results = await this._provider.search(keyword, { numResults });
|
|
80
|
+
return {
|
|
81
|
+
success: true,
|
|
82
|
+
results: results.map((r) => ({
|
|
83
|
+
title: r.title ?? null,
|
|
84
|
+
link: r.url ?? null,
|
|
85
|
+
snippet: r.snippet ?? null
|
|
86
|
+
}))
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// Legacy direct API call path
|
|
90
|
+
const apiKey = await getSerpApiKey(context);
|
|
91
|
+
const data = (await serpApiFetch({
|
|
92
|
+
engine: "google",
|
|
93
|
+
q: keyword,
|
|
94
|
+
api_key: apiKey,
|
|
95
|
+
num: numResults
|
|
96
|
+
}));
|
|
97
|
+
const organicResults = (data.organic_results ?? []);
|
|
98
|
+
const results = organicResults.map((r) => ({
|
|
99
|
+
title: r.title ?? null,
|
|
100
|
+
link: r.link ?? null,
|
|
101
|
+
snippet: r.snippet ?? null
|
|
102
|
+
}));
|
|
103
|
+
return { success: true, results };
|
|
104
|
+
}
|
|
105
|
+
userMessage(params) {
|
|
106
|
+
const keyword = params.keyword ?? "something";
|
|
107
|
+
const msg = `Searching Google for '${keyword}'...`;
|
|
108
|
+
return msg.length > 80 ? "Searching Google..." : msg;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/* ------------------------------------------------------------------ */
|
|
112
|
+
/* GoogleNewsTool */
|
|
113
|
+
/* ------------------------------------------------------------------ */
|
|
114
|
+
export class GoogleNewsTool extends Tool {
|
|
115
|
+
name = "google_news";
|
|
116
|
+
description = "Search Google News to retrieve live news articles via SerpAPI.";
|
|
117
|
+
inputSchema = {
|
|
118
|
+
type: "object",
|
|
119
|
+
properties: {
|
|
120
|
+
keyword: {
|
|
121
|
+
type: "string",
|
|
122
|
+
description: "The keyword to search for in Google News."
|
|
123
|
+
},
|
|
124
|
+
num_results: {
|
|
125
|
+
type: "integer",
|
|
126
|
+
description: "Number of news results to retrieve.",
|
|
127
|
+
default: 10
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
required: ["keyword"]
|
|
131
|
+
};
|
|
132
|
+
_provider;
|
|
133
|
+
constructor(provider) {
|
|
134
|
+
super();
|
|
135
|
+
this._provider = provider;
|
|
136
|
+
}
|
|
137
|
+
async process(context, params) {
|
|
138
|
+
const keyword = params.keyword;
|
|
139
|
+
if (!keyword)
|
|
140
|
+
return { error: "keyword is required" };
|
|
141
|
+
const apiKey = await getSerpApiKey(context);
|
|
142
|
+
const numResults = params.num_results ?? 10;
|
|
143
|
+
const data = (await serpApiFetch({
|
|
144
|
+
engine: "google_news",
|
|
145
|
+
q: keyword,
|
|
146
|
+
api_key: apiKey,
|
|
147
|
+
num: numResults
|
|
148
|
+
}));
|
|
149
|
+
const newsResults = (data.news_results ?? []);
|
|
150
|
+
const results = newsResults.map((r) => ({
|
|
151
|
+
title: r.title ?? null,
|
|
152
|
+
link: r.link ?? null,
|
|
153
|
+
snippet: r.snippet ?? null,
|
|
154
|
+
date: r.date ?? null,
|
|
155
|
+
source: r.source?.name ?? null
|
|
156
|
+
}));
|
|
157
|
+
return { success: true, results };
|
|
158
|
+
}
|
|
159
|
+
userMessage(params) {
|
|
160
|
+
const keyword = params.keyword ?? "something";
|
|
161
|
+
const msg = `Searching Google News for '${keyword}'...`;
|
|
162
|
+
return msg.length > 80 ? "Searching Google News..." : msg;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/* ------------------------------------------------------------------ */
|
|
166
|
+
/* GoogleImagesTool */
|
|
167
|
+
/* ------------------------------------------------------------------ */
|
|
168
|
+
export class GoogleImagesTool extends Tool {
|
|
169
|
+
name = "google_images";
|
|
170
|
+
description = "Search Google Images to retrieve image results via SerpAPI.";
|
|
171
|
+
inputSchema = {
|
|
172
|
+
type: "object",
|
|
173
|
+
properties: {
|
|
174
|
+
keyword: {
|
|
175
|
+
type: "string",
|
|
176
|
+
description: "Keyword for image search."
|
|
177
|
+
},
|
|
178
|
+
num_results: {
|
|
179
|
+
type: "integer",
|
|
180
|
+
description: "Number of image results to retrieve.",
|
|
181
|
+
default: 20
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
required: ["keyword"]
|
|
185
|
+
};
|
|
186
|
+
_provider;
|
|
187
|
+
constructor(provider) {
|
|
188
|
+
super();
|
|
189
|
+
this._provider = provider;
|
|
190
|
+
}
|
|
191
|
+
async process(context, params) {
|
|
192
|
+
const keyword = params.keyword;
|
|
193
|
+
if (!keyword)
|
|
194
|
+
return { error: "keyword is required" };
|
|
195
|
+
const apiKey = await getSerpApiKey(context);
|
|
196
|
+
const numResults = params.num_results ?? 20;
|
|
197
|
+
const data = (await serpApiFetch({
|
|
198
|
+
engine: "google_images",
|
|
199
|
+
q: keyword,
|
|
200
|
+
api_key: apiKey,
|
|
201
|
+
num: numResults
|
|
202
|
+
}));
|
|
203
|
+
const imagesResults = (data.images_results ?? []);
|
|
204
|
+
const results = imagesResults.map((r) => ({
|
|
205
|
+
title: r.title ?? null,
|
|
206
|
+
link: r.link ?? null,
|
|
207
|
+
original: r.original ?? null,
|
|
208
|
+
thumbnail: r.thumbnail ?? null
|
|
209
|
+
}));
|
|
210
|
+
return { success: true, results };
|
|
211
|
+
}
|
|
212
|
+
userMessage(params) {
|
|
213
|
+
const keyword = params.keyword ?? "something";
|
|
214
|
+
const msg = `Searching Google Images for '${keyword}'...`;
|
|
215
|
+
return msg.length > 80 ? "Searching Google Images..." : msg;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=search-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-tools.js","sourceRoot":"","sources":["../../src/tools/search-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAEvE,wEAAwE;AACxE,wEAAwE;AACxE,wEAAwE;AAExE,KAAK,UAAU,aAAa,CAAC,OAA0B;IACrD,gEAAgE;IAChE,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAC3D,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAE5B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC5C,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAE5B,MAAM,IAAI,KAAK,CACb,kGAAkG,CACnG,CAAC;AACJ,CAAC;AAUD,KAAK,UAAU,YAAY,CAAC,MAAqB;IAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAClD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5C,IAAI,CAAC,KAAK,SAAS;YAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CA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ACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataForSEO provider implementation.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the DataForSEO HTTP API and normalises results into the common
|
|
5
|
+
* SearchResult shape.
|
|
6
|
+
*/
|
|
7
|
+
import type { SerpProvider, SearchResult, SearchOptions } from "./index.js";
|
|
8
|
+
export declare class DataForSeoProvider implements SerpProvider {
|
|
9
|
+
private readonly auth;
|
|
10
|
+
constructor(login: string, password: string);
|
|
11
|
+
search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
|
|
12
|
+
searchRaw(query: string, options?: SearchOptions): Promise<unknown>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=dataforseo-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataforseo-provider.d.ts","sourceRoot":"","sources":["../../../src/tools/serp-providers/dataforseo-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAqF5E,qBAAa,kBAAmB,YAAW,YAAY;IACrD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;gBAElB,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAIrC,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,EAAE,CAAC;IAkCpB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;CAoB1E"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataForSEO provider implementation.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the DataForSEO HTTP API and normalises results into the common
|
|
5
|
+
* SearchResult shape.
|
|
6
|
+
*/
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Constants
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
const API_BASE = "https://api.dataforseo.com";
|
|
11
|
+
const DEFAULT_LOCATION_CODE = 2840; // United States
|
|
12
|
+
const DEFAULT_LANGUAGE_CODE = "en";
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Helpers
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
function makeAuthHeader(login, password) {
|
|
17
|
+
const encoded = Buffer.from(`${login}:${password}`).toString("base64");
|
|
18
|
+
return `Basic ${encoded}`;
|
|
19
|
+
}
|
|
20
|
+
async function dataForSEORequest(endpoint, payload, auth) {
|
|
21
|
+
const url = `${API_BASE}${endpoint}`;
|
|
22
|
+
try {
|
|
23
|
+
const res = await fetch(url, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: auth,
|
|
27
|
+
"Content-Type": "application/json"
|
|
28
|
+
},
|
|
29
|
+
body: JSON.stringify(payload)
|
|
30
|
+
});
|
|
31
|
+
if (!res.ok) {
|
|
32
|
+
let details;
|
|
33
|
+
try {
|
|
34
|
+
details = await res.json();
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
details = await res.text();
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
error: `HTTP error occurred: ${res.status} - ${res.statusText}`,
|
|
41
|
+
details
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return (await res.json());
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
return { error: `DataForSEO request failed: ${e.message}` };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function extractItems(result) {
|
|
51
|
+
if ("error" in result)
|
|
52
|
+
return result;
|
|
53
|
+
if (result.status_code !== 20000 || result.status_message !== "Ok.") {
|
|
54
|
+
return {
|
|
55
|
+
error: `DataForSEO API Error: ${result.status_code} - ${result.status_message}`,
|
|
56
|
+
details: result
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const taskResult = result.tasks?.[0]?.result;
|
|
60
|
+
if (taskResult && Array.isArray(taskResult) && taskResult.length > 0) {
|
|
61
|
+
return taskResult[0].items ?? [];
|
|
62
|
+
}
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// Provider
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
export class DataForSeoProvider {
|
|
69
|
+
auth;
|
|
70
|
+
constructor(login, password) {
|
|
71
|
+
this.auth = makeAuthHeader(login, password);
|
|
72
|
+
}
|
|
73
|
+
async search(query, options) {
|
|
74
|
+
const numResults = options?.numResults ?? 10;
|
|
75
|
+
const payload = [
|
|
76
|
+
{
|
|
77
|
+
keyword: query,
|
|
78
|
+
location_code: DEFAULT_LOCATION_CODE,
|
|
79
|
+
language_code: options?.language ?? DEFAULT_LANGUAGE_CODE,
|
|
80
|
+
device: "desktop",
|
|
81
|
+
os: "windows",
|
|
82
|
+
depth: numResults
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
const result = await dataForSEORequest("/v3/serp/google/organic/live/advanced", payload, this.auth);
|
|
86
|
+
const items = extractItems(result);
|
|
87
|
+
if (!Array.isArray(items)) {
|
|
88
|
+
throw new Error(items.error);
|
|
89
|
+
}
|
|
90
|
+
return items
|
|
91
|
+
.filter((item) => item.type === "organic")
|
|
92
|
+
.map((item, i) => ({
|
|
93
|
+
title: String(item.title ?? ""),
|
|
94
|
+
url: String(item.url ?? ""),
|
|
95
|
+
snippet: String(item.description ?? ""),
|
|
96
|
+
position: item.rank_absolute ?? i + 1
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
async searchRaw(query, options) {
|
|
100
|
+
const numResults = options?.numResults ?? 10;
|
|
101
|
+
const payload = [
|
|
102
|
+
{
|
|
103
|
+
keyword: query,
|
|
104
|
+
location_code: DEFAULT_LOCATION_CODE,
|
|
105
|
+
language_code: options?.language ?? DEFAULT_LANGUAGE_CODE,
|
|
106
|
+
device: "desktop",
|
|
107
|
+
os: "windows",
|
|
108
|
+
depth: numResults
|
|
109
|
+
}
|
|
110
|
+
];
|
|
111
|
+
return dataForSEORequest("/v3/serp/google/organic/live/advanced", payload, this.auth);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=dataforseo-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataforseo-provider.js","sourceRoot":"","sources":["../../../src/tools/serp-providers/dataforseo-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,QAAQ,GAAG,4BAA4B,CAAC;AAC9C,MAAM,qBAAqB,GAAG,IAAI,CAAC,CAAC,gBAAgB;AACpD,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,SAAS,cAAc,CAAC,KAAa,EAAE,QAAgB;IACrD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvE,OAAO,SAAS,OAAO,EAAE,CAAC;AAC5B,CAAC;AAYD,KAAK,UAAU,iBAAiB,CAC9B,QAAgB,EAChB,OAAkC,EAClC,IAAY;IAEZ,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ,EAAE,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC3B,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,IAAI;gBACnB,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAC9B,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,I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OAAuB;QACpD,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC;QAE7C,MAAM,OAAO,GAAG;YACd;gBACE,OAAO,EAAE,KAAK;gBACd,aAAa,EAAE,qBAAqB;gBACpC,aAAa,EAAE,OAAO,EAAE,QAAQ,IAAI,qBAAqB;gBACzD,MAAM,EAAE,SAAS;gBACjB,EAAE,EAAE,SAAS;gBACb,KAAK,EAAE,UAAU;aAClB;SACF,CAAC;QAEF,OAAO,iBAAiB,CACtB,uCAAuC,EACvC,OAAO,EACP,IAAI,CAAC,IAAI,CACV,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SERP provider abstraction layer.
|
|
3
|
+
*
|
|
4
|
+
* Port of src/nodetool/agents/serp_providers/serp_providers.py
|
|
5
|
+
*
|
|
6
|
+
* Provides a common interface for search engine results page (SERP) providers
|
|
7
|
+
* so that tool implementations can be provider-agnostic.
|
|
8
|
+
*/
|
|
9
|
+
export interface SearchResult {
|
|
10
|
+
title: string;
|
|
11
|
+
url: string;
|
|
12
|
+
snippet: string;
|
|
13
|
+
position: number;
|
|
14
|
+
}
|
|
15
|
+
export interface SearchOptions {
|
|
16
|
+
numResults?: number;
|
|
17
|
+
location?: string;
|
|
18
|
+
language?: string;
|
|
19
|
+
engine?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Abstract SERP provider interface.
|
|
23
|
+
*
|
|
24
|
+
* Implementations wrap a specific search API (SerpAPI, DataForSEO, etc.)
|
|
25
|
+
* and normalise results into a common shape.
|
|
26
|
+
*/
|
|
27
|
+
export interface SerpProvider {
|
|
28
|
+
/** Perform a web search and return normalised results. */
|
|
29
|
+
search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
|
|
30
|
+
/** Perform a web search and return the raw API response. */
|
|
31
|
+
searchRaw(query: string, options?: SearchOptions): Promise<unknown>;
|
|
32
|
+
}
|
|
33
|
+
export { SerpApiProvider } from "./serpapi-provider.js";
|
|
34
|
+
export { DataForSeoProvider } from "./dataforseo-provider.js";
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/serp-providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAMD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,0DAA0D;IAC1D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAExE,4DAA4D;IAC5D,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrE;AAMD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SERP provider abstraction layer.
|
|
3
|
+
*
|
|
4
|
+
* Port of src/nodetool/agents/serp_providers/serp_providers.py
|
|
5
|
+
*
|
|
6
|
+
* Provides a common interface for search engine results page (SERP) providers
|
|
7
|
+
* so that tool implementations can be provider-agnostic.
|
|
8
|
+
*/
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Re-exports
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
export { SerpApiProvider } from "./serpapi-provider.js";
|
|
13
|
+
export { DataForSeoProvider } from "./dataforseo-provider.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/serp-providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAsCH,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SerpAPI provider implementation.
|
|
3
|
+
*
|
|
4
|
+
* Port of src/nodetool/agents/serp_providers/serp_api_provider.py
|
|
5
|
+
*
|
|
6
|
+
* Wraps the SerpAPI HTTP API and normalises results into the common
|
|
7
|
+
* SearchResult shape.
|
|
8
|
+
*/
|
|
9
|
+
import type { SerpProvider, SearchResult, SearchOptions } from "./index.js";
|
|
10
|
+
export declare class SerpApiProvider implements SerpProvider {
|
|
11
|
+
private readonly apiKey;
|
|
12
|
+
private readonly gl;
|
|
13
|
+
private readonly hl;
|
|
14
|
+
constructor(apiKey: string, gl?: string, hl?: string);
|
|
15
|
+
search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
|
|
16
|
+
searchRaw(query: string, options?: SearchOptions): Promise<unknown>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=serpapi-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serpapi-provider.d.ts","sourceRoot":"","sources":["../../../src/tools/serp-providers/serpapi-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAiC5E,qBAAa,eAAgB,YAAW,YAAY;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAS;gBAEhB,MAAM,EAAE,MAAM,EAAE,EAAE,SAAO,EAAE,EAAE,SAAO;IAM1C,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,EAAE,CAAC;IAyBpB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;CAa1E"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SerpAPI provider implementation.
|
|
3
|
+
*
|
|
4
|
+
* Port of src/nodetool/agents/serp_providers/serp_api_provider.py
|
|
5
|
+
*
|
|
6
|
+
* Wraps the SerpAPI HTTP API and normalises results into the common
|
|
7
|
+
* SearchResult shape.
|
|
8
|
+
*/
|
|
9
|
+
async function serpApiFetch(params) {
|
|
10
|
+
const url = new URL("https://serpapi.com/search");
|
|
11
|
+
for (const [k, v] of Object.entries(params)) {
|
|
12
|
+
if (v !== undefined)
|
|
13
|
+
url.searchParams.set(k, String(v));
|
|
14
|
+
}
|
|
15
|
+
const res = await fetch(url.toString());
|
|
16
|
+
if (!res.ok) {
|
|
17
|
+
const text = await res.text();
|
|
18
|
+
throw new Error(`SerpAPI request failed (${res.status}): ${text}`);
|
|
19
|
+
}
|
|
20
|
+
return res.json();
|
|
21
|
+
}
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Provider
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
export class SerpApiProvider {
|
|
26
|
+
apiKey;
|
|
27
|
+
gl;
|
|
28
|
+
hl;
|
|
29
|
+
constructor(apiKey, gl = "us", hl = "en") {
|
|
30
|
+
this.apiKey = apiKey;
|
|
31
|
+
this.gl = gl;
|
|
32
|
+
this.hl = hl;
|
|
33
|
+
}
|
|
34
|
+
async search(query, options) {
|
|
35
|
+
const numResults = options?.numResults ?? 10;
|
|
36
|
+
const engine = options?.engine ?? "google";
|
|
37
|
+
const data = (await serpApiFetch({
|
|
38
|
+
engine,
|
|
39
|
+
q: query,
|
|
40
|
+
api_key: this.apiKey,
|
|
41
|
+
num: numResults,
|
|
42
|
+
gl: this.gl,
|
|
43
|
+
hl: options?.language ?? this.hl
|
|
44
|
+
}));
|
|
45
|
+
const organicResults = (data.organic_results ?? []);
|
|
46
|
+
return organicResults.map((r, i) => ({
|
|
47
|
+
title: String(r.title ?? ""),
|
|
48
|
+
url: String(r.link ?? ""),
|
|
49
|
+
snippet: String(r.snippet ?? ""),
|
|
50
|
+
position: r.position ?? i + 1
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
async searchRaw(query, options) {
|
|
54
|
+
const numResults = options?.numResults ?? 10;
|
|
55
|
+
const engine = options?.engine ?? "google";
|
|
56
|
+
return serpApiFetch({
|
|
57
|
+
engine,
|
|
58
|
+
q: query,
|
|
59
|
+
api_key: this.apiKey,
|
|
60
|
+
num: numResults,
|
|
61
|
+
gl: this.gl,
|
|
62
|
+
hl: options?.language ?? this.hl
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=serpapi-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serpapi-provider.js","sourceRoot":"","sources":["../../../src/tools/serp-providers/serpapi-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,KAAK,UAAU,YAAY,CAAC,MAAqB;IAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAClD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CA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QAE/B,MAAM,cAAc,GAAG,CAAC,IAAI,CAAC,eAAe,IAAI,EAAE,CAEjD,CAAC;QAEF,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YACnC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAC5B,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;YACzB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC;YAChC,QAAQ,EAAG,CAAC,CAAC,QAAmB,IAAI,CAAC,GAAG,CAAC;SAC1C,CAAC,CAAC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,OAAuB;QACpD,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,QAAQ,CAAC;QAE3C,OAAO,YAAY,CAAC;YAClB,MAAM;YACN,CAAC,EAAE,KAAK;YACR,OAAO,EAAE,IAAI,CAAC,MAAM;YACpB,GAAG,EAAE,UAAU;YACf,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,EAAE,EAAE,OAAO,EAAE,QAAQ,IAAI,IAAI,CAAC,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map-based tool registry for resolving tools by name.
|
|
3
|
+
*/
|
|
4
|
+
import type { Tool } from "./base-tool.js";
|
|
5
|
+
export declare function registerTool(tool: Tool): void;
|
|
6
|
+
export declare function resolveTool(name: string): Tool | null;
|
|
7
|
+
export declare function listTools(): string[];
|
|
8
|
+
export declare function getAllTools(): Tool[];
|
|
9
|
+
//# sourceMappingURL=tool-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../src/tools/tool-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAI3C,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAE7C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAErD;AAED,wBAAgB,SAAS,IAAI,MAAM,EAAE,CAEpC;AAED,wBAAgB,WAAW,IAAI,IAAI,EAAE,CAEpC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map-based tool registry for resolving tools by name.
|
|
3
|
+
*/
|
|
4
|
+
const registry = new Map();
|
|
5
|
+
export function registerTool(tool) {
|
|
6
|
+
registry.set(tool.name, tool);
|
|
7
|
+
}
|
|
8
|
+
export function resolveTool(name) {
|
|
9
|
+
return registry.get(name) ?? null;
|
|
10
|
+
}
|
|
11
|
+
export function listTools() {
|
|
12
|
+
return Array.from(registry.keys());
|
|
13
|
+
}
|
|
14
|
+
export function getAllTools() {
|
|
15
|
+
return Array.from(registry.values());
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=tool-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registry.js","sourceRoot":"","sources":["../../src/tools/tool-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAgB,CAAC;AAEzC,MAAM,UAAU,YAAY,CAAC,IAAU;IACrC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC"}
|