sneakoscope 4.2.1 → 4.3.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/README.md +34 -7
- package/crates/sks-core/Cargo.lock +1 -1
- package/crates/sks-core/Cargo.toml +1 -1
- package/crates/sks-core/src/main.rs +1 -1
- package/dist/bin/sks.js +1 -1
- package/dist/cli/command-registry.js +3 -1
- package/dist/cli/ultra-search-command.js +163 -0
- package/dist/cli/xai-command.js +28 -168
- package/dist/core/agents/agent-codex-cockpit.js +3 -3
- package/dist/core/agents/agent-runner-ollama.js +2 -0
- package/dist/core/agents/agent-wrongness.js +1 -1
- package/dist/core/agents/native-worker-backend-router.js +3 -0
- package/dist/core/bench.js +115 -0
- package/dist/core/code-structure.js +399 -11
- package/dist/core/codex-control/codex-fake-sdk-adapter.js +67 -9
- package/dist/core/codex-control/gpt-final-arbiter.js +4 -1
- package/dist/core/codex-control/gpt-final-review-schema.js +58 -0
- package/dist/core/codex-native/core-skill-manifest.js +23 -0
- package/dist/core/commands/bench-command.js +11 -2
- package/dist/core/commands/code-structure-command.js +34 -2
- package/dist/core/commands/run-command.js +92 -2
- package/dist/core/commands/seo-command.js +130 -0
- package/dist/core/feature-fixtures.js +6 -0
- package/dist/core/feature-registry.js +3 -1
- package/dist/core/fsx.js +1 -1
- package/dist/core/hooks-runtime.js +8 -0
- package/dist/core/init.js +8 -6
- package/dist/core/lean-engineering-policy.js +159 -0
- package/dist/core/pipeline-internals/runtime-core.js +15 -5
- package/dist/core/proof/auto-finalize.js +3 -2
- package/dist/core/proof/proof-schema.js +2 -1
- package/dist/core/proof/proof-writer.js +1 -0
- package/dist/core/proof/route-adapter.js +4 -2
- package/dist/core/proof/route-finalizer.js +35 -3
- package/dist/core/release-parallel-full-coverage.js +1 -1
- package/dist/core/routes.js +77 -10
- package/dist/core/search-visibility/adapter-registry.js +26 -0
- package/dist/core/search-visibility/adapters/next-app.js +6 -0
- package/dist/core/search-visibility/adapters/next-pages.js +6 -0
- package/dist/core/search-visibility/adapters/static-site.js +6 -0
- package/dist/core/search-visibility/analyzers.js +377 -0
- package/dist/core/search-visibility/artifacts.js +183 -0
- package/dist/core/search-visibility/discovery.js +347 -0
- package/dist/core/search-visibility/index.js +199 -0
- package/dist/core/search-visibility/mission.js +67 -0
- package/dist/core/search-visibility/mutation.js +314 -0
- package/dist/core/search-visibility/types.js +2 -0
- package/dist/core/search-visibility/verifier.js +60 -0
- package/dist/core/source-intelligence/source-intelligence-policy.js +45 -26
- package/dist/core/source-intelligence/source-intelligence-proof.js +10 -16
- package/dist/core/source-intelligence/source-intelligence-runner.js +56 -42
- package/dist/core/trust-kernel/trust-report.js +3 -5
- package/dist/core/ultra-search/index.js +3 -0
- package/dist/core/ultra-search/runtime.js +502 -0
- package/dist/core/ultra-search/types.js +3 -0
- package/dist/core/version.js +1 -1
- package/dist/scripts/agent-visual-consistency-check.js +1 -1
- package/dist/scripts/check-architecture.js +40 -7
- package/dist/scripts/check-command-module-budget.js +43 -5
- package/dist/scripts/check-pipeline-budget.js +17 -30
- package/dist/scripts/check-publish-tag.js +33 -6
- package/dist/scripts/check-route-modularity.js +25 -33
- package/dist/scripts/check-runtime-schemas.js +22 -0
- package/dist/scripts/core-skill-immutable-sync-check.js +3 -2
- package/dist/scripts/core-skill-integrity-blackbox.js +3 -2
- package/dist/scripts/core-skill-manifest-check.js +7 -2
- package/dist/scripts/geo-claim-evidence-check.js +18 -0
- package/dist/scripts/geo-cli-blackbox-check.js +18 -0
- package/dist/scripts/geo-crawler-policy-check.js +16 -0
- package/dist/scripts/geo-llms-txt-optional-check.js +19 -0
- package/dist/scripts/gpt-final-arbiter-check.js +4 -1
- package/dist/scripts/release-metadata-1-19-check.js +2 -2
- package/dist/scripts/release-parallel-check.js +17 -2
- package/dist/scripts/release-parallel-full-coverage-check.js +1 -1
- package/dist/scripts/release-readiness-report.js +6 -6
- package/dist/scripts/release-registry-check.js +33 -14
- package/dist/scripts/search-visibility-gate-lib.js +124 -0
- package/dist/scripts/seo-audit-fixture-check.js +16 -0
- package/dist/scripts/seo-canonical-locale-check.js +19 -0
- package/dist/scripts/seo-cli-blackbox-check.js +18 -0
- package/dist/scripts/seo-geo-feature-fixture-quality-check.js +18 -0
- package/dist/scripts/seo-geo-geo-disambiguation-check.js +12 -0
- package/dist/scripts/seo-geo-no-unsupported-ranking-claims-check.js +18 -0
- package/dist/scripts/seo-geo-route-identity-check.js +12 -0
- package/dist/scripts/seo-geo-skill-rich-content-check.js +22 -0
- package/dist/scripts/seo-mutation-rollback-check.js +23 -0
- package/dist/scripts/seo-no-mutation-by-default-check.js +17 -0
- package/dist/scripts/seo-structured-data-visible-content-check.js +19 -0
- package/dist/scripts/sks-1-18-gate-lib.js +2 -2
- package/dist/scripts/sks-3-1-5-directive-check-lib.js +10 -1
- package/dist/scripts/source-intelligence-all-modes-check.js +9 -19
- package/dist/scripts/source-intelligence-policy-check.js +6 -6
- package/dist/scripts/ultra-search-provider-interface-check.js +27 -0
- package/package.json +21 -3
- package/schemas/search-visibility/finding-ledger.schema.json +36 -0
- package/schemas/search-visibility/gate.schema.json +22 -0
- package/schemas/search-visibility/mutation-plan.schema.json +27 -0
- package/schemas/search-visibility/site-inventory.schema.json +21 -0
- package/schemas/search-visibility/verification-report.schema.json +23 -0
- package/dist/core/mcp/xai-mcp-detector.js +0 -157
- package/dist/core/mcp/xai-search-adapter.js +0 -100
- package/dist/scripts/xai-mcp-capability-check.js +0 -14
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sneakoscope",
|
|
3
3
|
"displayName": "ㅅㅋㅅ",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.0",
|
|
5
5
|
"description": "Sneakoscope Codex: fast proof-first Codex trust layer with image-based Voxel TriWiki.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"homepage": "https://github.com/mandarange/Sneakoscope-Codex#readme",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public",
|
|
21
21
|
"registry": "https://registry.npmjs.org/",
|
|
22
|
-
"tag": "
|
|
22
|
+
"tag": "backfill-4-3"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
@@ -68,6 +68,21 @@
|
|
|
68
68
|
"typescript:migration-report": "node ./dist/scripts/typescript-migration-report.js",
|
|
69
69
|
"typecheck:contracts": "node ./dist/scripts/check-ts-contracts.js",
|
|
70
70
|
"schema:check": "node ./dist/scripts/check-runtime-schemas.js",
|
|
71
|
+
"seo:cli-blackbox": "node ./dist/scripts/seo-cli-blackbox-check.js",
|
|
72
|
+
"seo:audit-fixture": "node ./dist/scripts/seo-audit-fixture-check.js",
|
|
73
|
+
"seo:no-mutation-by-default": "node ./dist/scripts/seo-no-mutation-by-default-check.js",
|
|
74
|
+
"seo:mutation-rollback": "node ./dist/scripts/seo-mutation-rollback-check.js",
|
|
75
|
+
"seo:canonical-sitemap-locale": "node ./dist/scripts/seo-canonical-locale-check.js",
|
|
76
|
+
"seo:structured-data-visible-content": "node ./dist/scripts/seo-structured-data-visible-content-check.js",
|
|
77
|
+
"geo:cli-blackbox": "node ./dist/scripts/geo-cli-blackbox-check.js",
|
|
78
|
+
"geo:claim-evidence": "node ./dist/scripts/geo-claim-evidence-check.js",
|
|
79
|
+
"geo:crawler-purpose-policy": "node ./dist/scripts/geo-crawler-policy-check.js",
|
|
80
|
+
"geo:llms-txt-optional": "node ./dist/scripts/geo-llms-txt-optional-check.js",
|
|
81
|
+
"seo-geo:route-identity": "node ./dist/scripts/seo-geo-route-identity-check.js",
|
|
82
|
+
"seo-geo:geo-disambiguation": "node ./dist/scripts/seo-geo-geo-disambiguation-check.js",
|
|
83
|
+
"seo-geo:skill-rich-content": "node ./dist/scripts/seo-geo-skill-rich-content-check.js",
|
|
84
|
+
"seo-geo:no-unsupported-ranking-claims": "node ./dist/scripts/seo-geo-no-unsupported-ranking-claims-check.js",
|
|
85
|
+
"seo-geo:feature-fixture-quality": "node ./dist/scripts/seo-geo-feature-fixture-quality-check.js",
|
|
71
86
|
"package-boundary:check": "node ./dist/scripts/check-package-boundary.js",
|
|
72
87
|
"blackbox:command-import-smoke": "node ./dist/scripts/blackbox-command-import-smoke.js",
|
|
73
88
|
"repo-audit": "node ./dist/scripts/repo-audit.js",
|
|
@@ -476,12 +491,12 @@
|
|
|
476
491
|
"qa:native-agent-backend": "node ./dist/scripts/agent-native-release-gate.js qa-native-agent-backend",
|
|
477
492
|
"agent:non-recursive-pipeline-report": "node ./dist/scripts/non-recursive-pipeline-check.js --json",
|
|
478
493
|
"agent:legacy-multiagent-removed": "node ./dist/scripts/legacy-multiagent-removal-check.js",
|
|
479
|
-
"xai-mcp:capability": "node ./dist/scripts/xai-mcp-capability-check.js",
|
|
480
494
|
"mcp:0.134-modernization": "node ./dist/scripts/mcp-0-134-modernization-check.js",
|
|
481
495
|
"mcp:readonly-concurrency": "node ./dist/scripts/mcp-readonly-concurrency-check.js",
|
|
482
496
|
"mcp:readonly-runtime-scheduler": "node ./dist/scripts/mcp-readonly-runtime-scheduler-check.js",
|
|
483
497
|
"codex:0.134-runner-truth": "node ./dist/scripts/codex-0-134-runner-truth-check.js",
|
|
484
498
|
"source-intelligence:policy": "node ./dist/scripts/source-intelligence-policy-check.js",
|
|
499
|
+
"ultra-search:provider-interface": "node ./dist/scripts/ultra-search-provider-interface-check.js",
|
|
485
500
|
"context7:evidence-dedupe": "node ./dist/scripts/context7-evidence-dedupe-check.js",
|
|
486
501
|
"source-intelligence:codex-history-search": "node ./dist/scripts/codex-history-search-check.js",
|
|
487
502
|
"source-intelligence:all-modes": "node ./dist/scripts/source-intelligence-all-modes-check.js",
|
|
@@ -1082,6 +1097,9 @@
|
|
|
1082
1097
|
"goal",
|
|
1083
1098
|
"research",
|
|
1084
1099
|
"autoresearch",
|
|
1100
|
+
"seo",
|
|
1101
|
+
"search-visibility",
|
|
1102
|
+
"generative-engine-optimization",
|
|
1085
1103
|
"honest-mode",
|
|
1086
1104
|
"update-check",
|
|
1087
1105
|
"llm-wiki",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://sneakoscope.dev/schemas/search-visibility/finding-ledger.schema.json",
|
|
4
|
+
"title": "SKS Search Visibility Finding Ledger",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schema", "mission_id", "route", "findings", "counts"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schema": { "enum": ["sks.search-visibility.seo-findings.v1", "sks.search-visibility.geo-findings.v1"] },
|
|
9
|
+
"mission_id": { "type": "string" },
|
|
10
|
+
"route": { "const": "$SEO-GEO-OPTIMIZER" },
|
|
11
|
+
"findings": {
|
|
12
|
+
"type": "array",
|
|
13
|
+
"items": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"required": ["id", "ruleId", "domain", "category", "severity", "confidence", "blocking", "summary", "evidence", "affected", "remediation", "autoFixable"],
|
|
16
|
+
"properties": {
|
|
17
|
+
"id": { "type": "string" },
|
|
18
|
+
"ruleId": { "type": "string" },
|
|
19
|
+
"domain": { "enum": ["seo", "geo", "shared"] },
|
|
20
|
+
"category": { "type": "string" },
|
|
21
|
+
"severity": { "enum": ["info", "low", "medium", "high", "critical"] },
|
|
22
|
+
"confidence": { "type": "number" },
|
|
23
|
+
"blocking": { "type": "boolean" },
|
|
24
|
+
"summary": { "type": "string" },
|
|
25
|
+
"evidence": { "type": "array", "minItems": 1 },
|
|
26
|
+
"affected": { "type": "array" },
|
|
27
|
+
"remediation": { "type": "string" },
|
|
28
|
+
"autoFixable": { "type": "boolean" }
|
|
29
|
+
},
|
|
30
|
+
"additionalProperties": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"counts": { "type": "object" }
|
|
34
|
+
},
|
|
35
|
+
"additionalProperties": true
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://sneakoscope.dev/schemas/search-visibility/gate.schema.json",
|
|
4
|
+
"title": "SKS Search Visibility Gate",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schema", "mission_id", "route", "ok", "passed", "status", "command_identity", "required_artifacts", "unsupported_claims", "blockers", "unverified", "completion_proof"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schema": { "const": "sks.search-visibility.gate.v1" },
|
|
9
|
+
"mission_id": { "type": "string" },
|
|
10
|
+
"route": { "const": "$SEO-GEO-OPTIMIZER" },
|
|
11
|
+
"ok": { "type": "boolean" },
|
|
12
|
+
"passed": { "type": "boolean" },
|
|
13
|
+
"status": { "enum": ["verified_partial", "blocked", "locally_verified", "production_verified"] },
|
|
14
|
+
"command_identity": { "type": "boolean" },
|
|
15
|
+
"required_artifacts": { "type": "array" },
|
|
16
|
+
"unsupported_claims": { "type": "array" },
|
|
17
|
+
"blockers": { "type": "array" },
|
|
18
|
+
"unverified": { "type": "array" },
|
|
19
|
+
"completion_proof": { "type": "string" }
|
|
20
|
+
},
|
|
21
|
+
"additionalProperties": true
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://sneakoscope.dev/schemas/search-visibility/mutation-plan.schema.json",
|
|
4
|
+
"title": "SKS Search Visibility Mutation Plan",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schema", "mission_id", "route", "mode", "adapter", "detection_confidence", "status", "operations", "blockers", "unverified"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schema": { "const": "sks.search-visibility.mutation-plan.v1" },
|
|
9
|
+
"mission_id": { "type": "string" },
|
|
10
|
+
"route": { "const": "$SEO-GEO-OPTIMIZER" },
|
|
11
|
+
"mode": { "enum": ["seo", "geo"] },
|
|
12
|
+
"adapter": { "type": "string" },
|
|
13
|
+
"detection_confidence": { "type": "number" },
|
|
14
|
+
"status": { "enum": ["planned", "blocked"] },
|
|
15
|
+
"operations": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"items": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"required": ["id", "path", "baseSha256", "proposedSha256", "kind", "owner", "findingIds", "reversible", "preview", "risk", "requiredVerification", "scopeAuthorization", "ownershipStrategy"],
|
|
20
|
+
"additionalProperties": true
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"blockers": { "type": "array" },
|
|
24
|
+
"unverified": { "type": "array" }
|
|
25
|
+
},
|
|
26
|
+
"additionalProperties": true
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://sneakoscope.dev/schemas/search-visibility/site-inventory.schema.json",
|
|
4
|
+
"title": "SKS Search Visibility Site Inventory",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schema", "mission_id", "route", "root", "target", "detected_adapter", "package", "routes", "policy_files"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schema": { "const": "sks.search-visibility.site-inventory.v1" },
|
|
9
|
+
"mission_id": { "type": "string" },
|
|
10
|
+
"route": { "const": "$SEO-GEO-OPTIMIZER" },
|
|
11
|
+
"root": { "type": "string" },
|
|
12
|
+
"target": { "enum": ["website", "docs", "package"] },
|
|
13
|
+
"detected_adapter": { "type": "object" },
|
|
14
|
+
"package": { "type": "object" },
|
|
15
|
+
"routes": { "type": "array" },
|
|
16
|
+
"policy_files": { "type": "array" },
|
|
17
|
+
"blockers": { "type": "array" },
|
|
18
|
+
"unverified": { "type": "array" }
|
|
19
|
+
},
|
|
20
|
+
"additionalProperties": true
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://sneakoscope.dev/schemas/search-visibility/verification-report.schema.json",
|
|
4
|
+
"title": "SKS Search Visibility Verification Report",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schema", "mission_id", "route", "status", "source_verified", "build_verified", "http_verified", "browser_verified", "production_verified", "measured_outcome", "checked_artifacts", "blockers", "unverified"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schema": { "const": "sks.search-visibility.verification-report.v1" },
|
|
9
|
+
"mission_id": { "type": "string" },
|
|
10
|
+
"route": { "const": "$SEO-GEO-OPTIMIZER" },
|
|
11
|
+
"status": { "enum": ["verified_partial", "blocked", "locally_verified", "production_verified", "measured_outcome_pending", "measured_outcome_recorded"] },
|
|
12
|
+
"source_verified": { "type": "boolean" },
|
|
13
|
+
"build_verified": { "type": "boolean" },
|
|
14
|
+
"http_verified": { "type": "boolean" },
|
|
15
|
+
"browser_verified": { "type": "boolean" },
|
|
16
|
+
"production_verified": { "type": "boolean" },
|
|
17
|
+
"measured_outcome": { "enum": ["pending", "recorded", "not_applicable"] },
|
|
18
|
+
"checked_artifacts": { "type": "array" },
|
|
19
|
+
"blockers": { "type": "array" },
|
|
20
|
+
"unverified": { "type": "array" }
|
|
21
|
+
},
|
|
22
|
+
"additionalProperties": true
|
|
23
|
+
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import os from 'node:os';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { exists, nowIso, readText } from '../fsx.js';
|
|
4
|
-
export const XAI_MCP_DETECTION_SCHEMA = 'sks.xai-mcp-detection.v1';
|
|
5
|
-
const XAI_SERVER_RE = /(?:^|[-_\s.])(xai|x-ai|x_ai|grok|x\.ai)(?:$|[-_\s.])/i;
|
|
6
|
-
const SEARCH_TOOL_RE = /(?:search|query|web|retrieve|retrieval|news|grok)/i;
|
|
7
|
-
export function isXaiServerName(name) {
|
|
8
|
-
return XAI_SERVER_RE.test(normalizeName(name));
|
|
9
|
-
}
|
|
10
|
-
export function isSearchToolName(name) {
|
|
11
|
-
return SEARCH_TOOL_RE.test(normalizeName(name));
|
|
12
|
-
}
|
|
13
|
-
export async function detectXaiMcp(opts = {}) {
|
|
14
|
-
const root = path.resolve(opts.root || process.cwd());
|
|
15
|
-
const home = opts.home || os.homedir();
|
|
16
|
-
const configPaths = [
|
|
17
|
-
{ path: path.join(home, '.codex', 'config.toml'), source: 'user' },
|
|
18
|
-
{ path: path.join(root, '.codex', 'config.toml'), source: 'project' },
|
|
19
|
-
{ path: path.join(root, '.codex', 'config.json'), source: 'project' }
|
|
20
|
-
];
|
|
21
|
-
const provided = opts.configSources || [];
|
|
22
|
-
const discovered = [...provided];
|
|
23
|
-
for (const entry of configPaths) {
|
|
24
|
-
if (provided.some((source) => path.resolve(source.path) === path.resolve(entry.path)))
|
|
25
|
-
continue;
|
|
26
|
-
if (await exists(entry.path)) {
|
|
27
|
-
discovered.push({ path: entry.path, source: entry.source, text: String(await readText(entry.path, '')) });
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return detectXaiMcpFromConfig(discovered, {
|
|
31
|
-
checked: configPaths.map((entry) => entry.path),
|
|
32
|
-
toolLists: opts.toolLists || {}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
export function detectXaiMcpFromConfig(sources = [], opts = {}) {
|
|
36
|
-
try {
|
|
37
|
-
const servers = sources.flatMap((source) => detectServersInSource(source, opts.toolLists || {}));
|
|
38
|
-
const configured = servers.length > 0;
|
|
39
|
-
const searchCapable = servers.some((server) => server.search_capable);
|
|
40
|
-
const configuredButUnverified = configured && !searchCapable && servers.some((server) => server.configured_but_unverified);
|
|
41
|
-
const status = !configured
|
|
42
|
-
? 'missing'
|
|
43
|
-
: searchCapable
|
|
44
|
-
? 'search_capable'
|
|
45
|
-
: configuredButUnverified
|
|
46
|
-
? 'configured_but_unverified'
|
|
47
|
-
: 'configured_no_search';
|
|
48
|
-
return {
|
|
49
|
-
schema: XAI_MCP_DETECTION_SCHEMA,
|
|
50
|
-
generated_at: nowIso(),
|
|
51
|
-
ok: true,
|
|
52
|
-
status,
|
|
53
|
-
configured,
|
|
54
|
-
search_capable: searchCapable,
|
|
55
|
-
configured_but_unverified: configuredButUnverified,
|
|
56
|
-
servers,
|
|
57
|
-
config_paths_checked: [...new Set([...(opts.checked || []), ...sources.map((source) => source.path)])],
|
|
58
|
-
config_paths_found: sources.map((source) => source.path),
|
|
59
|
-
blockers: [],
|
|
60
|
-
warnings: configuredButUnverified ? ['xai_mcp_configured_but_tool_list_unverified'] : []
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
return {
|
|
65
|
-
schema: XAI_MCP_DETECTION_SCHEMA,
|
|
66
|
-
generated_at: nowIso(),
|
|
67
|
-
ok: false,
|
|
68
|
-
status: 'error',
|
|
69
|
-
configured: false,
|
|
70
|
-
search_capable: false,
|
|
71
|
-
configured_but_unverified: false,
|
|
72
|
-
servers: [],
|
|
73
|
-
config_paths_checked: opts.checked || [],
|
|
74
|
-
config_paths_found: sources.map((source) => source.path),
|
|
75
|
-
blockers: [`xai_mcp_detection_error:${err instanceof Error ? err.message : String(err)}`],
|
|
76
|
-
warnings: []
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function detectServersInSource(source, toolLists) {
|
|
81
|
-
const jsonServers = parseJsonServers(source);
|
|
82
|
-
const tomlServers = jsonServers.length ? [] : parseTomlServerNames(source.text);
|
|
83
|
-
const names = [...jsonServers, ...tomlServers].filter((server) => isXaiServerName(server.name));
|
|
84
|
-
return names.map((server) => {
|
|
85
|
-
const configuredTools = [...server.tools, ...(toolLists[server.name] || []), ...(toolLists[normalizeName(server.name)] || [])];
|
|
86
|
-
const uniqueTools = [...new Set(configuredTools.map(String).filter(Boolean))];
|
|
87
|
-
const searchCapable = uniqueTools.some(isSearchToolName);
|
|
88
|
-
return {
|
|
89
|
-
name: normalizeName(server.name),
|
|
90
|
-
source: `${source.source}:${source.path}`,
|
|
91
|
-
configured: true,
|
|
92
|
-
search_capable: searchCapable,
|
|
93
|
-
configured_but_unverified: !searchCapable && uniqueTools.length === 0,
|
|
94
|
-
tools: uniqueTools,
|
|
95
|
-
raw_name: server.name
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
function parseJsonServers(source) {
|
|
100
|
-
const text = source.text.trim();
|
|
101
|
-
if (!text.startsWith('{'))
|
|
102
|
-
return [];
|
|
103
|
-
try {
|
|
104
|
-
const parsed = JSON.parse(text);
|
|
105
|
-
const servers = parsed?.mcp_servers || parsed?.mcpServers || {};
|
|
106
|
-
return Object.entries(servers).map(([name, value]) => ({
|
|
107
|
-
name,
|
|
108
|
-
tools: extractToolNames(value)
|
|
109
|
-
}));
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
return [];
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
function parseTomlServerNames(text) {
|
|
116
|
-
const rows = [];
|
|
117
|
-
const tableRe = /^\s*\[(?:mcp_servers|mcpServers)\.([^\]]+)\]\s*$/gm;
|
|
118
|
-
let match;
|
|
119
|
-
while ((match = tableRe.exec(text)) !== null) {
|
|
120
|
-
const name = unquote(match[1] || '');
|
|
121
|
-
const bodyStart = match.index + match[0].length;
|
|
122
|
-
const nextTable = text.slice(bodyStart).search(/^\s*\[/m);
|
|
123
|
-
const body = nextTable >= 0 ? text.slice(bodyStart, bodyStart + nextTable) : text.slice(bodyStart);
|
|
124
|
-
rows.push({ name, tools: extractToolNamesFromText(body) });
|
|
125
|
-
}
|
|
126
|
-
return rows;
|
|
127
|
-
}
|
|
128
|
-
function extractToolNames(value) {
|
|
129
|
-
if (!value || typeof value !== 'object')
|
|
130
|
-
return [];
|
|
131
|
-
const possible = [
|
|
132
|
-
value.tools,
|
|
133
|
-
value.tool_names,
|
|
134
|
-
value.capabilities,
|
|
135
|
-
value.search_tools
|
|
136
|
-
];
|
|
137
|
-
return possible.flatMap((entry) => Array.isArray(entry) ? entry.map(String) : []);
|
|
138
|
-
}
|
|
139
|
-
function extractToolNamesFromText(text) {
|
|
140
|
-
const tools = [];
|
|
141
|
-
const arrayRe = /(?:tools|tool_names|capabilities|search_tools)\s*=\s*\[([^\]]*)\]/g;
|
|
142
|
-
let match;
|
|
143
|
-
while ((match = arrayRe.exec(text)) !== null) {
|
|
144
|
-
tools.push(...String(match[1] || '').split(',').map((part) => unquote(part.trim())).filter(Boolean));
|
|
145
|
-
}
|
|
146
|
-
const keyRe = /^\s*(search|query|web|retrieve|news|grok)\s*=/gmi;
|
|
147
|
-
while ((match = keyRe.exec(text)) !== null)
|
|
148
|
-
tools.push(match[1] || '');
|
|
149
|
-
return tools;
|
|
150
|
-
}
|
|
151
|
-
function normalizeName(name) {
|
|
152
|
-
return String(name || '').trim().replace(/^["']|["']$/g, '').toLowerCase();
|
|
153
|
-
}
|
|
154
|
-
function unquote(value) {
|
|
155
|
-
return String(value || '').trim().replace(/^["']|["']$/g, '');
|
|
156
|
-
}
|
|
157
|
-
//# sourceMappingURL=xai-mcp-detector.js.map
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { ensureDir, nowIso, sha256, writeJsonAtomic } from '../fsx.js';
|
|
3
|
-
export const XAI_SEARCH_EVIDENCE_SCHEMA = 'sks.xai-search-evidence.v1';
|
|
4
|
-
export async function runXaiSearch(query, opts = {}) {
|
|
5
|
-
const timeoutMs = opts.timeoutMs || 10_000;
|
|
6
|
-
if (opts.configured === false)
|
|
7
|
-
return blockedEvidence(query, timeoutMs, 'not_configured', ['xai_mcp_missing']);
|
|
8
|
-
if (!opts.search)
|
|
9
|
-
return blockedEvidence(query, timeoutMs, 'blocked', ['xai_search_adapter_missing']);
|
|
10
|
-
try {
|
|
11
|
-
const raw = await withTimeout(opts.search(query), timeoutMs);
|
|
12
|
-
const results = normalizeXaiSearchResults(raw);
|
|
13
|
-
let rawArtifact = null;
|
|
14
|
-
if (opts.artifactDir) {
|
|
15
|
-
await ensureDir(opts.artifactDir);
|
|
16
|
-
rawArtifact = path.join(opts.artifactDir, `xai-search-raw-${sha256(JSON.stringify({ query, raw })).slice(0, 12)}.json`);
|
|
17
|
-
await writeJsonAtomic(rawArtifact, { schema: 'sks.xai-search-raw-local-only.v1', generated_at: nowIso(), local_only: true, query, raw });
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
schema: XAI_SEARCH_EVIDENCE_SCHEMA,
|
|
21
|
-
generated_at: nowIso(),
|
|
22
|
-
ok: true,
|
|
23
|
-
query,
|
|
24
|
-
status: 'completed',
|
|
25
|
-
timeout_ms: timeoutMs,
|
|
26
|
-
results: results.map((record) => ({ ...record, local_only_raw_artifact: rawArtifact })),
|
|
27
|
-
raw_response_artifact: rawArtifact,
|
|
28
|
-
redacted_summary: {
|
|
29
|
-
result_count: results.length,
|
|
30
|
-
urls: results.map((record) => record.url)
|
|
31
|
-
},
|
|
32
|
-
blockers: []
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
const timeout = err instanceof Error && err.message === 'xai_search_timeout';
|
|
37
|
-
return blockedEvidence(query, timeoutMs, timeout ? 'timeout' : 'blocked', [
|
|
38
|
-
timeout ? 'xai_search_timeout' : `xai_search_failure:${err instanceof Error ? err.message : String(err)}`
|
|
39
|
-
]);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export function normalizeXaiSearchResults(raw) {
|
|
43
|
-
const rows = Array.isArray(raw)
|
|
44
|
-
? raw
|
|
45
|
-
: Array.isArray(raw?.results)
|
|
46
|
-
? raw.results
|
|
47
|
-
: Array.isArray(raw?.data)
|
|
48
|
-
? raw.data
|
|
49
|
-
: [];
|
|
50
|
-
return rows.map((row, index) => ({
|
|
51
|
-
provider: 'xai',
|
|
52
|
-
id: String(row.id || row.url || row.link || `xai-${index + 1}`),
|
|
53
|
-
title: String(row.title || row.name || row.heading || `X AI result ${index + 1}`),
|
|
54
|
-
url: row.url || row.link || null,
|
|
55
|
-
snippet: String(row.snippet || row.summary || row.text || ''),
|
|
56
|
-
published_at: row.published_at || row.publishedAt || row.date || null,
|
|
57
|
-
local_only_raw_artifact: null
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
export function redactXaiRawResponse(raw) {
|
|
61
|
-
const results = normalizeXaiSearchResults(raw);
|
|
62
|
-
return {
|
|
63
|
-
provider: 'xai',
|
|
64
|
-
result_count: results.length,
|
|
65
|
-
results: results.map((result) => ({
|
|
66
|
-
title: result.title,
|
|
67
|
-
url: result.url,
|
|
68
|
-
snippet: result.snippet.slice(0, 240),
|
|
69
|
-
published_at: result.published_at
|
|
70
|
-
}))
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function blockedEvidence(query, timeoutMs, status, blockers) {
|
|
74
|
-
return {
|
|
75
|
-
schema: XAI_SEARCH_EVIDENCE_SCHEMA,
|
|
76
|
-
generated_at: nowIso(),
|
|
77
|
-
ok: false,
|
|
78
|
-
query,
|
|
79
|
-
status,
|
|
80
|
-
timeout_ms: timeoutMs,
|
|
81
|
-
results: [],
|
|
82
|
-
raw_response_artifact: null,
|
|
83
|
-
redacted_summary: { result_count: 0, urls: [] },
|
|
84
|
-
blockers
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function withTimeout(promise, timeoutMs) {
|
|
88
|
-
return new Promise((resolve, reject) => {
|
|
89
|
-
const timer = setTimeout(() => reject(new Error('xai_search_timeout')), timeoutMs);
|
|
90
|
-
timer.unref?.();
|
|
91
|
-
promise.then((value) => {
|
|
92
|
-
clearTimeout(timer);
|
|
93
|
-
resolve(value);
|
|
94
|
-
}, (err) => {
|
|
95
|
-
clearTimeout(timer);
|
|
96
|
-
reject(err);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=xai-search-adapter.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
import { assertGate, emitGate, importDist } from './sks-1-18-gate-lib.js';
|
|
4
|
-
const detector = await importDist('core/mcp/xai-mcp-detector.js');
|
|
5
|
-
const detection = detector.detectXaiMcpFromConfig([
|
|
6
|
-
{ path: 'fixture.toml', source: 'provided', text: '[mcp_servers.grok]\ntools = ["search", "query"]\n' }
|
|
7
|
-
]);
|
|
8
|
-
assertGate(detection.ok === true, 'X AI detector must not fail');
|
|
9
|
-
assertGate(detection.configured === true, 'X AI detector must detect configured Grok MCP');
|
|
10
|
-
assertGate(detection.search_capable === true, 'X AI detector must detect search-capable tools');
|
|
11
|
-
const missing = detector.detectXaiMcpFromConfig([]);
|
|
12
|
-
assertGate(missing.ok === true && missing.status === 'missing', 'missing X AI MCP must be ok fallback');
|
|
13
|
-
emitGate('xai-mcp:capability', { configured_status: detection.status, missing_status: missing.status });
|
|
14
|
-
//# sourceMappingURL=xai-mcp-capability-check.js.map
|