@openclaw/parallel-plugin 2026.11.3 → 2026.11.5-beta.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/dist/.setup/{parallel-free-web-search-provider-beCN4WUk.mjs → parallel-free-web-search-provider-Bc9ZvxIO.mjs} +21 -29
- package/dist/.setup/{parallel-free-web-search-provider.runtime-D3QNHPgE.mjs → parallel-free-web-search-provider.runtime-yJVscbpB.mjs} +90 -116
- package/dist/.setup/{parallel-search-normalize-CEpdeSGa.mjs → parallel-search-normalize-DLUK82z5.mjs} +44 -56
- package/dist/.setup/{parallel-web-search-provider.runtime-BwODKe5v.mjs → parallel-web-search-provider.runtime-Da3yvfmk.mjs} +22 -28
- package/dist/.source-module-urls/27482ad366c62469825181c2e46191eaffa65a05c60872aec27402a3a0f3f87c.json +1 -0
- package/dist/index.js +1 -1
- package/dist/web-search-contract-api.js +1 -2
- package/dist/web-search-provider.js +1 -2
- package/package.json +4 -4
|
@@ -1,31 +1,5 @@
|
|
|
1
1
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
2
2
|
import { createWebSearchProviderContractFields } from "openclaw/plugin-sdk/provider-web-search-contract";
|
|
3
|
-
//#region extensions/parallel/src/parallel-free-web-search-provider.shared.ts
|
|
4
|
-
const PARALLEL_FREE_ONBOARDING_SCOPES = ["text-inference"];
|
|
5
|
-
function createParallelFreeWebSearchProviderBase() {
|
|
6
|
-
return {
|
|
7
|
-
id: "parallel-free",
|
|
8
|
-
label: "Parallel Search (Free)",
|
|
9
|
-
hint: "Free web search via Parallel's hosted Search MCP — no API key required",
|
|
10
|
-
configPath: null,
|
|
11
|
-
onboardingScopes: [...PARALLEL_FREE_ONBOARDING_SCOPES],
|
|
12
|
-
requiresCredential: false,
|
|
13
|
-
envVars: [],
|
|
14
|
-
placeholder: "(no key needed)",
|
|
15
|
-
signupUrl: "https://parallel.ai",
|
|
16
|
-
docsUrl: "https://docs.openclaw.ai/tools/parallel-search",
|
|
17
|
-
credentialPath: "",
|
|
18
|
-
...createWebSearchProviderContractFields({
|
|
19
|
-
credentialPath: "",
|
|
20
|
-
searchCredential: {
|
|
21
|
-
type: "scoped",
|
|
22
|
-
scopeId: "parallel-free"
|
|
23
|
-
},
|
|
24
|
-
selectionPluginId: "parallel"
|
|
25
|
-
})
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
3
|
//#region extensions/parallel/src/parallel-web-search-provider.ts
|
|
30
4
|
const PARALLEL_CREDENTIAL_PATH = "plugins.entries.parallel.config.webSearch.apiKey";
|
|
31
5
|
const PARALLEL_MAX_SEARCH_COUNT = 40;
|
|
@@ -34,7 +8,7 @@ const PARALLEL_MAX_SEARCH_QUERY_CHARS = 200;
|
|
|
34
8
|
const PARALLEL_MAX_OBJECTIVE_CHARS = 5e3;
|
|
35
9
|
const PARALLEL_MAX_SESSION_ID_CHARS = 1e3;
|
|
36
10
|
const PARALLEL_MAX_CLIENT_MODEL_CHARS = 100;
|
|
37
|
-
const loadParallelWebSearchRuntime = createLazyRuntimeModule(() => import("./parallel-web-search-provider.runtime-
|
|
11
|
+
const loadParallelWebSearchRuntime = createLazyRuntimeModule(() => import("./parallel-web-search-provider.runtime-Da3yvfmk.mjs"));
|
|
38
12
|
const ParallelSearchSchema = {
|
|
39
13
|
type: "object",
|
|
40
14
|
properties: {
|
|
@@ -118,10 +92,28 @@ const ParallelFreeSearchSchema = {
|
|
|
118
92
|
}
|
|
119
93
|
}
|
|
120
94
|
};
|
|
121
|
-
const loadParallelFreeWebSearchRuntime = createLazyRuntimeModule(() => import("./parallel-free-web-search-provider.runtime-
|
|
95
|
+
const loadParallelFreeWebSearchRuntime = createLazyRuntimeModule(() => import("./parallel-free-web-search-provider.runtime-yJVscbpB.mjs"));
|
|
122
96
|
function createParallelFreeWebSearchProvider() {
|
|
123
97
|
return {
|
|
124
|
-
|
|
98
|
+
id: "parallel-free",
|
|
99
|
+
label: "Parallel Search (Free)",
|
|
100
|
+
hint: "Free web search via Parallel's hosted Search MCP — no API key required",
|
|
101
|
+
configPath: null,
|
|
102
|
+
onboardingScopes: ["text-inference"],
|
|
103
|
+
requiresCredential: false,
|
|
104
|
+
envVars: [],
|
|
105
|
+
placeholder: "(no key needed)",
|
|
106
|
+
signupUrl: "https://parallel.ai",
|
|
107
|
+
docsUrl: "https://docs.openclaw.ai/tools/parallel-search",
|
|
108
|
+
credentialPath: "",
|
|
109
|
+
...createWebSearchProviderContractFields({
|
|
110
|
+
credentialPath: "",
|
|
111
|
+
searchCredential: {
|
|
112
|
+
type: "scoped",
|
|
113
|
+
scopeId: "parallel-free"
|
|
114
|
+
},
|
|
115
|
+
selectionPluginId: "parallel"
|
|
116
|
+
}),
|
|
125
117
|
createTool: (ctx) => ({
|
|
126
118
|
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.",
|
|
127
119
|
parameters: ParallelFreeSearchSchema,
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { t as executeParallelSearchRequest } from "./parallel-search-normalize-
|
|
1
|
+
import { t as executeParallelSearchRequest } from "./parallel-search-normalize-DLUK82z5.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { mergeScopedSearchConfig, resolveProviderWebSearchPluginConfig, withTrustedWebSearchEndpoint } from "openclaw/plugin-sdk/provider-web-search";
|
|
4
3
|
import { randomUUID } from "node:crypto";
|
|
5
4
|
import { readPluginPackageVersion } from "openclaw/plugin-sdk/extension-shared";
|
|
6
5
|
import { ProviderHttpError, readProviderTextResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
|
|
6
|
+
import { mergeScopedSearchConfig, resolveProviderWebSearchPluginConfig, withTrustedWebSearchEndpoint } from "openclaw/plugin-sdk/provider-web-search";
|
|
7
7
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
|
-
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
9
|
-
//#region extensions/parallel/src/parallel-
|
|
8
|
+
import { safeParseJson, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
9
|
+
//#region extensions/parallel/src/parallel-free-web-search-provider.runtime.ts
|
|
10
10
|
const PARALLEL_MCP_SEARCH_URL = "https://search.parallel.ai/mcp";
|
|
11
11
|
const MCP_PROTOCOL_VERSION = "2025-06-18";
|
|
12
|
-
const MCP_TIMEOUT_SECONDS = 30;
|
|
13
12
|
const PARALLEL_MCP_ERROR_BODY_LIMIT_BYTES = 8192;
|
|
14
13
|
const require = createRequire(import.meta.url);
|
|
15
14
|
const PLUGIN_VERSION = readPluginPackageVersion({ require });
|
|
@@ -27,12 +26,8 @@ function selectMcpEnvelope(text, requestId) {
|
|
|
27
26
|
return message.id === requestId;
|
|
28
27
|
};
|
|
29
28
|
const selectPayload = (json) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return Array.isArray(payload) ? payload.some(selectMessage) : selectMessage(payload);
|
|
33
|
-
} catch {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
29
|
+
const payload = safeParseJson(json);
|
|
30
|
+
return Array.isArray(payload) ? payload.some(selectMessage) : selectMessage(payload);
|
|
36
31
|
};
|
|
37
32
|
const body = text.trim();
|
|
38
33
|
if (!body) return envelope;
|
|
@@ -68,106 +63,12 @@ function extractMcpToolPayload(envelope) {
|
|
|
68
63
|
if (result.isError) throw new Error(`Parallel MCP tool error: ${truncateUtf16Safe(JSON.stringify(result), 500)}`);
|
|
69
64
|
if (isRecord(result.structuredContent)) return result.structuredContent;
|
|
70
65
|
const content = Array.isArray(result.content) ? result.content : [];
|
|
71
|
-
for (const block of content) if (isRecord(block) && block.type === "text" && typeof block.text === "string" && block.text)
|
|
72
|
-
const parsed =
|
|
66
|
+
for (const block of content) if (isRecord(block) && block.type === "text" && typeof block.text === "string" && block.text) {
|
|
67
|
+
const parsed = safeParseJson(block.text);
|
|
73
68
|
if (isRecord(parsed)) return parsed;
|
|
74
|
-
}
|
|
69
|
+
}
|
|
75
70
|
throw new Error(`Parallel MCP returned no parseable content: ${truncateUtf16Safe(JSON.stringify(result), 500)}`);
|
|
76
71
|
}
|
|
77
|
-
async function postMcp(params) {
|
|
78
|
-
return withTrustedWebSearchEndpoint({
|
|
79
|
-
url: PARALLEL_MCP_SEARCH_URL,
|
|
80
|
-
timeoutSeconds: params.timeoutSeconds,
|
|
81
|
-
signal: params.signal,
|
|
82
|
-
init: {
|
|
83
|
-
method: "POST",
|
|
84
|
-
headers: {
|
|
85
|
-
"Content-Type": "application/json",
|
|
86
|
-
"User-Agent": USER_AGENT,
|
|
87
|
-
Accept: "application/json, text/event-stream",
|
|
88
|
-
...params.sessionId ? { "Mcp-Session-Id": params.sessionId } : {},
|
|
89
|
-
...params.protocolVersion ? { "MCP-Protocol-Version": params.protocolVersion } : {}
|
|
90
|
-
},
|
|
91
|
-
body: JSON.stringify(params.body)
|
|
92
|
-
}
|
|
93
|
-
}, async (response) => {
|
|
94
|
-
if (!response.ok) {
|
|
95
|
-
const detail = await readResponseTextLimited(response, PARALLEL_MCP_ERROR_BODY_LIMIT_BYTES);
|
|
96
|
-
throw new ProviderHttpError(`Parallel MCP ${params.body.method} failed (${response.status}): ${detail || response.statusText}`, { status: response.status });
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
text: await readProviderTextResponse(response, "Parallel MCP"),
|
|
100
|
-
sessionIdHeader: response.headers.get("mcp-session-id")
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
async function runParallelMcpSearch(params) {
|
|
105
|
-
const sessionId = params.sessionId?.trim() || randomUUID();
|
|
106
|
-
const timeoutSeconds = params.timeoutSeconds ?? MCP_TIMEOUT_SECONDS;
|
|
107
|
-
const args = {
|
|
108
|
-
objective: params.objective ?? params.searchQueries.join(" "),
|
|
109
|
-
search_queries: [...params.searchQueries],
|
|
110
|
-
session_id: sessionId
|
|
111
|
-
};
|
|
112
|
-
if (params.modelName) args.model_name = params.modelName;
|
|
113
|
-
const initId = randomUUID();
|
|
114
|
-
const init = await postMcp({
|
|
115
|
-
timeoutSeconds,
|
|
116
|
-
signal: params.signal,
|
|
117
|
-
body: {
|
|
118
|
-
jsonrpc: "2.0",
|
|
119
|
-
id: initId,
|
|
120
|
-
method: "initialize",
|
|
121
|
-
params: {
|
|
122
|
-
protocolVersion: MCP_PROTOCOL_VERSION,
|
|
123
|
-
capabilities: {},
|
|
124
|
-
clientInfo: {
|
|
125
|
-
name: "openclaw-parallel",
|
|
126
|
-
version: PLUGIN_VERSION
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
const mcpSessionId = init.sessionIdHeader ?? void 0;
|
|
132
|
-
const initEnvelope = selectMcpEnvelope(init.text, initId);
|
|
133
|
-
const negotiatedVersion = (isRecord(initEnvelope.result) && typeof initEnvelope.result.protocolVersion === "string" ? initEnvelope.result.protocolVersion : void 0) ?? MCP_PROTOCOL_VERSION;
|
|
134
|
-
await postMcp({
|
|
135
|
-
body: {
|
|
136
|
-
jsonrpc: "2.0",
|
|
137
|
-
method: "notifications/initialized"
|
|
138
|
-
},
|
|
139
|
-
sessionId: mcpSessionId,
|
|
140
|
-
protocolVersion: negotiatedVersion,
|
|
141
|
-
timeoutSeconds,
|
|
142
|
-
signal: params.signal
|
|
143
|
-
});
|
|
144
|
-
const callId = randomUUID();
|
|
145
|
-
const payload = extractMcpToolPayload(selectMcpEnvelope((await postMcp({
|
|
146
|
-
body: {
|
|
147
|
-
jsonrpc: "2.0",
|
|
148
|
-
id: callId,
|
|
149
|
-
method: "tools/call",
|
|
150
|
-
params: {
|
|
151
|
-
name: "web_search",
|
|
152
|
-
arguments: args
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
sessionId: mcpSessionId,
|
|
156
|
-
protocolVersion: negotiatedVersion,
|
|
157
|
-
timeoutSeconds,
|
|
158
|
-
signal: params.signal
|
|
159
|
-
})).text, callId));
|
|
160
|
-
const results = (Array.isArray(payload.results) ? payload.results : []).slice(0, Math.max(params.maxResults, 1));
|
|
161
|
-
return {
|
|
162
|
-
search_id: typeof payload.search_id === "string" ? payload.search_id : void 0,
|
|
163
|
-
session_id: sessionId,
|
|
164
|
-
results,
|
|
165
|
-
warnings: payload.warnings,
|
|
166
|
-
usage: payload.usage
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
//#endregion
|
|
170
|
-
//#region extensions/parallel/src/parallel-free-web-search-provider.runtime.ts
|
|
171
72
|
async function executeParallelFreeWebSearchProviderTool(ctx, args, signal) {
|
|
172
73
|
signal?.throwIfAborted();
|
|
173
74
|
const searchConfig = mergeScopedSearchConfig(ctx.searchConfig, "parallel-free", resolveProviderWebSearchPluginConfig(ctx.config, "parallel-free"));
|
|
@@ -176,14 +77,87 @@ async function executeParallelFreeWebSearchProviderTool(ctx, args, signal) {
|
|
|
176
77
|
endpoint: PARALLEL_MCP_SEARCH_URL,
|
|
177
78
|
args,
|
|
178
79
|
searchConfig,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
80
|
+
search: async (request, timeoutSeconds) => {
|
|
81
|
+
const postMcp = (params) => withTrustedWebSearchEndpoint({
|
|
82
|
+
url: PARALLEL_MCP_SEARCH_URL,
|
|
83
|
+
timeoutSeconds,
|
|
84
|
+
signal,
|
|
85
|
+
init: {
|
|
86
|
+
method: "POST",
|
|
87
|
+
headers: {
|
|
88
|
+
"Content-Type": "application/json",
|
|
89
|
+
"User-Agent": USER_AGENT,
|
|
90
|
+
Accept: "application/json, text/event-stream",
|
|
91
|
+
...params.sessionId ? { "Mcp-Session-Id": params.sessionId } : {},
|
|
92
|
+
...params.protocolVersion ? { "MCP-Protocol-Version": params.protocolVersion } : {}
|
|
93
|
+
},
|
|
94
|
+
body: JSON.stringify(params.body)
|
|
95
|
+
}
|
|
96
|
+
}, async (response) => {
|
|
97
|
+
if (!response.ok) {
|
|
98
|
+
const detail = await readResponseTextLimited(response, PARALLEL_MCP_ERROR_BODY_LIMIT_BYTES);
|
|
99
|
+
throw new ProviderHttpError(`Parallel MCP ${params.body.method} failed (${response.status}): ${detail || response.statusText}`, { status: response.status });
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
text: await readProviderTextResponse(response, "Parallel MCP"),
|
|
103
|
+
sessionIdHeader: response.headers.get("mcp-session-id")
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
const sessionId = request.sessionId?.trim() || randomUUID();
|
|
107
|
+
const searchArgs = {
|
|
108
|
+
objective: request.objective ?? request.searchQueries.join(" "),
|
|
109
|
+
search_queries: request.searchQueries,
|
|
110
|
+
session_id: sessionId
|
|
111
|
+
};
|
|
112
|
+
if (request.clientModel) searchArgs.model_name = request.clientModel;
|
|
113
|
+
const initId = randomUUID();
|
|
114
|
+
const init = await postMcp({ body: {
|
|
115
|
+
jsonrpc: "2.0",
|
|
116
|
+
id: initId,
|
|
117
|
+
method: "initialize",
|
|
118
|
+
params: {
|
|
119
|
+
protocolVersion: MCP_PROTOCOL_VERSION,
|
|
120
|
+
capabilities: {},
|
|
121
|
+
clientInfo: {
|
|
122
|
+
name: "openclaw-parallel",
|
|
123
|
+
version: PLUGIN_VERSION
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
} });
|
|
127
|
+
const mcpSessionId = init.sessionIdHeader ?? void 0;
|
|
128
|
+
const initEnvelope = selectMcpEnvelope(init.text, initId);
|
|
129
|
+
const negotiatedVersion = (isRecord(initEnvelope.result) && typeof initEnvelope.result.protocolVersion === "string" ? initEnvelope.result.protocolVersion : void 0) ?? MCP_PROTOCOL_VERSION;
|
|
130
|
+
await postMcp({
|
|
131
|
+
body: {
|
|
132
|
+
jsonrpc: "2.0",
|
|
133
|
+
method: "notifications/initialized"
|
|
134
|
+
},
|
|
135
|
+
sessionId: mcpSessionId,
|
|
136
|
+
protocolVersion: negotiatedVersion
|
|
137
|
+
});
|
|
138
|
+
const callId = randomUUID();
|
|
139
|
+
const payload = extractMcpToolPayload(selectMcpEnvelope((await postMcp({
|
|
140
|
+
body: {
|
|
141
|
+
jsonrpc: "2.0",
|
|
142
|
+
id: callId,
|
|
143
|
+
method: "tools/call",
|
|
144
|
+
params: {
|
|
145
|
+
name: "web_search",
|
|
146
|
+
arguments: searchArgs
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
sessionId: mcpSessionId,
|
|
150
|
+
protocolVersion: negotiatedVersion
|
|
151
|
+
})).text, callId));
|
|
152
|
+
const results = (Array.isArray(payload.results) ? payload.results : []).slice(0, Math.max(request.count, 1));
|
|
153
|
+
return {
|
|
154
|
+
search_id: typeof payload.search_id === "string" ? payload.search_id : void 0,
|
|
155
|
+
session_id: sessionId,
|
|
156
|
+
results,
|
|
157
|
+
warnings: payload.warnings,
|
|
158
|
+
usage: payload.usage
|
|
159
|
+
};
|
|
160
|
+
}
|
|
187
161
|
});
|
|
188
162
|
}
|
|
189
163
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import { DEFAULT_SEARCH_COUNT, buildSearchCacheKey, readCachedSearchPayload, readPositiveIntegerParam, readStringArrayParam, readStringParam, resolveSearchCacheTtlMs, resolveSearchTimeoutSeconds, resolveSiteName, wrapWebContent, writeCachedSearchPayload } from "openclaw/plugin-sdk/provider-web-search";
|
|
1
|
+
import { DEFAULT_SEARCH_COUNT, buildSearchCacheKey, externalContentStamp, readCachedSearchPayload, readPositiveIntegerParam, readStringArrayParam, readStringParam, resolveSearchCacheTtlMs, resolveSearchTimeoutSeconds, resolveSiteName, wrapWebContent, writeCachedSearchPayload } from "openclaw/plugin-sdk/provider-web-search";
|
|
3
2
|
import { asOptionalObjectRecord, filterStringEntries, isRecord, normalizeBoundedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
3
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
4
|
+
import { sha256Hex } from "openclaw/plugin-sdk/node-crypto-runtime";
|
|
5
5
|
import { resolveIntegerOption } from "openclaw/plugin-sdk/number-runtime";
|
|
6
6
|
//#region extensions/parallel/src/parallel-search-normalize.ts
|
|
7
7
|
const PARALLEL_MAX_SEARCH_COUNT = 40;
|
|
@@ -10,46 +10,67 @@ const PARALLEL_MAX_OBJECTIVE_CHARS = 5e3;
|
|
|
10
10
|
const PARALLEL_MAX_SEARCH_QUERIES = 5;
|
|
11
11
|
const PARALLEL_SESSION_ID_MAX_LENGTH = 1e3;
|
|
12
12
|
const PARALLEL_CLIENT_MODEL_MAX_LENGTH = 100;
|
|
13
|
-
function
|
|
13
|
+
async function executeParallelSearchRequest(params) {
|
|
14
|
+
const { args } = params;
|
|
15
|
+
const configuredCount = params.searchConfig?.maxResults;
|
|
14
16
|
const objective = truncateUtf16Safe(readStringParam(args, "objective") ?? "", PARALLEL_MAX_OBJECTIVE_CHARS) || void 0;
|
|
15
17
|
const cliQuery = truncateUtf16Safe(readStringParam(args, "query") ?? "", PARALLEL_MAX_OBJECTIVE_CHARS) || void 0;
|
|
16
18
|
let searchQueries = normalizeParallelSearchQueries(readStringArrayParam(args, "search_queries"));
|
|
17
19
|
if (searchQueries.length === 0 && cliQuery) searchQueries = normalizeParallelSearchQueries([cliQuery]);
|
|
18
|
-
if (searchQueries.length === 0) return {
|
|
19
|
-
|
|
20
|
+
if (searchQueries.length === 0) return {
|
|
21
|
+
error: "invalid_search_queries",
|
|
22
|
+
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.",
|
|
23
|
+
docs: "https://docs.openclaw.ai/tools/parallel-search"
|
|
24
|
+
};
|
|
25
|
+
const value = readPositiveIntegerParam(args, "count", {
|
|
26
|
+
max: PARALLEL_MAX_SEARCH_COUNT,
|
|
27
|
+
message: `count must be an integer from 1 to ${PARALLEL_MAX_SEARCH_COUNT}.`
|
|
28
|
+
}) ?? (typeof configuredCount === "number" ? configuredCount : DEFAULT_SEARCH_COUNT);
|
|
29
|
+
const request = {
|
|
20
30
|
objective,
|
|
21
31
|
searchQueries,
|
|
22
|
-
count:
|
|
23
|
-
|
|
32
|
+
count: resolveIntegerOption(value, DEFAULT_SEARCH_COUNT, {
|
|
33
|
+
min: 1,
|
|
34
|
+
max: PARALLEL_MAX_SEARCH_COUNT
|
|
35
|
+
}),
|
|
36
|
+
sessionId: normalizeBoundedOptionalString(readStringParam(args, "session_id"), params.provider === "parallel" ? PARALLEL_SESSION_ID_MAX_LENGTH : 100),
|
|
24
37
|
clientModel: truncateUtf16Safe(readStringParam(args, "client_model") ?? "", PARALLEL_CLIENT_MODEL_MAX_LENGTH) || void 0
|
|
25
38
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
const cacheKey = buildSearchCacheKey([
|
|
40
|
+
params.provider,
|
|
41
|
+
params.apiKey ? sha256Hex(params.apiKey) : void 0,
|
|
42
|
+
JSON.stringify({
|
|
43
|
+
endpoint: params.endpoint,
|
|
44
|
+
...request
|
|
45
|
+
})
|
|
46
|
+
]);
|
|
34
47
|
const cacheTtlMs = resolveSearchCacheTtlMs(params.searchConfig);
|
|
35
48
|
const cached = readCachedSearchPayload(cacheKey, cacheTtlMs);
|
|
36
49
|
if (cached) return cached;
|
|
37
50
|
const start = Date.now();
|
|
38
51
|
const response = await params.search(request, resolveSearchTimeoutSeconds(params.searchConfig));
|
|
39
|
-
|
|
40
|
-
const
|
|
52
|
+
const count = request.count;
|
|
53
|
+
const rawResults = asOptionalObjectRecord(response)?.results;
|
|
54
|
+
const results = (Array.isArray(rawResults) ? rawResults.filter(isRecord) : []).slice(0, count).map((entry) => {
|
|
55
|
+
const title = typeof entry.title === "string" ? entry.title : "";
|
|
56
|
+
const url = typeof entry.url === "string" ? entry.url : "";
|
|
57
|
+
const published = typeof entry.publish_date === "string" && entry.publish_date ? entry.publish_date : void 0;
|
|
58
|
+
const excerpts = filterStringEntries(entry.excerpts).map((e) => wrapWebContent(e, "web_search"));
|
|
59
|
+
const description = excerpts.join("\n\n");
|
|
60
|
+
return Object.assign({
|
|
61
|
+
title: title ? wrapWebContent(title, "web_search") : "",
|
|
62
|
+
url,
|
|
63
|
+
description,
|
|
64
|
+
siteName: resolveSiteName(url) || void 0
|
|
65
|
+
}, published ? { published } : {}, excerpts.length > 0 ? { excerpts } : {});
|
|
66
|
+
});
|
|
41
67
|
const payload = {
|
|
42
68
|
...request.objective ? { objective: request.objective } : {},
|
|
43
69
|
searchQueries: request.searchQueries,
|
|
44
70
|
provider: params.provider,
|
|
45
71
|
count: results.length,
|
|
46
72
|
tookMs: Date.now() - start,
|
|
47
|
-
externalContent:
|
|
48
|
-
untrusted: true,
|
|
49
|
-
source: "web_search",
|
|
50
|
-
provider: params.provider,
|
|
51
|
-
wrapped: true
|
|
52
|
-
},
|
|
73
|
+
externalContent: externalContentStamp(params.provider),
|
|
53
74
|
results
|
|
54
75
|
};
|
|
55
76
|
if (typeof response.search_id === "string") payload.searchId = response.search_id;
|
|
@@ -61,16 +82,6 @@ async function executeParallelSearchRequest(params) {
|
|
|
61
82
|
writeCachedSearchPayload(cacheKey, cachePayload, cacheTtlMs);
|
|
62
83
|
return payload;
|
|
63
84
|
}
|
|
64
|
-
function resolveParallelSearchCount(args, configuredCount) {
|
|
65
|
-
const value = readPositiveIntegerParam(args, "count", {
|
|
66
|
-
max: PARALLEL_MAX_SEARCH_COUNT,
|
|
67
|
-
message: `count must be an integer from 1 to ${PARALLEL_MAX_SEARCH_COUNT}.`
|
|
68
|
-
}) ?? (typeof configuredCount === "number" ? configuredCount : DEFAULT_SEARCH_COUNT);
|
|
69
|
-
return resolveIntegerOption(value, DEFAULT_SEARCH_COUNT, {
|
|
70
|
-
min: 1,
|
|
71
|
-
max: PARALLEL_MAX_SEARCH_COUNT
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
85
|
function normalizeParallelSearchQueries(candidates = []) {
|
|
75
86
|
const seen = /* @__PURE__ */ new Set();
|
|
76
87
|
const out = [];
|
|
@@ -85,28 +96,5 @@ function normalizeParallelSearchQueries(candidates = []) {
|
|
|
85
96
|
}
|
|
86
97
|
return out;
|
|
87
98
|
}
|
|
88
|
-
function invalidSearchQueriesPayload() {
|
|
89
|
-
return {
|
|
90
|
-
error: "invalid_search_queries",
|
|
91
|
-
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.",
|
|
92
|
-
docs: "https://docs.openclaw.ai/tools/parallel-search"
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function mapParallelResults(response, count) {
|
|
96
|
-
const rawResults = asOptionalObjectRecord(response)?.results;
|
|
97
|
-
return (Array.isArray(rawResults) ? rawResults.filter(isRecord) : []).slice(0, count).map((entry) => {
|
|
98
|
-
const title = typeof entry.title === "string" ? entry.title : "";
|
|
99
|
-
const url = typeof entry.url === "string" ? entry.url : "";
|
|
100
|
-
const published = typeof entry.publish_date === "string" && entry.publish_date ? entry.publish_date : void 0;
|
|
101
|
-
const excerpts = filterStringEntries(entry.excerpts).map((e) => wrapWebContent(e, "web_search"));
|
|
102
|
-
const description = excerpts.join("\n\n");
|
|
103
|
-
return Object.assign({
|
|
104
|
-
title: title ? wrapWebContent(title, "web_search") : "",
|
|
105
|
-
url,
|
|
106
|
-
description,
|
|
107
|
-
siteName: resolveSiteName(url) || void 0
|
|
108
|
-
}, published ? { published } : {}, excerpts.length > 0 ? { excerpts } : {});
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
99
|
//#endregion
|
|
112
100
|
export { executeParallelSearchRequest as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as executeParallelSearchRequest } from "./parallel-search-normalize-
|
|
1
|
+
import { t as executeParallelSearchRequest } from "./parallel-search-normalize-DLUK82z5.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { mergeScopedSearchConfig, readConfiguredSecretString, readProviderEnvValue, resolveProviderWebSearchPluginConfig, withTrustedWebSearchEndpoint } from "openclaw/plugin-sdk/provider-web-search";
|
|
4
3
|
import { readPluginPackageVersion } from "openclaw/plugin-sdk/extension-shared";
|
|
5
4
|
import { ProviderHttpError, readProviderJsonResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
|
|
5
|
+
import { mergeScopedSearchConfig, readWebSearchApiKey, resolveProviderWebSearchPluginConfig, withTrustedWebSearchEndpoint } from "openclaw/plugin-sdk/provider-web-search";
|
|
6
6
|
import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
7
|
import { redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
8
8
|
import { redactSensitiveText } from "openclaw/plugin-sdk/security-runtime";
|
|
@@ -13,9 +13,6 @@ const PARALLEL_ERROR_BODY_LIMIT_BYTES = 8192;
|
|
|
13
13
|
const PARALLEL_SEARCH_RESPONSE_LIMIT_BYTES = 16777216;
|
|
14
14
|
const require = createRequire(import.meta.url);
|
|
15
15
|
const USER_AGENT = `openclaw-parallel/${readPluginPackageVersion({ require })} (${process.platform})`;
|
|
16
|
-
function resolveParallelApiKey(parallel) {
|
|
17
|
-
return readConfiguredSecretString(parallel?.apiKey, "plugins.entries.parallel.config.webSearch.apiKey") ?? readProviderEnvValue(["PARALLEL_API_KEY"]);
|
|
18
|
-
}
|
|
19
16
|
function invalidBaseUrlPayload() {
|
|
20
17
|
return {
|
|
21
18
|
error: "invalid_base_url",
|
|
@@ -23,44 +20,41 @@ function invalidBaseUrlPayload() {
|
|
|
23
20
|
docs: "https://docs.openclaw.ai/tools/parallel-search"
|
|
24
21
|
};
|
|
25
22
|
}
|
|
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();
|
|
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();
|
|
36
|
-
}
|
|
37
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return invalidBaseUrlPayload();
|
|
38
|
-
const pathname = parsed.pathname.replace(/\/+$/, "");
|
|
39
|
-
parsed.pathname = pathname.endsWith(PARALLEL_SEARCH_PATHNAME) ? pathname : `${pathname}${PARALLEL_SEARCH_PATHNAME}`;
|
|
40
|
-
parsed.hash = "";
|
|
41
|
-
return { endpoint: parsed.toString() };
|
|
42
|
-
}
|
|
43
23
|
async function executeParallelWebSearchProviderTool(ctx, args, signal) {
|
|
44
24
|
const searchConfig = mergeScopedSearchConfig(ctx.searchConfig, "parallel", resolveProviderWebSearchPluginConfig(ctx.config, "parallel"));
|
|
45
25
|
const parallelConfig = asOptionalRecord(searchConfig?.parallel);
|
|
46
|
-
const apiKey =
|
|
26
|
+
const apiKey = readWebSearchApiKey(parallelConfig?.apiKey, "plugins.entries.parallel.config.webSearch.apiKey", ["PARALLEL_API_KEY"]);
|
|
47
27
|
if (!apiKey) return {
|
|
48
28
|
error: "missing_parallel_api_key",
|
|
49
29
|
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.",
|
|
50
30
|
docs: "https://docs.openclaw.ai/tools/parallel-search"
|
|
51
31
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
32
|
+
let endpoint = `${PARALLEL_BASE_URL}${PARALLEL_SEARCH_PATHNAME}`;
|
|
33
|
+
const configured = normalizeOptionalString(parallelConfig?.baseUrl);
|
|
34
|
+
if (configured) {
|
|
35
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(configured) && !/^https?:\/\//i.test(configured)) return invalidBaseUrlPayload();
|
|
36
|
+
const candidate = /^https?:\/\//i.test(configured) ? configured : `https://${configured}`;
|
|
37
|
+
let parsed;
|
|
38
|
+
try {
|
|
39
|
+
parsed = new URL(candidate);
|
|
40
|
+
} catch {
|
|
41
|
+
return invalidBaseUrlPayload();
|
|
42
|
+
}
|
|
43
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return invalidBaseUrlPayload();
|
|
44
|
+
const pathname = parsed.pathname.replace(/\/+$/, "");
|
|
45
|
+
parsed.pathname = pathname.endsWith(PARALLEL_SEARCH_PATHNAME) ? pathname : `${pathname}${PARALLEL_SEARCH_PATHNAME}`;
|
|
46
|
+
parsed.hash = "";
|
|
47
|
+
endpoint = parsed.toString();
|
|
48
|
+
}
|
|
55
49
|
return executeParallelSearchRequest({
|
|
56
50
|
provider: "parallel",
|
|
57
51
|
endpoint,
|
|
52
|
+
apiKey,
|
|
58
53
|
args,
|
|
59
54
|
searchConfig,
|
|
60
|
-
signal,
|
|
61
55
|
search: async (request, timeoutSeconds) => {
|
|
62
56
|
const body = {
|
|
63
|
-
search_queries:
|
|
57
|
+
search_queries: request.searchQueries,
|
|
64
58
|
advanced_settings: { max_results: request.count }
|
|
65
59
|
};
|
|
66
60
|
if (request.objective) body.objective = request.objective;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"entries":[{"output":"index.js","source":"extensions/parallel/index.ts"},{"output":"web-search-contract-api.js","source":"extensions/parallel/web-search-contract-api.ts"},{"output":"web-search-provider.js","source":"extensions/parallel/web-search-provider.ts"}],"chunks":[{"output":".setup/parallel-free-web-search-provider-Bc9ZvxIO.mjs","sha256":"96ef5018be9e8d131ecad12b2bb2d4bb714ff4d4431a465d27237cebbc3e58b7","facadeSource":null,"sources":["extensions/parallel/src/parallel-free-web-search-provider.ts","extensions/parallel/src/parallel-web-search-provider.ts"]},{"output":".setup/parallel-free-web-search-provider.runtime-yJVscbpB.mjs","sha256":"980382241147b1b8db459c987415cf3c9123a25b67a9ef5dd85c398fec4ff7ec","facadeSource":"extensions/parallel/src/parallel-free-web-search-provider.runtime.ts","sources":["extensions/parallel/src/parallel-free-web-search-provider.runtime.ts"]},{"output":".setup/parallel-search-normalize-DLUK82z5.mjs","sha256":"c4a6684366db7d257b624e300b090535468658b516adad328513b05af1ddd948","facadeSource":null,"sources":["extensions/parallel/src/parallel-search-normalize.ts"]},{"output":".setup/parallel-web-search-provider.runtime-Da3yvfmk.mjs","sha256":"ec9d0598f57392afe235a2e46cf56736bab5c8686d9569fc4ba36e39e1afa726","facadeSource":"extensions/parallel/src/parallel-web-search-provider.runtime.ts","sources":["extensions/parallel/src/parallel-web-search-provider.runtime.ts"]},{"output":"index.js","sha256":"cde043dfd1a5c66cc4665d201bb0b15c3387161b0f95cfe6b82fec0610eddf07","facadeSource":"extensions/parallel/index.ts","sources":["extensions/parallel/index.ts"]},{"output":"web-search-contract-api.js","sha256":"7116933f3c6c4b0b33824ab88e581c92e6e3543a3d661fb4a4c4b0e9d530082c","facadeSource":"extensions/parallel/web-search-contract-api.ts","sources":[]},{"output":"web-search-provider.js","sha256":"c8a9fb84c1e6aa4962faa2a71420ff0e0dd120739975f585304da9e5512a5f96","facadeSource":"extensions/parallel/web-search-provider.ts","sources":[]}],"unrenderedSources":["extensions/parallel/src/parallel-free-web-search-provider.shared.ts","extensions/parallel/web-search-contract-api.ts","extensions/parallel/web-search-provider.ts"]}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createParallelWebSearchProvider, t as createParallelFreeWebSearchProvider } from "./.setup/parallel-free-web-search-provider-
|
|
1
|
+
import { n as createParallelWebSearchProvider, t as createParallelFreeWebSearchProvider } from "./.setup/parallel-free-web-search-provider-Bc9ZvxIO.mjs";
|
|
2
2
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
3
3
|
//#region extensions/parallel/index.ts
|
|
4
4
|
var parallel_default = definePluginEntry({
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { t as createParallelFreeWebSearchProvider, n as createParallelWebSearchProvider } from "./.setup/parallel-free-web-search-provider-Bc9ZvxIO.mjs";
|
|
2
2
|
import "./web-search-provider.js";
|
|
3
|
-
export { createParallelFreeWebSearchProvider, createParallelWebSearchProvider };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { createParallelFreeWebSearchProvider, createParallelWebSearchProvider };
|
|
1
|
+
export { t as createParallelFreeWebSearchProvider, n as createParallelWebSearchProvider } from "./.setup/parallel-free-web-search-provider-Bc9ZvxIO.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/parallel-plugin",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.5-beta.2",
|
|
4
4
|
"description": "OpenClaw Parallel web search plugin.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"minHostVersion": ">=2026.6.8"
|
|
19
19
|
},
|
|
20
20
|
"compat": {
|
|
21
|
-
"pluginApi": ">=2026.11.
|
|
21
|
+
"pluginApi": ">=2026.11.5-beta.2"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.11.
|
|
24
|
+
"openclawVersion": "2026.11.5-beta.2",
|
|
25
25
|
"bundledDist": false
|
|
26
26
|
},
|
|
27
27
|
"release": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"assets/activity.svg"
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"openclaw": ">=2026.11.
|
|
43
|
+
"openclaw": ">=2026.11.5-beta.2"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"openclaw": {
|