@mnemom/agent-integrity-protocol 0.1.1 → 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 +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -767,6 +767,12 @@ function createAdapterRegistry() {
|
|
|
767
767
|
}
|
|
768
768
|
|
|
769
769
|
// src/analysis/agreement.ts
|
|
770
|
+
function escapeRegex(s) {
|
|
771
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
772
|
+
}
|
|
773
|
+
function containsWholeWord(text, term) {
|
|
774
|
+
return new RegExp(`\\b${escapeRegex(term)}\\b`).test(text);
|
|
775
|
+
}
|
|
770
776
|
function validateAgreement(card, conscienceValues) {
|
|
771
777
|
const conflicts = [];
|
|
772
778
|
const augmentations = [];
|
|
@@ -775,7 +781,7 @@ function validateAgreement(card, conscienceValues) {
|
|
|
775
781
|
const contentLower = value.content.toLowerCase();
|
|
776
782
|
if (value.type === "BOUNDARY" && card.autonomy_envelope.bounded_actions) {
|
|
777
783
|
for (const action of card.autonomy_envelope.bounded_actions) {
|
|
778
|
-
if (contentLower
|
|
784
|
+
if (containsWholeWord(contentLower, action.toLowerCase().replace(/_/g, " ")) || containsWholeWord(contentLower, action.toLowerCase())) {
|
|
779
785
|
if (contentLower.includes("never") || contentLower.includes("no ") || contentLower.includes("don't") || contentLower.includes("do not")) {
|
|
780
786
|
conflicts.push({
|
|
781
787
|
conscience_value: value,
|
|
@@ -788,7 +794,7 @@ function validateAgreement(card, conscienceValues) {
|
|
|
788
794
|
}
|
|
789
795
|
if (card.autonomy_envelope.forbidden_actions) {
|
|
790
796
|
for (const action of card.autonomy_envelope.forbidden_actions) {
|
|
791
|
-
if (contentLower
|
|
797
|
+
if (containsWholeWord(contentLower, action.toLowerCase().replace(/_/g, " ")) || containsWholeWord(contentLower, action.toLowerCase())) {
|
|
792
798
|
augmentations.push({
|
|
793
799
|
conscience_value: value,
|
|
794
800
|
augments: "autonomy_envelope.forbidden_actions",
|
|
@@ -799,7 +805,7 @@ function validateAgreement(card, conscienceValues) {
|
|
|
799
805
|
}
|
|
800
806
|
if (card.autonomy_envelope.escalation_triggers) {
|
|
801
807
|
for (const trigger of card.autonomy_envelope.escalation_triggers) {
|
|
802
|
-
if (contentLower
|
|
808
|
+
if (containsWholeWord(contentLower, trigger.condition.toLowerCase().replace(/_/g, " ")) || containsWholeWord(contentLower, trigger.condition.toLowerCase())) {
|
|
803
809
|
augmentations.push({
|
|
804
810
|
conscience_value: value,
|
|
805
811
|
augments: "autonomy_envelope.escalation_triggers",
|
|
@@ -1299,7 +1305,7 @@ function createClient(config) {
|
|
|
1299
1305
|
async check(responseBody, provider) {
|
|
1300
1306
|
if (destroyed) throw new Error("AIP client has been destroyed");
|
|
1301
1307
|
const adapter = provider ? registry.get(provider) : registry.detectFromUrl(config.analysis_llm.base_url);
|
|
1302
|
-
const thinking = adapter.extractThinking(responseBody);
|
|
1308
|
+
const thinking = adapter.extractThinking(responseBody) ?? adapter.extractThinkingFromStream(responseBody);
|
|
1303
1309
|
if (!thinking) {
|
|
1304
1310
|
return buildSyntheticSignal(config, window, "clear");
|
|
1305
1311
|
}
|