@ogment-ai/cli 0.9.1-next.1 → 0.9.1-next.2
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/cli.js +17 -4
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -71903,11 +71903,25 @@ const createRemoteRequestErrorFromMcpCause = (options) => {
|
|
|
71903
71903
|
const MCP_CONNECT_TIMEOUT_MS = 1e4;
|
|
71904
71904
|
const MCP_DISCOVERY_TIMEOUT_MS = 1e4;
|
|
71905
71905
|
const MCP_INVOKE_TIMEOUT_MS = 45e3;
|
|
71906
|
+
const DEFAULT_PATH_PREFIX = "/api/v1/mcp";
|
|
71906
71907
|
const normalizePathPrefix = (value) => {
|
|
71907
|
-
const candidate = value?.trim() ||
|
|
71908
|
+
const candidate = value?.trim() || DEFAULT_PATH_PREFIX;
|
|
71908
71909
|
if (candidate.startsWith("/")) return candidate;
|
|
71909
71910
|
return `/${candidate}`;
|
|
71910
71911
|
};
|
|
71912
|
+
const isLocalhost = (hostname) => {
|
|
71913
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname.startsWith("192.168.") || hostname.endsWith(".local");
|
|
71914
|
+
};
|
|
71915
|
+
const buildMcpEndpointUrl = (baseUrl, pathPrefix, target) => {
|
|
71916
|
+
const base = new URL(baseUrl);
|
|
71917
|
+
if (isLocalhost(base.hostname)) return new URL(`${pathPrefix}/${target.orgSlug}/${target.serverPath}`, `${base.origin}/`);
|
|
71918
|
+
if (base.hostname.startsWith("dashboard.")) {
|
|
71919
|
+
const rootDomain = base.hostname.slice(10);
|
|
71920
|
+
const toolPath = pathPrefix === "/code" ? `/code/${target.serverPath}` : `/${target.serverPath}`;
|
|
71921
|
+
return new URL(`${base.protocol}//${target.orgSlug}.mcp.${rootDomain}${toolPath}`);
|
|
71922
|
+
}
|
|
71923
|
+
return new URL(`${pathPrefix}/${target.orgSlug}/${target.serverPath}`, `${base.origin}/`);
|
|
71924
|
+
};
|
|
71911
71925
|
const defaultCreateClient = (version) => {
|
|
71912
71926
|
return new Client({
|
|
71913
71927
|
name: APP_NAME,
|
|
@@ -71922,8 +71936,7 @@ const createMcpService = (deps) => {
|
|
|
71922
71936
|
const createTransport = deps.createTransport ?? defaultCreateTransport;
|
|
71923
71937
|
const pathPrefix = normalizePathPrefix(deps.pathPrefix);
|
|
71924
71938
|
const withClient = async (target, apiKey, handler) => {
|
|
71925
|
-
const
|
|
71926
|
-
const transport = createTransport(new URL(endpoint), apiKey);
|
|
71939
|
+
const transport = createTransport(buildMcpEndpointUrl(deps.baseUrl, pathPrefix, target), apiKey);
|
|
71927
71940
|
const client = createClient();
|
|
71928
71941
|
const connectResult = await Result.tryPromise({
|
|
71929
71942
|
catch: (cause) => createRemoteRequestErrorFromMcpCause({
|
|
@@ -72542,4 +72555,4 @@ if (shouldExecuteCli(import.meta.url, process.argv[1])) await executeCli();
|
|
|
72542
72555
|
|
|
72543
72556
|
//#endregion
|
|
72544
72557
|
export { executeCli, runCli, shouldExecuteCli };
|
|
72545
|
-
//# debugId=
|
|
72558
|
+
//# debugId=7f3c7b5c-dc65-451e-8bd3-f0541a4f4fdf
|