@openclaw/parallel-plugin 0.0.0 → 2026.6.9
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 +11 -2
- package/dist/index.js +14 -0
- package/dist/parallel-free-web-search-provider-NaOJ6_QF.js +189 -0
- package/dist/parallel-free-web-search-provider.runtime-fyyL3Xip.js +263 -0
- package/dist/parallel-web-search-provider.runtime-CoE_E7IZ.js +159 -0
- package/dist/parallel-web-search-provider.shared-B8yrY1oc.js +55 -0
- package/dist/web-search-contract-api.js +16 -0
- package/dist/web-search-provider.js +2 -0
- package/npm-shrinkwrap.json +12 -0
- package/openclaw.plugin.json +50 -0
- package/package.json +44 -8
package/README.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OpenClaw Parallel Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official OpenClaw plugin for Parallel.
|
|
4
|
+
|
|
5
|
+
Install from OpenClaw:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
openclaw plugins install @openclaw/parallel-plugin
|
|
9
|
+
openclaw gateway restart
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
See <https://docs.openclaw.ai/tools/parallel-search> for setup and configuration.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { n as createParallelWebSearchProvider, t as createParallelFreeWebSearchProvider } from "./parallel-free-web-search-provider-NaOJ6_QF.js";
|
|
2
|
+
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
3
|
+
//#region extensions/parallel/index.ts
|
|
4
|
+
var parallel_default = definePluginEntry({
|
|
5
|
+
id: "parallel",
|
|
6
|
+
name: "Parallel Plugin",
|
|
7
|
+
description: "Bundled Parallel web search plugin",
|
|
8
|
+
register(api) {
|
|
9
|
+
api.registerWebSearchProvider(createParallelFreeWebSearchProvider());
|
|
10
|
+
api.registerWebSearchProvider(createParallelWebSearchProvider());
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { parallel_default as default };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { n as createParallelFreeWebSearchProviderBase, t as createParallelWebSearchProviderBase } from "./parallel-web-search-provider.shared-B8yrY1oc.js";
|
|
2
|
+
import { buildSearchCacheKey, resolveSiteName, wrapWebContent } from "openclaw/plugin-sdk/provider-web-search";
|
|
3
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
+
//#region extensions/parallel/src/parallel-search-normalize.ts
|
|
5
|
+
const PARALLEL_MAX_SEARCH_COUNT$1 = 40;
|
|
6
|
+
const PARALLEL_MAX_SEARCH_QUERY_CHARS$1 = 200;
|
|
7
|
+
const PARALLEL_MAX_OBJECTIVE_CHARS$1 = 5e3;
|
|
8
|
+
const PARALLEL_MAX_SEARCH_QUERIES$1 = 5;
|
|
9
|
+
const PARALLEL_SESSION_ID_MAX_LENGTH = 1e3;
|
|
10
|
+
const PARALLEL_CLIENT_MODEL_MAX_LENGTH = 100;
|
|
11
|
+
function resolveParallelSearchCount(value) {
|
|
12
|
+
return Math.max(1, Math.min(PARALLEL_MAX_SEARCH_COUNT$1, Math.floor(value)));
|
|
13
|
+
}
|
|
14
|
+
function normalizeParallelSessionId(value, maxLength) {
|
|
15
|
+
const trimmed = normalizeOptionalString(value);
|
|
16
|
+
return trimmed && trimmed.length <= maxLength ? trimmed : void 0;
|
|
17
|
+
}
|
|
18
|
+
function normalizeParallelObjective(value) {
|
|
19
|
+
const trimmed = normalizeOptionalString(value);
|
|
20
|
+
if (!trimmed) return;
|
|
21
|
+
return trimmed.length <= PARALLEL_MAX_OBJECTIVE_CHARS$1 ? trimmed : trimmed.slice(0, PARALLEL_MAX_OBJECTIVE_CHARS$1);
|
|
22
|
+
}
|
|
23
|
+
function normalizeParallelClientModel(value) {
|
|
24
|
+
const trimmed = normalizeOptionalString(value);
|
|
25
|
+
if (!trimmed) return;
|
|
26
|
+
return trimmed.length <= PARALLEL_CLIENT_MODEL_MAX_LENGTH ? trimmed : trimmed.slice(0, PARALLEL_CLIENT_MODEL_MAX_LENGTH);
|
|
27
|
+
}
|
|
28
|
+
function normalizeParallelSearchQueries(value) {
|
|
29
|
+
const candidates = Array.isArray(value) ? value : [];
|
|
30
|
+
const seen = /* @__PURE__ */ new Set();
|
|
31
|
+
const out = [];
|
|
32
|
+
for (const entry of candidates) {
|
|
33
|
+
if (typeof entry !== "string") continue;
|
|
34
|
+
const trimmed = entry.trim();
|
|
35
|
+
if (!trimmed) continue;
|
|
36
|
+
const capped = trimmed.length <= PARALLEL_MAX_SEARCH_QUERY_CHARS$1 ? trimmed : trimmed.slice(0, PARALLEL_MAX_SEARCH_QUERY_CHARS$1);
|
|
37
|
+
if (seen.has(capped)) continue;
|
|
38
|
+
seen.add(capped);
|
|
39
|
+
out.push(capped);
|
|
40
|
+
if (out.length === PARALLEL_MAX_SEARCH_QUERIES$1) break;
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
function invalidSearchQueriesPayload() {
|
|
45
|
+
return {
|
|
46
|
+
error: "invalid_search_queries",
|
|
47
|
+
message: "search_queries must be a non-empty array of keyword strings (max 5, max 200 chars each). See https://docs.parallel.ai/search/best-practices.",
|
|
48
|
+
docs: "https://docs.openclaw.ai/tools/parallel-search"
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function normalizeParallelResults(payload) {
|
|
52
|
+
if (!payload || typeof payload !== "object") return [];
|
|
53
|
+
const results = payload.results;
|
|
54
|
+
if (!Array.isArray(results)) return [];
|
|
55
|
+
return results.filter((entry) => Boolean(entry && typeof entry === "object" && !Array.isArray(entry)));
|
|
56
|
+
}
|
|
57
|
+
/** Maps a Parallel v1 response into wrapped `web_search` result entries. */
|
|
58
|
+
function mapParallelResults(response) {
|
|
59
|
+
return normalizeParallelResults(response).map((entry) => {
|
|
60
|
+
const title = typeof entry.title === "string" ? entry.title : "";
|
|
61
|
+
const url = typeof entry.url === "string" ? entry.url : "";
|
|
62
|
+
const published = typeof entry.publish_date === "string" && entry.publish_date ? entry.publish_date : void 0;
|
|
63
|
+
const excerpts = Array.isArray(entry.excerpts) ? entry.excerpts.filter((e) => typeof e === "string").map((e) => wrapWebContent(e, "web_search")) : [];
|
|
64
|
+
const description = excerpts.join("\n\n");
|
|
65
|
+
return Object.assign({
|
|
66
|
+
title: title ? wrapWebContent(title, "web_search") : "",
|
|
67
|
+
url,
|
|
68
|
+
description,
|
|
69
|
+
siteName: resolveSiteName(url) || void 0
|
|
70
|
+
}, published ? { published } : {}, excerpts.length > 0 ? { excerpts } : {});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Drops a Parallel-generated `sessionId` before caching. Identical queries from
|
|
75
|
+
* unrelated tasks would otherwise share that id; caller-supplied session ids are
|
|
76
|
+
* part of the cache key, so a cache hit only ever returns the matching id.
|
|
77
|
+
*/
|
|
78
|
+
function stripParallelGeneratedSessionId(payload) {
|
|
79
|
+
if (!("sessionId" in payload)) return payload;
|
|
80
|
+
const { sessionId: _omitted, ...rest } = payload;
|
|
81
|
+
return rest;
|
|
82
|
+
}
|
|
83
|
+
function buildParallelCacheKey(params) {
|
|
84
|
+
return buildSearchCacheKey([
|
|
85
|
+
"parallel",
|
|
86
|
+
params.endpoint,
|
|
87
|
+
params.objective,
|
|
88
|
+
params.searchQueries.join("\0"),
|
|
89
|
+
params.count,
|
|
90
|
+
params.sessionId,
|
|
91
|
+
params.clientModel
|
|
92
|
+
]);
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region extensions/parallel/src/parallel-web-search-provider.ts
|
|
96
|
+
const PARALLEL_MAX_SEARCH_COUNT = 40;
|
|
97
|
+
const PARALLEL_MAX_SEARCH_QUERIES = 5;
|
|
98
|
+
const PARALLEL_MAX_SEARCH_QUERY_CHARS = 200;
|
|
99
|
+
const PARALLEL_MAX_OBJECTIVE_CHARS = 5e3;
|
|
100
|
+
const PARALLEL_MAX_SESSION_ID_CHARS = 1e3;
|
|
101
|
+
const PARALLEL_MAX_CLIENT_MODEL_CHARS = 100;
|
|
102
|
+
let parallelWebSearchRuntimePromise;
|
|
103
|
+
function loadParallelWebSearchRuntime() {
|
|
104
|
+
parallelWebSearchRuntimePromise ??= import("./parallel-web-search-provider.runtime-CoE_E7IZ.js");
|
|
105
|
+
return parallelWebSearchRuntimePromise;
|
|
106
|
+
}
|
|
107
|
+
const ParallelSearchSchema = {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
objective: {
|
|
111
|
+
type: "string",
|
|
112
|
+
description: "Natural-language description of the underlying question or goal driving the search. Should be self-contained with enough context to understand the intent. Used together with search_queries to focus results on the most relevant content.",
|
|
113
|
+
maxLength: PARALLEL_MAX_OBJECTIVE_CHARS
|
|
114
|
+
},
|
|
115
|
+
search_queries: {
|
|
116
|
+
type: "array",
|
|
117
|
+
description: "Concise keyword search queries, 3-6 words each. Provide 2-3 diverse queries for best results (max 5). Vary entity names, synonyms, and angles. Each query is a keyword phrase, not a sentence; do not use site: operators.",
|
|
118
|
+
items: {
|
|
119
|
+
type: "string",
|
|
120
|
+
maxLength: PARALLEL_MAX_SEARCH_QUERY_CHARS
|
|
121
|
+
},
|
|
122
|
+
minItems: 1,
|
|
123
|
+
maxItems: PARALLEL_MAX_SEARCH_QUERIES
|
|
124
|
+
},
|
|
125
|
+
count: {
|
|
126
|
+
type: "integer",
|
|
127
|
+
description: "Number of results to return (1-40).",
|
|
128
|
+
minimum: 1,
|
|
129
|
+
maximum: PARALLEL_MAX_SEARCH_COUNT
|
|
130
|
+
},
|
|
131
|
+
session_id: {
|
|
132
|
+
type: "string",
|
|
133
|
+
description: "Optional session id returned by an earlier Parallel search. Pass it on follow-up searches that are part of the same task to keep Parallel's server-side context grouped (look for `sessionId` in the prior tool result).",
|
|
134
|
+
maxLength: PARALLEL_MAX_SESSION_ID_CHARS
|
|
135
|
+
},
|
|
136
|
+
client_model: {
|
|
137
|
+
type: "string",
|
|
138
|
+
description: "The identifier of the LLM model making this tool call (e.g. 'claude-opus-4-7', 'gpt-5.5', 'gemini-3.1-pro'). Pass the exact active model slug verbatim; never shorten or substitute a family alias like 'gpt-5'. Lets Parallel tailor default settings for your model's capabilities.",
|
|
139
|
+
maxLength: PARALLEL_MAX_CLIENT_MODEL_CHARS
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
required: ["objective", "search_queries"],
|
|
143
|
+
additionalProperties: false
|
|
144
|
+
};
|
|
145
|
+
function createParallelWebSearchProvider() {
|
|
146
|
+
return {
|
|
147
|
+
...createParallelWebSearchProviderBase(),
|
|
148
|
+
createTool: (ctx) => ({
|
|
149
|
+
description: "Search the web using Parallel. Returns ranked, LLM-optimized dense excerpts from web sources. Pass an `objective` describing the underlying question along with 2-3 short keyword `search_queries` (Parallel's recommended pairing). For multi-step research, thread the prior result's `sessionId` back in as `session_id` to keep Parallel's context grouped.",
|
|
150
|
+
parameters: ParallelSearchSchema,
|
|
151
|
+
execute: async (args) => {
|
|
152
|
+
const { executeParallelWebSearchProviderTool } = await loadParallelWebSearchRuntime();
|
|
153
|
+
return await executeParallelWebSearchProviderTool(ctx, args);
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region extensions/parallel/src/parallel-free-web-search-provider.ts
|
|
160
|
+
const ParallelFreeSearchSchema = {
|
|
161
|
+
...ParallelSearchSchema,
|
|
162
|
+
properties: {
|
|
163
|
+
...ParallelSearchSchema.properties,
|
|
164
|
+
session_id: {
|
|
165
|
+
...ParallelSearchSchema.properties.session_id,
|
|
166
|
+
maxLength: 100
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
let parallelFreeWebSearchRuntimePromise;
|
|
171
|
+
function loadParallelFreeWebSearchRuntime() {
|
|
172
|
+
parallelFreeWebSearchRuntimePromise ??= import("./parallel-free-web-search-provider.runtime-fyyL3Xip.js");
|
|
173
|
+
return parallelFreeWebSearchRuntimePromise;
|
|
174
|
+
}
|
|
175
|
+
function createParallelFreeWebSearchProvider() {
|
|
176
|
+
return {
|
|
177
|
+
...createParallelFreeWebSearchProviderBase(),
|
|
178
|
+
createTool: (ctx) => ({
|
|
179
|
+
description: "Search the web using Parallel's free Search MCP (no API key). Returns ranked, LLM-optimized dense excerpts from web sources. Pass an `objective` describing the underlying question along with 2-3 short keyword `search_queries` (Parallel's recommended pairing). For multi-step research, thread the prior result's `sessionId` back in as `session_id` to keep Parallel's context grouped.",
|
|
180
|
+
parameters: ParallelFreeSearchSchema,
|
|
181
|
+
execute: async (args, context) => {
|
|
182
|
+
const { executeParallelFreeWebSearchProviderTool } = await loadParallelFreeWebSearchRuntime();
|
|
183
|
+
return await executeParallelFreeWebSearchProviderTool(ctx, args, context?.signal);
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
189
|
+
export { invalidSearchQueriesPayload as a, normalizeParallelObjective as c, normalizeParallelSessionId as d, resolveParallelSearchCount as f, buildParallelCacheKey as i, normalizeParallelResults as l, createParallelWebSearchProvider as n, mapParallelResults as o, stripParallelGeneratedSessionId as p, PARALLEL_SESSION_ID_MAX_LENGTH as r, normalizeParallelClientModel as s, createParallelFreeWebSearchProvider as t, normalizeParallelSearchQueries as u };
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { a as invalidSearchQueriesPayload, c as normalizeParallelObjective, d as normalizeParallelSessionId, f as resolveParallelSearchCount, i as buildParallelCacheKey, o as mapParallelResults, p as stripParallelGeneratedSessionId, s as normalizeParallelClientModel, u as normalizeParallelSearchQueries } from "./parallel-free-web-search-provider-NaOJ6_QF.js";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { DEFAULT_SEARCH_COUNT, mergeScopedSearchConfig, readCachedSearchPayload, readNumberParam, readStringArrayParam, readStringParam, resolveProviderWebSearchPluginConfig, resolveSearchCacheTtlMs, resolveSearchTimeoutSeconds, withTrustedWebSearchEndpoint, writeCachedSearchPayload } from "openclaw/plugin-sdk/provider-web-search";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { readPluginPackageVersion } from "openclaw/plugin-sdk/extension-shared";
|
|
6
|
+
import { readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
|
|
7
|
+
//#region extensions/parallel/src/parallel-mcp-search.runtime.ts
|
|
8
|
+
const PARALLEL_MCP_SEARCH_URL = "https://search.parallel.ai/mcp";
|
|
9
|
+
const MCP_PROTOCOL_VERSION = "2025-06-18";
|
|
10
|
+
const MCP_TIMEOUT_SECONDS = 30;
|
|
11
|
+
const PARALLEL_MCP_ERROR_BODY_LIMIT_BYTES = 8 * 1024;
|
|
12
|
+
const PLUGIN_VERSION = readPluginPackageVersion({ require: createRequire(import.meta.url) });
|
|
13
|
+
const USER_AGENT = `openclaw-parallel/${PLUGIN_VERSION} (${process.platform})`;
|
|
14
|
+
function isRecord(value) {
|
|
15
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16
|
+
}
|
|
17
|
+
function mcpHeaders(params) {
|
|
18
|
+
const headers = {
|
|
19
|
+
"Content-Type": "application/json",
|
|
20
|
+
"User-Agent": USER_AGENT,
|
|
21
|
+
Accept: "application/json, text/event-stream"
|
|
22
|
+
};
|
|
23
|
+
if (params.sessionId) headers["Mcp-Session-Id"] = params.sessionId;
|
|
24
|
+
if (params.protocolVersion) headers["MCP-Protocol-Version"] = params.protocolVersion;
|
|
25
|
+
return headers;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Yield JSON-RPC message objects from a plain-JSON or SSE response body.
|
|
29
|
+
*
|
|
30
|
+
* Handles `application/json` (a single object) and `text/event-stream` (SSE:
|
|
31
|
+
* events separated by blank lines; an event's one-or-more `data:` lines
|
|
32
|
+
* concatenate into a single JSON payload). Streamable HTTP also allows batching
|
|
33
|
+
* responses into a JSON array, so arrays are flattened. Unparseable chunks and
|
|
34
|
+
* non-`data` SSE fields (`event:`/`id:`/comments) are skipped.
|
|
35
|
+
*/
|
|
36
|
+
function iterMcpMessages(text) {
|
|
37
|
+
const out = [];
|
|
38
|
+
const emit = (payload) => {
|
|
39
|
+
if (Array.isArray(payload)) {
|
|
40
|
+
for (const entry of payload) if (isRecord(entry)) out.push(entry);
|
|
41
|
+
} else if (isRecord(payload)) out.push(payload);
|
|
42
|
+
};
|
|
43
|
+
const body = (text ?? "").trim();
|
|
44
|
+
if (!body) return out;
|
|
45
|
+
if (body.startsWith("{") || body.startsWith("[")) {
|
|
46
|
+
try {
|
|
47
|
+
emit(JSON.parse(body));
|
|
48
|
+
} catch {}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
let dataLines = [];
|
|
52
|
+
const flush = () => {
|
|
53
|
+
if (dataLines.length === 0) return;
|
|
54
|
+
try {
|
|
55
|
+
emit(JSON.parse(dataLines.join("\n")));
|
|
56
|
+
} catch {}
|
|
57
|
+
dataLines = [];
|
|
58
|
+
};
|
|
59
|
+
for (const raw of body.split("\n")) {
|
|
60
|
+
const line = raw.replace(/\r$/, "");
|
|
61
|
+
if (line.startsWith("data:")) dataLines.push(line.slice(5).replace(/^ /, ""));
|
|
62
|
+
else if (line.trim() === "") flush();
|
|
63
|
+
}
|
|
64
|
+
flush();
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Select the JSON-RPC response for `requestId` from an MCP response body.
|
|
69
|
+
*
|
|
70
|
+
* Streamable-HTTP servers may emit progress/log notifications before the final
|
|
71
|
+
* result, so scan the whole stream and return the result/error message whose
|
|
72
|
+
* `id` matches. Falls back to the last result/error-bearing message if no id
|
|
73
|
+
* matches; `{}` if none is present.
|
|
74
|
+
*/
|
|
75
|
+
function selectMcpEnvelope(text, requestId) {
|
|
76
|
+
let fallback = {};
|
|
77
|
+
for (const msg of iterMcpMessages(text)) {
|
|
78
|
+
if (!("result" in msg || "error" in msg)) continue;
|
|
79
|
+
if (msg.id === requestId) return msg;
|
|
80
|
+
fallback = msg;
|
|
81
|
+
}
|
|
82
|
+
return fallback;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Extract the tool result payload from a `tools/call` envelope.
|
|
86
|
+
*
|
|
87
|
+
* Prefers `structuredContent` (authoritative machine-readable form); otherwise
|
|
88
|
+
* scans text blocks for the first JSON-parseable one. Throws on a JSON-RPC
|
|
89
|
+
* error or a tool-level `isError`.
|
|
90
|
+
*/
|
|
91
|
+
function extractMcpToolPayload(envelope) {
|
|
92
|
+
if ("error" in envelope) throw new Error(`Parallel MCP error: ${JSON.stringify(envelope.error).slice(0, 500)}`);
|
|
93
|
+
const result = isRecord(envelope.result) ? envelope.result : {};
|
|
94
|
+
if (result.isError) throw new Error(`Parallel MCP tool error: ${JSON.stringify(result).slice(0, 500)}`);
|
|
95
|
+
if (isRecord(result.structuredContent)) return result.structuredContent;
|
|
96
|
+
const content = Array.isArray(result.content) ? result.content : [];
|
|
97
|
+
for (const block of content) if (isRecord(block) && block.type === "text" && typeof block.text === "string" && block.text) try {
|
|
98
|
+
const parsed = JSON.parse(block.text);
|
|
99
|
+
if (isRecord(parsed)) return parsed;
|
|
100
|
+
} catch {}
|
|
101
|
+
throw new Error(`Parallel MCP returned no parseable content: ${JSON.stringify(result).slice(0, 500)}`);
|
|
102
|
+
}
|
|
103
|
+
async function postMcp(params) {
|
|
104
|
+
return withTrustedWebSearchEndpoint({
|
|
105
|
+
url: PARALLEL_MCP_SEARCH_URL,
|
|
106
|
+
timeoutSeconds: params.timeoutSeconds,
|
|
107
|
+
signal: params.signal,
|
|
108
|
+
init: {
|
|
109
|
+
method: "POST",
|
|
110
|
+
headers: mcpHeaders({
|
|
111
|
+
sessionId: params.sessionId,
|
|
112
|
+
protocolVersion: params.protocolVersion
|
|
113
|
+
}),
|
|
114
|
+
body: JSON.stringify(params.body)
|
|
115
|
+
}
|
|
116
|
+
}, async (response) => ({
|
|
117
|
+
ok: response.ok,
|
|
118
|
+
status: response.status,
|
|
119
|
+
statusText: response.statusText,
|
|
120
|
+
text: response.ok ? await response.text() : await readResponseTextLimited(response, PARALLEL_MCP_ERROR_BODY_LIMIT_BYTES),
|
|
121
|
+
sessionIdHeader: response.headers.get("mcp-session-id")
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Run the MCP handshake then a single `tools/call`, returning the tool payload.
|
|
126
|
+
*
|
|
127
|
+
* initialize -> (capture `Mcp-Session-Id` header + negotiated protocolVersion)
|
|
128
|
+
* -> notifications/initialized -> tools/call. Anonymous (no bearer token).
|
|
129
|
+
*/
|
|
130
|
+
async function mcpCall(toolName, args, timeoutSeconds, signal) {
|
|
131
|
+
const initId = randomUUID();
|
|
132
|
+
const init = await postMcp({
|
|
133
|
+
timeoutSeconds,
|
|
134
|
+
signal,
|
|
135
|
+
body: {
|
|
136
|
+
jsonrpc: "2.0",
|
|
137
|
+
id: initId,
|
|
138
|
+
method: "initialize",
|
|
139
|
+
params: {
|
|
140
|
+
protocolVersion: MCP_PROTOCOL_VERSION,
|
|
141
|
+
capabilities: {},
|
|
142
|
+
clientInfo: {
|
|
143
|
+
name: "openclaw-parallel",
|
|
144
|
+
version: PLUGIN_VERSION
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
if (!init.ok) throw new Error(`Parallel MCP initialize failed (${init.status}): ${init.text || init.statusText}`);
|
|
150
|
+
const sessionId = init.sessionIdHeader ?? void 0;
|
|
151
|
+
const initEnvelope = selectMcpEnvelope(init.text, initId);
|
|
152
|
+
const negotiatedVersion = (isRecord(initEnvelope.result) && typeof initEnvelope.result.protocolVersion === "string" ? initEnvelope.result.protocolVersion : void 0) ?? MCP_PROTOCOL_VERSION;
|
|
153
|
+
await postMcp({
|
|
154
|
+
body: {
|
|
155
|
+
jsonrpc: "2.0",
|
|
156
|
+
method: "notifications/initialized"
|
|
157
|
+
},
|
|
158
|
+
sessionId,
|
|
159
|
+
protocolVersion: negotiatedVersion,
|
|
160
|
+
timeoutSeconds,
|
|
161
|
+
signal
|
|
162
|
+
});
|
|
163
|
+
const callId = randomUUID();
|
|
164
|
+
const call = await postMcp({
|
|
165
|
+
body: {
|
|
166
|
+
jsonrpc: "2.0",
|
|
167
|
+
id: callId,
|
|
168
|
+
method: "tools/call",
|
|
169
|
+
params: {
|
|
170
|
+
name: toolName,
|
|
171
|
+
arguments: args
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
sessionId,
|
|
175
|
+
protocolVersion: negotiatedVersion,
|
|
176
|
+
timeoutSeconds,
|
|
177
|
+
signal
|
|
178
|
+
});
|
|
179
|
+
if (!call.ok) throw new Error(`Parallel MCP tools/call failed (${call.status}): ${call.text || call.statusText}`);
|
|
180
|
+
return extractMcpToolPayload(selectMcpEnvelope(call.text, callId));
|
|
181
|
+
}
|
|
182
|
+
function normalizeMcpSessionId(value) {
|
|
183
|
+
return value?.trim() || randomUUID();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Run a `web_search` tool call against the free hosted Search MCP and return a
|
|
187
|
+
* `ParallelSearchResponse`-compatible object so the runtime's existing result
|
|
188
|
+
* normalization (`normalizeParallelResults`) is reused verbatim.
|
|
189
|
+
*/
|
|
190
|
+
async function runParallelMcpSearch(params) {
|
|
191
|
+
const sessionId = normalizeMcpSessionId(params.sessionId);
|
|
192
|
+
const args = {
|
|
193
|
+
objective: params.objective ?? params.searchQueries.join(" "),
|
|
194
|
+
search_queries: [...params.searchQueries],
|
|
195
|
+
session_id: sessionId
|
|
196
|
+
};
|
|
197
|
+
if (params.modelName) args.model_name = params.modelName;
|
|
198
|
+
const payload = await mcpCall("web_search", args, params.timeoutSeconds ?? MCP_TIMEOUT_SECONDS, params.signal);
|
|
199
|
+
const results = (Array.isArray(payload.results) ? payload.results : []).slice(0, Math.max(params.maxResults, 1));
|
|
200
|
+
return {
|
|
201
|
+
search_id: typeof payload.search_id === "string" ? payload.search_id : void 0,
|
|
202
|
+
session_id: sessionId,
|
|
203
|
+
results,
|
|
204
|
+
warnings: payload.warnings,
|
|
205
|
+
usage: payload.usage
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region extensions/parallel/src/parallel-free-web-search-provider.runtime.ts
|
|
210
|
+
async function executeParallelFreeWebSearchProviderTool(ctx, args, signal) {
|
|
211
|
+
const searchConfig = mergeScopedSearchConfig(ctx.searchConfig, "parallel-free", resolveProviderWebSearchPluginConfig(ctx.config, "parallel-free"));
|
|
212
|
+
const objective = normalizeParallelObjective(readStringParam(args, "objective"));
|
|
213
|
+
const cliQuery = normalizeParallelObjective(readStringParam(args, "query"));
|
|
214
|
+
let searchQueries = normalizeParallelSearchQueries(readStringArrayParam(args, "search_queries"));
|
|
215
|
+
if (searchQueries.length === 0 && cliQuery) searchQueries = normalizeParallelSearchQueries([cliQuery]);
|
|
216
|
+
if (searchQueries.length === 0) return invalidSearchQueriesPayload();
|
|
217
|
+
const count = resolveParallelSearchCount(readNumberParam(args, "count", { integer: true }) ?? (typeof searchConfig?.maxResults === "number" ? searchConfig.maxResults : void 0) ?? DEFAULT_SEARCH_COUNT);
|
|
218
|
+
const sessionId = normalizeParallelSessionId(readStringParam(args, "session_id"), 100);
|
|
219
|
+
const clientModel = normalizeParallelClientModel(readStringParam(args, "client_model"));
|
|
220
|
+
const cacheKey = buildParallelCacheKey({
|
|
221
|
+
endpoint: PARALLEL_MCP_SEARCH_URL,
|
|
222
|
+
objective,
|
|
223
|
+
searchQueries,
|
|
224
|
+
count,
|
|
225
|
+
sessionId,
|
|
226
|
+
clientModel
|
|
227
|
+
});
|
|
228
|
+
const cached = readCachedSearchPayload(cacheKey);
|
|
229
|
+
if (cached) return cached;
|
|
230
|
+
const start = Date.now();
|
|
231
|
+
const response = await runParallelMcpSearch({
|
|
232
|
+
objective,
|
|
233
|
+
searchQueries,
|
|
234
|
+
maxResults: count,
|
|
235
|
+
sessionId,
|
|
236
|
+
modelName: clientModel,
|
|
237
|
+
timeoutSeconds: resolveSearchTimeoutSeconds(searchConfig),
|
|
238
|
+
signal
|
|
239
|
+
});
|
|
240
|
+
const results = mapParallelResults(response);
|
|
241
|
+
const payload = {
|
|
242
|
+
...objective ? { objective } : {},
|
|
243
|
+
searchQueries,
|
|
244
|
+
provider: "parallel-free",
|
|
245
|
+
count: results.length,
|
|
246
|
+
tookMs: Date.now() - start,
|
|
247
|
+
externalContent: {
|
|
248
|
+
untrusted: true,
|
|
249
|
+
source: "web_search",
|
|
250
|
+
provider: "parallel-free",
|
|
251
|
+
wrapped: true
|
|
252
|
+
},
|
|
253
|
+
results
|
|
254
|
+
};
|
|
255
|
+
if (typeof response.search_id === "string") payload.searchId = response.search_id;
|
|
256
|
+
if (typeof response.session_id === "string") payload.sessionId = response.session_id;
|
|
257
|
+
if (Array.isArray(response.warnings) && response.warnings.length > 0) payload.warnings = response.warnings;
|
|
258
|
+
if (Array.isArray(response.usage) && response.usage.length > 0) payload.usage = response.usage;
|
|
259
|
+
writeCachedSearchPayload(cacheKey, sessionId ? payload : stripParallelGeneratedSessionId(payload), resolveSearchCacheTtlMs(searchConfig));
|
|
260
|
+
return payload;
|
|
261
|
+
}
|
|
262
|
+
//#endregion
|
|
263
|
+
export { executeParallelFreeWebSearchProviderTool };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { a as invalidSearchQueriesPayload, c as normalizeParallelObjective, d as normalizeParallelSessionId, f as resolveParallelSearchCount, i as buildParallelCacheKey, l as normalizeParallelResults, o as mapParallelResults, p as stripParallelGeneratedSessionId, r as PARALLEL_SESSION_ID_MAX_LENGTH, s as normalizeParallelClientModel, u as normalizeParallelSearchQueries } from "./parallel-free-web-search-provider-NaOJ6_QF.js";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { DEFAULT_SEARCH_COUNT, mergeScopedSearchConfig, readCachedSearchPayload, readConfiguredSecretString, readNumberParam, readProviderEnvValue, readStringArrayParam, readStringParam, resolveProviderWebSearchPluginConfig, resolveSearchCacheTtlMs, resolveSearchTimeoutSeconds, withTrustedWebSearchEndpoint, writeCachedSearchPayload } from "openclaw/plugin-sdk/provider-web-search";
|
|
4
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
|
+
import { readPluginPackageVersion } from "openclaw/plugin-sdk/extension-shared";
|
|
6
|
+
import { readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
|
|
7
|
+
//#region extensions/parallel/src/parallel-web-search-provider.runtime.ts
|
|
8
|
+
const PARALLEL_BASE_URL = "https://api.parallel.ai";
|
|
9
|
+
const PARALLEL_SEARCH_PATHNAME = "/v1/search";
|
|
10
|
+
const PARALLEL_ERROR_BODY_LIMIT_BYTES = 8 * 1024;
|
|
11
|
+
const USER_AGENT = `openclaw-parallel/${readPluginPackageVersion({ require: createRequire(import.meta.url) })} (${process.platform})`;
|
|
12
|
+
function resolveParallelConfig(searchConfig) {
|
|
13
|
+
const parallel = searchConfig?.parallel;
|
|
14
|
+
return parallel && typeof parallel === "object" && !Array.isArray(parallel) ? parallel : {};
|
|
15
|
+
}
|
|
16
|
+
function resolveParallelApiKey(parallel) {
|
|
17
|
+
return readConfiguredSecretString(parallel?.apiKey, "tools.web.search.parallel.apiKey") ?? readProviderEnvValue(["PARALLEL_API_KEY"]);
|
|
18
|
+
}
|
|
19
|
+
function invalidBaseUrlPayload(value) {
|
|
20
|
+
return {
|
|
21
|
+
error: "invalid_base_url",
|
|
22
|
+
message: `plugins.entries.parallel.config.webSearch.baseUrl must be a valid http(s) URL. Got: ${value}`,
|
|
23
|
+
docs: "https://docs.openclaw.ai/tools/parallel-search"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function resolveParallelSearchEndpoint(parallel) {
|
|
27
|
+
const configured = normalizeOptionalString(parallel?.baseUrl);
|
|
28
|
+
if (!configured) return { endpoint: `${PARALLEL_BASE_URL}${PARALLEL_SEARCH_PATHNAME}` };
|
|
29
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(configured) && !/^https?:\/\//i.test(configured)) return invalidBaseUrlPayload(configured);
|
|
30
|
+
const candidate = /^https?:\/\//i.test(configured) ? configured : `https://${configured}`;
|
|
31
|
+
let parsed;
|
|
32
|
+
try {
|
|
33
|
+
parsed = new URL(candidate);
|
|
34
|
+
} catch {
|
|
35
|
+
return invalidBaseUrlPayload(configured);
|
|
36
|
+
}
|
|
37
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return invalidBaseUrlPayload(configured);
|
|
38
|
+
const pathname = parsed.pathname.replace(/\/+$/, "");
|
|
39
|
+
parsed.pathname = pathname.endsWith(PARALLEL_SEARCH_PATHNAME) ? pathname : `${pathname === "" ? "" : pathname}${PARALLEL_SEARCH_PATHNAME}`;
|
|
40
|
+
parsed.hash = "";
|
|
41
|
+
return { endpoint: parsed.toString() };
|
|
42
|
+
}
|
|
43
|
+
function missingParallelKeyPayload() {
|
|
44
|
+
return {
|
|
45
|
+
error: "missing_parallel_api_key",
|
|
46
|
+
message: "web_search (parallel) needs a Parallel API key. Set PARALLEL_API_KEY in the Gateway environment, or configure plugins.entries.parallel.config.webSearch.apiKey.",
|
|
47
|
+
docs: "https://docs.openclaw.ai/tools/parallel-search"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async function runParallelSearch(params) {
|
|
51
|
+
const body = {
|
|
52
|
+
search_queries: [...params.searchQueries],
|
|
53
|
+
advanced_settings: { max_results: params.maxResults }
|
|
54
|
+
};
|
|
55
|
+
if (params.objective) body.objective = params.objective;
|
|
56
|
+
if (params.sessionId) body.session_id = params.sessionId;
|
|
57
|
+
if (params.clientModel) body.client_model = params.clientModel;
|
|
58
|
+
return withTrustedWebSearchEndpoint({
|
|
59
|
+
url: params.endpoint,
|
|
60
|
+
timeoutSeconds: params.timeoutSeconds,
|
|
61
|
+
init: {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: {
|
|
64
|
+
Accept: "application/json",
|
|
65
|
+
"Content-Type": "application/json",
|
|
66
|
+
"x-api-key": params.apiKey,
|
|
67
|
+
"User-Agent": USER_AGENT
|
|
68
|
+
},
|
|
69
|
+
body: JSON.stringify(body)
|
|
70
|
+
}
|
|
71
|
+
}, async (res) => {
|
|
72
|
+
if (!res.ok) {
|
|
73
|
+
const detail = await readResponseTextLimited(res, PARALLEL_ERROR_BODY_LIMIT_BYTES).catch(() => "");
|
|
74
|
+
throw new Error(`Parallel API error (${res.status}): ${detail || res.statusText}`);
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
return await res.json();
|
|
78
|
+
} catch (cause) {
|
|
79
|
+
throw new Error("Parallel API returned malformed JSON", { cause });
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async function executeParallelWebSearchProviderTool(ctx, args) {
|
|
84
|
+
const searchConfig = mergeScopedSearchConfig(ctx.searchConfig, "parallel", resolveProviderWebSearchPluginConfig(ctx.config, "parallel"));
|
|
85
|
+
const parallelConfig = resolveParallelConfig(searchConfig);
|
|
86
|
+
const apiKey = resolveParallelApiKey(parallelConfig);
|
|
87
|
+
if (!apiKey) return missingParallelKeyPayload();
|
|
88
|
+
const endpointResult = resolveParallelSearchEndpoint(parallelConfig);
|
|
89
|
+
if ("error" in endpointResult) return endpointResult;
|
|
90
|
+
const endpoint = endpointResult.endpoint;
|
|
91
|
+
const objective = normalizeParallelObjective(readStringParam(args, "objective"));
|
|
92
|
+
const cliQuery = normalizeParallelObjective(readStringParam(args, "query"));
|
|
93
|
+
let searchQueries = normalizeParallelSearchQueries(readStringArrayParam(args, "search_queries"));
|
|
94
|
+
if (searchQueries.length === 0 && cliQuery) searchQueries = normalizeParallelSearchQueries([cliQuery]);
|
|
95
|
+
if (searchQueries.length === 0) return invalidSearchQueriesPayload();
|
|
96
|
+
const count = resolveParallelSearchCount(readNumberParam(args, "count", { integer: true }) ?? (typeof searchConfig?.maxResults === "number" ? searchConfig.maxResults : void 0) ?? DEFAULT_SEARCH_COUNT);
|
|
97
|
+
const sessionId = normalizeParallelSessionId(readStringParam(args, "session_id"), PARALLEL_SESSION_ID_MAX_LENGTH);
|
|
98
|
+
const clientModel = normalizeParallelClientModel(readStringParam(args, "client_model"));
|
|
99
|
+
const cacheKey = buildParallelCacheKey({
|
|
100
|
+
endpoint,
|
|
101
|
+
objective,
|
|
102
|
+
searchQueries,
|
|
103
|
+
count,
|
|
104
|
+
sessionId,
|
|
105
|
+
clientModel
|
|
106
|
+
});
|
|
107
|
+
const cached = readCachedSearchPayload(cacheKey);
|
|
108
|
+
if (cached) return cached;
|
|
109
|
+
const start = Date.now();
|
|
110
|
+
const response = await runParallelSearch({
|
|
111
|
+
apiKey,
|
|
112
|
+
endpoint,
|
|
113
|
+
objective,
|
|
114
|
+
searchQueries,
|
|
115
|
+
maxResults: count,
|
|
116
|
+
sessionId,
|
|
117
|
+
clientModel,
|
|
118
|
+
timeoutSeconds: resolveSearchTimeoutSeconds(searchConfig)
|
|
119
|
+
});
|
|
120
|
+
const results = mapParallelResults(response);
|
|
121
|
+
const payload = {
|
|
122
|
+
...objective ? { objective } : {},
|
|
123
|
+
searchQueries,
|
|
124
|
+
provider: "parallel",
|
|
125
|
+
count: results.length,
|
|
126
|
+
tookMs: Date.now() - start,
|
|
127
|
+
externalContent: {
|
|
128
|
+
untrusted: true,
|
|
129
|
+
source: "web_search",
|
|
130
|
+
provider: "parallel",
|
|
131
|
+
wrapped: true
|
|
132
|
+
},
|
|
133
|
+
results
|
|
134
|
+
};
|
|
135
|
+
if (typeof response.search_id === "string") payload.searchId = response.search_id;
|
|
136
|
+
if (typeof response.session_id === "string") payload.sessionId = response.session_id;
|
|
137
|
+
if (Array.isArray(response.warnings) && response.warnings.length > 0) payload.warnings = response.warnings;
|
|
138
|
+
if (Array.isArray(response.usage) && response.usage.length > 0) payload.usage = response.usage;
|
|
139
|
+
writeCachedSearchPayload(cacheKey, sessionId ? payload : stripParallelGeneratedSessionId(payload), resolveSearchCacheTtlMs(searchConfig));
|
|
140
|
+
return payload;
|
|
141
|
+
}
|
|
142
|
+
const testing = {
|
|
143
|
+
buildParallelCacheKey,
|
|
144
|
+
invalidSearchQueriesPayload,
|
|
145
|
+
missingParallelKeyPayload,
|
|
146
|
+
normalizeParallelClientModel,
|
|
147
|
+
normalizeParallelObjective,
|
|
148
|
+
normalizeParallelResults,
|
|
149
|
+
normalizeParallelSearchQueries,
|
|
150
|
+
normalizeParallelSessionId,
|
|
151
|
+
resolveParallelApiKey,
|
|
152
|
+
resolveParallelConfig,
|
|
153
|
+
resolveParallelSearchCount,
|
|
154
|
+
resolveParallelSearchEndpoint,
|
|
155
|
+
PARALLEL_ERROR_BODY_LIMIT_BYTES,
|
|
156
|
+
USER_AGENT
|
|
157
|
+
};
|
|
158
|
+
//#endregion
|
|
159
|
+
export { testing as __testing, testing, executeParallelWebSearchProviderTool };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createWebSearchProviderContractFields } from "openclaw/plugin-sdk/provider-web-search-contract";
|
|
2
|
+
//#region extensions/parallel/src/parallel-free-web-search-provider.shared.ts
|
|
3
|
+
const PARALLEL_FREE_ONBOARDING_SCOPES = ["text-inference"];
|
|
4
|
+
function createParallelFreeWebSearchProviderBase() {
|
|
5
|
+
return {
|
|
6
|
+
id: "parallel-free",
|
|
7
|
+
label: "Parallel Search (Free)",
|
|
8
|
+
hint: "Free web search via Parallel's hosted Search MCP — no API key required",
|
|
9
|
+
onboardingScopes: [...PARALLEL_FREE_ONBOARDING_SCOPES],
|
|
10
|
+
requiresCredential: false,
|
|
11
|
+
envVars: [],
|
|
12
|
+
placeholder: "(no key needed)",
|
|
13
|
+
signupUrl: "https://parallel.ai",
|
|
14
|
+
docsUrl: "https://docs.openclaw.ai/tools/parallel-search",
|
|
15
|
+
credentialPath: "",
|
|
16
|
+
...createWebSearchProviderContractFields({
|
|
17
|
+
credentialPath: "",
|
|
18
|
+
searchCredential: {
|
|
19
|
+
type: "scoped",
|
|
20
|
+
scopeId: "parallel-free"
|
|
21
|
+
},
|
|
22
|
+
selectionPluginId: "parallel"
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region extensions/parallel/src/parallel-web-search-provider.shared.ts
|
|
28
|
+
const PARALLEL_CREDENTIAL_PATH = "plugins.entries.parallel.config.webSearch.apiKey";
|
|
29
|
+
const PARALLEL_ONBOARDING_SCOPES = ["text-inference"];
|
|
30
|
+
function createParallelWebSearchProviderBase() {
|
|
31
|
+
return {
|
|
32
|
+
id: "parallel",
|
|
33
|
+
label: "Parallel Search",
|
|
34
|
+
hint: "LLM-optimized dense excerpts from web sources",
|
|
35
|
+
onboardingScopes: [...PARALLEL_ONBOARDING_SCOPES],
|
|
36
|
+
credentialLabel: "Parallel API key",
|
|
37
|
+
envVars: ["PARALLEL_API_KEY"],
|
|
38
|
+
placeholder: "par-...",
|
|
39
|
+
signupUrl: "https://platform.parallel.ai",
|
|
40
|
+
docsUrl: "https://docs.openclaw.ai/tools/parallel-search",
|
|
41
|
+
autoDetectOrder: 75,
|
|
42
|
+
credentialPath: PARALLEL_CREDENTIAL_PATH,
|
|
43
|
+
...createWebSearchProviderContractFields({
|
|
44
|
+
credentialPath: PARALLEL_CREDENTIAL_PATH,
|
|
45
|
+
searchCredential: {
|
|
46
|
+
type: "scoped",
|
|
47
|
+
scopeId: "parallel"
|
|
48
|
+
},
|
|
49
|
+
configuredCredential: { pluginId: "parallel" },
|
|
50
|
+
selectionPluginId: "parallel"
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { createParallelFreeWebSearchProviderBase as n, createParallelWebSearchProviderBase as t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { n as createParallelFreeWebSearchProviderBase, t as createParallelWebSearchProviderBase } from "./parallel-web-search-provider.shared-B8yrY1oc.js";
|
|
2
|
+
//#region extensions/parallel/web-search-contract-api.ts
|
|
3
|
+
function createParallelWebSearchProvider() {
|
|
4
|
+
return {
|
|
5
|
+
...createParallelWebSearchProviderBase(),
|
|
6
|
+
createTool: () => null
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function createParallelFreeWebSearchProvider() {
|
|
10
|
+
return {
|
|
11
|
+
...createParallelFreeWebSearchProviderBase(),
|
|
12
|
+
createTool: () => null
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { createParallelFreeWebSearchProvider, createParallelWebSearchProvider };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "parallel",
|
|
3
|
+
"activation": {
|
|
4
|
+
"onStartup": false
|
|
5
|
+
},
|
|
6
|
+
"setup": {
|
|
7
|
+
"providers": [
|
|
8
|
+
{
|
|
9
|
+
"id": "parallel",
|
|
10
|
+
"envVars": ["PARALLEL_API_KEY"]
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"uiHints": {
|
|
15
|
+
"webSearch.apiKey": {
|
|
16
|
+
"label": "Parallel API Key",
|
|
17
|
+
"help": "Parallel Search API key (fallback: PARALLEL_API_KEY env var).",
|
|
18
|
+
"sensitive": true,
|
|
19
|
+
"placeholder": "par-..."
|
|
20
|
+
},
|
|
21
|
+
"webSearch.baseUrl": {
|
|
22
|
+
"label": "Parallel Search Base URL",
|
|
23
|
+
"help": "Optional Parallel API base URL override. OpenClaw appends /v1/search when the URL does not already end there."
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"contracts": {
|
|
27
|
+
"webSearchProviders": ["parallel", "parallel-free"]
|
|
28
|
+
},
|
|
29
|
+
"configContracts": {
|
|
30
|
+
"compatibilityRuntimePaths": ["tools.web.search.apiKey"]
|
|
31
|
+
},
|
|
32
|
+
"configSchema": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"additionalProperties": false,
|
|
35
|
+
"properties": {
|
|
36
|
+
"webSearch": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"additionalProperties": false,
|
|
39
|
+
"properties": {
|
|
40
|
+
"apiKey": {
|
|
41
|
+
"type": ["string", "object"]
|
|
42
|
+
},
|
|
43
|
+
"baseUrl": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/parallel-plugin",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"license": "MIT",
|
|
3
|
+
"version": "2026.6.9",
|
|
4
|
+
"description": "OpenClaw Parallel web search plugin.",
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
8
|
-
"url": "
|
|
7
|
+
"url": "https://github.com/openclaw/openclaw"
|
|
9
8
|
},
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
9
|
+
"type": "module",
|
|
10
|
+
"openclaw": {
|
|
11
|
+
"extensions": [
|
|
12
|
+
"./index.ts"
|
|
13
|
+
],
|
|
14
|
+
"install": {
|
|
15
|
+
"clawhubSpec": "clawhub:@openclaw/parallel-plugin",
|
|
16
|
+
"npmSpec": "@openclaw/parallel-plugin",
|
|
17
|
+
"defaultChoice": "npm",
|
|
18
|
+
"minHostVersion": ">=2026.6.8"
|
|
19
|
+
},
|
|
20
|
+
"compat": {
|
|
21
|
+
"pluginApi": ">=2026.6.9"
|
|
22
|
+
},
|
|
23
|
+
"build": {
|
|
24
|
+
"openclawVersion": "2026.6.9",
|
|
25
|
+
"bundledDist": false
|
|
26
|
+
},
|
|
27
|
+
"release": {
|
|
28
|
+
"publishToClawHub": true,
|
|
29
|
+
"publishToNpm": true
|
|
30
|
+
},
|
|
31
|
+
"runtimeExtensions": [
|
|
32
|
+
"./dist/index.js"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist/**",
|
|
37
|
+
"openclaw.plugin.json",
|
|
38
|
+
"npm-shrinkwrap.json",
|
|
39
|
+
"README.md"
|
|
40
|
+
],
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"openclaw": ">=2026.6.9"
|
|
43
|
+
},
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"openclaw": {
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"bundledDependencies": []
|
|
14
50
|
}
|