@shellui/core 0.8.2 → 0.8.3
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/README.md +1 -1
- package/package.json +2 -2
- package/schemas/shellui.config.schema.json +4 -0
- package/src/features/config/types.ts +10 -0
- package/src/features/mcp/mcpAgentsConnect.spec.ts +62 -0
- package/src/features/mcp/mcpAgentsConnect.ts +49 -0
- package/src/features/settings/components/McpAgents.spec.tsx +31 -2
- package/src/features/settings/components/McpAgents.tsx +11 -3
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ React runtime for Shellui, the open-source app shell: navigation, layouts, light
|
|
|
6
6
|
npm install @shellui/core
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Shellui **0.8.
|
|
9
|
+
Shellui **0.8.3** is the current stable release: `npm install @shellui/core@0.8.3`.
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
import type { ShellUIConfig } from '@shellui/core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shellui/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "React runtime for Shellui, the open-source app shell. Renders navigation, layouts, themes with light and dark modes, sign-in and identity, and hosts your apps as micro frontends in one interface. MIT licensed.",
|
|
5
5
|
"homepage": "https://shellui.com",
|
|
6
6
|
"repository": {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"workbox-routing": "^7.4.1",
|
|
91
91
|
"workbox-strategies": "^7.4.1",
|
|
92
92
|
"workbox-window": "^7.4.1",
|
|
93
|
-
"@shellui/sdk": "0.8.
|
|
93
|
+
"@shellui/sdk": "0.8.3"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
96
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -407,6 +407,10 @@
|
|
|
407
407
|
"type": "string",
|
|
408
408
|
"description": "Base URL of ai-service. Required for apps to get AI. There is no built-in default. Local: `http://localhost:8006`."
|
|
409
409
|
},
|
|
410
|
+
"mcpUrl": {
|
|
411
|
+
"type": "string",
|
|
412
|
+
"description": "Full Shellui account MCP URL. Path must be exactly `/mcp`. When set, Settings shows this URL for MCP / AI agents, even if `backend.companyId` is also set. Use it for the global MCP (saas tools), for example `https://ai.example/mcp`. Omit it in a regional project so Settings can use `{url}/c/{companyId}/mcp`."
|
|
413
|
+
},
|
|
410
414
|
"showInAdmin": {
|
|
411
415
|
"type": "boolean",
|
|
412
416
|
"description": "When false, hide Admin → AI. Default: true (shown) when `aiService` is set."
|
|
@@ -392,6 +392,16 @@ export interface AiServiceConfig {
|
|
|
392
392
|
* Local: `http://localhost:8006`.
|
|
393
393
|
*/
|
|
394
394
|
url?: string;
|
|
395
|
+
/**
|
|
396
|
+
* Full Shellui account MCP URL (path must be exactly `/mcp`).
|
|
397
|
+
* When set, Settings shows this URL for MCP / AI agents, even if
|
|
398
|
+
* `backend.companyId` is also set (as on the dashboard).
|
|
399
|
+
* Use this for the global MCP (saas tools), for example
|
|
400
|
+
* `https://ai.example/mcp` or `http://localhost:8008/mcp`.
|
|
401
|
+
* Omit it in a regional project so Settings can use
|
|
402
|
+
* `{url}/c/{companyId}/mcp`.
|
|
403
|
+
*/
|
|
404
|
+
mcpUrl?: string;
|
|
395
405
|
/**
|
|
396
406
|
* When false, hide Admin → AI.
|
|
397
407
|
* Default: true (shown) when `aiService` is set.
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
agentPromptContainsCredentialMaterial,
|
|
9
9
|
buildAgentPrompt,
|
|
10
10
|
buildCompanyMcpUrl,
|
|
11
|
+
buildGlobalMcpUrl,
|
|
12
|
+
resolveSettingsMcpUrl,
|
|
11
13
|
defaultPersonalAgentExpiresAt,
|
|
12
14
|
formatDefaultAgentName,
|
|
13
15
|
getDefaultPersonalAgentServices,
|
|
@@ -32,6 +34,66 @@ describe('buildCompanyMcpUrl', () => {
|
|
|
32
34
|
});
|
|
33
35
|
});
|
|
34
36
|
|
|
37
|
+
describe('buildGlobalMcpUrl', () => {
|
|
38
|
+
it('uses a configured /mcp URL and ignores a trailing slash on the ai host', () => {
|
|
39
|
+
expect(buildGlobalMcpUrl('https://ai.example/', 'https://global.example/mcp')).toBe(
|
|
40
|
+
'https://global.example/mcp',
|
|
41
|
+
);
|
|
42
|
+
expect(buildGlobalMcpUrl('https://ai.example/')).toBe('https://ai.example/mcp');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('ignores a configured URL that is not an absolute /mcp endpoint', () => {
|
|
46
|
+
expect(buildGlobalMcpUrl('https://ai.example', 'https://global.example/c/1/mcp')).toBe(
|
|
47
|
+
'https://ai.example/mcp',
|
|
48
|
+
);
|
|
49
|
+
expect(buildGlobalMcpUrl(null, 'not-a-url')).toBe(null);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('resolveSettingsMcpUrl', () => {
|
|
54
|
+
it('uses the configured global MCP URL even when a company id is set', () => {
|
|
55
|
+
expect(
|
|
56
|
+
resolveSettingsMcpUrl({
|
|
57
|
+
aiServiceUrl: 'https://ai.example',
|
|
58
|
+
companyId: '1',
|
|
59
|
+
configuredGlobalMcpUrl: 'https://global.example/mcp',
|
|
60
|
+
statusMcpUrl: 'https://ai.example/c/1/mcp',
|
|
61
|
+
}),
|
|
62
|
+
).toBe('https://global.example/mcp');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('uses the regional company URL when no global MCP URL is configured', () => {
|
|
66
|
+
expect(
|
|
67
|
+
resolveSettingsMcpUrl({
|
|
68
|
+
aiServiceUrl: 'https://ai.example/',
|
|
69
|
+
companyId: '42',
|
|
70
|
+
statusMcpUrl: 'https://unused.example/c/42/mcp',
|
|
71
|
+
}),
|
|
72
|
+
).toBe('https://ai.example/c/42/mcp');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('falls back to {ai}/mcp when there is no company id', () => {
|
|
76
|
+
expect(
|
|
77
|
+
resolveSettingsMcpUrl({
|
|
78
|
+
aiServiceUrl: 'https://ai.example/',
|
|
79
|
+
companyId: '',
|
|
80
|
+
statusGlobalMcpUrl: 'https://status.example/mcp',
|
|
81
|
+
}),
|
|
82
|
+
).toBe('https://ai.example/mcp');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('falls back to status global MCP URL when a configured URL is invalid', () => {
|
|
86
|
+
expect(
|
|
87
|
+
resolveSettingsMcpUrl({
|
|
88
|
+
aiServiceUrl: null,
|
|
89
|
+
companyId: '1',
|
|
90
|
+
configuredGlobalMcpUrl: 'https://ai.example/c/1/mcp',
|
|
91
|
+
statusGlobalMcpUrl: 'https://status.example/mcp',
|
|
92
|
+
}),
|
|
93
|
+
).toBe('https://status.example/mcp');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
35
97
|
describe('isGlobalIdentitySession', () => {
|
|
36
98
|
it('reads globalIdentity from status when present', () => {
|
|
37
99
|
expect(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MCP_PERSONAL_SERVICE_OPTIONS,
|
|
3
|
+
parseValidatedGlobalMcpEndpointUrl,
|
|
3
4
|
type McpAgentSummary,
|
|
4
5
|
type McpPersonalService,
|
|
5
6
|
type McpPersonalStatus,
|
|
@@ -24,6 +25,54 @@ export function buildCompanyMcpUrl(
|
|
|
24
25
|
return fallback || null;
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
/** `{aiServiceUrl}/mcp`, or a configured absolute `/mcp` URL. */
|
|
29
|
+
export function buildGlobalMcpUrl(
|
|
30
|
+
aiServiceUrl: string | null | undefined,
|
|
31
|
+
configuredMcpUrl?: string | null,
|
|
32
|
+
): string | null {
|
|
33
|
+
const configured = parseValidatedGlobalMcpEndpointUrl(configuredMcpUrl);
|
|
34
|
+
if (configured) return configured;
|
|
35
|
+
const base = aiServiceUrl?.trim().replace(/\/+$/, '') || '';
|
|
36
|
+
if (!base) return null;
|
|
37
|
+
return parseValidatedGlobalMcpEndpointUrl(`${base}/mcp`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type ResolveSettingsMcpUrlInput = {
|
|
41
|
+
aiServiceUrl: string | null | undefined;
|
|
42
|
+
companyId: string;
|
|
43
|
+
/**
|
|
44
|
+
* Full account MCP URL from `aiService.mcpUrl`.
|
|
45
|
+
* When set, Settings uses the global MCP even if `companyId` is present.
|
|
46
|
+
*/
|
|
47
|
+
configuredGlobalMcpUrl?: string | null;
|
|
48
|
+
statusMcpUrl?: string | null;
|
|
49
|
+
statusGlobalMcpUrl?: string | null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* MCP URL shown in Settings.
|
|
54
|
+
* A configured `aiService.mcpUrl` selects the global account MCP
|
|
55
|
+
* (`https://host/mcp`), for dashboard and other global shells.
|
|
56
|
+
* Otherwise a company id selects the regional `{ai}/c/{id}/mcp` URL.
|
|
57
|
+
*/
|
|
58
|
+
export function resolveSettingsMcpUrl(input: ResolveSettingsMcpUrlInput): string | null {
|
|
59
|
+
const hasConfiguredGlobal = Boolean(input.configuredGlobalMcpUrl?.trim());
|
|
60
|
+
if (hasConfiguredGlobal) {
|
|
61
|
+
return (
|
|
62
|
+
buildGlobalMcpUrl(input.aiServiceUrl, input.configuredGlobalMcpUrl) ??
|
|
63
|
+
parseValidatedGlobalMcpEndpointUrl(input.statusGlobalMcpUrl)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
const companyId = input.companyId.trim();
|
|
67
|
+
if (companyId) {
|
|
68
|
+
return buildCompanyMcpUrl(input.aiServiceUrl, companyId, input.statusMcpUrl);
|
|
69
|
+
}
|
|
70
|
+
return (
|
|
71
|
+
buildGlobalMcpUrl(input.aiServiceUrl) ??
|
|
72
|
+
parseValidatedGlobalMcpEndpointUrl(input.statusGlobalMcpUrl)
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
27
76
|
export function isAbsoluteHttpUrl(value: string | null | undefined): boolean {
|
|
28
77
|
if (!value?.trim()) return false;
|
|
29
78
|
try {
|
|
@@ -15,6 +15,8 @@ import { McpAgents } from './McpAgents';
|
|
|
15
15
|
const page = vi.hoisted(() => ({
|
|
16
16
|
language: 'en',
|
|
17
17
|
aiUrl: 'https://ai.example/' as string | null,
|
|
18
|
+
mcpUrl: null as string | null,
|
|
19
|
+
companyId: '42',
|
|
18
20
|
visibility: 'visible',
|
|
19
21
|
}));
|
|
20
22
|
|
|
@@ -42,8 +44,15 @@ vi.mock('../../config/useConfig', () => ({
|
|
|
42
44
|
useConfig: () => ({
|
|
43
45
|
config: {
|
|
44
46
|
title: 'Acme',
|
|
45
|
-
backend: { type: 'shellui', url: 'https://id.example', companyId:
|
|
46
|
-
...(page.aiUrl
|
|
47
|
+
backend: { type: 'shellui', url: 'https://id.example', companyId: page.companyId },
|
|
48
|
+
...(page.aiUrl
|
|
49
|
+
? {
|
|
50
|
+
aiService: {
|
|
51
|
+
url: page.aiUrl,
|
|
52
|
+
...(page.mcpUrl ? { mcpUrl: page.mcpUrl } : {}),
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
: {}),
|
|
47
56
|
},
|
|
48
57
|
}),
|
|
49
58
|
}));
|
|
@@ -145,6 +154,8 @@ let root: Root;
|
|
|
145
154
|
beforeEach(() => {
|
|
146
155
|
page.language = 'en';
|
|
147
156
|
page.aiUrl = 'https://ai.example/';
|
|
157
|
+
page.mcpUrl = null;
|
|
158
|
+
page.companyId = '42';
|
|
148
159
|
page.visibility = 'visible';
|
|
149
160
|
Object.defineProperty(document, 'visibilityState', {
|
|
150
161
|
configurable: true,
|
|
@@ -243,6 +254,24 @@ describe('McpAgents connect prompt', () => {
|
|
|
243
254
|
expect(container.querySelector('pre')).toBeNull();
|
|
244
255
|
expect(buttonByText('Copy prompt')).toBeUndefined();
|
|
245
256
|
});
|
|
257
|
+
|
|
258
|
+
it('shows the global account MCP URL when aiService.mcpUrl is set, even with a company id', async () => {
|
|
259
|
+
const globalUrl = 'https://global.example/mcp';
|
|
260
|
+
page.companyId = '1';
|
|
261
|
+
page.mcpUrl = globalUrl;
|
|
262
|
+
await renderPage();
|
|
263
|
+
|
|
264
|
+
expect(container.textContent).toContain(globalUrl);
|
|
265
|
+
expect(container.textContent).not.toContain('https://ai.example/c/1/mcp');
|
|
266
|
+
const prompt = container.querySelector('pre')?.textContent ?? '';
|
|
267
|
+
expect(prompt).toBe(buildAgentPrompt(globalUrl, 'en'));
|
|
268
|
+
|
|
269
|
+
await act(async () => {
|
|
270
|
+
buttonByText('Copy URL')?.click();
|
|
271
|
+
await Promise.resolve();
|
|
272
|
+
});
|
|
273
|
+
expect(writeText).toHaveBeenCalledWith(globalUrl);
|
|
274
|
+
});
|
|
246
275
|
});
|
|
247
276
|
|
|
248
277
|
describe('McpAgents static secret', () => {
|
|
@@ -7,7 +7,7 @@ import { useAuth } from '../../auth/hooks/useAuth';
|
|
|
7
7
|
import {
|
|
8
8
|
agentIncludesSaasScope,
|
|
9
9
|
buildAgentPrompt,
|
|
10
|
-
|
|
10
|
+
resolveSettingsMcpUrl,
|
|
11
11
|
MCP_PERSONAL_AGENT_MAX_LIFETIME_DAYS,
|
|
12
12
|
defaultPersonalAgentExpiresAt,
|
|
13
13
|
formatAgentExpiry,
|
|
@@ -76,9 +76,17 @@ export const McpAgents = () => {
|
|
|
76
76
|
return u || null;
|
|
77
77
|
}, [status?.globalMcpUrl]);
|
|
78
78
|
|
|
79
|
+
const configuredGlobalMcpUrl = config?.aiService?.mcpUrl ?? null;
|
|
79
80
|
const companyMcpUrl = useMemo(
|
|
80
|
-
() =>
|
|
81
|
-
|
|
81
|
+
() =>
|
|
82
|
+
resolveSettingsMcpUrl({
|
|
83
|
+
aiServiceUrl,
|
|
84
|
+
companyId,
|
|
85
|
+
configuredGlobalMcpUrl,
|
|
86
|
+
statusMcpUrl: status?.mcpUrl,
|
|
87
|
+
statusGlobalMcpUrl: status?.globalMcpUrl,
|
|
88
|
+
}),
|
|
89
|
+
[aiServiceUrl, companyId, configuredGlobalMcpUrl, status?.globalMcpUrl, status?.mcpUrl],
|
|
82
90
|
);
|
|
83
91
|
const absoluteMcpUrl = useMemo(
|
|
84
92
|
() => (companyMcpUrl && isAbsoluteHttpUrl(companyMcpUrl) ? companyMcpUrl : null),
|