@openclaw/perplexity-plugin 2026.8.2 → 2026.9.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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createPerplexityWebSearchProvider } from "./perplexity-web-search-provider-BCKqky14.js";
1
+ import { t as createPerplexityWebSearchProvider } from "./perplexity-web-search-provider-APW6MQ72.js";
2
2
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
3
3
  //#region extensions/perplexity/index.ts
4
4
  var perplexity_default = definePluginEntry({
@@ -4,6 +4,7 @@ import { isRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString } fr
4
4
  //#region extensions/perplexity/src/perplexity-web-search-provider.shared.ts
5
5
  const DEFAULT_PERPLEXITY_BASE_URL = "https://openrouter.ai/api/v1";
6
6
  const PERPLEXITY_DIRECT_BASE_URL = "https://api.perplexity.ai";
7
+ const DEFAULT_PERPLEXITY_MODEL = "perplexity/sonar-pro";
7
8
  const PERPLEXITY_CREDENTIAL_PATH = "plugins.entries.perplexity.config.webSearch.apiKey";
8
9
  const PERPLEXITY_ONBOARDING_SCOPES = ["text-inference"];
9
10
  const PERPLEXITY_KEY_PREFIXES = ["pplx-"];
@@ -32,12 +33,12 @@ function createPerplexityWebSearchProviderBase() {
32
33
  };
33
34
  }
34
35
  function resolvePerplexityWebSearchRuntimeMetadata(ctx) {
35
- return { perplexityTransport: resolvePerplexityRuntimeTransport({
36
- searchConfig: mergeScopedSearchConfig(ctx.searchConfig, "perplexity", resolveProviderWebSearchPluginConfig(ctx.config, "perplexity")),
37
- resolvedKey: ctx.resolvedCredential?.value,
38
- keySource: ctx.resolvedCredential?.source ?? "missing",
39
- fallbackEnvVar: ctx.resolvedCredential?.fallbackEnvVar
40
- }) };
36
+ const credential = ctx.resolvedCredential;
37
+ const source = credential?.source === "env" ? credential.fallbackEnvVar === "PERPLEXITY_API_KEY" ? "perplexity_env" : "openrouter_env" : (credential?.source === "config" || credential?.source === "secretRef") && credential.value ? "config" : "none";
38
+ return { perplexityTransport: resolvePerplexityRuntime(resolvePerplexityConfig(mergeScopedSearchConfig(ctx.searchConfig, "perplexity", resolveProviderWebSearchPluginConfig(ctx.config, "perplexity"))), {
39
+ apiKey: credential?.value,
40
+ source
41
+ }).transport };
41
42
  }
42
43
  function inferPerplexityBaseUrlFromApiKey(apiKey) {
43
44
  if (!apiKey) return;
@@ -52,25 +53,26 @@ function isDirectPerplexityBaseUrl(baseUrl) {
52
53
  return false;
53
54
  }
54
55
  }
55
- function resolvePerplexityRuntimeTransport(params) {
56
- const perplexity = params.searchConfig?.perplexity;
57
- const scoped = perplexity && typeof perplexity === "object" && !Array.isArray(perplexity) ? perplexity : void 0;
58
- const configuredBaseUrl = normalizeOptionalString(scoped?.baseUrl) ?? "";
59
- const configuredModel = normalizeOptionalString(scoped?.model) ?? "";
60
- const baseUrl = (() => {
61
- if (configuredBaseUrl) return configuredBaseUrl;
62
- if (params.keySource === "env") {
63
- if (params.fallbackEnvVar === "PERPLEXITY_API_KEY") return PERPLEXITY_DIRECT_BASE_URL;
64
- if (params.fallbackEnvVar === "OPENROUTER_API_KEY") return DEFAULT_PERPLEXITY_BASE_URL;
65
- }
66
- if ((params.keySource === "config" || params.keySource === "secretRef") && params.resolvedKey) return inferPerplexityBaseUrlFromApiKey(params.resolvedKey) === "openrouter" ? DEFAULT_PERPLEXITY_BASE_URL : PERPLEXITY_DIRECT_BASE_URL;
67
- return DEFAULT_PERPLEXITY_BASE_URL;
68
- })();
69
- return configuredBaseUrl || configuredModel || !isDirectPerplexityBaseUrl(baseUrl) ? "chat_completions" : "search_api";
56
+ function resolvePerplexityConfig(searchConfig) {
57
+ const perplexity = searchConfig?.perplexity;
58
+ return isRecord(perplexity) ? perplexity : {};
59
+ }
60
+ function hasPerplexityLegacyOverride(perplexity) {
61
+ return Boolean(normalizeOptionalString(perplexity?.baseUrl) || normalizeOptionalString(perplexity?.model));
62
+ }
63
+ function resolvePerplexityRuntime(perplexity, auth) {
64
+ const baseUrl = normalizeOptionalString(perplexity?.baseUrl) || (auth.source === "perplexity_env" || auth.source === "config" && inferPerplexityBaseUrlFromApiKey(auth.apiKey) !== "openrouter" ? PERPLEXITY_DIRECT_BASE_URL : DEFAULT_PERPLEXITY_BASE_URL);
65
+ return {
66
+ apiKey: auth.apiKey,
67
+ source: auth.source,
68
+ baseUrl,
69
+ model: normalizeOptionalString(perplexity?.model) || DEFAULT_PERPLEXITY_MODEL,
70
+ transport: hasPerplexityLegacyOverride(perplexity) || !isDirectPerplexityBaseUrl(baseUrl) ? "chat_completions" : "search_api"
71
+ };
70
72
  }
71
73
  //#endregion
72
74
  //#region extensions/perplexity/src/perplexity-web-search-provider.ts
73
- const loadPerplexityWebSearchRuntime = createLazyRuntimeModule(() => import("./perplexity-web-search-provider.runtime-Cex5MH8x.js"));
75
+ const loadPerplexityWebSearchRuntime = createLazyRuntimeModule(() => import("./perplexity-web-search-provider.runtime-CYQXm2j8.js"));
74
76
  function createPerplexityParameters(transport) {
75
77
  const properties = {
76
78
  query: {
@@ -128,12 +130,8 @@ function createPerplexityParameters(transport) {
128
130
  required: ["query"]
129
131
  };
130
132
  }
131
- function hasPerplexityLegacyOverride(searchConfig) {
132
- const perplexity = isRecord(searchConfig?.perplexity) ? searchConfig.perplexity : void 0;
133
- return typeof perplexity?.baseUrl === "string" && perplexity.baseUrl.trim().length > 0 || typeof perplexity?.model === "string" && perplexity.model.trim().length > 0;
134
- }
135
133
  function createPerplexityToolDefinition(searchConfig, runtimeTransport) {
136
- const schemaTransport = runtimeTransport ?? (hasPerplexityLegacyOverride(searchConfig) ? "chat_completions" : void 0);
134
+ const schemaTransport = runtimeTransport ?? (hasPerplexityLegacyOverride(resolvePerplexityConfig(searchConfig)) ? "chat_completions" : void 0);
137
135
  return {
138
136
  description: schemaTransport === "chat_completions" ? "Search the web using Perplexity Sonar via Perplexity/OpenRouter chat completions. Returns AI-synthesized answers with citations from web-grounded search." : "Search the web using Perplexity. Runtime routing decides between native Search API and Sonar chat-completions compatibility. Structured filters are available on the native Search API path.",
139
137
  parameters: createPerplexityParameters(schemaTransport),
@@ -152,4 +150,4 @@ function createPerplexityWebSearchProvider() {
152
150
  };
153
151
  }
154
152
  //#endregion
155
- export { isDirectPerplexityBaseUrl as a, inferPerplexityBaseUrlFromApiKey as i, DEFAULT_PERPLEXITY_BASE_URL as n, PERPLEXITY_DIRECT_BASE_URL as r, createPerplexityWebSearchProvider as t };
153
+ export { resolvePerplexityRuntime as i, isDirectPerplexityBaseUrl as n, resolvePerplexityConfig as r, createPerplexityWebSearchProvider as t };
@@ -1,14 +1,9 @@
1
- import { a as isDirectPerplexityBaseUrl, i as inferPerplexityBaseUrlFromApiKey, n as DEFAULT_PERPLEXITY_BASE_URL, r as PERPLEXITY_DIRECT_BASE_URL } from "./perplexity-web-search-provider-BCKqky14.js";
1
+ import { i as resolvePerplexityRuntime, n as isDirectPerplexityBaseUrl, r as resolvePerplexityConfig } from "./perplexity-web-search-provider-APW6MQ72.js";
2
2
  import { normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  import { readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
4
4
  import { DEFAULT_SEARCH_COUNT, MAX_SEARCH_COUNT, buildSearchCacheKey, isoToPerplexityDate, normalizeFreshness, parseWebSearchTimeFilters, readCachedSearchPayload, readConfiguredSecretString, readPositiveIntegerParam, readProviderEnvValue, readStringArrayParam, readStringParam, resolveSearchCacheTtlMs, resolveSearchCount, resolveSearchTimeoutSeconds, resolveSiteName, throwWebSearchApiError, withTrustedWebSearchEndpoint, wrapWebContent, writeCachedSearchPayload } from "openclaw/plugin-sdk/provider-web-search";
5
5
  //#region extensions/perplexity/src/perplexity-web-search-provider.runtime.ts
6
6
  const PERPLEXITY_SEARCH_ENDPOINT = "https://api.perplexity.ai/search";
7
- const DEFAULT_PERPLEXITY_MODEL = "perplexity/sonar-pro";
8
- function resolvePerplexityConfig(searchConfig) {
9
- const perplexity = searchConfig?.perplexity;
10
- return perplexity && typeof perplexity === "object" && !Array.isArray(perplexity) ? perplexity : {};
11
- }
12
7
  function resolvePerplexityApiKey(perplexity) {
13
8
  const fromConfig = readConfiguredSecretString(perplexity?.apiKey, "plugins.entries.perplexity.config.webSearch.apiKey");
14
9
  if (fromConfig) return {
@@ -30,17 +25,6 @@ function resolvePerplexityApiKey(perplexity) {
30
25
  source: "none"
31
26
  };
32
27
  }
33
- function resolvePerplexityBaseUrl(perplexity, authSource = "none", configuredKey) {
34
- const fromConfig = normalizeOptionalString(perplexity?.baseUrl) ?? "";
35
- if (fromConfig) return fromConfig;
36
- if (authSource === "perplexity_env") return PERPLEXITY_DIRECT_BASE_URL;
37
- if (authSource === "openrouter_env") return DEFAULT_PERPLEXITY_BASE_URL;
38
- if (authSource === "config") return inferPerplexityBaseUrlFromApiKey(configuredKey) === "openrouter" ? DEFAULT_PERPLEXITY_BASE_URL : PERPLEXITY_DIRECT_BASE_URL;
39
- return DEFAULT_PERPLEXITY_BASE_URL;
40
- }
41
- function resolvePerplexityModel(perplexity) {
42
- return (normalizeOptionalString(perplexity?.model) ?? "") || DEFAULT_PERPLEXITY_MODEL;
43
- }
44
28
  function resolvePerplexityRequestModel(baseUrl, model) {
45
29
  if (!isDirectPerplexityBaseUrl(baseUrl)) return model;
46
30
  return model.startsWith("perplexity/") ? model.slice(11) : model;
@@ -54,18 +38,6 @@ function buildPerplexityRequestHeaders(apiKey, acceptJson = false) {
54
38
  "X-Title": "OpenClaw Web Search"
55
39
  };
56
40
  }
57
- function resolvePerplexityTransport(perplexity) {
58
- const auth = resolvePerplexityApiKey(perplexity);
59
- const baseUrl = resolvePerplexityBaseUrl(perplexity, auth.source, auth.apiKey);
60
- const model = resolvePerplexityModel(perplexity);
61
- const hasLegacyOverride = Boolean(normalizeOptionalString(perplexity?.baseUrl) || normalizeOptionalString(perplexity?.model));
62
- return {
63
- ...auth,
64
- baseUrl,
65
- model,
66
- transport: hasLegacyOverride || !isDirectPerplexityBaseUrl(baseUrl) ? "chat_completions" : "search_api"
67
- };
68
- }
69
41
  function extractPerplexityCitations(data) {
70
42
  const topLevel = (data.citations ?? []).filter((url) => Boolean(normalizeOptionalString(url)));
71
43
  if (topLevel.length > 0) return uniqueStrings(topLevel);
@@ -150,7 +122,8 @@ async function runPerplexitySearch(params) {
150
122
  });
151
123
  }
152
124
  async function executePerplexitySearch(args, searchConfig, signal) {
153
- const runtime = resolvePerplexityTransport(resolvePerplexityConfig(searchConfig));
125
+ const perplexityConfig = resolvePerplexityConfig(searchConfig);
126
+ const runtime = resolvePerplexityRuntime(perplexityConfig, resolvePerplexityApiKey(perplexityConfig));
154
127
  if (!runtime.apiKey) return {
155
128
  error: "missing_perplexity_api_key",
156
129
  message: "web_search (perplexity) needs an API key. Set PERPLEXITY_API_KEY or OPENROUTER_API_KEY in the Gateway environment, or configure plugins.entries.perplexity.config.webSearch.apiKey. If you do not want to configure a search API key, use web_fetch for a specific URL or the browser tool for interactive pages.",
@@ -332,10 +305,6 @@ async function executePerplexitySearch(args, searchConfig, signal) {
332
305
  return payload;
333
306
  }
334
307
  const testing = {
335
- inferPerplexityBaseUrlFromApiKey,
336
- resolvePerplexityBaseUrl,
337
- resolvePerplexityModel,
338
- resolvePerplexityTransport,
339
308
  resolvePerplexityRequestModel,
340
309
  resolvePerplexityApiKey
341
310
  };
@@ -1,3 +1,3 @@
1
- import { t as createPerplexityWebSearchProvider } from "./perplexity-web-search-provider-BCKqky14.js";
1
+ import { t as createPerplexityWebSearchProvider } from "./perplexity-web-search-provider-APW6MQ72.js";
2
2
  import "./web-search-provider.js";
3
3
  export { createPerplexityWebSearchProvider };
@@ -1,2 +1,2 @@
1
- import { t as createPerplexityWebSearchProvider } from "./perplexity-web-search-provider-BCKqky14.js";
1
+ import { t as createPerplexityWebSearchProvider } from "./perplexity-web-search-provider-APW6MQ72.js";
2
2
  export { createPerplexityWebSearchProvider };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/perplexity-plugin",
3
- "version": "2026.8.2",
3
+ "version": "2026.9.1",
4
4
  "description": "OpenClaw Perplexity 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.8.2"
21
+ "pluginApi": ">=2026.9.1"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.8.2",
24
+ "openclawVersion": "2026.9.1",
25
25
  "bundledDist": false
26
26
  },
27
27
  "release": {
@@ -38,7 +38,7 @@
38
38
  "README.md"
39
39
  ],
40
40
  "peerDependencies": {
41
- "openclaw": ">=2026.8.2"
41
+ "openclaw": ">=2026.9.1"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "openclaw": {