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