Merge 1791308cc9 into 87267fad4f
This commit is contained in:
commit
07806339de
@ -6,6 +6,7 @@ Docs: https://docs.openclaw.ai
|
|||||||
Status: stable.
|
Status: stable.
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
- Tools: add HTTP/HTTPS proxy support for web_search and web_fetch via environment variables (HTTP_PROXY/HTTPS_PROXY).
|
||||||
- Rebrand: rename the npm package/CLI to `openclaw`, add a `openclaw` compatibility shim, and move extensions to the `@openclaw/*` scope.
|
- Rebrand: rename the npm package/CLI to `openclaw`, add a `openclaw` compatibility shim, and move extensions to the `@openclaw/*` scope.
|
||||||
- Onboarding: strengthen security warning copy for beta + access control expectations.
|
- Onboarding: strengthen security warning copy for beta + access control expectations.
|
||||||
- Onboarding: add Venice API key to non-interactive flow. (#1893) Thanks @jonisjongithub.
|
- Onboarding: add Venice API key to non-interactive flow. (#1893) Thanks @jonisjongithub.
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Type } from "@sinclair/typebox";
|
|||||||
|
|
||||||
import type { OpenClawConfig } from "../../config/config.js";
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
import { formatCliCommand } from "../../cli/command-format.js";
|
import { formatCliCommand } from "../../cli/command-format.js";
|
||||||
|
import { createProxyAgent } from "../../infra/net/ssrf.js";
|
||||||
import type { AnyAgentTool } from "./common.js";
|
import type { AnyAgentTool } from "./common.js";
|
||||||
import { jsonResult, readNumberParam, readStringParam } from "./common.js";
|
import { jsonResult, readNumberParam, readStringParam } from "./common.js";
|
||||||
import {
|
import {
|
||||||
@ -273,6 +274,7 @@ async function runPerplexitySearch(params: {
|
|||||||
timeoutSeconds: number;
|
timeoutSeconds: number;
|
||||||
}): Promise<{ content: string; citations: string[] }> {
|
}): Promise<{ content: string; citations: string[] }> {
|
||||||
const endpoint = `${params.baseUrl.replace(/\/$/, "")}/chat/completions`;
|
const endpoint = `${params.baseUrl.replace(/\/$/, "")}/chat/completions`;
|
||||||
|
const proxyAgent = createProxyAgent();
|
||||||
|
|
||||||
const res = await fetch(endpoint, {
|
const res = await fetch(endpoint, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -292,6 +294,8 @@ async function runPerplexitySearch(params: {
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
signal: withTimeout(undefined, params.timeoutSeconds * 1000),
|
signal: withTimeout(undefined, params.timeoutSeconds * 1000),
|
||||||
|
// @ts-expect-error - undici ProxyAgent dispatcher is not in standard fetch types
|
||||||
|
dispatcher: proxyAgent,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
@ -371,6 +375,7 @@ async function runWebSearch(params: {
|
|||||||
url.searchParams.set("freshness", params.freshness);
|
url.searchParams.set("freshness", params.freshness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const proxyAgent = createProxyAgent();
|
||||||
const res = await fetch(url.toString(), {
|
const res = await fetch(url.toString(), {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
@ -378,6 +383,8 @@ async function runWebSearch(params: {
|
|||||||
"X-Subscription-Token": params.apiKey,
|
"X-Subscription-Token": params.apiKey,
|
||||||
},
|
},
|
||||||
signal: withTimeout(undefined, params.timeoutSeconds * 1000),
|
signal: withTimeout(undefined, params.timeoutSeconds * 1000),
|
||||||
|
// @ts-expect-error - undici ProxyAgent dispatcher is not in standard fetch types
|
||||||
|
dispatcher: proxyAgent,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
|||||||
@ -64,12 +64,12 @@ export function randomToken(): string {
|
|||||||
|
|
||||||
export function printWizardHeader(runtime: RuntimeEnv) {
|
export function printWizardHeader(runtime: RuntimeEnv) {
|
||||||
const header = [
|
const header = [
|
||||||
"▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄",
|
"▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄",
|
||||||
"██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░██",
|
"██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░██",
|
||||||
"██░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░██",
|
"██░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░██",
|
||||||
"██░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██",
|
"██░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██",
|
||||||
"▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀",
|
"▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀",
|
||||||
" 🦞 OPENCLAW 🦞 ",
|
" 🦞 OPENCLAW 🦞 ",
|
||||||
" ",
|
" ",
|
||||||
].join("\n");
|
].join("\n");
|
||||||
runtime.log(header);
|
runtime.log(header);
|
||||||
|
|||||||
@ -49,7 +49,13 @@ describe("state + config path candidates", () => {
|
|||||||
const home = "/home/test";
|
const home = "/home/test";
|
||||||
const candidates = resolveDefaultConfigCandidates({} as NodeJS.ProcessEnv, () => home);
|
const candidates = resolveDefaultConfigCandidates({} as NodeJS.ProcessEnv, () => home);
|
||||||
expect(candidates[0]).toBe(path.join(home, ".openclaw", "openclaw.json"));
|
expect(candidates[0]).toBe(path.join(home, ".openclaw", "openclaw.json"));
|
||||||
expect(candidates).toHaveLength(1);
|
// Should include new .openclaw dir + legacy dirs (.clawdbot, .moltbot, .moldbot)
|
||||||
|
// with all config filenames (openclaw.json + clawdbot.json, moltbot.json, moldbot.json)
|
||||||
|
// = 4 dirs × 4 filenames = 16 candidates
|
||||||
|
expect(candidates).toHaveLength(16);
|
||||||
|
// Verify the candidates include expected legacy paths
|
||||||
|
expect(candidates).toContain(path.join(home, ".clawdbot", "clawdbot.json"));
|
||||||
|
expect(candidates).toContain(path.join(home, ".moltbot", "moltbot.json"));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("prefers ~/.openclaw when it exists and legacy dir is missing", async () => {
|
it("prefers ~/.openclaw when it exists and legacy dir is missing", async () => {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { lookup as dnsLookup } from "node:dns/promises";
|
import { lookup as dnsLookup } from "node:dns/promises";
|
||||||
import { lookup as dnsLookupCb, type LookupAddress } from "node:dns";
|
import { lookup as dnsLookupCb, type LookupAddress } from "node:dns";
|
||||||
import { Agent, type Dispatcher } from "undici";
|
import { Agent, ProxyAgent, type Dispatcher } from "undici";
|
||||||
|
|
||||||
type LookupCallback = (
|
type LookupCallback = (
|
||||||
err: NodeJS.ErrnoException | null,
|
err: NodeJS.ErrnoException | null,
|
||||||
@ -210,7 +210,30 @@ export async function resolvePinnedHostname(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createProxyAgent(): ProxyAgent | undefined {
|
||||||
|
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
|
||||||
|
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
|
||||||
|
const proxy = httpsProxy || httpProxy;
|
||||||
|
|
||||||
|
if (!proxy) return undefined;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return new ProxyAgent(proxy);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to create proxy agent:", error);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function createPinnedDispatcher(pinned: PinnedHostname): Dispatcher {
|
export function createPinnedDispatcher(pinned: PinnedHostname): Dispatcher {
|
||||||
|
// If proxy is configured, use ProxyAgent instead of pinned Agent
|
||||||
|
// Note: When using proxy, SSRF protection is bypassed as the proxy handles DNS
|
||||||
|
const proxyAgent = createProxyAgent();
|
||||||
|
if (proxyAgent) {
|
||||||
|
return proxyAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, use Agent with pinned lookup for SSRF protection
|
||||||
return new Agent({
|
return new Agent({
|
||||||
connect: {
|
connect: {
|
||||||
lookup: pinned.lookup,
|
lookup: pinned.lookup,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user