@cdot65/prisma-airs-cli 3.1.0 → 3.3.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.d.ts CHANGED
@@ -35,16 +35,60 @@ interface RuntimeScanResult {
35
35
  category: string;
36
36
  triggered: boolean;
37
37
  detections: Record<string, boolean>;
38
+ error?: string;
39
+ }
40
+ /** Terminal action emitted by the reliable bulk-scan path. */
41
+ type BulkScanAction = RuntimeScanResult['action'] | 'failed';
42
+ /** A prompt paired with its stable position and AIRS request ID. */
43
+ interface IndexedPrompt {
44
+ index: number;
45
+ prompt: string;
46
+ }
47
+ /** Correlation data for one prompt accepted in an async AIRS submission. */
48
+ interface BatchEntry extends IndexedPrompt {
49
+ scanId: string;
50
+ reqId: number;
51
+ }
52
+ /** Receipt for exactly one SDK async submission (at most twenty prompts). */
53
+ interface SubmittedBatch {
54
+ scanId: string;
55
+ reportId?: string;
56
+ entries: BatchEntry[];
38
57
  }
39
- /** Contract for runtime scanning operations (sync + async). */
58
+ /** A normalized async result with its stable input position and AIRS request ID. */
59
+ interface BulkScanResult extends Omit<RuntimeScanResult, 'action'> {
60
+ index: number;
61
+ reqId: number;
62
+ action: BulkScanAction;
63
+ }
64
+ /** Backwards-compatible contract for the original runtime scanning operations. */
40
65
  interface RuntimeService {
41
66
  /** Scan a single prompt (and optional response) synchronously. */
42
67
  scanPrompt(profileName: string, prompt: string, response?: string): Promise<RuntimeScanResult>;
43
- /** Submit prompts for async bulk scanning, returns scan IDs. */
44
- submitBulkScan(profileName: string, prompts: string[]): Promise<string[]>;
45
- /** Poll async scan results until all complete. */
68
+ /** @deprecated Use ReliableRuntimeService.submitBatch to preserve per-prompt correlation. */
69
+ submitBulkScan(profileName: string, prompts: string[], sessionId?: string): Promise<string[]>;
70
+ /** @deprecated Use ReliableRuntimeService.pollBatch to preserve per-prompt correlation. */
46
71
  pollResults(scanIds: string[], intervalMs?: number): Promise<RuntimeScanResult[]>;
47
72
  }
73
+ /** Runtime scanning contract with item-correlated, resumable bulk operations. */
74
+ interface ReliableRuntimeService extends RuntimeService {
75
+ /** Submit one SDK-sized group of indexed prompts for async scanning. */
76
+ submitBatch(profileName: string, prompts: IndexedPrompt[], sessionId?: string, retryOpts?: {
77
+ maxRetries?: number;
78
+ baseDelayMs?: number;
79
+ maxNoProgressPolls?: number;
80
+ onRetry?: (attempt: number, delayMs: number) => void;
81
+ onProgress?: (results: BulkScanResult[]) => void | Promise<void>;
82
+ }): Promise<SubmittedBatch>;
83
+ /** Poll one async submission and return one result per prompt, ordered by input index. */
84
+ pollBatch(batch: SubmittedBatch, intervalMs?: number, retryOpts?: {
85
+ maxRetries?: number;
86
+ baseDelayMs?: number;
87
+ maxNoProgressPolls?: number;
88
+ onRetry?: (attempt: number, delayMs: number) => void;
89
+ onProgress?: (results: BulkScanResult[]) => void | Promise<void>;
90
+ }): Promise<BulkScanResult[]>;
91
+ }
48
92
  /** Contract for AIRS prompt scanning operations. */
49
93
  interface ScanService {
50
94
  /** Scan a single prompt against a security profile. */
@@ -528,6 +572,17 @@ interface RedTeamService {
528
572
  logs: RedTeamErrorLog[];
529
573
  totalItems?: number;
530
574
  }>;
575
+ listAdapters(opts?: RedTeamAdapterListOptions): Promise<{
576
+ adapters: RedTeamAdapterListItem[];
577
+ totalItems?: number;
578
+ }>;
579
+ getAdapter(uuid: string): Promise<RedTeamAdapterDetail>;
580
+ createAdapter(request: RedTeamAdapterCreateRequest, validate?: boolean): Promise<RedTeamAdapterDetail>;
581
+ /** Read-modify-write: merges overrides onto the current record (upstream PUT is full-replacement). */
582
+ updateAdapter(uuid: string, overrides: RedTeamAdapterUpdateOverrides, validate?: boolean): Promise<RedTeamAdapterDetail>;
583
+ deleteAdapter(uuid: string): Promise<void>;
584
+ /** Run a script end-to-end through the broker channel; returns an execution outcome. */
585
+ validateAdapter(request: RedTeamAdapterValidateRequest): Promise<RedTeamAdapterValidationResult>;
531
586
  }
532
587
  /** Normalized security group. */
533
588
  interface ModelSecurityGroup {
@@ -1033,6 +1088,83 @@ interface ManagementService {
1033
1088
  }): Promise<DeploymentProfileInfo[]>;
1034
1089
  queryScanLogs(opts: ScanLogQueryOptions): Promise<ScanLogQueryResult>;
1035
1090
  }
1091
+ /** An adapter configuration variable. Secrets are masked; key off `isRedacted`, not the value. */
1092
+ interface RedTeamAdapterVar {
1093
+ key: string;
1094
+ value?: string | null;
1095
+ type: 'VAR' | 'SECRET';
1096
+ isRedacted?: boolean;
1097
+ }
1098
+ /** Adapter list row — no script, description, or variables; `get` for the full record. */
1099
+ interface RedTeamAdapterListItem {
1100
+ uuid: string;
1101
+ name: string;
1102
+ status: string;
1103
+ createdAt?: string;
1104
+ updatedAt?: string;
1105
+ createdByUserId?: string | null;
1106
+ targetCount?: number | null;
1107
+ }
1108
+ /** Full adapter record. */
1109
+ interface RedTeamAdapterDetail {
1110
+ uuid: string;
1111
+ tsgId?: string;
1112
+ name: string;
1113
+ scriptB64: string;
1114
+ status: string;
1115
+ description?: string | null;
1116
+ networkBrokerChannelUuid?: string | null;
1117
+ variables: RedTeamAdapterVar[];
1118
+ targetCount?: number | null;
1119
+ createdAt?: string | null;
1120
+ updatedAt?: string | null;
1121
+ createdByUserId?: string | null;
1122
+ updatedByUserId?: string | null;
1123
+ }
1124
+ interface RedTeamAdapterListOptions {
1125
+ limit?: number;
1126
+ offset?: number;
1127
+ search?: string;
1128
+ }
1129
+ interface RedTeamAdapterCreateRequest {
1130
+ name: string;
1131
+ scriptB64: string;
1132
+ /** Sample prompt used to exercise the adapter during validation. Not stored. */
1133
+ prompt: string;
1134
+ description?: string;
1135
+ /** Optional while DRAFT; required to activate (validate: true). */
1136
+ networkBrokerChannelUuid?: string;
1137
+ variables?: RedTeamAdapterVar[];
1138
+ }
1139
+ /**
1140
+ * CLI-side overrides for adapter update. The upstream PUT is a full
1141
+ * replacement, so the service merges these onto the current record —
1142
+ * `prompt` is the only always-required field because it is never stored.
1143
+ */
1144
+ interface RedTeamAdapterUpdateOverrides {
1145
+ prompt: string;
1146
+ name?: string;
1147
+ scriptB64?: string;
1148
+ description?: string;
1149
+ networkBrokerChannelUuid?: string;
1150
+ /** Replaces the WHOLE variable set when given; omitted keys are deleted upstream. */
1151
+ variables?: RedTeamAdapterVar[];
1152
+ }
1153
+ interface RedTeamAdapterValidateRequest {
1154
+ scriptB64: string;
1155
+ networkBrokerChannelUuid: string;
1156
+ prompt: string;
1157
+ variables?: RedTeamAdapterVar[];
1158
+ /** Resolve redacted/null variable values from this stored adapter before the run. */
1159
+ adapterUuid?: string;
1160
+ }
1161
+ /** Execution outcome of a validation run — not an adapter record. */
1162
+ interface RedTeamAdapterValidationResult {
1163
+ validated: boolean;
1164
+ stdout?: string | null;
1165
+ stderr?: string | null;
1166
+ traceback?: string | null;
1167
+ }
1036
1168
 
1037
1169
  /**
1038
1170
  * Wraps the SDK's ManagementClient to implement our ManagementService interface.
@@ -1257,10 +1389,6 @@ declare class SdkPromptSetService implements PromptSetService {
1257
1389
  createPropertyValue(name: string, value: string): Promise<MutationResponse>;
1258
1390
  }
1259
1391
 
1260
- /**
1261
- * Wraps the SDK's RedTeamClient to implement RedTeamService.
1262
- * Provides scan creation, status polling, report retrieval, and target/category listing.
1263
- */
1264
1392
  declare class SdkRedTeamService implements RedTeamService {
1265
1393
  private client;
1266
1394
  constructor(opts?: RedTeamClientOptions);
@@ -1336,32 +1464,48 @@ declare class SdkRedTeamService implements RedTeamService {
1336
1464
  logs: RedTeamErrorLog[];
1337
1465
  totalItems?: number;
1338
1466
  }>;
1467
+ listAdapters(opts?: RedTeamAdapterListOptions): Promise<{
1468
+ adapters: RedTeamAdapterListItem[];
1469
+ totalItems?: number;
1470
+ }>;
1471
+ getAdapter(uuid: string): Promise<RedTeamAdapterDetail>;
1472
+ createAdapter(request: RedTeamAdapterCreateRequest, validate?: boolean): Promise<RedTeamAdapterDetail>;
1473
+ updateAdapter(uuid: string, overrides: RedTeamAdapterUpdateOverrides, validate?: boolean): Promise<RedTeamAdapterDetail>;
1474
+ deleteAdapter(uuid: string): Promise<void>;
1475
+ validateAdapter(request: RedTeamAdapterValidateRequest): Promise<RedTeamAdapterValidationResult>;
1339
1476
  }
1340
1477
 
1478
+ /** Maximum async request objects accepted by the installed AIRS SDK. */
1479
+ declare const SDK_ASYNC_BATCH_SIZE = 20;
1341
1480
  interface PollRetryOptions {
1342
1481
  /** Max retries per rate-limit error before giving up. Default: 5. */
1343
1482
  maxRetries?: number;
1344
1483
  /** Base delay in ms for exponential backoff. Default: 10000. */
1345
1484
  baseDelayMs?: number;
1485
+ /** Stop after this many consecutive successful polls resolve no new prompts. Default: 120. */
1486
+ maxNoProgressPolls?: number;
1346
1487
  /** Called on each retry with (attempt, delayMs). */
1347
1488
  onRetry?: (attempt: number, delayMs: number) => void;
1489
+ /** Called whenever newly terminal prompt results are resolved. */
1490
+ onProgress?: (results: BulkScanResult[]) => void | Promise<void>;
1348
1491
  }
1349
- declare class SdkRuntimeService implements RuntimeService {
1492
+ declare class SdkRuntimeService implements ReliableRuntimeService {
1350
1493
  private scanner;
1351
1494
  constructor(opts: InitOptions);
1352
1495
  scanPrompt(profileName: string, prompt: string, response?: string): Promise<RuntimeScanResult>;
1496
+ submitBatch(profileName: string, prompts: IndexedPrompt[], sessionId?: string, retryOpts?: PollRetryOptions): Promise<SubmittedBatch>;
1497
+ pollBatch(batch: SubmittedBatch, intervalMs?: number, retryOpts?: PollRetryOptions): Promise<BulkScanResult[]>;
1498
+ /** @deprecated Use submitBatch to preserve per-prompt request correlation. */
1353
1499
  submitBulkScan(profileName: string, prompts: string[], sessionId?: string): Promise<string[]>;
1354
1500
  /**
1355
- * Poll async scan results until all complete or fail.
1356
- *
1357
- * Note: The async query API (`queryByScanIds`) does not return `prompt`,
1358
- * `response`, `triggered`, or `detections` fields. These are set to
1359
- * defaults (`''`, `undefined`, `false`, `{}`) in the returned results.
1360
- * Use `scanPrompt()` (sync API) when these fields are needed.
1501
+ * Compatibility poller for callers that retained only batch scan IDs.
1502
+ * Nested detection data is preserved, but prompt text and per-request fan-out
1503
+ * cannot be reconstructed from scan IDs alone.
1504
+ * @deprecated Use pollBatch to preserve `(scan_id, req_id)` correlation and prompt text.
1361
1505
  */
1362
1506
  pollResults(scanIds: string[], intervalMs?: number, retryOpts?: PollRetryOptions): Promise<RuntimeScanResult[]>;
1363
1507
  private processQueryResults;
1364
- static formatResultsCsv(results: RuntimeScanResult[]): string;
1508
+ static formatResultsCsv(results: Array<RuntimeScanResult | BulkScanResult>): string;
1365
1509
  }
1366
1510
 
1367
1511
  /** Scans prompts against AIRS security profiles via the Prisma AIRS SDK. */
@@ -1431,6 +1575,9 @@ declare const ConfigSchema: z.ZodObject<{
1431
1575
  modelSecDataEndpoint: z.ZodOptional<z.ZodString>;
1432
1576
  modelSecMgmtEndpoint: z.ZodOptional<z.ZodString>;
1433
1577
  modelSecTokenEndpoint: z.ZodOptional<z.ZodString>;
1578
+ aiGwDataEndpoint: z.ZodOptional<z.ZodString>;
1579
+ aiGwAdminEndpoint: z.ZodOptional<z.ZodString>;
1580
+ aiGwTokenEndpoint: z.ZodOptional<z.ZodString>;
1434
1581
  scanConcurrency: z.ZodDefault<z.ZodNumber>;
1435
1582
  dataDir: z.ZodDefault<z.ZodString>;
1436
1583
  }, "strip", z.ZodTypeAny, {
@@ -1453,6 +1600,9 @@ declare const ConfigSchema: z.ZodObject<{
1453
1600
  modelSecDataEndpoint?: string | undefined;
1454
1601
  modelSecMgmtEndpoint?: string | undefined;
1455
1602
  modelSecTokenEndpoint?: string | undefined;
1603
+ aiGwDataEndpoint?: string | undefined;
1604
+ aiGwAdminEndpoint?: string | undefined;
1605
+ aiGwTokenEndpoint?: string | undefined;
1456
1606
  }, {
1457
1607
  airsApiKey?: string | undefined;
1458
1608
  airsApiToken?: string | undefined;
@@ -1471,6 +1621,9 @@ declare const ConfigSchema: z.ZodObject<{
1471
1621
  modelSecDataEndpoint?: string | undefined;
1472
1622
  modelSecMgmtEndpoint?: string | undefined;
1473
1623
  modelSecTokenEndpoint?: string | undefined;
1624
+ aiGwDataEndpoint?: string | undefined;
1625
+ aiGwAdminEndpoint?: string | undefined;
1626
+ aiGwTokenEndpoint?: string | undefined;
1474
1627
  scanConcurrency?: number | undefined;
1475
1628
  dataDir?: string | undefined;
1476
1629
  }>;
@@ -1595,4 +1748,4 @@ declare function computeMetrics(results: TestResult[]): EfficacyMetrics;
1595
1748
  /** Compute per-category error breakdown from test results. Sorted by error rate descending. */
1596
1749
  declare function computeCategoryBreakdown(results: TestResult[]): CategoryBreakdown[];
1597
1750
 
1598
- export { AirsScanService, type AnalysisReport, type BackupEnvelope, type BackupFormat, type BackupResult, type CategoryBreakdown, type CustomTopic, type EfficacyMetrics, type IterationResult, type ModelSecurityEvaluation, type ModelSecurityFile, type ModelSecurityFileListOptions, type ModelSecurityGroup, type ModelSecurityGroupCreateRequest, type ModelSecurityGroupListOptions, type ModelSecurityGroupUpdateRequest, type ModelSecurityLabel, type ModelSecurityPyPIAuth, type ModelSecurityRule, type ModelSecurityRuleEditableField, type ModelSecurityRuleInstance, type ModelSecurityRuleInstanceListOptions, type ModelSecurityRuleInstanceUpdateRequest, type ModelSecurityRuleListOptions, type ModelSecurityScan, type ModelSecurityScanListOptions, type ModelSecurityService, type ModelSecurityViolation, type MutationResponse, type ProfileTopic, type PromptDetail, type PromptSetDetail, type PromptSetService, type PromptSetVersionInfo, type PropertyValueList, type RedTeamAttack, type RedTeamCategory, type RedTeamCustomAttack, type RedTeamCustomReport, type RedTeamJob, type RedTeamService, type RedTeamStaticReport, type RedTeamTarget, type RedTeamTargetCreateRequest, type RedTeamTargetDetail, type RedTeamTargetUpdateRequest, type ResourceType, type RestoreResult, type RunState, type RuntimeScanResult, type RuntimeService, SdkManagementService, SdkModelSecurityService, SdkPromptSetService, SdkRedTeamService, SdkRuntimeService, type TargetOperationOptions, type TestCase, type TestResult, type UserInput, type ValidationError, computeCategoryBreakdown, computeMetrics, loadConfig, readBackupDir, readBackupFile, resolveOutputDir, sanitizeFilename, validateDescription, validateExamples, validateName, validateTopic, writeBackupFile };
1751
+ export { AirsScanService, type AnalysisReport, type BackupEnvelope, type BackupFormat, type BackupResult, type BatchEntry, type BulkScanAction, type BulkScanResult, type CategoryBreakdown, type CustomTopic, type EfficacyMetrics, type IndexedPrompt, type IterationResult, type ModelSecurityEvaluation, type ModelSecurityFile, type ModelSecurityFileListOptions, type ModelSecurityGroup, type ModelSecurityGroupCreateRequest, type ModelSecurityGroupListOptions, type ModelSecurityGroupUpdateRequest, type ModelSecurityLabel, type ModelSecurityPyPIAuth, type ModelSecurityRule, type ModelSecurityRuleEditableField, type ModelSecurityRuleInstance, type ModelSecurityRuleInstanceListOptions, type ModelSecurityRuleInstanceUpdateRequest, type ModelSecurityRuleListOptions, type ModelSecurityScan, type ModelSecurityScanListOptions, type ModelSecurityService, type ModelSecurityViolation, type MutationResponse, type PollRetryOptions, type ProfileTopic, type PromptDetail, type PromptSetDetail, type PromptSetService, type PromptSetVersionInfo, type PropertyValueList, type RedTeamAttack, type RedTeamCategory, type RedTeamCustomAttack, type RedTeamCustomReport, type RedTeamJob, type RedTeamService, type RedTeamStaticReport, type RedTeamTarget, type RedTeamTargetCreateRequest, type RedTeamTargetDetail, type RedTeamTargetUpdateRequest, type ReliableRuntimeService, type ResourceType, type RestoreResult, type RunState, type RuntimeScanResult, type RuntimeService, SDK_ASYNC_BATCH_SIZE, SdkManagementService, SdkModelSecurityService, SdkPromptSetService, SdkRedTeamService, SdkRuntimeService, type SubmittedBatch, type TargetOperationOptions, type TestCase, type TestResult, type UserInput, type ValidationError, computeCategoryBreakdown, computeMetrics, loadConfig, readBackupDir, readBackupFile, resolveOutputDir, sanitizeFilename, validateDescription, validateExamples, validateName, validateTopic, writeBackupFile };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  AirsScanService,
3
+ SDK_ASYNC_BATCH_SIZE,
3
4
  SdkManagementService,
4
5
  SdkModelSecurityService,
5
6
  SdkPromptSetService,
@@ -17,9 +18,10 @@ import {
17
18
  validateName,
18
19
  validateTopic,
19
20
  writeBackupFile
20
- } from "./chunk-DSNQSBLE.js";
21
+ } from "./chunk-2VIUZRPB.js";
21
22
  export {
22
23
  AirsScanService,
24
+ SDK_ASYNC_BATCH_SIZE,
23
25
  SdkManagementService,
24
26
  SdkModelSecurityService,
25
27
  SdkPromptSetService,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cdot65/prisma-airs-cli",
3
3
  "packageManager": "pnpm@10.6.5",
4
- "version": "3.1.0",
4
+ "version": "3.3.0",
5
5
  "description": "CLI and library for Palo Alto Prisma AIRS — guardrail refinement, AI red teaming, model security scanning, profile audits",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "license": "MIT",
46
46
  "dependencies": {
47
- "@cdot65/prisma-airs-sdk": "^0.13.0",
47
+ "@cdot65/prisma-airs-sdk": "^0.17.0",
48
48
  "@inquirer/prompts": "^8.3.0",
49
49
  "chalk": "^5.6.2",
50
50
  "commander": "^14.0.3",