merge: server architecture modularization
This commit is contained in:
@@ -9,6 +9,8 @@ import {
|
||||
DEFAULT_USER_CAPABILITIES,
|
||||
normalizeCapabilityPatch,
|
||||
resolveMindSearchMcpEndpoint,
|
||||
resolveExcelMcpServerPath,
|
||||
resolveMindSearchMcpServerPath,
|
||||
resolveSandboxMcpNodeExecPath,
|
||||
resolveSandboxMcpServerPath,
|
||||
resolveSandboxMcpUserDataPgUrl,
|
||||
@@ -30,6 +32,22 @@ test('resolveSandboxMcpServerPath honors container-path override without host fs
|
||||
);
|
||||
});
|
||||
|
||||
test('bundled MCP paths use the persistent Portal runtime root in split mode', () => {
|
||||
const runtimeRoot = '/srv/memind-persistent';
|
||||
assert.equal(
|
||||
resolveSandboxMcpServerPath('', runtimeRoot),
|
||||
'/srv/memind-persistent/mindspace-sandbox-mcp.mjs',
|
||||
);
|
||||
assert.equal(
|
||||
resolveMindSearchMcpServerPath('', runtimeRoot),
|
||||
'/srv/memind-persistent/tkmind-search-mcp.mjs',
|
||||
);
|
||||
assert.equal(
|
||||
resolveExcelMcpServerPath('', runtimeRoot),
|
||||
'/srv/memind-persistent/tkmind-excel-mcp.mjs',
|
||||
);
|
||||
});
|
||||
|
||||
test('resolveSandboxMcpUserDataPgUrl rewrites a portal loopback URL for container MCP access', () => {
|
||||
const resolved = resolveSandboxMcpUserDataPgUrl({
|
||||
portalUrl: 'postgresql://mindspace:secret@127.0.0.1:5433/mindspace_userdata_prod',
|
||||
@@ -41,6 +59,35 @@ test('resolveSandboxMcpUserDataPgUrl rewrites a portal loopback URL for containe
|
||||
assert.equal(parsed.pathname, '/mindspace_userdata_prod');
|
||||
});
|
||||
|
||||
test('resolveSandboxMcpUserDataPgUrl rewrites a host Unix socket DSN for container MCP access', () => {
|
||||
const resolved = resolveSandboxMcpUserDataPgUrl({
|
||||
portalUrl: 'postgresql://john:secret@/mindspace_userdata_dev?host=%2Ftmp&port=5433',
|
||||
containerized: true,
|
||||
});
|
||||
const parsed = new URL(resolved);
|
||||
assert.equal(parsed.hostname, 'host.docker.internal');
|
||||
assert.equal(parsed.port, '5433');
|
||||
assert.equal(parsed.pathname, '/mindspace_userdata_dev');
|
||||
assert.equal(parsed.password, 'secret');
|
||||
assert.equal(parsed.searchParams.has('host'), false);
|
||||
assert.equal(parsed.searchParams.has('port'), false);
|
||||
});
|
||||
|
||||
test('resolveSandboxMcpUserDataPgUrl fails fast for passwordless socket DSN in a container', () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
resolveSandboxMcpUserDataPgUrl({
|
||||
portalUrl:
|
||||
'postgresql://john@/mindspace_userdata_dev?host=%2Ftmp&port=5433',
|
||||
containerized: true,
|
||||
}),
|
||||
(error) =>
|
||||
error?.code ===
|
||||
'MINDSPACE_USERDATA_MCP_PG_URL_REQUIRED' &&
|
||||
/MINDSPACE_USERDATA_MCP_PG_URL/.test(error.message),
|
||||
);
|
||||
});
|
||||
|
||||
test('resolveSandboxMcpUserDataPgUrl preserves native URLs and honors an explicit MCP URL', () => {
|
||||
const portalUrl = 'postgresql://mindspace:secret@127.0.0.1:5433/mindspace_userdata_prod';
|
||||
assert.equal(resolveSandboxMcpUserDataPgUrl({ portalUrl }), portalUrl);
|
||||
@@ -346,6 +393,10 @@ test('static_publish with sandboxMcp uses stdio sandbox-fs extension instead of
|
||||
sandboxRoot: '/opt/h5/MindSpace/abc123',
|
||||
agentApiBaseUrl: 'http://host.docker.internal:8081/api',
|
||||
internalAgentSecret: 'internal-secret',
|
||||
publicBaseUrl: 'http://127.0.0.1:18131',
|
||||
portalBaseUrl: 'http://127.0.0.1:18131',
|
||||
portalPort: '18131',
|
||||
pageDataDeliveryBaseUrl: 'http://127.0.0.1:18131',
|
||||
};
|
||||
const policy = buildAgentExtensionPolicy(caps, { sandboxMcp });
|
||||
|
||||
@@ -357,6 +408,13 @@ test('static_publish with sandboxMcp uses stdio sandbox-fs extension instead of
|
||||
assert.equal(sandboxExt.args[1], '/opt/h5/MindSpace/abc123'); // also passed as argv[2]
|
||||
assert.equal(sandboxExt.envs.MINDSPACE_AGENT_API_BASE_URL, 'http://host.docker.internal:8081/api');
|
||||
assert.equal(sandboxExt.envs.MINDSPACE_INTERNAL_AGENT_SECRET, 'internal-secret');
|
||||
assert.equal(sandboxExt.envs.H5_PUBLIC_BASE_URL, 'http://127.0.0.1:18131');
|
||||
assert.equal(sandboxExt.envs.H5_PORTAL_BASE_URL, 'http://127.0.0.1:18131');
|
||||
assert.equal(sandboxExt.envs.H5_PORT, '18131');
|
||||
assert.equal(
|
||||
sandboxExt.envs.MEMIND_PAGE_DATA_DELIVERY_BASE_URL,
|
||||
'http://127.0.0.1:18131',
|
||||
);
|
||||
assert.ok(sandboxExt.available_tools.includes('write_file'));
|
||||
assert.ok(sandboxExt.available_tools.includes('read_file'));
|
||||
assert.ok(sandboxExt.available_tools.includes('generate_docx'));
|
||||
|
||||
Reference in New Issue
Block a user