diff --git a/packages/core/src/agent/tools/data/finance/api.ts b/packages/core/src/agent/tools/data/finance/api.ts index ab0a3a22..15004438 100644 --- a/packages/core/src/agent/tools/data/finance/api.ts +++ b/packages/core/src/agent/tools/data/finance/api.ts @@ -5,7 +5,7 @@ * All endpoints use GET with query parameters. */ -import { API_BASE_URL, getAuthHeaders } from "../../../../hub/api-client.js"; +import { getApiBaseUrl, getAuthHeaders } from "../../../../hub/api-client.js"; const PATH_PREFIX = "/api/v1/financial"; const TIMEOUT_MS = 30_000; @@ -24,7 +24,7 @@ export async function financeFetch>( ): Promise<{ data: T; url: string }> { const authHeaders = getAuthHeaders("to use financial data tools"); - const url = new URL(PATH_PREFIX + path, API_BASE_URL); + const url = new URL(PATH_PREFIX + path, getApiBaseUrl()); for (const [key, value] of Object.entries(params)) { if (value === undefined || value === null) continue; if (Array.isArray(value)) { diff --git a/packages/core/src/agent/tools/web/web-search.ts b/packages/core/src/agent/tools/web/web-search.ts index 67558acc..5d2bece1 100644 --- a/packages/core/src/agent/tools/web/web-search.ts +++ b/packages/core/src/agent/tools/web/web-search.ts @@ -1,7 +1,7 @@ import { Type } from "@sinclair/typebox"; import type { AgentTool } from "@mariozechner/pi-agent-core"; -import { API_BASE_URL, getAuthHeaders } from "../../../hub/api-client.js"; +import { getApiBaseUrl, getAuthHeaders } from "../../../hub/api-client.js"; import { DEFAULT_CACHE_TTL_MINUTES, DEFAULT_TIMEOUT_SECONDS, @@ -61,7 +61,7 @@ async function runDevvSearch(params: { }> { const authHeaders = getAuthHeaders("to use web search"); - const res = await fetch(`${API_BASE_URL}${WEB_SEARCH_PATH}`, { + const res = await fetch(`${getApiBaseUrl()}${WEB_SEARCH_PATH}`, { method: "POST", headers: { "Content-Type": "application/json", diff --git a/packages/core/src/hub/api-client.ts b/packages/core/src/hub/api-client.ts index 7b54cf07..c5888b5b 100644 --- a/packages/core/src/hub/api-client.ts +++ b/packages/core/src/hub/api-client.ts @@ -1,6 +1,8 @@ import { getLocalAuth } from "./auth-store.js"; -export const API_BASE_URL = "https://api.multica.ai"; +export function getApiBaseUrl(): string { + return process.env.MULTICA_API_URL || "https://api.multica.ai"; +} /** * Return auth headers for the proxy API. diff --git a/packages/core/src/hub/index.ts b/packages/core/src/hub/index.ts index 93c15b7a..a15a27f6 100644 --- a/packages/core/src/hub/index.ts +++ b/packages/core/src/hub/index.ts @@ -2,5 +2,5 @@ export { Hub } from "./hub.js"; export type { MessageSource, InboundMessageEvent } from "./hub.js"; export { getHubId } from "./hub-identity.js"; export { getLocalAuth, type LocalAuthData } from "./auth-store.js"; -export { API_BASE_URL, getAuthHeaders } from "./api-client.js"; +export { getApiBaseUrl, getAuthHeaders } from "./api-client.js"; export type { HubOptions } from "./types.js";