@mnemom/agent-integrity-protocol 0.1.2 → 0.1.3
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.cjs +9 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -765,6 +765,12 @@ function createAdapterRegistry() {
|
|
|
765
765
|
}
|
|
766
766
|
|
|
767
767
|
// src/analysis/agreement.ts
|
|
768
|
+
function escapeRegex(s) {
|
|
769
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
770
|
+
}
|
|
771
|
+
function containsWholeWord(text, term) {
|
|
772
|
+
return new RegExp(`\\b${escapeRegex(term)}\\b`).test(text);
|
|
773
|
+
}
|
|
768
774
|
function validateAgreement(card, conscienceValues) {
|
|
769
775
|
const conflicts = [];
|
|
770
776
|
const augmentations = [];
|
|
@@ -773,7 +779,7 @@ function validateAgreement(card, conscienceValues) {
|
|
|
773
779
|
const contentLower = value.content.toLowerCase();
|
|
774
780
|
if (value.type === "BOUNDARY" && card.autonomy_envelope.bounded_actions) {
|
|
775
781
|
for (const action of card.autonomy_envelope.bounded_actions) {
|
|
776
|
-
if (contentLower
|
|
782
|
+
if (containsWholeWord(contentLower, action.toLowerCase().replace(/_/g, " ")) || containsWholeWord(contentLower, action.toLowerCase())) {
|
|
777
783
|
if (contentLower.includes("never") || contentLower.includes("no ") || contentLower.includes("don't") || contentLower.includes("do not")) {
|
|
778
784
|
conflicts.push({
|
|
779
785
|
conscience_value: value,
|
|
@@ -786,7 +792,7 @@ function validateAgreement(card, conscienceValues) {
|
|
|
786
792
|
}
|
|
787
793
|
if (card.autonomy_envelope.forbidden_actions) {
|
|
788
794
|
for (const action of card.autonomy_envelope.forbidden_actions) {
|
|
789
|
-
if (contentLower
|
|
795
|
+
if (containsWholeWord(contentLower, action.toLowerCase().replace(/_/g, " ")) || containsWholeWord(contentLower, action.toLowerCase())) {
|
|
790
796
|
augmentations.push({
|
|
791
797
|
conscience_value: value,
|
|
792
798
|
augments: "autonomy_envelope.forbidden_actions",
|
|
@@ -797,7 +803,7 @@ function validateAgreement(card, conscienceValues) {
|
|
|
797
803
|
}
|
|
798
804
|
if (card.autonomy_envelope.escalation_triggers) {
|
|
799
805
|
for (const trigger of card.autonomy_envelope.escalation_triggers) {
|
|
800
|
-
if (contentLower
|
|
806
|
+
if (containsWholeWord(contentLower, trigger.condition.toLowerCase().replace(/_/g, " ")) || containsWholeWord(contentLower, trigger.condition.toLowerCase())) {
|
|
801
807
|
augmentations.push({
|
|
802
808
|
conscience_value: value,
|
|
803
809
|
augments: "autonomy_envelope.escalation_triggers",
|