@cdot65/prisma-airs-cli 3.1.0 → 3.2.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;
38
46
  }
39
- /** Contract for runtime scanning operations (sync + async). */
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[];
57
+ }
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. */
@@ -1338,30 +1382,37 @@ declare class SdkRedTeamService implements RedTeamService {
1338
1382
  }>;
1339
1383
  }
1340
1384
 
1385
+ /** Maximum async request objects accepted by the installed AIRS SDK. */
1386
+ declare const SDK_ASYNC_BATCH_SIZE = 20;
1341
1387
  interface PollRetryOptions {
1342
1388
  /** Max retries per rate-limit error before giving up. Default: 5. */
1343
1389
  maxRetries?: number;
1344
1390
  /** Base delay in ms for exponential backoff. Default: 10000. */
1345
1391
  baseDelayMs?: number;
1392
+ /** Stop after this many consecutive successful polls resolve no new prompts. Default: 120. */
1393
+ maxNoProgressPolls?: number;
1346
1394
  /** Called on each retry with (attempt, delayMs). */
1347
1395
  onRetry?: (attempt: number, delayMs: number) => void;
1396
+ /** Called whenever newly terminal prompt results are resolved. */
1397
+ onProgress?: (results: BulkScanResult[]) => void | Promise<void>;
1348
1398
  }
1349
- declare class SdkRuntimeService implements RuntimeService {
1399
+ declare class SdkRuntimeService implements ReliableRuntimeService {
1350
1400
  private scanner;
1351
1401
  constructor(opts: InitOptions);
1352
1402
  scanPrompt(profileName: string, prompt: string, response?: string): Promise<RuntimeScanResult>;
1403
+ submitBatch(profileName: string, prompts: IndexedPrompt[], sessionId?: string, retryOpts?: PollRetryOptions): Promise<SubmittedBatch>;
1404
+ pollBatch(batch: SubmittedBatch, intervalMs?: number, retryOpts?: PollRetryOptions): Promise<BulkScanResult[]>;
1405
+ /** @deprecated Use submitBatch to preserve per-prompt request correlation. */
1353
1406
  submitBulkScan(profileName: string, prompts: string[], sessionId?: string): Promise<string[]>;
1354
1407
  /**
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.
1408
+ * Compatibility poller for callers that retained only batch scan IDs.
1409
+ * Nested detection data is preserved, but prompt text and per-request fan-out
1410
+ * cannot be reconstructed from scan IDs alone.
1411
+ * @deprecated Use pollBatch to preserve `(scan_id, req_id)` correlation and prompt text.
1361
1412
  */
1362
1413
  pollResults(scanIds: string[], intervalMs?: number, retryOpts?: PollRetryOptions): Promise<RuntimeScanResult[]>;
1363
1414
  private processQueryResults;
1364
- static formatResultsCsv(results: RuntimeScanResult[]): string;
1415
+ static formatResultsCsv(results: Array<RuntimeScanResult | BulkScanResult>): string;
1365
1416
  }
1366
1417
 
1367
1418
  /** Scans prompts against AIRS security profiles via the Prisma AIRS SDK. */
@@ -1595,4 +1646,4 @@ declare function computeMetrics(results: TestResult[]): EfficacyMetrics;
1595
1646
  /** Compute per-category error breakdown from test results. Sorted by error rate descending. */
1596
1647
  declare function computeCategoryBreakdown(results: TestResult[]): CategoryBreakdown[];
1597
1648
 
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 };
1649
+ 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-TTBN7YHC.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.2.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.13.2",
48
48
  "@inquirer/prompts": "^8.3.0",
49
49
  "chalk": "^5.6.2",
50
50
  "commander": "^14.0.3",