@bevel-software/platform-core-frontend 0.32.0 → 0.34.0
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/package.json +2 -2
- package/src/core/CoreAppShell.tsx +1 -1
- package/src/lib/__tests__/api.test.ts +28 -1
- package/src/lib/api.ts +4 -2
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +53 -1
- package/src/modules/access/api.ts +4 -5
- package/src/modules/access/components/ManageAccessDialog.tsx +11 -12
- package/src/modules/access/hooks/useAccessRequests.ts +1 -1
- package/src/modules/access/hooks/useFileAccess.ts +1 -1
- package/src/modules/access/index.ts +11 -0
- package/src/modules/access/requests.api.ts +1 -1
- package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +51 -0
- package/src/modules/admin/components/AddMemberInput.tsx +1 -1
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +42 -5
- package/src/modules/admin/components/UserAccountsPage.tsx +3 -3
- package/src/modules/admin/index.ts +7 -0
- package/src/modules/admin/services/groups.api.ts +11 -1
- package/src/modules/admin/state/admin.context.tsx +1 -1
- package/src/modules/agents/__tests__/useConnectAsChoice.test.ts +56 -0
- package/src/modules/agents/components/ConnectAsChoice.tsx +81 -0
- package/src/modules/agents/connect-as.ts +15 -0
- package/src/modules/agents/index.ts +5 -0
- package/src/modules/agents/services/agent-choices.api.ts +39 -0
- package/src/modules/agents/useConnectAsChoice.ts +66 -0
- package/src/modules/audit/__tests__/AuditLogPage.test.tsx +13 -0
- package/src/modules/audit/components/AuditEventsPanel.tsx +1 -1
- package/src/modules/audit/components/AuditLogPage.tsx +11 -2
- package/src/modules/audit/services/audit.api.ts +5 -0
- package/src/modules/auth/__tests__/AccountPage.test.tsx +21 -0
- package/src/modules/auth/__tests__/account.api.test.ts +69 -0
- package/src/modules/auth/components/AccountPage.tsx +8 -2
- package/src/modules/auth/index.ts +12 -0
- package/src/modules/auth/services/account.api.ts +18 -2
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.edit.test.tsx +166 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +0 -2
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +0 -1
- package/src/modules/change-requests/components/BranchFilePreview.tsx +4 -12
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +138 -30
- package/src/modules/change-requests/components/ChangeRequestLink.tsx +2 -3
- package/src/modules/change-requests/components/CrFileTree.tsx +1 -1
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +2 -3
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +3 -5
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +1 -1
- package/src/modules/change-requests/index.ts +14 -0
- package/src/modules/change-requests/services/change-requests.api.ts +2 -2
- package/src/modules/change-requests/services/denied-file.api.ts +2 -2
- package/src/modules/change-requests/services/propose.api.ts +3 -4
- package/src/modules/change-requests/utils/diff.ts +1 -1
- package/src/modules/change-requests/utils/readFailure.ts +1 -1
- package/src/modules/embed/__tests__/EmbedView.test.tsx +19 -2
- package/src/modules/embed/components/EmbedLinkPage.tsx +1 -2
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +0 -14
- package/src/modules/git/__tests__/git.api.test.ts +2 -2
- package/src/modules/git/components/BranchSwitcher.tsx +3 -4
- package/src/modules/git/components/FileHistoryPanel.tsx +2 -2
- package/src/modules/git/components/GitSyncFailedBanner.tsx +2 -4
- package/src/modules/git/components/HistoryVersionPreview.tsx +4 -15
- package/src/modules/git/components/PullNeededBanner.tsx +1 -1
- package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +1 -1
- package/src/modules/git/hooks/useAutoPullUpdates.ts +1 -1
- package/src/modules/git/index.ts +11 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +1 -1
- package/src/modules/layout/index.ts +9 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +268 -24
- package/src/modules/library/__tests__/propose-change.test.ts +75 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +1 -1
- package/src/modules/library/components/ChangeRequestDock.tsx +1 -1
- package/src/modules/library/components/LibraryLayout.tsx +2 -2
- package/src/modules/library/components/LibraryPage.tsx +3 -3
- package/src/modules/library/components/ManagedPluginRequests.tsx +1 -1
- package/src/modules/library/components/NewSkillPanel.tsx +2 -2
- package/src/modules/library/components/PersonalAddDialog.tsx +1 -1
- package/src/modules/library/components/PersonalPluginPage.tsx +1 -1
- package/src/modules/library/components/PluginExtras.tsx +1 -4
- package/src/modules/library/components/PluginPage.tsx +1 -1
- package/src/modules/library/components/PluginRows.tsx +1 -1
- package/src/modules/library/components/SkillsTree.tsx +1 -4
- package/src/modules/library/components/plugin-page-parts.tsx +1 -1
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +74 -14
- package/src/modules/library/components/skill-page/SkillPage.tsx +80 -47
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +2 -4
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +2 -2
- package/src/modules/library/hooks/useJoinRequests.ts +1 -1
- package/src/modules/library/hooks/useLibraryData.ts +3 -3
- package/src/modules/library/hooks/useToolPage.ts +1 -1
- package/src/modules/library/hooks/useToolSource.ts +1 -1
- package/src/modules/library/index.ts +12 -0
- package/src/modules/library/routes/LibraryRoutes.tsx +1 -1
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +1 -3
- package/src/modules/library/routes/library-paths.ts +1 -1
- package/src/modules/library/services/library.api.ts +10 -8
- package/src/modules/library/services/plugins.api.ts +1 -1
- package/src/modules/library/services/teams.api.ts +1 -1
- package/src/modules/library/utils/status.ts +2 -2
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +1 -1
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +2 -3
- package/src/modules/onboarding/components/GetStartedColumn.tsx +6 -13
- package/src/modules/onboarding/components/InviteButton.tsx +2 -2
- package/src/modules/onboarding/components/InviteDialog.tsx +4 -6
- package/src/modules/onboarding/components/RootLanding.tsx +2 -2
- package/src/modules/onboarding/components/StarterPackCard.tsx +1 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +2 -5
- package/src/modules/onboarding/index.ts +10 -0
- package/src/modules/onboarding/paths.ts +1 -1
- package/src/modules/onboarding/state/agent-connection.ts +2 -2
- package/src/modules/onboarding/state/onboarding.ts +1 -1
- package/src/modules/onboarding/state/starter-packs.ts +1 -1
- package/src/modules/pr/components/OpenChangeRequestDialog.tsx +1 -1
- package/src/modules/pr/index.ts +14 -0
- package/src/modules/pr/services/pr-approvals.api.ts +1 -1
- package/src/modules/pr/services/pr-cancel.api.ts +1 -1
- package/src/modules/pr/services/pr-detail.api.ts +2 -2
- package/src/modules/pr/services/pr-edit.api.ts +22 -0
- package/src/modules/pr/services/pr-merge.api.ts +1 -1
- package/src/modules/pr/services/pr-open.api.ts +1 -1
- package/src/modules/review/components/DiffViewer.tsx +1 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +24 -3
- package/src/modules/review/components/ReviewPanel.tsx +10 -5
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +31 -0
- package/src/modules/review/state/ReviewProvider.tsx +2 -2
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +79 -16
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +112 -2
- package/src/modules/secrets-vault/index.ts +6 -0
- package/src/modules/secrets-vault/services/connect.api.ts +20 -5
- package/src/modules/settings/components/DeploymentPage.tsx +2 -2
- package/src/modules/settings/components/SettingsLayout.tsx +2 -2
- package/src/modules/settings/index.ts +8 -0
- package/src/modules/setup/components/FirstRunStorage.tsx +1 -1
- package/src/modules/setup/index.ts +6 -0
- package/src/modules/toolbar/commands/actions.tsx +3 -3
- package/src/modules/toolbar/commands/useCommandActions.ts +5 -9
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +2 -2
- package/src/modules/toolbar/components/AppSwitcher.tsx +1 -2
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +1 -1
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +39 -5
- package/src/modules/toolbar/components/ProfileMenu.tsx +3 -3
- package/src/modules/toolbar/components/SearchPalette.tsx +4 -8
- package/src/modules/toolbar/components/Toolbar.tsx +2 -5
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +91 -2
- package/src/modules/toolbar/index.ts +6 -0
- package/src/modules/toolbar/search/sources.ts +4 -7
- package/src/modules/toolbar/services/agent-instructions.api.ts +1 -1
- package/src/modules/toolbar/services/external-api-keys.api.ts +5 -2
- package/src/modules/tools/ToolsExplorerPage.tsx +217 -18
- package/src/modules/tools/__tests__/ToolsExplorerPage.read-only.test.tsx +220 -0
- package/src/modules/tools/tool-hints.api.ts +44 -0
- package/src/modules/workflow/index.ts +7 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +1 -0
- package/src/modules/workflow/state/EventBusFocusBinder.tsx +1 -1
- package/src/modules/workspace/components/FileExplorer.tsx +35 -8
- package/src/modules/workspace/components/FilePaneCard.tsx +37 -12
- package/src/modules/workspace/components/FileRoute.tsx +10 -3
- package/src/modules/workspace/components/FileViewer.tsx +169 -25
- package/src/modules/workspace/components/FullScreenView.tsx +93 -0
- package/src/modules/workspace/components/KbFileRail.tsx +1 -1
- package/src/modules/workspace/components/KbPageHeader.tsx +9 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +163 -0
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +11 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +487 -3
- package/src/modules/workspace/components/readingCarry.ts +59 -0
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +74 -180
- package/src/modules/workspace/components/renderers/KbAppLink.tsx +56 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +30 -10
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +37 -40
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +1 -1
- package/src/modules/workspace/components/renderers/__tests__/HtmlRenderer.links.test.tsx +185 -0
- package/src/modules/workspace/components/renderers/__tests__/HtmlRenderer.tools.test.tsx +168 -42
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.sectionReclick.test.tsx +88 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +199 -29
- package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +57 -7
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +122 -4
- package/src/modules/workspace/components/renderers/__tests__/htmlToolBridge.test.ts +235 -1
- package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +29 -4
- package/src/modules/workspace/components/renderers/__tests__/liveDataReferencePage.test.ts +397 -0
- package/src/modules/workspace/components/renderers/__tests__/pageToolsHarness.ts +79 -0
- package/src/modules/workspace/components/renderers/__tests__/useHtmlToolBridge.test.tsx +316 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +123 -28
- package/src/modules/workspace/components/renderers/htmlToolBridge.ts +215 -25
- package/src/modules/workspace/components/renderers/index.ts +10 -0
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +35 -28
- package/src/modules/workspace/components/renderers/scrollToHeading.ts +35 -0
- package/src/modules/workspace/components/renderers/useHtmlToolBridge.tsx +253 -0
- package/src/modules/workspace/hooks/__tests__/useLinksOut.test.ts +6 -0
- package/src/modules/workspace/hooks/useFullScreenView.ts +52 -0
- package/src/modules/workspace/hooks/useImageRevision.ts +1 -1
- package/src/modules/workspace/hooks/useKnowledgeWriteTarget.ts +1 -1
- package/src/modules/workspace/hooks/useLastCommit.ts +1 -1
- package/src/modules/workspace/hooks/useLinksOut.ts +12 -6
- package/src/modules/workspace/hooks/useWorkspaceState.ts +4 -4
- package/src/modules/workspace/index.ts +50 -2
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +262 -25
- package/src/modules/workspace/routing/kb-routes.ts +222 -54
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +0 -1
- package/src/modules/workspace/state/open-change-requests.tsx +1 -1
- package/src/modules/workspace/utils/fileTree.ts +1 -1
- package/src/modules/workspace/utils/frameEscape.ts +15 -0
- package/src/modules/workspace/utils/treeConfirm.ts +1 -1
- package/src/shared/theme/measure.ts +7 -0
- package/src/modules/pr/services/pr-comments.api.ts +0 -45
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';
|
|
2
|
-
import { render, screen, fireEvent, waitFor, within } from '@testing-library/react';
|
|
2
|
+
import { act, render, screen, fireEvent, waitFor, within } from '@testing-library/react';
|
|
3
3
|
import { MemoryRouter } from 'react-router-dom';
|
|
4
4
|
import type { ConnectPending } from '../../services/connect.api';
|
|
5
5
|
import { ConnectToolsPage } from '../ConnectToolsPage';
|
|
@@ -522,7 +522,117 @@ describe('ConnectToolsPage: inside Skills & Tools', () => {
|
|
|
522
522
|
} finally {
|
|
523
523
|
Object.defineProperty(window, 'location', { configurable: true, value: realLocation });
|
|
524
524
|
}
|
|
525
|
-
|
|
525
|
+
// Nothing chosen: the connection is made as Everything, exactly as before.
|
|
526
|
+
expect(connectMock.completeMcpOAuth).toHaveBeenCalledWith('signed-state', null);
|
|
526
527
|
expect(connectMock.getMcpOAuthRequest).toHaveBeenCalledWith('signed-state');
|
|
527
528
|
});
|
|
529
|
+
|
|
530
|
+
describe('"Connect as"', () => {
|
|
531
|
+
const OPS = { path: 'Agents/ops.agent', name: 'ops', description: 'Watches the dashboards.' };
|
|
532
|
+
|
|
533
|
+
/** Click Finish with the address held, as above; resolves once the browser would have left. */
|
|
534
|
+
async function finish() {
|
|
535
|
+
const realLocation = window.location;
|
|
536
|
+
Object.defineProperty(window, 'location', { configurable: true, value: { ...realLocation, href: realLocation.href } });
|
|
537
|
+
try {
|
|
538
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Finish & return to your agent' }));
|
|
539
|
+
await waitFor(() => expect(window.location.href).toBe('/agent-callback?code=abc'));
|
|
540
|
+
} finally {
|
|
541
|
+
Object.defineProperty(window, 'location', { configurable: true, value: realLocation });
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
beforeEach(() => {
|
|
546
|
+
window.history.replaceState(null, '', '/skills-and-tools/connect?oauth=signed-state');
|
|
547
|
+
connectMock.getMcpOAuthRequest.mockResolvedValue({ clientName: 'Claude', scope: null, resource: null, agents: [OPS] });
|
|
548
|
+
connectMock.completeMcpOAuth.mockResolvedValue('/agent-callback?code=abc');
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
it('offers Everything, selected, before the person approves, and each agent by name with its description', async () => {
|
|
552
|
+
renderPage();
|
|
553
|
+
const group = await screen.findByRole('group', { name: 'Connect as' });
|
|
554
|
+
expect(within(group).getByRole('radio', { name: /Everything/ })).toBeChecked();
|
|
555
|
+
expect(await within(group).findByRole('radio', { name: /ops.*Watches the dashboards\./ })).not.toBeChecked();
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
it('says when the agents could not be loaded, and approves Everything only once that is confirmed', async () => {
|
|
559
|
+
connectMock.getMcpOAuthRequest.mockResolvedValue({
|
|
560
|
+
clientName: 'Claude',
|
|
561
|
+
scope: null,
|
|
562
|
+
resource: null,
|
|
563
|
+
agents: [],
|
|
564
|
+
agentsUnavailable: true,
|
|
565
|
+
});
|
|
566
|
+
renderPage();
|
|
567
|
+
expect(await screen.findByRole('alert')).toHaveTextContent(/agents couldn't be loaded/);
|
|
568
|
+
expect(screen.getByRole('button', { name: 'Finish & return to your agent' })).toBeDisabled();
|
|
569
|
+
fireEvent.click(screen.getByRole('checkbox', { name: 'Connect as Everything anyway' }));
|
|
570
|
+
await finish();
|
|
571
|
+
expect(connectMock.completeMcpOAuth).toHaveBeenCalledWith('signed-state', null);
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
it('keeps Finish disabled until the agents on offer have answered', async () => {
|
|
575
|
+
let answer!: (r: unknown) => void;
|
|
576
|
+
connectMock.getMcpOAuthRequest.mockReturnValue(new Promise((resolve) => (answer = resolve)));
|
|
577
|
+
renderPage();
|
|
578
|
+
const finishButton = await screen.findByRole('button', { name: 'Finish & return to your agent' });
|
|
579
|
+
expect(finishButton).toBeDisabled();
|
|
580
|
+
await act(async () => answer({ clientName: 'Claude', scope: null, resource: null, agents: [OPS] }));
|
|
581
|
+
expect(finishButton).toBeEnabled();
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
it('approving with an agent picked connects as that agent', async () => {
|
|
585
|
+
renderPage();
|
|
586
|
+
fireEvent.click(await screen.findByRole('radio', { name: /ops/ }));
|
|
587
|
+
await finish();
|
|
588
|
+
expect(connectMock.completeMcpOAuth).toHaveBeenCalledWith('signed-state', 'Agents/ops.agent');
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
it('lists the tools for the chosen agent: the list is fetched again for it, quietly, and once more for Everything', async () => {
|
|
592
|
+
renderPage();
|
|
593
|
+
// The first load, before any choice, is Everything's.
|
|
594
|
+
await screen.findByLabelText('API_KEY value');
|
|
595
|
+
expect(connectMock.getConnectPending).toHaveBeenLastCalledWith(null);
|
|
596
|
+
// The agent loads no tool that needs anything: the page says so, for that agent.
|
|
597
|
+
connectMock.getConnectPending.mockResolvedValue({ tools: [], oauth: [], toolOAuth: [] });
|
|
598
|
+
fireEvent.click(await screen.findByRole('radio', { name: /ops/ }));
|
|
599
|
+
await waitFor(() => expect(connectMock.getConnectPending).toHaveBeenLastCalledWith('Agents/ops.agent'));
|
|
600
|
+
expect(await screen.findByRole('status')).toHaveTextContent(/none of the tools the chosen agent loads/);
|
|
601
|
+
// Quietly: the page never dropped to "Loading…" over the list it had.
|
|
602
|
+
expect(screen.queryByText('Loading…')).not.toBeInTheDocument();
|
|
603
|
+
// Back to Everything: fetched again, as Everything.
|
|
604
|
+
connectMock.getConnectPending.mockResolvedValue(pending(false));
|
|
605
|
+
fireEvent.click(screen.getByRole('radio', { name: /Everything/ }));
|
|
606
|
+
await waitFor(() => expect(connectMock.getConnectPending).toHaveBeenLastCalledWith(null));
|
|
607
|
+
await screen.findByLabelText('API_KEY value');
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
it('fetches the remembered agent’s list straight away when the page comes back from a sign-in', async () => {
|
|
611
|
+
const first = renderPage();
|
|
612
|
+
fireEvent.click(await screen.findByRole('radio', { name: /ops/ }));
|
|
613
|
+
await waitFor(() => expect(connectMock.getConnectPending).toHaveBeenLastCalledWith('Agents/ops.agent'));
|
|
614
|
+
first.unmount();
|
|
615
|
+
connectMock.getConnectPending.mockClear();
|
|
616
|
+
window.history.replaceState(null, '', '/skills-and-tools/connect');
|
|
617
|
+
renderPage();
|
|
618
|
+
await screen.findByRole('radio', { name: /ops/ });
|
|
619
|
+
await waitFor(() => expect(connectMock.getConnectPending).toHaveBeenLastCalledWith('Agents/ops.agent'));
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it('keeps the choice across a tool sign-in’s round-trip, and a new authorization starts at Everything', async () => {
|
|
623
|
+
const first = renderPage();
|
|
624
|
+
fireEvent.click(await screen.findByRole('radio', { name: /ops/ }));
|
|
625
|
+
first.unmount();
|
|
626
|
+
// Back from a provider: the query is gone, the session copy remains.
|
|
627
|
+
window.history.replaceState(null, '', '/skills-and-tools/connect');
|
|
628
|
+
const back = renderPage();
|
|
629
|
+
expect(await screen.findByRole('radio', { name: /ops/ })).toBeChecked();
|
|
630
|
+
back.unmount();
|
|
631
|
+
// Another agent's authorization arrives: its choice is its own.
|
|
632
|
+
window.history.replaceState(null, '', '/skills-and-tools/connect?oauth=another-state');
|
|
633
|
+
renderPage();
|
|
634
|
+
await screen.findByRole('radio', { name: /ops/ });
|
|
635
|
+
expect(screen.getByRole('radio', { name: /Everything/ })).toBeChecked();
|
|
636
|
+
});
|
|
637
|
+
});
|
|
528
638
|
});
|
|
@@ -5,3 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
/** "Connect your tools", mounted by Skills & Tools at `/skills-and-tools/connect`. */
|
|
7
7
|
export { ConnectToolsPage } from './components/ConnectToolsPage';
|
|
8
|
+
// Reached by other modules; exported here so they stop importing the files.
|
|
9
|
+
export { probeWords } from './probe/probe-verdict';
|
|
10
|
+
export { useSavedKeyProbe } from './probe/useSavedKeyProbe';
|
|
11
|
+
export { startToolOAuth } from './services/connect.api';
|
|
12
|
+
export { deleteAdminVar, listToolSecrets, setAdminVar, setOAuthClientSecret, setUserVar } from './services/tool-secrets.api';
|
|
13
|
+
export type { ProbeVerdict, ToolSecrets, ToolVarStatus } from './services/tool-secrets.api';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { authFetch } from '../../../lib/api';
|
|
2
|
+
import type { AgentChoice } from '../../agents';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The aggregated "connect your tools" surface: everything standing between the
|
|
@@ -96,9 +97,14 @@ async function fail(res: Response, fallback: string): Promise<never> {
|
|
|
96
97
|
throw new Error(message);
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
/**
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
/**
|
|
101
|
+
* The caller's outstanding per-user credentials across every accessible tool —
|
|
102
|
+
* or, with `agentPath` (the consent step's "Connect as" choice), across the
|
|
103
|
+
* connectors a connection made as that agent configuration loads. Null is
|
|
104
|
+
* Everything.
|
|
105
|
+
*/
|
|
106
|
+
export async function getConnectPending(agentPath: string | null = null): Promise<ConnectPending> {
|
|
107
|
+
const res = await authFetch(agentPath ? `/api/connect/pending?agent=${encodeURIComponent(agentPath)}` : '/api/connect/pending');
|
|
102
108
|
if (!res.ok) await fail(res, "Couldn't load your tools.");
|
|
103
109
|
return (await res.json()) as ConnectPending;
|
|
104
110
|
}
|
|
@@ -141,6 +147,14 @@ export interface McpOAuthRequest {
|
|
|
141
147
|
clientName: string | null;
|
|
142
148
|
scope: string | null;
|
|
143
149
|
resource: string | null;
|
|
150
|
+
/**
|
|
151
|
+
* The agent configurations the person may connect this client as, offered below
|
|
152
|
+
* Everything. Empty when there are none (or for a request that cannot take
|
|
153
|
+
* a choice).
|
|
154
|
+
*/
|
|
155
|
+
agents?: AgentChoice[];
|
|
156
|
+
/** Set when the agents could not be listed: `agents` is then empty for that reason, not because there are none. */
|
|
157
|
+
agentsUnavailable?: boolean;
|
|
144
158
|
}
|
|
145
159
|
|
|
146
160
|
/** Describe the pending MCP authorization carried in the signed `state`. */
|
|
@@ -153,12 +167,13 @@ export async function getMcpOAuthRequest(state: string): Promise<McpOAuthRequest
|
|
|
153
167
|
/**
|
|
154
168
|
* Finish the MCP authorization: mint the one-time code for the signed-in user
|
|
155
169
|
* and return the agent's redirect URL the browser should navigate to.
|
|
170
|
+
* `agentPath` is the "Connect as" choice; null (the default) is Everything.
|
|
156
171
|
*/
|
|
157
|
-
export async function completeMcpOAuth(state: string): Promise<string> {
|
|
172
|
+
export async function completeMcpOAuth(state: string, agentPath: string | null = null): Promise<string> {
|
|
158
173
|
const res = await authFetch('/api/mcp/oauth/complete', {
|
|
159
174
|
method: 'POST',
|
|
160
175
|
headers: { 'Content-Type': 'application/json' },
|
|
161
|
-
body: JSON.stringify({ state }),
|
|
176
|
+
body: JSON.stringify(agentPath ? { state, agentPath } : { state }),
|
|
162
177
|
});
|
|
163
178
|
if (!res.ok) await fail(res, "Couldn't finish connecting.");
|
|
164
179
|
return ((await res.json()) as { redirectTo: string }).redirectTo;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PageShell } from '../../../shared/components/PageShell';
|
|
2
2
|
import { Banner, Button } from '../../../shared/components';
|
|
3
3
|
import { SlotBoundary } from '../../../shared/components/SlotBoundary';
|
|
4
|
-
import { useAdmin } from '../../admin
|
|
5
|
-
import { useSetupStatus } from '../../setup
|
|
4
|
+
import { useAdmin } from '../../admin';
|
|
5
|
+
import { useSetupStatus } from '../../setup';
|
|
6
6
|
import { SetupScreen } from '../../setup/components/SetupScreen';
|
|
7
7
|
import { useAppRegistry } from '../../../core/registry';
|
|
8
8
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useContext, useMemo } from 'react';
|
|
2
2
|
import { Outlet, useLocation } from 'react-router-dom';
|
|
3
|
-
import { AdminContext } from '../../admin
|
|
3
|
+
import { AdminContext } from '../../admin';
|
|
4
4
|
import type { AdminMenuItem } from '../../../core/registry';
|
|
5
5
|
import { SidebarFrame } from '../../layout/components/SidebarFrame';
|
|
6
|
-
import { useMediaQuery } from '../../layout
|
|
6
|
+
import { useMediaQuery } from '../../layout';
|
|
7
7
|
import {
|
|
8
8
|
isSettingsNavPath,
|
|
9
9
|
normalizeSettingsPath,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the settings module offers the other modules. A consumer outside the
|
|
3
|
+
* module imports from here, never from the files: they are the module's own
|
|
4
|
+
* layout and free to move. Export what another module needs; nothing more.
|
|
5
|
+
*/
|
|
6
|
+
export { fetchMarketplaceRegistration } from './services/github-facade.api';
|
|
7
|
+
export { isSettingsNavPath, useMenuSections } from './settings-nav-items';
|
|
8
|
+
export type { MenuSections } from './settings-nav-items';
|
|
@@ -8,7 +8,7 @@ import { GitHubRepositoryPanel } from './GitHubRepositoryPanel';
|
|
|
8
8
|
import { forgetDraft } from '../utils/kept-draft';
|
|
9
9
|
import { tokenUsernameForHost } from '../utils/git-host';
|
|
10
10
|
import { suggestedBranch } from '../utils/suggested-branch';
|
|
11
|
-
import { KB_ROUTE_PREFIX } from '../../workspace
|
|
11
|
+
import { KB_ROUTE_PREFIX } from '../../workspace';
|
|
12
12
|
import { ConnectionProbeFailed, useConnectionProbe } from '../hooks/useConnectionProbe';
|
|
13
13
|
import {
|
|
14
14
|
saveSettings,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the setup module offers the other modules. A consumer outside the
|
|
3
|
+
* module imports from here, never from the files: they are the module's own
|
|
4
|
+
* layout and free to move. Export what another module needs; nothing more.
|
|
5
|
+
*/
|
|
6
|
+
export { useSetupStatus } from './hooks/useSetupStatus';
|
|
@@ -2,9 +2,9 @@ import type { ReactNode } from 'react';
|
|
|
2
2
|
import type { AuthUser } from '@bevel-software/platform-shared';
|
|
3
3
|
import { ArrowRight, FilePlus, Pencil, Plug, Settings, UserPlus } from 'lucide-react';
|
|
4
4
|
import type { AdminMenuItem, AppDef } from '../../../core/registry';
|
|
5
|
-
import type { MenuSections } from '../../settings
|
|
6
|
-
import type { InviteDialogController } from '../../onboarding
|
|
7
|
-
import { WELCOME_PATH } from '../../onboarding
|
|
5
|
+
import type { MenuSections } from '../../settings';
|
|
6
|
+
import type { InviteDialogController } from '../../onboarding';
|
|
7
|
+
import { WELCOME_PATH } from '../../onboarding';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The commands the toolbar's menu can run, beside the pages and items it
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useNavigate } from 'react-router-dom';
|
|
3
3
|
import { useActiveAppId, useAppRegistry } from '../../../core/registry';
|
|
4
|
-
import { useAdmin } from '../../admin
|
|
5
|
-
import { useAuth } from '../../auth
|
|
6
|
-
import { useMenuSections } from '../../settings
|
|
7
|
-
import { useInviteDialog } from '../../onboarding
|
|
8
|
-
import {
|
|
9
|
-
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
10
|
-
import { useEditablePage } from '../../workspace/state/editable-page';
|
|
11
|
-
import { useFileNav } from '../../workspace/routing/kb-routes';
|
|
12
|
-
import { useCreatePage } from '../../workspace/hooks/useCreatePage';
|
|
4
|
+
import { useAdmin } from '../../admin';
|
|
5
|
+
import { useAuth } from '../../auth';
|
|
6
|
+
import { useMenuSections } from '../../settings';
|
|
7
|
+
import { useInviteDialog, useOnboarding } from '../../onboarding';
|
|
8
|
+
import { useWorkspace, useEditablePage, useFileNav, useCreatePage } from '../../workspace';
|
|
13
9
|
import {
|
|
14
10
|
coreCommandActions,
|
|
15
11
|
mergeCommandActions,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { Pencil } from 'lucide-react';
|
|
3
|
-
import { AdminContext } from '../../admin
|
|
4
|
-
import { WorkspaceContext } from '../../workspace
|
|
3
|
+
import { AdminContext } from '../../admin';
|
|
4
|
+
import { WorkspaceContext } from '../../workspace';
|
|
5
5
|
import { Button } from '../../../shared/components';
|
|
6
6
|
import { Markdown } from '../../../shared/markdown/Markdown';
|
|
7
7
|
import {
|
|
@@ -2,8 +2,7 @@ import { useEffect, useMemo, useRef, useState, type MouseEvent as ReactMouseEven
|
|
|
2
2
|
import { Check, ChevronDown } from 'lucide-react';
|
|
3
3
|
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
|
4
4
|
import { activeAppId, useActiveAppId, useAppRegistry, type AppDef } from '../../../core/registry';
|
|
5
|
-
import { useMediaQuery } from '../../layout
|
|
6
|
-
import { TOOLBAR_STACK_QUERY } from '../../layout/breakpoints';
|
|
5
|
+
import { useMediaQuery, TOOLBAR_STACK_QUERY } from '../../layout';
|
|
7
6
|
import { cn } from '../../../lib/utils';
|
|
8
7
|
import { PRODUCT_NAME, ProductName } from '../../../core/ProductName';
|
|
9
8
|
import { useMakerLinkLabel, useMakerUrl } from '../../../core/maker-url';
|
|
@@ -3,7 +3,7 @@ import { Link } from 'react-router-dom';
|
|
|
3
3
|
import { Banner } from '../../../shared/components';
|
|
4
4
|
import { CopyBlock } from '../../../shared/mcp';
|
|
5
5
|
import { marketplaceGitUrl } from '../../../shared/marketplace-url';
|
|
6
|
-
import { fetchMarketplaceRegistration } from '../../settings
|
|
6
|
+
import { fetchMarketplaceRegistration } from '../../settings';
|
|
7
7
|
import { ClaudeMarketplaceCarousel } from './ClaudeMarketplaceCarousel';
|
|
8
8
|
import { Prose } from './setup-step-parts';
|
|
9
9
|
import { deploymentHost } from './deployment-address';
|
|
@@ -22,7 +22,9 @@ import { CODEX_LOGIN_NOTE, GITHUB_LINK_KIND, marketplaceCommands, marketplaceGit
|
|
|
22
22
|
import { AgentInstructionsCard } from './AgentInstructionsCard';
|
|
23
23
|
import { CONNECT_TOOLS_PATH } from '../../library';
|
|
24
24
|
import { CoworkSetupSteps } from './CoworkSetupSteps';
|
|
25
|
-
import { useAdmin } from '../../admin
|
|
25
|
+
import { useAdmin } from '../../admin';
|
|
26
|
+
import { connectedAsLabel, listAgentChoices, useConnectAsChoice } from '../../agents';
|
|
27
|
+
import { ConnectAsChoice } from '../../agents/components/ConnectAsChoice';
|
|
26
28
|
import {
|
|
27
29
|
type ExternalApiKeySummary,
|
|
28
30
|
type MintedExternalApiKey,
|
|
@@ -96,6 +98,10 @@ export function ExternalAgentAccessPage() {
|
|
|
96
98
|
const [loadError, setLoadError] = useState<string | null>(null);
|
|
97
99
|
|
|
98
100
|
const [label, setLabel] = useState('');
|
|
101
|
+
// "Connect as" for a new key: Everything unless an agent is picked. Until
|
|
102
|
+
// the agents answer, a key would be minted as Everything by default; when
|
|
103
|
+
// they could not be loaded, an Everything key waits to be confirmed.
|
|
104
|
+
const connectAs = useConnectAsChoice();
|
|
99
105
|
const [creating, setCreating] = useState(false);
|
|
100
106
|
const [createError, setCreateError] = useState<string | null>(null);
|
|
101
107
|
|
|
@@ -128,15 +134,34 @@ export function ExternalAgentAccessPage() {
|
|
|
128
134
|
void refresh();
|
|
129
135
|
}, [refresh]);
|
|
130
136
|
|
|
137
|
+
// The agents a key may be minted as. A failure costs only the choice —
|
|
138
|
+
// Everything is always on offer — and is shown, not passed off as none.
|
|
139
|
+
const settleConnectAs = connectAs.settle;
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
let cancelled = false;
|
|
142
|
+
listAgentChoices().then(
|
|
143
|
+
(agents) => {
|
|
144
|
+
if (!cancelled) settleConnectAs({ agents });
|
|
145
|
+
},
|
|
146
|
+
() => {
|
|
147
|
+
if (!cancelled) settleConnectAs({ agents: [], failed: true });
|
|
148
|
+
},
|
|
149
|
+
);
|
|
150
|
+
return () => {
|
|
151
|
+
cancelled = true;
|
|
152
|
+
};
|
|
153
|
+
}, [settleConnectAs]);
|
|
154
|
+
|
|
131
155
|
async function handleCreate() {
|
|
132
156
|
const trimmed = label.trim();
|
|
133
|
-
if (trimmed.length === 0 || trimmed.length > MAX_LABEL_LEN || creating) return;
|
|
157
|
+
if (trimmed.length === 0 || trimmed.length > MAX_LABEL_LEN || creating || !connectAs.mayConnect) return;
|
|
134
158
|
setCreating(true);
|
|
135
159
|
setCreateError(null);
|
|
136
160
|
try {
|
|
137
|
-
const minted = await createExternalApiKey(trimmed);
|
|
161
|
+
const minted = await createExternalApiKey(trimmed, connectAs.value);
|
|
138
162
|
setReveal(minted);
|
|
139
163
|
setLabel('');
|
|
164
|
+
connectAs.setValue(null);
|
|
140
165
|
// Optimistic-ish: refresh the list so the new row shows up underneath
|
|
141
166
|
// the reveal modal.
|
|
142
167
|
void refresh();
|
|
@@ -172,7 +197,7 @@ export function ExternalAgentAccessPage() {
|
|
|
172
197
|
}
|
|
173
198
|
|
|
174
199
|
const trimmed = label.trim();
|
|
175
|
-
const canSubmit = trimmed.length > 0 && trimmed.length <= MAX_LABEL_LEN && !creating;
|
|
200
|
+
const canSubmit = trimmed.length > 0 && trimmed.length <= MAX_LABEL_LEN && !creating && connectAs.mayConnect;
|
|
176
201
|
|
|
177
202
|
// Surface the keys that matter: active keys first (most-recently-used at the
|
|
178
203
|
// top, never-used ones last among the active), with disconnected keys sunk
|
|
@@ -535,6 +560,14 @@ export function ExternalAgentAccessPage() {
|
|
|
535
560
|
{creating ? 'Creating…' : 'Create key'}
|
|
536
561
|
</button>
|
|
537
562
|
</div>
|
|
563
|
+
<ConnectAsChoice
|
|
564
|
+
agents={connectAs.agents}
|
|
565
|
+
value={connectAs.value}
|
|
566
|
+
disabled={creating}
|
|
567
|
+
hint="What the key loads. An agent narrows it to the tools, skills and plugins its configuration lists, and only those you may read."
|
|
568
|
+
onChange={connectAs.setValue}
|
|
569
|
+
unavailable={connectAs.unavailable}
|
|
570
|
+
/>
|
|
538
571
|
{createError && (
|
|
539
572
|
<div className="text-xs text-red-600 bg-red-50 border border-red-200 rounded px-2 py-1.5">
|
|
540
573
|
{createError}
|
|
@@ -575,7 +608,8 @@ export function ExternalAgentAccessPage() {
|
|
|
575
608
|
<div className="flex-1 min-w-0">
|
|
576
609
|
<div className="font-medium truncate">{k.label}</div>
|
|
577
610
|
<div className="text-[11px] text-ink-muted">
|
|
578
|
-
|
|
611
|
+
<span title={k.agentPath ?? undefined}>As {connectedAsLabel(k.agentPath)}</span> · Created{' '}
|
|
612
|
+
{formatRelative(k.createdAt)} · Last used {formatRelative(k.lastUsedAt)}
|
|
579
613
|
{/* A key an admin took is not one you can reconnect — say so,
|
|
580
614
|
or people try. Your own disconnect keeps its word. */}
|
|
581
615
|
{revoked &&
|
|
@@ -2,10 +2,10 @@ import { Fragment, useCallback, useRef, useState } from 'react';
|
|
|
2
2
|
import { ChevronDown, LogOut } from 'lucide-react';
|
|
3
3
|
import { useNavigate } from 'react-router-dom';
|
|
4
4
|
import type { AuthUser } from '@bevel-software/platform-shared';
|
|
5
|
-
import { useAuth } from '../../auth
|
|
6
|
-
import { useAdmin } from '../../admin
|
|
5
|
+
import { useAuth } from '../../auth';
|
|
6
|
+
import { useAdmin } from '../../admin';
|
|
7
7
|
import type { AdminMenuItem } from '../../../core/registry';
|
|
8
|
-
import { useMenuSections } from '../../settings
|
|
8
|
+
import { useMenuSections } from '../../settings';
|
|
9
9
|
import {
|
|
10
10
|
MenuItem,
|
|
11
11
|
MenuLabel,
|
|
@@ -13,13 +13,9 @@ import { useNavigate } from 'react-router-dom';
|
|
|
13
13
|
import { ChevronRight, FileText, Puzzle, Search, Sparkles, Wrench } from 'lucide-react';
|
|
14
14
|
import { MenuPanel, useDismissableMenu, useLatestRef } from '../../../shared/components';
|
|
15
15
|
import { cn } from '../../../lib/utils';
|
|
16
|
-
import { useWorkspace } from '../../workspace
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { knowledgeFiles } from '../../workspace/utils/fileTree';
|
|
20
|
-
import { listSkills } from '../../library/services/library.api';
|
|
21
|
-
import { listPlugins } from '../../library/services/plugins.api';
|
|
22
|
-
import { listToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
|
|
16
|
+
import { useWorkspace, useMergedWorkspaceTree, useFileNav, knowledgeFiles } from '../../workspace';
|
|
17
|
+
import { listSkills, listPlugins } from '../../library';
|
|
18
|
+
import { listToolSecrets } from '../../secrets-vault';
|
|
23
19
|
import { rankByName, rankByNames } from '../search/rank';
|
|
24
20
|
import {
|
|
25
21
|
libraryResults,
|
|
@@ -39,7 +35,7 @@ import {
|
|
|
39
35
|
shortcutHint,
|
|
40
36
|
shortcutKeycapWidth,
|
|
41
37
|
} from '../commands/command-menu';
|
|
42
|
-
import { useSetupChecklist } from '../../onboarding
|
|
38
|
+
import { useSetupChecklist } from '../../onboarding';
|
|
43
39
|
|
|
44
40
|
/** Rows per group. Past this the query is too short to be useful, not the list too long. */
|
|
45
41
|
const GROUP_LIMIT = 8;
|
|
@@ -4,13 +4,10 @@ import { PanelRight } from 'lucide-react';
|
|
|
4
4
|
import { ProfileMenu } from './ProfileMenu';
|
|
5
5
|
import { AppSwitcher } from './AppSwitcher';
|
|
6
6
|
import { SearchPalette } from './SearchPalette';
|
|
7
|
-
import { useLayout } from '../../layout
|
|
8
|
-
import { useMediaQuery } from '../../layout/hooks/useMediaQuery';
|
|
7
|
+
import { useLayout, useMediaQuery, toggleSidebar, useSidebar, TOOLBAR_STACK_QUERY } from '../../layout';
|
|
9
8
|
import { useActiveAppId, useAppRegistry } from '../../../core/registry';
|
|
10
9
|
import { SidebarToggle } from '../../layout/components/SidebarToggle';
|
|
11
|
-
import {
|
|
12
|
-
import { TOOLBAR_STACK_QUERY } from '../../layout/breakpoints';
|
|
13
|
-
import { isSettingsNavPath } from '../../settings/settings-nav-items';
|
|
10
|
+
import { isSettingsNavPath } from '../../settings';
|
|
14
11
|
import { InviteButton } from '../../onboarding/components/InviteButton';
|
|
15
12
|
|
|
16
13
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { fireEvent, render, screen, within } from '@testing-library/react';
|
|
2
|
+
import { act, fireEvent, render, screen, within } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
|
5
5
|
import { ExternalAgentAccessPage } from '../ExternalAgentAccessPage';
|
|
@@ -22,7 +22,8 @@ import { GITHUB_LINK_KIND, configureMarketplaceGitUrl } from '../../../../shared
|
|
|
22
22
|
* regression cases below name all six.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
const { listMock, createMock, instructionsMock, facadeMock, registrationMock, adminState } = vi.hoisted(() => ({
|
|
25
|
+
const { listMock, createMock, instructionsMock, facadeMock, registrationMock, adminState, agentChoicesMock } = vi.hoisted(() => ({
|
|
26
|
+
agentChoicesMock: vi.fn(),
|
|
26
27
|
listMock: vi.fn(),
|
|
27
28
|
createMock: vi.fn(),
|
|
28
29
|
instructionsMock: vi.fn(),
|
|
@@ -49,6 +50,12 @@ vi.mock('../../../settings/services/github-facade.api', () => ({
|
|
|
49
50
|
fetchMarketplaceRegistration: registrationMock,
|
|
50
51
|
}));
|
|
51
52
|
|
|
53
|
+
// The agents a key may be minted as ("Connect as").
|
|
54
|
+
vi.mock('../../../agents/services/agent-choices.api', async (importOriginal) => ({
|
|
55
|
+
...(await importOriginal<typeof import('../../../agents/services/agent-choices.api')>()),
|
|
56
|
+
listAgentChoices: agentChoicesMock,
|
|
57
|
+
}));
|
|
58
|
+
|
|
52
59
|
vi.mock('../../services/external-api-keys.api', () => ({
|
|
53
60
|
listExternalApiKeys: listMock,
|
|
54
61
|
createExternalApiKey: createMock,
|
|
@@ -91,6 +98,9 @@ beforeEach(() => {
|
|
|
91
98
|
registrationMock.mockReset();
|
|
92
99
|
registrationMock.mockResolvedValue(true);
|
|
93
100
|
listMock.mockResolvedValue([]);
|
|
101
|
+
agentChoicesMock.mockReset();
|
|
102
|
+
agentChoicesMock.mockResolvedValue([]);
|
|
103
|
+
createMock.mockClear();
|
|
94
104
|
instructionsMock.mockResolvedValue({
|
|
95
105
|
instructions: 'Search the knowledge base first.',
|
|
96
106
|
header: 'Search the knowledge base first.',
|
|
@@ -792,6 +802,85 @@ describe('the Marketplaces tab', () => {
|
|
|
792
802
|
});
|
|
793
803
|
});
|
|
794
804
|
|
|
805
|
+
describe('minting a key as an agent ("Connect as")', () => {
|
|
806
|
+
const OPS = { path: 'Agents/ops.agent', name: 'ops', description: 'Watches the dashboards.' };
|
|
807
|
+
|
|
808
|
+
it('offers Everything, selected by default, then each agent by name with its description', async () => {
|
|
809
|
+
agentChoicesMock.mockResolvedValue([OPS]);
|
|
810
|
+
const user = userEvent.setup();
|
|
811
|
+
mount(PUBLIC_URL);
|
|
812
|
+
await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
|
|
813
|
+
const group = screen.getByRole('group', { name: 'Connect as' });
|
|
814
|
+
const everything = within(group).getByRole('radio', { name: /Everything/ });
|
|
815
|
+
expect(everything).toBeChecked();
|
|
816
|
+
const ops = await within(group).findByRole('radio', { name: /ops.*Watches the dashboards\./ });
|
|
817
|
+
expect(ops).not.toBeChecked();
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
it('mints as Everything unless an agent is picked, and as the agent when one is', async () => {
|
|
821
|
+
agentChoicesMock.mockResolvedValue([OPS]);
|
|
822
|
+
const user = userEvent.setup();
|
|
823
|
+
mount(PUBLIC_URL);
|
|
824
|
+
await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
|
|
825
|
+
await user.type(screen.getByRole('textbox', { name: /Create an external API key/ }), 'CI');
|
|
826
|
+
await user.click(screen.getByRole('button', { name: 'Create key' }));
|
|
827
|
+
expect(createMock).toHaveBeenLastCalledWith('CI', null);
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
it('records the picked agent on the key', async () => {
|
|
831
|
+
agentChoicesMock.mockResolvedValue([OPS]);
|
|
832
|
+
const user = userEvent.setup();
|
|
833
|
+
mount(PUBLIC_URL);
|
|
834
|
+
await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
|
|
835
|
+
await user.click(await screen.findByRole('radio', { name: /ops/ }));
|
|
836
|
+
await user.type(screen.getByRole('textbox', { name: /Create an external API key/ }), 'Pipeline');
|
|
837
|
+
await user.click(screen.getByRole('button', { name: 'Create key' }));
|
|
838
|
+
expect(createMock).toHaveBeenLastCalledWith('Pipeline', 'Agents/ops.agent');
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
it('says when the agents could not be loaded, and mints Everything only once that is confirmed', async () => {
|
|
842
|
+
agentChoicesMock.mockRejectedValue(new Error('down'));
|
|
843
|
+
const user = userEvent.setup();
|
|
844
|
+
mount(PUBLIC_URL);
|
|
845
|
+
await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
|
|
846
|
+
expect(await screen.findByRole('alert')).toHaveTextContent(/agents couldn't be loaded/);
|
|
847
|
+
await user.type(screen.getByRole('textbox', { name: /Create an external API key/ }), 'CI');
|
|
848
|
+
const create = screen.getByRole('button', { name: 'Create key' });
|
|
849
|
+
expect(create).toBeDisabled();
|
|
850
|
+
await user.click(screen.getByRole('checkbox', { name: 'Connect as Everything anyway' }));
|
|
851
|
+
expect(create).toBeEnabled();
|
|
852
|
+
await user.click(create);
|
|
853
|
+
expect(createMock).toHaveBeenLastCalledWith('CI', null);
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
it('keeps Create key disabled until the agents on offer have answered', async () => {
|
|
857
|
+
let answer!: (agents: (typeof OPS)[]) => void;
|
|
858
|
+
agentChoicesMock.mockReturnValue(new Promise((resolve) => (answer = resolve)));
|
|
859
|
+
const user = userEvent.setup();
|
|
860
|
+
mount(PUBLIC_URL);
|
|
861
|
+
await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
|
|
862
|
+
await user.type(screen.getByRole('textbox', { name: /Create an external API key/ }), 'CI');
|
|
863
|
+
const create = screen.getByRole('button', { name: 'Create key' });
|
|
864
|
+
expect(create).toBeDisabled();
|
|
865
|
+
await act(async () => answer([OPS]));
|
|
866
|
+
expect(create).toBeEnabled();
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
it('shows each key beside what it connects as', async () => {
|
|
870
|
+
listMock.mockResolvedValue([
|
|
871
|
+
{ id: 'k1', kind: 'key', label: 'Laptop', createdAt: Date.now(), lastUsedAt: null, revokedAt: null, revokedBy: null, agentPath: null },
|
|
872
|
+
{ id: 'k2', kind: 'key', label: 'Pipeline', createdAt: Date.now(), lastUsedAt: null, revokedAt: null, revokedBy: null, agentPath: 'Agents/ops.agent' },
|
|
873
|
+
]);
|
|
874
|
+
const user = userEvent.setup();
|
|
875
|
+
mount(PUBLIC_URL);
|
|
876
|
+
await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
|
|
877
|
+
await screen.findByText('Pipeline');
|
|
878
|
+
const rowOf = (label: string) => screen.getByText(label).closest('li') as HTMLElement;
|
|
879
|
+
expect(rowOf('Laptop')).toHaveTextContent('As Everything');
|
|
880
|
+
expect(rowOf('Pipeline')).toHaveTextContent('As ops');
|
|
881
|
+
});
|
|
882
|
+
});
|
|
883
|
+
|
|
795
884
|
describe('the one-click install link', () => {
|
|
796
885
|
it('offers Add to Claude on a reachable deployment', () => {
|
|
797
886
|
mount(PUBLIC_URL);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the toolbar module offers the other modules. A consumer outside the
|
|
3
|
+
* module imports from here, never from the files: they are the module's own
|
|
4
|
+
* layout and free to move. Export what another module needs; nothing more.
|
|
5
|
+
*/
|
|
6
|
+
export { COMMAND_MENU_SHORTCUT_LABEL, openCommandMenu } from './commands/command-menu';
|
|
@@ -6,13 +6,10 @@ import {
|
|
|
6
6
|
pluginOfPath,
|
|
7
7
|
type FileTreeEntry,
|
|
8
8
|
} from '@bevel-software/platform-shared';
|
|
9
|
-
import type { LibrarySkillSummary } from '../../library
|
|
10
|
-
import type {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import { pluginLabel, pluginNameForPath } from '../../library/utils/plugin-summary';
|
|
14
|
-
import { PERSONAL_PLUGIN_NAME } from '../../library/utils/personal-plugin';
|
|
15
|
-
import { displayFileName } from '../../workspace/utils/display-file-name';
|
|
9
|
+
import type { LibrarySkillSummary, PluginSummary } from '../../library';
|
|
10
|
+
import type { ToolSecrets } from '../../secrets-vault';
|
|
11
|
+
import { pathForPlugin, urlForLibraryItem, pluginLabel, pluginNameForPath, PERSONAL_PLUGIN_NAME } from '../../library';
|
|
12
|
+
import { displayFileName } from '../../workspace';
|
|
16
13
|
|
|
17
14
|
/**
|
|
18
15
|
* What the search palette lists, flattened out of the two places it reads:
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getOrCreateWorkspace,
|
|
12
12
|
readFile,
|
|
13
13
|
writeFile,
|
|
14
|
-
} from '../../workspace
|
|
14
|
+
} from '../../workspace';
|
|
15
15
|
|
|
16
16
|
// The caps, the file name and the comment rule come from
|
|
17
17
|
// `@bevel-software/platform-shared`, the same module the backend composer
|