-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathinitialize.test.ts
More file actions
85 lines (78 loc) · 2.81 KB
/
Copy pathinitialize.test.ts
File metadata and controls
85 lines (78 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import { CodexAcpServer } from '../../CodexAcpServer';
import * as acp from '@agentclientprotocol/sdk';
import { createMockConnections } from './test-utils';
import {getCodexAuthMethods} from "../../CodexAuthMethod";
import {CodexAcpClient} from "../../CodexAcpClient";
import {CodexAppServerClient} from "../../CodexAppServerClient";
import packageJson from "../../../package.json";
describe('CodexACPAgent - initialize', () => {
let agent: CodexAcpServer;
let mockAcpConnection: any;
let mockCodexConnection: any;
beforeEach(() => {
const mocks = createMockConnections();
mockAcpConnection = mocks.mockAcpConnection;
mockCodexConnection = mocks.mockCodexConnection;
const codexAppServerClient = new CodexAppServerClient(mockCodexConnection);
const codexAcpClient = new CodexAcpClient(codexAppServerClient);
agent = new CodexAcpServer(mockAcpConnection, codexAcpClient);
});
afterEach(() => {
vi.clearAllMocks();
});
it('should return protocol version and agent capabilities', async () => {
const params: acp.InitializeRequest = {
protocolVersion: acp.PROTOCOL_VERSION
};
const result = await agent.initialize(params);
expect(result).toEqual({
protocolVersion: acp.PROTOCOL_VERSION,
agentInfo: {
name: packageJson.name,
title: "Codex",
version: packageJson.version,
},
agentCapabilities: {
auth: {
logout: {},
},
loadSession: true,
promptCapabilities: {
embeddedContext: true,
image: true
},
sessionCapabilities: {
resume: {},
list: {},
close: {},
delete: {},
},
mcpCapabilities: {
acp: false,
http: true,
sse: false,
},
},
authMethods: getCodexAuthMethods(),
});
});
it('should advertise gateway auth when the client opts into gateway auth metadata', async () => {
const params: acp.InitializeRequest = {
protocolVersion: acp.PROTOCOL_VERSION,
clientCapabilities: {
auth: {
_meta: {
gateway: true,
}
}
}
};
const result = await agent.initialize(params);
expect(result.authMethods).toEqual(expect.arrayContaining([
expect.objectContaining({
id: "gateway",
})
]));
});
});