agentverify 1.2.0 → 1.4.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/CHANGELOG.md +28 -0
- package/README.md +47 -4
- package/dist/chunk-XVA2M2HS.mjs +131 -0
- package/dist/cli.js +247 -23
- package/dist/cli.mjs +190 -22
- package/dist/sdk.d.mts +117 -9
- package/dist/sdk.d.ts +117 -9
- package/dist/sdk.js +59 -3
- package/dist/sdk.mjs +1 -1
- package/package.json +4 -3
- package/dist/chunk-YOD7H7MC.mjs +0 -75
package/dist/sdk.js
CHANGED
|
@@ -26,6 +26,61 @@ __export(sdk_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(sdk_exports);
|
|
27
27
|
var DEFAULT_API_URL = "https://agentverify-api.agentverify.workers.dev/v1/scan";
|
|
28
28
|
var DEFAULT_TIMEOUT = 3e4;
|
|
29
|
+
function normalizeVerdict(value) {
|
|
30
|
+
if (value === "VERIFIED") return "VERIFIED";
|
|
31
|
+
if (value === "NOT_ASSESSED" || value === "NOT ASSESSED") return "NOT_ASSESSED";
|
|
32
|
+
return "NOT_VERIFIED";
|
|
33
|
+
}
|
|
34
|
+
function normalizeScanResult(data) {
|
|
35
|
+
const findings = Array.isArray(data.findings) ? data.findings : [];
|
|
36
|
+
const riskScore = typeof data.riskScore === "number" ? data.riskScore : 0;
|
|
37
|
+
return {
|
|
38
|
+
...data,
|
|
39
|
+
reportId: typeof data.reportId === "string" ? data.reportId : "",
|
|
40
|
+
verdict: normalizeVerdict(data.verdict),
|
|
41
|
+
riskScore,
|
|
42
|
+
riskLevel: data.riskLevel ?? "High Risk",
|
|
43
|
+
confidence: typeof data.confidence === "number" ? data.confidence : riskScore > 0 ? 80 : 0,
|
|
44
|
+
optimizationScore: typeof data.optimizationScore === "number" ? data.optimizationScore : 0,
|
|
45
|
+
reportInsights: data.reportInsights,
|
|
46
|
+
threatCategories: Array.isArray(data.threatCategories) ? data.threatCategories : [],
|
|
47
|
+
findings,
|
|
48
|
+
categoryScores: Array.isArray(data.categoryScores) ? data.categoryScores : [],
|
|
49
|
+
bom: data.bom ?? {
|
|
50
|
+
detectedLanguage: "Unknown",
|
|
51
|
+
detectedFramework: null,
|
|
52
|
+
detectedPlatform: null,
|
|
53
|
+
agentName: null,
|
|
54
|
+
toolAccessLevel: "Unknown",
|
|
55
|
+
credentialExposure: "Not Detected",
|
|
56
|
+
memoryPersistence: "Unknown",
|
|
57
|
+
auditLogging: "Unknown",
|
|
58
|
+
humanGates: "Unknown",
|
|
59
|
+
rateLimiting: "Unknown",
|
|
60
|
+
promptInjectionSurface: "Unknown",
|
|
61
|
+
delegationScope: "Unknown"
|
|
62
|
+
},
|
|
63
|
+
metadata: data.metadata ?? {
|
|
64
|
+
schemaVersion: "1.3.0",
|
|
65
|
+
scannerVersion: "unknown",
|
|
66
|
+
fileName: "unknown",
|
|
67
|
+
fileSize: 0,
|
|
68
|
+
scannedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
69
|
+
detectedLanguage: "Unknown",
|
|
70
|
+
detectedFramework: null,
|
|
71
|
+
selectedPlatform: null,
|
|
72
|
+
agentName: null,
|
|
73
|
+
scanDuration: 0
|
|
74
|
+
},
|
|
75
|
+
saved: data.saved === true,
|
|
76
|
+
reportUrl: data.reportUrl ?? null,
|
|
77
|
+
artifactFingerprint: data.artifactFingerprint,
|
|
78
|
+
reportIntegrity: data.reportIntegrity,
|
|
79
|
+
policyProfile: data.policyProfile ?? null,
|
|
80
|
+
policyResult: data.policyResult ?? null,
|
|
81
|
+
attestation: data.attestation ?? null
|
|
82
|
+
};
|
|
83
|
+
}
|
|
29
84
|
async function scan(input, options) {
|
|
30
85
|
const { apiKey, apiUrl = DEFAULT_API_URL, timeout = DEFAULT_TIMEOUT } = options;
|
|
31
86
|
if (!apiKey) {
|
|
@@ -49,13 +104,14 @@ async function scan(input, options) {
|
|
|
49
104
|
body: JSON.stringify({
|
|
50
105
|
content: input.content,
|
|
51
106
|
fileName: input.fileName ?? "agent",
|
|
52
|
-
platform: input.platform
|
|
107
|
+
platform: input.platform,
|
|
108
|
+
policyId: input.policyId
|
|
53
109
|
}),
|
|
54
110
|
signal: controller.signal
|
|
55
111
|
});
|
|
56
112
|
if (response.status === 401) {
|
|
57
113
|
throw new Error(
|
|
58
|
-
"Invalid API key. Generate
|
|
114
|
+
"Invalid or unauthorized Agent Verify API key. Generate a valid key at https://aimodularity.com/agentverify/dashboard/"
|
|
59
115
|
);
|
|
60
116
|
}
|
|
61
117
|
if (response.status === 400) {
|
|
@@ -66,7 +122,7 @@ async function scan(input, options) {
|
|
|
66
122
|
throw new Error(`API error: ${response.status} ${response.statusText}`);
|
|
67
123
|
}
|
|
68
124
|
const data = await response.json();
|
|
69
|
-
return data;
|
|
125
|
+
return normalizeScanResult(data);
|
|
70
126
|
} catch (err) {
|
|
71
127
|
if (err instanceof Error && err.name === "AbortError") {
|
|
72
128
|
throw new Error(`Request timed out after ${timeout}ms`);
|
package/dist/sdk.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentverify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "CLI and SDK for Agent Verify — execution trust analysis for AI agents",
|
|
5
5
|
"bin": {
|
|
6
|
-
"agentverify": "
|
|
6
|
+
"agentverify": "dist/cli.js"
|
|
7
7
|
},
|
|
8
8
|
"main": "./dist/sdk.js",
|
|
9
9
|
"module": "./dist/sdk.mjs",
|
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
},
|
|
17
17
|
"./cli": "./dist/cli.js"
|
|
18
18
|
},
|
|
19
|
-
"files": ["dist", "README.md", "LICENSE"],
|
|
19
|
+
"files": ["dist", "README.md", "LICENSE", "CHANGELOG.md"],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "tsup src/cli.ts src/sdk.ts --format cjs,esm --dts --clean",
|
|
22
22
|
"dev": "tsup src/cli.ts src/sdk.ts --format cjs,esm --dts --watch",
|
|
23
|
+
"test": "npm run build && node test/cli.test.mjs",
|
|
23
24
|
"prepublishOnly": "npm run build"
|
|
24
25
|
},
|
|
25
26
|
"engines": { "node": ">=18.0.0" },
|
package/dist/chunk-YOD7H7MC.mjs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// src/sdk.ts
|
|
2
|
-
var DEFAULT_API_URL = "https://agentverify-api.agentverify.workers.dev/v1/scan";
|
|
3
|
-
var DEFAULT_TIMEOUT = 3e4;
|
|
4
|
-
async function scan(input, options) {
|
|
5
|
-
const { apiKey, apiUrl = DEFAULT_API_URL, timeout = DEFAULT_TIMEOUT } = options;
|
|
6
|
-
if (!apiKey) {
|
|
7
|
-
throw new Error(
|
|
8
|
-
"API key required. Generate one at https://aimodularity.com/agentverify/dashboard"
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
if (!input.content || input.content.trim().length === 0) {
|
|
12
|
-
throw new Error("content is required and cannot be empty");
|
|
13
|
-
}
|
|
14
|
-
const controller = new AbortController();
|
|
15
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
16
|
-
try {
|
|
17
|
-
const response = await fetch(apiUrl, {
|
|
18
|
-
method: "POST",
|
|
19
|
-
headers: {
|
|
20
|
-
"Authorization": `Bearer ${apiKey}`,
|
|
21
|
-
"Content-Type": "application/json",
|
|
22
|
-
"User-Agent": "agentverify-sdk/1.0.0"
|
|
23
|
-
},
|
|
24
|
-
body: JSON.stringify({
|
|
25
|
-
content: input.content,
|
|
26
|
-
fileName: input.fileName ?? "agent",
|
|
27
|
-
platform: input.platform
|
|
28
|
-
}),
|
|
29
|
-
signal: controller.signal
|
|
30
|
-
});
|
|
31
|
-
if (response.status === 401) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
"Invalid API key. Generate one at https://aimodularity.com/agentverify/dashboard"
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
if (response.status === 400) {
|
|
37
|
-
const err = await response.json().catch(() => ({}));
|
|
38
|
-
throw new Error(err.error ?? "Invalid request");
|
|
39
|
-
}
|
|
40
|
-
if (!response.ok) {
|
|
41
|
-
throw new Error(`API error: ${response.status} ${response.statusText}`);
|
|
42
|
-
}
|
|
43
|
-
const data = await response.json();
|
|
44
|
-
return data;
|
|
45
|
-
} catch (err) {
|
|
46
|
-
if (err instanceof Error && err.name === "AbortError") {
|
|
47
|
-
throw new Error(`Request timed out after ${timeout}ms`);
|
|
48
|
-
}
|
|
49
|
-
throw err;
|
|
50
|
-
} finally {
|
|
51
|
-
clearTimeout(timer);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async function scanMany(inputs, options, concurrency = 3) {
|
|
55
|
-
const results = [];
|
|
56
|
-
for (let i = 0; i < inputs.length; i += concurrency) {
|
|
57
|
-
const batch = inputs.slice(i, i + concurrency);
|
|
58
|
-
const batchResults = await Promise.allSettled(
|
|
59
|
-
batch.map((input) => scan(input, options))
|
|
60
|
-
);
|
|
61
|
-
batchResults.forEach((res, j) => {
|
|
62
|
-
if (res.status === "fulfilled") {
|
|
63
|
-
results.push({ input: batch[j], result: res.value, error: null });
|
|
64
|
-
} else {
|
|
65
|
-
results.push({ input: batch[j], result: null, error: res.reason instanceof Error ? res.reason.message : String(res.reason) });
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return results;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export {
|
|
73
|
-
scan,
|
|
74
|
-
scanMany
|
|
75
|
-
};
|