@mnemom/agent-integrity-protocol 0.1.5 → 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.cjs CHANGED
@@ -91,6 +91,16 @@ var DEFAULT_CONSCIENCE_VALUES = [
91
91
  content: "Risk of agreeing with the user to avoid conflict rather than providing honest assessment"
92
92
  }
93
93
  ];
94
+ var EU_COMPLIANCE_WINDOW_CONFIG = {
95
+ max_size: 10,
96
+ mode: "sliding",
97
+ session_boundary: "reset",
98
+ max_age_seconds: 7200
99
+ };
100
+ var EU_COMPLIANCE_FAILURE_POLICY = {
101
+ mode: "fail_closed",
102
+ analysis_timeout_ms: 15e3
103
+ };
94
104
  var CHECKPOINT_ID_PREFIX = "ic-";
95
105
  var DRIFT_ALERT_ID_PREFIX = "ida-";
96
106
  var REGISTRATION_ID_PREFIX = "reg-";
@@ -1146,9 +1156,14 @@ function validateConscienceContext(value) {
1146
1156
  };
1147
1157
  }
1148
1158
  function checkIntegrity(input) {
1159
+ let jsonText = input.analysisResponse;
1160
+ const jsonMatch = jsonText.match(/\{[\s\S]*\}/);
1161
+ if (jsonMatch) {
1162
+ jsonText = jsonMatch[0];
1163
+ }
1149
1164
  let parsed;
1150
1165
  try {
1151
- parsed = JSON.parse(input.analysisResponse);
1166
+ parsed = JSON.parse(jsonText);
1152
1167
  } catch {
1153
1168
  throw new Error(
1154
1169
  `Failed to parse analysis response as JSON: ${input.analysisResponse.slice(0, 100)}`
@@ -1442,6 +1457,7 @@ async function callAnalysisLLM(llmConfig, system, user, timeoutMs) {
1442
1457
  const controller = new AbortController();
1443
1458
  const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
1444
1459
  try {
1460
+ const systemPayload = llmConfig.enable_prompt_caching ? [{ type: "text", text: system, cache_control: { type: "ephemeral" } }] : system;
1445
1461
  const response = await fetch(`${llmConfig.base_url}/v1/messages`, {
1446
1462
  method: "POST",
1447
1463
  headers: {
@@ -1452,7 +1468,7 @@ async function callAnalysisLLM(llmConfig, system, user, timeoutMs) {
1452
1468
  body: JSON.stringify({
1453
1469
  model: llmConfig.model,
1454
1470
  max_tokens: llmConfig.max_tokens,
1455
- system,
1471
+ system: systemPayload,
1456
1472
  messages: [{ role: "user", content: user }]
1457
1473
  }),
1458
1474
  signal: controller.signal
@@ -1555,6 +1571,8 @@ exports.DEFAULT_WINDOW_MAX_SIZE = DEFAULT_WINDOW_MAX_SIZE;
1555
1571
  exports.DRIFT_ALERT_ID_PREFIX = DRIFT_ALERT_ID_PREFIX;
1556
1572
  exports.DRIFT_SEVERITY_LOW_THRESHOLD = DRIFT_SEVERITY_LOW_THRESHOLD;
1557
1573
  exports.DRIFT_SEVERITY_MEDIUM_THRESHOLD = DRIFT_SEVERITY_MEDIUM_THRESHOLD;
1574
+ exports.EU_COMPLIANCE_FAILURE_POLICY = EU_COMPLIANCE_FAILURE_POLICY;
1575
+ exports.EU_COMPLIANCE_WINDOW_CONFIG = EU_COMPLIANCE_WINDOW_CONFIG;
1558
1576
  exports.FallbackAdapter = FallbackAdapter;
1559
1577
  exports.GoogleAdapter = GoogleAdapter;
1560
1578
  exports.MAX_EVIDENCE_LENGTH = MAX_EVIDENCE_LENGTH;