@cdot65/prisma-airs-sdk 0.2.0 → 0.4.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.
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
23
23
  var MAX_CONNECTION_POOL_SIZE = 100;
24
24
  var MAX_NUMBER_OF_RETRIES = 5;
25
25
  var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
26
- var SDK_VERSION = "0.1.2";
26
+ var SDK_VERSION = "0.4.0";
27
27
  var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
28
28
  var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
29
29
  var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
@@ -41,6 +41,41 @@ var MGMT_PROFILES_TSG_PATH = "/v1/mgmt/profiles/tsg";
41
41
  var MGMT_TOPIC_PATH = "/v1/mgmt/topic";
42
42
  var MGMT_TOPICS_TSG_PATH = "/v1/mgmt/topics/tsg";
43
43
  var MGMT_TOPIC_FORCE_PATH = "/v1/mgmt/topic/force";
44
+ var DEFAULT_MODEL_SEC_DATA_ENDPOINT = "https://api.sase.paloaltonetworks.com/aims/data";
45
+ var DEFAULT_MODEL_SEC_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aims/mgmt";
46
+ var MODEL_SEC_CLIENT_ID = "PANW_MODEL_SEC_CLIENT_ID";
47
+ var MODEL_SEC_CLIENT_SECRET = "PANW_MODEL_SEC_CLIENT_SECRET";
48
+ var MODEL_SEC_TSG_ID = "PANW_MODEL_SEC_TSG_ID";
49
+ var MODEL_SEC_DATA_ENDPOINT = "PANW_MODEL_SEC_DATA_ENDPOINT";
50
+ var MODEL_SEC_MGMT_ENDPOINT = "PANW_MODEL_SEC_MGMT_ENDPOINT";
51
+ var MODEL_SEC_TOKEN_ENDPOINT = "PANW_MODEL_SEC_TOKEN_ENDPOINT";
52
+ var MODEL_SEC_SCANS_PATH = "/v1/scans";
53
+ var MODEL_SEC_EVALUATIONS_PATH = "/v1/evaluations";
54
+ var MODEL_SEC_VIOLATIONS_PATH = "/v1/violations";
55
+ var MODEL_SEC_SECURITY_GROUPS_PATH = "/v1/security-groups";
56
+ var MODEL_SEC_SECURITY_RULES_PATH = "/v1/security-rules";
57
+ var MODEL_SEC_PYPI_AUTH_PATH = "/v1/pypi/authenticate";
58
+ var DEFAULT_RED_TEAM_DATA_ENDPOINT = "https://api.sase.paloaltonetworks.com/ai-red-teaming/data-plane";
59
+ var DEFAULT_RED_TEAM_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/ai-red-teaming/mgmt-plane";
60
+ var RED_TEAM_CLIENT_ID = "PANW_RED_TEAM_CLIENT_ID";
61
+ var RED_TEAM_CLIENT_SECRET = "PANW_RED_TEAM_CLIENT_SECRET";
62
+ var RED_TEAM_TSG_ID = "PANW_RED_TEAM_TSG_ID";
63
+ var RED_TEAM_DATA_ENDPOINT = "PANW_RED_TEAM_DATA_ENDPOINT";
64
+ var RED_TEAM_MGMT_ENDPOINT = "PANW_RED_TEAM_MGMT_ENDPOINT";
65
+ var RED_TEAM_TOKEN_ENDPOINT = "PANW_RED_TEAM_TOKEN_ENDPOINT";
66
+ var RED_TEAM_SCAN_PATH = "/v1/scan";
67
+ var RED_TEAM_CATEGORIES_PATH = "/v1/categories";
68
+ var RED_TEAM_REPORT_STATIC_PATH = "/v1/report/static";
69
+ var RED_TEAM_REPORT_DYNAMIC_PATH = "/v1/report/dynamic";
70
+ var RED_TEAM_REPORT_PATH = "/v1/report";
71
+ var RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH = "/v1/custom-attacks";
72
+ var RED_TEAM_DASHBOARD_PATH = "/v1/dashboard";
73
+ var RED_TEAM_QUOTA_PATH = "/v1/metering/quota";
74
+ var RED_TEAM_ERROR_LOG_PATH = "/v1/error-log/job";
75
+ var RED_TEAM_SENTIMENT_PATH = "/v1/sentiment";
76
+ var RED_TEAM_TARGET_PATH = "/v1/target";
77
+ var RED_TEAM_CUSTOM_ATTACK_PATH = "/v1/custom-attack";
78
+ var RED_TEAM_MGMT_DASHBOARD_PATH = "/v1/dashboard/overview";
44
79
 
45
80
  // src/errors.ts
46
81
  var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
@@ -54,6 +89,10 @@ var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
54
89
  })(ErrorType || {});
55
90
  var AISecSDKException = class _AISecSDKException extends Error {
56
91
  errorType;
92
+ /**
93
+ * @param message - Human-readable error description.
94
+ * @param errorType - Classification of the error.
95
+ */
57
96
  constructor(message, errorType) {
58
97
  super(errorType ? `${errorType}:${message}` : message);
59
98
  this.name = "AISecSDKException";
@@ -135,6 +174,68 @@ function init(opts = {}) {
135
174
  globalConfiguration.init(opts);
136
175
  }
137
176
 
177
+ // src/http-retry.ts
178
+ function sleep(ms) {
179
+ return new Promise((resolve) => setTimeout(resolve, ms));
180
+ }
181
+ function backoffDelay(attempt) {
182
+ return Math.pow(2, attempt) * 1e3;
183
+ }
184
+ function isRetryableStatus(status) {
185
+ return HTTP_FORCE_RETRY_STATUS_CODES.includes(status);
186
+ }
187
+ function classifyErrorType(status) {
188
+ return status >= 500 ? "AISEC_SERVER_SIDE_ERROR" /* SERVER_SIDE_ERROR */ : "AISEC_CLIENT_SIDE_ERROR" /* CLIENT_SIDE_ERROR */;
189
+ }
190
+ function extractErrorMessage(body, status) {
191
+ try {
192
+ const parsed = JSON.parse(body);
193
+ return parsed.error_message ?? parsed.message ?? parsed.error?.message ?? `API error ${status}`;
194
+ } catch {
195
+ return body ? `API error ${status}: ${body}` : `API error ${status}`;
196
+ }
197
+ }
198
+ async function executeWithRetry(opts) {
199
+ const { maxRetries, execute, onRetryableFailure } = opts;
200
+ let lastError;
201
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
202
+ let response;
203
+ try {
204
+ response = await execute(attempt);
205
+ } catch (err) {
206
+ if (err instanceof AISecSDKException) throw err;
207
+ lastError = err;
208
+ if (attempt < maxRetries) {
209
+ await sleep(backoffDelay(attempt));
210
+ continue;
211
+ }
212
+ throw new AISecSDKException(
213
+ lastError.message ?? "Network error",
214
+ "AISEC_CLIENT_SIDE_ERROR" /* CLIENT_SIDE_ERROR */
215
+ );
216
+ }
217
+ if (response.ok) return response;
218
+ if (onRetryableFailure) {
219
+ const handled = await onRetryableFailure(response, attempt);
220
+ if (handled) {
221
+ attempt--;
222
+ continue;
223
+ }
224
+ }
225
+ if (isRetryableStatus(response.status) && attempt < maxRetries) {
226
+ await sleep(backoffDelay(attempt));
227
+ continue;
228
+ }
229
+ const errorText = await response.text();
230
+ const errorMessage = extractErrorMessage(errorText, response.status);
231
+ throw new AISecSDKException(errorMessage, classifyErrorType(response.status));
232
+ }
233
+ throw new AISecSDKException(
234
+ lastError?.message ?? "Max retries exceeded",
235
+ "AISEC_CLIENT_SIDE_ERROR" /* CLIENT_SIDE_ERROR */
236
+ );
237
+ }
238
+
138
239
  // src/utils.ts
139
240
  import { createHmac } from "crypto";
140
241
  var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -160,9 +261,6 @@ function buildHeaders() {
160
261
  }
161
262
  return headers;
162
263
  }
163
- function sleep(ms) {
164
- return new Promise((resolve) => setTimeout(resolve, ms));
165
- }
166
264
  async function httpRequest(opts) {
167
265
  if (!globalConfiguration.initialized) {
168
266
  throw new AISecSDKException(
@@ -185,48 +283,27 @@ async function httpRequest(opts) {
185
283
  headers[PAYLOAD_HASH] = generatePayloadHash(bodyStr, globalConfiguration.apiKey);
186
284
  }
187
285
  }
188
- const maxRetries = globalConfiguration.numRetries;
189
- let lastError;
190
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
191
- try {
192
- const response = await fetch(url.toString(), {
193
- method: opts.method,
194
- headers,
195
- body: bodyStr
196
- });
197
- if (response.ok) {
198
- const data = await response.json();
199
- return { status: response.status, data };
200
- }
201
- if (HTTP_FORCE_RETRY_STATUS_CODES.includes(response.status) && attempt < maxRetries) {
202
- await sleep(Math.pow(2, attempt) * 1e3);
203
- continue;
204
- }
205
- let errorMessage;
206
- try {
207
- const errorBody = await response.json();
208
- errorMessage = errorBody.message ?? errorBody.error?.message ?? `API error ${response.status}`;
209
- } catch {
210
- errorMessage = `API error ${response.status}`;
211
- }
212
- const errorType = response.status >= 500 ? "AISEC_SERVER_SIDE_ERROR" /* SERVER_SIDE_ERROR */ : "AISEC_CLIENT_SIDE_ERROR" /* CLIENT_SIDE_ERROR */;
213
- throw new AISecSDKException(errorMessage, errorType);
214
- } catch (err) {
215
- if (err instanceof AISecSDKException) {
216
- throw err;
217
- }
218
- lastError = err;
219
- if (attempt < maxRetries) {
220
- await sleep(Math.pow(2, attempt) * 1e3);
221
- continue;
222
- }
223
- }
224
- }
225
- throw new AISecSDKException(lastError?.message ?? "Network error", "AISEC_CLIENT_SIDE_ERROR" /* CLIENT_SIDE_ERROR */);
286
+ const response = await executeWithRetry({
287
+ maxRetries: globalConfiguration.numRetries,
288
+ execute: () => fetch(url.toString(), {
289
+ method: opts.method,
290
+ headers,
291
+ body: bodyStr
292
+ })
293
+ });
294
+ const data = await response.json();
295
+ return { status: response.status, data };
226
296
  }
227
297
 
228
298
  // src/scan/scanner.ts
229
299
  var Scanner = class {
300
+ /**
301
+ * Perform a synchronous content scan.
302
+ * @param aiProfile - AI security profile to scan against.
303
+ * @param content - Content to scan.
304
+ * @param opts - Optional transaction/session IDs and metadata.
305
+ * @returns Scan response with verdict, action, and detection details.
306
+ */
230
307
  async syncScan(aiProfile, content, opts = {}) {
231
308
  if (opts.trId && opts.trId.length > MAX_TRANSACTION_ID_STR_LENGTH) {
232
309
  throw new AISecSDKException(
@@ -254,6 +331,11 @@ var Scanner = class {
254
331
  });
255
332
  return res.data;
256
333
  }
334
+ /**
335
+ * Submit content for asynchronous scanning.
336
+ * @param scanObjects - Array of scan objects (1–5 items).
337
+ * @returns Response containing scan IDs for later querying.
338
+ */
257
339
  async asyncScan(scanObjects) {
258
340
  if (scanObjects.length < 1) {
259
341
  throw new AISecSDKException(
@@ -274,6 +356,11 @@ var Scanner = class {
274
356
  });
275
357
  return res.data;
276
358
  }
359
+ /**
360
+ * Query scan results by scan IDs.
361
+ * @param scanIds - Array of scan UUIDs (1–5 items).
362
+ * @returns Array of scan results with status and response data.
363
+ */
277
364
  async queryByScanIds(scanIds) {
278
365
  if (scanIds.length < 1) {
279
366
  throw new AISecSDKException(
@@ -299,6 +386,11 @@ var Scanner = class {
299
386
  });
300
387
  return res.data;
301
388
  }
389
+ /**
390
+ * Query detailed threat reports by report IDs.
391
+ * @param reportIds - Array of report IDs (1–5 items).
392
+ * @returns Array of threat scan reports with detection details.
393
+ */
302
394
  async queryByReportIds(reportIds) {
303
395
  if (reportIds.length < 1) {
304
396
  throw new AISecSDKException(
@@ -410,6 +502,7 @@ var Content = class _Content {
410
502
  set toolEvent(value) {
411
503
  this._toolEvent = value;
412
504
  }
505
+ /** Total byte length of all text content fields. */
413
506
  get length() {
414
507
  let total = 0;
415
508
  if (this._prompt) total += Buffer.byteLength(this._prompt);
@@ -419,6 +512,7 @@ var Content = class _Content {
419
512
  if (this._codeResponse) total += Buffer.byteLength(this._codeResponse);
420
513
  return total;
421
514
  }
515
+ /** Serialize to the API request format. */
422
516
  toJSON() {
423
517
  const obj = {};
424
518
  if (this._prompt !== void 0) obj.prompt = this._prompt;
@@ -429,6 +523,10 @@ var Content = class _Content {
429
523
  if (this._toolEvent !== void 0) obj.tool_event = this._toolEvent;
430
524
  return obj;
431
525
  }
526
+ /**
527
+ * Create a Content instance from an API response object.
528
+ * @param json - Scan request contents inner object.
529
+ */
432
530
  static fromJSON(json) {
433
531
  return new _Content({
434
532
  prompt: json.prompt,
@@ -439,6 +537,10 @@ var Content = class _Content {
439
537
  toolEvent: json.tool_event
440
538
  });
441
539
  }
540
+ /**
541
+ * Load content from a JSON file.
542
+ * @param filePath - Path to JSON file containing scan request contents.
543
+ */
442
544
  static fromJSONFile(filePath) {
443
545
  const raw = readFileSync(filePath, "utf-8");
444
546
  const parsed = JSON.parse(raw);
@@ -446,6 +548,23 @@ var Content = class _Content {
446
548
  }
447
549
  };
448
550
 
551
+ // src/models/enums.ts
552
+ var Verdict = {
553
+ BENIGN: "benign",
554
+ MALICIOUS: "malicious",
555
+ UNKNOWN: "unknown"
556
+ };
557
+ var Action = {
558
+ ALLOW: "allow",
559
+ BLOCK: "block",
560
+ ALERT: "alert"
561
+ };
562
+ var Category = {
563
+ BENIGN: "benign",
564
+ MALICIOUS: "malicious",
565
+ UNKNOWN: "unknown"
566
+ };
567
+
449
568
  // src/models/ai-profile.ts
450
569
  import { z } from "zod";
451
570
  var AiProfileSchema = z.object({
@@ -791,13 +910,1402 @@ var DeleteTopicConflictSchema = z16.object({
791
910
  )
792
911
  }).passthrough();
793
912
 
794
- // src/models/oauth-token.ts
913
+ // src/models/model-security-enums.ts
914
+ var ErrorCodes = {
915
+ UNKNOWN_ERROR: "UNKNOWN_ERROR",
916
+ SCAN_ERROR: "SCAN_ERROR",
917
+ INVALID_RESPONSE: "INVALID_RESPONSE",
918
+ ACCESS_DENIED: "ACCESS_DENIED",
919
+ MISSING_CREDENTIALS: "MISSING_CREDENTIALS",
920
+ NO_SUCH_KEY: "NO_SUCH_KEY",
921
+ NO_SUCH_BUCKET: "NO_SUCH_BUCKET",
922
+ INVALID_BUCKET_NAME: "INVALID_BUCKET_NAME",
923
+ INTERNAL_ERROR: "INTERNAL_ERROR",
924
+ SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE",
925
+ INVALID_OBJECT_STATE: "INVALID_OBJECT_STATE",
926
+ UNKNOWN_REMOTE_SERVICE_ERROR: "UNKNOWN_REMOTE_SERVICE_ERROR",
927
+ UNSUPPORTED_REMOTE_STORAGE: "UNSUPPORTED_REMOTE_STORAGE",
928
+ MISSING_ARTIFACTS: "MISSING_ARTIFACTS",
929
+ WORKER_ERROR: "WORKER_ERROR",
930
+ POLICY_EVAL_ERROR: "POLICY_EVAL_ERROR"
931
+ };
932
+ var EvalOutcome = {
933
+ PENDING: "PENDING",
934
+ ALLOWED: "ALLOWED",
935
+ BLOCKED: "BLOCKED",
936
+ ERROR: "ERROR"
937
+ };
938
+ var FileScanResult = {
939
+ SKIPPED: "SKIPPED",
940
+ SUCCESS: "SUCCESS",
941
+ ERROR: "ERROR",
942
+ FAILED: "FAILED"
943
+ };
944
+ var FileType = {
945
+ DIRECTORY: "DIRECTORY",
946
+ FILE: "FILE"
947
+ };
948
+ var ModelScanStatus = {
949
+ SCANNED: "SCANNED",
950
+ SKIPPED: "SKIPPED",
951
+ ERROR: "ERROR"
952
+ };
953
+ var RuleEvaluationResult = {
954
+ PASSED: "PASSED",
955
+ FAILED: "FAILED",
956
+ ERROR: "ERROR"
957
+ };
958
+ var RuleState = {
959
+ DISABLED: "DISABLED",
960
+ ALLOWING: "ALLOWING",
961
+ BLOCKING: "BLOCKING"
962
+ };
963
+ var ScanOrigin = {
964
+ MODEL_SECURITY_SDK: "MODEL_SECURITY_SDK",
965
+ HUGGING_FACE: "HUGGING_FACE"
966
+ };
967
+ var SortByDateField = {
968
+ CREATED_AT: "created_at",
969
+ UPDATED_AT: "updated_at"
970
+ };
971
+ var SortByFileField = {
972
+ PATH: "path",
973
+ TYPE: "type"
974
+ };
975
+ var SortDirection = {
976
+ ASC: "asc",
977
+ DESC: "desc"
978
+ };
979
+ var SourceType = {
980
+ LOCAL: "LOCAL",
981
+ HUGGING_FACE: "HUGGING_FACE",
982
+ S3: "S3",
983
+ GCS: "GCS",
984
+ AZURE: "AZURE",
985
+ ARTIFACTORY: "ARTIFACTORY",
986
+ GITLAB: "GITLAB",
987
+ ALL: "ALL"
988
+ };
989
+ var ThreatCategory = {
990
+ PAIT_ARV_100: "PAIT-ARV-100",
991
+ PAIT_GGUF_100: "PAIT-GGUF-100",
992
+ PAIT_GGUF_101: "PAIT-GGUF-101",
993
+ PAIT_KERAS_100: "PAIT-KERAS-100",
994
+ PAIT_KERAS_101: "PAIT-KERAS-101",
995
+ PAIT_KERAS_102: "PAIT-KERAS-102",
996
+ PAIT_JOBLIB_100: "PAIT-JOBLIB-100",
997
+ PAIT_JOBLIB_101: "PAIT-JOBLIB-101",
998
+ PAIT_PKL_100: "PAIT-PKL-100",
999
+ PAIT_PKL_101: "PAIT-PKL-101",
1000
+ PAIT_PYTCH_100: "PAIT-PYTCH-100",
1001
+ PAIT_PYTCH_101: "PAIT-PYTCH-101",
1002
+ PAIT_EXDIR_100: "PAIT-EXDIR-100",
1003
+ PAIT_EXDIR_101: "PAIT-EXDIR-101",
1004
+ PAIT_ONNX_200: "PAIT-ONNX-200",
1005
+ PAIT_TF_200: "PAIT-TF-200",
1006
+ PAIT_LMAFL_300: "PAIT-LMAFL-300",
1007
+ PAIT_LITERT_300: "PAIT-LITERT-300",
1008
+ PAIT_LITERT_301: "PAIT-LITERT-301",
1009
+ PAIT_LITERT_302: "PAIT-LITERT-302",
1010
+ PAIT_KERAS_300: "PAIT-KERAS-300",
1011
+ PAIT_KERAS_301: "PAIT-KERAS-301",
1012
+ PAIT_TCHST_300: "PAIT-TCHST-300",
1013
+ PAIT_TCHST_301: "PAIT-TCHST-301",
1014
+ PAIT_TF_300: "PAIT-TF-300",
1015
+ PAIT_TF_301: "PAIT-TF-301",
1016
+ PAIT_TF_302: "PAIT-TF-302",
1017
+ PAIT_TMT_300: "PAIT-TMT-300",
1018
+ PAIT_TMT_301: "PAIT-TMT-301",
1019
+ UNAPPROVED_FORMATS: "UNAPPROVED_FORMATS"
1020
+ };
1021
+ var ModelSecurityGroupState = {
1022
+ PENDING: "PENDING",
1023
+ ACTIVE: "ACTIVE"
1024
+ };
1025
+ var RuleType = {
1026
+ METADATA: "METADATA",
1027
+ ARTIFACT: "ARTIFACT"
1028
+ };
1029
+ var RuleEditableFieldType = {
1030
+ SELECT: "SELECT",
1031
+ LIST: "LIST"
1032
+ };
1033
+ var RuleFieldValueKey = {
1034
+ APPROVED_FORMATS: "approved_formats",
1035
+ APPROVED_LOCATIONS: "approved_locations",
1036
+ APPROVED_LICENSES: "approved_licenses",
1037
+ DENY_ORGS: "deny_orgs",
1038
+ DENIED_ORG_MODELS: "denied_org_models",
1039
+ APPROVED_ORG_MODELS: "approved_org_models"
1040
+ };
1041
+
1042
+ // src/models/model-security.ts
795
1043
  import { z as z17 } from "zod";
796
- var OAuthTokenResponseSchema = z17.object({
797
- access_token: z17.string(),
798
- token_type: z17.string().optional(),
799
- expires_in: z17.number(),
800
- scope: z17.string().optional()
1044
+ var ModelSecurityPaginationSchema = z17.object({
1045
+ total_items: z17.number().int().nullable().optional()
1046
+ }).passthrough();
1047
+ var LabelSchema = z17.object({
1048
+ key: z17.string(),
1049
+ value: z17.string()
1050
+ });
1051
+ var LabelsCreateRequestSchema = z17.object({
1052
+ labels: z17.array(LabelSchema)
1053
+ });
1054
+ var LabelsResponseSchema = z17.object({}).passthrough();
1055
+ var LabelKeyListSchema = z17.object({
1056
+ pagination: ModelSecurityPaginationSchema,
1057
+ keys: z17.array(z17.string())
1058
+ }).passthrough();
1059
+ var LabelValueListSchema = z17.object({
1060
+ pagination: ModelSecurityPaginationSchema,
1061
+ values: z17.array(z17.string())
1062
+ }).passthrough();
1063
+ var EvalSummarySchema = z17.object({
1064
+ rules_failed: z17.number().int().optional().default(0),
1065
+ rules_passed: z17.number().int().optional().default(0),
1066
+ total_rules: z17.number().int().optional().default(0)
1067
+ }).passthrough();
1068
+ var ModelScanIssueSchema = z17.object({
1069
+ description: z17.string(),
1070
+ source: z17.string(),
1071
+ threat: z17.string().nullable().optional(),
1072
+ module: z17.string().nullable().optional(),
1073
+ operator: z17.string().nullable().optional()
1074
+ }).passthrough();
1075
+ var FileScanDataSchema = z17.object({
1076
+ file_path: z17.string(),
1077
+ modelscan_status: z17.string(),
1078
+ blob_id: z17.string(),
1079
+ error_message: z17.string().nullable().optional(),
1080
+ formats: z17.array(z17.string()).nullable().optional(),
1081
+ issues_detected: z17.array(ModelScanIssueSchema).nullable().optional()
1082
+ }).passthrough();
1083
+ var ScanDetailsSchema = z17.object({
1084
+ scanner_version: z17.string(),
1085
+ time_started: z17.string(),
1086
+ files: z17.array(FileScanDataSchema),
1087
+ total_files_scanned: z17.number().int(),
1088
+ total_files_skipped: z17.number().int(),
1089
+ model_formats: z17.array(z17.string()),
1090
+ model_size_bytes: z17.number().int(),
1091
+ scan_duration_ms: z17.number().int(),
1092
+ error_code: z17.string().nullable().optional(),
1093
+ error_message: z17.string().nullable().optional()
1094
+ });
1095
+ var ScanCreateRequestSchema = z17.object({
1096
+ model_uri: z17.string(),
1097
+ security_group_uuid: z17.string(),
1098
+ scan_origin: z17.string(),
1099
+ allow_patterns: z17.array(z17.string()).nullable().optional(),
1100
+ ignore_patterns: z17.array(z17.string()).nullable().optional(),
1101
+ labels: z17.array(LabelSchema).nullable().optional(),
1102
+ model_author: z17.string().nullable().optional(),
1103
+ model_name: z17.string().nullable().optional(),
1104
+ model_version: z17.string().nullable().optional(),
1105
+ scan_details: ScanDetailsSchema.nullable().optional()
1106
+ });
1107
+ var ScanBaseResponseSchema = z17.object({
1108
+ uuid: z17.string(),
1109
+ tsg_id: z17.string(),
1110
+ created_at: z17.string(),
1111
+ updated_at: z17.string(),
1112
+ model_uri: z17.string(),
1113
+ owner: z17.string(),
1114
+ scan_origin: z17.string(),
1115
+ security_group_uuid: z17.string(),
1116
+ security_group_name: z17.string(),
1117
+ model_version_uuid: z17.string(),
1118
+ eval_outcome: z17.string(),
1119
+ source_type: z17.string(),
1120
+ created_by: z17.string().nullable().optional(),
1121
+ enabled_rule_count_snapshot: z17.number().int().nullable().optional(),
1122
+ error_code: z17.string().nullable().optional(),
1123
+ error_message: z17.string().nullable().optional(),
1124
+ eval_summary: EvalSummarySchema.nullable().optional(),
1125
+ labels: z17.array(LabelSchema).optional(),
1126
+ model_formats: z17.array(z17.string()).nullable().optional(),
1127
+ scanner_version: z17.string().nullable().optional(),
1128
+ time_started: z17.string().nullable().optional(),
1129
+ total_files_scanned: z17.number().int().nullable().optional(),
1130
+ total_files_skipped: z17.number().int().nullable().optional()
1131
+ }).passthrough();
1132
+ var ScanListSchema = z17.object({
1133
+ pagination: ModelSecurityPaginationSchema,
1134
+ scans: z17.array(ScanBaseResponseSchema)
1135
+ }).passthrough();
1136
+ var FileResponseSchema = z17.object({
1137
+ uuid: z17.string(),
1138
+ tsg_id: z17.string(),
1139
+ created_at: z17.string(),
1140
+ updated_at: z17.string(),
1141
+ path: z17.string(),
1142
+ parent_path: z17.string(),
1143
+ type: z17.string(),
1144
+ result: z17.string(),
1145
+ model_version_uuid: z17.string(),
1146
+ blob_id: z17.string().nullable().optional(),
1147
+ formats: z17.array(z17.string()).nullable().optional(),
1148
+ scan_uuid: z17.string().nullable().optional()
1149
+ }).passthrough();
1150
+ var FileListSchema = z17.object({
1151
+ pagination: ModelSecurityPaginationSchema,
1152
+ files: z17.array(FileResponseSchema)
1153
+ }).passthrough();
1154
+ var RuleEvaluationResponseSchema = z17.object({
1155
+ uuid: z17.string(),
1156
+ tsg_id: z17.string(),
1157
+ created_at: z17.string(),
1158
+ updated_at: z17.string(),
1159
+ result: z17.string(),
1160
+ violation_count: z17.number().int(),
1161
+ rule_instance_uuid: z17.string(),
1162
+ scan_uuid: z17.string(),
1163
+ rule_name: z17.string(),
1164
+ rule_description: z17.string(),
1165
+ rule_instance_state: z17.string()
1166
+ }).passthrough();
1167
+ var RuleEvaluationListSchema = z17.object({
1168
+ pagination: ModelSecurityPaginationSchema,
1169
+ evaluations: z17.array(RuleEvaluationResponseSchema)
1170
+ }).passthrough();
1171
+ var ViolationResponseSchema = z17.object({
1172
+ uuid: z17.string(),
1173
+ tsg_id: z17.string(),
1174
+ created_at: z17.string(),
1175
+ updated_at: z17.string(),
1176
+ description: z17.string(),
1177
+ rule_instance_uuid: z17.string(),
1178
+ rule_name: z17.string(),
1179
+ rule_description: z17.string(),
1180
+ rule_instance_state: z17.string(),
1181
+ file: z17.string().nullable().optional(),
1182
+ hash: z17.string().nullable().optional(),
1183
+ module: z17.string().nullable().optional(),
1184
+ operator: z17.string().nullable().optional(),
1185
+ threat: z17.string().nullable().optional(),
1186
+ threat_description: z17.string().nullable().optional()
1187
+ }).passthrough();
1188
+ var ViolationListSchema = z17.object({
1189
+ pagination: ModelSecurityPaginationSchema,
1190
+ violations: z17.array(ViolationResponseSchema)
1191
+ }).passthrough();
1192
+ var RuleEditableFieldDropdownSchema = z17.object({
1193
+ value: z17.string(),
1194
+ label: z17.string()
1195
+ }).passthrough();
1196
+ var RuleEditableFieldSchema = z17.object({
1197
+ attribute_name: z17.string(),
1198
+ type: z17.string(),
1199
+ display_name: z17.string(),
1200
+ display_type: z17.string(),
1201
+ description: z17.string().nullable().optional(),
1202
+ dropdown_values: z17.array(RuleEditableFieldDropdownSchema).nullable().optional()
1203
+ }).passthrough();
1204
+ var RuleRemediationSchema = z17.object({
1205
+ description: z17.string(),
1206
+ steps: z17.array(z17.string()),
1207
+ url: z17.string()
1208
+ }).passthrough();
1209
+ var RuleConfigurationSchema = z17.object({
1210
+ field_values: z17.record(z17.unknown()).optional(),
1211
+ state: z17.string().nullable().optional()
1212
+ }).passthrough();
1213
+ var ModelSecurityRuleResponseSchema = z17.object({
1214
+ uuid: z17.string(),
1215
+ name: z17.string(),
1216
+ description: z17.string(),
1217
+ rule_type: z17.string(),
1218
+ compatible_sources: z17.array(z17.string()),
1219
+ default_state: z17.string(),
1220
+ remediation: RuleRemediationSchema,
1221
+ editable_fields: z17.array(RuleEditableFieldSchema),
1222
+ constant_values: z17.record(z17.unknown()),
1223
+ default_values: z17.record(z17.unknown())
1224
+ }).passthrough();
1225
+ var ListModelSecurityRulesResponseSchema = z17.object({
1226
+ pagination: ModelSecurityPaginationSchema,
1227
+ rules: z17.array(ModelSecurityRuleResponseSchema)
1228
+ }).passthrough();
1229
+ var ModelSecurityRuleInstanceResponseSchema = z17.object({
1230
+ uuid: z17.string(),
1231
+ tsg_id: z17.string(),
1232
+ created_at: z17.string(),
1233
+ updated_at: z17.string(),
1234
+ security_group_uuid: z17.string(),
1235
+ security_rule_uuid: z17.string(),
1236
+ state: z17.string(),
1237
+ rule: ModelSecurityRuleResponseSchema,
1238
+ field_values: z17.record(z17.unknown()).optional()
1239
+ }).passthrough();
1240
+ var ModelSecurityRuleInstanceUpdateRequestSchema = z17.object({
1241
+ security_group_uuid: z17.string(),
1242
+ state: z17.string().nullable().optional(),
1243
+ field_values: z17.record(z17.unknown()).nullable().optional()
1244
+ });
1245
+ var ListModelSecurityRuleInstancesResponseSchema = z17.object({
1246
+ pagination: ModelSecurityPaginationSchema,
1247
+ rule_instances: z17.array(ModelSecurityRuleInstanceResponseSchema)
1248
+ }).passthrough();
1249
+ var ModelSecurityGroupCreateRequestSchema = z17.object({
1250
+ name: z17.string(),
1251
+ source_type: z17.string(),
1252
+ description: z17.string().optional().default(""),
1253
+ rule_configurations: z17.record(RuleConfigurationSchema).optional()
1254
+ });
1255
+ var ModelSecurityGroupResponseSchema = z17.object({
1256
+ uuid: z17.string(),
1257
+ tsg_id: z17.string(),
1258
+ created_at: z17.string(),
1259
+ updated_at: z17.string(),
1260
+ name: z17.string(),
1261
+ description: z17.string(),
1262
+ source_type: z17.string(),
1263
+ state: z17.string(),
1264
+ is_tombstone: z17.boolean()
1265
+ }).passthrough();
1266
+ var ModelSecurityGroupUpdateRequestSchema = z17.object({
1267
+ name: z17.string().nullable().optional(),
1268
+ description: z17.string().nullable().optional()
1269
+ });
1270
+ var ListModelSecurityGroupsResponseSchema = z17.object({
1271
+ pagination: ModelSecurityPaginationSchema,
1272
+ security_groups: z17.array(ModelSecurityGroupResponseSchema)
1273
+ }).passthrough();
1274
+ var PyPIAuthResponseSchema = z17.object({
1275
+ url: z17.string(),
1276
+ expires_at: z17.string()
1277
+ }).passthrough();
1278
+
1279
+ // src/models/red-team-enums.ts
1280
+ var ApiEndpointType = {
1281
+ PUBLIC: "PUBLIC",
1282
+ PRIVATE: "PRIVATE",
1283
+ NETWORK_BROKER: "NETWORK_BROKER"
1284
+ };
1285
+ var AttackStatus = {
1286
+ INIT: "INIT",
1287
+ ATTACK: "ATTACK",
1288
+ DETECTION: "DETECTION",
1289
+ REPORT: "REPORT",
1290
+ COMPLETED: "COMPLETED",
1291
+ FAILED: "FAILED"
1292
+ };
1293
+ var AttackType = {
1294
+ NORMAL: "NORMAL",
1295
+ CUSTOM: "CUSTOM"
1296
+ };
1297
+ var AuthType = {
1298
+ OAUTH: "OAUTH",
1299
+ ACCESS_TOKEN: "ACCESS_TOKEN"
1300
+ };
1301
+ var BrandSubCategory = {
1302
+ COMPETITOR_ENDORSEMENTS: "COMPETITOR_ENDORSEMENTS",
1303
+ BRAND_TARNISHING_SELF_CRITICISM: "BRAND_TARNISHING_SELF_CRITICISM",
1304
+ DISCRIMINATING_CLAIMS: "DISCRIMINATING_CLAIMS",
1305
+ POLITICAL_ENDORSEMENTS: "POLITICAL_ENDORSEMENTS"
1306
+ };
1307
+ var ComplianceSubCategory = {
1308
+ OWASP: "OWASP",
1309
+ MITRE_ATLAS: "MITRE_ATLAS",
1310
+ NIST: "NIST",
1311
+ DASF_V2: "DASF_V2"
1312
+ };
1313
+ var CountedQuotaEnum = {
1314
+ HELD: "HELD",
1315
+ COUNTED: "COUNTED",
1316
+ NOT_COUNTED: "NOT_COUNTED"
1317
+ };
1318
+ var DateRangeFilter = {
1319
+ LAST_7_DAYS: "LAST_7_DAYS",
1320
+ LAST_15_DAYS: "LAST_15_DAYS",
1321
+ LAST_30_DAYS: "LAST_30_DAYS",
1322
+ ALL: "ALL"
1323
+ };
1324
+ var ErrorSource = {
1325
+ TARGET: "TARGET",
1326
+ JOB: "JOB",
1327
+ SYSTEM: "SYSTEM",
1328
+ VALIDATION: "VALIDATION",
1329
+ TARGET_PROFILING: "TARGET_PROFILING"
1330
+ };
1331
+ var RedTeamErrorType = {
1332
+ CONTENT_FILTER: "CONTENT_FILTER",
1333
+ RATE_LIMIT: "RATE_LIMIT",
1334
+ AUTHENTICATION: "AUTHENTICATION",
1335
+ NETWORK: "NETWORK",
1336
+ VALIDATION: "VALIDATION",
1337
+ NETWORK_CHANNEL: "NETWORK_CHANNEL",
1338
+ UNKNOWN: "UNKNOWN"
1339
+ };
1340
+ var FileFormat = {
1341
+ CSV: "CSV",
1342
+ JSON: "JSON",
1343
+ ALL: "ALL"
1344
+ };
1345
+ var GoalType = {
1346
+ BASE: "BASE",
1347
+ TOOL_MISUSE: "TOOL_MISUSE",
1348
+ GOAL_MANIPULATION: "GOAL_MANIPULATION"
1349
+ };
1350
+ var GoalTypeQueryParam = {
1351
+ AGENT: "AGENT",
1352
+ HUMAN_AUGMENTED: "HUMAN_AUGMENTED"
1353
+ };
1354
+ var GuardrailAction = {
1355
+ ALLOW: "ALLOW",
1356
+ BLOCK: "BLOCK"
1357
+ };
1358
+ var JobStatus = {
1359
+ INIT: "INIT",
1360
+ QUEUED: "QUEUED",
1361
+ RUNNING: "RUNNING",
1362
+ COMPLETED: "COMPLETED",
1363
+ PARTIALLY_COMPLETE: "PARTIALLY_COMPLETE",
1364
+ FAILED: "FAILED",
1365
+ ABORTED: "ABORTED"
1366
+ };
1367
+ var JobStatusFilter = {
1368
+ QUEUED: "QUEUED",
1369
+ RUNNING: "RUNNING",
1370
+ COMPLETED: "COMPLETED",
1371
+ PARTIALLY_COMPLETE: "PARTIALLY_COMPLETE",
1372
+ FAILED: "FAILED",
1373
+ ABORTED: "ABORTED"
1374
+ };
1375
+ var JobType = {
1376
+ STATIC: "STATIC",
1377
+ DYNAMIC: "DYNAMIC",
1378
+ CUSTOM: "CUSTOM"
1379
+ };
1380
+ var PolicyType = {
1381
+ PROMPT_INJECTION: "PROMPT_INJECTION",
1382
+ TOXIC_CONTENT: "TOXIC_CONTENT",
1383
+ CUSTOM_TOPIC_GUARDRAILS: "CUSTOM_TOPIC_GUARDRAILS",
1384
+ MALICIOUS_CODE_DETECTION: "MALICIOUS_CODE_DETECTION",
1385
+ MALICIOUS_URL_DETECTION: "MALICIOUS_URL_DETECTION",
1386
+ SENSITIVE_DATA_PROTECTION: "SENSITIVE_DATA_PROTECTION"
1387
+ };
1388
+ var ProfilingStatus = {
1389
+ INIT: "INIT",
1390
+ QUEUED: "QUEUED",
1391
+ IN_PROGRESS: "IN_PROGRESS",
1392
+ COMPLETED: "COMPLETED",
1393
+ FAILED: "FAILED"
1394
+ };
1395
+ var RedTeamCategory = {
1396
+ SECURITY: "SECURITY",
1397
+ SAFETY: "SAFETY",
1398
+ COMPLIANCE: "COMPLIANCE",
1399
+ BRAND: "BRAND"
1400
+ };
1401
+ var ResponseMode = {
1402
+ REST: "REST",
1403
+ STREAMING: "STREAMING"
1404
+ };
1405
+ var RiskRating = {
1406
+ LOW: "LOW",
1407
+ MEDIUM: "MEDIUM",
1408
+ HIGH: "HIGH",
1409
+ CRITICAL: "CRITICAL"
1410
+ };
1411
+ var SafetySubCategory = {
1412
+ BIAS: "BIAS",
1413
+ CBRN: "CBRN",
1414
+ CYBERCRIME: "CYBERCRIME",
1415
+ DRUGS: "DRUGS",
1416
+ HATE_TOXIC_ABUSE: "HATE_TOXIC_ABUSE",
1417
+ NON_VIOLENT_CRIMES: "NON_VIOLENT_CRIMES",
1418
+ POLITICAL: "POLITICAL",
1419
+ SELF_HARM: "SELF_HARM",
1420
+ SEXUAL: "SEXUAL",
1421
+ VIOLENT_CRIMES_WEAPONS: "VIOLENT_CRIMES_WEAPONS"
1422
+ };
1423
+ var SecuritySubCategory = {
1424
+ ADVERSARIAL_SUFFIX: "ADVERSARIAL_SUFFIX",
1425
+ EVASION: "EVASION",
1426
+ INDIRECT_PROMPT_INJECTION: "INDIRECT_PROMPT_INJECTION",
1427
+ JAILBREAK: "JAILBREAK",
1428
+ MULTI_TURN: "MULTI_TURN",
1429
+ PROMPT_INJECTION: "PROMPT_INJECTION",
1430
+ REMOTE_CODE_EXECUTION: "REMOTE_CODE_EXECUTION",
1431
+ SYSTEM_PROMPT_LEAK: "SYSTEM_PROMPT_LEAK",
1432
+ TOOL_LEAK: "TOOL_LEAK",
1433
+ MALWARE_GENERATION: "MALWARE_GENERATION"
1434
+ };
1435
+ var SeverityFilter = {
1436
+ LOW: "LOW",
1437
+ MEDIUM: "MEDIUM",
1438
+ HIGH: "HIGH",
1439
+ CRITICAL: "CRITICAL"
1440
+ };
1441
+ var StatusQueryParam = {
1442
+ SUCCESSFUL: "SUCCESSFUL",
1443
+ FAILED: "FAILED"
1444
+ };
1445
+ var StreamType = {
1446
+ NORMAL: "NORMAL",
1447
+ ADVERSARIAL: "ADVERSARIAL"
1448
+ };
1449
+ var TargetConnectionType = {
1450
+ DATABRICKS: "DATABRICKS",
1451
+ BEDROCK: "BEDROCK",
1452
+ OPENAI: "OPENAI",
1453
+ HUGGING_FACE: "HUGGING_FACE",
1454
+ CUSTOM: "CUSTOM",
1455
+ REST: "REST",
1456
+ STREAMING: "STREAMING"
1457
+ };
1458
+ var TargetStatus = {
1459
+ DRAFT: "DRAFT",
1460
+ VALIDATING: "VALIDATING",
1461
+ VALIDATED: "VALIDATED",
1462
+ ACTIVE: "ACTIVE",
1463
+ INACTIVE: "INACTIVE",
1464
+ FAILED: "FAILED",
1465
+ PENDING_AUTH: "PENDING_AUTH"
1466
+ };
1467
+ var TargetType = {
1468
+ APPLICATION: "APPLICATION",
1469
+ AGENT: "AGENT",
1470
+ MODEL: "MODEL"
1471
+ };
1472
+
1473
+ // src/models/red-team.ts
1474
+ import { z as z18 } from "zod";
1475
+ var RedTeamPaginationSchema = z18.object({ total_items: z18.number().int().nullable().optional() }).passthrough();
1476
+ var CountByNameSchema = z18.object({ name: z18.string(), count: z18.number().int() });
1477
+ var ValidationErrorSchema = z18.object({
1478
+ loc: z18.array(z18.union([z18.string(), z18.number()])),
1479
+ msg: z18.string(),
1480
+ type: z18.string()
1481
+ });
1482
+ var HTTPValidationErrorSchema = z18.object({ detail: z18.array(ValidationErrorSchema).optional() }).passthrough();
1483
+ var TargetBackgroundSchema = z18.object({
1484
+ industry: z18.unknown().optional(),
1485
+ use_case: z18.unknown().optional(),
1486
+ competitors: z18.unknown().optional()
1487
+ }).passthrough();
1488
+ var TargetAdditionalContextSchema = z18.object({
1489
+ base_model: z18.unknown().optional(),
1490
+ core_architecture: z18.unknown().optional(),
1491
+ system_prompt: z18.unknown().optional(),
1492
+ languages_supported: z18.unknown().optional(),
1493
+ banned_keywords: z18.unknown().optional(),
1494
+ tools_accessible: z18.unknown().optional()
1495
+ }).passthrough();
1496
+ var TargetMetadataSchema = z18.object({
1497
+ multi_turn: z18.boolean().optional(),
1498
+ multi_turn_error_message: z18.unknown().optional(),
1499
+ rate_limit: z18.unknown().optional(),
1500
+ rate_limit_enabled: z18.boolean().optional(),
1501
+ rate_limit_error_code: z18.unknown().optional(),
1502
+ rate_limit_error_json: z18.unknown().optional(),
1503
+ rate_limit_error_message: z18.unknown().optional(),
1504
+ content_filter_enabled: z18.boolean().optional(),
1505
+ content_filter_error_code: z18.unknown().optional(),
1506
+ content_filter_error_json: z18.unknown().optional(),
1507
+ content_filter_error_message: z18.unknown().optional(),
1508
+ probe_message: z18.string().optional(),
1509
+ request_timeout: z18.number().optional()
1510
+ }).passthrough();
1511
+ var TargetJobRequestSchema = z18.object({
1512
+ uuid: z18.string(),
1513
+ version: z18.number().int().nullable().optional()
1514
+ });
1515
+ var JobTimeRecordSchema = z18.object({
1516
+ queued_at: z18.string().nullable().optional(),
1517
+ started_at: z18.string().nullable().optional(),
1518
+ completed_at: z18.string().nullable().optional(),
1519
+ time_taken: z18.string().nullable().optional()
1520
+ }).passthrough();
1521
+ var StaticJobMetadataSchema = z18.object({
1522
+ categories: z18.record(z18.unknown()),
1523
+ rate_limit_enabled: z18.boolean().optional(),
1524
+ rate_limit: z18.number().int().nullable().optional(),
1525
+ rate_limit_error_code: z18.number().int().nullable().optional(),
1526
+ rate_limit_error_message: z18.string().nullable().optional(),
1527
+ rate_limit_error_json: z18.unknown().optional(),
1528
+ content_filter_enabled: z18.boolean().optional(),
1529
+ content_filter_error_code: z18.number().int().nullable().optional(),
1530
+ content_filter_error_message: z18.string().nullable().optional(),
1531
+ content_filter_error_json: z18.unknown().optional()
1532
+ }).passthrough();
1533
+ var DynamicJobMetadataSchema = z18.object({
1534
+ rate_limit_enabled: z18.boolean().optional(),
1535
+ rate_limit: z18.number().int().nullable().optional(),
1536
+ rate_limit_error_code: z18.number().int().nullable().optional(),
1537
+ rate_limit_error_message: z18.string().nullable().optional(),
1538
+ rate_limit_error_json: z18.unknown().optional(),
1539
+ content_filter_enabled: z18.boolean().optional(),
1540
+ content_filter_error_code: z18.number().int().nullable().optional(),
1541
+ content_filter_error_message: z18.string().nullable().optional(),
1542
+ content_filter_error_json: z18.unknown().optional(),
1543
+ stream_breadth: z18.number().int().optional(),
1544
+ stream_depth: z18.number().int().optional(),
1545
+ max_tokens: z18.number().int().optional(),
1546
+ context_size: z18.number().int().optional(),
1547
+ attack_goals: z18.array(z18.unknown()).optional(),
1548
+ base_model: z18.string().nullable().optional(),
1549
+ use_case: z18.string().nullable().optional(),
1550
+ system_prompt: z18.string().nullable().optional()
1551
+ }).passthrough();
1552
+ var CustomJobMetadataSchema = z18.object({
1553
+ custom_prompt_sets: z18.array(z18.unknown()),
1554
+ rate_limit_enabled: z18.boolean().optional(),
1555
+ rate_limit: z18.number().int().nullable().optional(),
1556
+ rate_limit_error_code: z18.number().int().nullable().optional(),
1557
+ rate_limit_error_message: z18.string().nullable().optional(),
1558
+ rate_limit_error_json: z18.unknown().optional(),
1559
+ content_filter_enabled: z18.boolean().optional(),
1560
+ content_filter_error_code: z18.number().int().nullable().optional(),
1561
+ content_filter_error_message: z18.string().nullable().optional(),
1562
+ content_filter_error_json: z18.unknown().optional()
1563
+ }).passthrough();
1564
+ var JobCreateRequestSchema = z18.object({
1565
+ name: z18.string(),
1566
+ target: TargetJobRequestSchema,
1567
+ job_type: z18.string(),
1568
+ job_metadata: z18.union([
1569
+ StaticJobMetadataSchema,
1570
+ DynamicJobMetadataSchema,
1571
+ CustomJobMetadataSchema
1572
+ ]),
1573
+ version: z18.number().int().nullable().optional(),
1574
+ extra_info: z18.record(z18.unknown()).nullable().optional()
1575
+ });
1576
+ var StaticJobReportStatsSchema = z18.object({
1577
+ output_completion_percentage: z18.number(),
1578
+ partial_report_unlocked: z18.boolean().optional(),
1579
+ partial_report_unlocked_at: z18.string().nullable().optional(),
1580
+ report_summary: z18.string().nullable().optional()
1581
+ }).passthrough();
1582
+ var DynamicJobReportStatsSchema = z18.object({
1583
+ total_goals: z18.number().int().optional(),
1584
+ total_streams: z18.number().int().optional(),
1585
+ total_threats: z18.number().int().optional(),
1586
+ goals_achieved: z18.number().int().optional(),
1587
+ report_summary: z18.string().nullable().optional()
1588
+ }).passthrough();
1589
+ var TargetReferenceSchema = z18.object({
1590
+ uuid: z18.string(),
1591
+ tsg_id: z18.string(),
1592
+ name: z18.string(),
1593
+ description: z18.string().nullable().optional(),
1594
+ target_type: z18.string().nullable().optional(),
1595
+ connection_type: z18.string().nullable().optional(),
1596
+ api_endpoint_type: z18.string().nullable().optional(),
1597
+ response_mode: z18.string().nullable().optional(),
1598
+ session_supported: z18.boolean().optional(),
1599
+ extra_info: z18.record(z18.unknown()).nullable().optional(),
1600
+ status: z18.string(),
1601
+ active: z18.boolean(),
1602
+ validated: z18.boolean(),
1603
+ version: z18.number().int().nullable().optional(),
1604
+ secret_version: z18.string().nullable().optional(),
1605
+ created_by_user_id: z18.string().nullable().optional(),
1606
+ updated_by_user_id: z18.string().nullable().optional(),
1607
+ created_at: z18.string(),
1608
+ updated_at: z18.string(),
1609
+ target_metadata: TargetMetadataSchema.optional(),
1610
+ target_background: TargetBackgroundSchema.nullable().optional(),
1611
+ profiling_status: z18.string().nullable().optional(),
1612
+ additional_context: TargetAdditionalContextSchema.nullable().optional()
1613
+ }).passthrough();
1614
+ var JobResponseSchema = z18.object({
1615
+ uuid: z18.string(),
1616
+ tsg_id: z18.string(),
1617
+ name: z18.string(),
1618
+ target: TargetReferenceSchema,
1619
+ job_type: z18.string(),
1620
+ job_metadata: z18.unknown(),
1621
+ version: z18.number().int().nullable().optional(),
1622
+ extra_info: z18.record(z18.unknown()).nullable().optional(),
1623
+ target_id: z18.string(),
1624
+ target_type: z18.string(),
1625
+ total: z18.number().int().nullable().optional(),
1626
+ completed: z18.number().int().nullable().optional(),
1627
+ status: z18.string().optional(),
1628
+ score: z18.number().nullable().optional(),
1629
+ asr: z18.number().nullable().optional(),
1630
+ time_record: JobTimeRecordSchema.nullable().optional(),
1631
+ created_at: z18.string().nullable().optional(),
1632
+ updated_at: z18.string().nullable().optional(),
1633
+ created_by_user_id: z18.string().nullable().optional(),
1634
+ report_stats: z18.unknown().optional(),
1635
+ metering_quota_uuid: z18.string().nullable().optional(),
1636
+ counted_towards_quota: z18.string().optional(),
1637
+ invocation_id: z18.string().nullable().optional()
1638
+ }).passthrough();
1639
+ var JobListResponseSchema = z18.object({
1640
+ pagination: RedTeamPaginationSchema,
1641
+ data: z18.array(JobResponseSchema)
1642
+ }).passthrough();
1643
+ var JobAbortResponseSchema = z18.object({
1644
+ job_id: z18.string(),
1645
+ message: z18.string()
1646
+ });
1647
+ var PrerequisiteModelSchema = z18.object({
1648
+ id: z18.string(),
1649
+ display_name: z18.string(),
1650
+ description: z18.string()
1651
+ });
1652
+ var SubCategoryModelSchema = z18.object({
1653
+ id: z18.string(),
1654
+ display_name: z18.string(),
1655
+ description: z18.string(),
1656
+ preselect: z18.boolean().optional(),
1657
+ prerequisites: z18.array(PrerequisiteModelSchema).nullable().optional(),
1658
+ active: z18.boolean().optional()
1659
+ }).passthrough();
1660
+ var CategoryModelSchema = z18.object({
1661
+ id: z18.string(),
1662
+ display_name: z18.string(),
1663
+ description: z18.string(),
1664
+ preselect: z18.boolean().optional(),
1665
+ sub_categories: z18.array(SubCategoryModelSchema)
1666
+ }).passthrough();
1667
+ var AttackOutputSchema = z18.object({
1668
+ uuid: z18.string(),
1669
+ tsg_id: z18.string(),
1670
+ attack_id: z18.string(),
1671
+ job_id: z18.string(),
1672
+ target_id: z18.string(),
1673
+ output: z18.string(),
1674
+ threat: z18.boolean().nullable().optional(),
1675
+ marked_safe: z18.boolean().nullable().optional()
1676
+ }).passthrough();
1677
+ var AttackMultiTurnOutputSchema = z18.object({
1678
+ uuid: z18.string(),
1679
+ tsg_id: z18.string(),
1680
+ attack_id: z18.string(),
1681
+ job_id: z18.string(),
1682
+ target_id: z18.string(),
1683
+ output: z18.string(),
1684
+ prompt: z18.string(),
1685
+ turn: z18.number().int(),
1686
+ threat: z18.boolean().nullable().optional(),
1687
+ marked_safe: z18.boolean().nullable().optional(),
1688
+ generation: z18.number().int().optional(),
1689
+ multi_turn: z18.boolean().optional()
1690
+ }).passthrough();
1691
+ var AttackListItemSchema = z18.object({
1692
+ uuid: z18.string(),
1693
+ tsg_id: z18.string(),
1694
+ job_id: z18.string(),
1695
+ target_id: z18.string(),
1696
+ prompt: z18.string(),
1697
+ prompt_mapping_id: z18.string(),
1698
+ prompt_id: z18.string(),
1699
+ category: z18.string(),
1700
+ sub_category: z18.string(),
1701
+ category_display_name: z18.string(),
1702
+ sub_category_display_name: z18.string(),
1703
+ status: z18.string().optional(),
1704
+ marked_safe: z18.boolean().nullable().optional(),
1705
+ extra_info: z18.record(z18.unknown()).optional(),
1706
+ threat: z18.boolean().nullable().optional(),
1707
+ attack_type: z18.string().optional(),
1708
+ multi_turn: z18.boolean().optional(),
1709
+ asr: z18.number().nullable().optional(),
1710
+ version: z18.number().int().nullable().optional(),
1711
+ severity: z18.string().optional()
1712
+ }).passthrough();
1713
+ var AttackListResponseSchema = z18.object({
1714
+ pagination: RedTeamPaginationSchema,
1715
+ data: z18.array(AttackListItemSchema)
1716
+ }).passthrough();
1717
+ var AttackDetailResponseSchema = z18.object({
1718
+ uuid: z18.string(),
1719
+ tsg_id: z18.string(),
1720
+ job_id: z18.string(),
1721
+ target_id: z18.string(),
1722
+ prompt: z18.string(),
1723
+ prompt_mapping_id: z18.string(),
1724
+ prompt_id: z18.string(),
1725
+ category: z18.string(),
1726
+ sub_category: z18.string(),
1727
+ category_display_name: z18.string(),
1728
+ sub_category_display_name: z18.string(),
1729
+ compliance_frameworks: z18.array(z18.unknown()),
1730
+ goal: z18.string().nullable(),
1731
+ status: z18.string().optional(),
1732
+ marked_safe: z18.boolean().nullable().optional(),
1733
+ extra_info: z18.record(z18.unknown()).optional(),
1734
+ threat: z18.boolean().nullable().optional(),
1735
+ attack_type: z18.string().optional(),
1736
+ multi_turn: z18.boolean().optional(),
1737
+ asr: z18.number().nullable().optional(),
1738
+ version: z18.number().int().nullable().optional(),
1739
+ severity: z18.string().optional(),
1740
+ outputs: z18.array(AttackOutputSchema).optional()
1741
+ }).passthrough();
1742
+ var AttackMultiTurnDetailResponseSchema = z18.object({
1743
+ uuid: z18.string(),
1744
+ tsg_id: z18.string(),
1745
+ job_id: z18.string(),
1746
+ target_id: z18.string(),
1747
+ prompt: z18.string(),
1748
+ prompt_mapping_id: z18.string(),
1749
+ prompt_id: z18.string(),
1750
+ category: z18.string(),
1751
+ sub_category: z18.string(),
1752
+ category_display_name: z18.string(),
1753
+ sub_category_display_name: z18.string(),
1754
+ compliance_frameworks: z18.array(z18.unknown()),
1755
+ goal: z18.string().nullable(),
1756
+ status: z18.string().optional(),
1757
+ marked_safe: z18.boolean().nullable().optional(),
1758
+ extra_info: z18.record(z18.unknown()).optional(),
1759
+ threat: z18.boolean().nullable().optional(),
1760
+ attack_type: z18.string().optional(),
1761
+ multi_turn: z18.boolean().optional(),
1762
+ asr: z18.number().nullable().optional(),
1763
+ version: z18.number().int().nullable().optional(),
1764
+ severity: z18.string().optional(),
1765
+ outputs: z18.array(AttackMultiTurnOutputSchema).optional()
1766
+ }).passthrough();
1767
+ var SubCategoryStatsSchema = z18.object({
1768
+ id: z18.string(),
1769
+ display_name: z18.string(),
1770
+ description: z18.string(),
1771
+ preselect: z18.boolean().optional(),
1772
+ prerequisites: z18.array(PrerequisiteModelSchema).nullable().optional(),
1773
+ active: z18.boolean().optional(),
1774
+ successful: z18.number().int(),
1775
+ failed: z18.number().int(),
1776
+ total: z18.number().int().optional()
1777
+ }).passthrough();
1778
+ var CategoryReportSchema = z18.object({
1779
+ id: z18.string(),
1780
+ display_name: z18.string(),
1781
+ description: z18.string(),
1782
+ preselect: z18.boolean().optional(),
1783
+ sub_categories: z18.array(SubCategoryStatsSchema),
1784
+ asr: z18.number(),
1785
+ total_prompts: z18.number().int(),
1786
+ total_attacks: z18.number().int(),
1787
+ successful: z18.number().int(),
1788
+ failed: z18.number().int()
1789
+ }).passthrough();
1790
+ var SeverityStatsSchema = z18.object({
1791
+ severity: z18.string(),
1792
+ successful: z18.number().int().optional(),
1793
+ failed: z18.number().int().optional()
1794
+ }).passthrough();
1795
+ var SeverityReportSchema = z18.object({
1796
+ stats: z18.array(SeverityStatsSchema),
1797
+ successful: z18.number().int().optional(),
1798
+ failed: z18.number().int().optional(),
1799
+ total_attacks: z18.number().int().optional()
1800
+ }).passthrough();
1801
+ var ComplianceTechniqueSchema = z18.object({
1802
+ id: z18.string(),
1803
+ display_name: z18.string(),
1804
+ compliance_id: z18.string(),
1805
+ description: z18.string(),
1806
+ link: z18.string(),
1807
+ version: z18.string(),
1808
+ active: z18.boolean(),
1809
+ successful: z18.number().int().optional(),
1810
+ failed: z18.number().int().optional(),
1811
+ total: z18.number().int().optional()
1812
+ }).passthrough();
1813
+ var ComplianceReportSchema = z18.object({
1814
+ id: z18.string(),
1815
+ display_name: z18.string(),
1816
+ description: z18.string(),
1817
+ active: z18.boolean(),
1818
+ version: z18.string(),
1819
+ link: z18.string(),
1820
+ techniques: z18.array(ComplianceTechniqueSchema),
1821
+ score: z18.number().int().optional()
1822
+ }).passthrough();
1823
+ var RuntimeSecurityPolicySchema = z18.object({
1824
+ policy_id: z18.string(),
1825
+ display_name: z18.string(),
1826
+ config: z18.record(z18.unknown())
1827
+ }).passthrough();
1828
+ var StaticJobRemediationSchema = z18.object({
1829
+ remediation: z18.string(),
1830
+ description: z18.string(),
1831
+ mapping_remediation_id: z18.string().nullable().optional(),
1832
+ subcategories: z18.array(z18.string()).nullable().optional(),
1833
+ effectiveness: z18.number().int().optional(),
1834
+ ease_of_implementation: z18.number().int().optional(),
1835
+ priority: z18.number().int().optional(),
1836
+ resource_links: z18.array(z18.string()).optional(),
1837
+ categories: z18.array(z18.string()).nullable().optional()
1838
+ }).passthrough();
1839
+ var StaticJobRemediationRecommendationSchema = z18.object({
1840
+ runtime_security_policy_configuration: z18.array(RuntimeSecurityPolicySchema).nullable().optional(),
1841
+ other_measures: z18.array(StaticJobRemediationSchema).optional()
1842
+ }).passthrough();
1843
+ var StaticJobReportSchema = z18.object({
1844
+ severity_report: SeverityReportSchema,
1845
+ asr: z18.number().nullable().optional(),
1846
+ score: z18.number().nullable().optional(),
1847
+ security_report: CategoryReportSchema.nullable().optional(),
1848
+ safety_report: CategoryReportSchema.nullable().optional(),
1849
+ brand_report: CategoryReportSchema.nullable().optional(),
1850
+ compliance_report: z18.array(ComplianceReportSchema).nullable().optional(),
1851
+ report_summary: z18.string().nullable().optional(),
1852
+ recommendations: StaticJobRemediationRecommendationSchema.nullable().optional()
1853
+ }).passthrough();
1854
+ var DynamicJobReportSchema = z18.object({
1855
+ total_goals: z18.number().int().optional(),
1856
+ total_streams: z18.number().int().optional(),
1857
+ total_threats: z18.number().int().optional(),
1858
+ goals_achieved: z18.number().int().optional(),
1859
+ report_summary: z18.string().nullable().optional(),
1860
+ score: z18.number().optional(),
1861
+ asr: z18.number().optional()
1862
+ }).passthrough();
1863
+ var RemediationDetailSchema = z18.object({
1864
+ remediation: z18.string(),
1865
+ description: z18.string(),
1866
+ resource_links: z18.array(z18.string()).optional(),
1867
+ priority_level: z18.string().optional(),
1868
+ ease_of_implementation_level: z18.string().optional(),
1869
+ effectiveness_level: z18.string().optional()
1870
+ }).passthrough();
1871
+ var RemediationResponseSchema = z18.object({ remediations: z18.array(RemediationDetailSchema).optional() }).passthrough();
1872
+ var RuntimeSecurityProfileResponseSchema = z18.object({
1873
+ runtime_security_profile: z18.array(RuntimeSecurityPolicySchema).nullable().optional()
1874
+ }).passthrough();
1875
+ var GoalSchema = z18.object({
1876
+ goal: z18.string(),
1877
+ safe_response: z18.string(),
1878
+ jailbroken_response: z18.string(),
1879
+ goal_metadata: z18.record(z18.unknown()).optional(),
1880
+ custom_goal: z18.boolean().optional(),
1881
+ goal_type: z18.string().optional(),
1882
+ uuid: z18.string(),
1883
+ tsg_id: z18.string(),
1884
+ job_id: z18.string(),
1885
+ goal_to_show: z18.string().nullable().optional(),
1886
+ threat: z18.boolean().optional(),
1887
+ version: z18.number().int().nullable().optional(),
1888
+ extra_info: z18.record(z18.unknown()).nullable().optional()
1889
+ }).passthrough();
1890
+ var GoalListResponseSchema = z18.object({ pagination: RedTeamPaginationSchema, data: z18.array(GoalSchema) }).passthrough();
1891
+ var StreamIterationDataSchema = z18.object({
1892
+ uuid: z18.string(),
1893
+ tsg_id: z18.string(),
1894
+ job_id: z18.string(),
1895
+ stream_id: z18.string(),
1896
+ goal_id: z18.string(),
1897
+ iteration: z18.number().int(),
1898
+ prompt: z18.string(),
1899
+ techniques: z18.string(),
1900
+ improvement: z18.string(),
1901
+ prompts_objective: z18.string(),
1902
+ summary: z18.string(),
1903
+ output: z18.string().nullable().optional(),
1904
+ score: z18.number().int().nullable().optional(),
1905
+ judge_reasoning: z18.string().nullable().optional(),
1906
+ threat: z18.boolean().optional(),
1907
+ created_at: z18.string().nullable().optional(),
1908
+ updated_at: z18.string().nullable().optional(),
1909
+ extra_info: z18.record(z18.unknown()).nullable().optional(),
1910
+ version: z18.number().int().nullable().optional()
1911
+ }).passthrough();
1912
+ var StreamDetailResponseSchema = z18.object({
1913
+ uuid: z18.string(),
1914
+ tsg_id: z18.string(),
1915
+ job_id: z18.string(),
1916
+ target_id: z18.string(),
1917
+ goal_id: z18.string(),
1918
+ stream_idx: z18.number().int().optional(),
1919
+ iteration: z18.number().int().optional(),
1920
+ goal: z18.unknown().optional(),
1921
+ marked_safe: z18.boolean().optional(),
1922
+ stream_type: z18.string().nullable().optional(),
1923
+ threat: z18.boolean().optional(),
1924
+ first_threat_iteration: StreamIterationDataSchema.nullable().optional(),
1925
+ created_at: z18.string().nullable().optional(),
1926
+ updated_at: z18.string().nullable().optional(),
1927
+ extra_info: z18.record(z18.unknown()).optional(),
1928
+ version: z18.number().int().nullable().optional(),
1929
+ iterations: z18.array(StreamIterationDataSchema).optional()
1930
+ }).passthrough();
1931
+ var StreamListResponseSchema = z18.object({ pagination: RedTeamPaginationSchema, data: z18.array(StreamDetailResponseSchema) }).passthrough();
1932
+ var CustomAttackOutputSchema = z18.object({
1933
+ uuid: z18.string(),
1934
+ tsg_id: z18.string(),
1935
+ custom_attack_id: z18.string(),
1936
+ job_id: z18.string(),
1937
+ target_id: z18.string(),
1938
+ output: z18.string(),
1939
+ threat: z18.boolean().nullable().optional(),
1940
+ marked_safe: z18.boolean().nullable().optional()
1941
+ }).passthrough();
1942
+ var PropertyAssignmentSchema = z18.object({
1943
+ name: z18.string(),
1944
+ value: z18.string()
1945
+ });
1946
+ var PropertyValueStatisticSchema = z18.object({
1947
+ value: z18.string(),
1948
+ successful_attack_count: z18.number().int(),
1949
+ total_attack_count: z18.number().int(),
1950
+ success_rate: z18.number()
1951
+ });
1952
+ var PropertyStatisticSchema = z18.object({
1953
+ property_name: z18.string(),
1954
+ values: z18.array(PropertyValueStatisticSchema)
1955
+ });
1956
+ var PromptSetSummarySchema = z18.object({
1957
+ prompt_set_id: z18.string(),
1958
+ prompt_set_name: z18.string(),
1959
+ total_prompts: z18.number().int(),
1960
+ total_attacks: z18.number().int(),
1961
+ total_threats: z18.number().int(),
1962
+ failed_attacks: z18.number().int(),
1963
+ threat_rate: z18.number(),
1964
+ property_names: z18.array(z18.string()).optional(),
1965
+ property_statistics: z18.array(PropertyStatisticSchema).optional()
1966
+ }).passthrough();
1967
+ var CustomAttackReportResponseSchema = z18.object({
1968
+ total_prompts: z18.number().int(),
1969
+ total_attacks: z18.number().int(),
1970
+ total_threats: z18.number().int(),
1971
+ failed_attacks: z18.number().int(),
1972
+ score: z18.number(),
1973
+ asr: z18.number(),
1974
+ custom_attack_reports: z18.array(PromptSetSummarySchema).optional(),
1975
+ property_statistics: z18.array(PropertyStatisticSchema).optional()
1976
+ }).passthrough();
1977
+ var PromptSetsReportResponseSchema = z18.object({
1978
+ prompt_sets: z18.array(PromptSetSummarySchema),
1979
+ total_prompt_sets: z18.number().int(),
1980
+ applied_filters: z18.record(z18.unknown()).optional()
1981
+ }).passthrough();
1982
+ var PromptDetailResponseSchema = z18.object({
1983
+ prompt_id: z18.string(),
1984
+ prompt_text: z18.string(),
1985
+ goal: z18.string().nullable().optional(),
1986
+ user_defined_goal: z18.boolean().optional(),
1987
+ properties: z18.array(PropertyAssignmentSchema).optional(),
1988
+ attack_id: z18.string().nullable().optional(),
1989
+ threat: z18.boolean().nullable().optional(),
1990
+ attack_outputs: z18.array(CustomAttackOutputSchema).optional(),
1991
+ asr: z18.number().nullable().optional(),
1992
+ prompt_set_id: z18.string().nullable().optional(),
1993
+ prompt_set_name: z18.string().nullable().optional()
1994
+ }).passthrough();
1995
+ var CustomAttacksListResponseSchema = z18.object({
1996
+ pagination: RedTeamPaginationSchema,
1997
+ data: z18.array(z18.unknown()),
1998
+ total_attacks: z18.number().int(),
1999
+ total_threats: z18.number().int()
2000
+ }).passthrough();
2001
+ var RiskLevelSchema = z18.object({
2002
+ risk_rating: z18.string(),
2003
+ total: z18.number().int(),
2004
+ targets_by_type: z18.array(CountByNameSchema).optional()
2005
+ }).passthrough();
2006
+ var ScanStatisticsResponseSchema = z18.object({
2007
+ total_scans: z18.number().int(),
2008
+ targets_scanned: z18.number().int(),
2009
+ targets_scanned_by_type: z18.array(CountByNameSchema).optional(),
2010
+ scan_status: z18.array(CountByNameSchema).optional(),
2011
+ risk_profile: z18.array(RiskLevelSchema).optional()
2012
+ }).passthrough();
2013
+ var ScoreTrendSeriesSchema = z18.object({
2014
+ label: z18.string(),
2015
+ data: z18.array(z18.number().nullable())
2016
+ });
2017
+ var ScoreTrendResponseSchema = z18.object({
2018
+ labels: z18.array(z18.string()),
2019
+ series: z18.array(ScoreTrendSeriesSchema)
2020
+ });
2021
+ var SentimentRequestSchema = z18.object({
2022
+ job_id: z18.string(),
2023
+ up_vote: z18.boolean().optional(),
2024
+ down_vote: z18.boolean().optional()
2025
+ });
2026
+ var SentimentResponseSchema = z18.object({
2027
+ job_id: z18.string(),
2028
+ up_vote: z18.boolean().optional(),
2029
+ down_vote: z18.boolean().optional()
2030
+ }).passthrough();
2031
+ var QuotaDetailsSchema = z18.object({
2032
+ allocated: z18.number().int(),
2033
+ unlimited: z18.boolean(),
2034
+ consumed: z18.number().int()
2035
+ });
2036
+ var QuotaSummarySchema = z18.object({
2037
+ static: QuotaDetailsSchema,
2038
+ dynamic: QuotaDetailsSchema,
2039
+ custom: QuotaDetailsSchema
2040
+ });
2041
+ var ErrorLogSchema = z18.object({
2042
+ created_at: z18.string(),
2043
+ updated_at: z18.string(),
2044
+ job_id: z18.string().nullable().optional(),
2045
+ target_id: z18.string().nullable().optional(),
2046
+ target_version: z18.number().int().nullable().optional(),
2047
+ attack_id: z18.string().nullable().optional(),
2048
+ error_type: z18.string().nullable().optional(),
2049
+ error_source: z18.string().nullable().optional(),
2050
+ error_message: z18.string().nullable().optional(),
2051
+ target_object: z18.record(z18.unknown()).nullable().optional(),
2052
+ extra_info: z18.record(z18.unknown()).nullable().optional(),
2053
+ version: z18.number().int().optional()
2054
+ }).passthrough();
2055
+ var ErrorLogListResponseSchema = z18.object({ pagination: RedTeamPaginationSchema, data: z18.array(ErrorLogSchema) }).passthrough();
2056
+ var TargetCreateRequestSchema = z18.object({
2057
+ name: z18.string(),
2058
+ description: z18.unknown().optional(),
2059
+ target_type: z18.unknown().optional(),
2060
+ connection_type: z18.unknown().optional(),
2061
+ api_endpoint_type: z18.unknown().optional(),
2062
+ response_mode: z18.unknown().optional(),
2063
+ connection_params: z18.unknown().optional(),
2064
+ session_supported: z18.boolean().optional(),
2065
+ target_metadata: z18.unknown().optional(),
2066
+ target_background: z18.unknown().optional(),
2067
+ additional_context: z18.unknown().optional(),
2068
+ extra_info: z18.unknown().optional(),
2069
+ network_broker_channel_uuid: z18.unknown().optional()
2070
+ }).passthrough();
2071
+ var TargetUpdateRequestSchema = z18.object({
2072
+ name: z18.string(),
2073
+ description: z18.unknown().optional(),
2074
+ target_type: z18.unknown().optional(),
2075
+ connection_type: z18.unknown().optional(),
2076
+ api_endpoint_type: z18.unknown().optional(),
2077
+ response_mode: z18.unknown().optional(),
2078
+ connection_params: z18.unknown().optional(),
2079
+ session_supported: z18.boolean().optional(),
2080
+ target_metadata: z18.unknown().optional(),
2081
+ target_background: z18.unknown().optional(),
2082
+ additional_context: z18.unknown().optional(),
2083
+ extra_info: z18.unknown().optional(),
2084
+ network_broker_channel_uuid: z18.unknown().optional()
2085
+ }).passthrough();
2086
+ var TargetContextUpdateSchema = z18.object({
2087
+ target_background: z18.unknown().optional(),
2088
+ additional_context: z18.unknown().optional()
2089
+ }).passthrough();
2090
+ var TargetResponseSchema = z18.object({
2091
+ uuid: z18.string(),
2092
+ tsg_id: z18.string(),
2093
+ name: z18.string(),
2094
+ status: z18.unknown(),
2095
+ active: z18.boolean(),
2096
+ validated: z18.boolean(),
2097
+ created_at: z18.string(),
2098
+ updated_at: z18.string(),
2099
+ description: z18.unknown().optional(),
2100
+ target_type: z18.unknown().optional(),
2101
+ connection_type: z18.unknown().optional(),
2102
+ api_endpoint_type: z18.unknown().optional(),
2103
+ response_mode: z18.unknown().optional(),
2104
+ session_supported: z18.boolean().optional(),
2105
+ extra_info: z18.unknown().optional(),
2106
+ version: z18.unknown().optional(),
2107
+ secret_version: z18.unknown().optional(),
2108
+ created_by_user_id: z18.unknown().optional(),
2109
+ updated_by_user_id: z18.unknown().optional(),
2110
+ target_metadata: z18.unknown().optional(),
2111
+ target_background: z18.unknown().optional(),
2112
+ profiling_status: z18.unknown().optional(),
2113
+ additional_context: z18.unknown().optional()
2114
+ }).passthrough();
2115
+ var TargetListItemSchema = z18.object({
2116
+ uuid: z18.string(),
2117
+ tsg_id: z18.string(),
2118
+ name: z18.string(),
2119
+ status: z18.unknown(),
2120
+ active: z18.boolean(),
2121
+ validated: z18.boolean(),
2122
+ created_at: z18.string(),
2123
+ updated_at: z18.string(),
2124
+ description: z18.unknown().optional(),
2125
+ target_type: z18.unknown().optional(),
2126
+ connection_type: z18.unknown().optional(),
2127
+ api_endpoint_type: z18.unknown().optional(),
2128
+ response_mode: z18.unknown().optional(),
2129
+ session_supported: z18.boolean().optional(),
2130
+ extra_info: z18.unknown().optional(),
2131
+ version: z18.unknown().optional(),
2132
+ secret_version: z18.unknown().optional(),
2133
+ created_by_user_id: z18.unknown().optional(),
2134
+ updated_by_user_id: z18.unknown().optional()
2135
+ }).passthrough();
2136
+ var TargetListSchema = z18.object({ pagination: RedTeamPaginationSchema, data: z18.array(TargetListItemSchema).optional() }).passthrough();
2137
+ var TargetProbeRequestSchema = z18.object({
2138
+ name: z18.string(),
2139
+ uuid: z18.unknown().optional(),
2140
+ description: z18.unknown().optional(),
2141
+ target_type: z18.unknown().optional(),
2142
+ connection_type: z18.unknown().optional(),
2143
+ api_endpoint_type: z18.unknown().optional(),
2144
+ response_mode: z18.unknown().optional(),
2145
+ connection_params: z18.unknown().optional(),
2146
+ session_supported: z18.boolean().optional(),
2147
+ target_metadata: z18.unknown().optional(),
2148
+ target_background: z18.unknown().optional(),
2149
+ additional_context: z18.unknown().optional(),
2150
+ extra_info: z18.unknown().optional(),
2151
+ network_broker_channel_uuid: z18.unknown().optional(),
2152
+ probe_fields: z18.unknown().optional()
2153
+ }).passthrough();
2154
+ var TargetProfileResponseSchema = z18.object({
2155
+ target_id: z18.string(),
2156
+ target_version: z18.number().int(),
2157
+ status: z18.string(),
2158
+ profiling_status: z18.unknown().optional(),
2159
+ target_background: z18.unknown().optional(),
2160
+ additional_context: z18.unknown().optional(),
2161
+ ai_generated_fields: z18.unknown().optional(),
2162
+ other_details: z18.unknown().optional()
2163
+ }).passthrough();
2164
+ var BaseResponseSchema = z18.object({
2165
+ message: z18.string(),
2166
+ status: z18.number().int()
2167
+ });
2168
+ var PromptSetStatsSchema = z18.object({
2169
+ total_prompts: z18.number().int(),
2170
+ active_prompts: z18.number().int(),
2171
+ inactive_prompts: z18.number().int(),
2172
+ failed_prompts: z18.number().int().optional(),
2173
+ validation_prompts: z18.number().int().optional()
2174
+ }).passthrough();
2175
+ var CustomPromptSetCreateRequestSchema = z18.object({
2176
+ name: z18.string(),
2177
+ description: z18.unknown().optional(),
2178
+ property_names: z18.array(z18.string()).optional()
2179
+ });
2180
+ var CustomPromptSetUpdateRequestSchema = z18.object({
2181
+ name: z18.unknown().optional(),
2182
+ description: z18.unknown().optional(),
2183
+ archive: z18.unknown().optional(),
2184
+ property_names: z18.unknown().optional()
2185
+ }).passthrough();
2186
+ var CustomPromptSetArchiveRequestSchema = z18.object({ archive: z18.boolean() });
2187
+ var CustomPromptSetResponseSchema = z18.object({
2188
+ uuid: z18.string(),
2189
+ name: z18.string(),
2190
+ active: z18.boolean(),
2191
+ archive: z18.boolean(),
2192
+ status: z18.string(),
2193
+ created_at: z18.string(),
2194
+ updated_at: z18.string(),
2195
+ description: z18.unknown().optional(),
2196
+ property_names: z18.array(z18.string()).optional(),
2197
+ properties: z18.array(z18.unknown()).optional(),
2198
+ stats: z18.unknown().optional(),
2199
+ extra_info: z18.unknown().optional(),
2200
+ version: z18.unknown().optional(),
2201
+ created_by_user_id: z18.unknown().optional(),
2202
+ updated_by_user_id: z18.unknown().optional()
2203
+ }).passthrough();
2204
+ var CustomPromptSetListItemSchema = z18.object({
2205
+ uuid: z18.string(),
2206
+ name: z18.string(),
2207
+ active: z18.boolean(),
2208
+ archive: z18.boolean(),
2209
+ status: z18.string(),
2210
+ created_at: z18.string(),
2211
+ updated_at: z18.string(),
2212
+ description: z18.unknown().optional(),
2213
+ property_names: z18.array(z18.string()).optional(),
2214
+ stats: z18.unknown().optional(),
2215
+ created_by_user_id: z18.unknown().optional()
2216
+ }).passthrough();
2217
+ var CustomPromptSetListSchema = z18.object({
2218
+ pagination: RedTeamPaginationSchema,
2219
+ data: z18.array(CustomPromptSetListItemSchema).optional()
2220
+ }).passthrough();
2221
+ var CustomPromptSetListActiveSchema = z18.object({ data: z18.array(CustomPromptSetListItemSchema).optional() }).passthrough();
2222
+ var CustomPromptSetReferenceSchema = z18.object({
2223
+ uuid: z18.string(),
2224
+ name: z18.string(),
2225
+ status: z18.string(),
2226
+ active: z18.boolean(),
2227
+ tsg_id: z18.string(),
2228
+ created_at: z18.string(),
2229
+ updated_at: z18.string(),
2230
+ version: z18.unknown().optional()
2231
+ }).passthrough();
2232
+ var CustomPromptSetVersionInfoSchema = z18.object({
2233
+ uuid: z18.string(),
2234
+ status: z18.string(),
2235
+ is_latest: z18.boolean(),
2236
+ version: z18.unknown().optional(),
2237
+ stats: z18.unknown().optional(),
2238
+ snapshot_created_at: z18.unknown().optional()
2239
+ }).passthrough();
2240
+ var CustomPromptCreateRequestSchema = z18.object({
2241
+ prompt: z18.string(),
2242
+ prompt_set_id: z18.string(),
2243
+ goal: z18.unknown().optional(),
2244
+ properties: z18.unknown().optional()
2245
+ });
2246
+ var CustomPromptUpdateRequestSchema = z18.object({
2247
+ prompt: z18.unknown().optional(),
2248
+ goal: z18.unknown().optional(),
2249
+ properties: z18.unknown().optional()
2250
+ }).passthrough();
2251
+ var CustomPromptResponseSchema = z18.object({
2252
+ uuid: z18.string(),
2253
+ prompt: z18.string(),
2254
+ user_defined_goal: z18.boolean(),
2255
+ status: z18.string(),
2256
+ active: z18.boolean(),
2257
+ prompt_set_id: z18.string(),
2258
+ created_at: z18.string(),
2259
+ updated_at: z18.string(),
2260
+ goal: z18.unknown().optional(),
2261
+ properties: z18.unknown().optional(),
2262
+ property_assignments: z18.array(z18.unknown()).optional(),
2263
+ detector_category: z18.unknown().optional(),
2264
+ severity: z18.unknown().optional(),
2265
+ extra_info: z18.unknown().optional()
2266
+ }).passthrough();
2267
+ var CustomPromptListItemSchema = z18.object({
2268
+ uuid: z18.string(),
2269
+ prompt: z18.string(),
2270
+ user_defined_goal: z18.boolean(),
2271
+ status: z18.string(),
2272
+ active: z18.boolean(),
2273
+ created_at: z18.string(),
2274
+ updated_at: z18.string(),
2275
+ goal: z18.unknown().optional(),
2276
+ properties: z18.unknown().optional()
2277
+ }).passthrough();
2278
+ var CustomPromptListSchema = z18.object({
2279
+ pagination: RedTeamPaginationSchema,
2280
+ data: z18.array(CustomPromptListItemSchema).optional()
2281
+ }).passthrough();
2282
+ var PropertyNameCreateRequestSchema = z18.object({ name: z18.string() });
2283
+ var PropertyValueCreateRequestSchema = z18.object({
2284
+ property_name: z18.string(),
2285
+ property_value: z18.string()
2286
+ });
2287
+ var PropertyDefinitionSchema = z18.object({
2288
+ property_name: z18.string(),
2289
+ created_at: z18.string()
2290
+ });
2291
+ var PropertyNamesListResponseSchema = z18.object({ data: z18.array(PropertyDefinitionSchema).optional() }).passthrough();
2292
+ var PropertyValuesResponseSchema = z18.object({
2293
+ name: z18.string(),
2294
+ values: z18.array(z18.string()).optional()
2295
+ }).passthrough();
2296
+ var PropertyValuesMultipleResponseSchema = z18.object({ data: z18.record(z18.array(z18.string())).optional() }).passthrough();
2297
+ var DashboardOverviewResponseSchema = z18.object({
2298
+ total_targets: z18.number().int(),
2299
+ targets_by_type: z18.array(CountByNameSchema).optional()
2300
+ }).passthrough();
2301
+
2302
+ // src/models/oauth-token.ts
2303
+ import { z as z19 } from "zod";
2304
+ var OAuthTokenResponseSchema = z19.object({
2305
+ access_token: z19.string(),
2306
+ token_type: z19.string().optional(),
2307
+ expires_in: z19.number(),
2308
+ scope: z19.string().optional()
801
2309
  });
802
2310
 
803
2311
  // src/management/oauth-client.ts
@@ -816,6 +2324,10 @@ var OAuthClient = class {
816
2324
  this.tsgId = opts.tsgId;
817
2325
  this.tokenEndpoint = opts.tokenEndpoint ?? DEFAULT_TOKEN_ENDPOINT;
818
2326
  }
2327
+ /**
2328
+ * Get a valid access token, refreshing if needed.
2329
+ * @returns Bearer access token string.
2330
+ */
819
2331
  async getToken() {
820
2332
  if (this.accessToken && Date.now() < this.expiresAt - TOKEN_BUFFER_MS) {
821
2333
  return this.accessToken;
@@ -828,6 +2340,7 @@ var OAuthClient = class {
828
2340
  });
829
2341
  return this.pendingFetch;
830
2342
  }
2343
+ /** Clear the cached token, forcing a fresh fetch on next call. */
831
2344
  clearToken() {
832
2345
  this.accessToken = null;
833
2346
  this.expiresAt = 0;
@@ -872,76 +2385,43 @@ var OAuthClient = class {
872
2385
  };
873
2386
 
874
2387
  // src/management/management-http-client.ts
875
- function sleep2(ms) {
876
- return new Promise((resolve) => setTimeout(resolve, ms));
877
- }
878
- function extractError(body, status) {
879
- try {
880
- const parsed = JSON.parse(body);
881
- return parsed.error_message ?? parsed.message ?? `API error ${status}: ${body}`;
882
- } catch {
883
- return body ? `API error ${status}: ${body}` : `API error ${status}`;
884
- }
885
- }
886
2388
  async function managementHttpRequest(opts) {
887
2389
  const { method, baseUrl, path, body, params, oauthClient, numRetries } = opts;
888
2390
  let hadTokenRefresh = false;
889
- for (let attempt = 0; attempt <= numRetries; attempt++) {
890
- const token = await oauthClient.getToken();
891
- const stripped = baseUrl.replace(/\/+$/, "");
892
- const url = new URL(`${stripped}${path}`);
893
- if (params) {
894
- for (const [key, value] of Object.entries(params)) {
895
- url.searchParams.set(key, value);
2391
+ const response = await executeWithRetry({
2392
+ maxRetries: numRetries,
2393
+ execute: async () => {
2394
+ const token = await oauthClient.getToken();
2395
+ const stripped = baseUrl.replace(/\/+$/, "");
2396
+ const url = new URL(`${stripped}${path}`);
2397
+ if (params) {
2398
+ for (const [key, value] of Object.entries(params)) {
2399
+ url.searchParams.set(key, value);
2400
+ }
896
2401
  }
897
- }
898
- const headers = {
899
- Authorization: `Bearer ${token}`,
900
- "User-Agent": USER_AGENT
901
- };
902
- let bodyStr;
903
- if (body !== void 0) {
904
- headers["Content-Type"] = "application/json";
905
- bodyStr = JSON.stringify(body);
906
- }
907
- let response;
908
- try {
909
- response = await fetch(url.toString(), {
910
- method,
911
- headers,
912
- body: bodyStr
913
- });
914
- } catch (err) {
915
- if (attempt < numRetries) {
916
- await sleep2(Math.pow(2, attempt) * 1e3);
917
- continue;
2402
+ const headers = {
2403
+ Authorization: `Bearer ${token}`,
2404
+ "User-Agent": USER_AGENT
2405
+ };
2406
+ let bodyStr;
2407
+ if (body !== void 0) {
2408
+ headers["Content-Type"] = "application/json";
2409
+ bodyStr = JSON.stringify(body);
918
2410
  }
919
- throw new AISecSDKException(
920
- err.message ?? "Network error",
921
- "AISEC_CLIENT_SIDE_ERROR" /* CLIENT_SIDE_ERROR */
922
- );
923
- }
924
- if (response.ok) {
925
- const text = await response.text();
926
- const data = text ? JSON.parse(text) : {};
927
- return { status: response.status, data };
928
- }
929
- if (response.status === 401 && !hadTokenRefresh) {
930
- hadTokenRefresh = true;
931
- oauthClient.clearToken();
932
- attempt--;
933
- continue;
934
- }
935
- if (HTTP_FORCE_RETRY_STATUS_CODES.includes(response.status) && attempt < numRetries) {
936
- await sleep2(Math.pow(2, attempt) * 1e3);
937
- continue;
2411
+ return fetch(url.toString(), { method, headers, body: bodyStr });
2412
+ },
2413
+ onRetryableFailure: async (response2) => {
2414
+ if (response2.status === 401 && !hadTokenRefresh) {
2415
+ hadTokenRefresh = true;
2416
+ oauthClient.clearToken();
2417
+ return true;
2418
+ }
2419
+ return false;
938
2420
  }
939
- const errorText = await response.text();
940
- const errorMessage = extractError(errorText, response.status);
941
- const errorType = response.status >= 500 ? "AISEC_SERVER_SIDE_ERROR" /* SERVER_SIDE_ERROR */ : "AISEC_CLIENT_SIDE_ERROR" /* CLIENT_SIDE_ERROR */;
942
- throw new AISecSDKException(errorMessage, errorType);
943
- }
944
- throw new AISecSDKException("Max retries exceeded", "AISEC_CLIENT_SIDE_ERROR" /* CLIENT_SIDE_ERROR */);
2421
+ });
2422
+ const text = await response.text();
2423
+ const data = text ? JSON.parse(text) : {};
2424
+ return { status: response.status, data };
945
2425
  }
946
2426
 
947
2427
  // src/management/profiles.ts
@@ -956,6 +2436,11 @@ var ProfilesClient = class {
956
2436
  this.tsgId = opts.tsgId;
957
2437
  this.numRetries = opts.numRetries;
958
2438
  }
2439
+ /**
2440
+ * Create a new security profile.
2441
+ * @param request - Profile configuration.
2442
+ * @returns The created security profile.
2443
+ */
959
2444
  async create(request) {
960
2445
  const res = await managementHttpRequest({
961
2446
  method: "POST",
@@ -967,6 +2452,11 @@ var ProfilesClient = class {
967
2452
  });
968
2453
  return res.data;
969
2454
  }
2455
+ /**
2456
+ * List security profiles for the TSG.
2457
+ * @param opts - Pagination options.
2458
+ * @returns Paginated list of security profiles.
2459
+ */
970
2460
  async list(opts) {
971
2461
  const params = {
972
2462
  offset: String(opts?.offset ?? 0),
@@ -982,6 +2472,12 @@ var ProfilesClient = class {
982
2472
  });
983
2473
  return res.data;
984
2474
  }
2475
+ /**
2476
+ * Update an existing security profile.
2477
+ * @param profileId - UUID of the profile to update.
2478
+ * @param request - Updated profile configuration.
2479
+ * @returns The updated security profile.
2480
+ */
985
2481
  async update(profileId, request) {
986
2482
  if (!isValidUuid(profileId)) {
987
2483
  throw new AISecSDKException(
@@ -999,6 +2495,11 @@ var ProfilesClient = class {
999
2495
  });
1000
2496
  return res.data;
1001
2497
  }
2498
+ /**
2499
+ * Delete a security profile.
2500
+ * @param profileId - UUID of the profile to delete.
2501
+ * @returns Deletion confirmation message.
2502
+ */
1002
2503
  async delete(profileId) {
1003
2504
  if (!isValidUuid(profileId)) {
1004
2505
  throw new AISecSDKException(
@@ -1029,6 +2530,11 @@ var TopicsClient = class {
1029
2530
  this.tsgId = opts.tsgId;
1030
2531
  this.numRetries = opts.numRetries;
1031
2532
  }
2533
+ /**
2534
+ * Create a new custom topic.
2535
+ * @param request - Topic definition with name, description, and examples.
2536
+ * @returns The created custom topic.
2537
+ */
1032
2538
  async create(request) {
1033
2539
  const res = await managementHttpRequest({
1034
2540
  method: "POST",
@@ -1040,6 +2546,11 @@ var TopicsClient = class {
1040
2546
  });
1041
2547
  return res.data;
1042
2548
  }
2549
+ /**
2550
+ * List custom topics for the TSG.
2551
+ * @param opts - Pagination options.
2552
+ * @returns Paginated list of custom topics.
2553
+ */
1043
2554
  async list(opts) {
1044
2555
  const params = {
1045
2556
  offset: String(opts?.offset ?? 0),
@@ -1055,6 +2566,12 @@ var TopicsClient = class {
1055
2566
  });
1056
2567
  return res.data;
1057
2568
  }
2569
+ /**
2570
+ * Update an existing custom topic.
2571
+ * @param topicId - UUID of the topic to update.
2572
+ * @param request - Updated topic definition.
2573
+ * @returns The updated custom topic.
2574
+ */
1058
2575
  async update(topicId, request) {
1059
2576
  if (!isValidUuid(topicId)) {
1060
2577
  throw new AISecSDKException(
@@ -1072,6 +2589,11 @@ var TopicsClient = class {
1072
2589
  });
1073
2590
  return res.data;
1074
2591
  }
2592
+ /**
2593
+ * Delete a custom topic. Fails if topic is referenced by a profile.
2594
+ * @param topicId - UUID of the topic to delete.
2595
+ * @returns Deletion confirmation message.
2596
+ */
1075
2597
  async delete(topicId) {
1076
2598
  if (!isValidUuid(topicId)) {
1077
2599
  throw new AISecSDKException(
@@ -1088,6 +2610,11 @@ var TopicsClient = class {
1088
2610
  });
1089
2611
  return res.data;
1090
2612
  }
2613
+ /**
2614
+ * Force-delete a custom topic, removing it from any referencing profiles.
2615
+ * @param topicId - UUID of the topic to force-delete.
2616
+ * @returns Deletion confirmation message.
2617
+ */
1091
2618
  async forceDelete(topicId) {
1092
2619
  if (!isValidUuid(topicId)) {
1093
2620
  throw new AISecSDKException(
@@ -1158,39 +2685,1823 @@ var ManagementClient = class {
1158
2685
  });
1159
2686
  }
1160
2687
  };
2688
+
2689
+ // src/model-security/scans-client.ts
2690
+ function buildListParams(opts) {
2691
+ const params = {};
2692
+ if (opts?.skip !== void 0) params.skip = String(opts.skip);
2693
+ if (opts?.limit !== void 0) params.limit = String(opts.limit);
2694
+ if (opts?.sort_by !== void 0) params.sort_by = opts.sort_by;
2695
+ if (opts?.sort_direction !== void 0) params.sort_direction = opts.sort_direction;
2696
+ if (opts?.search !== void 0) params.search = opts.search;
2697
+ return params;
2698
+ }
2699
+ var ModelSecurityScansClient = class {
2700
+ baseUrl;
2701
+ oauthClient;
2702
+ numRetries;
2703
+ constructor(opts) {
2704
+ this.baseUrl = opts.baseUrl;
2705
+ this.oauthClient = opts.oauthClient;
2706
+ this.numRetries = opts.numRetries;
2707
+ }
2708
+ /**
2709
+ * Create a new model security scan.
2710
+ * @param request - Scan creation request body.
2711
+ * @returns The created scan response.
2712
+ */
2713
+ async create(request) {
2714
+ const res = await managementHttpRequest({
2715
+ method: "POST",
2716
+ baseUrl: this.baseUrl,
2717
+ path: MODEL_SEC_SCANS_PATH,
2718
+ body: request,
2719
+ oauthClient: this.oauthClient,
2720
+ numRetries: this.numRetries
2721
+ });
2722
+ return res.data;
2723
+ }
2724
+ /**
2725
+ * List model security scans with optional filters.
2726
+ * @param opts - Pagination and filter options.
2727
+ * @returns Paginated list of scans.
2728
+ */
2729
+ async list(opts) {
2730
+ const params = buildListParams(opts);
2731
+ if (opts?.eval_outcome !== void 0) params.eval_outcome = opts.eval_outcome;
2732
+ if (opts?.source_type !== void 0) params.source_type = opts.source_type;
2733
+ if (opts?.scan_origin !== void 0) params.scan_origin = opts.scan_origin;
2734
+ const res = await managementHttpRequest({
2735
+ method: "GET",
2736
+ baseUrl: this.baseUrl,
2737
+ path: MODEL_SEC_SCANS_PATH,
2738
+ params,
2739
+ oauthClient: this.oauthClient,
2740
+ numRetries: this.numRetries
2741
+ });
2742
+ return res.data;
2743
+ }
2744
+ /**
2745
+ * Get a single scan by UUID.
2746
+ * @param uuid - Scan UUID.
2747
+ * @returns The scan response.
2748
+ */
2749
+ async get(uuid) {
2750
+ if (!isValidUuid(uuid)) {
2751
+ throw new AISecSDKException(
2752
+ `Invalid scan uuid: ${uuid}`,
2753
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
2754
+ );
2755
+ }
2756
+ const res = await managementHttpRequest({
2757
+ method: "GET",
2758
+ baseUrl: this.baseUrl,
2759
+ path: `${MODEL_SEC_SCANS_PATH}/${uuid}`,
2760
+ oauthClient: this.oauthClient,
2761
+ numRetries: this.numRetries
2762
+ });
2763
+ return res.data;
2764
+ }
2765
+ /**
2766
+ * Get rule evaluations for a scan.
2767
+ * @param scanUuid - Scan UUID.
2768
+ * @param opts - Pagination options.
2769
+ * @returns Paginated list of rule evaluations.
2770
+ */
2771
+ async getEvaluations(scanUuid, opts) {
2772
+ if (!isValidUuid(scanUuid)) {
2773
+ throw new AISecSDKException(
2774
+ `Invalid scan uuid: ${scanUuid}`,
2775
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
2776
+ );
2777
+ }
2778
+ const res = await managementHttpRequest({
2779
+ method: "GET",
2780
+ baseUrl: this.baseUrl,
2781
+ path: `${MODEL_SEC_SCANS_PATH}/${scanUuid}/evaluations`,
2782
+ params: buildListParams(opts),
2783
+ oauthClient: this.oauthClient,
2784
+ numRetries: this.numRetries
2785
+ });
2786
+ return res.data;
2787
+ }
2788
+ /**
2789
+ * Get files for a scan.
2790
+ * @param scanUuid - Scan UUID.
2791
+ * @param opts - Pagination and file filter options.
2792
+ * @returns Paginated list of files.
2793
+ */
2794
+ async getFiles(scanUuid, opts) {
2795
+ if (!isValidUuid(scanUuid)) {
2796
+ throw new AISecSDKException(
2797
+ `Invalid scan uuid: ${scanUuid}`,
2798
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
2799
+ );
2800
+ }
2801
+ const params = buildListParams(opts);
2802
+ if (opts?.type !== void 0) params.type = opts.type;
2803
+ if (opts?.result !== void 0) params.result = opts.result;
2804
+ const res = await managementHttpRequest({
2805
+ method: "GET",
2806
+ baseUrl: this.baseUrl,
2807
+ path: `${MODEL_SEC_SCANS_PATH}/${scanUuid}/files`,
2808
+ params,
2809
+ oauthClient: this.oauthClient,
2810
+ numRetries: this.numRetries
2811
+ });
2812
+ return res.data;
2813
+ }
2814
+ /**
2815
+ * Add labels to a scan (merge with existing).
2816
+ * @param scanUuid - Scan UUID.
2817
+ * @param request - Labels to add.
2818
+ * @returns Labels response.
2819
+ */
2820
+ async addLabels(scanUuid, request) {
2821
+ if (!isValidUuid(scanUuid)) {
2822
+ throw new AISecSDKException(
2823
+ `Invalid scan uuid: ${scanUuid}`,
2824
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
2825
+ );
2826
+ }
2827
+ const res = await managementHttpRequest({
2828
+ method: "POST",
2829
+ baseUrl: this.baseUrl,
2830
+ path: `${MODEL_SEC_SCANS_PATH}/${scanUuid}/labels`,
2831
+ body: request,
2832
+ oauthClient: this.oauthClient,
2833
+ numRetries: this.numRetries
2834
+ });
2835
+ return res.data;
2836
+ }
2837
+ /**
2838
+ * Set labels on a scan (replace all existing).
2839
+ * @param scanUuid - Scan UUID.
2840
+ * @param request - Labels to set.
2841
+ * @returns Labels response.
2842
+ */
2843
+ async setLabels(scanUuid, request) {
2844
+ if (!isValidUuid(scanUuid)) {
2845
+ throw new AISecSDKException(
2846
+ `Invalid scan uuid: ${scanUuid}`,
2847
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
2848
+ );
2849
+ }
2850
+ const res = await managementHttpRequest({
2851
+ method: "PUT",
2852
+ baseUrl: this.baseUrl,
2853
+ path: `${MODEL_SEC_SCANS_PATH}/${scanUuid}/labels`,
2854
+ body: request,
2855
+ oauthClient: this.oauthClient,
2856
+ numRetries: this.numRetries
2857
+ });
2858
+ return res.data;
2859
+ }
2860
+ /**
2861
+ * Delete labels from a scan by key.
2862
+ * @param scanUuid - Scan UUID.
2863
+ * @param keys - Label keys to delete.
2864
+ */
2865
+ async deleteLabels(scanUuid, keys) {
2866
+ if (!isValidUuid(scanUuid)) {
2867
+ throw new AISecSDKException(
2868
+ `Invalid scan uuid: ${scanUuid}`,
2869
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
2870
+ );
2871
+ }
2872
+ const url = new URL(`https://placeholder${MODEL_SEC_SCANS_PATH}/${scanUuid}/labels`);
2873
+ for (const key of keys) {
2874
+ url.searchParams.append("keys", key);
2875
+ }
2876
+ const queryString = url.searchParams.toString();
2877
+ const pathWithQuery = `${MODEL_SEC_SCANS_PATH}/${scanUuid}/labels${queryString ? `?${queryString}` : ""}`;
2878
+ await managementHttpRequest({
2879
+ method: "DELETE",
2880
+ baseUrl: this.baseUrl,
2881
+ path: pathWithQuery,
2882
+ oauthClient: this.oauthClient,
2883
+ numRetries: this.numRetries
2884
+ });
2885
+ }
2886
+ /**
2887
+ * Get rule violations for a scan.
2888
+ * @param scanUuid - Scan UUID.
2889
+ * @param opts - Pagination options.
2890
+ * @returns Paginated list of violations.
2891
+ */
2892
+ async getViolations(scanUuid, opts) {
2893
+ if (!isValidUuid(scanUuid)) {
2894
+ throw new AISecSDKException(
2895
+ `Invalid scan uuid: ${scanUuid}`,
2896
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
2897
+ );
2898
+ }
2899
+ const res = await managementHttpRequest({
2900
+ method: "GET",
2901
+ baseUrl: this.baseUrl,
2902
+ path: `${MODEL_SEC_SCANS_PATH}/${scanUuid}/rule-violations`,
2903
+ params: buildListParams(opts),
2904
+ oauthClient: this.oauthClient,
2905
+ numRetries: this.numRetries
2906
+ });
2907
+ return res.data;
2908
+ }
2909
+ /**
2910
+ * Get distinct label keys across all scans.
2911
+ * @param opts - Pagination options.
2912
+ * @returns Paginated list of label keys.
2913
+ */
2914
+ async getLabelKeys(opts) {
2915
+ const res = await managementHttpRequest({
2916
+ method: "GET",
2917
+ baseUrl: this.baseUrl,
2918
+ path: `${MODEL_SEC_SCANS_PATH}/label-keys`,
2919
+ params: buildListParams(opts),
2920
+ oauthClient: this.oauthClient,
2921
+ numRetries: this.numRetries
2922
+ });
2923
+ return res.data;
2924
+ }
2925
+ /**
2926
+ * Get distinct values for a label key.
2927
+ * @param key - Label key to get values for.
2928
+ * @param opts - Pagination options.
2929
+ * @returns Paginated list of label values.
2930
+ */
2931
+ async getLabelValues(key, opts) {
2932
+ const res = await managementHttpRequest({
2933
+ method: "GET",
2934
+ baseUrl: this.baseUrl,
2935
+ path: `${MODEL_SEC_SCANS_PATH}/label-keys/${encodeURIComponent(key)}/values`,
2936
+ params: buildListParams(opts),
2937
+ oauthClient: this.oauthClient,
2938
+ numRetries: this.numRetries
2939
+ });
2940
+ return res.data;
2941
+ }
2942
+ /**
2943
+ * Get a single rule evaluation by UUID.
2944
+ * @param uuid - Evaluation UUID.
2945
+ * @returns The rule evaluation response.
2946
+ */
2947
+ async getEvaluation(uuid) {
2948
+ if (!isValidUuid(uuid)) {
2949
+ throw new AISecSDKException(
2950
+ `Invalid evaluation uuid: ${uuid}`,
2951
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
2952
+ );
2953
+ }
2954
+ const res = await managementHttpRequest({
2955
+ method: "GET",
2956
+ baseUrl: this.baseUrl,
2957
+ path: `${MODEL_SEC_EVALUATIONS_PATH}/${uuid}`,
2958
+ oauthClient: this.oauthClient,
2959
+ numRetries: this.numRetries
2960
+ });
2961
+ return res.data;
2962
+ }
2963
+ /**
2964
+ * Get a single violation by UUID.
2965
+ * @param uuid - Violation UUID.
2966
+ * @returns The violation response.
2967
+ */
2968
+ async getViolation(uuid) {
2969
+ if (!isValidUuid(uuid)) {
2970
+ throw new AISecSDKException(
2971
+ `Invalid violation uuid: ${uuid}`,
2972
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
2973
+ );
2974
+ }
2975
+ const res = await managementHttpRequest({
2976
+ method: "GET",
2977
+ baseUrl: this.baseUrl,
2978
+ path: `${MODEL_SEC_VIOLATIONS_PATH}/${uuid}`,
2979
+ oauthClient: this.oauthClient,
2980
+ numRetries: this.numRetries
2981
+ });
2982
+ return res.data;
2983
+ }
2984
+ };
2985
+
2986
+ // src/model-security/security-groups-client.ts
2987
+ function buildListParams2(opts) {
2988
+ const params = {};
2989
+ if (opts?.skip !== void 0) params.skip = String(opts.skip);
2990
+ if (opts?.limit !== void 0) params.limit = String(opts.limit);
2991
+ if (opts?.sort_by !== void 0) params.sort_by = opts.sort_by;
2992
+ if (opts?.sort_direction !== void 0) params.sort_direction = opts.sort_direction;
2993
+ if (opts?.search !== void 0) params.search = opts.search;
2994
+ return params;
2995
+ }
2996
+ var ModelSecurityGroupsClient = class {
2997
+ baseUrl;
2998
+ oauthClient;
2999
+ numRetries;
3000
+ constructor(opts) {
3001
+ this.baseUrl = opts.baseUrl;
3002
+ this.oauthClient = opts.oauthClient;
3003
+ this.numRetries = opts.numRetries;
3004
+ }
3005
+ /**
3006
+ * Create a new security group.
3007
+ * @param request - Security group creation request.
3008
+ * @returns The created security group.
3009
+ */
3010
+ async create(request) {
3011
+ const res = await managementHttpRequest({
3012
+ method: "POST",
3013
+ baseUrl: this.baseUrl,
3014
+ path: MODEL_SEC_SECURITY_GROUPS_PATH,
3015
+ body: request,
3016
+ oauthClient: this.oauthClient,
3017
+ numRetries: this.numRetries
3018
+ });
3019
+ return res.data;
3020
+ }
3021
+ /**
3022
+ * List security groups with optional filters.
3023
+ * @param opts - Pagination and filter options.
3024
+ * @returns Paginated list of security groups.
3025
+ */
3026
+ async list(opts) {
3027
+ const res = await managementHttpRequest({
3028
+ method: "GET",
3029
+ baseUrl: this.baseUrl,
3030
+ path: MODEL_SEC_SECURITY_GROUPS_PATH,
3031
+ params: buildListParams2(opts),
3032
+ oauthClient: this.oauthClient,
3033
+ numRetries: this.numRetries
3034
+ });
3035
+ return res.data;
3036
+ }
3037
+ /**
3038
+ * Get a single security group by UUID.
3039
+ * @param uuid - Security group UUID.
3040
+ * @returns The security group.
3041
+ */
3042
+ async get(uuid) {
3043
+ if (!isValidUuid(uuid)) {
3044
+ throw new AISecSDKException(
3045
+ `Invalid security group uuid: ${uuid}`,
3046
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3047
+ );
3048
+ }
3049
+ const res = await managementHttpRequest({
3050
+ method: "GET",
3051
+ baseUrl: this.baseUrl,
3052
+ path: `${MODEL_SEC_SECURITY_GROUPS_PATH}/${uuid}`,
3053
+ oauthClient: this.oauthClient,
3054
+ numRetries: this.numRetries
3055
+ });
3056
+ return res.data;
3057
+ }
3058
+ /**
3059
+ * Update an existing security group.
3060
+ * @param uuid - Security group UUID.
3061
+ * @param request - Updated security group fields.
3062
+ * @returns The updated security group.
3063
+ */
3064
+ async update(uuid, request) {
3065
+ if (!isValidUuid(uuid)) {
3066
+ throw new AISecSDKException(
3067
+ `Invalid security group uuid: ${uuid}`,
3068
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3069
+ );
3070
+ }
3071
+ const res = await managementHttpRequest({
3072
+ method: "PUT",
3073
+ baseUrl: this.baseUrl,
3074
+ path: `${MODEL_SEC_SECURITY_GROUPS_PATH}/${uuid}`,
3075
+ body: request,
3076
+ oauthClient: this.oauthClient,
3077
+ numRetries: this.numRetries
3078
+ });
3079
+ return res.data;
3080
+ }
3081
+ /**
3082
+ * Delete a security group.
3083
+ * @param uuid - Security group UUID.
3084
+ */
3085
+ async delete(uuid) {
3086
+ if (!isValidUuid(uuid)) {
3087
+ throw new AISecSDKException(
3088
+ `Invalid security group uuid: ${uuid}`,
3089
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3090
+ );
3091
+ }
3092
+ await managementHttpRequest({
3093
+ method: "DELETE",
3094
+ baseUrl: this.baseUrl,
3095
+ path: `${MODEL_SEC_SECURITY_GROUPS_PATH}/${uuid}`,
3096
+ oauthClient: this.oauthClient,
3097
+ numRetries: this.numRetries
3098
+ });
3099
+ }
3100
+ /**
3101
+ * List rule instances for a security group.
3102
+ * @param securityGroupUuid - Security group UUID.
3103
+ * @param opts - Pagination options.
3104
+ * @returns Paginated list of rule instances.
3105
+ */
3106
+ async listRuleInstances(securityGroupUuid, opts) {
3107
+ if (!isValidUuid(securityGroupUuid)) {
3108
+ throw new AISecSDKException(
3109
+ `Invalid security group uuid: ${securityGroupUuid}`,
3110
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3111
+ );
3112
+ }
3113
+ const res = await managementHttpRequest({
3114
+ method: "GET",
3115
+ baseUrl: this.baseUrl,
3116
+ path: `${MODEL_SEC_SECURITY_GROUPS_PATH}/${securityGroupUuid}/rule-instances`,
3117
+ params: buildListParams2(opts),
3118
+ oauthClient: this.oauthClient,
3119
+ numRetries: this.numRetries
3120
+ });
3121
+ return res.data;
3122
+ }
3123
+ /**
3124
+ * Get a single rule instance within a security group.
3125
+ * @param securityGroupUuid - Security group UUID.
3126
+ * @param ruleInstanceUuid - Rule instance UUID.
3127
+ * @returns The rule instance.
3128
+ */
3129
+ async getRuleInstance(securityGroupUuid, ruleInstanceUuid) {
3130
+ if (!isValidUuid(securityGroupUuid)) {
3131
+ throw new AISecSDKException(
3132
+ `Invalid security group uuid: ${securityGroupUuid}`,
3133
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3134
+ );
3135
+ }
3136
+ if (!isValidUuid(ruleInstanceUuid)) {
3137
+ throw new AISecSDKException(
3138
+ `Invalid rule instance uuid: ${ruleInstanceUuid}`,
3139
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3140
+ );
3141
+ }
3142
+ const res = await managementHttpRequest({
3143
+ method: "GET",
3144
+ baseUrl: this.baseUrl,
3145
+ path: `${MODEL_SEC_SECURITY_GROUPS_PATH}/${securityGroupUuid}/rule-instances/${ruleInstanceUuid}`,
3146
+ oauthClient: this.oauthClient,
3147
+ numRetries: this.numRetries
3148
+ });
3149
+ return res.data;
3150
+ }
3151
+ /**
3152
+ * Update a rule instance within a security group.
3153
+ * @param securityGroupUuid - Security group UUID.
3154
+ * @param ruleInstanceUuid - Rule instance UUID.
3155
+ * @param request - Updated rule instance fields.
3156
+ * @returns The updated rule instance.
3157
+ */
3158
+ async updateRuleInstance(securityGroupUuid, ruleInstanceUuid, request) {
3159
+ if (!isValidUuid(securityGroupUuid)) {
3160
+ throw new AISecSDKException(
3161
+ `Invalid security group uuid: ${securityGroupUuid}`,
3162
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3163
+ );
3164
+ }
3165
+ if (!isValidUuid(ruleInstanceUuid)) {
3166
+ throw new AISecSDKException(
3167
+ `Invalid rule instance uuid: ${ruleInstanceUuid}`,
3168
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3169
+ );
3170
+ }
3171
+ const res = await managementHttpRequest({
3172
+ method: "PUT",
3173
+ baseUrl: this.baseUrl,
3174
+ path: `${MODEL_SEC_SECURITY_GROUPS_PATH}/${securityGroupUuid}/rule-instances/${ruleInstanceUuid}`,
3175
+ body: request,
3176
+ oauthClient: this.oauthClient,
3177
+ numRetries: this.numRetries
3178
+ });
3179
+ return res.data;
3180
+ }
3181
+ };
3182
+
3183
+ // src/model-security/security-rules-client.ts
3184
+ function buildListParams3(opts) {
3185
+ const params = {};
3186
+ if (opts?.skip !== void 0) params.skip = String(opts.skip);
3187
+ if (opts?.limit !== void 0) params.limit = String(opts.limit);
3188
+ if (opts?.sort_by !== void 0) params.sort_by = opts.sort_by;
3189
+ if (opts?.sort_direction !== void 0) params.sort_direction = opts.sort_direction;
3190
+ if (opts?.search !== void 0) params.search = opts.search;
3191
+ return params;
3192
+ }
3193
+ var ModelSecurityRulesClient = class {
3194
+ baseUrl;
3195
+ oauthClient;
3196
+ numRetries;
3197
+ constructor(opts) {
3198
+ this.baseUrl = opts.baseUrl;
3199
+ this.oauthClient = opts.oauthClient;
3200
+ this.numRetries = opts.numRetries;
3201
+ }
3202
+ /**
3203
+ * List available security rules.
3204
+ * @param opts - Pagination options.
3205
+ * @returns Paginated list of security rules.
3206
+ */
3207
+ async list(opts) {
3208
+ const res = await managementHttpRequest({
3209
+ method: "GET",
3210
+ baseUrl: this.baseUrl,
3211
+ path: MODEL_SEC_SECURITY_RULES_PATH,
3212
+ params: buildListParams3(opts),
3213
+ oauthClient: this.oauthClient,
3214
+ numRetries: this.numRetries
3215
+ });
3216
+ return res.data;
3217
+ }
3218
+ /**
3219
+ * Get a single security rule by UUID.
3220
+ * @param uuid - Security rule UUID.
3221
+ * @returns The security rule.
3222
+ */
3223
+ async get(uuid) {
3224
+ if (!isValidUuid(uuid)) {
3225
+ throw new AISecSDKException(
3226
+ `Invalid security rule uuid: ${uuid}`,
3227
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3228
+ );
3229
+ }
3230
+ const res = await managementHttpRequest({
3231
+ method: "GET",
3232
+ baseUrl: this.baseUrl,
3233
+ path: `${MODEL_SEC_SECURITY_RULES_PATH}/${uuid}`,
3234
+ oauthClient: this.oauthClient,
3235
+ numRetries: this.numRetries
3236
+ });
3237
+ return res.data;
3238
+ }
3239
+ };
3240
+
3241
+ // src/model-security/client.ts
3242
+ var ModelSecurityClient = class {
3243
+ /** Data plane scan operations. */
3244
+ scans;
3245
+ /** Management plane security group operations. */
3246
+ securityGroups;
3247
+ /** Management plane security rule operations (read-only). */
3248
+ securityRules;
3249
+ mgmtEndpoint;
3250
+ oauthClient;
3251
+ numRetries;
3252
+ constructor(opts = {}) {
3253
+ const clientId = opts.clientId ?? process.env[MODEL_SEC_CLIENT_ID] ?? process.env[MGMT_CLIENT_ID];
3254
+ const clientSecret = opts.clientSecret ?? process.env[MODEL_SEC_CLIENT_SECRET] ?? process.env[MGMT_CLIENT_SECRET];
3255
+ const tsgId = opts.tsgId ?? process.env[MODEL_SEC_TSG_ID] ?? process.env[MGMT_TSG_ID];
3256
+ const dataEndpoint = opts.dataEndpoint ?? process.env[MODEL_SEC_DATA_ENDPOINT] ?? DEFAULT_MODEL_SEC_DATA_ENDPOINT;
3257
+ const mgmtEndpoint = opts.mgmtEndpoint ?? process.env[MODEL_SEC_MGMT_ENDPOINT] ?? DEFAULT_MODEL_SEC_MGMT_ENDPOINT;
3258
+ const tokenEndpoint = opts.tokenEndpoint ?? process.env[MODEL_SEC_TOKEN_ENDPOINT] ?? process.env[MGMT_TOKEN_ENDPOINT];
3259
+ const numRetries = Math.min(
3260
+ Math.max(opts.numRetries ?? MAX_NUMBER_OF_RETRIES, 0),
3261
+ MAX_NUMBER_OF_RETRIES
3262
+ );
3263
+ if (!clientId) {
3264
+ throw new AISecSDKException(
3265
+ "clientId is required (option or PANW_MODEL_SEC_CLIENT_ID / PANW_MGMT_CLIENT_ID env var)",
3266
+ "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
3267
+ );
3268
+ }
3269
+ if (!clientSecret) {
3270
+ throw new AISecSDKException(
3271
+ "clientSecret is required (option or PANW_MODEL_SEC_CLIENT_SECRET / PANW_MGMT_CLIENT_SECRET env var)",
3272
+ "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
3273
+ );
3274
+ }
3275
+ if (!tsgId) {
3276
+ throw new AISecSDKException(
3277
+ "tsgId is required (option or PANW_MODEL_SEC_TSG_ID / PANW_MGMT_TSG_ID env var)",
3278
+ "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
3279
+ );
3280
+ }
3281
+ this.oauthClient = new OAuthClient({
3282
+ clientId,
3283
+ clientSecret,
3284
+ tsgId,
3285
+ tokenEndpoint
3286
+ });
3287
+ this.mgmtEndpoint = mgmtEndpoint;
3288
+ this.numRetries = numRetries;
3289
+ this.scans = new ModelSecurityScansClient({
3290
+ baseUrl: dataEndpoint,
3291
+ oauthClient: this.oauthClient,
3292
+ numRetries
3293
+ });
3294
+ this.securityGroups = new ModelSecurityGroupsClient({
3295
+ baseUrl: mgmtEndpoint,
3296
+ oauthClient: this.oauthClient,
3297
+ numRetries
3298
+ });
3299
+ this.securityRules = new ModelSecurityRulesClient({
3300
+ baseUrl: mgmtEndpoint,
3301
+ oauthClient: this.oauthClient,
3302
+ numRetries
3303
+ });
3304
+ }
3305
+ /**
3306
+ * Get PyPI authentication credentials for Google Artifact Registry.
3307
+ * @returns PyPI auth response with URL and expiration.
3308
+ */
3309
+ async getPyPIAuth() {
3310
+ const res = await managementHttpRequest({
3311
+ method: "GET",
3312
+ baseUrl: this.mgmtEndpoint,
3313
+ path: MODEL_SEC_PYPI_AUTH_PATH,
3314
+ oauthClient: this.oauthClient,
3315
+ numRetries: this.numRetries
3316
+ });
3317
+ return res.data;
3318
+ }
3319
+ };
3320
+
3321
+ // src/red-team/scans-client.ts
3322
+ function buildListParams4(opts) {
3323
+ const params = {};
3324
+ if (opts?.skip !== void 0) params.skip = String(opts.skip);
3325
+ if (opts?.limit !== void 0) params.limit = String(opts.limit);
3326
+ if (opts?.sort_by !== void 0) params.sort_by = opts.sort_by;
3327
+ if (opts?.sort_direction !== void 0) params.sort_direction = opts.sort_direction;
3328
+ if (opts?.search !== void 0) params.search = opts.search;
3329
+ return params;
3330
+ }
3331
+ var RedTeamScansClient = class {
3332
+ baseUrl;
3333
+ oauthClient;
3334
+ numRetries;
3335
+ constructor(opts) {
3336
+ this.baseUrl = opts.baseUrl;
3337
+ this.oauthClient = opts.oauthClient;
3338
+ this.numRetries = opts.numRetries;
3339
+ }
3340
+ /** Create a new red team scan job. */
3341
+ async create(request) {
3342
+ const res = await managementHttpRequest({
3343
+ method: "POST",
3344
+ baseUrl: this.baseUrl,
3345
+ path: RED_TEAM_SCAN_PATH,
3346
+ body: request,
3347
+ oauthClient: this.oauthClient,
3348
+ numRetries: this.numRetries
3349
+ });
3350
+ return res.data;
3351
+ }
3352
+ /** List red team scan jobs with optional filters. */
3353
+ async list(opts) {
3354
+ const params = buildListParams4(opts);
3355
+ if (opts?.status !== void 0) params.status = opts.status;
3356
+ if (opts?.job_type !== void 0) params.job_type = opts.job_type;
3357
+ if (opts?.target_id !== void 0) params.target_id = opts.target_id;
3358
+ const res = await managementHttpRequest({
3359
+ method: "GET",
3360
+ baseUrl: this.baseUrl,
3361
+ path: RED_TEAM_SCAN_PATH,
3362
+ params,
3363
+ oauthClient: this.oauthClient,
3364
+ numRetries: this.numRetries
3365
+ });
3366
+ return res.data;
3367
+ }
3368
+ /** Get a single scan job by ID. */
3369
+ async get(jobId) {
3370
+ if (!isValidUuid(jobId)) {
3371
+ throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
3372
+ }
3373
+ const res = await managementHttpRequest({
3374
+ method: "GET",
3375
+ baseUrl: this.baseUrl,
3376
+ path: `${RED_TEAM_SCAN_PATH}/${jobId}`,
3377
+ oauthClient: this.oauthClient,
3378
+ numRetries: this.numRetries
3379
+ });
3380
+ return res.data;
3381
+ }
3382
+ /** Abort a running scan job. */
3383
+ async abort(jobId) {
3384
+ if (!isValidUuid(jobId)) {
3385
+ throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
3386
+ }
3387
+ const res = await managementHttpRequest({
3388
+ method: "POST",
3389
+ baseUrl: this.baseUrl,
3390
+ path: `${RED_TEAM_SCAN_PATH}/${jobId}/abort`,
3391
+ oauthClient: this.oauthClient,
3392
+ numRetries: this.numRetries
3393
+ });
3394
+ return res.data;
3395
+ }
3396
+ /** Get all categories with subcategories. */
3397
+ async getCategories() {
3398
+ const res = await managementHttpRequest({
3399
+ method: "GET",
3400
+ baseUrl: this.baseUrl,
3401
+ path: RED_TEAM_CATEGORIES_PATH,
3402
+ oauthClient: this.oauthClient,
3403
+ numRetries: this.numRetries
3404
+ });
3405
+ return res.data;
3406
+ }
3407
+ };
3408
+
3409
+ // src/red-team/reports-client.ts
3410
+ function buildListParams5(opts) {
3411
+ const params = {};
3412
+ if (opts?.skip !== void 0) params.skip = String(opts.skip);
3413
+ if (opts?.limit !== void 0) params.limit = String(opts.limit);
3414
+ if (opts?.sort_by !== void 0) params.sort_by = opts.sort_by;
3415
+ if (opts?.sort_direction !== void 0) params.sort_direction = opts.sort_direction;
3416
+ if (opts?.search !== void 0) params.search = opts.search;
3417
+ return params;
3418
+ }
3419
+ function validateJobId(jobId) {
3420
+ if (!isValidUuid(jobId)) {
3421
+ throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
3422
+ }
3423
+ }
3424
+ var RedTeamReportsClient = class {
3425
+ baseUrl;
3426
+ oauthClient;
3427
+ numRetries;
3428
+ constructor(opts) {
3429
+ this.baseUrl = opts.baseUrl;
3430
+ this.oauthClient = opts.oauthClient;
3431
+ this.numRetries = opts.numRetries;
3432
+ }
3433
+ // -----------------------------------------------------------------------
3434
+ // Static (attack library) report endpoints
3435
+ // -----------------------------------------------------------------------
3436
+ /** List attacks for a static scan. */
3437
+ async listAttacks(jobId, opts) {
3438
+ validateJobId(jobId);
3439
+ const params = buildListParams5(opts);
3440
+ if (opts?.status !== void 0) params.status = opts.status;
3441
+ if (opts?.severity !== void 0) params.severity = opts.severity;
3442
+ if (opts?.category !== void 0) params.category = opts.category;
3443
+ if (opts?.sub_category !== void 0) params.sub_category = opts.sub_category;
3444
+ const res = await managementHttpRequest({
3445
+ method: "GET",
3446
+ baseUrl: this.baseUrl,
3447
+ path: `${RED_TEAM_REPORT_STATIC_PATH}/${jobId}/list-attacks`,
3448
+ params,
3449
+ oauthClient: this.oauthClient,
3450
+ numRetries: this.numRetries
3451
+ });
3452
+ return res.data;
3453
+ }
3454
+ /** Get attack details for a static scan. */
3455
+ async getAttackDetail(jobId, attackId) {
3456
+ validateJobId(jobId);
3457
+ if (!isValidUuid(attackId)) {
3458
+ throw new AISecSDKException(
3459
+ `Invalid attack id: ${attackId}`,
3460
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3461
+ );
3462
+ }
3463
+ const res = await managementHttpRequest({
3464
+ method: "GET",
3465
+ baseUrl: this.baseUrl,
3466
+ path: `${RED_TEAM_REPORT_STATIC_PATH}/${jobId}/attack/${attackId}`,
3467
+ oauthClient: this.oauthClient,
3468
+ numRetries: this.numRetries
3469
+ });
3470
+ return res.data;
3471
+ }
3472
+ /** Get multi-turn attack details for a static scan. */
3473
+ async getMultiTurnAttackDetail(jobId, attackId) {
3474
+ validateJobId(jobId);
3475
+ if (!isValidUuid(attackId)) {
3476
+ throw new AISecSDKException(
3477
+ `Invalid attack id: ${attackId}`,
3478
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3479
+ );
3480
+ }
3481
+ const res = await managementHttpRequest({
3482
+ method: "GET",
3483
+ baseUrl: this.baseUrl,
3484
+ path: `${RED_TEAM_REPORT_STATIC_PATH}/${jobId}/attack-multi-turn/${attackId}`,
3485
+ oauthClient: this.oauthClient,
3486
+ numRetries: this.numRetries
3487
+ });
3488
+ return res.data;
3489
+ }
3490
+ /** Get the attack library report for a static scan. */
3491
+ async getStaticReport(jobId) {
3492
+ validateJobId(jobId);
3493
+ const res = await managementHttpRequest({
3494
+ method: "GET",
3495
+ baseUrl: this.baseUrl,
3496
+ path: `${RED_TEAM_REPORT_STATIC_PATH}/${jobId}/report`,
3497
+ oauthClient: this.oauthClient,
3498
+ numRetries: this.numRetries
3499
+ });
3500
+ return res.data;
3501
+ }
3502
+ /** Get remediation recommendations for a static scan. */
3503
+ async getStaticRemediation(jobId) {
3504
+ validateJobId(jobId);
3505
+ const res = await managementHttpRequest({
3506
+ method: "GET",
3507
+ baseUrl: this.baseUrl,
3508
+ path: `${RED_TEAM_REPORT_STATIC_PATH}/${jobId}/remediation`,
3509
+ oauthClient: this.oauthClient,
3510
+ numRetries: this.numRetries
3511
+ });
3512
+ return res.data;
3513
+ }
3514
+ /** Get runtime security profile config for a static scan. */
3515
+ async getStaticRuntimePolicy(jobId) {
3516
+ validateJobId(jobId);
3517
+ const res = await managementHttpRequest({
3518
+ method: "GET",
3519
+ baseUrl: this.baseUrl,
3520
+ path: `${RED_TEAM_REPORT_STATIC_PATH}/${jobId}/runtime-policy-config`,
3521
+ oauthClient: this.oauthClient,
3522
+ numRetries: this.numRetries
3523
+ });
3524
+ return res.data;
3525
+ }
3526
+ // -----------------------------------------------------------------------
3527
+ // Dynamic (agent) report endpoints
3528
+ // -----------------------------------------------------------------------
3529
+ /** Get the agent scan report for a dynamic scan. */
3530
+ async getDynamicReport(jobId) {
3531
+ validateJobId(jobId);
3532
+ const res = await managementHttpRequest({
3533
+ method: "GET",
3534
+ baseUrl: this.baseUrl,
3535
+ path: `${RED_TEAM_REPORT_DYNAMIC_PATH}/${jobId}/report`,
3536
+ oauthClient: this.oauthClient,
3537
+ numRetries: this.numRetries
3538
+ });
3539
+ return res.data;
3540
+ }
3541
+ /** Get remediation recommendations for a dynamic scan. */
3542
+ async getDynamicRemediation(jobId) {
3543
+ validateJobId(jobId);
3544
+ const res = await managementHttpRequest({
3545
+ method: "GET",
3546
+ baseUrl: this.baseUrl,
3547
+ path: `${RED_TEAM_REPORT_DYNAMIC_PATH}/${jobId}/remediation`,
3548
+ oauthClient: this.oauthClient,
3549
+ numRetries: this.numRetries
3550
+ });
3551
+ return res.data;
3552
+ }
3553
+ /** Get runtime security profile config for a dynamic scan. */
3554
+ async getDynamicRuntimePolicy(jobId) {
3555
+ validateJobId(jobId);
3556
+ const res = await managementHttpRequest({
3557
+ method: "GET",
3558
+ baseUrl: this.baseUrl,
3559
+ path: `${RED_TEAM_REPORT_DYNAMIC_PATH}/${jobId}/runtime-policy-config`,
3560
+ oauthClient: this.oauthClient,
3561
+ numRetries: this.numRetries
3562
+ });
3563
+ return res.data;
3564
+ }
3565
+ /** List goals for a dynamic scan. */
3566
+ async listGoals(jobId, opts) {
3567
+ validateJobId(jobId);
3568
+ const params = buildListParams5(opts);
3569
+ if (opts?.goal_type !== void 0) params.goal_type = opts.goal_type;
3570
+ const res = await managementHttpRequest({
3571
+ method: "GET",
3572
+ baseUrl: this.baseUrl,
3573
+ path: `${RED_TEAM_REPORT_DYNAMIC_PATH}/${jobId}/list-goals`,
3574
+ params,
3575
+ oauthClient: this.oauthClient,
3576
+ numRetries: this.numRetries
3577
+ });
3578
+ return res.data;
3579
+ }
3580
+ /** List streams for a goal in a dynamic scan. */
3581
+ async listGoalStreams(jobId, goalId, opts) {
3582
+ validateJobId(jobId);
3583
+ if (!isValidUuid(goalId)) {
3584
+ throw new AISecSDKException(
3585
+ `Invalid goal id: ${goalId}`,
3586
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3587
+ );
3588
+ }
3589
+ const res = await managementHttpRequest({
3590
+ method: "GET",
3591
+ baseUrl: this.baseUrl,
3592
+ path: `${RED_TEAM_REPORT_DYNAMIC_PATH}/${jobId}/goal/${goalId}/list-streams`,
3593
+ params: buildListParams5(opts),
3594
+ oauthClient: this.oauthClient,
3595
+ numRetries: this.numRetries
3596
+ });
3597
+ return res.data;
3598
+ }
3599
+ // -----------------------------------------------------------------------
3600
+ // Common report endpoints
3601
+ // -----------------------------------------------------------------------
3602
+ /** Get stream details by stream ID. */
3603
+ async getStreamDetail(streamId) {
3604
+ if (!isValidUuid(streamId)) {
3605
+ throw new AISecSDKException(
3606
+ `Invalid stream id: ${streamId}`,
3607
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3608
+ );
3609
+ }
3610
+ const res = await managementHttpRequest({
3611
+ method: "GET",
3612
+ baseUrl: this.baseUrl,
3613
+ path: `${RED_TEAM_REPORT_DYNAMIC_PATH}/stream/${streamId}`,
3614
+ oauthClient: this.oauthClient,
3615
+ numRetries: this.numRetries
3616
+ });
3617
+ return res.data;
3618
+ }
3619
+ /** Download a report in the specified format. */
3620
+ async downloadReport(jobId, format) {
3621
+ validateJobId(jobId);
3622
+ const params = {};
3623
+ if (format !== void 0) params.file_format = format;
3624
+ const res = await managementHttpRequest({
3625
+ method: "GET",
3626
+ baseUrl: this.baseUrl,
3627
+ path: `${RED_TEAM_REPORT_PATH}/${jobId}/download`,
3628
+ params,
3629
+ oauthClient: this.oauthClient,
3630
+ numRetries: this.numRetries
3631
+ });
3632
+ return res.data;
3633
+ }
3634
+ /** Generate a partial report for a running scan. */
3635
+ async generatePartialReport(jobId) {
3636
+ validateJobId(jobId);
3637
+ const res = await managementHttpRequest({
3638
+ method: "POST",
3639
+ baseUrl: this.baseUrl,
3640
+ path: `${RED_TEAM_REPORT_PATH}/${jobId}/generate-partial-report`,
3641
+ oauthClient: this.oauthClient,
3642
+ numRetries: this.numRetries
3643
+ });
3644
+ return res.data;
3645
+ }
3646
+ };
3647
+
3648
+ // src/red-team/custom-attack-reports-client.ts
3649
+ function buildListParams6(opts) {
3650
+ const params = {};
3651
+ if (opts?.skip !== void 0) params.skip = String(opts.skip);
3652
+ if (opts?.limit !== void 0) params.limit = String(opts.limit);
3653
+ if (opts?.sort_by !== void 0) params.sort_by = opts.sort_by;
3654
+ if (opts?.sort_direction !== void 0) params.sort_direction = opts.sort_direction;
3655
+ if (opts?.search !== void 0) params.search = opts.search;
3656
+ return params;
3657
+ }
3658
+ function validateJobId2(jobId) {
3659
+ if (!isValidUuid(jobId)) {
3660
+ throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
3661
+ }
3662
+ }
3663
+ var RedTeamCustomAttackReportsClient = class {
3664
+ baseUrl;
3665
+ oauthClient;
3666
+ numRetries;
3667
+ constructor(opts) {
3668
+ this.baseUrl = opts.baseUrl;
3669
+ this.oauthClient = opts.oauthClient;
3670
+ this.numRetries = opts.numRetries;
3671
+ }
3672
+ /** Get custom attack report for a scan. */
3673
+ async getReport(jobId) {
3674
+ validateJobId2(jobId);
3675
+ const res = await managementHttpRequest({
3676
+ method: "GET",
3677
+ baseUrl: this.baseUrl,
3678
+ path: `${RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH}/report/${jobId}`,
3679
+ oauthClient: this.oauthClient,
3680
+ numRetries: this.numRetries
3681
+ });
3682
+ return res.data;
3683
+ }
3684
+ /** Get prompt sets for a custom attack scan. */
3685
+ async getPromptSets(jobId) {
3686
+ validateJobId2(jobId);
3687
+ const res = await managementHttpRequest({
3688
+ method: "GET",
3689
+ baseUrl: this.baseUrl,
3690
+ path: `${RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH}/report/${jobId}/prompt-sets`,
3691
+ oauthClient: this.oauthClient,
3692
+ numRetries: this.numRetries
3693
+ });
3694
+ return res.data;
3695
+ }
3696
+ /** Get prompts for a specific prompt set in a scan. */
3697
+ async getPromptsBySet(jobId, promptSetId, opts) {
3698
+ validateJobId2(jobId);
3699
+ if (!isValidUuid(promptSetId)) {
3700
+ throw new AISecSDKException(
3701
+ `Invalid prompt set id: ${promptSetId}`,
3702
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3703
+ );
3704
+ }
3705
+ const res = await managementHttpRequest({
3706
+ method: "GET",
3707
+ baseUrl: this.baseUrl,
3708
+ path: `${RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH}/report/${jobId}/prompt-set/${promptSetId}/prompts`,
3709
+ params: buildListParams6(opts),
3710
+ oauthClient: this.oauthClient,
3711
+ numRetries: this.numRetries
3712
+ });
3713
+ return res.data;
3714
+ }
3715
+ /** Get details for a specific prompt. */
3716
+ async getPromptDetail(jobId, promptId) {
3717
+ validateJobId2(jobId);
3718
+ if (!isValidUuid(promptId)) {
3719
+ throw new AISecSDKException(
3720
+ `Invalid prompt id: ${promptId}`,
3721
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3722
+ );
3723
+ }
3724
+ const res = await managementHttpRequest({
3725
+ method: "GET",
3726
+ baseUrl: this.baseUrl,
3727
+ path: `${RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH}/report/${jobId}/prompt/${promptId}`,
3728
+ oauthClient: this.oauthClient,
3729
+ numRetries: this.numRetries
3730
+ });
3731
+ return res.data;
3732
+ }
3733
+ /** List custom attacks for a scan. */
3734
+ async listCustomAttacks(jobId, opts) {
3735
+ validateJobId2(jobId);
3736
+ const res = await managementHttpRequest({
3737
+ method: "GET",
3738
+ baseUrl: this.baseUrl,
3739
+ path: `${RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH}/job/${jobId}/list-custom-attacks`,
3740
+ params: buildListParams6(opts),
3741
+ oauthClient: this.oauthClient,
3742
+ numRetries: this.numRetries
3743
+ });
3744
+ return res.data;
3745
+ }
3746
+ /** Get attack outputs for a custom attack. */
3747
+ async getAttackOutputs(jobId, attackId) {
3748
+ validateJobId2(jobId);
3749
+ if (!isValidUuid(attackId)) {
3750
+ throw new AISecSDKException(
3751
+ `Invalid attack id: ${attackId}`,
3752
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3753
+ );
3754
+ }
3755
+ const res = await managementHttpRequest({
3756
+ method: "GET",
3757
+ baseUrl: this.baseUrl,
3758
+ path: `${RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH}/job/${jobId}/attack/${attackId}/list-outputs`,
3759
+ oauthClient: this.oauthClient,
3760
+ numRetries: this.numRetries
3761
+ });
3762
+ return res.data;
3763
+ }
3764
+ /** Get property statistics for a custom attack scan. */
3765
+ async getPropertyStats(jobId) {
3766
+ validateJobId2(jobId);
3767
+ const res = await managementHttpRequest({
3768
+ method: "GET",
3769
+ baseUrl: this.baseUrl,
3770
+ path: `${RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH}/job/${jobId}/property-stats`,
3771
+ oauthClient: this.oauthClient,
3772
+ numRetries: this.numRetries
3773
+ });
3774
+ return res.data;
3775
+ }
3776
+ };
3777
+
3778
+ // src/red-team/targets-client.ts
3779
+ function buildListParams7(opts) {
3780
+ const params = {};
3781
+ if (opts?.skip !== void 0) params.skip = String(opts.skip);
3782
+ if (opts?.limit !== void 0) params.limit = String(opts.limit);
3783
+ if (opts?.sort_by !== void 0) params.sort_by = opts.sort_by;
3784
+ if (opts?.sort_direction !== void 0) params.sort_direction = opts.sort_direction;
3785
+ if (opts?.search !== void 0) params.search = opts.search;
3786
+ return params;
3787
+ }
3788
+ var RedTeamTargetsClient = class {
3789
+ baseUrl;
3790
+ oauthClient;
3791
+ numRetries;
3792
+ constructor(opts) {
3793
+ this.baseUrl = opts.baseUrl;
3794
+ this.oauthClient = opts.oauthClient;
3795
+ this.numRetries = opts.numRetries;
3796
+ }
3797
+ /** Create a new target. */
3798
+ async create(request) {
3799
+ const res = await managementHttpRequest({
3800
+ method: "POST",
3801
+ baseUrl: this.baseUrl,
3802
+ path: RED_TEAM_TARGET_PATH,
3803
+ body: request,
3804
+ oauthClient: this.oauthClient,
3805
+ numRetries: this.numRetries
3806
+ });
3807
+ return res.data;
3808
+ }
3809
+ /** List targets with optional filters. */
3810
+ async list(opts) {
3811
+ const params = buildListParams7(opts);
3812
+ if (opts?.target_type !== void 0) params.target_type = opts.target_type;
3813
+ if (opts?.status !== void 0) params.status = opts.status;
3814
+ if (opts?.active !== void 0) params.active = String(opts.active);
3815
+ const res = await managementHttpRequest({
3816
+ method: "GET",
3817
+ baseUrl: this.baseUrl,
3818
+ path: RED_TEAM_TARGET_PATH,
3819
+ params,
3820
+ oauthClient: this.oauthClient,
3821
+ numRetries: this.numRetries
3822
+ });
3823
+ return res.data;
3824
+ }
3825
+ /** Get a target by UUID. */
3826
+ async get(uuid) {
3827
+ if (!isValidUuid(uuid)) {
3828
+ throw new AISecSDKException(
3829
+ `Invalid target uuid: ${uuid}`,
3830
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3831
+ );
3832
+ }
3833
+ const res = await managementHttpRequest({
3834
+ method: "GET",
3835
+ baseUrl: this.baseUrl,
3836
+ path: `${RED_TEAM_TARGET_PATH}/${uuid}`,
3837
+ oauthClient: this.oauthClient,
3838
+ numRetries: this.numRetries
3839
+ });
3840
+ return res.data;
3841
+ }
3842
+ /** Update a target. */
3843
+ async update(uuid, request) {
3844
+ if (!isValidUuid(uuid)) {
3845
+ throw new AISecSDKException(
3846
+ `Invalid target uuid: ${uuid}`,
3847
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3848
+ );
3849
+ }
3850
+ const res = await managementHttpRequest({
3851
+ method: "PUT",
3852
+ baseUrl: this.baseUrl,
3853
+ path: `${RED_TEAM_TARGET_PATH}/${uuid}`,
3854
+ body: request,
3855
+ oauthClient: this.oauthClient,
3856
+ numRetries: this.numRetries
3857
+ });
3858
+ return res.data;
3859
+ }
3860
+ /** Delete a target. */
3861
+ async delete(uuid) {
3862
+ if (!isValidUuid(uuid)) {
3863
+ throw new AISecSDKException(
3864
+ `Invalid target uuid: ${uuid}`,
3865
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3866
+ );
3867
+ }
3868
+ const res = await managementHttpRequest({
3869
+ method: "DELETE",
3870
+ baseUrl: this.baseUrl,
3871
+ path: `${RED_TEAM_TARGET_PATH}/${uuid}`,
3872
+ oauthClient: this.oauthClient,
3873
+ numRetries: this.numRetries
3874
+ });
3875
+ return res.data;
3876
+ }
3877
+ /** Run profiling probes on a target. */
3878
+ async probe(request) {
3879
+ const res = await managementHttpRequest({
3880
+ method: "POST",
3881
+ baseUrl: this.baseUrl,
3882
+ path: `${RED_TEAM_TARGET_PATH}/probe`,
3883
+ body: request,
3884
+ oauthClient: this.oauthClient,
3885
+ numRetries: this.numRetries
3886
+ });
3887
+ return res.data;
3888
+ }
3889
+ /** Get profiling results for a target. */
3890
+ async getProfile(uuid) {
3891
+ if (!isValidUuid(uuid)) {
3892
+ throw new AISecSDKException(
3893
+ `Invalid target uuid: ${uuid}`,
3894
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3895
+ );
3896
+ }
3897
+ const res = await managementHttpRequest({
3898
+ method: "GET",
3899
+ baseUrl: this.baseUrl,
3900
+ path: `${RED_TEAM_TARGET_PATH}/${uuid}/profile`,
3901
+ oauthClient: this.oauthClient,
3902
+ numRetries: this.numRetries
3903
+ });
3904
+ return res.data;
3905
+ }
3906
+ /** Update a target profile (background + additional context). */
3907
+ async updateProfile(uuid, request) {
3908
+ if (!isValidUuid(uuid)) {
3909
+ throw new AISecSDKException(
3910
+ `Invalid target uuid: ${uuid}`,
3911
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3912
+ );
3913
+ }
3914
+ const res = await managementHttpRequest({
3915
+ method: "PUT",
3916
+ baseUrl: this.baseUrl,
3917
+ path: `${RED_TEAM_TARGET_PATH}/${uuid}/profile`,
3918
+ body: request,
3919
+ oauthClient: this.oauthClient,
3920
+ numRetries: this.numRetries
3921
+ });
3922
+ return res.data;
3923
+ }
3924
+ };
3925
+
3926
+ // src/red-team/custom-attacks-client.ts
3927
+ function buildListParams8(opts) {
3928
+ const params = {};
3929
+ if (opts?.skip !== void 0) params.skip = String(opts.skip);
3930
+ if (opts?.limit !== void 0) params.limit = String(opts.limit);
3931
+ if (opts?.sort_by !== void 0) params.sort_by = opts.sort_by;
3932
+ if (opts?.sort_direction !== void 0) params.sort_direction = opts.sort_direction;
3933
+ if (opts?.search !== void 0) params.search = opts.search;
3934
+ return params;
3935
+ }
3936
+ function validateUuid(uuid, label) {
3937
+ if (!isValidUuid(uuid)) {
3938
+ throw new AISecSDKException(`Invalid ${label}: ${uuid}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
3939
+ }
3940
+ }
3941
+ var RedTeamCustomAttacksClient = class {
3942
+ baseUrl;
3943
+ oauthClient;
3944
+ numRetries;
3945
+ constructor(opts) {
3946
+ this.baseUrl = opts.baseUrl;
3947
+ this.oauthClient = opts.oauthClient;
3948
+ this.numRetries = opts.numRetries;
3949
+ }
3950
+ // -----------------------------------------------------------------------
3951
+ // Prompt Set operations
3952
+ // -----------------------------------------------------------------------
3953
+ /** Create a new custom prompt set. */
3954
+ async createPromptSet(request) {
3955
+ const res = await managementHttpRequest({
3956
+ method: "POST",
3957
+ baseUrl: this.baseUrl,
3958
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/custom-prompt-set`,
3959
+ body: request,
3960
+ oauthClient: this.oauthClient,
3961
+ numRetries: this.numRetries
3962
+ });
3963
+ return res.data;
3964
+ }
3965
+ /** List custom prompt sets. */
3966
+ async listPromptSets(opts) {
3967
+ const params = buildListParams8(opts);
3968
+ if (opts?.active !== void 0) params.active = String(opts.active);
3969
+ if (opts?.archive !== void 0) params.archive = String(opts.archive);
3970
+ const res = await managementHttpRequest({
3971
+ method: "GET",
3972
+ baseUrl: this.baseUrl,
3973
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/list-custom-prompt-sets`,
3974
+ params,
3975
+ oauthClient: this.oauthClient,
3976
+ numRetries: this.numRetries
3977
+ });
3978
+ return res.data;
3979
+ }
3980
+ /** Get a prompt set by UUID. */
3981
+ async getPromptSet(uuid) {
3982
+ validateUuid(uuid, "prompt set uuid");
3983
+ const res = await managementHttpRequest({
3984
+ method: "GET",
3985
+ baseUrl: this.baseUrl,
3986
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/custom-prompt-set/${uuid}`,
3987
+ oauthClient: this.oauthClient,
3988
+ numRetries: this.numRetries
3989
+ });
3990
+ return res.data;
3991
+ }
3992
+ /** Update a prompt set. */
3993
+ async updatePromptSet(uuid, request) {
3994
+ validateUuid(uuid, "prompt set uuid");
3995
+ const res = await managementHttpRequest({
3996
+ method: "PUT",
3997
+ baseUrl: this.baseUrl,
3998
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/custom-prompt-set/${uuid}`,
3999
+ body: request,
4000
+ oauthClient: this.oauthClient,
4001
+ numRetries: this.numRetries
4002
+ });
4003
+ return res.data;
4004
+ }
4005
+ /** Archive or unarchive a prompt set. */
4006
+ async archivePromptSet(uuid, request) {
4007
+ validateUuid(uuid, "prompt set uuid");
4008
+ const res = await managementHttpRequest({
4009
+ method: "PUT",
4010
+ baseUrl: this.baseUrl,
4011
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/custom-prompt-set/${uuid}/archive`,
4012
+ body: request,
4013
+ oauthClient: this.oauthClient,
4014
+ numRetries: this.numRetries
4015
+ });
4016
+ return res.data;
4017
+ }
4018
+ /** Resolve a prompt set reference for data plane consumption. */
4019
+ async getPromptSetReference(uuid) {
4020
+ validateUuid(uuid, "prompt set uuid");
4021
+ const res = await managementHttpRequest({
4022
+ method: "GET",
4023
+ baseUrl: this.baseUrl,
4024
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/custom-prompt-set/${uuid}/reference`,
4025
+ oauthClient: this.oauthClient,
4026
+ numRetries: this.numRetries
4027
+ });
4028
+ return res.data;
4029
+ }
4030
+ /** Get version information for a prompt set. */
4031
+ async getPromptSetVersionInfo(uuid) {
4032
+ validateUuid(uuid, "prompt set uuid");
4033
+ const res = await managementHttpRequest({
4034
+ method: "GET",
4035
+ baseUrl: this.baseUrl,
4036
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/custom-prompt-set/${uuid}/version-info`,
4037
+ oauthClient: this.oauthClient,
4038
+ numRetries: this.numRetries
4039
+ });
4040
+ return res.data;
4041
+ }
4042
+ /** List active prompt sets (for data plane). */
4043
+ async listActivePromptSets() {
4044
+ const res = await managementHttpRequest({
4045
+ method: "GET",
4046
+ baseUrl: this.baseUrl,
4047
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/active-custom-prompt-sets`,
4048
+ oauthClient: this.oauthClient,
4049
+ numRetries: this.numRetries
4050
+ });
4051
+ return res.data;
4052
+ }
4053
+ /** Download CSV template for a prompt set. */
4054
+ async downloadTemplate(uuid) {
4055
+ validateUuid(uuid, "prompt set uuid");
4056
+ const res = await managementHttpRequest({
4057
+ method: "GET",
4058
+ baseUrl: this.baseUrl,
4059
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/download-template/${uuid}`,
4060
+ oauthClient: this.oauthClient,
4061
+ numRetries: this.numRetries
4062
+ });
4063
+ return res.data;
4064
+ }
4065
+ // -----------------------------------------------------------------------
4066
+ // Prompt operations
4067
+ // -----------------------------------------------------------------------
4068
+ /** Create a new custom prompt. */
4069
+ async createPrompt(request) {
4070
+ const res = await managementHttpRequest({
4071
+ method: "POST",
4072
+ baseUrl: this.baseUrl,
4073
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/custom-prompt-set/custom-prompt`,
4074
+ body: request,
4075
+ oauthClient: this.oauthClient,
4076
+ numRetries: this.numRetries
4077
+ });
4078
+ return res.data;
4079
+ }
4080
+ /** List prompts in a prompt set. */
4081
+ async listPrompts(promptSetUuid, opts) {
4082
+ validateUuid(promptSetUuid, "prompt set uuid");
4083
+ const params = buildListParams8(opts);
4084
+ if (opts?.active !== void 0) params.active = String(opts.active);
4085
+ const res = await managementHttpRequest({
4086
+ method: "GET",
4087
+ baseUrl: this.baseUrl,
4088
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/custom-prompt-set/${promptSetUuid}/list-custom-prompts`,
4089
+ params,
4090
+ oauthClient: this.oauthClient,
4091
+ numRetries: this.numRetries
4092
+ });
4093
+ return res.data;
4094
+ }
4095
+ /** Get a prompt by UUID. */
4096
+ async getPrompt(promptSetUuid, promptUuid) {
4097
+ validateUuid(promptSetUuid, "prompt set uuid");
4098
+ validateUuid(promptUuid, "prompt uuid");
4099
+ const res = await managementHttpRequest({
4100
+ method: "GET",
4101
+ baseUrl: this.baseUrl,
4102
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/custom-prompt-set/${promptSetUuid}/custom-prompt/${promptUuid}`,
4103
+ oauthClient: this.oauthClient,
4104
+ numRetries: this.numRetries
4105
+ });
4106
+ return res.data;
4107
+ }
4108
+ /** Update a prompt. */
4109
+ async updatePrompt(promptSetUuid, promptUuid, request) {
4110
+ validateUuid(promptSetUuid, "prompt set uuid");
4111
+ validateUuid(promptUuid, "prompt uuid");
4112
+ const res = await managementHttpRequest({
4113
+ method: "PUT",
4114
+ baseUrl: this.baseUrl,
4115
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/custom-prompt-set/${promptSetUuid}/custom-prompt/${promptUuid}`,
4116
+ body: request,
4117
+ oauthClient: this.oauthClient,
4118
+ numRetries: this.numRetries
4119
+ });
4120
+ return res.data;
4121
+ }
4122
+ /** Delete a prompt. */
4123
+ async deletePrompt(promptSetUuid, promptUuid) {
4124
+ validateUuid(promptSetUuid, "prompt set uuid");
4125
+ validateUuid(promptUuid, "prompt uuid");
4126
+ const res = await managementHttpRequest({
4127
+ method: "DELETE",
4128
+ baseUrl: this.baseUrl,
4129
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/custom-prompt-set/${promptSetUuid}/custom-prompt/${promptUuid}`,
4130
+ oauthClient: this.oauthClient,
4131
+ numRetries: this.numRetries
4132
+ });
4133
+ return res.data;
4134
+ }
4135
+ // -----------------------------------------------------------------------
4136
+ // Property operations
4137
+ // -----------------------------------------------------------------------
4138
+ /** Get all property names. */
4139
+ async getPropertyNames() {
4140
+ const res = await managementHttpRequest({
4141
+ method: "GET",
4142
+ baseUrl: this.baseUrl,
4143
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/property-names`,
4144
+ oauthClient: this.oauthClient,
4145
+ numRetries: this.numRetries
4146
+ });
4147
+ return res.data;
4148
+ }
4149
+ /** Create a new property name. */
4150
+ async createPropertyName(request) {
4151
+ const res = await managementHttpRequest({
4152
+ method: "POST",
4153
+ baseUrl: this.baseUrl,
4154
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/property-names`,
4155
+ body: request,
4156
+ oauthClient: this.oauthClient,
4157
+ numRetries: this.numRetries
4158
+ });
4159
+ return res.data;
4160
+ }
4161
+ /** Get values for a property name. */
4162
+ async getPropertyValues(propertyName) {
4163
+ const res = await managementHttpRequest({
4164
+ method: "GET",
4165
+ baseUrl: this.baseUrl,
4166
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/property-values/${encodeURIComponent(propertyName)}`,
4167
+ oauthClient: this.oauthClient,
4168
+ numRetries: this.numRetries
4169
+ });
4170
+ return res.data;
4171
+ }
4172
+ /** Get values for multiple property names. */
4173
+ async getPropertyValuesMultiple(propertyNames) {
4174
+ const url = new URL(`https://placeholder${RED_TEAM_CUSTOM_ATTACK_PATH}/property-values`);
4175
+ for (const name of propertyNames) {
4176
+ url.searchParams.append("property_names", name);
4177
+ }
4178
+ const queryString = url.searchParams.toString();
4179
+ const pathWithQuery = `${RED_TEAM_CUSTOM_ATTACK_PATH}/property-values${queryString ? `?${queryString}` : ""}`;
4180
+ const res = await managementHttpRequest({
4181
+ method: "GET",
4182
+ baseUrl: this.baseUrl,
4183
+ path: pathWithQuery,
4184
+ oauthClient: this.oauthClient,
4185
+ numRetries: this.numRetries
4186
+ });
4187
+ return res.data;
4188
+ }
4189
+ /** Create a property value. */
4190
+ async createPropertyValue(request) {
4191
+ const res = await managementHttpRequest({
4192
+ method: "POST",
4193
+ baseUrl: this.baseUrl,
4194
+ path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/property-values`,
4195
+ body: request,
4196
+ oauthClient: this.oauthClient,
4197
+ numRetries: this.numRetries
4198
+ });
4199
+ return res.data;
4200
+ }
4201
+ };
4202
+
4203
+ // src/red-team/client.ts
4204
+ function buildListParams9(opts) {
4205
+ const params = {};
4206
+ if (opts?.skip !== void 0) params.skip = String(opts.skip);
4207
+ if (opts?.limit !== void 0) params.limit = String(opts.limit);
4208
+ if (opts?.sort_by !== void 0) params.sort_by = opts.sort_by;
4209
+ if (opts?.sort_direction !== void 0) params.sort_direction = opts.sort_direction;
4210
+ if (opts?.search !== void 0) params.search = opts.search;
4211
+ return params;
4212
+ }
4213
+ var RedTeamClient = class {
4214
+ /** Data plane scan operations. */
4215
+ scans;
4216
+ /** Data plane report operations. */
4217
+ reports;
4218
+ /** Data plane custom attack report operations. */
4219
+ customAttackReports;
4220
+ /** Management plane target operations. */
4221
+ targets;
4222
+ /** Management plane custom attack/prompt set operations. */
4223
+ customAttacks;
4224
+ dataEndpoint;
4225
+ mgmtEndpoint;
4226
+ oauthClient;
4227
+ numRetries;
4228
+ constructor(opts = {}) {
4229
+ const clientId = opts.clientId ?? process.env[RED_TEAM_CLIENT_ID] ?? process.env[MGMT_CLIENT_ID];
4230
+ const clientSecret = opts.clientSecret ?? process.env[RED_TEAM_CLIENT_SECRET] ?? process.env[MGMT_CLIENT_SECRET];
4231
+ const tsgId = opts.tsgId ?? process.env[RED_TEAM_TSG_ID] ?? process.env[MGMT_TSG_ID];
4232
+ const dataEndpoint = opts.dataEndpoint ?? process.env[RED_TEAM_DATA_ENDPOINT] ?? DEFAULT_RED_TEAM_DATA_ENDPOINT;
4233
+ const mgmtEndpoint = opts.mgmtEndpoint ?? process.env[RED_TEAM_MGMT_ENDPOINT] ?? DEFAULT_RED_TEAM_MGMT_ENDPOINT;
4234
+ const tokenEndpoint = opts.tokenEndpoint ?? process.env[RED_TEAM_TOKEN_ENDPOINT] ?? process.env[MGMT_TOKEN_ENDPOINT];
4235
+ const numRetries = Math.min(
4236
+ Math.max(opts.numRetries ?? MAX_NUMBER_OF_RETRIES, 0),
4237
+ MAX_NUMBER_OF_RETRIES
4238
+ );
4239
+ if (!clientId) {
4240
+ throw new AISecSDKException(
4241
+ "clientId is required (option or PANW_RED_TEAM_CLIENT_ID / PANW_MGMT_CLIENT_ID env var)",
4242
+ "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
4243
+ );
4244
+ }
4245
+ if (!clientSecret) {
4246
+ throw new AISecSDKException(
4247
+ "clientSecret is required (option or PANW_RED_TEAM_CLIENT_SECRET / PANW_MGMT_CLIENT_SECRET env var)",
4248
+ "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
4249
+ );
4250
+ }
4251
+ if (!tsgId) {
4252
+ throw new AISecSDKException(
4253
+ "tsgId is required (option or PANW_RED_TEAM_TSG_ID / PANW_MGMT_TSG_ID env var)",
4254
+ "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
4255
+ );
4256
+ }
4257
+ this.oauthClient = new OAuthClient({ clientId, clientSecret, tsgId, tokenEndpoint });
4258
+ this.dataEndpoint = dataEndpoint;
4259
+ this.mgmtEndpoint = mgmtEndpoint;
4260
+ this.numRetries = numRetries;
4261
+ this.scans = new RedTeamScansClient({
4262
+ baseUrl: dataEndpoint,
4263
+ oauthClient: this.oauthClient,
4264
+ numRetries
4265
+ });
4266
+ this.reports = new RedTeamReportsClient({
4267
+ baseUrl: dataEndpoint,
4268
+ oauthClient: this.oauthClient,
4269
+ numRetries
4270
+ });
4271
+ this.customAttackReports = new RedTeamCustomAttackReportsClient({
4272
+ baseUrl: dataEndpoint,
4273
+ oauthClient: this.oauthClient,
4274
+ numRetries
4275
+ });
4276
+ this.targets = new RedTeamTargetsClient({
4277
+ baseUrl: mgmtEndpoint,
4278
+ oauthClient: this.oauthClient,
4279
+ numRetries
4280
+ });
4281
+ this.customAttacks = new RedTeamCustomAttacksClient({
4282
+ baseUrl: mgmtEndpoint,
4283
+ oauthClient: this.oauthClient,
4284
+ numRetries
4285
+ });
4286
+ }
4287
+ // -----------------------------------------------------------------------
4288
+ // Data plane convenience methods
4289
+ // -----------------------------------------------------------------------
4290
+ /** Get scan statistics and risk profile (data plane dashboard). */
4291
+ async getScanStatistics(params) {
4292
+ const p = {};
4293
+ if (params?.date_range !== void 0) p.date_range = params.date_range;
4294
+ if (params?.target_id !== void 0) p.target_id = params.target_id;
4295
+ const res = await managementHttpRequest({
4296
+ method: "GET",
4297
+ baseUrl: this.dataEndpoint,
4298
+ path: `${RED_TEAM_DASHBOARD_PATH}/scan-statistics`,
4299
+ params: p,
4300
+ oauthClient: this.oauthClient,
4301
+ numRetries: this.numRetries
4302
+ });
4303
+ return res.data;
4304
+ }
4305
+ /** Get score trend for a target (data plane dashboard). */
4306
+ async getScoreTrend(targetId) {
4307
+ if (!isValidUuid(targetId)) {
4308
+ throw new AISecSDKException(
4309
+ `Invalid target id: ${targetId}`,
4310
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
4311
+ );
4312
+ }
4313
+ const res = await managementHttpRequest({
4314
+ method: "GET",
4315
+ baseUrl: this.dataEndpoint,
4316
+ path: `${RED_TEAM_DASHBOARD_PATH}/score-trend`,
4317
+ params: { target_id: targetId },
4318
+ oauthClient: this.oauthClient,
4319
+ numRetries: this.numRetries
4320
+ });
4321
+ return res.data;
4322
+ }
4323
+ /** Get quota summary. */
4324
+ async getQuota() {
4325
+ const res = await managementHttpRequest({
4326
+ method: "POST",
4327
+ baseUrl: this.dataEndpoint,
4328
+ path: RED_TEAM_QUOTA_PATH,
4329
+ oauthClient: this.oauthClient,
4330
+ numRetries: this.numRetries
4331
+ });
4332
+ return res.data;
4333
+ }
4334
+ /** List error logs for a scan job. */
4335
+ async getErrorLogs(jobId, opts) {
4336
+ if (!isValidUuid(jobId)) {
4337
+ throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
4338
+ }
4339
+ const res = await managementHttpRequest({
4340
+ method: "GET",
4341
+ baseUrl: this.dataEndpoint,
4342
+ path: `${RED_TEAM_ERROR_LOG_PATH}/${jobId}`,
4343
+ params: buildListParams9(opts),
4344
+ oauthClient: this.oauthClient,
4345
+ numRetries: this.numRetries
4346
+ });
4347
+ return res.data;
4348
+ }
4349
+ /** Update sentiment for a scan report. */
4350
+ async updateSentiment(request) {
4351
+ const res = await managementHttpRequest({
4352
+ method: "POST",
4353
+ baseUrl: this.dataEndpoint,
4354
+ path: RED_TEAM_SENTIMENT_PATH,
4355
+ body: request,
4356
+ oauthClient: this.oauthClient,
4357
+ numRetries: this.numRetries
4358
+ });
4359
+ return res.data;
4360
+ }
4361
+ /** Get sentiment for a scan report. */
4362
+ async getSentiment(jobId) {
4363
+ if (!isValidUuid(jobId)) {
4364
+ throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
4365
+ }
4366
+ const res = await managementHttpRequest({
4367
+ method: "GET",
4368
+ baseUrl: this.dataEndpoint,
4369
+ path: `${RED_TEAM_SENTIMENT_PATH}/${jobId}`,
4370
+ oauthClient: this.oauthClient,
4371
+ numRetries: this.numRetries
4372
+ });
4373
+ return res.data;
4374
+ }
4375
+ // -----------------------------------------------------------------------
4376
+ // Management plane convenience methods
4377
+ // -----------------------------------------------------------------------
4378
+ /** Get management dashboard overview. */
4379
+ async getDashboardOverview() {
4380
+ const res = await managementHttpRequest({
4381
+ method: "GET",
4382
+ baseUrl: this.mgmtEndpoint,
4383
+ path: RED_TEAM_MGMT_DASHBOARD_PATH,
4384
+ oauthClient: this.oauthClient,
4385
+ numRetries: this.numRetries
4386
+ });
4387
+ return res.data;
4388
+ }
4389
+ };
1161
4390
  export {
1162
4391
  AISecSDKException,
1163
4392
  AI_SEC_API_ENDPOINT,
1164
4393
  AI_SEC_API_KEY,
1165
4394
  AI_SEC_API_TOKEN,
1166
4395
  ASYNC_SCAN_PATH,
4396
+ Action,
1167
4397
  AgentMetaSchema,
1168
4398
  AiProfileSchema,
4399
+ ApiEndpointType,
1169
4400
  AsyncScanObjectSchema,
1170
4401
  AsyncScanResponseSchema,
4402
+ AttackDetailResponseSchema,
4403
+ AttackListItemSchema,
4404
+ AttackListResponseSchema,
4405
+ AttackMultiTurnDetailResponseSchema,
4406
+ AttackMultiTurnOutputSchema,
4407
+ AttackOutputSchema,
4408
+ AttackStatus,
4409
+ AttackType,
4410
+ AuthType,
1171
4411
  BEARER,
4412
+ BaseResponseSchema,
4413
+ BrandSubCategory,
4414
+ Category,
4415
+ CategoryModelSchema,
4416
+ CategoryReportSchema,
4417
+ ComplianceReportSchema,
4418
+ ComplianceSubCategory,
4419
+ ComplianceTechniqueSchema,
1172
4420
  Content,
4421
+ CountByNameSchema,
4422
+ CountedQuotaEnum,
1173
4423
  CreateCustomTopicRequestSchema,
1174
4424
  CreateSecurityProfileRequestSchema,
4425
+ CustomAttackOutputSchema,
4426
+ CustomAttackReportResponseSchema,
4427
+ CustomAttacksListResponseSchema,
4428
+ CustomJobMetadataSchema,
4429
+ CustomPromptCreateRequestSchema,
4430
+ CustomPromptListItemSchema,
4431
+ CustomPromptListSchema,
4432
+ CustomPromptResponseSchema,
4433
+ CustomPromptSetArchiveRequestSchema,
4434
+ CustomPromptSetCreateRequestSchema,
4435
+ CustomPromptSetListActiveSchema,
4436
+ CustomPromptSetListItemSchema,
4437
+ CustomPromptSetListSchema,
4438
+ CustomPromptSetReferenceSchema,
4439
+ CustomPromptSetResponseSchema,
4440
+ CustomPromptSetUpdateRequestSchema,
4441
+ CustomPromptSetVersionInfoSchema,
4442
+ CustomPromptUpdateRequestSchema,
1175
4443
  CustomTopicListResponseSchema,
1176
4444
  CustomTopicSchema,
1177
4445
  DEFAULT_ENDPOINT,
1178
4446
  DEFAULT_MGMT_ENDPOINT,
4447
+ DEFAULT_MODEL_SEC_DATA_ENDPOINT,
4448
+ DEFAULT_MODEL_SEC_MGMT_ENDPOINT,
4449
+ DEFAULT_RED_TEAM_DATA_ENDPOINT,
4450
+ DEFAULT_RED_TEAM_MGMT_ENDPOINT,
1179
4451
  DEFAULT_TOKEN_ENDPOINT,
1180
4452
  DSDetailResultSchema,
1181
4453
  DSResultMetadataSchema,
4454
+ DashboardOverviewResponseSchema,
4455
+ DateRangeFilter,
1182
4456
  DeleteProfileConflictSchema,
1183
4457
  DeleteProfileResponseSchema,
1184
4458
  DeleteTopicConflictSchema,
1185
4459
  DeleteTopicResponseSchema,
1186
4460
  DetectionServiceResultSchema,
1187
4461
  DlpReportSchema,
4462
+ DynamicJobMetadataSchema,
4463
+ DynamicJobReportSchema,
4464
+ DynamicJobReportStatsSchema,
4465
+ ErrorCodes,
4466
+ ErrorLogListResponseSchema,
4467
+ ErrorLogSchema,
1188
4468
  ErrorResponseSchema,
4469
+ ErrorSource,
1189
4470
  ErrorType,
4471
+ EvalOutcome,
4472
+ EvalSummarySchema,
4473
+ FileFormat,
4474
+ FileListSchema,
4475
+ FileResponseSchema,
4476
+ FileScanDataSchema,
4477
+ FileScanResult,
4478
+ FileType,
4479
+ GoalListResponseSchema,
4480
+ GoalSchema,
4481
+ GoalType,
4482
+ GoalTypeQueryParam,
4483
+ GuardrailAction,
1190
4484
  HEADER_API_KEY,
1191
4485
  HEADER_AUTH_TOKEN,
4486
+ HTTPValidationErrorSchema,
1192
4487
  HTTP_FORCE_RETRY_STATUS_CODES,
1193
4488
  IODetectedSchema,
4489
+ JobAbortResponseSchema,
4490
+ JobCreateRequestSchema,
4491
+ JobListResponseSchema,
4492
+ JobResponseSchema,
4493
+ JobStatus,
4494
+ JobStatusFilter,
4495
+ JobTimeRecordSchema,
4496
+ JobType,
4497
+ LabelKeyListSchema,
4498
+ LabelSchema,
4499
+ LabelValueListSchema,
4500
+ LabelsCreateRequestSchema,
4501
+ LabelsResponseSchema,
4502
+ ListModelSecurityGroupsResponseSchema,
4503
+ ListModelSecurityRuleInstancesResponseSchema,
4504
+ ListModelSecurityRulesResponseSchema,
1194
4505
  MAX_AI_PROFILE_NAME_LENGTH,
1195
4506
  MAX_API_KEY_LENGTH,
1196
4507
  MAX_CONNECTION_POOL_SIZE,
@@ -1216,28 +4527,167 @@ export {
1216
4527
  MGMT_TOPIC_FORCE_PATH,
1217
4528
  MGMT_TOPIC_PATH,
1218
4529
  MGMT_TSG_ID,
4530
+ MODEL_SEC_CLIENT_ID,
4531
+ MODEL_SEC_CLIENT_SECRET,
4532
+ MODEL_SEC_DATA_ENDPOINT,
4533
+ MODEL_SEC_EVALUATIONS_PATH,
4534
+ MODEL_SEC_MGMT_ENDPOINT,
4535
+ MODEL_SEC_PYPI_AUTH_PATH,
4536
+ MODEL_SEC_SCANS_PATH,
4537
+ MODEL_SEC_SECURITY_GROUPS_PATH,
4538
+ MODEL_SEC_SECURITY_RULES_PATH,
4539
+ MODEL_SEC_TOKEN_ENDPOINT,
4540
+ MODEL_SEC_TSG_ID,
4541
+ MODEL_SEC_VIOLATIONS_PATH,
1219
4542
  ManagementClient,
1220
4543
  MaskedDataSchema,
1221
4544
  MetadataSchema,
4545
+ ModelScanIssueSchema,
4546
+ ModelScanStatus,
4547
+ ModelSecurityClient,
4548
+ ModelSecurityGroupCreateRequestSchema,
4549
+ ModelSecurityGroupResponseSchema,
4550
+ ModelSecurityGroupState,
4551
+ ModelSecurityGroupUpdateRequestSchema,
4552
+ ModelSecurityGroupsClient,
4553
+ ModelSecurityPaginationSchema,
4554
+ ModelSecurityRuleInstanceResponseSchema,
4555
+ ModelSecurityRuleInstanceUpdateRequestSchema,
4556
+ ModelSecurityRuleResponseSchema,
4557
+ ModelSecurityRulesClient,
4558
+ ModelSecurityScansClient,
1222
4559
  PAYLOAD_HASH,
1223
4560
  PolicySchema,
4561
+ PolicyType,
4562
+ PrerequisiteModelSchema,
1224
4563
  ProfilesClient,
4564
+ ProfilingStatus,
4565
+ PromptDetailResponseSchema,
1225
4566
  PromptDetectedSchema,
1226
4567
  PromptDetectionDetailsSchema,
4568
+ PromptSetStatsSchema,
4569
+ PromptSetSummarySchema,
4570
+ PromptSetsReportResponseSchema,
4571
+ PropertyAssignmentSchema,
4572
+ PropertyDefinitionSchema,
4573
+ PropertyNameCreateRequestSchema,
4574
+ PropertyNamesListResponseSchema,
4575
+ PropertyStatisticSchema,
4576
+ PropertyValueCreateRequestSchema,
4577
+ PropertyValueStatisticSchema,
4578
+ PropertyValuesMultipleResponseSchema,
4579
+ PropertyValuesResponseSchema,
4580
+ PyPIAuthResponseSchema,
4581
+ QuotaDetailsSchema,
4582
+ QuotaSummarySchema,
4583
+ RED_TEAM_CATEGORIES_PATH,
4584
+ RED_TEAM_CLIENT_ID,
4585
+ RED_TEAM_CLIENT_SECRET,
4586
+ RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH,
4587
+ RED_TEAM_CUSTOM_ATTACK_PATH,
4588
+ RED_TEAM_DASHBOARD_PATH,
4589
+ RED_TEAM_DATA_ENDPOINT,
4590
+ RED_TEAM_ERROR_LOG_PATH,
4591
+ RED_TEAM_MGMT_DASHBOARD_PATH,
4592
+ RED_TEAM_MGMT_ENDPOINT,
4593
+ RED_TEAM_QUOTA_PATH,
4594
+ RED_TEAM_REPORT_DYNAMIC_PATH,
4595
+ RED_TEAM_REPORT_PATH,
4596
+ RED_TEAM_REPORT_STATIC_PATH,
4597
+ RED_TEAM_SCAN_PATH,
4598
+ RED_TEAM_SENTIMENT_PATH,
4599
+ RED_TEAM_TARGET_PATH,
4600
+ RED_TEAM_TOKEN_ENDPOINT,
4601
+ RED_TEAM_TSG_ID,
4602
+ RedTeamCategory,
4603
+ RedTeamClient,
4604
+ RedTeamCustomAttackReportsClient,
4605
+ RedTeamCustomAttacksClient,
4606
+ RedTeamErrorType,
4607
+ RedTeamPaginationSchema,
4608
+ RedTeamReportsClient,
4609
+ RedTeamScansClient,
4610
+ RedTeamTargetsClient,
4611
+ RemediationDetailSchema,
4612
+ RemediationResponseSchema,
1227
4613
  ResponseDetectedSchema,
1228
4614
  ResponseDetectionDetailsSchema,
4615
+ ResponseMode,
4616
+ RiskLevelSchema,
4617
+ RiskRating,
4618
+ RuleConfigurationSchema,
4619
+ RuleEditableFieldDropdownSchema,
4620
+ RuleEditableFieldSchema,
4621
+ RuleEditableFieldType,
4622
+ RuleEvaluationListSchema,
4623
+ RuleEvaluationResponseSchema,
4624
+ RuleEvaluationResult,
4625
+ RuleFieldValueKey,
4626
+ RuleRemediationSchema,
4627
+ RuleState,
4628
+ RuleType,
4629
+ RuntimeSecurityPolicySchema,
4630
+ RuntimeSecurityProfileResponseSchema,
1229
4631
  SCAN_REPORTS_PATH,
1230
4632
  SCAN_RESULTS_PATH,
1231
4633
  SDK_VERSION,
1232
4634
  SYNC_SCAN_PATH,
4635
+ SafetySubCategory,
4636
+ ScanBaseResponseSchema,
4637
+ ScanCreateRequestSchema,
4638
+ ScanDetailsSchema,
1233
4639
  ScanIdResultSchema,
4640
+ ScanListSchema,
4641
+ ScanOrigin,
1234
4642
  ScanRequestContentsInnerSchema,
1235
4643
  ScanRequestSchema,
1236
4644
  ScanResponseSchema,
4645
+ ScanStatisticsResponseSchema,
1237
4646
  ScanSummarySchema,
1238
4647
  Scanner,
4648
+ ScoreTrendResponseSchema,
4649
+ ScoreTrendSeriesSchema,
1239
4650
  SecurityProfileListResponseSchema,
1240
4651
  SecurityProfileSchema,
4652
+ SecuritySubCategory,
4653
+ SentimentRequestSchema,
4654
+ SentimentResponseSchema,
4655
+ SeverityFilter,
4656
+ SeverityReportSchema,
4657
+ SeverityStatsSchema,
4658
+ SortByDateField,
4659
+ SortByFileField,
4660
+ SortDirection,
4661
+ SourceType,
4662
+ StaticJobMetadataSchema,
4663
+ StaticJobRemediationRecommendationSchema,
4664
+ StaticJobRemediationSchema,
4665
+ StaticJobReportSchema,
4666
+ StaticJobReportStatsSchema,
4667
+ StatusQueryParam,
4668
+ StreamDetailResponseSchema,
4669
+ StreamIterationDataSchema,
4670
+ StreamListResponseSchema,
4671
+ StreamType,
4672
+ SubCategoryModelSchema,
4673
+ SubCategoryStatsSchema,
4674
+ TargetAdditionalContextSchema,
4675
+ TargetBackgroundSchema,
4676
+ TargetConnectionType,
4677
+ TargetContextUpdateSchema,
4678
+ TargetCreateRequestSchema,
4679
+ TargetJobRequestSchema,
4680
+ TargetListItemSchema,
4681
+ TargetListSchema,
4682
+ TargetMetadataSchema,
4683
+ TargetProbeRequestSchema,
4684
+ TargetProfileResponseSchema,
4685
+ TargetReferenceSchema,
4686
+ TargetResponseSchema,
4687
+ TargetStatus,
4688
+ TargetType,
4689
+ TargetUpdateRequestSchema,
4690
+ ThreatCategory,
1241
4691
  ThreatScanReportSchema,
1242
4692
  ToolDetectedSchema,
1243
4693
  ToolEventMetadataSchema,
@@ -1245,6 +4695,10 @@ export {
1245
4695
  TopicsClient,
1246
4696
  USER_AGENT,
1247
4697
  UrlfEntrySchema,
4698
+ ValidationErrorSchema,
4699
+ Verdict,
4700
+ ViolationListSchema,
4701
+ ViolationResponseSchema,
1248
4702
  globalConfiguration,
1249
4703
  init
1250
4704
  };