@cdot65/prisma-airs-cli 7.1.3 → 7.1.4
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/cli/index.js +2 -57
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -6289,61 +6289,10 @@ function isDict(value) {
|
|
|
6289
6289
|
function digest(text2) {
|
|
6290
6290
|
return createHash("sha256").update(text2, "utf8").digest("hex").slice(0, 16);
|
|
6291
6291
|
}
|
|
6292
|
-
function pythonJson(value) {
|
|
6293
|
-
if (Array.isArray(value)) return `[${value.map(pythonJson).join(", ")}]`;
|
|
6294
|
-
if (isDict(value))
|
|
6295
|
-
return `{${Object.entries(value).filter(([, v]) => v !== void 0).map(([k, v]) => `${JSON.stringify(k)}: ${pythonJson(v)}`).join(", ")}}`;
|
|
6296
|
-
return JSON.stringify(value ?? null);
|
|
6297
|
-
}
|
|
6298
|
-
function textFromContentList(content) {
|
|
6299
|
-
if (!Array.isArray(content)) return null;
|
|
6300
|
-
const parts = content.filter((c) => isDict(c) && typeof c.text === "string").map((c) => c.text);
|
|
6301
|
-
return parts.length ? parts.join("\n") : null;
|
|
6302
|
-
}
|
|
6303
6292
|
function extractResponseText(raw) {
|
|
6304
6293
|
if (raw === null || raw === void 0) return ["", "empty"];
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
if (typeof raw === "string") {
|
|
6308
|
-
const stripped = raw.trim();
|
|
6309
|
-
if (!stripped) return ["", "empty"];
|
|
6310
|
-
if (stripped[0] !== "{" && stripped[0] !== "[") return [raw, "plain"];
|
|
6311
|
-
[value, method] = decodeContainer(stripped);
|
|
6312
|
-
if (method === "plain") return [raw, "plain"];
|
|
6313
|
-
}
|
|
6314
|
-
const message = messageText(value);
|
|
6315
|
-
if (message !== null) return message;
|
|
6316
|
-
if (isDict(value)) {
|
|
6317
|
-
const outputs = value.output;
|
|
6318
|
-
if (Array.isArray(outputs)) {
|
|
6319
|
-
const texts = outputs.map((item) => isDict(item) ? textFromContentList(item.content) : null).filter((text2) => Boolean(text2));
|
|
6320
|
-
if (texts.length) return [texts.join("\n"), "responses_api"];
|
|
6321
|
-
}
|
|
6322
|
-
const choices = value.choices;
|
|
6323
|
-
if (Array.isArray(choices) && choices.length && isDict(choices[0])) {
|
|
6324
|
-
const message2 = choices[0].message;
|
|
6325
|
-
if (isDict(message2) && typeof message2.content === "string")
|
|
6326
|
-
return [message2.content, "chat_completions"];
|
|
6327
|
-
}
|
|
6328
|
-
for (const key of ["output_text", "response", "text", "content", "message", "answer"]) {
|
|
6329
|
-
if (typeof value[key] === "string") return [value[key], `json.${key}`];
|
|
6330
|
-
}
|
|
6331
|
-
const turns = value.messages || value.turns || value.conversation;
|
|
6332
|
-
if (Array.isArray(turns) && turns.length) {
|
|
6333
|
-
const last = turns[turns.length - 1];
|
|
6334
|
-
if (isDict(last)) {
|
|
6335
|
-
const text2 = typeof last.content === "string" ? last.content : textFromContentList(last.content);
|
|
6336
|
-
if (text2) return [text2, "multi_turn_last"];
|
|
6337
|
-
}
|
|
6338
|
-
}
|
|
6339
|
-
return [pythonJson(value), `${method}_unparsed`];
|
|
6340
|
-
}
|
|
6341
|
-
if (Array.isArray(value)) {
|
|
6342
|
-
const texts = value.filter((item) => typeof item === "string");
|
|
6343
|
-
if (texts.length) return [texts.join("\n"), "list_of_strings"];
|
|
6344
|
-
return [pythonJson(value), `${method}_unparsed`];
|
|
6345
|
-
}
|
|
6346
|
-
return [String(value), "coerced"];
|
|
6294
|
+
if (typeof raw !== "string") throw new Error("Expected output to be a string");
|
|
6295
|
+
return [raw, raw.trim() ? "plain" : "empty"];
|
|
6347
6296
|
}
|
|
6348
6297
|
function recordsFromDocument(document) {
|
|
6349
6298
|
if (Array.isArray(document)) return [document.filter(isDict), "array"];
|
|
@@ -6412,10 +6361,6 @@ function normalizeScan(document, options = {}) {
|
|
|
6412
6361
|
const airsAsr = typeof record.asr === "number" ? record.asr : null;
|
|
6413
6362
|
for (const [outputIndex, output] of rawOutputs.entries()) {
|
|
6414
6363
|
const [text2, extraction] = extractResponseText(output.output);
|
|
6415
|
-
if (extraction.startsWith("a2a_"))
|
|
6416
|
-
notes.response_envelopes = (notes.response_envelopes ?? 0) + 1;
|
|
6417
|
-
if (extraction === "a2a_unsupported_parts")
|
|
6418
|
-
notes.unsupported_response_envelopes = (notes.unsupported_response_envelopes ?? 0) + 1;
|
|
6419
6364
|
const isError = Boolean(output.error) || !text2.trim();
|
|
6420
6365
|
if (isError) notes.error_outputs += 1;
|
|
6421
6366
|
const outputId = label(output.uuid) || String(outputIndex);
|
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": "7.1.
|
|
4
|
+
"version": "7.1.4",
|
|
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",
|