@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.d.cts CHANGED
@@ -437,6 +437,8 @@ interface AnalysisLLMConfig {
437
437
  api_key: string;
438
438
  /** Maximum tokens for the analysis response */
439
439
  max_tokens: number;
440
+ /** Enable Anthropic prompt caching on system prompt. Default: false. */
441
+ enable_prompt_caching?: boolean;
440
442
  }
441
443
  /**
442
444
  * Optional callback functions for SDK signal delivery.
@@ -1029,9 +1031,21 @@ declare const DEFAULT_CONSCIENCE_VALUES: readonly [{
1029
1031
  readonly id: "fear-sycophancy";
1030
1032
  readonly content: "Risk of agreeing with the user to avoid conflict rather than providing honest assessment";
1031
1033
  }];
1034
+ /** Window configuration for EU compliance — extended retention and fail-closed. */
1035
+ declare const EU_COMPLIANCE_WINDOW_CONFIG: {
1036
+ readonly max_size: 10;
1037
+ readonly mode: "sliding";
1038
+ readonly session_boundary: "reset";
1039
+ readonly max_age_seconds: 7200;
1040
+ };
1041
+ /** Failure policy for EU compliance — fail closed with extended timeout. */
1042
+ declare const EU_COMPLIANCE_FAILURE_POLICY: {
1043
+ readonly mode: "fail_closed";
1044
+ readonly analysis_timeout_ms: 15000;
1045
+ };
1032
1046
  /** ID prefixes for protocol entities. */
1033
1047
  declare const CHECKPOINT_ID_PREFIX = "ic-";
1034
1048
  declare const DRIFT_ALERT_ID_PREFIX = "ida-";
1035
1049
  declare const REGISTRATION_ID_PREFIX = "reg-";
1036
1050
 
1037
- export { type AIPCallbacks, type AIPClient, type AIPConfig, AIP_CONTENT_TYPE, AIP_SIGNATURE_HEADER, AIP_VERSION, AIP_VERSION_HEADER, ALGORITHM_VERSION, type AdapterRegistry, type AlignmentCard, type AlignmentCardValue, type AnalysisLLMConfig, type AnalysisMetadata, AnthropicAdapter, type AutonomyEnvelope, type BuiltPrompt, CHECKPOINT_ID_PREFIX, CONFIDENCE_EXPLICIT, CONFIDENCE_FALLBACK, CONFIDENCE_NATIVE, type CardConscienceAgreement, type CardConscienceAugmentation, type CardConscienceConflict, type CheckIntegrityInput, type ConcernCategory, type ConscienceContext, type ConscienceValue, type ConscienceValueType, type ConsultationDepth, DEFAULT_ANALYSIS_MAX_TOKENS, DEFAULT_ANALYSIS_TIMEOUT_MS, DEFAULT_CONSCIENCE_VALUES, DEFAULT_SUSTAINED_CHECKS_THRESHOLD, DEFAULT_THINKING_TOKEN_BUDGET, DEFAULT_WINDOW_MAX_AGE_SECONDS, DEFAULT_WINDOW_MAX_SIZE, DRIFT_ALERT_ID_PREFIX, DRIFT_SEVERITY_LOW_THRESHOLD, DRIFT_SEVERITY_MEDIUM_THRESHOLD, type DriftDirection, type DriftState, type EscalationTrigger, type ExtractedThinking, type ExtractionMethod, type FailureMode, type FailurePolicy, FallbackAdapter, GoogleAdapter, type IntegrityCheckpoint, type IntegrityConcern, type IntegrityDriftAlert, type IntegritySeverity, type IntegritySignal, type IntegrityVerdict, MAX_EVIDENCE_LENGTH, MIN_WINDOW_SIZE, OpenAIAdapter, type PromptInput, type ProviderAdapter, REGISTRATION_ID_PREFIX, type RecommendedAction, type SessionBoundary, TRUNCATION_HEAD_RATIO, TRUNCATION_TAIL_RATIO, WEBHOOK_MAX_RETRIES, WEBHOOK_RETRY_DELAYS_MS, type WindowConfig, WindowManager, type WindowMode, type WindowPosition, type WindowState, type WindowSummary, buildConsciencePrompt, buildSignal, checkIntegrity, createAdapterRegistry, createClient, createDriftState, createWindowState, detectIntegrityDrift, hashThinkingBlock, mapVerdictToAction, mapVerdictToProceed, signPayload, summarizeCard, validateAgreement, verifySignature };
1051
+ export { type AIPCallbacks, type AIPClient, type AIPConfig, AIP_CONTENT_TYPE, AIP_SIGNATURE_HEADER, AIP_VERSION, AIP_VERSION_HEADER, ALGORITHM_VERSION, type AdapterRegistry, type AlignmentCard, type AlignmentCardValue, type AnalysisLLMConfig, type AnalysisMetadata, AnthropicAdapter, type AutonomyEnvelope, type BuiltPrompt, CHECKPOINT_ID_PREFIX, CONFIDENCE_EXPLICIT, CONFIDENCE_FALLBACK, CONFIDENCE_NATIVE, type CardConscienceAgreement, type CardConscienceAugmentation, type CardConscienceConflict, type CheckIntegrityInput, type ConcernCategory, type ConscienceContext, type ConscienceValue, type ConscienceValueType, type ConsultationDepth, DEFAULT_ANALYSIS_MAX_TOKENS, DEFAULT_ANALYSIS_TIMEOUT_MS, DEFAULT_CONSCIENCE_VALUES, DEFAULT_SUSTAINED_CHECKS_THRESHOLD, DEFAULT_THINKING_TOKEN_BUDGET, DEFAULT_WINDOW_MAX_AGE_SECONDS, DEFAULT_WINDOW_MAX_SIZE, DRIFT_ALERT_ID_PREFIX, DRIFT_SEVERITY_LOW_THRESHOLD, DRIFT_SEVERITY_MEDIUM_THRESHOLD, type DriftDirection, type DriftState, EU_COMPLIANCE_FAILURE_POLICY, EU_COMPLIANCE_WINDOW_CONFIG, type EscalationTrigger, type ExtractedThinking, type ExtractionMethod, type FailureMode, type FailurePolicy, FallbackAdapter, GoogleAdapter, type IntegrityCheckpoint, type IntegrityConcern, type IntegrityDriftAlert, type IntegritySeverity, type IntegritySignal, type IntegrityVerdict, MAX_EVIDENCE_LENGTH, MIN_WINDOW_SIZE, OpenAIAdapter, type PromptInput, type ProviderAdapter, REGISTRATION_ID_PREFIX, type RecommendedAction, type SessionBoundary, TRUNCATION_HEAD_RATIO, TRUNCATION_TAIL_RATIO, WEBHOOK_MAX_RETRIES, WEBHOOK_RETRY_DELAYS_MS, type WindowConfig, WindowManager, type WindowMode, type WindowPosition, type WindowState, type WindowSummary, buildConsciencePrompt, buildSignal, checkIntegrity, createAdapterRegistry, createClient, createDriftState, createWindowState, detectIntegrityDrift, hashThinkingBlock, mapVerdictToAction, mapVerdictToProceed, signPayload, summarizeCard, validateAgreement, verifySignature };
package/dist/index.d.ts CHANGED
@@ -437,6 +437,8 @@ interface AnalysisLLMConfig {
437
437
  api_key: string;
438
438
  /** Maximum tokens for the analysis response */
439
439
  max_tokens: number;
440
+ /** Enable Anthropic prompt caching on system prompt. Default: false. */
441
+ enable_prompt_caching?: boolean;
440
442
  }
441
443
  /**
442
444
  * Optional callback functions for SDK signal delivery.
@@ -1029,9 +1031,21 @@ declare const DEFAULT_CONSCIENCE_VALUES: readonly [{
1029
1031
  readonly id: "fear-sycophancy";
1030
1032
  readonly content: "Risk of agreeing with the user to avoid conflict rather than providing honest assessment";
1031
1033
  }];
1034
+ /** Window configuration for EU compliance — extended retention and fail-closed. */
1035
+ declare const EU_COMPLIANCE_WINDOW_CONFIG: {
1036
+ readonly max_size: 10;
1037
+ readonly mode: "sliding";
1038
+ readonly session_boundary: "reset";
1039
+ readonly max_age_seconds: 7200;
1040
+ };
1041
+ /** Failure policy for EU compliance — fail closed with extended timeout. */
1042
+ declare const EU_COMPLIANCE_FAILURE_POLICY: {
1043
+ readonly mode: "fail_closed";
1044
+ readonly analysis_timeout_ms: 15000;
1045
+ };
1032
1046
  /** ID prefixes for protocol entities. */
1033
1047
  declare const CHECKPOINT_ID_PREFIX = "ic-";
1034
1048
  declare const DRIFT_ALERT_ID_PREFIX = "ida-";
1035
1049
  declare const REGISTRATION_ID_PREFIX = "reg-";
1036
1050
 
1037
- export { type AIPCallbacks, type AIPClient, type AIPConfig, AIP_CONTENT_TYPE, AIP_SIGNATURE_HEADER, AIP_VERSION, AIP_VERSION_HEADER, ALGORITHM_VERSION, type AdapterRegistry, type AlignmentCard, type AlignmentCardValue, type AnalysisLLMConfig, type AnalysisMetadata, AnthropicAdapter, type AutonomyEnvelope, type BuiltPrompt, CHECKPOINT_ID_PREFIX, CONFIDENCE_EXPLICIT, CONFIDENCE_FALLBACK, CONFIDENCE_NATIVE, type CardConscienceAgreement, type CardConscienceAugmentation, type CardConscienceConflict, type CheckIntegrityInput, type ConcernCategory, type ConscienceContext, type ConscienceValue, type ConscienceValueType, type ConsultationDepth, DEFAULT_ANALYSIS_MAX_TOKENS, DEFAULT_ANALYSIS_TIMEOUT_MS, DEFAULT_CONSCIENCE_VALUES, DEFAULT_SUSTAINED_CHECKS_THRESHOLD, DEFAULT_THINKING_TOKEN_BUDGET, DEFAULT_WINDOW_MAX_AGE_SECONDS, DEFAULT_WINDOW_MAX_SIZE, DRIFT_ALERT_ID_PREFIX, DRIFT_SEVERITY_LOW_THRESHOLD, DRIFT_SEVERITY_MEDIUM_THRESHOLD, type DriftDirection, type DriftState, type EscalationTrigger, type ExtractedThinking, type ExtractionMethod, type FailureMode, type FailurePolicy, FallbackAdapter, GoogleAdapter, type IntegrityCheckpoint, type IntegrityConcern, type IntegrityDriftAlert, type IntegritySeverity, type IntegritySignal, type IntegrityVerdict, MAX_EVIDENCE_LENGTH, MIN_WINDOW_SIZE, OpenAIAdapter, type PromptInput, type ProviderAdapter, REGISTRATION_ID_PREFIX, type RecommendedAction, type SessionBoundary, TRUNCATION_HEAD_RATIO, TRUNCATION_TAIL_RATIO, WEBHOOK_MAX_RETRIES, WEBHOOK_RETRY_DELAYS_MS, type WindowConfig, WindowManager, type WindowMode, type WindowPosition, type WindowState, type WindowSummary, buildConsciencePrompt, buildSignal, checkIntegrity, createAdapterRegistry, createClient, createDriftState, createWindowState, detectIntegrityDrift, hashThinkingBlock, mapVerdictToAction, mapVerdictToProceed, signPayload, summarizeCard, validateAgreement, verifySignature };
1051
+ export { type AIPCallbacks, type AIPClient, type AIPConfig, AIP_CONTENT_TYPE, AIP_SIGNATURE_HEADER, AIP_VERSION, AIP_VERSION_HEADER, ALGORITHM_VERSION, type AdapterRegistry, type AlignmentCard, type AlignmentCardValue, type AnalysisLLMConfig, type AnalysisMetadata, AnthropicAdapter, type AutonomyEnvelope, type BuiltPrompt, CHECKPOINT_ID_PREFIX, CONFIDENCE_EXPLICIT, CONFIDENCE_FALLBACK, CONFIDENCE_NATIVE, type CardConscienceAgreement, type CardConscienceAugmentation, type CardConscienceConflict, type CheckIntegrityInput, type ConcernCategory, type ConscienceContext, type ConscienceValue, type ConscienceValueType, type ConsultationDepth, DEFAULT_ANALYSIS_MAX_TOKENS, DEFAULT_ANALYSIS_TIMEOUT_MS, DEFAULT_CONSCIENCE_VALUES, DEFAULT_SUSTAINED_CHECKS_THRESHOLD, DEFAULT_THINKING_TOKEN_BUDGET, DEFAULT_WINDOW_MAX_AGE_SECONDS, DEFAULT_WINDOW_MAX_SIZE, DRIFT_ALERT_ID_PREFIX, DRIFT_SEVERITY_LOW_THRESHOLD, DRIFT_SEVERITY_MEDIUM_THRESHOLD, type DriftDirection, type DriftState, EU_COMPLIANCE_FAILURE_POLICY, EU_COMPLIANCE_WINDOW_CONFIG, type EscalationTrigger, type ExtractedThinking, type ExtractionMethod, type FailureMode, type FailurePolicy, FallbackAdapter, GoogleAdapter, type IntegrityCheckpoint, type IntegrityConcern, type IntegrityDriftAlert, type IntegritySeverity, type IntegritySignal, type IntegrityVerdict, MAX_EVIDENCE_LENGTH, MIN_WINDOW_SIZE, OpenAIAdapter, type PromptInput, type ProviderAdapter, REGISTRATION_ID_PREFIX, type RecommendedAction, type SessionBoundary, TRUNCATION_HEAD_RATIO, TRUNCATION_TAIL_RATIO, WEBHOOK_MAX_RETRIES, WEBHOOK_RETRY_DELAYS_MS, type WindowConfig, WindowManager, type WindowMode, type WindowPosition, type WindowState, type WindowSummary, buildConsciencePrompt, buildSignal, checkIntegrity, createAdapterRegistry, createClient, createDriftState, createWindowState, detectIntegrityDrift, hashThinkingBlock, mapVerdictToAction, mapVerdictToProceed, signPayload, summarizeCard, validateAgreement, verifySignature };
package/dist/index.js CHANGED
@@ -89,6 +89,16 @@ var DEFAULT_CONSCIENCE_VALUES = [
89
89
  content: "Risk of agreeing with the user to avoid conflict rather than providing honest assessment"
90
90
  }
91
91
  ];
92
+ var EU_COMPLIANCE_WINDOW_CONFIG = {
93
+ max_size: 10,
94
+ mode: "sliding",
95
+ session_boundary: "reset",
96
+ max_age_seconds: 7200
97
+ };
98
+ var EU_COMPLIANCE_FAILURE_POLICY = {
99
+ mode: "fail_closed",
100
+ analysis_timeout_ms: 15e3
101
+ };
92
102
  var CHECKPOINT_ID_PREFIX = "ic-";
93
103
  var DRIFT_ALERT_ID_PREFIX = "ida-";
94
104
  var REGISTRATION_ID_PREFIX = "reg-";
@@ -1144,9 +1154,14 @@ function validateConscienceContext(value) {
1144
1154
  };
1145
1155
  }
1146
1156
  function checkIntegrity(input) {
1157
+ let jsonText = input.analysisResponse;
1158
+ const jsonMatch = jsonText.match(/\{[\s\S]*\}/);
1159
+ if (jsonMatch) {
1160
+ jsonText = jsonMatch[0];
1161
+ }
1147
1162
  let parsed;
1148
1163
  try {
1149
- parsed = JSON.parse(input.analysisResponse);
1164
+ parsed = JSON.parse(jsonText);
1150
1165
  } catch {
1151
1166
  throw new Error(
1152
1167
  `Failed to parse analysis response as JSON: ${input.analysisResponse.slice(0, 100)}`
@@ -1440,6 +1455,7 @@ async function callAnalysisLLM(llmConfig, system, user, timeoutMs) {
1440
1455
  const controller = new AbortController();
1441
1456
  const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
1442
1457
  try {
1458
+ const systemPayload = llmConfig.enable_prompt_caching ? [{ type: "text", text: system, cache_control: { type: "ephemeral" } }] : system;
1443
1459
  const response = await fetch(`${llmConfig.base_url}/v1/messages`, {
1444
1460
  method: "POST",
1445
1461
  headers: {
@@ -1450,7 +1466,7 @@ async function callAnalysisLLM(llmConfig, system, user, timeoutMs) {
1450
1466
  body: JSON.stringify({
1451
1467
  model: llmConfig.model,
1452
1468
  max_tokens: llmConfig.max_tokens,
1453
- system,
1469
+ system: systemPayload,
1454
1470
  messages: [{ role: "user", content: user }]
1455
1471
  }),
1456
1472
  signal: controller.signal
@@ -1533,6 +1549,6 @@ function constantTimeEqual(a, b) {
1533
1549
  return result === 0;
1534
1550
  }
1535
1551
 
1536
- export { AIP_CONTENT_TYPE, AIP_SIGNATURE_HEADER, AIP_VERSION, AIP_VERSION_HEADER, ALGORITHM_VERSION, AnthropicAdapter, CHECKPOINT_ID_PREFIX, CONFIDENCE_EXPLICIT, CONFIDENCE_FALLBACK, CONFIDENCE_NATIVE, DEFAULT_ANALYSIS_MAX_TOKENS, DEFAULT_ANALYSIS_TIMEOUT_MS, DEFAULT_CONSCIENCE_VALUES, DEFAULT_SUSTAINED_CHECKS_THRESHOLD, DEFAULT_THINKING_TOKEN_BUDGET, DEFAULT_WINDOW_MAX_AGE_SECONDS, DEFAULT_WINDOW_MAX_SIZE, DRIFT_ALERT_ID_PREFIX, DRIFT_SEVERITY_LOW_THRESHOLD, DRIFT_SEVERITY_MEDIUM_THRESHOLD, FallbackAdapter, GoogleAdapter, MAX_EVIDENCE_LENGTH, MIN_WINDOW_SIZE, OpenAIAdapter, REGISTRATION_ID_PREFIX, TRUNCATION_HEAD_RATIO, TRUNCATION_TAIL_RATIO, WEBHOOK_MAX_RETRIES, WEBHOOK_RETRY_DELAYS_MS, WindowManager, buildConsciencePrompt, buildSignal, checkIntegrity, createAdapterRegistry, createClient, createDriftState, createWindowState, detectIntegrityDrift, hashThinkingBlock, mapVerdictToAction, mapVerdictToProceed, signPayload, summarizeCard, validateAgreement, verifySignature };
1552
+ export { AIP_CONTENT_TYPE, AIP_SIGNATURE_HEADER, AIP_VERSION, AIP_VERSION_HEADER, ALGORITHM_VERSION, AnthropicAdapter, CHECKPOINT_ID_PREFIX, CONFIDENCE_EXPLICIT, CONFIDENCE_FALLBACK, CONFIDENCE_NATIVE, DEFAULT_ANALYSIS_MAX_TOKENS, DEFAULT_ANALYSIS_TIMEOUT_MS, DEFAULT_CONSCIENCE_VALUES, DEFAULT_SUSTAINED_CHECKS_THRESHOLD, DEFAULT_THINKING_TOKEN_BUDGET, DEFAULT_WINDOW_MAX_AGE_SECONDS, DEFAULT_WINDOW_MAX_SIZE, DRIFT_ALERT_ID_PREFIX, DRIFT_SEVERITY_LOW_THRESHOLD, DRIFT_SEVERITY_MEDIUM_THRESHOLD, EU_COMPLIANCE_FAILURE_POLICY, EU_COMPLIANCE_WINDOW_CONFIG, FallbackAdapter, GoogleAdapter, MAX_EVIDENCE_LENGTH, MIN_WINDOW_SIZE, OpenAIAdapter, REGISTRATION_ID_PREFIX, TRUNCATION_HEAD_RATIO, TRUNCATION_TAIL_RATIO, WEBHOOK_MAX_RETRIES, WEBHOOK_RETRY_DELAYS_MS, WindowManager, buildConsciencePrompt, buildSignal, checkIntegrity, createAdapterRegistry, createClient, createDriftState, createWindowState, detectIntegrityDrift, hashThinkingBlock, mapVerdictToAction, mapVerdictToProceed, signPayload, summarizeCard, validateAgreement, verifySignature };
1537
1553
  //# sourceMappingURL=index.js.map
1538
1554
  //# sourceMappingURL=index.js.map