@openclaw/parallel-plugin 0.0.0 → 2026.6.9-beta.1

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 CHANGED
@@ -1,3 +1,12 @@
1
- # @openclaw/parallel-plugin
1
+ # OpenClaw Parallel Plugin
2
2
 
3
- Reserved placeholder for the official OpenClaw plugin package. Use a published release version instead.
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-bR8lt5fb.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-Hkr5nWrH.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-IGwansnj.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,261 @@
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-bR8lt5fb.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
+ //#region extensions/parallel/src/parallel-mcp-search.runtime.ts
7
+ const PARALLEL_MCP_SEARCH_URL = "https://search.parallel.ai/mcp";
8
+ const MCP_PROTOCOL_VERSION = "2025-06-18";
9
+ const MCP_TIMEOUT_SECONDS = 30;
10
+ const PLUGIN_VERSION = readPluginPackageVersion({ require: createRequire(import.meta.url) });
11
+ const USER_AGENT = `openclaw-parallel/${PLUGIN_VERSION} (${process.platform})`;
12
+ function isRecord(value) {
13
+ return typeof value === "object" && value !== null && !Array.isArray(value);
14
+ }
15
+ function mcpHeaders(params) {
16
+ const headers = {
17
+ "Content-Type": "application/json",
18
+ "User-Agent": USER_AGENT,
19
+ Accept: "application/json, text/event-stream"
20
+ };
21
+ if (params.sessionId) headers["Mcp-Session-Id"] = params.sessionId;
22
+ if (params.protocolVersion) headers["MCP-Protocol-Version"] = params.protocolVersion;
23
+ return headers;
24
+ }
25
+ /**
26
+ * Yield JSON-RPC message objects from a plain-JSON or SSE response body.
27
+ *
28
+ * Handles `application/json` (a single object) and `text/event-stream` (SSE:
29
+ * events separated by blank lines; an event's one-or-more `data:` lines
30
+ * concatenate into a single JSON payload). Streamable HTTP also allows batching
31
+ * responses into a JSON array, so arrays are flattened. Unparseable chunks and
32
+ * non-`data` SSE fields (`event:`/`id:`/comments) are skipped.
33
+ */
34
+ function iterMcpMessages(text) {
35
+ const out = [];
36
+ const emit = (payload) => {
37
+ if (Array.isArray(payload)) {
38
+ for (const entry of payload) if (isRecord(entry)) out.push(entry);
39
+ } else if (isRecord(payload)) out.push(payload);
40
+ };
41
+ const body = (text ?? "").trim();
42
+ if (!body) return out;
43
+ if (body.startsWith("{") || body.startsWith("[")) {
44
+ try {
45
+ emit(JSON.parse(body));
46
+ } catch {}
47
+ return out;
48
+ }
49
+ let dataLines = [];
50
+ const flush = () => {
51
+ if (dataLines.length === 0) return;
52
+ try {
53
+ emit(JSON.parse(dataLines.join("\n")));
54
+ } catch {}
55
+ dataLines = [];
56
+ };
57
+ for (const raw of body.split("\n")) {
58
+ const line = raw.replace(/\r$/, "");
59
+ if (line.startsWith("data:")) dataLines.push(line.slice(5).replace(/^ /, ""));
60
+ else if (line.trim() === "") flush();
61
+ }
62
+ flush();
63
+ return out;
64
+ }
65
+ /**
66
+ * Select the JSON-RPC response for `requestId` from an MCP response body.
67
+ *
68
+ * Streamable-HTTP servers may emit progress/log notifications before the final
69
+ * result, so scan the whole stream and return the result/error message whose
70
+ * `id` matches. Falls back to the last result/error-bearing message if no id
71
+ * matches; `{}` if none is present.
72
+ */
73
+ function selectMcpEnvelope(text, requestId) {
74
+ let fallback = {};
75
+ for (const msg of iterMcpMessages(text)) {
76
+ if (!("result" in msg || "error" in msg)) continue;
77
+ if (msg.id === requestId) return msg;
78
+ fallback = msg;
79
+ }
80
+ return fallback;
81
+ }
82
+ /**
83
+ * Extract the tool result payload from a `tools/call` envelope.
84
+ *
85
+ * Prefers `structuredContent` (authoritative machine-readable form); otherwise
86
+ * scans text blocks for the first JSON-parseable one. Throws on a JSON-RPC
87
+ * error or a tool-level `isError`.
88
+ */
89
+ function extractMcpToolPayload(envelope) {
90
+ if ("error" in envelope) throw new Error(`Parallel MCP error: ${JSON.stringify(envelope.error).slice(0, 500)}`);
91
+ const result = isRecord(envelope.result) ? envelope.result : {};
92
+ if (result.isError) throw new Error(`Parallel MCP tool error: ${JSON.stringify(result).slice(0, 500)}`);
93
+ if (isRecord(result.structuredContent)) return result.structuredContent;
94
+ const content = Array.isArray(result.content) ? result.content : [];
95
+ for (const block of content) if (isRecord(block) && block.type === "text" && typeof block.text === "string" && block.text) try {
96
+ const parsed = JSON.parse(block.text);
97
+ if (isRecord(parsed)) return parsed;
98
+ } catch {}
99
+ throw new Error(`Parallel MCP returned no parseable content: ${JSON.stringify(result).slice(0, 500)}`);
100
+ }
101
+ async function postMcp(params) {
102
+ return withTrustedWebSearchEndpoint({
103
+ url: PARALLEL_MCP_SEARCH_URL,
104
+ timeoutSeconds: params.timeoutSeconds,
105
+ signal: params.signal,
106
+ init: {
107
+ method: "POST",
108
+ headers: mcpHeaders({
109
+ sessionId: params.sessionId,
110
+ protocolVersion: params.protocolVersion
111
+ }),
112
+ body: JSON.stringify(params.body)
113
+ }
114
+ }, async (response) => ({
115
+ ok: response.ok,
116
+ status: response.status,
117
+ statusText: response.statusText,
118
+ text: await response.text(),
119
+ sessionIdHeader: response.headers.get("mcp-session-id")
120
+ }));
121
+ }
122
+ /**
123
+ * Run the MCP handshake then a single `tools/call`, returning the tool payload.
124
+ *
125
+ * initialize -> (capture `Mcp-Session-Id` header + negotiated protocolVersion)
126
+ * -> notifications/initialized -> tools/call. Anonymous (no bearer token).
127
+ */
128
+ async function mcpCall(toolName, args, timeoutSeconds, signal) {
129
+ const initId = randomUUID();
130
+ const init = await postMcp({
131
+ timeoutSeconds,
132
+ signal,
133
+ body: {
134
+ jsonrpc: "2.0",
135
+ id: initId,
136
+ method: "initialize",
137
+ params: {
138
+ protocolVersion: MCP_PROTOCOL_VERSION,
139
+ capabilities: {},
140
+ clientInfo: {
141
+ name: "openclaw-parallel",
142
+ version: PLUGIN_VERSION
143
+ }
144
+ }
145
+ }
146
+ });
147
+ if (!init.ok) throw new Error(`Parallel MCP initialize failed (${init.status}): ${init.text || init.statusText}`);
148
+ const sessionId = init.sessionIdHeader ?? void 0;
149
+ const initEnvelope = selectMcpEnvelope(init.text, initId);
150
+ const negotiatedVersion = (isRecord(initEnvelope.result) && typeof initEnvelope.result.protocolVersion === "string" ? initEnvelope.result.protocolVersion : void 0) ?? MCP_PROTOCOL_VERSION;
151
+ await postMcp({
152
+ body: {
153
+ jsonrpc: "2.0",
154
+ method: "notifications/initialized"
155
+ },
156
+ sessionId,
157
+ protocolVersion: negotiatedVersion,
158
+ timeoutSeconds,
159
+ signal
160
+ });
161
+ const callId = randomUUID();
162
+ const call = await postMcp({
163
+ body: {
164
+ jsonrpc: "2.0",
165
+ id: callId,
166
+ method: "tools/call",
167
+ params: {
168
+ name: toolName,
169
+ arguments: args
170
+ }
171
+ },
172
+ sessionId,
173
+ protocolVersion: negotiatedVersion,
174
+ timeoutSeconds,
175
+ signal
176
+ });
177
+ if (!call.ok) throw new Error(`Parallel MCP tools/call failed (${call.status}): ${call.text || call.statusText}`);
178
+ return extractMcpToolPayload(selectMcpEnvelope(call.text, callId));
179
+ }
180
+ function normalizeMcpSessionId(value) {
181
+ return value?.trim() || randomUUID();
182
+ }
183
+ /**
184
+ * Run a `web_search` tool call against the free hosted Search MCP and return a
185
+ * `ParallelSearchResponse`-compatible object so the runtime's existing result
186
+ * normalization (`normalizeParallelResults`) is reused verbatim.
187
+ */
188
+ async function runParallelMcpSearch(params) {
189
+ const sessionId = normalizeMcpSessionId(params.sessionId);
190
+ const args = {
191
+ objective: params.objective ?? params.searchQueries.join(" "),
192
+ search_queries: [...params.searchQueries],
193
+ session_id: sessionId
194
+ };
195
+ if (params.modelName) args.model_name = params.modelName;
196
+ const payload = await mcpCall("web_search", args, params.timeoutSeconds ?? MCP_TIMEOUT_SECONDS, params.signal);
197
+ const results = (Array.isArray(payload.results) ? payload.results : []).slice(0, Math.max(params.maxResults, 1));
198
+ return {
199
+ search_id: typeof payload.search_id === "string" ? payload.search_id : void 0,
200
+ session_id: sessionId,
201
+ results,
202
+ warnings: payload.warnings,
203
+ usage: payload.usage
204
+ };
205
+ }
206
+ //#endregion
207
+ //#region extensions/parallel/src/parallel-free-web-search-provider.runtime.ts
208
+ async function executeParallelFreeWebSearchProviderTool(ctx, args, signal) {
209
+ const searchConfig = mergeScopedSearchConfig(ctx.searchConfig, "parallel-free", resolveProviderWebSearchPluginConfig(ctx.config, "parallel-free"));
210
+ const objective = normalizeParallelObjective(readStringParam(args, "objective"));
211
+ const cliQuery = normalizeParallelObjective(readStringParam(args, "query"));
212
+ let searchQueries = normalizeParallelSearchQueries(readStringArrayParam(args, "search_queries"));
213
+ if (searchQueries.length === 0 && cliQuery) searchQueries = normalizeParallelSearchQueries([cliQuery]);
214
+ if (searchQueries.length === 0) return invalidSearchQueriesPayload();
215
+ const count = resolveParallelSearchCount(readNumberParam(args, "count", { integer: true }) ?? (typeof searchConfig?.maxResults === "number" ? searchConfig.maxResults : void 0) ?? DEFAULT_SEARCH_COUNT);
216
+ const sessionId = normalizeParallelSessionId(readStringParam(args, "session_id"), 100);
217
+ const clientModel = normalizeParallelClientModel(readStringParam(args, "client_model"));
218
+ const cacheKey = buildParallelCacheKey({
219
+ endpoint: PARALLEL_MCP_SEARCH_URL,
220
+ objective,
221
+ searchQueries,
222
+ count,
223
+ sessionId,
224
+ clientModel
225
+ });
226
+ const cached = readCachedSearchPayload(cacheKey);
227
+ if (cached) return cached;
228
+ const start = Date.now();
229
+ const response = await runParallelMcpSearch({
230
+ objective,
231
+ searchQueries,
232
+ maxResults: count,
233
+ sessionId,
234
+ modelName: clientModel,
235
+ timeoutSeconds: resolveSearchTimeoutSeconds(searchConfig),
236
+ signal
237
+ });
238
+ const results = mapParallelResults(response);
239
+ const payload = {
240
+ ...objective ? { objective } : {},
241
+ searchQueries,
242
+ provider: "parallel-free",
243
+ count: results.length,
244
+ tookMs: Date.now() - start,
245
+ externalContent: {
246
+ untrusted: true,
247
+ source: "web_search",
248
+ provider: "parallel-free",
249
+ wrapped: true
250
+ },
251
+ results
252
+ };
253
+ if (typeof response.search_id === "string") payload.searchId = response.search_id;
254
+ if (typeof response.session_id === "string") payload.sessionId = response.session_id;
255
+ if (Array.isArray(response.warnings) && response.warnings.length > 0) payload.warnings = response.warnings;
256
+ if (Array.isArray(response.usage) && response.usage.length > 0) payload.usage = response.usage;
257
+ writeCachedSearchPayload(cacheKey, sessionId ? payload : stripParallelGeneratedSessionId(payload), resolveSearchCacheTtlMs(searchConfig));
258
+ return payload;
259
+ }
260
+ //#endregion
261
+ export { executeParallelFreeWebSearchProviderTool };
@@ -0,0 +1,156 @@
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-bR8lt5fb.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
+ //#region extensions/parallel/src/parallel-web-search-provider.runtime.ts
7
+ const PARALLEL_BASE_URL = "https://api.parallel.ai";
8
+ const PARALLEL_SEARCH_PATHNAME = "/v1/search";
9
+ const USER_AGENT = `openclaw-parallel/${readPluginPackageVersion({ require: createRequire(import.meta.url) })} (${process.platform})`;
10
+ function resolveParallelConfig(searchConfig) {
11
+ const parallel = searchConfig?.parallel;
12
+ return parallel && typeof parallel === "object" && !Array.isArray(parallel) ? parallel : {};
13
+ }
14
+ function resolveParallelApiKey(parallel) {
15
+ return readConfiguredSecretString(parallel?.apiKey, "tools.web.search.parallel.apiKey") ?? readProviderEnvValue(["PARALLEL_API_KEY"]);
16
+ }
17
+ function invalidBaseUrlPayload(value) {
18
+ return {
19
+ error: "invalid_base_url",
20
+ message: `plugins.entries.parallel.config.webSearch.baseUrl must be a valid http(s) URL. Got: ${value}`,
21
+ docs: "https://docs.openclaw.ai/tools/parallel-search"
22
+ };
23
+ }
24
+ function resolveParallelSearchEndpoint(parallel) {
25
+ const configured = normalizeOptionalString(parallel?.baseUrl);
26
+ if (!configured) return { endpoint: `${PARALLEL_BASE_URL}${PARALLEL_SEARCH_PATHNAME}` };
27
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(configured) && !/^https?:\/\//i.test(configured)) return invalidBaseUrlPayload(configured);
28
+ const candidate = /^https?:\/\//i.test(configured) ? configured : `https://${configured}`;
29
+ let parsed;
30
+ try {
31
+ parsed = new URL(candidate);
32
+ } catch {
33
+ return invalidBaseUrlPayload(configured);
34
+ }
35
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return invalidBaseUrlPayload(configured);
36
+ const pathname = parsed.pathname.replace(/\/+$/, "");
37
+ parsed.pathname = pathname.endsWith(PARALLEL_SEARCH_PATHNAME) ? pathname : `${pathname === "" ? "" : pathname}${PARALLEL_SEARCH_PATHNAME}`;
38
+ parsed.hash = "";
39
+ return { endpoint: parsed.toString() };
40
+ }
41
+ function missingParallelKeyPayload() {
42
+ return {
43
+ error: "missing_parallel_api_key",
44
+ 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.",
45
+ docs: "https://docs.openclaw.ai/tools/parallel-search"
46
+ };
47
+ }
48
+ async function runParallelSearch(params) {
49
+ const body = {
50
+ search_queries: [...params.searchQueries],
51
+ advanced_settings: { max_results: params.maxResults }
52
+ };
53
+ if (params.objective) body.objective = params.objective;
54
+ if (params.sessionId) body.session_id = params.sessionId;
55
+ if (params.clientModel) body.client_model = params.clientModel;
56
+ return withTrustedWebSearchEndpoint({
57
+ url: params.endpoint,
58
+ timeoutSeconds: params.timeoutSeconds,
59
+ init: {
60
+ method: "POST",
61
+ headers: {
62
+ Accept: "application/json",
63
+ "Content-Type": "application/json",
64
+ "x-api-key": params.apiKey,
65
+ "User-Agent": USER_AGENT
66
+ },
67
+ body: JSON.stringify(body)
68
+ }
69
+ }, async (res) => {
70
+ if (!res.ok) {
71
+ const detail = await res.text().catch(() => "");
72
+ throw new Error(`Parallel API error (${res.status}): ${detail || res.statusText}`);
73
+ }
74
+ try {
75
+ return await res.json();
76
+ } catch (cause) {
77
+ throw new Error("Parallel API returned malformed JSON", { cause });
78
+ }
79
+ });
80
+ }
81
+ async function executeParallelWebSearchProviderTool(ctx, args) {
82
+ const searchConfig = mergeScopedSearchConfig(ctx.searchConfig, "parallel", resolveProviderWebSearchPluginConfig(ctx.config, "parallel"));
83
+ const parallelConfig = resolveParallelConfig(searchConfig);
84
+ const apiKey = resolveParallelApiKey(parallelConfig);
85
+ if (!apiKey) return missingParallelKeyPayload();
86
+ const endpointResult = resolveParallelSearchEndpoint(parallelConfig);
87
+ if ("error" in endpointResult) return endpointResult;
88
+ const endpoint = endpointResult.endpoint;
89
+ const objective = normalizeParallelObjective(readStringParam(args, "objective"));
90
+ const cliQuery = normalizeParallelObjective(readStringParam(args, "query"));
91
+ let searchQueries = normalizeParallelSearchQueries(readStringArrayParam(args, "search_queries"));
92
+ if (searchQueries.length === 0 && cliQuery) searchQueries = normalizeParallelSearchQueries([cliQuery]);
93
+ if (searchQueries.length === 0) return invalidSearchQueriesPayload();
94
+ const count = resolveParallelSearchCount(readNumberParam(args, "count", { integer: true }) ?? (typeof searchConfig?.maxResults === "number" ? searchConfig.maxResults : void 0) ?? DEFAULT_SEARCH_COUNT);
95
+ const sessionId = normalizeParallelSessionId(readStringParam(args, "session_id"), PARALLEL_SESSION_ID_MAX_LENGTH);
96
+ const clientModel = normalizeParallelClientModel(readStringParam(args, "client_model"));
97
+ const cacheKey = buildParallelCacheKey({
98
+ endpoint,
99
+ objective,
100
+ searchQueries,
101
+ count,
102
+ sessionId,
103
+ clientModel
104
+ });
105
+ const cached = readCachedSearchPayload(cacheKey);
106
+ if (cached) return cached;
107
+ const start = Date.now();
108
+ const response = await runParallelSearch({
109
+ apiKey,
110
+ endpoint,
111
+ objective,
112
+ searchQueries,
113
+ maxResults: count,
114
+ sessionId,
115
+ clientModel,
116
+ timeoutSeconds: resolveSearchTimeoutSeconds(searchConfig)
117
+ });
118
+ const results = mapParallelResults(response);
119
+ const payload = {
120
+ ...objective ? { objective } : {},
121
+ searchQueries,
122
+ provider: "parallel",
123
+ count: results.length,
124
+ tookMs: Date.now() - start,
125
+ externalContent: {
126
+ untrusted: true,
127
+ source: "web_search",
128
+ provider: "parallel",
129
+ wrapped: true
130
+ },
131
+ results
132
+ };
133
+ if (typeof response.search_id === "string") payload.searchId = response.search_id;
134
+ if (typeof response.session_id === "string") payload.sessionId = response.session_id;
135
+ if (Array.isArray(response.warnings) && response.warnings.length > 0) payload.warnings = response.warnings;
136
+ if (Array.isArray(response.usage) && response.usage.length > 0) payload.usage = response.usage;
137
+ writeCachedSearchPayload(cacheKey, sessionId ? payload : stripParallelGeneratedSessionId(payload), resolveSearchCacheTtlMs(searchConfig));
138
+ return payload;
139
+ }
140
+ const testing = {
141
+ buildParallelCacheKey,
142
+ invalidSearchQueriesPayload,
143
+ missingParallelKeyPayload,
144
+ normalizeParallelClientModel,
145
+ normalizeParallelObjective,
146
+ normalizeParallelResults,
147
+ normalizeParallelSearchQueries,
148
+ normalizeParallelSessionId,
149
+ resolveParallelApiKey,
150
+ resolveParallelConfig,
151
+ resolveParallelSearchCount,
152
+ resolveParallelSearchEndpoint,
153
+ USER_AGENT
154
+ };
155
+ //#endregion
156
+ 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,2 @@
1
+ import { n as createParallelWebSearchProvider, t as createParallelFreeWebSearchProvider } from "./parallel-free-web-search-provider-bR8lt5fb.js";
2
+ export { createParallelFreeWebSearchProvider, createParallelWebSearchProvider };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@openclaw/parallel-plugin",
3
+ "version": "2026.6.9-beta.1",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "@openclaw/parallel-plugin",
9
+ "version": "2026.6.9-beta.1"
10
+ }
11
+ }
12
+ }
@@ -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": "0.0.0",
4
- "description": "Reserved package name for an official OpenClaw plugin.",
5
- "license": "MIT",
3
+ "version": "2026.6.9-beta.1",
4
+ "description": "OpenClaw Parallel web search plugin.",
6
5
  "repository": {
7
6
  "type": "git",
8
- "url": "git+https://github.com/openclaw/openclaw.git"
7
+ "url": "https://github.com/openclaw/openclaw"
9
8
  },
10
- "publishConfig": {
11
- "access": "public",
12
- "tag": "placeholder"
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-beta.1"
22
+ },
23
+ "build": {
24
+ "openclawVersion": "2026.6.9-beta.1",
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-beta.1"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "openclaw": {
46
+ "optional": true
47
+ }
48
+ },
49
+ "bundledDependencies": []
14
50
  }