@ik-firewall/core 2.3.5 → 2.3.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
@@ -1496,6 +1496,7 @@ var UsageTracker = class {
1496
1496
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1497
1497
  is_local: model === "local",
1498
1498
  cq_score: params.cqScore,
1499
+ iq_score: params.iqScore,
1499
1500
  clientOrigin: params.clientOrigin,
1500
1501
  trace: params.trace
1501
1502
  });
@@ -1527,8 +1528,14 @@ var UsageTracker = class {
1527
1528
  try {
1528
1529
  await this.sendBatch(payload);
1529
1530
  } catch (error) {
1530
- console.error("[IK_TRACKER] Batch send failed, queuing for retry:", error);
1531
- this.handleFailure(payload);
1531
+ console.error("[IK_TRACKER] Batch send failed:", error.message);
1532
+ const isAuthError = error.message?.includes("401");
1533
+ if (!isAuthError) {
1534
+ console.log("[IK_TRACKER] Queuing for retry...");
1535
+ this.handleFailure(payload);
1536
+ } else {
1537
+ console.warn("[IK_TRACKER] Unauthorized: Please check your IK_FIREWALL_SECRET and License Key. Discarding batch.");
1538
+ }
1532
1539
  } finally {
1533
1540
  this.flushInProgress = false;
1534
1541
  }
@@ -1537,6 +1544,9 @@ var UsageTracker = class {
1537
1544
  const baseUrl = this.config.get("centralReportEndpoint") || "https://ik-firewall.vercel.app";
1538
1545
  const endpoint = `${baseUrl.replace(/\/$/, "")}/api/v1/report`;
1539
1546
  const hmacSecret = this.config.get("hmacSecret") || process.env.IK_FIREWALL_SECRET;
1547
+ if (process.env.IK_FIREWALL_DISABLED === "true" || process.env.NEXT_PUBLIC_IK_FIREWALL_DISABLED === "true") {
1548
+ return;
1549
+ }
1540
1550
  if (hmacSecret) {
1541
1551
  try {
1542
1552
  const crypto = typeof window === "undefined" ? (await import("crypto")).default : null;
@@ -1982,6 +1992,9 @@ var IKFirewallCore = class _IKFirewallCore {
1982
1992
  gatekeeperFlag: "LOCAL_HEURISTIC_SKIP",
1983
1993
  semanticProof: 1,
1984
1994
  cognitiveKinetic: 0.8,
1995
+ cqScore: Math.min(10, dm * 6 + ei * 4),
1996
+ requiredIQTier: dm > 2 ? "TIER_2" : "TIER_1",
1997
+ routingPath: "HEURISTIC_LOCAL",
1985
1998
  toneVector: {
1986
1999
  abstraction: _IKFirewallCore.CONSTANTS.TONE.STABLE_VAL,
1987
2000
  directness: _IKFirewallCore.CONSTANTS.TONE.STABLE_VAL,
@@ -2078,8 +2091,8 @@ var IKFirewallCore = class _IKFirewallCore {
2078
2091
  redundancyRatio,
2079
2092
  gatekeeperFlag,
2080
2093
  rawAuditResponse: response.content,
2081
- requiredIQTier: insights.required_iq_tier || "TIER_1",
2082
- routingReason: insights.routing_reason || "Standard load analysis.",
2094
+ requiredIQTier: insights.required_iq_tier || insights.requiredIQTier || "TIER_1",
2095
+ routingReason: insights.routing_reason || insights.routingReason || "Standard load analysis.",
2083
2096
  archetype: insights.archetype || "DYNAMIC",
2084
2097
  ambiguityTolerance: insights.ambiguity_tolerance || 0.5,
2085
2098
  logicalFocus: insights.logicalFocus,
@@ -2159,6 +2172,9 @@ Any action outside this scope MUST be rejected and flagged as a boundary violati
2159
2172
  "toneVector": { "abstraction": 0.1, "directness": 0.1, "density": 0.1 },
2160
2173
  "kft": "number 1-10",
2161
2174
  "opt": "number 1-10",
2175
+ "required_iq_tier": "TIER_1" | "TIER_2" | "TIER_3",
2176
+ "cqScore": 0.0-10.0,
2177
+ "routing_reason": "string",
2162
2178
  "approach": { "category": "REFLECTIVE" | "NARRATIVE" | "PROBLEM_ORIENTED" | "DIRECTIVE" | "ARGUMENTATIVE" | "DIALOGICAL", "subtype": "string" },
2163
2179
  "logicalFocus": "string",
2164
2180
  "detectedLanguage": "string"
package/dist/index.d.cts CHANGED
@@ -162,6 +162,7 @@ interface UsageData {
162
162
  timestamp: string;
163
163
  is_local: boolean;
164
164
  cq_score: number;
165
+ iq_score: number;
165
166
  clientOrigin?: string;
166
167
  trace?: any;
167
168
  }
@@ -371,6 +372,7 @@ declare class IKFirewallCore {
371
372
  outputTokens: number;
372
373
  optimizedTokens?: number;
373
374
  cqScore: number;
375
+ iqScore: number;
374
376
  routingPath: string;
375
377
  clientOrigin?: string;
376
378
  trace?: any;
package/dist/index.d.ts CHANGED
@@ -162,6 +162,7 @@ interface UsageData {
162
162
  timestamp: string;
163
163
  is_local: boolean;
164
164
  cq_score: number;
165
+ iq_score: number;
165
166
  clientOrigin?: string;
166
167
  trace?: any;
167
168
  }
@@ -371,6 +372,7 @@ declare class IKFirewallCore {
371
372
  outputTokens: number;
372
373
  optimizedTokens?: number;
373
374
  cqScore: number;
375
+ iqScore: number;
374
376
  routingPath: string;
375
377
  clientOrigin?: string;
376
378
  trace?: any;
package/dist/index.js CHANGED
@@ -1454,6 +1454,7 @@ var UsageTracker = class {
1454
1454
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1455
1455
  is_local: model === "local",
1456
1456
  cq_score: params.cqScore,
1457
+ iq_score: params.iqScore,
1457
1458
  clientOrigin: params.clientOrigin,
1458
1459
  trace: params.trace
1459
1460
  });
@@ -1485,8 +1486,14 @@ var UsageTracker = class {
1485
1486
  try {
1486
1487
  await this.sendBatch(payload);
1487
1488
  } catch (error) {
1488
- console.error("[IK_TRACKER] Batch send failed, queuing for retry:", error);
1489
- this.handleFailure(payload);
1489
+ console.error("[IK_TRACKER] Batch send failed:", error.message);
1490
+ const isAuthError = error.message?.includes("401");
1491
+ if (!isAuthError) {
1492
+ console.log("[IK_TRACKER] Queuing for retry...");
1493
+ this.handleFailure(payload);
1494
+ } else {
1495
+ console.warn("[IK_TRACKER] Unauthorized: Please check your IK_FIREWALL_SECRET and License Key. Discarding batch.");
1496
+ }
1490
1497
  } finally {
1491
1498
  this.flushInProgress = false;
1492
1499
  }
@@ -1495,6 +1502,9 @@ var UsageTracker = class {
1495
1502
  const baseUrl = this.config.get("centralReportEndpoint") || "https://ik-firewall.vercel.app";
1496
1503
  const endpoint = `${baseUrl.replace(/\/$/, "")}/api/v1/report`;
1497
1504
  const hmacSecret = this.config.get("hmacSecret") || process.env.IK_FIREWALL_SECRET;
1505
+ if (process.env.IK_FIREWALL_DISABLED === "true" || process.env.NEXT_PUBLIC_IK_FIREWALL_DISABLED === "true") {
1506
+ return;
1507
+ }
1498
1508
  if (hmacSecret) {
1499
1509
  try {
1500
1510
  const crypto = typeof window === "undefined" ? (await import("crypto")).default : null;
@@ -1940,6 +1950,9 @@ var IKFirewallCore = class _IKFirewallCore {
1940
1950
  gatekeeperFlag: "LOCAL_HEURISTIC_SKIP",
1941
1951
  semanticProof: 1,
1942
1952
  cognitiveKinetic: 0.8,
1953
+ cqScore: Math.min(10, dm * 6 + ei * 4),
1954
+ requiredIQTier: dm > 2 ? "TIER_2" : "TIER_1",
1955
+ routingPath: "HEURISTIC_LOCAL",
1943
1956
  toneVector: {
1944
1957
  abstraction: _IKFirewallCore.CONSTANTS.TONE.STABLE_VAL,
1945
1958
  directness: _IKFirewallCore.CONSTANTS.TONE.STABLE_VAL,
@@ -2036,8 +2049,8 @@ var IKFirewallCore = class _IKFirewallCore {
2036
2049
  redundancyRatio,
2037
2050
  gatekeeperFlag,
2038
2051
  rawAuditResponse: response.content,
2039
- requiredIQTier: insights.required_iq_tier || "TIER_1",
2040
- routingReason: insights.routing_reason || "Standard load analysis.",
2052
+ requiredIQTier: insights.required_iq_tier || insights.requiredIQTier || "TIER_1",
2053
+ routingReason: insights.routing_reason || insights.routingReason || "Standard load analysis.",
2041
2054
  archetype: insights.archetype || "DYNAMIC",
2042
2055
  ambiguityTolerance: insights.ambiguity_tolerance || 0.5,
2043
2056
  logicalFocus: insights.logicalFocus,
@@ -2117,6 +2130,9 @@ Any action outside this scope MUST be rejected and flagged as a boundary violati
2117
2130
  "toneVector": { "abstraction": 0.1, "directness": 0.1, "density": 0.1 },
2118
2131
  "kft": "number 1-10",
2119
2132
  "opt": "number 1-10",
2133
+ "required_iq_tier": "TIER_1" | "TIER_2" | "TIER_3",
2134
+ "cqScore": 0.0-10.0,
2135
+ "routing_reason": "string",
2120
2136
  "approach": { "category": "REFLECTIVE" | "NARRATIVE" | "PROBLEM_ORIENTED" | "DIRECTIVE" | "ARGUMENTATIVE" | "DIALOGICAL", "subtype": "string" },
2121
2137
  "logicalFocus": "string",
2122
2138
  "detectedLanguage": "string"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ik-firewall/core",
3
- "version": "2.3.5",
3
+ "version": "2.3.7",
4
4
  "type": "module",
5
5
  "description": "The core IK Firewall engine for semantic-driven AI optimization.",
6
6
  "main": "./dist/index.js",