@cdot65/prisma-airs-sdk 0.5.1 → 0.6.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.5.1";
26
+ var SDK_VERSION = "0.6.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";
@@ -1481,33 +1481,83 @@ var ValidationErrorSchema = z18.object({
1481
1481
  });
1482
1482
  var HTTPValidationErrorSchema = z18.object({ detail: z18.array(ValidationErrorSchema).optional() }).passthrough();
1483
1483
  var TargetBackgroundSchema = z18.object({
1484
- industry: z18.unknown().optional(),
1485
- use_case: z18.unknown().optional(),
1486
- competitors: z18.unknown().optional()
1484
+ industry: z18.string().nullable().optional(),
1485
+ use_case: z18.string().nullable().optional(),
1486
+ competitors: z18.array(z18.string()).nullable().optional()
1487
1487
  }).passthrough();
1488
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()
1489
+ base_model: z18.string().nullable().optional(),
1490
+ core_architecture: z18.string().nullable().optional(),
1491
+ system_prompt: z18.string().nullable().optional(),
1492
+ languages_supported: z18.array(z18.string()).nullable().optional(),
1493
+ banned_keywords: z18.array(z18.string()).nullable().optional(),
1494
+ tools_accessible: z18.array(z18.string()).nullable().optional()
1495
1495
  }).passthrough();
1496
1496
  var TargetMetadataSchema = z18.object({
1497
1497
  multi_turn: z18.boolean().optional(),
1498
- multi_turn_error_message: z18.unknown().optional(),
1499
- rate_limit: z18.unknown().optional(),
1498
+ multi_turn_error_message: z18.string().nullable().optional(),
1499
+ rate_limit: z18.number().int().nullable().optional(),
1500
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(),
1501
+ rate_limit_error_code: z18.number().int().nullable().optional(),
1502
+ rate_limit_error_json: z18.record(z18.unknown()).nullable().optional(),
1503
+ rate_limit_error_message: z18.string().nullable().optional(),
1504
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(),
1505
+ content_filter_error_code: z18.number().int().nullable().optional(),
1506
+ content_filter_error_json: z18.record(z18.unknown()).nullable().optional(),
1507
+ content_filter_error_message: z18.string().nullable().optional(),
1508
1508
  probe_message: z18.string().optional(),
1509
1509
  request_timeout: z18.number().optional()
1510
1510
  }).passthrough();
1511
+ var MultiTurnStatefulConfigSchema = z18.object({
1512
+ type: z18.string().default("stateful"),
1513
+ response_id_field: z18.string(),
1514
+ request_id_field: z18.string()
1515
+ }).passthrough();
1516
+ var MultiTurnStatelessConfigSchema = z18.object({
1517
+ type: z18.string().default("stateless"),
1518
+ assistant_role: z18.string().nullable().optional()
1519
+ }).passthrough();
1520
+ var OpenAIConnectionParamsSchema = z18.object({
1521
+ api_key: z18.string(),
1522
+ model_name: z18.string()
1523
+ }).passthrough();
1524
+ var HuggingfaceConnectionParamsSchema = z18.object({
1525
+ api_key: z18.string(),
1526
+ model_name: z18.string()
1527
+ }).passthrough();
1528
+ var DatabricksConnectionParamsSchema = z18.object({
1529
+ auth_type: z18.string(),
1530
+ workspace_url: z18.string(),
1531
+ model_name: z18.string(),
1532
+ access_token: z18.string().nullable().optional(),
1533
+ client_id: z18.string().nullable().optional(),
1534
+ secret: z18.string().nullable().optional()
1535
+ }).passthrough();
1536
+ var BedrockAccessConnectionParamsSchema = z18.object({
1537
+ access_id: z18.string(),
1538
+ access_secret: z18.string(),
1539
+ region: z18.string(),
1540
+ model_id: z18.string(),
1541
+ session_token: z18.string().nullable().optional()
1542
+ }).passthrough();
1543
+ var RestConnectionParamsSchema = z18.object({
1544
+ api_endpoint: z18.string().nullable().optional(),
1545
+ request_headers: z18.record(z18.unknown()).nullable().optional(),
1546
+ request_json: z18.record(z18.unknown()).nullable().optional(),
1547
+ response_json: z18.record(z18.unknown()).nullable().optional(),
1548
+ response_key: z18.string().nullable().optional(),
1549
+ target_connection_config: z18.unknown().nullable().optional(),
1550
+ curl: z18.string().nullable().optional(),
1551
+ multi_turn_config: z18.unknown().nullable().optional()
1552
+ }).passthrough();
1553
+ var StreamingConnectionParamsSchema = RestConnectionParamsSchema.extend({
1554
+ response_stop_key: z18.string(),
1555
+ response_stop_value: z18.string()
1556
+ }).passthrough();
1557
+ var ConnectionParamsSchema = z18.union([
1558
+ StreamingConnectionParamsSchema,
1559
+ RestConnectionParamsSchema
1560
+ ]);
1511
1561
  var TargetJobRequestSchema = z18.object({
1512
1562
  uuid: z18.string(),
1513
1563
  version: z18.number().int().nullable().optional()
@@ -2233,9 +2283,9 @@ var CustomPromptSetVersionInfoSchema = z18.object({
2233
2283
  uuid: z18.string(),
2234
2284
  status: z18.string(),
2235
2285
  is_latest: z18.boolean(),
2236
- version: z18.unknown().optional(),
2237
- stats: z18.unknown().optional(),
2238
- snapshot_created_at: z18.unknown().optional()
2286
+ version: z18.string().nullable().optional(),
2287
+ stats: PromptSetStatsSchema.nullable().optional(),
2288
+ snapshot_created_at: z18.string().nullable().optional()
2239
2289
  }).passthrough();
2240
2290
  var CustomPromptCreateRequestSchema = z18.object({
2241
2291
  prompt: z18.string(),
@@ -3839,12 +3889,15 @@ var RedTeamTargetsClient = class {
3839
3889
  this.numRetries = opts.numRetries;
3840
3890
  }
3841
3891
  /** Create a new target. */
3842
- async create(request) {
3892
+ async create(request, opts) {
3893
+ const params = {};
3894
+ if (opts?.validate !== void 0) params.validate = String(opts.validate);
3843
3895
  const res = await managementHttpRequest({
3844
3896
  method: "POST",
3845
3897
  baseUrl: this.baseUrl,
3846
3898
  path: RED_TEAM_TARGET_PATH,
3847
3899
  body: request,
3900
+ params: Object.keys(params).length > 0 ? params : void 0,
3848
3901
  oauthClient: this.oauthClient,
3849
3902
  numRetries: this.numRetries
3850
3903
  });
@@ -3884,18 +3937,21 @@ var RedTeamTargetsClient = class {
3884
3937
  return res.data;
3885
3938
  }
3886
3939
  /** Update a target. */
3887
- async update(uuid, request) {
3940
+ async update(uuid, request, opts) {
3888
3941
  if (!isValidUuid(uuid)) {
3889
3942
  throw new AISecSDKException(
3890
3943
  `Invalid target uuid: ${uuid}`,
3891
3944
  "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3892
3945
  );
3893
3946
  }
3947
+ const params = {};
3948
+ if (opts?.validate !== void 0) params.validate = String(opts.validate);
3894
3949
  const res = await managementHttpRequest({
3895
3950
  method: "PUT",
3896
3951
  baseUrl: this.baseUrl,
3897
3952
  path: `${RED_TEAM_TARGET_PATH}/${uuid}`,
3898
3953
  body: request,
3954
+ params: Object.keys(params).length > 0 ? params : void 0,
3899
3955
  oauthClient: this.oauthClient,
3900
3956
  numRetries: this.numRetries
3901
3957
  });
@@ -4106,6 +4162,33 @@ var RedTeamCustomAttacksClient = class {
4106
4162
  });
4107
4163
  return res.data;
4108
4164
  }
4165
+ /** Upload a CSV file of custom prompts for a prompt set. */
4166
+ async uploadPromptsCsv(promptSetUuid, file) {
4167
+ validateUuid(promptSetUuid, "prompt set uuid");
4168
+ const token = await this.oauthClient.getToken();
4169
+ const url = new URL(
4170
+ `${this.baseUrl.replace(/\/+$/, "")}${RED_TEAM_CUSTOM_ATTACK_PATH}/upload-custom-prompts-csv`
4171
+ );
4172
+ url.searchParams.set("prompt_set_uuid", promptSetUuid);
4173
+ const formData = new FormData();
4174
+ formData.append("file", file);
4175
+ const response = await fetch(url.toString(), {
4176
+ method: "POST",
4177
+ headers: {
4178
+ Authorization: `Bearer ${token}`,
4179
+ "User-Agent": USER_AGENT
4180
+ },
4181
+ body: formData
4182
+ });
4183
+ const text = await response.text();
4184
+ if (!response.ok) {
4185
+ throw new AISecSDKException(
4186
+ `Upload failed (${response.status}): ${text}`,
4187
+ "AISEC_SERVER_SIDE_ERROR" /* SERVER_SIDE_ERROR */
4188
+ );
4189
+ }
4190
+ return text ? JSON.parse(text) : { message: "ok", status: 201 };
4191
+ }
4109
4192
  // -----------------------------------------------------------------------
4110
4193
  // Prompt operations
4111
4194
  // -----------------------------------------------------------------------
@@ -4454,6 +4537,7 @@ export {
4454
4537
  AuthType,
4455
4538
  BEARER,
4456
4539
  BaseResponseSchema,
4540
+ BedrockAccessConnectionParamsSchema,
4457
4541
  BrandSubCategory,
4458
4542
  Category,
4459
4543
  CategoryModelSchema,
@@ -4461,6 +4545,7 @@ export {
4461
4545
  ComplianceReportSchema,
4462
4546
  ComplianceSubCategory,
4463
4547
  ComplianceTechniqueSchema,
4548
+ ConnectionParamsSchema,
4464
4549
  Content,
4465
4550
  CountByNameSchema,
4466
4551
  CountedQuotaEnum,
@@ -4496,6 +4581,7 @@ export {
4496
4581
  DSDetailResultSchema,
4497
4582
  DSResultMetadataSchema,
4498
4583
  DashboardOverviewResponseSchema,
4584
+ DatabricksConnectionParamsSchema,
4499
4585
  DateRangeFilter,
4500
4586
  DeleteProfileConflictSchema,
4501
4587
  DeleteProfileResponseSchema,
@@ -4529,6 +4615,7 @@ export {
4529
4615
  HEADER_AUTH_TOKEN,
4530
4616
  HTTPValidationErrorSchema,
4531
4617
  HTTP_FORCE_RETRY_STATUS_CODES,
4618
+ HuggingfaceConnectionParamsSchema,
4532
4619
  IODetectedSchema,
4533
4620
  JobAbortResponseSchema,
4534
4621
  JobCreateRequestSchema,
@@ -4600,7 +4687,10 @@ export {
4600
4687
  ModelSecurityRuleResponseSchema,
4601
4688
  ModelSecurityRulesClient,
4602
4689
  ModelSecurityScansClient,
4690
+ MultiTurnStatefulConfigSchema,
4691
+ MultiTurnStatelessConfigSchema,
4603
4692
  OAuthClient,
4693
+ OpenAIConnectionParamsSchema,
4604
4694
  PAYLOAD_HASH,
4605
4695
  PolicySchema,
4606
4696
  PolicyType,
@@ -4658,6 +4748,7 @@ export {
4658
4748
  ResponseDetectedSchema,
4659
4749
  ResponseDetectionDetailsSchema,
4660
4750
  ResponseMode,
4751
+ RestConnectionParamsSchema,
4661
4752
  RiskLevelSchema,
4662
4753
  RiskRating,
4663
4754
  RuleConfigurationSchema,
@@ -4714,6 +4805,7 @@ export {
4714
4805
  StreamIterationDataSchema,
4715
4806
  StreamListResponseSchema,
4716
4807
  StreamType,
4808
+ StreamingConnectionParamsSchema,
4717
4809
  SubCategoryModelSchema,
4718
4810
  SubCategoryStatsSchema,
4719
4811
  TargetAdditionalContextSchema,