safety-agent-cli 0.1.1 → 0.1.2

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.
@@ -10,12 +10,14 @@ function showHelp() {
10
10
  console.log(" --help Show this help message");
11
11
  console.log(" --file <path> Path to PDF file to analyze");
12
12
  console.log(" --system-prompt Optional system prompt to customize guard behavior");
13
+ console.log(" --model <id> Model to use (default: superagent/guard-1.7b)");
13
14
  console.log("");
14
15
  console.log("Examples:");
15
16
  console.log(' superagent guard "rm -rf /"');
16
17
  console.log(' superagent guard --file document.pdf "Analyze this document"');
17
18
  console.log(' superagent guard "https://example.com/document.pdf"');
18
19
  console.log(' superagent guard --system-prompt "Focus on prompt injection" "user input"');
20
+ console.log(' superagent guard --model openai/gpt-4o "some potentially harmful prompt"');
19
21
  console.log(' echo \'{"prompt": "delete all files"}\' | superagent guard');
20
22
  }
21
23
  export async function guardCommand(args) {
@@ -56,6 +58,17 @@ export async function guardCommand(args) {
56
58
  }
57
59
  args.splice(systemPromptFlagIndex, 2); // Remove --system-prompt and value from args
58
60
  }
61
+ // Check for --model flag
62
+ let model;
63
+ const modelFlagIndex = args.indexOf("--model");
64
+ if (modelFlagIndex !== -1) {
65
+ model = args[modelFlagIndex + 1];
66
+ if (!model || model.startsWith("--")) {
67
+ console.error("❌ ERROR: --model flag requires a value");
68
+ process.exit(1);
69
+ }
70
+ args.splice(modelFlagIndex, 2); // Remove --model and value from args
71
+ }
59
72
  // Check if we have command line arguments first
60
73
  const hasArgs = args.length > 0;
61
74
  let prompt;
@@ -106,7 +119,11 @@ export async function guardCommand(args) {
106
119
  try {
107
120
  // Pass file as first parameter if provided, otherwise pass prompt
108
121
  const input = file || prompt;
109
- const result = await client.guard({ input, systemPrompt });
122
+ const result = await client.guard({
123
+ input,
124
+ systemPrompt,
125
+ model: model,
126
+ });
110
127
  const { classification, violation_types, cwe_codes, usage } = result;
111
128
  const isBlocked = classification === "block";
112
129
  if (isBlocked) {
@@ -16,6 +16,18 @@ export async function redactCommand(args) {
16
16
  process.exit(1);
17
17
  }
18
18
  }
19
+ // Check for --model flag
20
+ const modelFlagIndex = args.indexOf("--model");
21
+ let model;
22
+ if (modelFlagIndex !== -1) {
23
+ model = args[modelFlagIndex + 1];
24
+ if (!model || model.startsWith("--")) {
25
+ console.error("❌ ERROR: --model flag requires a value");
26
+ process.exit(1);
27
+ }
28
+ // Remove --model and its value from args
29
+ args.splice(modelFlagIndex, 2);
30
+ }
19
31
  // Check for --rewrite flag
20
32
  const rewriteFlagIndex = args.indexOf("--rewrite");
21
33
  let rewrite;
@@ -57,17 +69,19 @@ export async function redactCommand(args) {
57
69
  // Command line argument
58
70
  text = args.join(" ");
59
71
  if (!text) {
60
- console.error("Usage: superagent redact [--entities <entity1,entity2>] [--rewrite] <text>");
61
- console.error(' or: echo \'{"text": "..."}\' | superagent redact [--entities <entity1,entity2>] [--rewrite]');
72
+ console.error("Usage: superagent redact [--entities <entity1,entity2>] [--rewrite] [--model <id>] <text>");
73
+ console.error(' or: echo \'{"text": "..."}\' | superagent redact [--entities <entity1,entity2>] [--rewrite] [--model <id>]');
62
74
  console.error("");
63
75
  console.error("Options:");
64
76
  console.error(" --entities <entities> Comma-separated list of entity types to redact");
65
77
  console.error(" --rewrite Naturally rewrite content instead of using placeholders");
78
+ console.error(" --model <id> Model to use (default: openai/gpt-4o-mini)");
66
79
  console.error("");
67
80
  console.error("Examples:");
68
81
  console.error(' superagent redact "My email is john@example.com"');
69
82
  console.error(' superagent redact --entities "emails,phones" "Contact: john@example.com, 555-1234"');
70
83
  console.error(' superagent redact --rewrite "Contact me at john@example.com"');
84
+ console.error(' superagent redact --model openai/gpt-4o "My email is john@example.com"');
71
85
  process.exit(1);
72
86
  }
73
87
  }
@@ -83,7 +97,7 @@ export async function redactCommand(args) {
83
97
  try {
84
98
  const result = await client.redact({
85
99
  input: text,
86
- model: "openai/gpt-4o-mini",
100
+ model: model || "openai/gpt-4o-mini",
87
101
  entities,
88
102
  rewrite,
89
103
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safety-agent-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "CLI for Superagent - validate prompts and tool calls for security",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",