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

next
ts 34 lines 1.36 KB
Raw
1 import type { Tool } from '@composio/core';
2 import { expect, it, vi } from 'vitest';
3
4 // Lives in its own file: `vi.resetModules()` clears the module cache for every
5 // later dynamic import in the file, so this must not share one with suites that
6 // load eve's internals by path.
7 const DURABLE_TOOL_CALLBACKS = Symbol.for('eve:durable-dynamic-tool-callbacks');
8
9 const tool: Tool = {
10 slug: 'GITHUB_CREATE_ISSUE',
11 name: 'GITHUB_CREATE_ISSUE',
12 inputParameters: { type: 'object', properties: {} },
13 } as unknown as Tool;
14
15 // Each fresh module graph mints its own process token, the way a restarted
16 // process would.
17 const bindingFromFreshModule = async (): Promise<string> => {
18 vi.resetModules();
19 const { EveProvider } = await import('../src/eve');
20 const wrapped = new EveProvider().wrapTools([tool], vi.fn())[tool.slug];
21 const callbacks = (
22 wrapped as unknown as Record<symbol, { execute: { closure: { binding: string } } }>
23 )[DURABLE_TOOL_CALLBACKS];
24 return callbacks.execute.closure.binding;
25 };
26
27 it('never mints the same binding id in two processes', async () => {
28 const first = await bindingFromFreshModule();
29 const second = await bindingFromFreshModule();
30
31 expect(first).not.toBe(second);
32 // Each call re-evaluates the whole eve and @composio/core module graph from
33 // source, which alone can exceed vitest's 5s default on a cold, busy CI runner.
34 }, 30_000);