@bevel-software/platform-core-frontend 0.10.0 → 0.11.1

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.
Files changed (36) hide show
  1. package/package.json +2 -2
  2. package/src/core/CoreAppShell.tsx +2 -0
  3. package/src/core/registry.ts +25 -0
  4. package/src/lib/email.ts +25 -0
  5. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +1 -1
  6. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +280 -4
  7. package/src/modules/access/api.ts +47 -13
  8. package/src/modules/access/components/ManageAccessDialog.tsx +119 -49
  9. package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +281 -0
  10. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +4 -4
  11. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +438 -0
  12. package/src/modules/admin/components/AdminRolesPage.tsx +203 -411
  13. package/src/modules/admin/components/DirectoryGroupsPage.tsx +610 -0
  14. package/src/modules/admin/hooks/useExclusiveRunner.ts +27 -0
  15. package/src/modules/admin/services/groups.api.ts +151 -0
  16. package/src/modules/admin/services/roles.api.ts +57 -31
  17. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +42 -3
  18. package/src/modules/library/__tests__/PluginPage.test.tsx +29 -0
  19. package/src/modules/library/__tests__/ToolPage.test.tsx +22 -0
  20. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +90 -0
  21. package/src/modules/library/components/LibraryPage.tsx +2 -2
  22. package/src/modules/library/components/PersonalPluginPage.tsx +2 -2
  23. package/src/modules/library/components/PluginPage.tsx +2 -2
  24. package/src/modules/library/components/tool-page/ToolPage.tsx +7 -1
  25. package/src/modules/library/routes/LibraryRoutes.tsx +6 -4
  26. package/src/modules/library/routes/WorkspaceItemRoute.tsx +33 -5
  27. package/src/modules/library/routes/library-paths.ts +30 -0
  28. package/src/modules/onboarding/__tests__/onboarding.test.tsx +63 -17
  29. package/src/modules/onboarding/agent-clients.ts +21 -7
  30. package/src/modules/onboarding/components/WelcomePage.tsx +1 -1
  31. package/src/modules/settings/settings-nav-items.tsx +9 -1
  32. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +135 -20
  33. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +113 -14
  34. package/src/shared/mcp/__tests__/connect-snippets.test.ts +66 -0
  35. package/src/shared/mcp/connect-snippets.ts +76 -0
  36. package/src/shared/mcp/index.ts +3 -0
@@ -7,9 +7,14 @@ import { configureMcpUrl } from '../../../../shared/mcp';
7
7
 
8
8
  /**
9
9
  * The Connect page's contract, and the reason this file exists at all: every
10
- * address it hands out is the DEPLOYMENT's, never the browser's.
10
+ * HOSTED snippet quotes the DEPLOYMENT's address, never the browser's — and
11
+ * every LOCAL-server (hexis-mcp) snippet quotes the browser's origin, never
12
+ * the deployment's MCP endpoint. Two families, two addresses, on purpose:
13
+ * hexis-mcp takes the workspace base and resolves the endpoint from
14
+ * `GET /api/config` itself, and the one base the browser has proven serves
15
+ * the whole app is its own origin.
11
16
  *
12
- * Six sites on this page used to rebuild the endpoint from
17
+ * Six hosted sites on this page used to rebuild the endpoint from
13
18
  * `window.location.origin` — three keyless, three carrying a freshly minted
14
19
  * external API key. They agreed with the server's own idea of its address
15
20
  * only by luck, and a proxy or a second domain was enough to break it. The
@@ -73,8 +78,8 @@ async function revealAKey(user: ReturnType<typeof userEvent.setup>) {
73
78
  await screen.findByRole('heading', { name: /Save this external API key now/ });
74
79
  }
75
80
 
76
- describe('the interactive tab quotes the deployment, not the browser', () => {
77
- it('builds all three keyless snippets from the configured URL', () => {
81
+ describe('the interactive tab: local first, hosted second, each with its own address', () => {
82
+ it('builds all three hosted keyless snippets from the configured URL', () => {
78
83
  mount(PUBLIC_URL);
79
84
  const values = snippets();
80
85
 
@@ -84,19 +89,60 @@ describe('the interactive tab quotes the deployment, not the browser', () => {
84
89
  );
85
90
  // 2. the bare URL for claude.ai / Claude Desktop
86
91
  expect(values).toContain(PUBLIC_URL);
87
- // 3. the JSON config for everything else
88
- const json = values.find((v) => v.includes('mcpServers'));
92
+ // 3. the JSON config for everything else — the LOCAL section renders a
93
+ // `mcpServers` block too, so pick the hosted one by its server name.
94
+ const json = values.find((v) => v.includes('knowledge-base') && v.includes('mcpServers'));
89
95
  expect(JSON.parse(json!).mcpServers['knowledge-base'].url).toBe(PUBLIC_URL);
90
96
  });
91
97
 
92
98
  /**
93
- * The regression stated as a negative: the page's own origin must appear
94
- * nowhere, or one of the six sites quietly went back to deriving it.
99
+ * The RECOMMENDED path leads: the local-server drawer renders above the
100
+ * hosted one, and its two snippets are KEYLESS — interactive mode signs in
101
+ * through the browser on first run, so no key belongs in the config. Both
102
+ * quote the workspace ORIGIN, because hexis-mcp resolves the endpoint from
103
+ * `GET <base>/api/config` itself.
95
104
  */
96
- it('never falls back to the page origin', () => {
105
+ it('leads with the local server: keyless snippets built from the origin', () => {
106
+ mount(PUBLIC_URL);
107
+ // Two CLOSED drawers, desktop first. The summaries are the whole pitch;
108
+ // the configs sit inside and neither drawer arrives open.
109
+ const local = screen.getByText(
110
+ 'Desktop agents: Claude Code, Claude Desktop, Cursor, Windsurf, Cline and similar',
111
+ );
112
+ const hosted = screen.getByText('Any other agent');
113
+ // DOCUMENT_POSITION_FOLLOWING: the hosted drawer comes after the local one.
114
+ expect(local.compareDocumentPosition(hosted) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
115
+ for (const drawer of [local, hosted]) {
116
+ expect((drawer.closest('details') as HTMLDetailsElement).open).toBe(false);
117
+ }
118
+
119
+ const values = snippets();
120
+ expect(values).toContain(
121
+ `claude mcp add hexis-local --env HEXIS_URL="${window.location.origin}" -- npx -y @bevel-software/hexis-mcp`,
122
+ );
123
+ const json = values.find((v) => v.includes('mcpServers') && v.includes('hexis-local'));
124
+ const parsed = JSON.parse(json!).mcpServers['hexis-local'];
125
+ expect(parsed.args).toEqual(['-y', '@bevel-software/hexis-mcp']);
126
+ expect(parsed.env.HEXIS_URL).toBe(window.location.origin);
127
+ // Keyless = interactive: the browser-sign-in mode carries no key env.
128
+ expect(parsed.env.HEXIS_CONNECTION_KEY).toBeUndefined();
129
+ });
130
+
131
+ /**
132
+ * The regression stated as a negative, per family: a hosted snippet
133
+ * quoting the origin means one of the six sites quietly went back to
134
+ * deriving it, and a local snippet quoting the configured endpoint would
135
+ * hand hexis-mcp a base that may serve only the MCP path.
136
+ */
137
+ it('keeps each family on its own address', () => {
97
138
  mount(PUBLIC_URL);
98
139
  for (const value of snippets()) {
99
- expect(value).not.toContain(window.location.origin);
140
+ if (value.includes('hexis')) {
141
+ expect(value).toContain(window.location.origin);
142
+ expect(value).not.toContain(PUBLIC_URL);
143
+ } else {
144
+ expect(value).not.toContain(window.location.origin);
145
+ }
100
146
  }
101
147
  });
102
148
 
@@ -143,8 +189,40 @@ describe('the key-bearing snippets quote the deployment too', () => {
143
189
  });
144
190
 
145
191
  /**
146
- * The consolidation's real risk: three snippets that must carry a secret
147
- * and three that must not. Losing the token during the move would look
192
+ * The modal leads with the local server too — the recommended block comes
193
+ * first, with the REAL key in both snippets (unlike the interactive tab's
194
+ * placeholder). And it is the one place the page's own origin is right:
195
+ * hexis-mcp takes the workspace's address — the one the browser provably
196
+ * loaded this app from — and resolves the MCP endpoint from it itself,
197
+ * so the configured `mcpUrl` (possibly a proxy serving only the MCP path)
198
+ * must appear in neither snippet.
199
+ */
200
+ it('leads with the local server, handing it the origin and the minted key', async () => {
201
+ const user = userEvent.setup();
202
+ mount(PUBLIC_URL);
203
+ await revealAKey(user);
204
+ const local = screen.getByText('Desktop agents — the local server (recommended)');
205
+ const hosted = screen.getByText('Web agents and pipelines — the hosted endpoint');
206
+ // DOCUMENT_POSITION_FOLLOWING: the hosted block comes after the local one.
207
+ expect(local.compareDocumentPosition(hosted) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
208
+ const values = snippets();
209
+
210
+ // 7. the Claude Code stdio one-liner
211
+ expect(values).toContain(
212
+ `claude mcp add hexis-local --env HEXIS_URL="${window.location.origin}" --env HEXIS_CONNECTION_KEY="${KEY}" -- npx -y @bevel-software/hexis-mcp`,
213
+ );
214
+ // 8. the JSON config that spawns the package
215
+ const json = values.find((v) => v.includes('mcpServers') && v.includes('hexis-local'));
216
+ const parsed = JSON.parse(json!).mcpServers['hexis-local'];
217
+ expect(parsed.args).toEqual(['-y', '@bevel-software/hexis-mcp']);
218
+ expect(parsed.env.HEXIS_URL).toBe(window.location.origin);
219
+ expect(parsed.env.HEXIS_CONNECTION_KEY).toBe(KEY);
220
+ expect(json).not.toContain(PUBLIC_URL);
221
+ });
222
+
223
+ /**
224
+ * The consolidation's real risk: snippets that must carry a secret
225
+ * and snippets that must not. Losing the token during the move would look
148
226
  * like working code and fail at connect time.
149
227
  */
150
228
  it('keeps the key in the keyed snippets and out of the keyless ones', async () => {
@@ -153,8 +231,9 @@ describe('the key-bearing snippets quote the deployment too', () => {
153
231
  expect(snippets().some((v) => v.includes(KEY))).toBe(false);
154
232
  await revealAKey(user);
155
233
  expect(snippets().filter((v) => v.includes(KEY))).toHaveLength(
156
- // the reveal textarea itself, plus the three keyed snippets
157
- 4,
234
+ // the reveal textarea itself, the three keyed hosted snippets, and the
235
+ // two local-server (hexis-mcp) snippets
236
+ 6,
158
237
  );
159
238
  });
160
239
  });
@@ -217,6 +296,26 @@ describe('tabs', () => {
217
296
  expect(tabs[1]).toHaveAttribute('aria-selected', 'false');
218
297
  });
219
298
 
299
+ /**
300
+ * The local server authenticates by key alone, and the key is minted on
301
+ * the other tab — so the recommended section names why a tool
302
+ * `list_local_tools` lists is worth the trip, and its inline button walks
303
+ * someone straight there.
304
+ */
305
+ it('points local-server users at the autonomous tab, and the button goes there', async () => {
306
+ const user = userEvent.setup();
307
+ mount(PUBLIC_URL);
308
+ expect(screen.getByText(/local-only tools/)).toBeInTheDocument();
309
+ expect(screen.getByText('list_local_tools')).toBeInTheDocument();
310
+ // The local section's button and the CI footnote's point at the same
311
+ // tab; the local section comes first.
312
+ await user.click(screen.getAllByRole('button', { name: 'Autonomous agents' })[0]!);
313
+ expect(screen.getByRole('tab', { name: 'Autonomous agents' })).toHaveAttribute(
314
+ 'aria-selected',
315
+ 'true',
316
+ );
317
+ });
318
+
220
319
  // The install link belongs to the interactive tab only — the autonomous
221
320
  // tab is for agents that cannot open a browser at all.
222
321
  it('does not offer one-click connect on the autonomous tab', async () => {
@@ -5,10 +5,13 @@ import {
5
5
  claudeInstallUrl,
6
6
  configureMcpUrl,
7
7
  connectorName,
8
+ hexisMcpClaudeCommand,
9
+ hexisMcpJsonSnippet,
8
10
  jsonConfigSnippet,
9
11
  langdockSnippet,
10
12
  mcpEndpointUrl,
11
13
  resetMcpUrlForTests,
14
+ workspaceBaseUrl,
12
15
  } from '../connect-snippets';
13
16
 
14
17
  /**
@@ -410,6 +413,69 @@ describe('snippets: one builder per client, keyed or not', () => {
410
413
  );
411
414
  });
412
415
 
416
+ /**
417
+ * The LOCAL server's builders. These take the WORKSPACE base, not the MCP
418
+ * endpoint — hexis-mcp resolves the endpoint from `GET <base>/api/config`
419
+ * itself — so unlike everything above they are handed `workspaceBaseUrl()`
420
+ * by their callers.
421
+ */
422
+ describe('the local server (hexis-mcp)', () => {
423
+ const BASE = 'https://kb.acme.com';
424
+
425
+ // The one address the browser has proven serves this app, config
426
+ // endpoint included, is the one it loaded the app from.
427
+ it('workspaceBaseUrl is the page origin', () => {
428
+ expect(workspaceBaseUrl()).toBe(window.location.origin);
429
+ });
430
+
431
+ it('builds a JSON config that spawns the package with the key', () => {
432
+ const parsed = JSON.parse(hexisMcpJsonSnippet(BASE, KEY));
433
+ expect(parsed.mcpServers['hexis-local']).toEqual({
434
+ command: 'npx',
435
+ args: ['-y', '@bevel-software/hexis-mcp'],
436
+ env: {
437
+ HEXIS_URL: BASE,
438
+ HEXIS_CONNECTION_KEY: KEY,
439
+ },
440
+ });
441
+ });
442
+
443
+ /**
444
+ * Keyless is the interactive mode: the server opens the person's browser
445
+ * to sign in on first run, so no key belongs in the config — the env must
446
+ * carry the URL alone. An empty or placeholder HEXIS_CONNECTION_KEY would
447
+ * be read as key mode and fail at connect time.
448
+ */
449
+ it('omits the key env entirely when no key was minted — keyless selects browser sign-in', () => {
450
+ const parsed = JSON.parse(hexisMcpJsonSnippet(BASE));
451
+ expect(parsed.mcpServers['hexis-local'].env).toEqual({
452
+ HEXIS_URL: BASE,
453
+ });
454
+ expect(hexisMcpJsonSnippet(BASE)).not.toContain(KEY);
455
+ });
456
+
457
+ it('builds the Claude Code command as a stdio add with both env values', () => {
458
+ expect(hexisMcpClaudeCommand(BASE, KEY)).toBe(
459
+ `claude mcp add hexis-local --env HEXIS_URL="${BASE}" --env HEXIS_CONNECTION_KEY="${KEY}" -- npx -y @bevel-software/hexis-mcp`,
460
+ );
461
+ });
462
+
463
+ /**
464
+ * The env values sit inside double quotes on a POSIX shell, where `"`,
465
+ * `$`, backtick and backslash are still read. A key carrying one of them
466
+ * must not cut the pasted command short or expand into it — same rule as
467
+ * the header in `claudeCodeCommand`, applied to both values.
468
+ */
469
+ it('escapes shell metacharacters in the key and the URL', () => {
470
+ expect(hexisMcpClaudeCommand(BASE, 'a"b$c`d\\e')).toContain(
471
+ '--env HEXIS_CONNECTION_KEY="a\\"b\\$c\\`d\\\\e"',
472
+ );
473
+ expect(hexisMcpClaudeCommand('https://kb.acme.com/?a=$b', KEY)).toContain(
474
+ '--env HEXIS_URL="https://kb.acme.com/?a=\\$b"',
475
+ );
476
+ });
477
+ });
478
+
413
479
  /**
414
480
  * The regression that the six-site consolidation could have introduced:
415
481
  * every snippet quotes the endpoint it was handed, and none of them
@@ -351,3 +351,79 @@ export function jsonConfigSnippet(mcpUrl: string, bearer?: string): string {
351
351
  export function langdockSnippet(mcpUrl: string, bearer: string): string {
352
352
  return `URL: ${mcpUrl}\nHeader name: Authorization\nHeader value: Bearer ${bearer}`;
353
353
  }
354
+
355
+ /* ------------------------------------------------------------------ *
356
+ * The LOCAL server (`npx @bevel-software/hexis-mcp`): the same workspace
357
+ * as a stdio server on the member's own machine, which is the only place
358
+ * a plugin's local-only tools — stdio servers, localhost services — can
359
+ * run. It serves everything the hosted endpoint serves plus those. It
360
+ * authenticates either interactively — keyless, opening the person's own
361
+ * browser to sign in on first run — or autonomously with a connection
362
+ * key, for pipelines with nobody present to sign in.
363
+ * ------------------------------------------------------------------ */
364
+
365
+ /**
366
+ * The base URL to hand the local server — deliberately NOT `mcpEndpointUrl`.
367
+ *
368
+ * `hexis-mcp` takes the WORKSPACE's address, not the MCP endpoint: it asks
369
+ * `GET <base>/api/config` for the real endpoint itself, the same field
370
+ * `configureMcpUrl` records up top. So what it needs is a base the config
371
+ * endpoint answers on — and the one address the browser has PROVEN serves
372
+ * this whole app, config endpoint included, is its own origin, because it
373
+ * loaded this page from it. The configured `mcpUrl` proves less: it may sit
374
+ * on a proxy domain that forwards only the MCP path.
375
+ */
376
+ export function workspaceBaseUrl(): string {
377
+ return window.location.origin;
378
+ }
379
+
380
+ /**
381
+ * The JSON block that runs the workspace as a LOCAL MCP server. Read by the
382
+ * same clients as `jsonConfigSnippet` — Claude Desktop, Cursor, Windsurf,
383
+ * Cline, anything that loads servers from a JSON config — but the entry
384
+ * spawns `npx @bevel-software/hexis-mcp` instead of pointing at the hosted
385
+ * endpoint, so the command needs Node on the machine.
386
+ *
387
+ * Without a bearer there is NO key field at all: keyless is the interactive
388
+ * mode, where the server opens the person's browser to sign in on first run
389
+ * (the same OAuth flow the hosted endpoint puts web agents through). The
390
+ * bearer variant exists for the key-reveal modal, whose reader is setting up
391
+ * an autonomous pipeline that cannot open a browser.
392
+ */
393
+ export function hexisMcpJsonSnippet(baseUrl: string, bearer?: string): string {
394
+ return JSON.stringify(
395
+ {
396
+ mcpServers: {
397
+ 'hexis-local': {
398
+ command: 'npx',
399
+ args: ['-y', '@bevel-software/hexis-mcp'],
400
+ env: {
401
+ HEXIS_URL: baseUrl,
402
+ ...(bearer ? { HEXIS_CONNECTION_KEY: bearer } : {}),
403
+ },
404
+ },
405
+ },
406
+ },
407
+ null,
408
+ 2,
409
+ );
410
+ }
411
+
412
+ /**
413
+ * The `claude mcp add` one-liner for the local server. A stdio command, not
414
+ * a URL, so the address (and the key, when the autonomous variant carries
415
+ * one) travel as `--env` values — interpolated inside double quotes and
416
+ * escaped, exactly as the header is in `claudeCodeCommand`. Today's values
417
+ * are tame (a tenant-prefixed key, an https URL), but a URL can legally
418
+ * carry `$` or backtick, and quoting only the value that looks dangerous is
419
+ * how the other one bites later. Keyless = interactive sign-in, same as
420
+ * {@link hexisMcpJsonSnippet}.
421
+ */
422
+ export function hexisMcpClaudeCommand(baseUrl: string, bearer?: string): string {
423
+ return (
424
+ `claude mcp add hexis-local` +
425
+ ` --env HEXIS_URL="${escapeForDoubleQuotes(baseUrl)}"` +
426
+ (bearer ? ` --env HEXIS_CONNECTION_KEY="${escapeForDoubleQuotes(bearer)}"` : '') +
427
+ ` -- npx -y @bevel-software/hexis-mcp`
428
+ );
429
+ }
@@ -17,9 +17,12 @@ export {
17
17
  claudeInstallUrl,
18
18
  configureMcpUrl,
19
19
  connectorName,
20
+ hexisMcpClaudeCommand,
21
+ hexisMcpJsonSnippet,
20
22
  jsonConfigSnippet,
21
23
  langdockSnippet,
22
24
  mcpEndpointUrl,
25
+ workspaceBaseUrl,
23
26
  } from './connect-snippets';
24
27
 
25
28
  export { ClaudeInstallLink } from './ClaudeInstallLink';