Skip to content

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

test(experimental): type Eve approval contexts

jkomyno071bca0feb11
diff --git a/ts/packages/experimental/test/eve.test.ts b/ts/packages/experimental/test/eve.test.ts
index aec6b46dd..95f42f7a4 100644
--- a/ts/packages/experimental/test/eve.test.ts
+++ b/ts/packages/experimental/test/eve.test.ts
@@ -1,4 +1,5 @@
import type { ExecuteToolFn, Tool, ToolExecuteResponse } from '@composio/core';
+import type { ApprovalContext } from 'eve/tools';
import { describe, expect, it, vi } from 'vitest';
import {
EveProvider,
@@ -21,6 +22,23 @@ const ok = (data: Record<string, unknown> = {}): ToolExecuteResponse => ({
successful: true,
});
+const approvalContext = (
+ toolName: string,
+ toolInput: Record<string, unknown>
+): ApprovalContext<Record<string, unknown>> => ({
+ approvedTools: new Set<string>(),
+ callId: 'call-1',
+ getSandbox: vi.fn<ApprovalContext['getSandbox']>(),
+ getSkill: vi.fn<ApprovalContext['getSkill']>(),
+ session: {
+ id: 'eve-session',
+ auth: { current: null, initiator: null },
+ turn: { id: 'turn-1', sequence: 0 },
+ },
+ toolInput,
+ toolName,
+});
+
describe('EveProvider', () => {
it('identifies as the eve provider', () => {
expect(new EveProvider().name).toBe('eve');
@@ -122,11 +140,10 @@ describe('EveProvider', () => {
[tool('LOCAL_IMESSAGE_SEND'), tool('GITHUB_GET_REPOSITORY')],
vi.fn(async () => ok())
);
- const context = {
- approvedTools: new Set<string>(),
- toolInput: { to: '+15551234567', text: 'test' },
- toolName: 'LOCAL_IMESSAGE_SEND',
- };
+ const context = approvalContext('LOCAL_IMESSAGE_SEND', {
+ to: '+15551234567',
+ text: 'test',
+ });
const sendApproval = wrapped.LOCAL_IMESSAGE_SEND.approval;
const readApproval = wrapped.GITHUB_GET_REPOSITORY.approval;
@@ -135,8 +152,8 @@ describe('EveProvider', () => {
if (typeof sendApproval !== 'function' || typeof readApproval !== 'function') {
throw new TypeError('Expected Composio approval policies to be functions');
}
- expect(sendApproval(context as never)).toBe(true);
- expect(readApproval(context as never)).toBe(false);
+ expect(sendApproval(context)).toBe(true);
+ expect(readApproval(context)).toBe(false);
expect(needsApproval).toHaveBeenCalledWith(
expect.objectContaining({ slug: 'LOCAL_IMESSAGE_SEND' }),
context
@@ -158,18 +175,14 @@ describe('EveProvider', () => {
throw new TypeError('Expected the multi-execute approval policy to be a function');
}
expect(
- approval({
- approvedTools: new Set<string>(),
- callId: 'call-1',
- session: {} as never,
- toolInput: {
+ approval(
+ approvalContext('COMPOSIO_MULTI_EXECUTE_TOOL', {
tools: [
{ tool_slug: 'GMAIL_FETCH_EMAILS', arguments: {} },
{ tool_slug: 'LOCAL_IMESSAGE_SEND', arguments: { text: 'test' } },
],
- },
- toolName: 'COMPOSIO_MULTI_EXECUTE_TOOL',
- } as never)
+ })
+ )
).toBe(true);
});