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
jkomyno committed
Aug 28, 2026 at 15:35 UTC
071bca0feb11d005e01b7a0f1b38429e5084466b
1 file changed
+28
-15
ts/packages/experimental/test/eve.test.ts
+28
-15
@@ -1,4 +1,5 @@
1
import type { ExecuteToolFn, Tool, ToolExecuteResponse } from '@composio/core';
2
+import type { ApprovalContext } from 'eve/tools';
3
import { describe, expect, it, vi } from 'vitest';
4
import {
5
EveProvider,
@@ -21,6 +22,23 @@ const ok = (data: Record<string, unknown> = {}): ToolExecuteResponse => ({
22
successful: true,
23
});
24
25
+const approvalContext = (
26
+ toolName: string,
27
+ toolInput: Record<string, unknown>
28
+): ApprovalContext<Record<string, unknown>> => ({
29
+ approvedTools: new Set<string>(),
30
+ callId: 'call-1',
31
+ getSandbox: vi.fn<ApprovalContext['getSandbox']>(),
32
+ getSkill: vi.fn<ApprovalContext['getSkill']>(),
33
+ session: {
34
+ id: 'eve-session',
35
+ auth: { current: null, initiator: null },
36
+ turn: { id: 'turn-1', sequence: 0 },
37
+ },
38
+ toolInput,
39
+ toolName,
40
+});
41
+
42
describe('EveProvider', () => {
43
it('identifies as the eve provider', () => {
44
expect(new EveProvider().name).toBe('eve');
@@ -122,11 +140,10 @@ describe('EveProvider', () => {
140
[tool('LOCAL_IMESSAGE_SEND'), tool('GITHUB_GET_REPOSITORY')],
141
vi.fn(async () => ok())
142
);
125
- const context = {
126
- approvedTools: new Set<string>(),
127
- toolInput: { to: '+15551234567', text: 'test' },
128
- toolName: 'LOCAL_IMESSAGE_SEND',
129
- };
143
+ const context = approvalContext('LOCAL_IMESSAGE_SEND', {
144
+ to: '+15551234567',
145
+ text: 'test',
146
+ });
147
148
const sendApproval = wrapped.LOCAL_IMESSAGE_SEND.approval;
149
const readApproval = wrapped.GITHUB_GET_REPOSITORY.approval;
@@ -135,8 +152,8 @@ describe('EveProvider', () => {
152
if (typeof sendApproval !== 'function' || typeof readApproval !== 'function') {
153
throw new TypeError('Expected Composio approval policies to be functions');
154
}
138
- expect(sendApproval(context as never)).toBe(true);
139
- expect(readApproval(context as never)).toBe(false);
155
+ expect(sendApproval(context)).toBe(true);
156
+ expect(readApproval(context)).toBe(false);
157
expect(needsApproval).toHaveBeenCalledWith(
158
expect.objectContaining({ slug: 'LOCAL_IMESSAGE_SEND' }),
159
context
@@ -158,18 +175,14 @@ describe('EveProvider', () => {
175
throw new TypeError('Expected the multi-execute approval policy to be a function');
176
}
177
expect(
161
- approval({
162
- approvedTools: new Set<string>(),
163
- callId: 'call-1',
164
- session: {} as never,
165
- toolInput: {
178
+ approval(
179
+ approvalContext('COMPOSIO_MULTI_EXECUTE_TOOL', {
180
tools: [
181
{ tool_slug: 'GMAIL_FETCH_EMAILS', arguments: {} },
182
{ tool_slug: 'LOCAL_IMESSAGE_SEND', arguments: { text: 'test' } },
183
],
170
- },
171
- toolName: 'COMPOSIO_MULTI_EXECUTE_TOOL',
172
- } as never)
184
+ })
185
+ )
186
).toBe(true);
187
});
188