@kya-os/checkpoint-shared 1.0.0 → 1.2.0
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/CHANGELOG.md +48 -0
- package/dist/beacon-types/index.d.mts +427 -0
- package/dist/beacon-types/index.d.ts +427 -0
- package/dist/beacon-types/index.js +204 -0
- package/dist/beacon-types/index.mjs +191 -0
- package/dist/browser.d.mts +3 -2
- package/dist/browser.d.ts +3 -2
- package/dist/browser.js +1 -2
- package/dist/browser.mjs +1 -2
- package/dist/canonical-signer/index.d.mts +40 -0
- package/dist/canonical-signer/index.d.ts +40 -0
- package/dist/canonical-signer/index.js +186 -0
- package/dist/canonical-signer/index.mjs +175 -0
- package/dist/index.d.mts +581 -93
- package/dist/index.d.ts +581 -93
- package/dist/index.js +323 -136
- package/dist/index.mjs +321 -133
- package/dist/test-fixtures/index.js +0 -2
- package/dist/test-fixtures/index.mjs +0 -2
- package/package.json +14 -3
- package/dist/browser.js.map +0 -1
- package/dist/browser.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/test-fixtures/index.js.map +0 -1
- package/dist/test-fixtures/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -5061,7 +5061,7 @@ var EngineInfoSchema = external_exports.object({
|
|
|
5061
5061
|
buildSha: external_exports.string().optional(),
|
|
5062
5062
|
extras: external_exports.record(external_exports.unknown()).optional()
|
|
5063
5063
|
});
|
|
5064
|
-
var
|
|
5064
|
+
var DetectionDetailSchema = external_exports.object({
|
|
5065
5065
|
// Core fields
|
|
5066
5066
|
/**
|
|
5067
5067
|
* @deprecated Use detectionClass instead. Will be removed in v2.0.0
|
|
@@ -5122,6 +5122,7 @@ var DetectionResultSchema = external_exports.object({
|
|
|
5122
5122
|
* pre-Phase-0.1 SDKs; dashboard treats absence as "legacy SDK." */
|
|
5123
5123
|
engine: EngineInfoSchema.optional()
|
|
5124
5124
|
});
|
|
5125
|
+
var DetectionResultSchema = DetectionDetailSchema;
|
|
5125
5126
|
var DetectionModeSchema = external_exports.enum(["strict", "balanced", "lenient"]);
|
|
5126
5127
|
var CustomRuleSchema = external_exports.object({
|
|
5127
5128
|
id: external_exports.string(),
|
|
@@ -5206,62 +5207,12 @@ var AI_CRAWLER_NAMES = [
|
|
|
5206
5207
|
"amazon bedrock",
|
|
5207
5208
|
"vertex"
|
|
5208
5209
|
];
|
|
5209
|
-
function shouldEnforce(result) {
|
|
5210
|
-
if (result.isAgent || result.isAiCrawler) return true;
|
|
5211
|
-
const name = (result.agentName || result.agent || result.detectedAgent?.name || "").toLowerCase();
|
|
5212
|
-
if (!name) return false;
|
|
5213
|
-
return AI_CRAWLER_NAMES.some((crawler) => name.includes(crawler));
|
|
5214
|
-
}
|
|
5215
5210
|
function isKnownAiCrawler(agentName) {
|
|
5216
5211
|
if (!agentName) return false;
|
|
5217
5212
|
const lower = agentName.toLowerCase();
|
|
5218
5213
|
return AI_CRAWLER_NAMES.some((crawler) => lower.includes(crawler));
|
|
5219
5214
|
}
|
|
5220
5215
|
|
|
5221
|
-
// src/core/enforcement.ts
|
|
5222
|
-
function evaluateEnforcement(result, config = {}) {
|
|
5223
|
-
const {
|
|
5224
|
-
enabled = true,
|
|
5225
|
-
confidenceThreshold = 70,
|
|
5226
|
-
defaultAction = "allow",
|
|
5227
|
-
redirectUrl,
|
|
5228
|
-
allowList = [],
|
|
5229
|
-
denyList = []
|
|
5230
|
-
} = config;
|
|
5231
|
-
if (!enabled) {
|
|
5232
|
-
return { action: "allow", reason: "enforcement_disabled", shouldNotify: false };
|
|
5233
|
-
}
|
|
5234
|
-
if (!shouldEnforce(result)) {
|
|
5235
|
-
return { action: "allow", reason: "not_enforced", shouldNotify: false };
|
|
5236
|
-
}
|
|
5237
|
-
const agentName = result.agentName || result.agent || result.detectedAgent?.name || void 0;
|
|
5238
|
-
if (allowList.length > 0 && agentName) {
|
|
5239
|
-
const lower = agentName.toLowerCase();
|
|
5240
|
-
if (allowList.some((a) => lower.includes(a.toLowerCase()))) {
|
|
5241
|
-
return { action: "allow", reason: "allow_list", shouldNotify: false };
|
|
5242
|
-
}
|
|
5243
|
-
}
|
|
5244
|
-
if (denyList.length > 0 && agentName) {
|
|
5245
|
-
const lower = agentName.toLowerCase();
|
|
5246
|
-
if (denyList.some((d) => lower.includes(d.toLowerCase()))) {
|
|
5247
|
-
return {
|
|
5248
|
-
action: "block",
|
|
5249
|
-
reason: "deny_list",
|
|
5250
|
-
shouldNotify: true
|
|
5251
|
-
};
|
|
5252
|
-
}
|
|
5253
|
-
}
|
|
5254
|
-
if (result.confidence >= confidenceThreshold) {
|
|
5255
|
-
return {
|
|
5256
|
-
action: defaultAction,
|
|
5257
|
-
reason: "threshold",
|
|
5258
|
-
shouldNotify: true,
|
|
5259
|
-
redirectUrl: defaultAction === "redirect" || defaultAction === "instruct" ? redirectUrl : void 0
|
|
5260
|
-
};
|
|
5261
|
-
}
|
|
5262
|
-
return { action: "allow", reason: "below_threshold", shouldNotify: false };
|
|
5263
|
-
}
|
|
5264
|
-
|
|
5265
5216
|
// src/core/agent.ts
|
|
5266
5217
|
var AgentTypeSchema = external_exports.enum([
|
|
5267
5218
|
// OpenAI
|
|
@@ -5292,6 +5243,17 @@ var AgentTypeSchema = external_exports.enum([
|
|
|
5292
5243
|
// Content/Writing AI
|
|
5293
5244
|
"writer",
|
|
5294
5245
|
"jasper",
|
|
5246
|
+
// Additional AI vendors — Engine-Pattern-Codegen-Retirement-1 backfilled
|
|
5247
|
+
// these after the SSOT migration surfaced legacy patterns_generated.rs
|
|
5248
|
+
// entries (xAI Grok, DeepSeek-User/DeepSeekBot, Amazon Q + NovaAct,
|
|
5249
|
+
// KYA Agent) that were never represented in TS. Their patterns lived
|
|
5250
|
+
// only in the retired YAML→Rust pipeline; without these types the
|
|
5251
|
+
// backfilled `KNOWN_AGENT_PATTERNS` entries would have to coerce to
|
|
5252
|
+
// `'unknown'` and lose per-vendor classification downstream.
|
|
5253
|
+
"xai",
|
|
5254
|
+
"deepseek",
|
|
5255
|
+
"amazon",
|
|
5256
|
+
"kya",
|
|
5295
5257
|
// Unknown AI agent
|
|
5296
5258
|
"unknown"
|
|
5297
5259
|
]);
|
|
@@ -5546,7 +5508,11 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5546
5508
|
id: "openai-chatgpt",
|
|
5547
5509
|
type: "openai",
|
|
5548
5510
|
name: "ChatGPT",
|
|
5549
|
-
|
|
5511
|
+
// `OAI-SearchBot` backfilled by Engine-Pattern-Codegen-Retirement-1
|
|
5512
|
+
// after the legacy YAML→Rust path was retired. Previously detected
|
|
5513
|
+
// only via the legacy generator; the new TS SSOT migration would
|
|
5514
|
+
// have silently lost it.
|
|
5515
|
+
patterns: ["ChatGPT-User", "OAI-SearchBot", "gpt-4", "gpt-3.5", "gpt-4-turbo", "gpt-4o"],
|
|
5550
5516
|
headers: {
|
|
5551
5517
|
"X-OpenAI-Assistant": "*"
|
|
5552
5518
|
},
|
|
@@ -5554,6 +5520,32 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5554
5520
|
category: "ai_assistant",
|
|
5555
5521
|
isLegitimate: true
|
|
5556
5522
|
},
|
|
5523
|
+
// GPT-Crawler — distinct from GPTBot (OpenAI's official training crawler);
|
|
5524
|
+
// tracked separately so the classifier can attribute hits to the
|
|
5525
|
+
// right entity. PDM-2 promoted from the INTERACTIVE_AGENT_PATTERNS
|
|
5526
|
+
// supplement.
|
|
5527
|
+
{
|
|
5528
|
+
id: "openai-gpt-crawler",
|
|
5529
|
+
type: "openai",
|
|
5530
|
+
name: "GPT Crawler",
|
|
5531
|
+
patterns: ["GPT-Crawler"],
|
|
5532
|
+
confidence: 0.95,
|
|
5533
|
+
category: "scraper",
|
|
5534
|
+
isLegitimate: true
|
|
5535
|
+
},
|
|
5536
|
+
// OpenAI generic vendor fallback — catches UAs that mention OpenAI
|
|
5537
|
+
// but use an undocumented sub-token (e.g. `OpenAI-Foo/1.0`,
|
|
5538
|
+
// `OpenAI-Web/2.0`). Word-boundary anchored (post-#2599). Lower
|
|
5539
|
+
// confidence than the strict per-token entries above. PDM-2.
|
|
5540
|
+
{
|
|
5541
|
+
id: "openai-generic",
|
|
5542
|
+
type: "openai",
|
|
5543
|
+
name: "OpenAI",
|
|
5544
|
+
patterns: ["OpenAI"],
|
|
5545
|
+
confidence: 0.9,
|
|
5546
|
+
category: "ai_assistant",
|
|
5547
|
+
isLegitimate: true
|
|
5548
|
+
},
|
|
5557
5549
|
// Anthropic — split into interactive assistant vs training crawler.
|
|
5558
5550
|
// The 'anthropic-ai' UA token used to live in this entry's patterns
|
|
5559
5551
|
// alongside 'Claude-Web', which made every anthropic-ai crawler hit
|
|
@@ -5577,6 +5569,18 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5577
5569
|
// was missing, which left ~14 real Claude-User sessions on
|
|
5578
5570
|
// production stamped (bot, …) instead of (ai_agent, ai_assistant).
|
|
5579
5571
|
"Claude-User",
|
|
5572
|
+
// `Claude-SearchBot` and `claude-code` backfilled by
|
|
5573
|
+
// Engine-Pattern-Codegen-Retirement-1 — both were in the retired
|
|
5574
|
+
// YAML→Rust pipeline but never represented in TS. Claude-Code is
|
|
5575
|
+
// Anthropic's CLI agent (this very tool); Claude-SearchBot is
|
|
5576
|
+
// their search-augmented fetcher (parallel to OAI-SearchBot).
|
|
5577
|
+
"Claude-SearchBot",
|
|
5578
|
+
"claude-code",
|
|
5579
|
+
// Engine-Pattern-Codegen-Retirement-1 round 2 (Bugbot #e111d65f):
|
|
5580
|
+
// the retired YAML→Rust pipeline matched both `claude-code` AND
|
|
5581
|
+
// `claude code` (space-separated). Some host wrappers stamp the
|
|
5582
|
+
// tool name with a space; the hyphenated form alone misses them.
|
|
5583
|
+
"claude code",
|
|
5580
5584
|
"claude-3",
|
|
5581
5585
|
"claude-2",
|
|
5582
5586
|
"claude-instant",
|
|
@@ -5609,8 +5613,24 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5609
5613
|
category: "scraper",
|
|
5610
5614
|
isLegitimate: true
|
|
5611
5615
|
},
|
|
5616
|
+
// Anthropic generic vendor fallback — catches UAs that mention
|
|
5617
|
+
// Anthropic but use an undocumented sub-token (e.g. `Anthropic-Web`,
|
|
5618
|
+
// future variants). Word-boundary anchored (post-#2599) — only
|
|
5619
|
+
// matches when `Anthropic` is a standalone token, not embedded in
|
|
5620
|
+
// e.g. `AnthropicAssistant`. Lower confidence than the per-token
|
|
5621
|
+
// entries above. PDM-2 promoted from the INTERACTIVE_AGENT_PATTERNS
|
|
5622
|
+
// supplement.
|
|
5623
|
+
{
|
|
5624
|
+
id: "anthropic-generic",
|
|
5625
|
+
type: "anthropic",
|
|
5626
|
+
name: "Anthropic",
|
|
5627
|
+
patterns: ["Anthropic"],
|
|
5628
|
+
confidence: 0.9,
|
|
5629
|
+
category: "ai_assistant",
|
|
5630
|
+
isLegitimate: true
|
|
5631
|
+
},
|
|
5612
5632
|
// Perplexity (training crawler, distinct from the interactive Perplexity-User
|
|
5613
|
-
// session captured by
|
|
5633
|
+
// session captured by perplexity-user below)
|
|
5614
5634
|
{
|
|
5615
5635
|
id: "perplexity-bot",
|
|
5616
5636
|
type: "perplexity",
|
|
@@ -5620,6 +5640,40 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5620
5640
|
category: "scraper",
|
|
5621
5641
|
isLegitimate: true
|
|
5622
5642
|
},
|
|
5643
|
+
// Interactive Perplexity fetcher — parallel to ChatGPT-User shape;
|
|
5644
|
+
// the assistant pulls a URL on a human's behalf. Distinct from
|
|
5645
|
+
// PerplexityBot (training crawler). PDM-2 promoted this from the
|
|
5646
|
+
// INTERACTIVE_AGENT_PATTERNS supplement that #2599 carved out.
|
|
5647
|
+
{
|
|
5648
|
+
id: "perplexity-user",
|
|
5649
|
+
type: "perplexity",
|
|
5650
|
+
name: "Perplexity",
|
|
5651
|
+
// `Comet` is Perplexity's AI-powered browser; backfilled into the
|
|
5652
|
+
// TS canonical via Engine-Pattern-Codegen-Retirement-1 after the
|
|
5653
|
+
// SSOT consolidation surfaced the gap. Previously detected only by
|
|
5654
|
+
// the legacy YAML→Rust codegen path; `apps/web/scripts/seed-agent-
|
|
5655
|
+
// types-data.ts` listed it as a Perplexity AI detection while
|
|
5656
|
+
// `KNOWN_AGENT_PATTERNS` did not. Now structurally enforced.
|
|
5657
|
+
patterns: ["Perplexity-User", "Perplexity-AI", "Comet"],
|
|
5658
|
+
confidence: 0.95,
|
|
5659
|
+
category: "ai_assistant",
|
|
5660
|
+
isLegitimate: true
|
|
5661
|
+
},
|
|
5662
|
+
// Perplexity generic vendor fallback — catches UAs that mention
|
|
5663
|
+
// Perplexity but use an undocumented sub-token (future variants).
|
|
5664
|
+
// Lower confidence than the strict per-token entries above; the
|
|
5665
|
+
// matcher picks the highest-confidence match, so this only wins on
|
|
5666
|
+
// truly unknown shapes. Word-boundary anchored (post-#2599) so
|
|
5667
|
+
// `perplexity` only matches as a standalone token, not embedded.
|
|
5668
|
+
{
|
|
5669
|
+
id: "perplexity-generic",
|
|
5670
|
+
type: "perplexity",
|
|
5671
|
+
name: "Perplexity",
|
|
5672
|
+
patterns: ["Perplexity"],
|
|
5673
|
+
confidence: 0.85,
|
|
5674
|
+
category: "ai_assistant",
|
|
5675
|
+
isLegitimate: true
|
|
5676
|
+
},
|
|
5623
5677
|
// Google — split into crawler (Google-Extended) vs interactive (Bard, Gemini, etc.) (PR-C)
|
|
5624
5678
|
{
|
|
5625
5679
|
id: "google-extended",
|
|
@@ -5630,45 +5684,81 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5630
5684
|
category: "scraper",
|
|
5631
5685
|
isLegitimate: true
|
|
5632
5686
|
},
|
|
5687
|
+
{
|
|
5688
|
+
// ORDERING NOTE: `gemini-deep-research` MUST appear BEFORE
|
|
5689
|
+
// `google-bard` so the more-specific 'Gemini-Deep-Research'
|
|
5690
|
+
// pattern wins under the engine's first-match-wins iteration over
|
|
5691
|
+
// AI_AGENT_PATTERNS. The legacy YAML→Rust output collapsed all
|
|
5692
|
+
// Google patterns under a single "Google AI" name with identical
|
|
5693
|
+
// confidence (0.90), so shadowing was benign; the SSOT migration
|
|
5694
|
+
// surfaced different names + confidences (0.95 scraper vs 0.90
|
|
5695
|
+
// ai_assistant), making the order load-bearing.
|
|
5696
|
+
//
|
|
5697
|
+
// Google's "Deep Research" training/research crawler — distinct
|
|
5698
|
+
// UA from Bard/Gemini interactive sessions.
|
|
5699
|
+
id: "gemini-deep-research",
|
|
5700
|
+
type: "google",
|
|
5701
|
+
name: "Gemini-Deep-Research",
|
|
5702
|
+
patterns: ["Gemini-Deep-Research", "gemini-deep-research"],
|
|
5703
|
+
confidence: 0.95,
|
|
5704
|
+
category: "scraper",
|
|
5705
|
+
isLegitimate: true
|
|
5706
|
+
},
|
|
5633
5707
|
{
|
|
5634
5708
|
id: "google-bard",
|
|
5635
5709
|
type: "google",
|
|
5636
5710
|
name: "Google Bard",
|
|
5711
|
+
// Engine-Pattern-Codegen-Retirement-1 corrections:
|
|
5712
|
+
// - REMOVED `Google-InspectionTool` from this entry. The legacy
|
|
5713
|
+
// YAML→Rust pipeline classified Google-InspectionTool as a
|
|
5714
|
+
// Googlebot-family search inspection tool (Search Console
|
|
5715
|
+
// verification, structured-data testing), not a Bard/Gemini AI
|
|
5716
|
+
// session. Moved to `NON_AI_PATTERNS` in
|
|
5717
|
+
// `rust/crates/kya-os-engine/src/stages/patterns.rs` under the
|
|
5718
|
+
// `Googlebot` family so classification stays SearchCrawler.
|
|
5719
|
+
// - ADDED `LaMDA` (Google's pre-Bard conversational AI; legacy
|
|
5720
|
+
// YAML had it under Google AI) and `GoogleAgent-Mariner`
|
|
5721
|
+
// (Google's browser-controlling agent product) — both were in
|
|
5722
|
+
// the retired pipeline, never in TS.
|
|
5723
|
+
// - The broad 'gemini' pattern below shadows narrower Gemini-*
|
|
5724
|
+
// UAs under first-match-wins. The Gemini-Deep-Research entry
|
|
5725
|
+
// above must stay ordered first to avoid being shadowed.
|
|
5637
5726
|
patterns: [
|
|
5638
5727
|
"Bard",
|
|
5639
|
-
"Google-InspectionTool",
|
|
5640
5728
|
"gemini",
|
|
5641
5729
|
"gemini-pro",
|
|
5642
5730
|
"gemini-1.5",
|
|
5643
5731
|
"gemini-1.5-pro",
|
|
5644
5732
|
"gemini-ultra",
|
|
5645
5733
|
"palm",
|
|
5646
|
-
"palm2"
|
|
5734
|
+
"palm2",
|
|
5735
|
+
"LaMDA",
|
|
5736
|
+
"GoogleAgent-Mariner"
|
|
5647
5737
|
],
|
|
5648
5738
|
confidence: 0.9,
|
|
5649
5739
|
category: "ai_assistant",
|
|
5650
5740
|
isLegitimate: true
|
|
5651
5741
|
},
|
|
5652
|
-
{
|
|
5653
|
-
// Google's "Deep Research" training/research crawler — distinct UA
|
|
5654
|
-
// from Bard/Gemini interactive sessions. Pattern matches the
|
|
5655
|
-
// canonical 'Gemini-Deep-Research/<version>' UA token; the broad
|
|
5656
|
-
// 'gemini' substring in google-bard would otherwise win and stamp
|
|
5657
|
-
// these crawler hits as ai_assistant.
|
|
5658
|
-
id: "gemini-deep-research",
|
|
5659
|
-
type: "google",
|
|
5660
|
-
name: "Gemini-Deep-Research",
|
|
5661
|
-
patterns: ["Gemini-Deep-Research", "gemini-deep-research"],
|
|
5662
|
-
confidence: 0.95,
|
|
5663
|
-
category: "scraper",
|
|
5664
|
-
isLegitimate: true
|
|
5665
|
-
},
|
|
5666
5742
|
// Microsoft Copilot
|
|
5667
5743
|
{
|
|
5668
5744
|
id: "microsoft-copilot",
|
|
5669
5745
|
type: "microsoft",
|
|
5670
5746
|
name: "Microsoft Copilot",
|
|
5671
|
-
patterns: [
|
|
5747
|
+
patterns: [
|
|
5748
|
+
"copilot",
|
|
5749
|
+
"github-copilot",
|
|
5750
|
+
"microsoft-copilot",
|
|
5751
|
+
// Engine-Pattern-Codegen-Retirement-1 round 2 (Bugbot #89cfb23d):
|
|
5752
|
+
// the retired YAML→Rust pipeline carried `BingPreview/.*ChatGPT`
|
|
5753
|
+
// for Bing Copilot UAs. Without this, BingPreview+ChatGPT UAs hit
|
|
5754
|
+
// the non-AI `BingPreview` Bingbot rule and resolve as SearchBot.
|
|
5755
|
+
// Note: this entry must order BEFORE the Bingbot regex in the
|
|
5756
|
+
// composed table — AI patterns lead, so the dispatch order in
|
|
5757
|
+
// patterns.rs::AI_AGENT_PATTERNS (AI_PATTERNS_FROM_TS then
|
|
5758
|
+
// NON_AI_PATTERNS) preserves the precedence the legacy table
|
|
5759
|
+
// gave Microsoft AI at confidence 0.9.
|
|
5760
|
+
"BingPreview/.*ChatGPT"
|
|
5761
|
+
],
|
|
5672
5762
|
confidence: 0.9,
|
|
5673
5763
|
category: "ai_assistant",
|
|
5674
5764
|
isLegitimate: true
|
|
@@ -5703,7 +5793,12 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5703
5793
|
id: "cohere-bot",
|
|
5704
5794
|
type: "cohere",
|
|
5705
5795
|
name: "CohereBot",
|
|
5706
|
-
|
|
5796
|
+
// Engine-Pattern-Codegen-Retirement-1 round 2 (Bugbot #8007b7a3):
|
|
5797
|
+
// the retired YAML→Rust pipeline matched the literal `CohereBot`
|
|
5798
|
+
// token; without it the UA falls through to the generic-bot
|
|
5799
|
+
// fallback (`bot` substring) and resolves as `Generic Bot` /
|
|
5800
|
+
// OtherBot, losing vendor attribution.
|
|
5801
|
+
patterns: ["cohere-ai", "CohereBot"],
|
|
5707
5802
|
confidence: 0.85,
|
|
5708
5803
|
category: "scraper",
|
|
5709
5804
|
isLegitimate: true
|
|
@@ -5876,6 +5971,86 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5876
5971
|
confidence: 0.8,
|
|
5877
5972
|
category: "ai_assistant",
|
|
5878
5973
|
isLegitimate: true
|
|
5974
|
+
},
|
|
5975
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5976
|
+
// Engine-Pattern-Codegen-Retirement-1 backfills.
|
|
5977
|
+
//
|
|
5978
|
+
// Each entry below was detected by the retired YAML→Rust codegen path
|
|
5979
|
+
// (`patterns_generated.rs`) but never represented in TS. The SSOT
|
|
5980
|
+
// migration would have silently dropped detection for these vendors.
|
|
5981
|
+
// Names + confidences mirror the legacy pipeline so classify_agent /
|
|
5982
|
+
// classify_vendor downstream consumers don't see a behavioral shift.
|
|
5983
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5984
|
+
// xAI Grok — Elon's AI; user-facing assistant + crawler share the
|
|
5985
|
+
// same vendor brand, all routed through this single entry. The
|
|
5986
|
+
// legacy pipeline emitted them under one "xAI Grok" name, so a split
|
|
5987
|
+
// would change downstream classification.
|
|
5988
|
+
{
|
|
5989
|
+
id: "xai-grok",
|
|
5990
|
+
type: "xai",
|
|
5991
|
+
name: "xAI Grok",
|
|
5992
|
+
patterns: ["xAI-Grok", "GrokBot", "Grok-DeepSearch"],
|
|
5993
|
+
confidence: 0.95,
|
|
5994
|
+
category: "ai_assistant",
|
|
5995
|
+
isLegitimate: true
|
|
5996
|
+
},
|
|
5997
|
+
// DeepSeek — split into interactive (DeepSeek-User) and crawler
|
|
5998
|
+
// (DeepSeekBot), parallel to the openai-chatgpt / openai-gptbot
|
|
5999
|
+
// and anthropic-claude / anthropic-claudebot splits.
|
|
6000
|
+
{
|
|
6001
|
+
id: "deepseek-user",
|
|
6002
|
+
type: "deepseek",
|
|
6003
|
+
name: "DeepSeek AI",
|
|
6004
|
+
patterns: ["DeepSeek-User"],
|
|
6005
|
+
confidence: 0.95,
|
|
6006
|
+
category: "ai_assistant",
|
|
6007
|
+
isLegitimate: true
|
|
6008
|
+
},
|
|
6009
|
+
{
|
|
6010
|
+
id: "deepseek-bot",
|
|
6011
|
+
type: "deepseek",
|
|
6012
|
+
name: "DeepSeekBot",
|
|
6013
|
+
patterns: ["DeepSeekBot"],
|
|
6014
|
+
confidence: 0.95,
|
|
6015
|
+
category: "scraper",
|
|
6016
|
+
isLegitimate: true
|
|
6017
|
+
},
|
|
6018
|
+
// Amazon Q + NovaAct — Amazon's AI assistant product family.
|
|
6019
|
+
// NovaAct is the AWS-branded browser-controlling agent (parallel to
|
|
6020
|
+
// Anthropic's Claude-Code, Google's GoogleAgent-Mariner).
|
|
6021
|
+
{
|
|
6022
|
+
id: "amazon-q",
|
|
6023
|
+
type: "amazon",
|
|
6024
|
+
name: "Amazon Q",
|
|
6025
|
+
patterns: ["Amazon-Q", "NovaAct"],
|
|
6026
|
+
confidence: 0.95,
|
|
6027
|
+
category: "ai_assistant",
|
|
6028
|
+
isLegitimate: true
|
|
6029
|
+
},
|
|
6030
|
+
// KYA Agent — our own product family. KYA-Agent/<version> is the
|
|
6031
|
+
// canonical UA; KYA-OS is the umbrella protocol token; KYA-Compute/
|
|
6032
|
+
// is the signed-compute variant. All ai_assistant — none of these
|
|
6033
|
+
// are training crawlers.
|
|
6034
|
+
//
|
|
6035
|
+
// Display name is `'Kya Agent'` (sentence case), NOT `'KYA Agent'`
|
|
6036
|
+
// (brand all-caps). Matches every other consumer's expectation:
|
|
6037
|
+
// `did-verifier.ts` hardcodes `'Kya Agent'` as the display fallback
|
|
6038
|
+
// for did:key / unhumanizable did:web (3 sites), the gateway router
|
|
6039
|
+
// docstring refers to the "Kya Agent" pattern, and the signed-agent
|
|
6040
|
+
// e2e test asserts on `'Kya Agent'` for both the unsigned Tier-3 UA
|
|
6041
|
+
// path and the signed DID-verified path. The prior `'KYA Agent'`
|
|
6042
|
+
// value here was a codegen-source outlier that produced consistent
|
|
6043
|
+
// brand-case-vs-sentence-case drift between Tier 3 emissions (which
|
|
6044
|
+
// read this) and Tier 1 emissions (which use the did-verifier
|
|
6045
|
+
// hardcode). One source of truth, sentence case.
|
|
6046
|
+
{
|
|
6047
|
+
id: "kya-agent",
|
|
6048
|
+
type: "kya",
|
|
6049
|
+
name: "Kya Agent",
|
|
6050
|
+
patterns: ["KYA-Agent/", "KYA-OS", "KYA-Compute/"],
|
|
6051
|
+
confidence: 0.95,
|
|
6052
|
+
category: "ai_assistant",
|
|
6053
|
+
isLegitimate: true
|
|
5879
6054
|
}
|
|
5880
6055
|
];
|
|
5881
6056
|
var CLOUD_PROVIDER_RANGES = {
|
|
@@ -5918,6 +6093,21 @@ var BOT_USER_AGENT_PATTERNS = [
|
|
|
5918
6093
|
/yi(-?[0-9]+b)?/i,
|
|
5919
6094
|
/stablelm/i,
|
|
5920
6095
|
/\bphind\b/i,
|
|
6096
|
+
// `you.com` is detected as a UA SUBSTRING — the pattern is consumed
|
|
6097
|
+
// only by `BOT_USER_AGENT_PATTERNS.some(p => p.test(userAgent))`
|
|
6098
|
+
// (UA context, not URL). CodeQL js/regex/missing-regexp-anchor
|
|
6099
|
+
// speculated about URL misuse on PR #2576; PR #2591's tightened
|
|
6100
|
+
// consuming-class form (`[\s;()]`) introduced a real false-negative
|
|
6101
|
+
// for legit UA shapes containing `/`:
|
|
6102
|
+
// - `you.com/1.0` (You.com bot, version-suffixed)
|
|
6103
|
+
// - `Mozilla/5.0 you.com/bot` (token-with-version)
|
|
6104
|
+
// - `+https://you.com)` (token after URL inside parens)
|
|
6105
|
+
// Cursor caught the regression on PR #2591. Reverting to `\b` —
|
|
6106
|
+
// word-boundary is the correct anchor for UA-substring matching;
|
|
6107
|
+
// the original CodeQL flag is a context-blind false positive (the
|
|
6108
|
+
// codebase does not apply BOT_USER_AGENT_PATTERNS to URL strings).
|
|
6109
|
+
// If CodeQL re-flags, dismiss in the UI as "false positive" with
|
|
6110
|
+
// pointer to this comment.
|
|
5921
6111
|
/\byou\.com\b/i,
|
|
5922
6112
|
/\bneeva\b/i,
|
|
5923
6113
|
/jasper/i,
|
|
@@ -6913,10 +7103,13 @@ var SUSPICIOUS_PATTERNS = {
|
|
|
6913
7103
|
URL_ENCODED: /%[0-9a-f]{2}/i,
|
|
6914
7104
|
BASE64_DATA: /data:[^;]+;base64,/i
|
|
6915
7105
|
};
|
|
7106
|
+
var MAX_PATTERN_INPUT_LENGTH = 4096;
|
|
6916
7107
|
function testPattern(pattern, value) {
|
|
7108
|
+
if (value.length > MAX_PATTERN_INPUT_LENGTH) return false;
|
|
6917
7109
|
return pattern.test(value);
|
|
6918
7110
|
}
|
|
6919
7111
|
function extractMatch(pattern, value) {
|
|
7112
|
+
if (value.length > MAX_PATTERN_INPUT_LENGTH) return null;
|
|
6920
7113
|
const match = value.match(pattern);
|
|
6921
7114
|
return match ? match[1] || match[0] : null;
|
|
6922
7115
|
}
|
|
@@ -9385,6 +9578,10 @@ function getAgentDisplayName(agentType) {
|
|
|
9385
9578
|
"01ai": "01.AI",
|
|
9386
9579
|
writer: "Writer",
|
|
9387
9580
|
jasper: "Jasper",
|
|
9581
|
+
xai: "xAI",
|
|
9582
|
+
deepseek: "DeepSeek",
|
|
9583
|
+
amazon: "Amazon",
|
|
9584
|
+
kya: "KYA",
|
|
9388
9585
|
unknown: "Unknown"
|
|
9389
9586
|
};
|
|
9390
9587
|
return displayNames[agentType] || agentType;
|
|
@@ -11336,62 +11533,6 @@ function createValidationErrorResponse(message, details, meta) {
|
|
|
11336
11533
|
}
|
|
11337
11534
|
|
|
11338
11535
|
// src/utils/verification.ts
|
|
11339
|
-
function mapVerificationMethod(method) {
|
|
11340
|
-
if (!method) return "none";
|
|
11341
|
-
const normalized = method.toLowerCase().trim();
|
|
11342
|
-
switch (normalized) {
|
|
11343
|
-
// Signature-based verification
|
|
11344
|
-
case "signature":
|
|
11345
|
-
case "sig":
|
|
11346
|
-
case "signature_verified":
|
|
11347
|
-
case "http_signature":
|
|
11348
|
-
return "signature";
|
|
11349
|
-
// Pattern-based detection
|
|
11350
|
-
case "pattern":
|
|
11351
|
-
case "useragent":
|
|
11352
|
-
case "user_agent":
|
|
11353
|
-
case "pattern_matching":
|
|
11354
|
-
case "ua_pattern":
|
|
11355
|
-
return "pattern";
|
|
11356
|
-
// Behavioral analysis
|
|
11357
|
-
case "behavioral":
|
|
11358
|
-
case "behavior":
|
|
11359
|
-
case "behavioral_analysis":
|
|
11360
|
-
case "mouse_keyboard":
|
|
11361
|
-
return "behavioral";
|
|
11362
|
-
// Network-based detection
|
|
11363
|
-
case "network":
|
|
11364
|
-
case "ip":
|
|
11365
|
-
case "ip_analysis":
|
|
11366
|
-
case "cloud_provider":
|
|
11367
|
-
return "network";
|
|
11368
|
-
// MCP handshake detection
|
|
11369
|
-
case "mcp_i_handshake":
|
|
11370
|
-
case "mcp":
|
|
11371
|
-
case "handshake":
|
|
11372
|
-
return "mcp_i_handshake";
|
|
11373
|
-
// Error states
|
|
11374
|
-
case "error":
|
|
11375
|
-
case "failed":
|
|
11376
|
-
case "timeout":
|
|
11377
|
-
return "error";
|
|
11378
|
-
// Default fallback
|
|
11379
|
-
default:
|
|
11380
|
-
if (normalized.includes("signature") || normalized.includes("sig")) {
|
|
11381
|
-
return "signature";
|
|
11382
|
-
}
|
|
11383
|
-
if (normalized.includes("pattern") || normalized.includes("ua")) {
|
|
11384
|
-
return "pattern";
|
|
11385
|
-
}
|
|
11386
|
-
if (normalized.includes("behavior") || normalized.includes("mouse")) {
|
|
11387
|
-
return "behavioral";
|
|
11388
|
-
}
|
|
11389
|
-
if (normalized.includes("network") || normalized.includes("ip")) {
|
|
11390
|
-
return "network";
|
|
11391
|
-
}
|
|
11392
|
-
return "none";
|
|
11393
|
-
}
|
|
11394
|
-
}
|
|
11395
11536
|
function getVerificationMethodDescription(method) {
|
|
11396
11537
|
switch (method) {
|
|
11397
11538
|
case "signature":
|
|
@@ -12569,9 +12710,6 @@ var RuleLoader = class _RuleLoader {
|
|
|
12569
12710
|
}
|
|
12570
12711
|
}
|
|
12571
12712
|
};
|
|
12572
|
-
function loadRulesSync() {
|
|
12573
|
-
return RuleLoader.loadSync();
|
|
12574
|
-
}
|
|
12575
12713
|
async function loadRulesAsync(options) {
|
|
12576
12714
|
const loader = RuleLoader.getInstance();
|
|
12577
12715
|
return loader.loadRules(options);
|
|
@@ -13782,6 +13920,58 @@ function base64UrlDecodeToString(s) {
|
|
|
13782
13920
|
return Buffer.from(base64UrlDecodeToBytes(s)).toString("utf-8");
|
|
13783
13921
|
}
|
|
13784
13922
|
|
|
13923
|
+
// src/parsers/jafar.ts
|
|
13924
|
+
var IPV4_CIDR_RE = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\/(?:3[0-2]|[12]?\d)$/;
|
|
13925
|
+
var IPV6_CIDR_RE = /^[0-9a-fA-F:]+\/(?:12[0-8]|1[01]\d|\d{1,2})$/;
|
|
13926
|
+
var HAS_OFFSET_RE = /[zZ]|[+-]\d{2}:?\d{2}$/;
|
|
13927
|
+
var creationTimeSchema = external_exports.string().min(1).transform((raw, ctx) => {
|
|
13928
|
+
const normalized = HAS_OFFSET_RE.test(raw) ? raw : `${raw}Z`;
|
|
13929
|
+
const ms = Date.parse(normalized);
|
|
13930
|
+
if (Number.isNaN(ms)) {
|
|
13931
|
+
ctx.addIssue({
|
|
13932
|
+
code: external_exports.ZodIssueCode.custom,
|
|
13933
|
+
message: `creationTime is not a parseable ISO 8601 timestamp: ${raw}`
|
|
13934
|
+
});
|
|
13935
|
+
return external_exports.NEVER;
|
|
13936
|
+
}
|
|
13937
|
+
return new Date(ms);
|
|
13938
|
+
});
|
|
13939
|
+
var prefixSchema = external_exports.object({
|
|
13940
|
+
ipv4Prefix: external_exports.string().regex(IPV4_CIDR_RE).optional(),
|
|
13941
|
+
ipv6Prefix: external_exports.string().regex(IPV6_CIDR_RE).optional()
|
|
13942
|
+
}).strict().refine((p) => p.ipv4Prefix != null !== (p.ipv6Prefix != null), {
|
|
13943
|
+
message: "prefix entry must have exactly one of ipv4Prefix or ipv6Prefix"
|
|
13944
|
+
});
|
|
13945
|
+
var jafarFeedSchema = external_exports.object({
|
|
13946
|
+
creationTime: creationTimeSchema,
|
|
13947
|
+
prefixes: external_exports.array(prefixSchema),
|
|
13948
|
+
synctoken: external_exports.string().optional(),
|
|
13949
|
+
notes: external_exports.string().optional()
|
|
13950
|
+
}).passthrough();
|
|
13951
|
+
var JafarParseError = class extends Error {
|
|
13952
|
+
constructor(message, cause) {
|
|
13953
|
+
super(message);
|
|
13954
|
+
this.cause = cause;
|
|
13955
|
+
this.name = "JafarParseError";
|
|
13956
|
+
}
|
|
13957
|
+
};
|
|
13958
|
+
function parseJafarFeed(json) {
|
|
13959
|
+
let raw;
|
|
13960
|
+
try {
|
|
13961
|
+
raw = JSON.parse(json);
|
|
13962
|
+
} catch (err) {
|
|
13963
|
+
throw new JafarParseError("JAFAR feed is not valid JSON", err);
|
|
13964
|
+
}
|
|
13965
|
+
const result = jafarFeedSchema.safeParse(raw);
|
|
13966
|
+
if (!result.success) {
|
|
13967
|
+
throw new JafarParseError(
|
|
13968
|
+
`JAFAR feed failed schema validation: ${result.error.message}`,
|
|
13969
|
+
result.error
|
|
13970
|
+
);
|
|
13971
|
+
}
|
|
13972
|
+
return result.data;
|
|
13973
|
+
}
|
|
13974
|
+
|
|
13785
13975
|
// src/index.ts
|
|
13786
13976
|
var VERSION = "0.1.0";
|
|
13787
13977
|
var PACKAGE_NAME = "@kya-os/checkpoint-shared";
|
|
@@ -13993,6 +14183,7 @@ exports.DeployStepStateSchema = DeployStepStateSchema;
|
|
|
13993
14183
|
exports.DeployStepStatusSchema = DeployStepStatusSchema;
|
|
13994
14184
|
exports.DeploymentMetadataSchema = DeploymentMetadataSchema;
|
|
13995
14185
|
exports.DetectionClassSchema = DetectionClassSchema;
|
|
14186
|
+
exports.DetectionDetailSchema = DetectionDetailSchema;
|
|
13996
14187
|
exports.DetectionErrorDetailsSchema = DetectionErrorDetailsSchema;
|
|
13997
14188
|
exports.DetectionEventSchema = DetectionEventSchema;
|
|
13998
14189
|
exports.DetectionInputSchema = DetectionInputSchema;
|
|
@@ -14055,6 +14246,7 @@ exports.IntegrationTypeSchema = IntegrationTypeSchema;
|
|
|
14055
14246
|
exports.InternalProcessingFlagsSchema = InternalProcessingFlagsSchema;
|
|
14056
14247
|
exports.IpRangeCollectionSchema = IpRangeCollectionSchema;
|
|
14057
14248
|
exports.IpRangeRuleSchema = IpRangeRuleSchema;
|
|
14249
|
+
exports.JafarParseError = JafarParseError;
|
|
14058
14250
|
exports.JwsParseError = JwsParseError;
|
|
14059
14251
|
exports.KNOWN_AGENT_PATTERNS = KNOWN_AGENT_PATTERNS;
|
|
14060
14252
|
exports.KeyboardEventSchema = KeyboardEventSchema;
|
|
@@ -14308,7 +14500,6 @@ exports.detectionClassToEnum = detectionClassToEnum;
|
|
|
14308
14500
|
exports.discoveredToolSchema = discoveredToolSchema;
|
|
14309
14501
|
exports.encodeVerdictCookie = encodeVerdictCookie;
|
|
14310
14502
|
exports.enumToDetectionClass = enumToDetectionClass;
|
|
14311
|
-
exports.evaluateEnforcement = evaluateEnforcement;
|
|
14312
14503
|
exports.evaluatePolicy = evaluatePolicy;
|
|
14313
14504
|
exports.extractMatch = extractMatch;
|
|
14314
14505
|
exports.fetchPolicy = fetchPolicy;
|
|
@@ -14354,10 +14545,8 @@ exports.isValidFingerprintResponse = isValidFingerprintResponse;
|
|
|
14354
14545
|
exports.isValidWasmDetectionResult = isValidWasmDetectionResult;
|
|
14355
14546
|
exports.isValidWasmRequestMetadata = isValidWasmRequestMetadata;
|
|
14356
14547
|
exports.loadRulesAsync = loadRulesAsync;
|
|
14357
|
-
exports.loadRulesSync = loadRulesSync;
|
|
14358
14548
|
exports.mapLegacyAuthType = mapLegacyAuthType;
|
|
14359
14549
|
exports.mapToLegacyAuthType = mapToLegacyAuthType;
|
|
14360
|
-
exports.mapVerificationMethod = mapVerificationMethod;
|
|
14361
14550
|
exports.matchPath = matchPath;
|
|
14362
14551
|
exports.mergeWithDefaults = mergeWithDefaults;
|
|
14363
14552
|
exports.migrateLegacyDetectionClass = migrateLegacyDetectionClass;
|
|
@@ -14369,6 +14558,7 @@ exports.normalizeOrganizationName = normalizeOrganizationName;
|
|
|
14369
14558
|
exports.oauthClientSchema = oauthClientSchema;
|
|
14370
14559
|
exports.parseAgentName = parseAgentName;
|
|
14371
14560
|
exports.parseEvaluationContext = parseEvaluationContext;
|
|
14561
|
+
exports.parseJafarFeed = parseJafarFeed;
|
|
14372
14562
|
exports.parseJwsCompact = parseJwsCompact;
|
|
14373
14563
|
exports.parsePolicyConfig = parsePolicyConfig;
|
|
14374
14564
|
exports.parseRules = parseRules;
|
|
@@ -14380,7 +14570,6 @@ exports.resetPasswordSchema = resetPasswordSchema;
|
|
|
14380
14570
|
exports.resetPolicyFetcher = resetPolicyFetcher;
|
|
14381
14571
|
exports.safeParsePolicyConfig = safeParsePolicyConfig;
|
|
14382
14572
|
exports.safeUrl = safeUrl;
|
|
14383
|
-
exports.shouldEnforce = shouldEnforce;
|
|
14384
14573
|
exports.signInSchema = signInSchema;
|
|
14385
14574
|
exports.signMcpiEnvelope = signMcpiEnvelope;
|
|
14386
14575
|
exports.signUpSchema = signUpSchema;
|
|
@@ -14412,5 +14601,3 @@ exports.vaultResolveResponseSchema = vaultResolveResponseSchema;
|
|
|
14412
14601
|
exports.vaultResolveSuccessSchema = vaultResolveSuccessSchema;
|
|
14413
14602
|
exports.verifyEmailSchema = verifyEmailSchema;
|
|
14414
14603
|
exports.wasmToDetectionResult = wasmToDetectionResult;
|
|
14415
|
-
//# sourceMappingURL=index.js.map
|
|
14416
|
-
//# sourceMappingURL=index.js.map
|