@openclaw/parallel-plugin 2026.9.5 → 2026.9.7

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/assets/icon.png CHANGED
Binary file
@@ -7,6 +7,7 @@ function createParallelFreeWebSearchProviderBase() {
7
7
  id: "parallel-free",
8
8
  label: "Parallel Search (Free)",
9
9
  hint: "Free web search via Parallel's hosted Search MCP — no API key required",
10
+ configPath: null,
10
11
  onboardingScopes: [...PARALLEL_FREE_ONBOARDING_SCOPES],
11
12
  requiresCredential: false,
12
13
  envVars: [],
@@ -60,7 +61,7 @@ const PARALLEL_MAX_SEARCH_QUERY_CHARS = 200;
60
61
  const PARALLEL_MAX_OBJECTIVE_CHARS = 5e3;
61
62
  const PARALLEL_MAX_SESSION_ID_CHARS = 1e3;
62
63
  const PARALLEL_MAX_CLIENT_MODEL_CHARS = 100;
63
- const loadParallelWebSearchRuntime = createLazyRuntimeModule(() => import("./parallel-web-search-provider.runtime-YULWvnO9.mjs"));
64
+ const loadParallelWebSearchRuntime = createLazyRuntimeModule(() => import("./parallel-web-search-provider.runtime-BO11rmJ6.mjs"));
64
65
  const ParallelSearchSchema = {
65
66
  type: "object",
66
67
  properties: {
@@ -125,7 +126,7 @@ const ParallelFreeSearchSchema = {
125
126
  }
126
127
  }
127
128
  };
128
- const loadParallelFreeWebSearchRuntime = createLazyRuntimeModule(() => import("./parallel-free-web-search-provider.runtime-CoicsZIw.mjs"));
129
+ const loadParallelFreeWebSearchRuntime = createLazyRuntimeModule(() => import("./parallel-free-web-search-provider.runtime-C2wHlx8V.mjs"));
129
130
  function createParallelFreeWebSearchProvider() {
130
131
  return {
131
132
  ...createParallelFreeWebSearchProviderBase(),
@@ -1,9 +1,9 @@
1
- import { t as executeParallelSearchRequest } from "./parallel-search-normalize-BTXsGUqi.mjs";
1
+ import { t as executeParallelSearchRequest } from "./parallel-search-normalize-CP1w5YdR.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { mergeScopedSearchConfig, resolveProviderWebSearchPluginConfig, withTrustedWebSearchEndpoint } from "openclaw/plugin-sdk/provider-web-search";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readPluginPackageVersion } from "openclaw/plugin-sdk/extension-shared";
6
- import { readProviderTextResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
6
+ import { ProviderHttpError, readProviderTextResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
7
7
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
8
8
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
9
9
  //#region extensions/parallel/src/parallel-mcp-search.runtime.ts
@@ -25,61 +25,45 @@ function mcpHeaders(params) {
25
25
  return headers;
26
26
  }
27
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.
28
+ * Select the first result/error matching requestId from a fully read JSON or SSE body,
29
+ * falling back to the last result/error when no id matches. JSON batches are flattened
30
+ * one level; multiline SSE data fields are joined and malformed events are skipped.
35
31
  */
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);
32
+ function selectMcpEnvelope(text, requestId) {
33
+ let envelope = {};
34
+ const selectMessage = (message) => {
35
+ if (!isRecord(message) || !("result" in message || "error" in message)) return false;
36
+ envelope = message;
37
+ return message.id === requestId;
38
+ };
39
+ const selectPayload = (json) => {
40
+ try {
41
+ const payload = JSON.parse(json);
42
+ return Array.isArray(payload) ? payload.some(selectMessage) : selectMessage(payload);
43
+ } catch {
44
+ return false;
45
+ }
42
46
  };
43
47
  const body = (text ?? "").trim();
44
- if (!body) return out;
48
+ if (!body) return envelope;
45
49
  if (body.startsWith("{") || body.startsWith("[")) {
46
- try {
47
- emit(JSON.parse(body));
48
- } catch {}
49
- return out;
50
+ selectPayload(body);
51
+ return envelope;
50
52
  }
51
53
  let dataLines = [];
52
54
  const flush = () => {
53
- if (dataLines.length === 0) return;
54
- try {
55
- emit(JSON.parse(dataLines.join("\n")));
56
- } catch {}
55
+ if (dataLines.length === 0) return false;
56
+ const matched = selectPayload(dataLines.join("\n"));
57
57
  dataLines = [];
58
+ return matched;
58
59
  };
59
60
  for (const raw of body.split("\n")) {
60
61
  const line = raw.replace(/\r$/, "");
61
62
  if (line.startsWith("data:")) dataLines.push(line.slice(5).replace(/^ /, ""));
62
- else if (line.trim() === "") flush();
63
+ else if (line.trim() === "" && flush()) return envelope;
63
64
  }
64
65
  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;
66
+ return envelope;
83
67
  }
84
68
  /**
85
69
  * Extract the tool result payload from a `tools/call` envelope.
@@ -113,13 +97,16 @@ async function postMcp(params) {
113
97
  }),
114
98
  body: JSON.stringify(params.body)
115
99
  }
116
- }, async (response) => ({
117
- ok: response.ok,
118
- status: response.status,
119
- statusText: response.statusText,
120
- text: response.ok ? await readProviderTextResponse(response, "Parallel MCP") : await readResponseTextLimited(response, PARALLEL_MCP_ERROR_BODY_LIMIT_BYTES),
121
- sessionIdHeader: response.headers.get("mcp-session-id")
122
- }));
100
+ }, async (response) => {
101
+ if (!response.ok) {
102
+ const detail = await readResponseTextLimited(response, PARALLEL_MCP_ERROR_BODY_LIMIT_BYTES);
103
+ throw new ProviderHttpError(`Parallel MCP ${params.body.method} failed (${response.status}): ${detail || response.statusText}`, { status: response.status });
104
+ }
105
+ return {
106
+ text: await readProviderTextResponse(response, "Parallel MCP"),
107
+ sessionIdHeader: response.headers.get("mcp-session-id")
108
+ };
109
+ });
123
110
  }
124
111
  /**
125
112
  * Run the MCP handshake then a single `tools/call`, returning the tool payload.
@@ -146,11 +133,10 @@ async function mcpCall(toolName, args, timeoutSeconds, signal) {
146
133
  }
147
134
  }
148
135
  });
149
- if (!init.ok) throw new Error(`Parallel MCP initialize failed (${init.status}): ${init.text || init.statusText}`);
150
136
  const sessionId = init.sessionIdHeader ?? void 0;
151
137
  const initEnvelope = selectMcpEnvelope(init.text, initId);
152
138
  const negotiatedVersion = (isRecord(initEnvelope.result) && typeof initEnvelope.result.protocolVersion === "string" ? initEnvelope.result.protocolVersion : void 0) ?? MCP_PROTOCOL_VERSION;
153
- const initialized = await postMcp({
139
+ await postMcp({
154
140
  body: {
155
141
  jsonrpc: "2.0",
156
142
  method: "notifications/initialized"
@@ -160,9 +146,8 @@ async function mcpCall(toolName, args, timeoutSeconds, signal) {
160
146
  timeoutSeconds,
161
147
  signal
162
148
  });
163
- if (!initialized.ok) throw new Error(`Parallel MCP notifications/initialized failed (${initialized.status}): ${initialized.text || initialized.statusText}`);
164
149
  const callId = randomUUID();
165
- const call = await postMcp({
150
+ return extractMcpToolPayload(selectMcpEnvelope((await postMcp({
166
151
  body: {
167
152
  jsonrpc: "2.0",
168
153
  id: callId,
@@ -176,9 +161,7 @@ async function mcpCall(toolName, args, timeoutSeconds, signal) {
176
161
  protocolVersion: negotiatedVersion,
177
162
  timeoutSeconds,
178
163
  signal
179
- });
180
- if (!call.ok) throw new Error(`Parallel MCP tools/call failed (${call.status}): ${call.text || call.statusText}`);
181
- return extractMcpToolPayload(selectMcpEnvelope(call.text, callId));
164
+ })).text, callId));
182
165
  }
183
166
  function normalizeMcpSessionId(value) {
184
167
  return value?.trim() || randomUUID();
@@ -1,6 +1,6 @@
1
- import "./parallel-free-web-search-provider-ucr6eh9O.mjs";
1
+ import "./parallel-free-web-search-provider-DVjfPmlG.mjs";
2
2
  import { DEFAULT_SEARCH_COUNT, buildSearchCacheKey, readCachedSearchPayload, readPositiveIntegerParam, readStringArrayParam, readStringParam, resolveSearchCacheTtlMs, resolveSearchTimeoutSeconds, resolveSiteName, wrapWebContent, writeCachedSearchPayload } from "openclaw/plugin-sdk/provider-web-search";
3
- import { normalizeBoundedOptionalString, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
+ import { asOptionalObjectRecord, isRecord, normalizeBoundedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
4
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
5
5
  import { resolveIntegerOption } from "openclaw/plugin-sdk/number-runtime";
6
6
  //#region extensions/parallel/src/parallel-search-normalize.ts
@@ -11,8 +11,8 @@ 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
13
  function normalizeParallelSearchRequest(args, configuredCount, sessionIdMaxLength) {
14
- const objective = normalizeParallelObjective(readStringParam(args, "objective"));
15
- const cliQuery = normalizeParallelObjective(readStringParam(args, "query"));
14
+ const objective = truncateUtf16Safe(readStringParam(args, "objective") ?? "", PARALLEL_MAX_OBJECTIVE_CHARS) || void 0;
15
+ const cliQuery = truncateUtf16Safe(readStringParam(args, "query") ?? "", PARALLEL_MAX_OBJECTIVE_CHARS) || void 0;
16
16
  let searchQueries = normalizeParallelSearchQueries(readStringArrayParam(args, "search_queries"));
17
17
  if (searchQueries.length === 0 && cliQuery) searchQueries = normalizeParallelSearchQueries([cliQuery]);
18
18
  if (searchQueries.length === 0) return { error: invalidSearchQueriesPayload() };
@@ -21,7 +21,7 @@ function normalizeParallelSearchRequest(args, configuredCount, sessionIdMaxLengt
21
21
  searchQueries,
22
22
  count: resolveParallelSearchCount(args, configuredCount),
23
23
  sessionId: normalizeBoundedOptionalString(readStringParam(args, "session_id"), sessionIdMaxLength),
24
- clientModel: normalizeParallelClientModel(readStringParam(args, "client_model"))
24
+ clientModel: truncateUtf16Safe(readStringParam(args, "client_model") ?? "", PARALLEL_CLIENT_MODEL_MAX_LENGTH) || void 0
25
25
  };
26
26
  }
27
27
  async function executeParallelSearchRequest(params) {
@@ -41,6 +41,7 @@ async function executeParallelSearchRequest(params) {
41
41
  provider: params.provider,
42
42
  objective: request.objective,
43
43
  searchQueries: request.searchQueries,
44
+ count: request.count,
44
45
  response,
45
46
  start
46
47
  });
@@ -58,16 +59,6 @@ function resolveParallelSearchCount(args, configuredCount) {
58
59
  max: PARALLEL_MAX_SEARCH_COUNT
59
60
  });
60
61
  }
61
- function normalizeParallelObjective(value) {
62
- const trimmed = normalizeOptionalString(value);
63
- if (!trimmed) return;
64
- return trimmed.length <= PARALLEL_MAX_OBJECTIVE_CHARS ? trimmed : truncateUtf16Safe(trimmed, PARALLEL_MAX_OBJECTIVE_CHARS);
65
- }
66
- function normalizeParallelClientModel(value) {
67
- const trimmed = normalizeOptionalString(value);
68
- if (!trimmed) return;
69
- return trimmed.length <= PARALLEL_CLIENT_MODEL_MAX_LENGTH ? trimmed : truncateUtf16Safe(trimmed, PARALLEL_CLIENT_MODEL_MAX_LENGTH);
70
- }
71
62
  function normalizeParallelSearchQueries(value) {
72
63
  const candidates = Array.isArray(value) ? value : [];
73
64
  const seen = /* @__PURE__ */ new Set();
@@ -76,7 +67,7 @@ function normalizeParallelSearchQueries(value) {
76
67
  if (typeof entry !== "string") continue;
77
68
  const trimmed = entry.trim();
78
69
  if (!trimmed) continue;
79
- const capped = trimmed.length <= PARALLEL_MAX_SEARCH_QUERY_CHARS ? trimmed : truncateUtf16Safe(trimmed, PARALLEL_MAX_SEARCH_QUERY_CHARS);
70
+ const capped = truncateUtf16Safe(trimmed, PARALLEL_MAX_SEARCH_QUERY_CHARS);
80
71
  if (seen.has(capped)) continue;
81
72
  seen.add(capped);
82
73
  out.push(capped);
@@ -91,15 +82,10 @@ function invalidSearchQueriesPayload() {
91
82
  docs: "https://docs.openclaw.ai/tools/parallel-search"
92
83
  };
93
84
  }
94
- function normalizeParallelResults(payload) {
95
- if (!payload || typeof payload !== "object") return [];
96
- const results = payload.results;
97
- if (!Array.isArray(results)) return [];
98
- return results.filter((entry) => Boolean(entry && typeof entry === "object" && !Array.isArray(entry)));
99
- }
100
85
  /** Maps a Parallel v1 response into wrapped `web_search` result entries. */
101
- function mapParallelResults(response) {
102
- return normalizeParallelResults(response).map((entry) => {
86
+ function mapParallelResults(response, count) {
87
+ const rawResults = asOptionalObjectRecord(response)?.results;
88
+ return (Array.isArray(rawResults) ? rawResults.filter(isRecord) : []).slice(0, count).map((entry) => {
103
89
  const title = typeof entry.title === "string" ? entry.title : "";
104
90
  const url = typeof entry.url === "string" ? entry.url : "";
105
91
  const published = typeof entry.publish_date === "string" && entry.publish_date ? entry.publish_date : void 0;
@@ -114,7 +100,7 @@ function mapParallelResults(response) {
114
100
  });
115
101
  }
116
102
  function buildParallelSearchPayload(params) {
117
- const results = mapParallelResults(params.response);
103
+ const results = mapParallelResults(params.response, params.count);
118
104
  const payload = {
119
105
  ...params.objective ? { objective: params.objective } : {},
120
106
  searchQueries: params.searchQueries,
@@ -1,9 +1,9 @@
1
- import { t as executeParallelSearchRequest } from "./parallel-search-normalize-BTXsGUqi.mjs";
1
+ import { t as executeParallelSearchRequest } from "./parallel-search-normalize-CP1w5YdR.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { mergeScopedSearchConfig, readConfiguredSecretString, readProviderEnvValue, resolveProviderWebSearchPluginConfig, withTrustedWebSearchEndpoint } from "openclaw/plugin-sdk/provider-web-search";
4
4
  import { readPluginPackageVersion } from "openclaw/plugin-sdk/extension-shared";
5
- import { readProviderJsonResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
6
- import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
+ import { ProviderHttpError, readProviderJsonResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
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";
9
9
  //#region extensions/parallel/src/parallel-web-search-provider.runtime.ts
@@ -13,10 +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 resolveParallelConfig(searchConfig) {
17
- const parallel = searchConfig?.parallel;
18
- return parallel && typeof parallel === "object" && !Array.isArray(parallel) ? parallel : {};
19
- }
20
16
  function resolveParallelApiKey(parallel) {
21
17
  return readConfiguredSecretString(parallel?.apiKey, "plugins.entries.parallel.config.webSearch.apiKey") ?? readProviderEnvValue(["PARALLEL_API_KEY"]);
22
18
  }
@@ -76,14 +72,15 @@ async function runParallelSearch(params) {
76
72
  }, async (res) => {
77
73
  if (!res.ok) {
78
74
  const detail = await readResponseTextLimited(res, PARALLEL_ERROR_BODY_LIMIT_BYTES).catch(() => "");
79
- throw new Error(`Parallel API error (${res.status}): ${redactToolPayloadText(redactSensitiveText(detail || res.statusText, { mode: "tools" }))}`);
75
+ params.signal?.throwIfAborted();
76
+ throw new ProviderHttpError(`Parallel API error (${res.status}): ${redactToolPayloadText(redactSensitiveText(detail || res.statusText, { mode: "tools" }))}`, { status: res.status });
80
77
  }
81
78
  return await readProviderJsonResponse(res, "Parallel API", { maxBytes: PARALLEL_SEARCH_RESPONSE_LIMIT_BYTES });
82
79
  });
83
80
  }
84
81
  async function executeParallelWebSearchProviderTool(ctx, args, signal) {
85
82
  const searchConfig = mergeScopedSearchConfig(ctx.searchConfig, "parallel", resolveProviderWebSearchPluginConfig(ctx.config, "parallel"));
86
- const parallelConfig = resolveParallelConfig(searchConfig);
83
+ const parallelConfig = asOptionalRecord(searchConfig?.parallel);
87
84
  const apiKey = resolveParallelApiKey(parallelConfig);
88
85
  if (!apiKey) return missingParallelKeyPayload();
89
86
  const endpointResult = resolveParallelSearchEndpoint(parallelConfig);
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as createParallelWebSearchProvider, t as createParallelFreeWebSearchProvider } from "./.setup/parallel-free-web-search-provider-ucr6eh9O.mjs";
1
+ import { n as createParallelWebSearchProvider, t as createParallelFreeWebSearchProvider } from "./.setup/parallel-free-web-search-provider-DVjfPmlG.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,3 @@
1
- import { n as createParallelWebSearchProvider, t as createParallelFreeWebSearchProvider } from "./.setup/parallel-free-web-search-provider-ucr6eh9O.mjs";
1
+ import { n as createParallelWebSearchProvider, t as createParallelFreeWebSearchProvider } from "./.setup/parallel-free-web-search-provider-DVjfPmlG.mjs";
2
2
  import "./web-search-provider.js";
3
3
  export { createParallelFreeWebSearchProvider, createParallelWebSearchProvider };
@@ -1,2 +1,2 @@
1
- import { n as createParallelWebSearchProvider, t as createParallelFreeWebSearchProvider } from "./.setup/parallel-free-web-search-provider-ucr6eh9O.mjs";
1
+ import { n as createParallelWebSearchProvider, t as createParallelFreeWebSearchProvider } from "./.setup/parallel-free-web-search-provider-DVjfPmlG.mjs";
2
2
  export { createParallelFreeWebSearchProvider, createParallelWebSearchProvider };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/parallel-plugin",
3
- "version": "2026.9.5",
3
+ "version": "2026.9.7",
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.9.5"
21
+ "pluginApi": ">=2026.9.7"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.9.5",
24
+ "openclawVersion": "2026.9.7",
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.9.5"
43
+ "openclaw": ">=2026.9.7"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "openclaw": {