@cognigy/rest-api-client 2026.1.0 → 2026.2.0-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +15 -0
  3. package/build/apigroups/InsightsAPIGroup_2_1.js +27 -0
  4. package/build/apigroups/ResourcesAPIGroup_2_0.js +134 -383
  5. package/build/apigroups/SimulationAPIGroup_2_0.js +24 -23
  6. package/build/apigroups/aiAgentsV2/agent.js +3 -0
  7. package/build/apigroups/aiAgentsV2/agentAPI.js +38 -0
  8. package/build/apigroups/aiAgentsV2/agentPersona.js +3 -0
  9. package/build/apigroups/aiAgentsV2/agentPersonaAPI.js +38 -0
  10. package/build/apigroups/aiAgentsV2/tool.js +3 -0
  11. package/build/apigroups/aiAgentsV2/toolAPI.js +35 -0
  12. package/build/apigroups/aiAgentsV2/toolDescriptor.js +3 -0
  13. package/build/apigroups/aiAgentsV2/toolDescriptorAPI.js +13 -0
  14. package/build/apigroups/index.js +3 -1
  15. package/build/shared/charts/descriptors/connectionNodes/smtp/index.js +5 -1
  16. package/build/shared/charts/descriptors/connectionNodes/smtp/oAuth2ClientCredentialsConnection.js +15 -0
  17. package/build/shared/charts/descriptors/connectionNodes/smtp/oAuth2JwtBearerConnection.js +13 -0
  18. package/build/shared/charts/descriptors/connectionNodes/smtp/sendEmail.js +54 -10
  19. package/build/shared/charts/descriptors/connectionNodes/speechProviders/elevenlabsSpeechProviderConnection.js +52 -0
  20. package/build/shared/charts/descriptors/connectionNodes/speechProviders/index.js +8 -7
  21. package/build/shared/charts/descriptors/index.js +4 -0
  22. package/build/shared/charts/descriptors/message/question/question.js +249 -59
  23. package/build/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +17 -15
  24. package/build/shared/charts/descriptors/service/aiAgent/aiAgentJobCallMCPTool.js +6 -4
  25. package/build/shared/charts/descriptors/service/aiAgent/aiAgentJobMCPTool.js +57 -1
  26. package/build/shared/charts/descriptors/service/aiAgent/helpers/createToolDefinitions.js +7 -0
  27. package/build/shared/charts/descriptors/service/aiAgentV2.js +89 -0
  28. package/build/shared/charts/descriptors/service/index.js +5 -1
  29. package/build/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +15 -13
  30. package/build/shared/charts/descriptors/service/llmPrompt/llmPromptMCPTool.js +57 -1
  31. package/build/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +67 -13
  32. package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +25 -3
  33. package/build/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +65 -0
  34. package/build/shared/charts/descriptors/voicegateway2/nodes/play.js +7 -0
  35. package/build/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +137 -1
  36. package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +135 -2
  37. package/build/shared/errors/ErrorCode.js +2 -1
  38. package/build/shared/errors/ErrorCollection.js +1 -0
  39. package/build/shared/helper/BaseContext.js +1 -1
  40. package/build/shared/interfaces/generativeAI/IGenerativeAIModels.js +1 -0
  41. package/build/shared/interfaces/handover.js +1 -0
  42. package/build/shared/interfaces/handoverProviders.js +0 -1
  43. package/build/shared/interfaces/messageAPI/endpoints.js +3 -0
  44. package/build/shared/interfaces/resources/IAuditEvent.js +1 -0
  45. package/build/shared/interfaces/resources/knowledgeStore/IKnowledgeSource.js +1 -1
  46. package/build/shared/interfaces/resources/settings/IAudioPreviewSettings.js +7 -1
  47. package/build/shared/interfaces/restAPI/analytics/IDeleteConversationsBySessionRest_2_1.js +3 -0
  48. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IRunKnowledgeConnectorRest_2_0.js +3 -0
  49. package/build/shared/interfaces/restAPI/simulation/simulationOverview/IGetSimulationOverviewMetricsRestData_2_0.js +3 -0
  50. package/build/shared/interfaces/restAPI/simulation/simulationOverview/IGetSuccessRateTrendRestData_2_0.js +3 -0
  51. package/build/shared/interfaces/restAPI/simulation/simulationOverview/IGetUpcomingScheduledRunsRestData_2_0.js +3 -0
  52. package/build/shared/interfaces/security/ISessionScope.js +3 -0
  53. package/build/spec/aiAgentV2.spec.js +564 -0
  54. package/dist/esm/apigroups/InsightsAPIGroup_2_1.js +13 -0
  55. package/dist/esm/apigroups/ResourcesAPIGroup_2_0.js +134 -383
  56. package/dist/esm/apigroups/SimulationAPIGroup_2_0.js +24 -23
  57. package/dist/esm/apigroups/aiAgentsV2/agent.js +2 -0
  58. package/dist/esm/apigroups/aiAgentsV2/agentAPI.js +24 -0
  59. package/dist/esm/apigroups/aiAgentsV2/agentPersona.js +2 -0
  60. package/dist/esm/apigroups/aiAgentsV2/agentPersonaAPI.js +24 -0
  61. package/dist/esm/apigroups/aiAgentsV2/aiAgentV2API.js +2 -0
  62. package/dist/esm/apigroups/aiAgentsV2/tool.js +2 -0
  63. package/dist/esm/apigroups/aiAgentsV2/toolAPI.js +21 -0
  64. package/dist/esm/apigroups/aiAgentsV2/toolDescriptor.js +2 -0
  65. package/dist/esm/apigroups/aiAgentsV2/toolDescriptorAPI.js +9 -0
  66. package/dist/esm/apigroups/index.js +1 -0
  67. package/dist/esm/shared/charts/descriptors/connectionNodes/smtp/index.js +5 -1
  68. package/dist/esm/shared/charts/descriptors/connectionNodes/smtp/oAuth2ClientCredentialsConnection.js +12 -0
  69. package/dist/esm/shared/charts/descriptors/connectionNodes/smtp/oAuth2JwtBearerConnection.js +10 -0
  70. package/dist/esm/shared/charts/descriptors/connectionNodes/smtp/sendEmail.js +54 -10
  71. package/dist/esm/shared/charts/descriptors/connectionNodes/speechProviders/elevenlabsSpeechProviderConnection.js +49 -0
  72. package/dist/esm/shared/charts/descriptors/connectionNodes/speechProviders/index.js +3 -3
  73. package/dist/esm/shared/charts/descriptors/index.js +5 -1
  74. package/dist/esm/shared/charts/descriptors/message/question/question.js +249 -59
  75. package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +17 -15
  76. package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJobCallMCPTool.js +6 -4
  77. package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJobMCPTool.js +56 -0
  78. package/dist/esm/shared/charts/descriptors/service/aiAgent/helpers/createToolDefinitions.js +7 -0
  79. package/dist/esm/shared/charts/descriptors/service/aiAgentV2.js +87 -0
  80. package/dist/esm/shared/charts/descriptors/service/index.js +2 -0
  81. package/dist/esm/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +22 -20
  82. package/dist/esm/shared/charts/descriptors/service/llmPrompt/llmPromptMCPTool.js +56 -0
  83. package/dist/esm/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +67 -13
  84. package/dist/esm/shared/charts/descriptors/voice/mappers/transfer.mapper.js +25 -3
  85. package/dist/esm/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +65 -0
  86. package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/play.js +7 -0
  87. package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +137 -1
  88. package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/transfer.js +135 -2
  89. package/dist/esm/shared/errors/ErrorCode.js +2 -1
  90. package/dist/esm/shared/errors/ErrorCollection.js +1 -0
  91. package/dist/esm/shared/helper/BaseContext.js +1 -1
  92. package/dist/esm/shared/interfaces/generativeAI/IGenerativeAIModels.js +1 -0
  93. package/dist/esm/shared/interfaces/handover.js +1 -0
  94. package/dist/esm/shared/interfaces/handoverProviders.js +0 -1
  95. package/dist/esm/shared/interfaces/messageAPI/endpoints.js +3 -0
  96. package/dist/esm/shared/interfaces/resources/IAuditEvent.js +1 -0
  97. package/dist/esm/shared/interfaces/resources/knowledgeStore/IKnowledgeSource.js +1 -1
  98. package/dist/esm/shared/interfaces/resources/settings/IAudioPreviewSettings.js +7 -1
  99. package/dist/esm/shared/interfaces/restAPI/analytics/IDeleteConversationsBySessionRest_2_1.js +2 -0
  100. package/dist/esm/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/connector/IRunKnowledgeConnectorRest_2_0.js +2 -0
  101. package/dist/esm/shared/interfaces/restAPI/simulation/simulationOverview/IGetSimulationOverviewMetricsRestData_2_0.js +2 -0
  102. package/dist/esm/shared/interfaces/restAPI/simulation/simulationOverview/IGetSuccessRateTrendRestData_2_0.js +2 -0
  103. package/dist/esm/shared/interfaces/restAPI/simulation/simulationOverview/IGetUpcomingScheduledRunsRestData_2_0.js +2 -0
  104. package/dist/esm/shared/interfaces/security/ISessionScope.js +2 -0
  105. package/dist/esm/spec/aiAgentV2.spec.js +563 -0
  106. package/package.json +6 -3
  107. package/types/index.d.ts +667 -30
@@ -0,0 +1,563 @@
1
+ import { __awaiter } from "tslib";
2
+ import { describe, it, before } from "node:test";
3
+ import * as assert from "node:assert";
4
+ import { RestAPIClient } from "../RestAPIClient";
5
+ import { ResourceNotFoundError } from "../shared/errors";
6
+ describe("AI Agents V2 API", () => {
7
+ let client;
8
+ before(() => {
9
+ const apiBaseUrl = process.env.REST_API_CLIENT_E2E_TESTS_API_BASE_URL || "https://api-benni-test.cognigy.dev";
10
+ client = new RestAPIClient({
11
+ baseUrl: apiBaseUrl
12
+ });
13
+ client.setCredentials({
14
+ type: "ApiKey",
15
+ apiKey: process.env.REST_API_CLIENT_E2E_TESTS_API_KEY || ""
16
+ });
17
+ });
18
+ const validLocaleReferenceId = "ac919341-77c7-484f-86b9-f59b0759f1f8";
19
+ const validProjectId = "6960e2eaac2b03e5485f3d65";
20
+ const validAgentPersonaReferenceId = "b2199b60-631f-4e4d-88d6-7149ce3aee78";
21
+ describe("Agents", () => {
22
+ it("creates a new Agent", () => __awaiter(void 0, void 0, void 0, function* () {
23
+ const agent = yield client.createAgent({
24
+ name: "Customer Support Agent",
25
+ description: "Accepts support requests from customers and creates ticket in Zendesk.",
26
+ instructions: "You answer customer support requests in a friendly way. You can create tickets in our ticketing portal using the createTicket tool.",
27
+ localeReferenceId: validLocaleReferenceId,
28
+ projectId: validProjectId,
29
+ personaReferenceId: validAgentPersonaReferenceId,
30
+ toolReferenceIds: [],
31
+ knowledge: {
32
+ context: "This is some always available context for the agent.",
33
+ ragType: "cognigy",
34
+ ragMode: "never",
35
+ ragParameters: {}
36
+ }
37
+ });
38
+ assert.ok(agent, "Created agent is undefined");
39
+ assert.equal(Object.keys(agent).length, 15);
40
+ assert.ok(agent.id, "Agent ID is missing");
41
+ assert.ok(agent.referenceId, "Agent referenceId is missing");
42
+ assert.equal(agent.localeReferenceId, validLocaleReferenceId, "Agent localeReferenceId does not match");
43
+ assert.equal(agent.name, "Customer Support Agent", "Agent name does not match");
44
+ assert.equal(agent.description, "Accepts support requests from customers and creates ticket in Zendesk.", "Agent description does not match");
45
+ assert.equal(agent.instructions, "You answer customer support requests in a friendly way. You can create tickets in our ticketing portal using the createTicket tool.", "Agent instructions do not match");
46
+ assert.equal(agent.personaReferenceId, validAgentPersonaReferenceId, "Agent personaReferenceId does not match");
47
+ assert.deepStrictEqual(agent.toolReferenceIds, [], "Agent toolReferenceIds do not match");
48
+ assert.deepStrictEqual(agent.knowledge, {
49
+ context: "This is some always available context for the agent.",
50
+ ragType: "cognigy",
51
+ ragMode: "never",
52
+ ragParameters: {}
53
+ }, "Agent knowledge does not match");
54
+ assert.equal(agent.projectId, validProjectId, "Agent projectId does not match");
55
+ assert.ok(agent.organisationId, "Agent organisationId is missing");
56
+ assert.ok(agent.createdBy, "Agent createdBy is missing");
57
+ assert.ok(agent.createdAt, "Agent createdAt is missing");
58
+ assert.ok(agent.lastChangedBy, "Agent lastChangedBy is missing");
59
+ assert.ok(agent.lastChangedAt, "Agent lastChangedAt is missing");
60
+ }));
61
+ it("creates a new Agent and then reads its properties back", () => __awaiter(void 0, void 0, void 0, function* () {
62
+ const agent = yield client.createAgent({
63
+ name: "Customer Support Agent",
64
+ description: "Accepts support requests from customers and creates ticket in Zendesk.",
65
+ instructions: "You answer customer support requests in a friendly way. You can create tickets in our ticketing portal using the createTicket tool.",
66
+ localeReferenceId: validLocaleReferenceId,
67
+ projectId: validProjectId,
68
+ personaReferenceId: validAgentPersonaReferenceId,
69
+ toolReferenceIds: [],
70
+ knowledge: {
71
+ context: "This is some always available context for the agent.",
72
+ ragType: "cognigy",
73
+ ragMode: "never",
74
+ ragParameters: {}
75
+ }
76
+ });
77
+ const fetchedAgent = yield client.readAgent({
78
+ agentId: agent.id
79
+ });
80
+ assert.ok(fetchedAgent);
81
+ assert.equal(Object.keys(fetchedAgent).length, 15, "Fetched agent has incorrect number of properties");
82
+ assert.equal(fetchedAgent.id, agent.id, "Fetched agent ID does not match");
83
+ assert.equal(fetchedAgent.referenceId, agent.referenceId, "Fetched agent referenceId does not match");
84
+ assert.equal(fetchedAgent.localeReferenceId, agent.localeReferenceId, "Fetched agent localeReferenceId does not match");
85
+ assert.equal(fetchedAgent.name, agent.name, "Fetched agent name does not match");
86
+ assert.equal(fetchedAgent.description, agent.description, "Fetched agent description does not match");
87
+ assert.equal(fetchedAgent.instructions, agent.instructions, "Fetched agent instructions do not match");
88
+ assert.equal(fetchedAgent.personaReferenceId, agent.personaReferenceId, "Fetched agent personaReferenceId does not match");
89
+ assert.deepStrictEqual(fetchedAgent.toolReferenceIds, agent.toolReferenceIds, "Fetched agent toolReferenceIds do not match");
90
+ assert.deepStrictEqual(fetchedAgent.knowledge, agent.knowledge, "Fetched agent knowledge does not match");
91
+ assert.deepStrictEqual(fetchedAgent.knowledge, agent.knowledge, "Fetched agent knowledge does not match");
92
+ assert.equal(fetchedAgent.projectId, agent.projectId, "Fetched agent projectId does not match");
93
+ assert.equal(fetchedAgent.organisationId, agent.organisationId, "Fetched agent organisationId does not match");
94
+ assert.equal(fetchedAgent.createdBy, agent.createdBy, "Fetched agent createdBy does not match");
95
+ assert.equal(fetchedAgent.createdAt, agent.createdAt, "Fetched agent createdAt does not match");
96
+ assert.equal(fetchedAgent.lastChangedBy, agent.lastChangedBy, "Fetched agent lastChangedBy does not match");
97
+ assert.equal(fetchedAgent.lastChangedAt, agent.lastChangedAt, "Fetched agent lastChangedAt does not match");
98
+ }));
99
+ it("creates different Agents and then lists them", () => __awaiter(void 0, void 0, void 0, function* () {
100
+ yield client.createAgent({
101
+ name: "Support Agent",
102
+ description: "Accepts support requests from customers and creates ticket in Zendesk.",
103
+ instructions: "You answer customer support requests in a friendly way. You can create tickets in our ticketing portal using the createTicket tool.",
104
+ localeReferenceId: validLocaleReferenceId,
105
+ projectId: validProjectId,
106
+ personaReferenceId: validAgentPersonaReferenceId,
107
+ toolReferenceIds: [],
108
+ knowledge: {
109
+ context: "We never talk about prices of our products via our helpdesk.",
110
+ ragType: "cognigy",
111
+ ragMode: "never",
112
+ ragParameters: {}
113
+ }
114
+ });
115
+ yield client.createAgent({
116
+ name: "Flight Status Agent",
117
+ description: "Provides information about flight statuses to customers.",
118
+ instructions: "You provide up-to-date flight status information based on customer queries.",
119
+ localeReferenceId: validLocaleReferenceId,
120
+ projectId: validProjectId,
121
+ personaReferenceId: validAgentPersonaReferenceId,
122
+ toolReferenceIds: [],
123
+ knowledge: {
124
+ context: "We never talk about prices of our products via our helpdesk.",
125
+ ragType: "cognigy",
126
+ ragMode: "never",
127
+ ragParameters: {}
128
+ }
129
+ });
130
+ const agentList = yield client.indexAgents({}); // filter based on actual projectId
131
+ assert.ok(agentList.items);
132
+ assert.ok(agentList.nextCursor);
133
+ assert.ok(agentList.previousCursor);
134
+ assert.ok(agentList.total);
135
+ agentList.items.every(agent => {
136
+ assert.equal(Object.keys(agent).length, 15);
137
+ assert.ok(agent.id, "Agent ID is missing");
138
+ assert.ok(agent.referenceId, "Agent referenceId is missing");
139
+ assert.equal(agent.localeReferenceId, validLocaleReferenceId, "Agent localeReferenceId does not match");
140
+ assert.ok(agent.name, "Agent name is missing");
141
+ assert.ok(agent.description, "Agent description is missing");
142
+ assert.ok(agent.instructions, "Agent instructions are missing");
143
+ assert.equal(agent.personaReferenceId, validAgentPersonaReferenceId, "Agent personaReferenceId does not match");
144
+ assert.ok(agent.toolReferenceIds, "Agent toolReferenceIds are missing");
145
+ assert.ok(agent.knowledge, "Agent knowledge is missing");
146
+ assert.equal(agent.projectId, validProjectId, "Agent projectId does not match");
147
+ assert.ok(agent.organisationId, "Agent organisationId is missing");
148
+ assert.ok(agent.createdBy, "Agent createdBy is missing");
149
+ assert.ok(agent.createdAt, "Agent createdAt is missing");
150
+ assert.ok(agent.lastChangedBy, "Agent lastChangedBy is missing");
151
+ assert.ok(agent.lastChangedAt, "Agent lastChangedAt is missing");
152
+ });
153
+ }));
154
+ it("creates an Agent and then deletes it", () => __awaiter(void 0, void 0, void 0, function* () {
155
+ const agent = yield client.createAgent({
156
+ name: "Customer Support Agent",
157
+ description: "Accepts support requests from customers and creates ticket in Zendesk.",
158
+ instructions: "You answer customer support requests in a friendly way. You can create tickets in our ticketing portal using the createTicket tool.",
159
+ localeReferenceId: validLocaleReferenceId,
160
+ projectId: validProjectId,
161
+ personaReferenceId: validAgentPersonaReferenceId,
162
+ toolReferenceIds: [],
163
+ knowledge: {
164
+ context: "This is some always available context for the agent.",
165
+ ragType: "cognigy",
166
+ ragMode: "never",
167
+ ragParameters: {}
168
+ }
169
+ });
170
+ assert.ok(agent, "Created agent is undefined");
171
+ yield client.deleteAgent({
172
+ agentId: agent.id
173
+ });
174
+ // verify that the agent is gone
175
+ assert.rejects(() => client.readAgent({ agentId: agent.id }), ResourceNotFoundError);
176
+ }));
177
+ });
178
+ describe("Agent Personas", () => {
179
+ it("creates a new Agent Persona", () => __awaiter(void 0, void 0, void 0, function* () {
180
+ const agentPersona = yield client.createAgentPersona({
181
+ name: "Helpful Assistant",
182
+ description: "A friendly and helpful assistant persona.",
183
+ image: "https://example.com/images/helpful-assistant.png",
184
+ imageOptimizedFormat: true,
185
+ speakingStyle: {
186
+ completeness: "concise",
187
+ formality: "formal",
188
+ },
189
+ voiceConfig: {
190
+ ttsModel: "neural",
191
+ ttsVendor: "aws",
192
+ ttsVoice: "Joanna",
193
+ ttsLabel: "german",
194
+ ttsLanguage: "de-DE",
195
+ ttsDisableCache: false
196
+ },
197
+ projectId: validProjectId
198
+ });
199
+ assert.ok(agentPersona);
200
+ assert.equal(Object.keys(agentPersona).length, 14, "Agent Persona has incorrect number of properties");
201
+ assert.ok(agentPersona.id, "Agent Persona ID is missing");
202
+ assert.ok(agentPersona.referenceId, "Agent Persona referenceId is missing");
203
+ assert.equal(agentPersona.name, "Helpful Assistant", "Agent Persona name does not match");
204
+ assert.equal(agentPersona.image, "https://example.com/images/helpful-assistant.png", "Agent Persona image does not match");
205
+ assert.equal(agentPersona.imageOptimizedFormat, true, "Agent Persona imageOptimizedFormat does not match");
206
+ assert.equal(agentPersona.description, "A friendly and helpful assistant persona.", "Agent Persona description does not match");
207
+ assert.deepStrictEqual(agentPersona.speakingStyle, {
208
+ completeness: "concise",
209
+ formality: "formal",
210
+ }, "Agent Persona speakingStyle does not match");
211
+ assert.deepStrictEqual(agentPersona.voiceConfig, {
212
+ ttsModel: "neural",
213
+ ttsVendor: "aws",
214
+ ttsVoice: "Joanna",
215
+ ttsLabel: "german",
216
+ ttsLanguage: "de-DE",
217
+ ttsDisableCache: false
218
+ }, "Agent Persona voiceConfig does not match");
219
+ assert.equal(agentPersona.projectId, validProjectId, "Agent Persona projectId does not match");
220
+ assert.ok(agentPersona.organisationId);
221
+ assert.ok(agentPersona.createdBy, "Agent Persona createdBy is missing");
222
+ assert.ok(agentPersona.createdAt, "Agent Persona createdAt is missing");
223
+ assert.ok(agentPersona.lastChangedBy, "Agent Persona lastChangedBy is missing");
224
+ assert.ok(agentPersona.lastChangedAt, "Agent Persona lastChangedAt is missing");
225
+ }));
226
+ it("creates a new Agent Persona and then reads its properties back", () => __awaiter(void 0, void 0, void 0, function* () {
227
+ const agentPersona = yield client.createAgentPersona({
228
+ name: "Helpful Assistant",
229
+ description: "A friendly and helpful assistant persona.",
230
+ image: "https://example.com/images/helpful-assistant.png",
231
+ imageOptimizedFormat: true,
232
+ speakingStyle: {
233
+ completeness: "concise",
234
+ formality: "formal",
235
+ },
236
+ voiceConfig: {
237
+ ttsModel: "neural",
238
+ ttsVendor: "aws",
239
+ ttsVoice: "Joanna",
240
+ ttsLabel: "german",
241
+ ttsLanguage: "de-DE",
242
+ ttsDisableCache: false
243
+ },
244
+ projectId: validProjectId
245
+ });
246
+ const fetchedAgentPersona = yield client.readAgentPersona({
247
+ agentPersonaId: agentPersona.id
248
+ });
249
+ assert.deepStrictEqual(fetchedAgentPersona, agentPersona, "Fetched Agent Persona does not match the created one");
250
+ }));
251
+ it("creates different Agent Personas and then lists them", () => __awaiter(void 0, void 0, void 0, function* () {
252
+ yield client.createAgentPersona({
253
+ name: "Friendly Guide",
254
+ description: "A friendly guide persona.",
255
+ image: "https://example.com/images/friendly-guide.png",
256
+ imageOptimizedFormat: true,
257
+ speakingStyle: {
258
+ completeness: "detailed",
259
+ formality: "informal",
260
+ },
261
+ voiceConfig: {
262
+ ttsModel: "neural",
263
+ ttsVendor: "aws",
264
+ ttsVoice: "Matthew",
265
+ ttsLabel: "english",
266
+ ttsLanguage: "en-US",
267
+ ttsDisableCache: false
268
+ },
269
+ projectId: validProjectId
270
+ });
271
+ yield client.createAgentPersona({
272
+ name: "Professional Advisor",
273
+ description: "A professional advisor persona.",
274
+ image: "https://example.com/images/professional-advisor.png",
275
+ imageOptimizedFormat: false,
276
+ speakingStyle: {
277
+ completeness: "concise",
278
+ formality: "formal",
279
+ },
280
+ voiceConfig: {
281
+ ttsModel: "standard",
282
+ ttsVendor: "google",
283
+ ttsVoice: "en-US-Wavenet-D",
284
+ ttsLabel: "english",
285
+ ttsLanguage: "en-US",
286
+ ttsDisableCache: false
287
+ },
288
+ projectId: validProjectId
289
+ });
290
+ const agentPersonas = yield client.indexAgentPersonas({});
291
+ assert.ok(agentPersonas.items);
292
+ assert.ok(agentPersonas.nextCursor);
293
+ assert.ok(agentPersonas.previousCursor);
294
+ assert.ok(agentPersonas.total);
295
+ agentPersonas.items.every(agentPersona => {
296
+ assert.equal(Object.keys(agentPersona).length, 14);
297
+ assert.ok(agentPersona.id, "Agent Persona ID is missing");
298
+ assert.ok(agentPersona.referenceId, "Agent Persona referenceId is missing");
299
+ assert.ok(agentPersona.name, "Agent Persona name is missing");
300
+ assert.ok(agentPersona.description, "Agent Persona description is missing");
301
+ assert.ok(agentPersona.image, "Agent Persona image is missing");
302
+ assert.ok(typeof agentPersona.imageOptimizedFormat === "boolean", "Agent Persona imageOptimizedFormat is missing");
303
+ assert.ok(agentPersona.speakingStyle, "Agent Persona speakingStyle is missing");
304
+ assert.ok(agentPersona.voiceConfig, "Agent Persona voiceConfig is missing");
305
+ assert.ok(agentPersona.projectId, "Agent Persona projectId is missing");
306
+ assert.ok(agentPersona.organisationId, "Agent Persona organisationId is missing");
307
+ assert.ok(agentPersona.createdBy, "Agent Persona createdBy is missing");
308
+ assert.ok(agentPersona.createdAt, "Agent Persona createdAt is missing");
309
+ assert.ok(agentPersona.lastChangedBy, "Agent Persona lastChangedBy is missing");
310
+ assert.ok(agentPersona.lastChangedAt, "Agent Persona lastChangedAt is missing");
311
+ });
312
+ }));
313
+ it("creates an Agent Persona and updates it multiple times", () => __awaiter(void 0, void 0, void 0, function* () {
314
+ let agentPersona = yield client.createAgentPersona({
315
+ name: "Temporary Persona",
316
+ description: "This persona will be updated.",
317
+ image: "https://example.com/images/temporary-persona.png",
318
+ imageOptimizedFormat: false,
319
+ speakingStyle: {
320
+ completeness: "concise",
321
+ formality: "informal",
322
+ },
323
+ voiceConfig: {
324
+ ttsModel: "standard",
325
+ ttsVendor: "google",
326
+ ttsVoice: "en-US-Wavenet-B",
327
+ ttsLabel: "english",
328
+ ttsLanguage: "en-US",
329
+ ttsDisableCache: false
330
+ },
331
+ projectId: validProjectId
332
+ });
333
+ assert.ok(agentPersona);
334
+ agentPersona = yield client.updateAgentPersona({
335
+ agentPersonaId: agentPersona.id,
336
+ name: "Updated Persona Name",
337
+ description: "The description has been updated.",
338
+ image: "https://example.com/images/updated-persona.png",
339
+ imageOptimizedFormat: true,
340
+ speakingStyle: {
341
+ completeness: "detailed",
342
+ formality: "formal",
343
+ },
344
+ voiceConfig: {
345
+ ttsModel: "neural",
346
+ ttsVendor: "aws",
347
+ ttsVoice: "Joanna",
348
+ ttsLabel: "german",
349
+ ttsLanguage: "de-DE",
350
+ ttsDisableCache: false
351
+ }
352
+ });
353
+ assert.equal(agentPersona.name, "Updated Persona Name", "Agent Persona name was not updated correctly.");
354
+ assert.equal(agentPersona.description, "The description has been updated.", "Agent Persona description was not updated correctly.");
355
+ assert.equal(agentPersona.image, "https://example.com/images/updated-persona.png", "Agent Persona image was not updated correctly.");
356
+ assert.equal(agentPersona.imageOptimizedFormat, true);
357
+ assert.deepStrictEqual(agentPersona.speakingStyle, {
358
+ completeness: "detailed",
359
+ formality: "formal",
360
+ }, "Agent Persona speakingStyle was not updated correctly.");
361
+ assert.deepStrictEqual(agentPersona.voiceConfig, {
362
+ ttsModel: "neural",
363
+ ttsVendor: "aws",
364
+ ttsVoice: "Joanna",
365
+ ttsLabel: "german",
366
+ ttsLanguage: "de-DE",
367
+ ttsDisableCache: false
368
+ }, "Agent Persona voiceConfig was not updated correctly.");
369
+ }));
370
+ it("creates an Agent Persona and then deletes it", () => __awaiter(void 0, void 0, void 0, function* () {
371
+ const agentPersona = yield client.createAgentPersona({
372
+ name: "Temporary Persona",
373
+ description: "This persona will be deleted.",
374
+ image: "https://example.com/images/temporary-persona.png",
375
+ imageOptimizedFormat: false,
376
+ speakingStyle: {
377
+ completeness: "concise",
378
+ formality: "informal",
379
+ },
380
+ voiceConfig: {
381
+ ttsModel: "standard",
382
+ ttsVendor: "google",
383
+ ttsVoice: "en-US-Wavenet-B",
384
+ ttsLabel: "english",
385
+ ttsLanguage: "en-US",
386
+ ttsDisableCache: false
387
+ },
388
+ projectId: validProjectId
389
+ });
390
+ assert.ok(agentPersona);
391
+ yield client.deleteAgentPersona({
392
+ agentPersonaId: agentPersona.id
393
+ });
394
+ assert.rejects(() => client.readAgentPersona({ agentPersonaId: agentPersona.id }), ResourceNotFoundError);
395
+ }));
396
+ });
397
+ describe("Tool Descriptors", () => {
398
+ it("lists all available Tool Descriptors", () => __awaiter(void 0, void 0, void 0, function* () {
399
+ const toolDescriptors = yield client.indexToolDescriptors({});
400
+ assert.ok(toolDescriptors);
401
+ assert.ok(toolDescriptors.items);
402
+ const [firstToolDescriptor] = toolDescriptors.items;
403
+ assert.ok(Object.keys(firstToolDescriptor).length === 8);
404
+ assert.ok(firstToolDescriptor.id, "Tool Descriptor ID is missing");
405
+ assert.ok(firstToolDescriptor.type, "Tool Descriptor type is missing");
406
+ assert.ok(firstToolDescriptor.extension, "Tool Descriptor extension is missing");
407
+ assert.ok(firstToolDescriptor.imageUrl, "Tool Descriptor imageUrl is missing");
408
+ assert.ok(firstToolDescriptor.defaultLabel, "Tool Descriptor defaultLabel is missing");
409
+ assert.ok(firstToolDescriptor.defaultParameters, "Tool Descriptor defaultParameters is missing");
410
+ assert.ok(firstToolDescriptor.projectId, "Tool Descriptor projectId is missing");
411
+ assert.ok(firstToolDescriptor.organisationId, "Tool Descriptor organisationId is missing");
412
+ }));
413
+ });
414
+ describe("Tools", () => {
415
+ it("creates a new Tool", () => __awaiter(void 0, void 0, void 0, function* () {
416
+ const tool = yield client.createTool({
417
+ type: "httpRequest",
418
+ extension: "@cognigy/basic-tools",
419
+ name: "HTTP Request",
420
+ description: "A tool to make HTTP requests.",
421
+ parameters: [
422
+ {
423
+ name: "method",
424
+ description: "The HTTP method to use.",
425
+ mode: "dynamic",
426
+ type: "string",
427
+ value: {
428
+ valueType: "static",
429
+ }
430
+ }
431
+ ],
432
+ projectId: validProjectId
433
+ });
434
+ assert.ok(tool);
435
+ assert.equal(Object.keys(tool).length, 13, "Tool has incorrect number of properties");
436
+ assert.ok(tool.id, "Tool ID is missing");
437
+ assert.equal(tool.type, "httpRequest", "Tool type does not match");
438
+ assert.equal(tool.extension, "@cognigy/basic-tools", "Tool extension does not match");
439
+ assert.equal(tool.name, "HTTP Request", "Tool name does not match");
440
+ assert.equal(tool.description, "A tool to make HTTP requests.", "Tool description does not match");
441
+ assert.deepStrictEqual(tool.parameters, [
442
+ {
443
+ name: "method",
444
+ description: "The HTTP method to use.",
445
+ mode: "dynamic",
446
+ type: "string",
447
+ value: {
448
+ valueType: "static"
449
+ }
450
+ }
451
+ ], "Tool parameters do not match");
452
+ assert.equal(tool.projectId, validProjectId, "Tool projectId does not match");
453
+ assert.ok(tool.organisationId, "Tool organisationId is missing");
454
+ assert.ok(tool.createdAt, "Tool createdAt is missing");
455
+ assert.ok(tool.createdBy, "Tool createdBy is missing");
456
+ assert.ok(tool.lastChangedAt, "Tool lastChangedAt is missing");
457
+ assert.ok(tool.lastChangedBy, "Tool lastChangedBy is missing");
458
+ }));
459
+ it("creates a new Tool and then reads its properties back", () => __awaiter(void 0, void 0, void 0, function* () {
460
+ const tool = yield client.createTool({
461
+ type: "httpRequest",
462
+ extension: "@cognigy/basic-tools",
463
+ name: "HTTP Request",
464
+ description: "A tool to make HTTP requests.",
465
+ parameters: [
466
+ {
467
+ name: "method",
468
+ description: "The HTTP method to use.",
469
+ mode: "dynamic",
470
+ type: "string",
471
+ value: {
472
+ valueType: "static",
473
+ }
474
+ }
475
+ ],
476
+ projectId: validProjectId
477
+ });
478
+ const fetchedTool = yield client.readTool({
479
+ toolId: tool.id
480
+ });
481
+ assert.ok(fetchedTool);
482
+ assert.ok(fetchedTool.id, "Tool ID is missing");
483
+ assert.equal(fetchedTool.type, "httpRequest", "Tool type does not match");
484
+ assert.equal(fetchedTool.extension, "@cognigy/basic-tools", "Tool extension does not match");
485
+ assert.equal(fetchedTool.name, "HTTP Request", "Tool name does not match");
486
+ assert.equal(fetchedTool.description, "A tool to make HTTP requests.", "Tool description does not match");
487
+ assert.equal(fetchedTool.projectId, validProjectId, "Tool projectId does not match");
488
+ assert.ok(fetchedTool.createdAt, "Tool createdAt is missing");
489
+ assert.ok(fetchedTool.createdBy, "Tool createdBy is missing");
490
+ assert.ok(fetchedTool.lastChangedAt);
491
+ assert.ok(fetchedTool.lastChangedBy, "Tool lastChangedBy is missing");
492
+ const [firstParam] = fetchedTool.parameters;
493
+ assert.ok(firstParam.name, "Tool parameter name is missing");
494
+ assert.ok(firstParam.description, "Tool parameter description is missing");
495
+ assert.ok(firstParam.mode, "Tool parameter mode is missing");
496
+ assert.ok(firstParam.type, "Tool parameter type is missing");
497
+ assert.ok(firstParam.value, "Tool parameter value is missing");
498
+ }));
499
+ it("lists all available Tools", () => __awaiter(void 0, void 0, void 0, function* () {
500
+ const tools = yield client.indexTools({});
501
+ assert.ok(tools);
502
+ assert.ok(tools.items);
503
+ assert.ok(tools.nextCursor);
504
+ assert.ok(tools.previousCursor);
505
+ assert.ok(tools.total);
506
+ const [firstTool] = tools.items;
507
+ assert.ok(Object.keys(firstTool).length === 13, "Tool has incorrect number of properties");
508
+ assert.ok(firstTool.id, "Tool ID is missing");
509
+ assert.ok(firstTool.referenceId, "Tool referenceId is missing");
510
+ assert.ok(firstTool.type, "Tool type is missing");
511
+ assert.ok(firstTool.extension, "Tool extension is missing");
512
+ assert.ok(firstTool.parameters, "Tool parameters are missing");
513
+ assert.ok(firstTool.name, "Tool name is missing");
514
+ assert.ok(firstTool.description, "Tool description is missing");
515
+ assert.ok(firstTool.projectId, "Tool projectId is missing");
516
+ assert.ok(firstTool.organisationId, "Tool organisationId is missing");
517
+ assert.ok(firstTool.createdAt, "Tool createdAt is missing");
518
+ assert.ok(firstTool.createdBy, "Tool createdBy is missing");
519
+ assert.ok(firstTool.lastChangedAt, "Tool lastChangedAt is missing");
520
+ assert.ok(firstTool.lastChangedBy, "Tool lastChangedBy is missing");
521
+ }));
522
+ it("creates a Tool and then deletes it", () => __awaiter(void 0, void 0, void 0, function* () {
523
+ const tool = yield client.createTool({
524
+ type: "httpRequest",
525
+ extension: "@cognigy/basic-tools",
526
+ name: "Temporary HTTP Request",
527
+ description: "A temporary tool to make HTTP requests.",
528
+ parameters: [],
529
+ projectId: validProjectId
530
+ });
531
+ assert.ok(tool);
532
+ yield client.deleteTool({
533
+ toolId: tool.id
534
+ });
535
+ assert.rejects(() => client.readTool({ toolId: tool.id }), ResourceNotFoundError);
536
+ }));
537
+ it("creates a Tool and then updates it", () => __awaiter(void 0, void 0, void 0, function* () {
538
+ const tool = yield client.createTool({
539
+ type: "httpRequest",
540
+ extension: "@cognigy/basic-tools",
541
+ name: "Updatable HTTP Request",
542
+ description: "A tool to make HTTP requests that will be updated.",
543
+ parameters: [],
544
+ projectId: validProjectId
545
+ });
546
+ assert.ok(tool);
547
+ const updatedTool = yield client.updateTool({
548
+ toolId: tool.id,
549
+ name: "Updated HTTP Request Tool",
550
+ description: "The description has been updated.",
551
+ parameters: []
552
+ });
553
+ assert.equal(updatedTool.id, tool.id, "Tool ID should not change after update");
554
+ assert.equal(updatedTool.name, "Updated HTTP Request Tool", "Tool name does not match after update");
555
+ assert.equal(updatedTool.description, "The description has been updated.", "Tool description does not match after update");
556
+ assert.ok(updatedTool.createdBy, "Tool createdBy is missing after update");
557
+ assert.ok(updatedTool.createdAt, "Tool createdAt is missing after update");
558
+ assert.ok(updatedTool.lastChangedBy, "Tool lastChangedBy is missing after update");
559
+ // assert.ok(updatedTool.lastChangedAt); (not properly set - always 0!)
560
+ }));
561
+ });
562
+ });
563
+ //# sourceMappingURL=aiAgentV2.spec.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognigy/rest-api-client",
3
- "version": "2026.1.0",
3
+ "version": "2026.2.0-rc1",
4
4
  "description": "Cognigy REST-Client",
5
5
  "main": "build/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -18,6 +18,7 @@
18
18
  "type-check:watch": "npm run type-check -- --watch",
19
19
  "test:only": "npm run test:unit",
20
20
  "test:unit": "nyc mocha --opts .mocharc && rimraf ./.nyc_output",
21
+ "test:aiAgentsV2": "node --import=tsx --test --test-timeout=120000 --test-force-exit --test-reporter spec ./src/spec/aiAgentV2.spec.ts",
21
22
  "prepublishOnly": "npm run build"
22
23
  },
23
24
  "repository": {},
@@ -30,6 +31,7 @@
30
31
  "author": "Cognigy GmbH",
31
32
  "license": "Cognigy Proprietary License",
32
33
  "dependencies": {
34
+ "@cognigy/extension-tools": "0.17.0-rc4",
33
35
  "ajv": "6.12.6",
34
36
  "axios": "1.8.3",
35
37
  "form-data": "4.0.4",
@@ -51,7 +53,7 @@
51
53
  "@rollup/plugin-json": "4.1.0",
52
54
  "@rollup/plugin-node-resolve": "13.3.0",
53
55
  "@rollup/plugin-typescript": "8.3.4",
54
- "@types/node": "18.7.6",
56
+ "@types/node": "22.19.7",
55
57
  "@types/sinon": "10.0.13",
56
58
  "@types/tus-js-client": "^2.1.0",
57
59
  "@typescript-eslint/eslint-plugin": "5.33.1",
@@ -70,6 +72,7 @@
70
72
  "regenerator-runtime": "0.13.9",
71
73
  "rimraf": "3.0.2",
72
74
  "rollup": "2.78.0",
75
+ "tsx": "4.21",
73
76
  "typescript": "4.7.4"
74
77
  },
75
78
  "engines": {
@@ -77,4 +80,4 @@
77
80
  "npm": ">=10.1.0",
78
81
  "vscode": "^1.22.0"
79
82
  }
80
- }
83
+ }