@algolia/agent-studio 0.1.0-beta.0

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.
@@ -0,0 +1,1364 @@
1
+ // builds/node.ts
2
+ import { gzipSync } from "zlib";
3
+ import { createHmac } from "crypto";
4
+ import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/client-common";
5
+ import { createHttpRequester } from "@algolia/requester-node-http";
6
+
7
+ // src/agentStudioClient.ts
8
+ import { createAuth, createTransporter, getAlgoliaAgent, shuffle, validateRequired } from "@algolia/client-common";
9
+ var apiClientVersion = "0.1.0-beta.0";
10
+ function getDefaultHosts(appId) {
11
+ return [
12
+ {
13
+ url: `${appId}-dsn.algolia.net`,
14
+ accept: "read",
15
+ protocol: "https"
16
+ },
17
+ {
18
+ url: `${appId}.algolia.net`,
19
+ accept: "write",
20
+ protocol: "https"
21
+ }
22
+ ].concat(
23
+ shuffle([
24
+ {
25
+ url: `${appId}-1.algolianet.com`,
26
+ accept: "readWrite",
27
+ protocol: "https"
28
+ },
29
+ {
30
+ url: `${appId}-2.algolianet.com`,
31
+ accept: "readWrite",
32
+ protocol: "https"
33
+ },
34
+ {
35
+ url: `${appId}-3.algolianet.com`,
36
+ accept: "readWrite",
37
+ protocol: "https"
38
+ }
39
+ ])
40
+ );
41
+ }
42
+ function createAgentStudioClient({
43
+ appId: appIdOption,
44
+ apiKey: apiKeyOption,
45
+ authMode,
46
+ algoliaAgents,
47
+ ...options
48
+ }) {
49
+ const auth = createAuth(appIdOption, apiKeyOption, authMode);
50
+ const transporter = createTransporter({
51
+ hosts: getDefaultHosts(appIdOption),
52
+ ...options,
53
+ algoliaAgent: getAlgoliaAgent({
54
+ algoliaAgents,
55
+ client: "AgentStudio",
56
+ version: apiClientVersion
57
+ }),
58
+ baseHeaders: {
59
+ "content-type": "text/plain",
60
+ ...auth.headers(),
61
+ ...options.baseHeaders
62
+ },
63
+ baseQueryParameters: {
64
+ ...auth.queryParameters(),
65
+ ...options.baseQueryParameters
66
+ }
67
+ });
68
+ return {
69
+ transporter,
70
+ /**
71
+ * The `appId` currently in use.
72
+ */
73
+ appId: appIdOption,
74
+ /**
75
+ * The `apiKey` currently in use.
76
+ */
77
+ apiKey: apiKeyOption,
78
+ /**
79
+ * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
80
+ */
81
+ clearCache() {
82
+ return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
83
+ },
84
+ /**
85
+ * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
86
+ */
87
+ get _ua() {
88
+ return transporter.algoliaAgent.value;
89
+ },
90
+ /**
91
+ * Adds a `segment` to the `x-algolia-agent` sent with every requests.
92
+ *
93
+ * @param segment - The algolia agent (user-agent) segment to add.
94
+ * @param version - The version of the agent.
95
+ */
96
+ addAlgoliaAgent(segment, version) {
97
+ transporter.algoliaAgent.add({ segment, version });
98
+ },
99
+ /**
100
+ * Helper method to switch the API key used to authenticate the requests.
101
+ *
102
+ * @param params - Method params.
103
+ * @param params.apiKey - The new API Key to use.
104
+ */
105
+ setClientApiKey({ apiKey }) {
106
+ if (!authMode || authMode === "WithinHeaders") {
107
+ transporter.baseHeaders["x-algolia-api-key"] = apiKey;
108
+ } else {
109
+ transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
110
+ }
111
+ },
112
+ /**
113
+ * Add multiple allowed domain patterns. Duplicates are skipped.
114
+ *
115
+ * Required API Key ACLs:
116
+ * - editSettings
117
+ * @param bulkCreateAllowedDomains - The bulkCreateAllowedDomains object.
118
+ * @param bulkCreateAllowedDomains.agentId - The agentId.
119
+ * @param bulkCreateAllowedDomains.allowedDomainBulkInsert - The allowedDomainBulkInsert object.
120
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
121
+ */
122
+ bulkCreateAllowedDomains({ agentId, allowedDomainBulkInsert }, requestOptions) {
123
+ validateRequired("agentId", "bulkCreateAllowedDomains", agentId);
124
+ validateRequired("allowedDomainBulkInsert", "bulkCreateAllowedDomains", allowedDomainBulkInsert);
125
+ validateRequired("allowedDomainBulkInsert.domains", "bulkCreateAllowedDomains", allowedDomainBulkInsert.domains);
126
+ const requestPath = "/agent-studio/1/agents/{agentId}/allowed-domains/bulk".replace(
127
+ "{agentId}",
128
+ encodeURIComponent(agentId)
129
+ );
130
+ const headers = {};
131
+ const queryParameters = {};
132
+ const request = {
133
+ method: "POST",
134
+ path: requestPath,
135
+ queryParameters,
136
+ headers,
137
+ data: allowedDomainBulkInsert
138
+ };
139
+ return transporter.request(request, requestOptions);
140
+ },
141
+ /**
142
+ * Delete allowed domains by id list.
143
+ *
144
+ * Required API Key ACLs:
145
+ * - editSettings
146
+ * @param bulkDeleteAllowedDomains - The bulkDeleteAllowedDomains object.
147
+ * @param bulkDeleteAllowedDomains.agentId - The agentId.
148
+ * @param bulkDeleteAllowedDomains.allowedDomainBulkDelete - The allowedDomainBulkDelete object.
149
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
150
+ */
151
+ bulkDeleteAllowedDomains({ agentId, allowedDomainBulkDelete }, requestOptions) {
152
+ validateRequired("agentId", "bulkDeleteAllowedDomains", agentId);
153
+ validateRequired("allowedDomainBulkDelete", "bulkDeleteAllowedDomains", allowedDomainBulkDelete);
154
+ validateRequired(
155
+ "allowedDomainBulkDelete.domainIds",
156
+ "bulkDeleteAllowedDomains",
157
+ allowedDomainBulkDelete.domainIds
158
+ );
159
+ const requestPath = "/agent-studio/1/agents/{agentId}/allowed-domains/bulk".replace(
160
+ "{agentId}",
161
+ encodeURIComponent(agentId)
162
+ );
163
+ const headers = {};
164
+ const queryParameters = {};
165
+ const request = {
166
+ method: "DELETE",
167
+ path: requestPath,
168
+ queryParameters,
169
+ headers,
170
+ data: allowedDomainBulkDelete
171
+ };
172
+ return transporter.request(request, requestOptions);
173
+ },
174
+ /**
175
+ * Create a new agent.
176
+ *
177
+ * Required API Key ACLs:
178
+ * - editSettings
179
+ * @param agentConfigCreate - The agentConfigCreate object.
180
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
181
+ */
182
+ createAgent(agentConfigCreate, requestOptions) {
183
+ validateRequired("agentConfigCreate", "createAgent", agentConfigCreate);
184
+ validateRequired("agentConfigCreate.name", "createAgent", agentConfigCreate.name);
185
+ validateRequired("agentConfigCreate.instructions", "createAgent", agentConfigCreate.instructions);
186
+ const requestPath = "/agent-studio/1/agents";
187
+ const headers = {};
188
+ const queryParameters = {};
189
+ const request = {
190
+ method: "POST",
191
+ path: requestPath,
192
+ queryParameters,
193
+ headers,
194
+ data: agentConfigCreate
195
+ };
196
+ return transporter.request(request, requestOptions);
197
+ },
198
+ /**
199
+ * Add a single allowed domain pattern (e.g. https://app.example.com or *.example.com).
200
+ *
201
+ * Required API Key ACLs:
202
+ * - editSettings
203
+ * @param createAgentAllowedDomain - The createAgentAllowedDomain object.
204
+ * @param createAgentAllowedDomain.agentId - The agentId.
205
+ * @param createAgentAllowedDomain.allowedDomainCreate - The allowedDomainCreate object.
206
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
207
+ */
208
+ createAgentAllowedDomain({ agentId, allowedDomainCreate }, requestOptions) {
209
+ validateRequired("agentId", "createAgentAllowedDomain", agentId);
210
+ validateRequired("allowedDomainCreate", "createAgentAllowedDomain", allowedDomainCreate);
211
+ validateRequired("allowedDomainCreate.domain", "createAgentAllowedDomain", allowedDomainCreate.domain);
212
+ const requestPath = "/agent-studio/1/agents/{agentId}/allowed-domains".replace(
213
+ "{agentId}",
214
+ encodeURIComponent(agentId)
215
+ );
216
+ const headers = {};
217
+ const queryParameters = {};
218
+ const request = {
219
+ method: "POST",
220
+ path: requestPath,
221
+ queryParameters,
222
+ headers,
223
+ data: allowedDomainCreate
224
+ };
225
+ return transporter.request(request, requestOptions);
226
+ },
227
+ /**
228
+ * Create a completion for the specified agent. This endpoint handles two types of requests: 1. Normal completion request: User message -> Agent response 2. Tool approval response: User approval -> Execute tool -> Agent response Tool Approval Flow (for MCP tools with requiresApproval: true): - Request 1: User sends message -> Agent requests tool call -> Return approval request - Request 2: User approves -> Execute tool -> Agent continues with result.
229
+ *
230
+ * Required API Key ACLs:
231
+ * - search
232
+ * @param createAgentCompletion - The createAgentCompletion object.
233
+ * @param createAgentCompletion.agentId - The agentId.
234
+ * @param createAgentCompletion.compatibilityMode - Compatibility mode for the completion API.
235
+ * @param createAgentCompletion.agentCompletionRequest - The agentCompletionRequest object.
236
+ * @param createAgentCompletion.stream - Whether to stream the response or not.
237
+ * @param createAgentCompletion.cache - Use cached responses if available.
238
+ * @param createAgentCompletion.memory - Set to false to disable memory (enabled by default).
239
+ * @param createAgentCompletion.analytics - Set to false to skip analytics for this completion (default: true). Disables Agent Studio BigQuery analytics, Algolia search analytics, click analytics, and query-suggestions training. Useful for offline-eval workflows.
240
+ * @param createAgentCompletion.xAlgoliaSecureUserToken - The X-Algolia-Secure-User-Token.
241
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
242
+ */
243
+ createAgentCompletion({
244
+ agentId,
245
+ compatibilityMode,
246
+ agentCompletionRequest,
247
+ stream,
248
+ cache,
249
+ memory,
250
+ analytics,
251
+ xAlgoliaSecureUserToken
252
+ }, requestOptions) {
253
+ validateRequired("agentId", "createAgentCompletion", agentId);
254
+ validateRequired("compatibilityMode", "createAgentCompletion", compatibilityMode);
255
+ validateRequired("agentCompletionRequest", "createAgentCompletion", agentCompletionRequest);
256
+ const requestPath = "/agent-studio/1/agents/{agentId}/completions".replace(
257
+ "{agentId}",
258
+ encodeURIComponent(agentId)
259
+ );
260
+ const headers = {};
261
+ const queryParameters = {};
262
+ if (compatibilityMode !== void 0) {
263
+ queryParameters["compatibilityMode"] = compatibilityMode.toString();
264
+ }
265
+ if (stream !== void 0) {
266
+ queryParameters["stream"] = stream.toString();
267
+ }
268
+ if (cache !== void 0) {
269
+ queryParameters["cache"] = cache.toString();
270
+ }
271
+ if (memory !== void 0) {
272
+ queryParameters["memory"] = memory.toString();
273
+ }
274
+ if (analytics !== void 0) {
275
+ queryParameters["analytics"] = analytics.toString();
276
+ }
277
+ if (xAlgoliaSecureUserToken !== void 0) {
278
+ headers["X-Algolia-Secure-User-Token"] = xAlgoliaSecureUserToken.toString();
279
+ }
280
+ const request = {
281
+ method: "POST",
282
+ path: requestPath,
283
+ queryParameters,
284
+ headers,
285
+ data: agentCompletionRequest
286
+ };
287
+ return transporter.request(request, requestOptions);
288
+ },
289
+ /**
290
+ * Create a completion for the specified agent. This endpoint handles two types of requests: 1. Normal completion request: User message -> Agent response 2. Tool approval response: User approval -> Execute tool -> Agent response Tool Approval Flow (for MCP tools with requiresApproval: true): - Request 1: User sends message -> Agent requests tool call -> Return approval request - Request 2: User approves -> Execute tool -> Agent continues with result. (raw streaming version).
291
+ *
292
+ * Yields raw {@link ServerSentEvent} objects. Each event's `data` field contains a JSON-encoded `{ [key: string]: any; }` string.
293
+ *
294
+ * @see createAgentCompletionStream for the parsed variant.
295
+ * @see createAgentCompletion for the non-streaming version.
296
+ */
297
+ createAgentCompletionStreamRaw({
298
+ agentId,
299
+ compatibilityMode,
300
+ agentCompletionRequest,
301
+ stream,
302
+ cache,
303
+ memory,
304
+ analytics,
305
+ xAlgoliaSecureUserToken
306
+ }, requestOptions) {
307
+ validateRequired("agentId", "createAgentCompletionStreamRaw", agentId);
308
+ validateRequired("compatibilityMode", "createAgentCompletionStreamRaw", compatibilityMode);
309
+ validateRequired("agentCompletionRequest", "createAgentCompletionStreamRaw", agentCompletionRequest);
310
+ const requestPath = "/agent-studio/1/agents/{agentId}/completions".replace(
311
+ "{agentId}",
312
+ encodeURIComponent(agentId)
313
+ );
314
+ const headers = {};
315
+ const queryParameters = {};
316
+ if (compatibilityMode !== void 0) {
317
+ queryParameters["compatibilityMode"] = compatibilityMode.toString();
318
+ }
319
+ if (stream !== void 0) {
320
+ queryParameters["stream"] = stream.toString();
321
+ }
322
+ if (cache !== void 0) {
323
+ queryParameters["cache"] = cache.toString();
324
+ }
325
+ if (memory !== void 0) {
326
+ queryParameters["memory"] = memory.toString();
327
+ }
328
+ if (analytics !== void 0) {
329
+ queryParameters["analytics"] = analytics.toString();
330
+ }
331
+ if (xAlgoliaSecureUserToken !== void 0) {
332
+ headers["X-Algolia-Secure-User-Token"] = xAlgoliaSecureUserToken.toString();
333
+ }
334
+ const request = {
335
+ method: "POST",
336
+ path: requestPath,
337
+ queryParameters,
338
+ headers,
339
+ data: agentCompletionRequest
340
+ };
341
+ return transporter.requestStream(request, requestOptions);
342
+ },
343
+ /**
344
+ * Create a completion for the specified agent. This endpoint handles two types of requests: 1. Normal completion request: User message -> Agent response 2. Tool approval response: User approval -> Execute tool -> Agent response Tool Approval Flow (for MCP tools with requiresApproval: true): - Request 1: User sends message -> Agent requests tool call -> Return approval request - Request 2: User approves -> Execute tool -> Agent continues with result. (streaming version).
345
+ *
346
+ * Yields {@link StreamEvent} objects wrapping parsed `{ [key: string]: any; }` payloads.
347
+ *
348
+ * @see createAgentCompletionStreamRaw for the raw variant.
349
+ * @see createAgentCompletion for the non-streaming version.
350
+ */
351
+ async *createAgentCompletionStream({
352
+ agentId,
353
+ compatibilityMode,
354
+ agentCompletionRequest,
355
+ stream,
356
+ cache,
357
+ memory,
358
+ analytics,
359
+ xAlgoliaSecureUserToken
360
+ }, requestOptions) {
361
+ for await (const event of this.createAgentCompletionStreamRaw(
362
+ {
363
+ agentId,
364
+ compatibilityMode,
365
+ agentCompletionRequest,
366
+ stream,
367
+ cache,
368
+ memory,
369
+ analytics,
370
+ xAlgoliaSecureUserToken
371
+ },
372
+ requestOptions
373
+ )) {
374
+ try {
375
+ const data = JSON.parse(event.data);
376
+ yield { data, raw: event };
377
+ } catch (e) {
378
+ yield { data: null, raw: event, error: e };
379
+ }
380
+ }
381
+ },
382
+ /**
383
+ * Create new feedback entry.
384
+ *
385
+ * Required API Key ACLs:
386
+ * - search
387
+ * @param feedbackCreationRequest - The feedbackCreationRequest object.
388
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
389
+ */
390
+ createFeedback(feedbackCreationRequest, requestOptions) {
391
+ validateRequired("feedbackCreationRequest", "createFeedback", feedbackCreationRequest);
392
+ validateRequired("feedbackCreationRequest.messageId", "createFeedback", feedbackCreationRequest.messageId);
393
+ validateRequired("feedbackCreationRequest.agentId", "createFeedback", feedbackCreationRequest.agentId);
394
+ validateRequired("feedbackCreationRequest.vote", "createFeedback", feedbackCreationRequest.vote);
395
+ const requestPath = "/agent-studio/1/feedback";
396
+ const headers = {};
397
+ const queryParameters = {};
398
+ const request = {
399
+ method: "POST",
400
+ path: requestPath,
401
+ queryParameters,
402
+ headers,
403
+ data: feedbackCreationRequest
404
+ };
405
+ return transporter.request(request, requestOptions);
406
+ },
407
+ /**
408
+ * Create Provider.
409
+ *
410
+ * Required API Key ACLs:
411
+ * - editSettings
412
+ * @param providerAuthenticationCreate - The providerAuthenticationCreate object.
413
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
414
+ */
415
+ createProvider(providerAuthenticationCreate, requestOptions) {
416
+ validateRequired("providerAuthenticationCreate", "createProvider", providerAuthenticationCreate);
417
+ validateRequired("providerAuthenticationCreate.name", "createProvider", providerAuthenticationCreate.name);
418
+ validateRequired(
419
+ "providerAuthenticationCreate.providerName",
420
+ "createProvider",
421
+ providerAuthenticationCreate.providerName
422
+ );
423
+ validateRequired("providerAuthenticationCreate.input", "createProvider", providerAuthenticationCreate.input);
424
+ const requestPath = "/agent-studio/1/providers";
425
+ const headers = {};
426
+ const queryParameters = {};
427
+ const request = {
428
+ method: "POST",
429
+ path: requestPath,
430
+ queryParameters,
431
+ headers,
432
+ data: providerAuthenticationCreate
433
+ };
434
+ return transporter.request(request, requestOptions);
435
+ },
436
+ /**
437
+ * Create Secret Key.
438
+ *
439
+ * Required API Key ACLs:
440
+ * - admin
441
+ * @param secretKeyCreate - The secretKeyCreate object.
442
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
443
+ */
444
+ createSecretKey(secretKeyCreate, requestOptions) {
445
+ validateRequired("secretKeyCreate", "createSecretKey", secretKeyCreate);
446
+ validateRequired("secretKeyCreate.name", "createSecretKey", secretKeyCreate.name);
447
+ const requestPath = "/agent-studio/1/secret-keys";
448
+ const headers = {};
449
+ const queryParameters = {};
450
+ const request = {
451
+ method: "POST",
452
+ path: requestPath,
453
+ queryParameters,
454
+ headers,
455
+ data: secretKeyCreate
456
+ };
457
+ return transporter.request(request, requestOptions);
458
+ },
459
+ /**
460
+ * This method lets you send requests to the Algolia REST API.
461
+ * @param customDelete - The customDelete object.
462
+ * @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
463
+ * @param customDelete.parameters - Query parameters to apply to the current query.
464
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
465
+ */
466
+ customDelete({ path, parameters }, requestOptions) {
467
+ validateRequired("path", "customDelete", path);
468
+ const requestPath = "/agent-studio/{path}".replace("{path}", path);
469
+ const headers = {};
470
+ const queryParameters = parameters ? parameters : {};
471
+ const request = {
472
+ method: "DELETE",
473
+ path: requestPath,
474
+ queryParameters,
475
+ headers
476
+ };
477
+ return transporter.request(request, requestOptions);
478
+ },
479
+ /**
480
+ * This method lets you send requests to the Algolia REST API.
481
+ * @param customGet - The customGet object.
482
+ * @param customGet.path - Path of the endpoint, for example `1/newFeature`.
483
+ * @param customGet.parameters - Query parameters to apply to the current query.
484
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
485
+ */
486
+ customGet({ path, parameters }, requestOptions) {
487
+ validateRequired("path", "customGet", path);
488
+ const requestPath = "/agent-studio/{path}".replace("{path}", path);
489
+ const headers = {};
490
+ const queryParameters = parameters ? parameters : {};
491
+ const request = {
492
+ method: "GET",
493
+ path: requestPath,
494
+ queryParameters,
495
+ headers
496
+ };
497
+ return transporter.request(request, requestOptions);
498
+ },
499
+ /**
500
+ * This method lets you send requests to the Algolia REST API.
501
+ * @param customPost - The customPost object.
502
+ * @param customPost.path - Path of the endpoint, for example `1/newFeature`.
503
+ * @param customPost.parameters - Query parameters to apply to the current query.
504
+ * @param customPost.body - Parameters to send with the custom request.
505
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
506
+ */
507
+ customPost({ path, parameters, body }, requestOptions) {
508
+ validateRequired("path", "customPost", path);
509
+ const requestPath = "/agent-studio/{path}".replace("{path}", path);
510
+ const headers = {};
511
+ const queryParameters = parameters ? parameters : {};
512
+ const request = {
513
+ method: "POST",
514
+ path: requestPath,
515
+ queryParameters,
516
+ headers,
517
+ data: body ? body : {}
518
+ };
519
+ return transporter.request(request, requestOptions);
520
+ },
521
+ /**
522
+ * This method lets you send requests to the Algolia REST API.
523
+ * @param customPut - The customPut object.
524
+ * @param customPut.path - Path of the endpoint, for example `1/newFeature`.
525
+ * @param customPut.parameters - Query parameters to apply to the current query.
526
+ * @param customPut.body - Parameters to send with the custom request.
527
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
528
+ */
529
+ customPut({ path, parameters, body }, requestOptions) {
530
+ validateRequired("path", "customPut", path);
531
+ const requestPath = "/agent-studio/{path}".replace("{path}", path);
532
+ const headers = {};
533
+ const queryParameters = parameters ? parameters : {};
534
+ const request = {
535
+ method: "PUT",
536
+ path: requestPath,
537
+ queryParameters,
538
+ headers,
539
+ data: body ? body : {}
540
+ };
541
+ return transporter.request(request, requestOptions);
542
+ },
543
+ /**
544
+ * Delete the specified agent.
545
+ *
546
+ * Required API Key ACLs:
547
+ * - editSettings
548
+ * @param deleteAgent - The deleteAgent object.
549
+ * @param deleteAgent.agentId - The agentId.
550
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
551
+ */
552
+ deleteAgent({ agentId }, requestOptions) {
553
+ validateRequired("agentId", "deleteAgent", agentId);
554
+ const requestPath = "/agent-studio/1/agents/{agentId}".replace("{agentId}", encodeURIComponent(agentId));
555
+ const headers = {};
556
+ const queryParameters = {};
557
+ const request = {
558
+ method: "DELETE",
559
+ path: requestPath,
560
+ queryParameters,
561
+ headers
562
+ };
563
+ return transporter.request(request, requestOptions);
564
+ },
565
+ /**
566
+ * Deletes the conversations matching the given filers.
567
+ *
568
+ * Required API Key ACLs:
569
+ * - logs
570
+ * @param deleteAgentConversations - The deleteAgentConversations object.
571
+ * @param deleteAgentConversations.agentId - The agentId.
572
+ * @param deleteAgentConversations.startDate - Filter conversations created after this date (format: YYYY-MM-DD).
573
+ * @param deleteAgentConversations.endDate - Filter conversations created before this date (format: YYYY-MM-DD).
574
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
575
+ */
576
+ deleteAgentConversations({ agentId, startDate, endDate }, requestOptions) {
577
+ validateRequired("agentId", "deleteAgentConversations", agentId);
578
+ const requestPath = "/agent-studio/1/agents/{agentId}/conversations".replace(
579
+ "{agentId}",
580
+ encodeURIComponent(agentId)
581
+ );
582
+ const headers = {};
583
+ const queryParameters = {};
584
+ if (startDate !== void 0) {
585
+ queryParameters["startDate"] = startDate.toString();
586
+ }
587
+ if (endDate !== void 0) {
588
+ queryParameters["endDate"] = endDate.toString();
589
+ }
590
+ const request = {
591
+ method: "DELETE",
592
+ path: requestPath,
593
+ queryParameters,
594
+ headers
595
+ };
596
+ return transporter.request(request, requestOptions);
597
+ },
598
+ /**
599
+ * Remove an allowed domain by id.
600
+ *
601
+ * Required API Key ACLs:
602
+ * - editSettings
603
+ * @param deleteAllowedDomain - The deleteAllowedDomain object.
604
+ * @param deleteAllowedDomain.domainId - The domainId.
605
+ * @param deleteAllowedDomain.agentId - The agentId.
606
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
607
+ */
608
+ deleteAllowedDomain({ domainId, agentId }, requestOptions) {
609
+ validateRequired("domainId", "deleteAllowedDomain", domainId);
610
+ validateRequired("agentId", "deleteAllowedDomain", agentId);
611
+ const requestPath = "/agent-studio/1/agents/{agentId}/allowed-domains/{domainId}".replace("{domainId}", encodeURIComponent(domainId)).replace("{agentId}", encodeURIComponent(agentId));
612
+ const headers = {};
613
+ const queryParameters = {};
614
+ const request = {
615
+ method: "DELETE",
616
+ path: requestPath,
617
+ queryParameters,
618
+ headers
619
+ };
620
+ return transporter.request(request, requestOptions);
621
+ },
622
+ /**
623
+ * Deletes the conversation with the given ID.
624
+ *
625
+ * Required API Key ACLs:
626
+ * - logs
627
+ * @param deleteConversation - The deleteConversation object.
628
+ * @param deleteConversation.conversationId - The conversationId.
629
+ * @param deleteConversation.agentId - The agentId.
630
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
631
+ */
632
+ deleteConversation({ conversationId, agentId }, requestOptions) {
633
+ validateRequired("conversationId", "deleteConversation", conversationId);
634
+ validateRequired("agentId", "deleteConversation", agentId);
635
+ const requestPath = "/agent-studio/1/agents/{agentId}/conversations/{conversationId}".replace("{conversationId}", encodeURIComponent(conversationId)).replace("{agentId}", encodeURIComponent(agentId));
636
+ const headers = {};
637
+ const queryParameters = {};
638
+ const request = {
639
+ method: "DELETE",
640
+ path: requestPath,
641
+ queryParameters,
642
+ headers
643
+ };
644
+ return transporter.request(request, requestOptions);
645
+ },
646
+ /**
647
+ * Delete Provider.
648
+ *
649
+ * Required API Key ACLs:
650
+ * - editSettings
651
+ * @param deleteProvider - The deleteProvider object.
652
+ * @param deleteProvider.providerId - The providerId.
653
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
654
+ */
655
+ deleteProvider({ providerId }, requestOptions) {
656
+ validateRequired("providerId", "deleteProvider", providerId);
657
+ const requestPath = "/agent-studio/1/providers/{providerId}".replace(
658
+ "{providerId}",
659
+ encodeURIComponent(providerId)
660
+ );
661
+ const headers = {};
662
+ const queryParameters = {};
663
+ const request = {
664
+ method: "DELETE",
665
+ path: requestPath,
666
+ queryParameters,
667
+ headers
668
+ };
669
+ return transporter.request(request, requestOptions);
670
+ },
671
+ /**
672
+ * Delete Secret Key.
673
+ *
674
+ * Required API Key ACLs:
675
+ * - admin
676
+ * @param deleteSecretKey - The deleteSecretKey object.
677
+ * @param deleteSecretKey.secretKeyId - The secretKeyId.
678
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
679
+ */
680
+ deleteSecretKey({ secretKeyId }, requestOptions) {
681
+ validateRequired("secretKeyId", "deleteSecretKey", secretKeyId);
682
+ const requestPath = "/agent-studio/1/secret-keys/{secretKeyId}".replace(
683
+ "{secretKeyId}",
684
+ encodeURIComponent(secretKeyId)
685
+ );
686
+ const headers = {};
687
+ const queryParameters = {};
688
+ const request = {
689
+ method: "DELETE",
690
+ path: requestPath,
691
+ queryParameters,
692
+ headers
693
+ };
694
+ return transporter.request(request, requestOptions);
695
+ },
696
+ /**
697
+ * Permanently deletes all messages for the given user token. Does not delete conversations.
698
+ *
699
+ * Required API Key ACLs:
700
+ * - logs
701
+ * @param deleteUserData - The deleteUserData object.
702
+ * @param deleteUserData.userToken - The userToken.
703
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
704
+ */
705
+ deleteUserData({ userToken }, requestOptions) {
706
+ validateRequired("userToken", "deleteUserData", userToken);
707
+ const requestPath = "/agent-studio/1/user-data/{userToken}".replace("{userToken}", encodeURIComponent(userToken));
708
+ const headers = {};
709
+ const queryParameters = {};
710
+ const request = {
711
+ method: "DELETE",
712
+ path: requestPath,
713
+ queryParameters,
714
+ headers
715
+ };
716
+ return transporter.request(request, requestOptions);
717
+ },
718
+ /**
719
+ * Exports all conversations based on the passed filters.
720
+ *
721
+ * Required API Key ACLs:
722
+ * - logs
723
+ * @param exportConversations - The exportConversations object.
724
+ * @param exportConversations.agentId - The agentId.
725
+ * @param exportConversations.startDate - Filter conversations created after this date (format: YYYY-MM-DD).
726
+ * @param exportConversations.endDate - Filter conversations created before this date (format: YYYY-MM-DD).
727
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
728
+ */
729
+ exportConversations({ agentId, startDate, endDate }, requestOptions) {
730
+ validateRequired("agentId", "exportConversations", agentId);
731
+ const requestPath = "/agent-studio/1/agents/{agentId}/conversations/export".replace(
732
+ "{agentId}",
733
+ encodeURIComponent(agentId)
734
+ );
735
+ const headers = {};
736
+ const queryParameters = {};
737
+ if (startDate !== void 0) {
738
+ queryParameters["startDate"] = startDate.toString();
739
+ }
740
+ if (endDate !== void 0) {
741
+ queryParameters["endDate"] = endDate.toString();
742
+ }
743
+ const request = {
744
+ method: "GET",
745
+ path: requestPath,
746
+ queryParameters,
747
+ headers
748
+ };
749
+ return transporter.request(request, requestOptions);
750
+ },
751
+ /**
752
+ * Retrieve details of the specified agent.
753
+ *
754
+ * Required API Key ACLs:
755
+ * - settings
756
+ * @param getAgent - The getAgent object.
757
+ * @param getAgent.agentId - The agentId.
758
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
759
+ */
760
+ getAgent({ agentId }, requestOptions) {
761
+ validateRequired("agentId", "getAgent", agentId);
762
+ const requestPath = "/agent-studio/1/agents/{agentId}".replace("{agentId}", encodeURIComponent(agentId));
763
+ const headers = {};
764
+ const queryParameters = {};
765
+ const request = {
766
+ method: "GET",
767
+ path: requestPath,
768
+ queryParameters,
769
+ headers
770
+ };
771
+ return transporter.request(request, requestOptions);
772
+ },
773
+ /**
774
+ * Get a single allowed domain by id.
775
+ *
776
+ * Required API Key ACLs:
777
+ * - settings
778
+ * @param getAllowedDomain - The getAllowedDomain object.
779
+ * @param getAllowedDomain.domainId - The domainId.
780
+ * @param getAllowedDomain.agentId - The agentId.
781
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
782
+ */
783
+ getAllowedDomain({ domainId, agentId }, requestOptions) {
784
+ validateRequired("domainId", "getAllowedDomain", domainId);
785
+ validateRequired("agentId", "getAllowedDomain", agentId);
786
+ const requestPath = "/agent-studio/1/agents/{agentId}/allowed-domains/{domainId}".replace("{domainId}", encodeURIComponent(domainId)).replace("{agentId}", encodeURIComponent(agentId));
787
+ const headers = {};
788
+ const queryParameters = {};
789
+ const request = {
790
+ method: "GET",
791
+ path: requestPath,
792
+ queryParameters,
793
+ headers
794
+ };
795
+ return transporter.request(request, requestOptions);
796
+ },
797
+ /**
798
+ * Get Configuration.
799
+ *
800
+ * Required API Key ACLs:
801
+ * - logs
802
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
803
+ */
804
+ getConfiguration(requestOptions) {
805
+ const requestPath = "/agent-studio/1/configuration";
806
+ const headers = {};
807
+ const queryParameters = {};
808
+ const request = {
809
+ method: "GET",
810
+ path: requestPath,
811
+ queryParameters,
812
+ headers
813
+ };
814
+ return transporter.request(request, requestOptions);
815
+ },
816
+ /**
817
+ * Retrieves the conversation and its messages for the given ID.
818
+ *
819
+ * Required API Key ACLs:
820
+ * - logs
821
+ * @param getConversation - The getConversation object.
822
+ * @param getConversation.conversationId - The conversationId.
823
+ * @param getConversation.agentId - The agentId.
824
+ * @param getConversation.includeFeedback - Include feedback for the conversation.
825
+ * @param getConversation.xAlgoliaSecureUserToken - The X-Algolia-Secure-User-Token.
826
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
827
+ */
828
+ getConversation({ conversationId, agentId, includeFeedback, xAlgoliaSecureUserToken }, requestOptions) {
829
+ validateRequired("conversationId", "getConversation", conversationId);
830
+ validateRequired("agentId", "getConversation", agentId);
831
+ const requestPath = "/agent-studio/1/agents/{agentId}/conversations/{conversationId}".replace("{conversationId}", encodeURIComponent(conversationId)).replace("{agentId}", encodeURIComponent(agentId));
832
+ const headers = {};
833
+ const queryParameters = {};
834
+ if (includeFeedback !== void 0) {
835
+ queryParameters["includeFeedback"] = includeFeedback.toString();
836
+ }
837
+ if (xAlgoliaSecureUserToken !== void 0) {
838
+ headers["X-Algolia-Secure-User-Token"] = xAlgoliaSecureUserToken.toString();
839
+ }
840
+ const request = {
841
+ method: "GET",
842
+ path: requestPath,
843
+ queryParameters,
844
+ headers
845
+ };
846
+ return transporter.request(request, requestOptions);
847
+ },
848
+ /**
849
+ * Get Provider.
850
+ *
851
+ * Required API Key ACLs:
852
+ * - settings
853
+ * @param getProvider - The getProvider object.
854
+ * @param getProvider.providerId - The providerId.
855
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
856
+ */
857
+ getProvider({ providerId }, requestOptions) {
858
+ validateRequired("providerId", "getProvider", providerId);
859
+ const requestPath = "/agent-studio/1/providers/{providerId}".replace(
860
+ "{providerId}",
861
+ encodeURIComponent(providerId)
862
+ );
863
+ const headers = {};
864
+ const queryParameters = {};
865
+ const request = {
866
+ method: "GET",
867
+ path: requestPath,
868
+ queryParameters,
869
+ headers
870
+ };
871
+ return transporter.request(request, requestOptions);
872
+ },
873
+ /**
874
+ * Get Secret Key.
875
+ *
876
+ * Required API Key ACLs:
877
+ * - settings
878
+ * @param getSecretKey - The getSecretKey object.
879
+ * @param getSecretKey.secretKeyId - The secretKeyId.
880
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
881
+ */
882
+ getSecretKey({ secretKeyId }, requestOptions) {
883
+ validateRequired("secretKeyId", "getSecretKey", secretKeyId);
884
+ const requestPath = "/agent-studio/1/secret-keys/{secretKeyId}".replace(
885
+ "{secretKeyId}",
886
+ encodeURIComponent(secretKeyId)
887
+ );
888
+ const headers = {};
889
+ const queryParameters = {};
890
+ const request = {
891
+ method: "GET",
892
+ path: requestPath,
893
+ queryParameters,
894
+ headers
895
+ };
896
+ return transporter.request(request, requestOptions);
897
+ },
898
+ /**
899
+ * Retrieves all memories, conversations and their messages for the given user token.
900
+ *
901
+ * Required API Key ACLs:
902
+ * - logs
903
+ * @param getUserData - The getUserData object.
904
+ * @param getUserData.userToken - The userToken.
905
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
906
+ */
907
+ getUserData({ userToken }, requestOptions) {
908
+ validateRequired("userToken", "getUserData", userToken);
909
+ const requestPath = "/agent-studio/1/user-data/{userToken}".replace("{userToken}", encodeURIComponent(userToken));
910
+ const headers = {};
911
+ const queryParameters = {};
912
+ const request = {
913
+ method: "GET",
914
+ path: requestPath,
915
+ queryParameters,
916
+ headers
917
+ };
918
+ return transporter.request(request, requestOptions);
919
+ },
920
+ /**
921
+ * Invalidate cached completions for this agent. Filter with `before` (exclusive).
922
+ *
923
+ * Required API Key ACLs:
924
+ * - editSettings
925
+ * @param invalidateAgentCache - The invalidateAgentCache object.
926
+ * @param invalidateAgentCache.agentId - The agentId.
927
+ * @param invalidateAgentCache.before - Delete entries strictly before this date (exclusive, YYYY-MM-DD).
928
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
929
+ */
930
+ invalidateAgentCache({ agentId, before }, requestOptions) {
931
+ validateRequired("agentId", "invalidateAgentCache", agentId);
932
+ const requestPath = "/agent-studio/1/agents/{agentId}/cache".replace("{agentId}", encodeURIComponent(agentId));
933
+ const headers = {};
934
+ const queryParameters = {};
935
+ if (before !== void 0) {
936
+ queryParameters["before"] = before.toString();
937
+ }
938
+ const request = {
939
+ method: "DELETE",
940
+ path: requestPath,
941
+ queryParameters,
942
+ headers
943
+ };
944
+ return transporter.request(request, requestOptions);
945
+ },
946
+ /**
947
+ * List all allowed domain patterns for this agent.
948
+ *
949
+ * Required API Key ACLs:
950
+ * - settings
951
+ * @param listAgentAllowedDomains - The listAgentAllowedDomains object.
952
+ * @param listAgentAllowedDomains.agentId - The agentId.
953
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
954
+ */
955
+ listAgentAllowedDomains({ agentId }, requestOptions) {
956
+ validateRequired("agentId", "listAgentAllowedDomains", agentId);
957
+ const requestPath = "/agent-studio/1/agents/{agentId}/allowed-domains".replace(
958
+ "{agentId}",
959
+ encodeURIComponent(agentId)
960
+ );
961
+ const headers = {};
962
+ const queryParameters = {};
963
+ const request = {
964
+ method: "GET",
965
+ path: requestPath,
966
+ queryParameters,
967
+ headers
968
+ };
969
+ return transporter.request(request, requestOptions);
970
+ },
971
+ /**
972
+ * Retrieves the conversations for the given agent ID.
973
+ *
974
+ * Required API Key ACLs:
975
+ * - logs
976
+ * @param listAgentConversations - The listAgentConversations object.
977
+ * @param listAgentConversations.agentId - The agentId.
978
+ * @param listAgentConversations.startDate - Filter conversations created after this date (format: YYYY-MM-DD).
979
+ * @param listAgentConversations.endDate - Filter conversations created before this date (format: YYYY-MM-DD).
980
+ * @param listAgentConversations.includeFeedback - Include feedback per conversation.
981
+ * @param listAgentConversations.feedbackVote - Filter by feedback value (requires includeFeedback=true).
982
+ * @param listAgentConversations.page - Page number.
983
+ * @param listAgentConversations.limit - Items per page.
984
+ * @param listAgentConversations.xAlgoliaSecureUserToken - The X-Algolia-Secure-User-Token.
985
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
986
+ */
987
+ listAgentConversations({
988
+ agentId,
989
+ startDate,
990
+ endDate,
991
+ includeFeedback,
992
+ feedbackVote,
993
+ page,
994
+ limit,
995
+ xAlgoliaSecureUserToken
996
+ }, requestOptions) {
997
+ validateRequired("agentId", "listAgentConversations", agentId);
998
+ const requestPath = "/agent-studio/1/agents/{agentId}/conversations".replace(
999
+ "{agentId}",
1000
+ encodeURIComponent(agentId)
1001
+ );
1002
+ const headers = {};
1003
+ const queryParameters = {};
1004
+ if (startDate !== void 0) {
1005
+ queryParameters["startDate"] = startDate.toString();
1006
+ }
1007
+ if (endDate !== void 0) {
1008
+ queryParameters["endDate"] = endDate.toString();
1009
+ }
1010
+ if (includeFeedback !== void 0) {
1011
+ queryParameters["includeFeedback"] = includeFeedback.toString();
1012
+ }
1013
+ if (feedbackVote !== void 0) {
1014
+ queryParameters["feedbackVote"] = feedbackVote.toString();
1015
+ }
1016
+ if (page !== void 0) {
1017
+ queryParameters["page"] = page.toString();
1018
+ }
1019
+ if (limit !== void 0) {
1020
+ queryParameters["limit"] = limit.toString();
1021
+ }
1022
+ if (xAlgoliaSecureUserToken !== void 0) {
1023
+ headers["X-Algolia-Secure-User-Token"] = xAlgoliaSecureUserToken.toString();
1024
+ }
1025
+ const request = {
1026
+ method: "GET",
1027
+ path: requestPath,
1028
+ queryParameters,
1029
+ headers
1030
+ };
1031
+ return transporter.request(request, requestOptions);
1032
+ },
1033
+ /**
1034
+ * List all agents with pagination and filtering.
1035
+ *
1036
+ * Required API Key ACLs:
1037
+ * - settings
1038
+ * @param listAgents - The listAgents object.
1039
+ * @param listAgents.page - Page number.
1040
+ * @param listAgents.limit - Items per page.
1041
+ * @param listAgents.providerId - Filter by provider id.
1042
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1043
+ */
1044
+ listAgents({ page, limit, providerId } = {}, requestOptions = void 0) {
1045
+ const requestPath = "/agent-studio/1/agents";
1046
+ const headers = {};
1047
+ const queryParameters = {};
1048
+ if (page !== void 0) {
1049
+ queryParameters["page"] = page.toString();
1050
+ }
1051
+ if (limit !== void 0) {
1052
+ queryParameters["limit"] = limit.toString();
1053
+ }
1054
+ if (providerId !== void 0) {
1055
+ queryParameters["providerId"] = providerId.toString();
1056
+ }
1057
+ const request = {
1058
+ method: "GET",
1059
+ path: requestPath,
1060
+ queryParameters,
1061
+ headers
1062
+ };
1063
+ return transporter.request(request, requestOptions);
1064
+ },
1065
+ /**
1066
+ * Get Provider Models.
1067
+ *
1068
+ * Required API Key ACLs:
1069
+ * - settings
1070
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1071
+ */
1072
+ listModels(requestOptions) {
1073
+ const requestPath = "/agent-studio/1/providers/models";
1074
+ const headers = {};
1075
+ const queryParameters = {};
1076
+ const request = {
1077
+ method: "GET",
1078
+ path: requestPath,
1079
+ queryParameters,
1080
+ headers
1081
+ };
1082
+ return transporter.request(request, requestOptions);
1083
+ },
1084
+ /**
1085
+ * Get available models for a specific provider.
1086
+ *
1087
+ * Required API Key ACLs:
1088
+ * - settings
1089
+ * @param listProviderModels - The listProviderModels object.
1090
+ * @param listProviderModels.providerId - The providerId.
1091
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1092
+ */
1093
+ listProviderModels({ providerId }, requestOptions) {
1094
+ validateRequired("providerId", "listProviderModels", providerId);
1095
+ const requestPath = "/agent-studio/1/providers/{providerId}/models".replace(
1096
+ "{providerId}",
1097
+ encodeURIComponent(providerId)
1098
+ );
1099
+ const headers = {};
1100
+ const queryParameters = {};
1101
+ const request = {
1102
+ method: "GET",
1103
+ path: requestPath,
1104
+ queryParameters,
1105
+ headers
1106
+ };
1107
+ return transporter.request(request, requestOptions);
1108
+ },
1109
+ /**
1110
+ * List Providers.
1111
+ *
1112
+ * Required API Key ACLs:
1113
+ * - settings
1114
+ * @param listProviders - The listProviders object.
1115
+ * @param listProviders.page - Page number.
1116
+ * @param listProviders.limit - Items per page.
1117
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1118
+ */
1119
+ listProviders({ page, limit } = {}, requestOptions = void 0) {
1120
+ const requestPath = "/agent-studio/1/providers";
1121
+ const headers = {};
1122
+ const queryParameters = {};
1123
+ if (page !== void 0) {
1124
+ queryParameters["page"] = page.toString();
1125
+ }
1126
+ if (limit !== void 0) {
1127
+ queryParameters["limit"] = limit.toString();
1128
+ }
1129
+ const request = {
1130
+ method: "GET",
1131
+ path: requestPath,
1132
+ queryParameters,
1133
+ headers
1134
+ };
1135
+ return transporter.request(request, requestOptions);
1136
+ },
1137
+ /**
1138
+ * List Secret Keys.
1139
+ *
1140
+ * Required API Key ACLs:
1141
+ * - settings
1142
+ * @param listSecretKeys - The listSecretKeys object.
1143
+ * @param listSecretKeys.page - Page number.
1144
+ * @param listSecretKeys.limit - Items per page.
1145
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1146
+ */
1147
+ listSecretKeys({ page, limit } = {}, requestOptions = void 0) {
1148
+ const requestPath = "/agent-studio/1/secret-keys";
1149
+ const headers = {};
1150
+ const queryParameters = {};
1151
+ if (page !== void 0) {
1152
+ queryParameters["page"] = page.toString();
1153
+ }
1154
+ if (limit !== void 0) {
1155
+ queryParameters["limit"] = limit.toString();
1156
+ }
1157
+ const request = {
1158
+ method: "GET",
1159
+ path: requestPath,
1160
+ queryParameters,
1161
+ headers
1162
+ };
1163
+ return transporter.request(request, requestOptions);
1164
+ },
1165
+ /**
1166
+ * Publish the specified agent.
1167
+ *
1168
+ * Required API Key ACLs:
1169
+ * - editSettings
1170
+ * @param publishAgent - The publishAgent object.
1171
+ * @param publishAgent.agentId - The agentId.
1172
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1173
+ */
1174
+ publishAgent({ agentId }, requestOptions) {
1175
+ validateRequired("agentId", "publishAgent", agentId);
1176
+ const requestPath = "/agent-studio/1/agents/{agentId}/publish".replace("{agentId}", encodeURIComponent(agentId));
1177
+ const headers = {};
1178
+ const queryParameters = {};
1179
+ const request = {
1180
+ method: "POST",
1181
+ path: requestPath,
1182
+ queryParameters,
1183
+ headers
1184
+ };
1185
+ return transporter.request(request, requestOptions);
1186
+ },
1187
+ /**
1188
+ * Unpublish the specified agent.
1189
+ *
1190
+ * Required API Key ACLs:
1191
+ * - editSettings
1192
+ * @param unpublishAgent - The unpublishAgent object.
1193
+ * @param unpublishAgent.agentId - The agentId.
1194
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1195
+ */
1196
+ unpublishAgent({ agentId }, requestOptions) {
1197
+ validateRequired("agentId", "unpublishAgent", agentId);
1198
+ const requestPath = "/agent-studio/1/agents/{agentId}/unpublish".replace(
1199
+ "{agentId}",
1200
+ encodeURIComponent(agentId)
1201
+ );
1202
+ const headers = {};
1203
+ const queryParameters = {};
1204
+ const request = {
1205
+ method: "POST",
1206
+ path: requestPath,
1207
+ queryParameters,
1208
+ headers
1209
+ };
1210
+ return transporter.request(request, requestOptions);
1211
+ },
1212
+ /**
1213
+ * Update the specified agent.
1214
+ *
1215
+ * Required API Key ACLs:
1216
+ * - editSettings
1217
+ * @param updateAgent - The updateAgent object.
1218
+ * @param updateAgent.agentId - The agentId.
1219
+ * @param updateAgent.agentConfigUpdate - The agentConfigUpdate object.
1220
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1221
+ */
1222
+ updateAgent({ agentId, agentConfigUpdate }, requestOptions) {
1223
+ validateRequired("agentId", "updateAgent", agentId);
1224
+ validateRequired("agentConfigUpdate", "updateAgent", agentConfigUpdate);
1225
+ const requestPath = "/agent-studio/1/agents/{agentId}".replace("{agentId}", encodeURIComponent(agentId));
1226
+ const headers = {};
1227
+ const queryParameters = {};
1228
+ const request = {
1229
+ method: "PATCH",
1230
+ path: requestPath,
1231
+ queryParameters,
1232
+ headers,
1233
+ data: agentConfigUpdate
1234
+ };
1235
+ return transporter.request(request, requestOptions);
1236
+ },
1237
+ /**
1238
+ * Patch Configuration.
1239
+ *
1240
+ * Required API Key ACLs:
1241
+ * - logs
1242
+ * @param applicationConfigPatch - The applicationConfigPatch object.
1243
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1244
+ */
1245
+ updateConfiguration(applicationConfigPatch, requestOptions) {
1246
+ validateRequired("applicationConfigPatch", "updateConfiguration", applicationConfigPatch);
1247
+ const requestPath = "/agent-studio/1/configuration";
1248
+ const headers = {};
1249
+ const queryParameters = {};
1250
+ const request = {
1251
+ method: "PATCH",
1252
+ path: requestPath,
1253
+ queryParameters,
1254
+ headers,
1255
+ data: applicationConfigPatch
1256
+ };
1257
+ return transporter.request(request, requestOptions);
1258
+ },
1259
+ /**
1260
+ * Update Provider.
1261
+ *
1262
+ * Required API Key ACLs:
1263
+ * - editSettings
1264
+ * @param updateProvider - The updateProvider object.
1265
+ * @param updateProvider.providerId - The providerId.
1266
+ * @param updateProvider.providerAuthenticationPatch - The providerAuthenticationPatch object.
1267
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1268
+ */
1269
+ updateProvider({ providerId, providerAuthenticationPatch }, requestOptions) {
1270
+ validateRequired("providerId", "updateProvider", providerId);
1271
+ validateRequired("providerAuthenticationPatch", "updateProvider", providerAuthenticationPatch);
1272
+ const requestPath = "/agent-studio/1/providers/{providerId}".replace(
1273
+ "{providerId}",
1274
+ encodeURIComponent(providerId)
1275
+ );
1276
+ const headers = {};
1277
+ const queryParameters = {};
1278
+ const request = {
1279
+ method: "PATCH",
1280
+ path: requestPath,
1281
+ queryParameters,
1282
+ headers,
1283
+ data: providerAuthenticationPatch
1284
+ };
1285
+ return transporter.request(request, requestOptions);
1286
+ },
1287
+ /**
1288
+ * Patch Secret Key.
1289
+ *
1290
+ * Required API Key ACLs:
1291
+ * - admin
1292
+ * @param updateSecretKey - The updateSecretKey object.
1293
+ * @param updateSecretKey.secretKeyId - The secretKeyId.
1294
+ * @param updateSecretKey.secretKeyPatch - The secretKeyPatch object.
1295
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1296
+ */
1297
+ updateSecretKey({ secretKeyId, secretKeyPatch }, requestOptions) {
1298
+ validateRequired("secretKeyId", "updateSecretKey", secretKeyId);
1299
+ validateRequired("secretKeyPatch", "updateSecretKey", secretKeyPatch);
1300
+ const requestPath = "/agent-studio/1/secret-keys/{secretKeyId}".replace(
1301
+ "{secretKeyId}",
1302
+ encodeURIComponent(secretKeyId)
1303
+ );
1304
+ const headers = {};
1305
+ const queryParameters = {};
1306
+ const request = {
1307
+ method: "PATCH",
1308
+ path: requestPath,
1309
+ queryParameters,
1310
+ headers,
1311
+ data: secretKeyPatch
1312
+ };
1313
+ return transporter.request(request, requestOptions);
1314
+ }
1315
+ };
1316
+ }
1317
+
1318
+ // builds/node.ts
1319
+ function agentStudioClient(appId, apiKey, options) {
1320
+ if (!appId || typeof appId !== "string") {
1321
+ throw new Error("`appId` is missing.");
1322
+ }
1323
+ if (!apiKey || typeof apiKey !== "string") {
1324
+ throw new Error("`apiKey` is missing.");
1325
+ }
1326
+ return {
1327
+ ...createAgentStudioClient({
1328
+ appId,
1329
+ apiKey,
1330
+ timeouts: {
1331
+ connect: 25e3,
1332
+ read: 25e3,
1333
+ write: 25e3
1334
+ },
1335
+ logger: createNullLogger(),
1336
+ requester: createHttpRequester(),
1337
+ algoliaAgents: [{ segment: "Node.js", version: process.versions.node }],
1338
+ responsesCache: createNullCache(),
1339
+ requestsCache: createNullCache(),
1340
+ hostsCache: createMemoryCache(),
1341
+ compress: async (data) => gzipSync(Buffer.from(data)),
1342
+ ...options
1343
+ }),
1344
+ forgeSecuredUserToken({
1345
+ secretKey,
1346
+ secretKeyId,
1347
+ userId,
1348
+ expiresIn = 24 * 3600
1349
+ // 24 hours
1350
+ }) {
1351
+ const header = Buffer.from(JSON.stringify({ alg: "HS256", typ: "JWT", kid: secretKeyId })).toString("base64url");
1352
+ const payload = Buffer.from(
1353
+ JSON.stringify({ sub: userId, exp: Math.floor(Date.now() / 1e3) + expiresIn })
1354
+ ).toString("base64url");
1355
+ const signature = createHmac("sha256", secretKey).update(`${header}.${payload}`).digest("base64url");
1356
+ return `${header}.${payload}.${signature}`;
1357
+ }
1358
+ };
1359
+ }
1360
+ export {
1361
+ agentStudioClient,
1362
+ apiClientVersion
1363
+ };
1364
+ //# sourceMappingURL=node.js.map