@mnemom/agent-alignment-protocol 0.1.6 → 0.1.7
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.js +18 -2
- package/dist/index.mjs +18 -2
- package/package.json +2 -2
- package/src/verification/api.ts +26 -2
package/dist/index.js
CHANGED
|
@@ -214,6 +214,22 @@ function createViolation(type, description, traceField) {
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
// src/verification/api.ts
|
|
217
|
+
function actionMatchesList(actionName, list) {
|
|
218
|
+
const components = actionName.includes(", ") ? actionName.split(", ") : [actionName];
|
|
219
|
+
return components.every((component) => {
|
|
220
|
+
const trimmed = component.trim();
|
|
221
|
+
if (!trimmed) return true;
|
|
222
|
+
return list.some((entry) => {
|
|
223
|
+
if (entry === trimmed) return true;
|
|
224
|
+
const colonIndex = entry.indexOf(":");
|
|
225
|
+
if (colonIndex > 0) {
|
|
226
|
+
const prefix = entry.substring(0, colonIndex).trim();
|
|
227
|
+
if (prefix === trimmed) return true;
|
|
228
|
+
}
|
|
229
|
+
return false;
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
}
|
|
217
233
|
function verifyTrace(trace, card) {
|
|
218
234
|
const startTime = performance.now();
|
|
219
235
|
const violations = [];
|
|
@@ -254,7 +270,7 @@ function verifyTrace(trace, card) {
|
|
|
254
270
|
const actionName = action.name;
|
|
255
271
|
if (actionCategory === "bounded") {
|
|
256
272
|
const boundedActions = envelope.bounded_actions ?? [];
|
|
257
|
-
if (actionName && !
|
|
273
|
+
if (actionName && !actionMatchesList(actionName, boundedActions)) {
|
|
258
274
|
violations.push(
|
|
259
275
|
createViolation(
|
|
260
276
|
"unbounded_action",
|
|
@@ -266,7 +282,7 @@ function verifyTrace(trace, card) {
|
|
|
266
282
|
}
|
|
267
283
|
checksPerformed.push("forbidden");
|
|
268
284
|
const forbiddenActions = envelope.forbidden_actions ?? [];
|
|
269
|
-
if (actionName &&
|
|
285
|
+
if (actionName && actionMatchesList(actionName, forbiddenActions)) {
|
|
270
286
|
violations.push(
|
|
271
287
|
createViolation(
|
|
272
288
|
"forbidden_action",
|
package/dist/index.mjs
CHANGED
|
@@ -165,6 +165,22 @@ function createViolation(type, description, traceField) {
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
// src/verification/api.ts
|
|
168
|
+
function actionMatchesList(actionName, list) {
|
|
169
|
+
const components = actionName.includes(", ") ? actionName.split(", ") : [actionName];
|
|
170
|
+
return components.every((component) => {
|
|
171
|
+
const trimmed = component.trim();
|
|
172
|
+
if (!trimmed) return true;
|
|
173
|
+
return list.some((entry) => {
|
|
174
|
+
if (entry === trimmed) return true;
|
|
175
|
+
const colonIndex = entry.indexOf(":");
|
|
176
|
+
if (colonIndex > 0) {
|
|
177
|
+
const prefix = entry.substring(0, colonIndex).trim();
|
|
178
|
+
if (prefix === trimmed) return true;
|
|
179
|
+
}
|
|
180
|
+
return false;
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
168
184
|
function verifyTrace(trace, card) {
|
|
169
185
|
const startTime = performance.now();
|
|
170
186
|
const violations = [];
|
|
@@ -205,7 +221,7 @@ function verifyTrace(trace, card) {
|
|
|
205
221
|
const actionName = action.name;
|
|
206
222
|
if (actionCategory === "bounded") {
|
|
207
223
|
const boundedActions = envelope.bounded_actions ?? [];
|
|
208
|
-
if (actionName && !
|
|
224
|
+
if (actionName && !actionMatchesList(actionName, boundedActions)) {
|
|
209
225
|
violations.push(
|
|
210
226
|
createViolation(
|
|
211
227
|
"unbounded_action",
|
|
@@ -217,7 +233,7 @@ function verifyTrace(trace, card) {
|
|
|
217
233
|
}
|
|
218
234
|
checksPerformed.push("forbidden");
|
|
219
235
|
const forbiddenActions = envelope.forbidden_actions ?? [];
|
|
220
|
-
if (actionName &&
|
|
236
|
+
if (actionName && actionMatchesList(actionName, forbiddenActions)) {
|
|
221
237
|
violations.push(
|
|
222
238
|
createViolation(
|
|
223
239
|
"forbidden_action",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mnemom/agent-alignment-protocol",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Agent Alignment Protocol (AAP) - Verification and drift detection for AI agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"a2a",
|
|
36
36
|
"mcp"
|
|
37
37
|
],
|
|
38
|
-
"author": "
|
|
38
|
+
"author": "Mnemom.ai",
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
package/src/verification/api.ts
CHANGED
|
@@ -36,6 +36,30 @@ import {
|
|
|
36
36
|
type Warning,
|
|
37
37
|
} from "./models";
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Check if a (possibly compound) action name matches any entry in a list.
|
|
41
|
+
* Supports exact match, prefix match (before ':'), and compound name splitting.
|
|
42
|
+
*/
|
|
43
|
+
function actionMatchesList(actionName: string, list: string[]): boolean {
|
|
44
|
+
const components = actionName.includes(', ')
|
|
45
|
+
? actionName.split(', ')
|
|
46
|
+
: [actionName];
|
|
47
|
+
|
|
48
|
+
return components.every(component => {
|
|
49
|
+
const trimmed = component.trim();
|
|
50
|
+
if (!trimmed) return true;
|
|
51
|
+
return list.some(entry => {
|
|
52
|
+
if (entry === trimmed) return true;
|
|
53
|
+
const colonIndex = entry.indexOf(':');
|
|
54
|
+
if (colonIndex > 0) {
|
|
55
|
+
const prefix = entry.substring(0, colonIndex).trim();
|
|
56
|
+
if (prefix === trimmed) return true;
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
39
63
|
/**
|
|
40
64
|
* Verify a single AP-Trace against an Alignment Card.
|
|
41
65
|
*
|
|
@@ -102,7 +126,7 @@ export function verifyTrace(
|
|
|
102
126
|
|
|
103
127
|
if (actionCategory === "bounded") {
|
|
104
128
|
const boundedActions = envelope.bounded_actions ?? [];
|
|
105
|
-
if (actionName && !
|
|
129
|
+
if (actionName && !actionMatchesList(actionName, boundedActions)) {
|
|
106
130
|
violations.push(
|
|
107
131
|
createViolation(
|
|
108
132
|
"unbounded_action",
|
|
@@ -116,7 +140,7 @@ export function verifyTrace(
|
|
|
116
140
|
// Check forbidden actions
|
|
117
141
|
checksPerformed.push("forbidden");
|
|
118
142
|
const forbiddenActions = envelope.forbidden_actions ?? [];
|
|
119
|
-
if (actionName &&
|
|
143
|
+
if (actionName && actionMatchesList(actionName, forbiddenActions)) {
|
|
120
144
|
violations.push(
|
|
121
145
|
createViolation(
|
|
122
146
|
"forbidden_action",
|