Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

refactor(core): convert MULTICA_API_URL constant to getApiBaseUrl() function

yushenb8aa5ad7e686
diff --git a/packages/core/src/agent/tools/data/finance/api.ts b/packages/core/src/agent/tools/data/finance/api.ts
index ab0a3a22af..150044381f 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<T = Record<string, unknown>>(
): 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 67558acc69..5d2bece103 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 7b54cf071b..c5888b5b36 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 93c15b7a71..a15a27f6b4 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";