@devries-cameron20 / composio Mirror · read-only
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 03:37 UTC

next
ts 60 lines 2.65 KB
Raw
1 import { beforeAll, expect, test } from 'bun:test';
2 import { z } from 'zod';
3 import { fetchPage } from './helpers';
4 import { assertPageFacts, corpusPages, parityPages } from '../fixtures/semantic-parity';
5
6 let corpus: Map<string, string>;
7 const markdown = new Map<string, string>();
8 beforeAll(async () => {
9 const response = await fetchPage('/llms-full.txt', { timeout: 30_000 });
10 expect(response.status, 'llms-full.txt status').toBe(200);
11 corpus = corpusPages(await response.text());
12 await Promise.all(parityPages.map(async page => {
13 const response = await fetchPage(`${page.url}.md`);
14 expect(response.status, `HTTP Markdown ${page.url} status`).toBe(200);
15 expect(response.headers.get('content-type')).toMatch(/text\/(plain|markdown)/);
16 markdown.set(page.url, await response.text());
17 }));
18 });
19
20 for (const page of parityPages) {
21 const surfaces = [{ name: 'HTTP Markdown', text: () => markdown.get(page.url) ?? '' }];
22 // Legacy REST pages are individually readable but intentionally absent from the current corpus.
23 if (page.url.startsWith('/reference/v3/')) {
24 test(`llms-full.txt excludes legacy page ${page.url}`, () => {
25 expect(corpus.has(page.url), `Legacy page leaked into llms-full.txt: ${page.url}`).toBe(false);
26 });
27 } else {
28 surfaces.push({ name: 'llms-full.txt', text: () => corpus.get(page.url) ?? '' });
29 }
30 for (const surface of surfaces) {
31 test(`${surface.name} semantic parity ${page.url}`, () => {
32 assertPageFacts(surface.text(), page, surface.name);
33 });
34 for (const [id, expected] of page.facts) {
35 test(`mutation catches ${surface.name} ${page.url} lost fact ${id}`, () => {
36 const text = surface.text();
37 assertPageFacts(text, page, surface.name);
38 const mutated = text.replace(/\s+/g, ' ')
39 .split(expected.replace(/\s+/g, ' ')).join('');
40 expect(() => assertPageFacts(mutated, page, surface.name)).toThrow(
41 `${surface.name} ${page.url} lost fact ${id}`,
42 );
43 });
44 }
45 }
46 }
47
48 test('local HTTP search retains section links alongside the added command and code corpus', async () => {
49 const query = encodeURIComponent('session has access to every toolkit');
50 const response = await fetchPage(`/api/search?query=${query}`);
51 expect(response.status).toBe(200);
52 const results = z.array(z.object({
53 type: z.string(), url: z.string(), content: z.string(),
54 })).parse(await response.json());
55 const destinations = results
56 .filter(result => result.type === 'text'
57 && result.content.replace(/<\/?mark>/g, '').includes('every toolkit'))
58 .map(result => result.url);
59 expect(destinations).toContain('/docs/configuring-sessions#creating-a-session');
60 });