@blockrun/clawrouter 0.12.141 → 0.12.143

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
@@ -79884,7 +79884,11 @@ function extractResults(payload) {
79884
79884
  }
79885
79885
  const direct = asObject(payload);
79886
79886
  if (!direct) return [];
79887
- const candidates = [direct.results, asObject(direct.data)?.results, asObject(direct.response)?.results];
79887
+ const candidates = [
79888
+ direct.results,
79889
+ asObject(direct.data)?.results,
79890
+ asObject(direct.response)?.results
79891
+ ];
79888
79892
  for (const candidate of candidates) {
79889
79893
  if (!Array.isArray(candidate)) continue;
79890
79894
  return candidate.map(asObject).filter((entry) => Boolean(entry));
@@ -79945,10 +79949,7 @@ async function runBlockrunExaSearch(args) {
79945
79949
  if (!query) {
79946
79950
  return errorPayload("missing_query", "web_search (blockrun-exa) requires a non-empty query.");
79947
79951
  }
79948
- const count = Math.min(
79949
- readPositiveInteger(args.count) ?? DEFAULT_RESULT_COUNT,
79950
- MAX_RESULT_COUNT
79951
- );
79952
+ const count = Math.min(readPositiveInteger(args.count) ?? DEFAULT_RESULT_COUNT, MAX_RESULT_COUNT);
79952
79953
  const category = readString(args.category);
79953
79954
  const includeDomains = readStringList(args.include_domains) ?? readStringList(args.includeDomains) ?? readStringList(args.domains);
79954
79955
  const excludeDomains = readStringList(args.exclude_domains) ?? readStringList(args.excludeDomains);
@@ -81374,6 +81375,41 @@ async function startProxyInBackground(api) {
81374
81375
  api.logger.info(`Wallet (${network}): ${displayAddress} | Balance: (checking...)`);
81375
81376
  });
81376
81377
  }
81378
+ function startProxyAfterPortProbe(api) {
81379
+ const proxyPort = getProxyPort();
81380
+ const portProbe = import("net").then(
81381
+ (net) => new Promise((resolve) => {
81382
+ const sock = net.connect({ host: "127.0.0.1", port: proxyPort }, () => {
81383
+ sock.destroy();
81384
+ resolve(true);
81385
+ });
81386
+ sock.on("error", () => resolve(false));
81387
+ sock.setTimeout(500, () => {
81388
+ sock.destroy();
81389
+ resolve(false);
81390
+ });
81391
+ })
81392
+ );
81393
+ portProbe.then((portInUse) => {
81394
+ if (portInUse) {
81395
+ api.logger.info(
81396
+ `Port ${proxyPort} already in use \u2014 skipping proxy startup (another instance running)`
81397
+ );
81398
+ return;
81399
+ }
81400
+ return startProxyInBackground(api).then(async () => {
81401
+ const port = getProxyPort();
81402
+ const healthy = await waitForProxyHealth(port, 15e3);
81403
+ if (!healthy) {
81404
+ api.logger.warn(`Proxy health check timed out, commands may not work immediately`);
81405
+ }
81406
+ });
81407
+ }).catch((err) => {
81408
+ api.logger.error(
81409
+ `Failed to start BlockRun proxy: ${err instanceof Error ? err.message : String(err)}`
81410
+ );
81411
+ });
81412
+ }
81377
81413
  var IMAGE_DIR2 = join10(homedir7(), ".openclaw", "blockrun", "images");
81378
81414
  var AUDIO_DIR2 = join10(homedir7(), ".openclaw", "blockrun", "audio");
81379
81415
  function buildImageGenerationProvider() {
@@ -81817,7 +81853,10 @@ var plugin = {
81817
81853
  }
81818
81854
  api.config.tools.web.search.provider = BLOCKRUN_EXA_PROVIDER_ID;
81819
81855
  api.config.tools.web.search.enabled = true;
81820
- const runtimeMcpResult = ensureBlockrunMcpServerConfig(api.config, blockrunMcpServer.definition);
81856
+ const runtimeMcpResult = ensureBlockrunMcpServerConfig(
81857
+ api.config,
81858
+ blockrunMcpServer.definition
81859
+ );
81821
81860
  api.logger.info("BlockRun provider registered (55+ models via x402)");
81822
81861
  if (typeof api.registerWebSearchProvider === "function") {
81823
81862
  api.logger.info(`Registered BlockRun web_search provider (${BLOCKRUN_EXA_PROVIDER_ID})`);
@@ -81827,9 +81866,7 @@ var plugin = {
81827
81866
  blockrunMcpServer.source === "local" ? `Configured BlockRun MCP server (${BLOCKRUN_MCP_SERVER_NAME}) from local blockrun-mcp build` : `Configured BlockRun MCP server (${BLOCKRUN_MCP_SERVER_NAME}) via npx @blockrun/mcp@latest`
81828
81867
  );
81829
81868
  } else if (runtimeMcpResult.status === "preserved") {
81830
- api.logger.info(
81831
- `Preserved custom BlockRun MCP server config (${BLOCKRUN_MCP_SERVER_NAME})`
81832
- );
81869
+ api.logger.info(`Preserved custom BlockRun MCP server config (${BLOCKRUN_MCP_SERVER_NAME})`);
81833
81870
  }
81834
81871
  try {
81835
81872
  const proxyBaseUrl = `http://127.0.0.1:${runtimePort}`;
@@ -81924,44 +81961,32 @@ var plugin = {
81924
81961
  api.logger.info("Not in gateway mode \u2014 proxy will start when gateway runs");
81925
81962
  return;
81926
81963
  }
81964
+ const pluginConfigEmpty = !api.pluginConfig || typeof api.pluginConfig !== "object" || Object.keys(api.pluginConfig).length === 0;
81927
81965
  if (proxyAlreadyStarted) {
81928
81966
  api.logger.info("Proxy already started by earlier register() call \u2014 skipping");
81929
81967
  return;
81930
81968
  }
81931
- proc.__clawrouterProxyStarted = true;
81932
- const proxyPort = getProxyPort();
81933
- const portProbe = import("net").then(
81934
- (net) => new Promise((resolve) => {
81935
- const sock = net.connect({ host: "127.0.0.1", port: proxyPort }, () => {
81936
- sock.destroy();
81937
- resolve(true);
81938
- });
81939
- sock.on("error", () => resolve(false));
81940
- sock.setTimeout(500, () => {
81941
- sock.destroy();
81942
- resolve(false);
81943
- });
81944
- })
81945
- );
81946
- portProbe.then((portInUse) => {
81947
- if (portInUse) {
81948
- api.logger.info(
81949
- `Port ${proxyPort} already in use \u2014 skipping proxy startup (another instance running)`
81950
- );
81951
- return;
81952
- }
81953
- return startProxyInBackground(api).then(async () => {
81954
- const port = getProxyPort();
81955
- const healthy = await waitForProxyHealth(port, 15e3);
81956
- if (!healthy) {
81957
- api.logger.warn(`Proxy health check timed out, commands may not work immediately`);
81958
- }
81959
- });
81960
- }).catch((err) => {
81961
- api.logger.error(
81962
- `Failed to start BlockRun proxy: ${err instanceof Error ? err.message : String(err)}`
81969
+ const procDeferred = proc;
81970
+ if (procDeferred.__clawrouterDeferredStartTimer) {
81971
+ clearTimeout(procDeferred.__clawrouterDeferredStartTimer);
81972
+ procDeferred.__clawrouterDeferredStartTimer = void 0;
81973
+ api.logger.info("Superseding earlier deferred proxy start \u2014 using current pluginConfig");
81974
+ }
81975
+ if (pluginConfigEmpty) {
81976
+ api.logger.info(
81977
+ "pluginConfig empty \u2014 deferring proxy startup 250ms in case a populated config arrives"
81963
81978
  );
81964
- });
81979
+ procDeferred.__clawrouterDeferredStartTimer = setTimeout(() => {
81980
+ procDeferred.__clawrouterDeferredStartTimer = void 0;
81981
+ if (proc.__clawrouterProxyStarted) return;
81982
+ proc.__clawrouterProxyStarted = true;
81983
+ api.logger.info("Deferred timer fired \u2014 starting proxy with default config");
81984
+ startProxyAfterPortProbe(api);
81985
+ }, 250);
81986
+ return;
81987
+ }
81988
+ proc.__clawrouterProxyStarted = true;
81989
+ startProxyAfterPortProbe(api);
81965
81990
  },
81966
81991
  /**
81967
81992
  * Cleanup hook called when plugin is uninstalled via `openclaw plugins uninstall`.