Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { act } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { afterEach, describe, expect, it } from 'vitest';
/**
* What "Who can talk to your agent" starts on for a brand-new agent (CHOO-2137).
*
* An agent created in Switch Console answers its owner and the owner's own
* agents unless someone says otherwise, and that lives in one line of form
* state that nothing else would notice going wrong. An agent created open to
* everyone still works perfectly, which is exactly why this needs pinning
* rather than watching.
*/
import { useConfigureAgentForm } from '@renderer/features/locations/components/add-agent-modal/modes';
import { addressingModeOf } from '@shared/core/switch-servers/owner-policy';
let container: HTMLDivElement | null = null;
let root: Root | null = null;
afterEach(async () => {
if (root) await act(async () => root!.unmount());
container?.remove();
container = null;
root = null;
});
/** The mode the creation form starts on, read off the real hook. */
async function initialMode(): Promise<string> {
let seen = '';
function Probe() {
const form = useConfigureAgentForm(null);
seen = addressingModeOf(form.addressingPolicy);
return null;
}
container = document.createElement('div');
document.body.appendChild(container);
root = createRoot(container);
const client = new QueryClient({ defaultOptions: { queries: { retry: false, gcTime: 0 } } });
await act(async () =>
root!.render(
<QueryClientProvider client={client}>
<Probe />
</QueryClientProvider>
)
);
return seen;
}
describe('a new agent', () => {
it('starts answering its owner and the owner’s agents', async () => {
expect(await initialMode()).toBe('ownerAndAgents');
});
it('does not start open to everyone', async () => {
// Stated separately because this is the failure that looks like nothing:
// an agent anyone can drive behaves normally right up until someone else
// drives it.
expect(await initialMode()).not.toBe('anyone');
});
});