fix: connect Page Data sandbox to user PostgreSQL
Memind CI / Test, build, and release guards (pull_request) Failing after 15m29s
Memind CI / Test, build, and release guards (pull_request) Failing after 15m29s
This commit is contained in:
+43
-1
@@ -15,6 +15,33 @@ export function resolveSandboxMcpNodeExecPath(overridePath) {
|
||||
return process.execPath;
|
||||
}
|
||||
|
||||
const LOOPBACK_PG_HOSTS = new Set(['127.0.0.1', 'localhost', '::1']);
|
||||
|
||||
export function resolveSandboxMcpUserDataPgUrl({
|
||||
portalUrl,
|
||||
mcpUrl,
|
||||
containerized = false,
|
||||
hostGateway = 'host.docker.internal',
|
||||
} = {}) {
|
||||
const explicitMcpUrl = String(mcpUrl ?? '').trim();
|
||||
if (explicitMcpUrl) return explicitMcpUrl;
|
||||
|
||||
const sourceUrl = String(portalUrl ?? '').trim();
|
||||
if (!sourceUrl || !containerized) return sourceUrl;
|
||||
|
||||
try {
|
||||
const parsed = new URL(sourceUrl);
|
||||
if (LOOPBACK_PG_HOSTS.has(parsed.hostname)) {
|
||||
parsed.hostname = String(hostGateway || 'host.docker.internal').trim();
|
||||
}
|
||||
return parsed.toString();
|
||||
} catch {
|
||||
// Preserve the configured value so the MCP reports the real configuration
|
||||
// error instead of silently falling back to its local Unix socket default.
|
||||
return sourceUrl;
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveMindSearchMcpServerPath(overridePath) {
|
||||
const normalized = String(overridePath ?? '').trim();
|
||||
if (normalized) return normalized;
|
||||
@@ -311,6 +338,21 @@ function sandboxMcpEnvs(sandboxMcp, mcpTools) {
|
||||
if (sandboxMcp.workspaceRoot || localRoot) envs.MINDSPACE_WORKSPACE_ROOT = sandboxMcp.workspaceRoot || localRoot;
|
||||
if (sandboxMcp.workspaceRef) envs.MINDSPACE_WORKSPACE_REF = sandboxMcp.workspaceRef;
|
||||
if (sandboxMcp.userId) envs.PRIVATE_DATA_USER_ID = sandboxMcp.userId;
|
||||
if (mcpTools.includes('private_data_info')) {
|
||||
const userDataPgUrl = resolveSandboxMcpUserDataPgUrl({
|
||||
portalUrl: sandboxMcp.userDataPgUrl ?? process.env.MINDSPACE_USERDATA_PG_URL,
|
||||
mcpUrl: sandboxMcp.userDataMcpPgUrl ?? process.env.MINDSPACE_USERDATA_MCP_PG_URL,
|
||||
containerized: Boolean(sandboxMcp.containerized),
|
||||
hostGateway:
|
||||
sandboxMcp.userDataPgHostGateway ?? process.env.MINDSPACE_USERDATA_MCP_PG_HOST ?? 'host.docker.internal',
|
||||
});
|
||||
envs.MINDSPACE_USERDATA_BACKEND = sandboxMcp.userDataBackend ?? process.env.MINDSPACE_USERDATA_BACKEND ?? 'postgres';
|
||||
if (userDataPgUrl) envs.MINDSPACE_USERDATA_PG_URL = userDataPgUrl;
|
||||
const autoProvision = sandboxMcp.userDataAutoProvision ?? process.env.MINDSPACE_USERDATA_AUTO_PROVISION;
|
||||
if (autoProvision != null && String(autoProvision).trim()) {
|
||||
envs.MINDSPACE_USERDATA_AUTO_PROVISION = String(autoProvision).trim();
|
||||
}
|
||||
}
|
||||
for (const key of [
|
||||
'DATABASE_URL',
|
||||
'MYSQL_HOST',
|
||||
@@ -356,7 +398,7 @@ export function buildAgentExtensionPolicy(
|
||||
type: 'stdio',
|
||||
name: 'sandbox-fs',
|
||||
description:
|
||||
'工作区沙箱文件系统与用户私有数据空间。用户私有数据空间是当前用户唯一的 SQLite 数据库,适合问卷、表单、清单、调研数据和分析中间表;不要用于账号、计费、权限、审计、公开平台数据或跨用户数据。',
|
||||
'工作区沙箱文件系统与用户私有数据空间。用户私有数据空间是当前用户隔离的 PostgreSQL schema,适合问卷、表单、清单、调研数据和分析中间表;不要用于账号、计费、权限、审计、公开平台数据或跨用户数据。',
|
||||
display_name: 'sandbox-fs',
|
||||
bundled: false,
|
||||
cmd: resolveSandboxMcpNodeExecPath(sandboxMcp.nodeExecPath),
|
||||
|
||||
Reference in New Issue
Block a user