@aiassesstech/grillo 0.1.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 +56 -0
- package/LICENSE +21 -0
- package/README.md +512 -0
- package/SKILL.md +87 -0
- package/dist/api/server.d.ts +68 -0
- package/dist/api/server.d.ts.map +1 -0
- package/dist/api/server.js +596 -0
- package/dist/api/server.js.map +1 -0
- package/dist/audit/audit-log.d.ts +88 -0
- package/dist/audit/audit-log.d.ts.map +1 -0
- package/dist/audit/audit-log.js +195 -0
- package/dist/audit/audit-log.js.map +1 -0
- package/dist/certification/certificate.d.ts +80 -0
- package/dist/certification/certificate.d.ts.map +1 -0
- package/dist/certification/certificate.js +176 -0
- package/dist/certification/certificate.js.map +1 -0
- package/dist/cli/bin.d.ts +8 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +12 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/config-loader.d.ts +66 -0
- package/dist/cli/config-loader.d.ts.map +1 -0
- package/dist/cli/config-loader.js +243 -0
- package/dist/cli/config-loader.js.map +1 -0
- package/dist/cli/runner.d.ts +27 -0
- package/dist/cli/runner.d.ts.map +1 -0
- package/dist/cli/runner.js +388 -0
- package/dist/cli/runner.js.map +1 -0
- package/dist/commands/grillo-commands.d.ts +50 -0
- package/dist/commands/grillo-commands.d.ts.map +1 -0
- package/dist/commands/grillo-commands.js +752 -0
- package/dist/commands/grillo-commands.js.map +1 -0
- package/dist/commands/inline-commands.d.ts +16 -0
- package/dist/commands/inline-commands.d.ts.map +1 -0
- package/dist/commands/inline-commands.js +277 -0
- package/dist/commands/inline-commands.js.map +1 -0
- package/dist/commands/router.d.ts +56 -0
- package/dist/commands/router.d.ts.map +1 -0
- package/dist/commands/router.js +154 -0
- package/dist/commands/router.js.map +1 -0
- package/dist/config/defaults.d.ts +9 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +78 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/schema.d.ts +573 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +142 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/dashboard/metrics.d.ts +100 -0
- package/dist/dashboard/metrics.d.ts.map +1 -0
- package/dist/dashboard/metrics.js +282 -0
- package/dist/dashboard/metrics.js.map +1 -0
- package/dist/dashboard/ui.d.ts +19 -0
- package/dist/dashboard/ui.d.ts.map +1 -0
- package/dist/dashboard/ui.js +951 -0
- package/dist/dashboard/ui.js.map +1 -0
- package/dist/discovery/discovery-adapter.d.ts +94 -0
- package/dist/discovery/discovery-adapter.d.ts.map +1 -0
- package/dist/discovery/discovery-adapter.js +114 -0
- package/dist/discovery/discovery-adapter.js.map +1 -0
- package/dist/discovery/discovery-service.d.ts +77 -0
- package/dist/discovery/discovery-service.d.ts.map +1 -0
- package/dist/discovery/discovery-service.js +240 -0
- package/dist/discovery/discovery-service.js.map +1 -0
- package/dist/drift/detector.d.ts +51 -0
- package/dist/drift/detector.d.ts.map +1 -0
- package/dist/drift/detector.js +148 -0
- package/dist/drift/detector.js.map +1 -0
- package/dist/drift/fleet-anomaly.d.ts +28 -0
- package/dist/drift/fleet-anomaly.d.ts.map +1 -0
- package/dist/drift/fleet-anomaly.js +186 -0
- package/dist/drift/fleet-anomaly.js.map +1 -0
- package/dist/events/event-bus.d.ts +209 -0
- package/dist/events/event-bus.d.ts.map +1 -0
- package/dist/events/event-bus.js +184 -0
- package/dist/events/event-bus.js.map +1 -0
- package/dist/frameworks/framework-registry.d.ts +116 -0
- package/dist/frameworks/framework-registry.d.ts.map +1 -0
- package/dist/frameworks/framework-registry.js +241 -0
- package/dist/frameworks/framework-registry.js.map +1 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +254 -0
- package/dist/index.js.map +1 -0
- package/dist/monitoring/continuous-monitor.d.ts +61 -0
- package/dist/monitoring/continuous-monitor.d.ts.map +1 -0
- package/dist/monitoring/continuous-monitor.js +191 -0
- package/dist/monitoring/continuous-monitor.js.map +1 -0
- package/dist/notifications/notifier.d.ts +21 -0
- package/dist/notifications/notifier.d.ts.map +1 -0
- package/dist/notifications/notifier.js +119 -0
- package/dist/notifications/notifier.js.map +1 -0
- package/dist/notifications/templates.d.ts +14 -0
- package/dist/notifications/templates.d.ts.map +1 -0
- package/dist/notifications/templates.js +105 -0
- package/dist/notifications/templates.js.map +1 -0
- package/dist/orchestration/orchestrator.d.ts +99 -0
- package/dist/orchestration/orchestrator.d.ts.map +1 -0
- package/dist/orchestration/orchestrator.js +426 -0
- package/dist/orchestration/orchestrator.js.map +1 -0
- package/dist/orchestration/queue.d.ts +17 -0
- package/dist/orchestration/queue.d.ts.map +1 -0
- package/dist/orchestration/queue.js +121 -0
- package/dist/orchestration/queue.js.map +1 -0
- package/dist/orchestration/scheduler.d.ts +26 -0
- package/dist/orchestration/scheduler.d.ts.map +1 -0
- package/dist/orchestration/scheduler.js +110 -0
- package/dist/orchestration/scheduler.js.map +1 -0
- package/dist/registry/agent-registry.d.ts +106 -0
- package/dist/registry/agent-registry.d.ts.map +1 -0
- package/dist/registry/agent-registry.js +349 -0
- package/dist/registry/agent-registry.js.map +1 -0
- package/dist/registry/types.d.ts +158 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +44 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/reports/compliance-report.d.ts +66 -0
- package/dist/reports/compliance-report.d.ts.map +1 -0
- package/dist/reports/compliance-report.js +208 -0
- package/dist/reports/compliance-report.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/dashboard/ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,mEAAmE;AACnE,2BAA2B;AAC3B,mEAAmE;AAEnE,MAAM,UAAU,qBAAqB,CAAC,MAAoB;IACxD,MAAM,WAAW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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8WvB,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grillo Cricket — Agent Discovery Protocol
|
|
3
|
+
*
|
|
4
|
+
* Pluggable adapter interface for discovering agents from various
|
|
5
|
+
* orchestration platforms (OpenClaw, LangChain, CrewAI, AutoGen, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Grillo doesn't care HOW agents are hosted — it only needs a
|
|
8
|
+
* standardized discovery result. Each platform provides an adapter.
|
|
9
|
+
*/
|
|
10
|
+
import type { AgentCategory, RiskTier } from "../registry/types.js";
|
|
11
|
+
export interface DiscoveredAgent {
|
|
12
|
+
/** External ID from the orchestration platform */
|
|
13
|
+
externalId: string;
|
|
14
|
+
/** Human-readable agent name */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Agent type (e.g., 'bot', 'assistant', 'tool', 'skill') */
|
|
17
|
+
agentType: string;
|
|
18
|
+
/** Model being used (e.g., 'gpt-4', 'claude-3-opus') */
|
|
19
|
+
model: string;
|
|
20
|
+
/** Provider (e.g., 'openai', 'anthropic') */
|
|
21
|
+
provider: string;
|
|
22
|
+
/** Suggested category for Grillo's registry */
|
|
23
|
+
category?: AgentCategory;
|
|
24
|
+
/** Suggested risk tier */
|
|
25
|
+
riskTier?: RiskTier;
|
|
26
|
+
/** Tags from the platform */
|
|
27
|
+
tags?: string[];
|
|
28
|
+
/** Additional platform-specific metadata */
|
|
29
|
+
metadata?: Record<string, unknown>;
|
|
30
|
+
/** The orchestration framework this agent runs on */
|
|
31
|
+
framework?: string;
|
|
32
|
+
/** When this agent was created/deployed */
|
|
33
|
+
deployedAt?: Date;
|
|
34
|
+
/** Whether the agent is currently active */
|
|
35
|
+
active?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface DiscoveryResult {
|
|
38
|
+
/** Agents found by the adapter */
|
|
39
|
+
agents: DiscoveredAgent[];
|
|
40
|
+
/** Platform/adapter that produced this result */
|
|
41
|
+
source: string;
|
|
42
|
+
/** When the scan was performed */
|
|
43
|
+
scannedAt: Date;
|
|
44
|
+
/** Any errors encountered during discovery */
|
|
45
|
+
errors?: string[];
|
|
46
|
+
/** Additional metadata from the scan */
|
|
47
|
+
metadata?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
export interface DiscoveryAdapter {
|
|
50
|
+
/** Unique identifier for this adapter (e.g., 'openclaw', 'langchain') */
|
|
51
|
+
id: string;
|
|
52
|
+
/** Human-readable name */
|
|
53
|
+
name: string;
|
|
54
|
+
/** Discover agents from the platform */
|
|
55
|
+
discover(): Promise<DiscoveryResult>;
|
|
56
|
+
/** Test connectivity to the platform */
|
|
57
|
+
healthCheck(): Promise<boolean>;
|
|
58
|
+
}
|
|
59
|
+
export interface OpenClawDiscoveryConfig {
|
|
60
|
+
/** OpenClaw Gateway URL (e.g., http://127.0.0.1:18789) */
|
|
61
|
+
gatewayUrl: string;
|
|
62
|
+
/** API key for authentication */
|
|
63
|
+
apiKey?: string;
|
|
64
|
+
/** Timeout for discovery requests */
|
|
65
|
+
timeoutMs?: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Discovery adapter for OpenClaw deployments.
|
|
69
|
+
*
|
|
70
|
+
* Queries the OpenClaw Gateway's agent API to enumerate all
|
|
71
|
+
* registered agents, their models, and configurations.
|
|
72
|
+
*/
|
|
73
|
+
export declare class OpenClawDiscoveryAdapter implements DiscoveryAdapter {
|
|
74
|
+
readonly id = "openclaw";
|
|
75
|
+
readonly name = "OpenClaw Gateway";
|
|
76
|
+
private readonly config;
|
|
77
|
+
constructor(config: OpenClawDiscoveryConfig);
|
|
78
|
+
discover(): Promise<DiscoveryResult>;
|
|
79
|
+
healthCheck(): Promise<boolean>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Static discovery adapter that returns a fixed set of agents.
|
|
83
|
+
* Useful for testing, demos, and environments without a live
|
|
84
|
+
* orchestration platform.
|
|
85
|
+
*/
|
|
86
|
+
export declare class StaticDiscoveryAdapter implements DiscoveryAdapter {
|
|
87
|
+
readonly id = "static";
|
|
88
|
+
readonly name = "Static Configuration";
|
|
89
|
+
private readonly agents;
|
|
90
|
+
constructor(agents: DiscoveredAgent[]);
|
|
91
|
+
discover(): Promise<DiscoveryResult>;
|
|
92
|
+
healthCheck(): Promise<boolean>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=discovery-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-adapter.d.ts","sourceRoot":"","sources":["../../src/discovery/discovery-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAMpE,MAAM,WAAW,eAAe;IAC9B,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB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AoB;gBAE/B,MAAM,EAAE,eAAe,EAAE;IAI/B,QAAQ,IAAI,OAAO,CAAC,eAAe,CAAC;IAQpC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAGtC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grillo Cricket — Agent Discovery Protocol
|
|
3
|
+
*
|
|
4
|
+
* Pluggable adapter interface for discovering agents from various
|
|
5
|
+
* orchestration platforms (OpenClaw, LangChain, CrewAI, AutoGen, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Grillo doesn't care HOW agents are hosted — it only needs a
|
|
8
|
+
* standardized discovery result. Each platform provides an adapter.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Discovery adapter for OpenClaw deployments.
|
|
12
|
+
*
|
|
13
|
+
* Queries the OpenClaw Gateway's agent API to enumerate all
|
|
14
|
+
* registered agents, their models, and configurations.
|
|
15
|
+
*/
|
|
16
|
+
export class OpenClawDiscoveryAdapter {
|
|
17
|
+
id = "openclaw";
|
|
18
|
+
name = "OpenClaw Gateway";
|
|
19
|
+
config;
|
|
20
|
+
constructor(config) {
|
|
21
|
+
this.config = config;
|
|
22
|
+
}
|
|
23
|
+
async discover() {
|
|
24
|
+
const scannedAt = new Date();
|
|
25
|
+
const errors = [];
|
|
26
|
+
try {
|
|
27
|
+
const url = `${this.config.gatewayUrl}/v1/agents`;
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
const timeout = setTimeout(() => controller.abort(), this.config.timeoutMs ?? 10000);
|
|
30
|
+
try {
|
|
31
|
+
const response = await fetch(url, {
|
|
32
|
+
headers: {
|
|
33
|
+
...(this.config.apiKey
|
|
34
|
+
? { Authorization: `Bearer ${this.config.apiKey}` }
|
|
35
|
+
: {}),
|
|
36
|
+
},
|
|
37
|
+
signal: controller.signal,
|
|
38
|
+
});
|
|
39
|
+
clearTimeout(timeout);
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
errors.push(`OpenClaw API returned ${response.status}: ${response.statusText}`);
|
|
42
|
+
return { agents: [], source: this.id, scannedAt, errors };
|
|
43
|
+
}
|
|
44
|
+
const data = (await response.json());
|
|
45
|
+
const agents = (data.agents ?? []).map((raw) => ({
|
|
46
|
+
externalId: String(raw.id ?? ""),
|
|
47
|
+
name: String(raw.name ?? raw.id ?? "unknown"),
|
|
48
|
+
agentType: String(raw.type ?? "bot"),
|
|
49
|
+
model: String(raw.model ?? "unknown"),
|
|
50
|
+
provider: String(raw.provider ?? "unknown"),
|
|
51
|
+
tags: raw.tags ?? [],
|
|
52
|
+
metadata: raw.metadata ?? {},
|
|
53
|
+
framework: "openclaw",
|
|
54
|
+
deployedAt: raw.created_at ? new Date(raw.created_at) : undefined,
|
|
55
|
+
active: raw.active ?? true,
|
|
56
|
+
}));
|
|
57
|
+
return { agents, source: this.id, scannedAt };
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
clearTimeout(timeout);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
65
|
+
errors.push(`OpenClaw discovery failed: ${msg}`);
|
|
66
|
+
return { agents: [], source: this.id, scannedAt, errors };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async healthCheck() {
|
|
70
|
+
try {
|
|
71
|
+
const url = `${this.config.gatewayUrl}/v1/health`;
|
|
72
|
+
const controller = new AbortController();
|
|
73
|
+
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
74
|
+
try {
|
|
75
|
+
const response = await fetch(url, { signal: controller.signal });
|
|
76
|
+
clearTimeout(timeout);
|
|
77
|
+
return response.ok;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
clearTimeout(timeout);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// ================================================================
|
|
89
|
+
// Static Adapter (for testing and manual configurations)
|
|
90
|
+
// ================================================================
|
|
91
|
+
/**
|
|
92
|
+
* Static discovery adapter that returns a fixed set of agents.
|
|
93
|
+
* Useful for testing, demos, and environments without a live
|
|
94
|
+
* orchestration platform.
|
|
95
|
+
*/
|
|
96
|
+
export class StaticDiscoveryAdapter {
|
|
97
|
+
id = "static";
|
|
98
|
+
name = "Static Configuration";
|
|
99
|
+
agents;
|
|
100
|
+
constructor(agents) {
|
|
101
|
+
this.agents = agents;
|
|
102
|
+
}
|
|
103
|
+
async discover() {
|
|
104
|
+
return {
|
|
105
|
+
agents: [...this.agents],
|
|
106
|
+
source: this.id,
|
|
107
|
+
scannedAt: new Date(),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
async healthCheck() {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=discovery-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-adapter.js","sourceRoot":"","sources":["../../src/discovery/discovery-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA4EH;;;;;GAKG;AACH,MAAM,OAAO,wBAAwB;IAC1B,EAAE,GAAG,UAAU,CAAC;IAChB,IAAI,GAAG,kBAAkB,CAAC;IAClB,MAAM,CAA0B;IAEjD,YAAY,MAA+B;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,YAAY,CAAC;YAClD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;YACzC,MAAM,OAAO,GAAG,UAAU,CACxB,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,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AC,MAAM,EAAE,CAAC,CAAC;gBACjE,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtB,OAAO,QAAQ,CAAC,EAAE,CAAC;YACrB,CAAC;oBAAS,CAAC;gBACT,YAAY,CAAC,OAAO,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AAED,mEAAmE;AACnE,yDAAyD;AACzD,mEAAmE;AAEnE;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IACxB,EAAE,GAAG,QAAQ,CAAC;IACd,IAAI,GAAG,sBAAsB,CAAC;IACtB,MAAM,CAAoB;IAE3C,YAAY,MAAyB;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,OAAO;YACL,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;YACxB,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grillo Cricket — Discovery Service
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates agent discovery across multiple adapters, reconciles
|
|
5
|
+
* discovered agents against the existing registry, and handles
|
|
6
|
+
* registration of new agents.
|
|
7
|
+
*/
|
|
8
|
+
import type { AgentRegistry } from "../registry/agent-registry.js";
|
|
9
|
+
import type { AuditLog } from "../audit/audit-log.js";
|
|
10
|
+
import type { Notifier } from "../notifications/notifier.js";
|
|
11
|
+
import type { DiscoveryAdapter, DiscoveredAgent, DiscoveryResult } from "./discovery-adapter.js";
|
|
12
|
+
export interface ReconciliationResult {
|
|
13
|
+
/** Newly registered agents */
|
|
14
|
+
registered: DiscoveredAgent[];
|
|
15
|
+
/** Agents already known to Grillo */
|
|
16
|
+
existing: DiscoveredAgent[];
|
|
17
|
+
/** Agents in Grillo's registry but NOT found by any adapter (stale?) */
|
|
18
|
+
orphaned: string[];
|
|
19
|
+
/** Agents that were skipped (inactive, filtered, etc.) */
|
|
20
|
+
skipped: DiscoveredAgent[];
|
|
21
|
+
/** Errors from adapters */
|
|
22
|
+
errors: string[];
|
|
23
|
+
/** Total scan time in ms */
|
|
24
|
+
durationMs: number;
|
|
25
|
+
}
|
|
26
|
+
export declare class DiscoveryService {
|
|
27
|
+
private readonly adapters;
|
|
28
|
+
private readonly registry;
|
|
29
|
+
private readonly auditLog;
|
|
30
|
+
private readonly notifier;
|
|
31
|
+
constructor(params: {
|
|
32
|
+
registry: AgentRegistry;
|
|
33
|
+
auditLog?: AuditLog;
|
|
34
|
+
notifier?: Notifier;
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Register a discovery adapter.
|
|
38
|
+
*/
|
|
39
|
+
addAdapter(adapter: DiscoveryAdapter): void;
|
|
40
|
+
/**
|
|
41
|
+
* Remove a discovery adapter.
|
|
42
|
+
*/
|
|
43
|
+
removeAdapter(id: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* List registered adapters.
|
|
46
|
+
*/
|
|
47
|
+
listAdapters(): {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
}[];
|
|
51
|
+
/**
|
|
52
|
+
* Run discovery across all registered adapters.
|
|
53
|
+
*/
|
|
54
|
+
discover(): Promise<DiscoveryResult[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Discover agents and reconcile against the registry.
|
|
57
|
+
* New agents are auto-registered; orphaned agents are flagged.
|
|
58
|
+
*/
|
|
59
|
+
discoverAndReconcile(options?: {
|
|
60
|
+
autoRegister?: boolean;
|
|
61
|
+
skipInactive?: boolean;
|
|
62
|
+
}): Promise<ReconciliationResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Check health of all registered adapters.
|
|
65
|
+
*/
|
|
66
|
+
healthCheck(): Promise<Record<string, boolean>>;
|
|
67
|
+
/**
|
|
68
|
+
* Build a Grillo-internal agent ID from a discovered agent.
|
|
69
|
+
* Format: {framework}-{externalId} or just {externalId} if no framework.
|
|
70
|
+
*/
|
|
71
|
+
private buildAgentId;
|
|
72
|
+
/**
|
|
73
|
+
* Format discovery results as human-readable text.
|
|
74
|
+
*/
|
|
75
|
+
formatResults(result: ReconciliationResult): string;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=discovery-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-service.d.ts","sourceRoot":"","sources":["../../src/discovery/discovery-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAOhC,MAAM,WAAW,oBAAoB;IACnC,8BAA8B;IAC9B,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,qCAAqC;IACrC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,wEAAwE;IACxE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,0DAA0D;IAC1D,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,2BAA2B;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB;AAMD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4C;IACrE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;gBAE/B,MAAM,EAAE;QAClB,QAAQ,EAAE,aAAa,CAAC;QACxB,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;KACrB;IAUD;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAI3C;;OAEG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,YAAY,IAAI;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE;IAW9C;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAsB5C;;;OAGG;IACG,oBAAoB,CAAC,OAAO,CAAC,EAAE;QACnC,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAoHjC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAkBrD;;;OAGG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM;CAuCpD"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grillo Cricket — Discovery Service
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates agent discovery across multiple adapters, reconciles
|
|
5
|
+
* discovered agents against the existing registry, and handles
|
|
6
|
+
* registration of new agents.
|
|
7
|
+
*/
|
|
8
|
+
import { AgentCategory, RiskTier } from "../registry/types.js";
|
|
9
|
+
// ================================================================
|
|
10
|
+
// Discovery Service
|
|
11
|
+
// ================================================================
|
|
12
|
+
export class DiscoveryService {
|
|
13
|
+
adapters = new Map();
|
|
14
|
+
registry;
|
|
15
|
+
auditLog;
|
|
16
|
+
notifier;
|
|
17
|
+
constructor(params) {
|
|
18
|
+
this.registry = params.registry;
|
|
19
|
+
this.auditLog = params.auditLog ?? null;
|
|
20
|
+
this.notifier = params.notifier ?? null;
|
|
21
|
+
}
|
|
22
|
+
// ============================================================
|
|
23
|
+
// Adapter Management
|
|
24
|
+
// ============================================================
|
|
25
|
+
/**
|
|
26
|
+
* Register a discovery adapter.
|
|
27
|
+
*/
|
|
28
|
+
addAdapter(adapter) {
|
|
29
|
+
this.adapters.set(adapter.id, adapter);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Remove a discovery adapter.
|
|
33
|
+
*/
|
|
34
|
+
removeAdapter(id) {
|
|
35
|
+
this.adapters.delete(id);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* List registered adapters.
|
|
39
|
+
*/
|
|
40
|
+
listAdapters() {
|
|
41
|
+
return Array.from(this.adapters.values()).map((a) => ({
|
|
42
|
+
id: a.id,
|
|
43
|
+
name: a.name,
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
// ============================================================
|
|
47
|
+
// Discovery + Reconciliation
|
|
48
|
+
// ============================================================
|
|
49
|
+
/**
|
|
50
|
+
* Run discovery across all registered adapters.
|
|
51
|
+
*/
|
|
52
|
+
async discover() {
|
|
53
|
+
const results = [];
|
|
54
|
+
for (const adapter of this.adapters.values()) {
|
|
55
|
+
try {
|
|
56
|
+
const result = await adapter.discover();
|
|
57
|
+
results.push(result);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
results.push({
|
|
61
|
+
agents: [],
|
|
62
|
+
source: adapter.id,
|
|
63
|
+
scannedAt: new Date(),
|
|
64
|
+
errors: [
|
|
65
|
+
`Adapter ${adapter.id} threw: ${error instanceof Error ? error.message : String(error)}`,
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return results;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Discover agents and reconcile against the registry.
|
|
74
|
+
* New agents are auto-registered; orphaned agents are flagged.
|
|
75
|
+
*/
|
|
76
|
+
async discoverAndReconcile(options) {
|
|
77
|
+
const startTime = Date.now();
|
|
78
|
+
const autoRegister = options?.autoRegister ?? true;
|
|
79
|
+
const skipInactive = options?.skipInactive ?? true;
|
|
80
|
+
const discoveryResults = await this.discover();
|
|
81
|
+
const registered = [];
|
|
82
|
+
const existing = [];
|
|
83
|
+
const skipped = [];
|
|
84
|
+
const errors = [];
|
|
85
|
+
const discoveredIds = new Set();
|
|
86
|
+
// Process all discovered agents
|
|
87
|
+
for (const result of discoveryResults) {
|
|
88
|
+
if (result.errors?.length) {
|
|
89
|
+
errors.push(...result.errors);
|
|
90
|
+
}
|
|
91
|
+
for (const agent of result.agents) {
|
|
92
|
+
// Skip inactive agents if configured
|
|
93
|
+
if (skipInactive && agent.active === false) {
|
|
94
|
+
skipped.push(agent);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
// Build the Grillo agent ID from the external ID
|
|
98
|
+
const agentId = this.buildAgentId(agent);
|
|
99
|
+
discoveredIds.add(agentId);
|
|
100
|
+
// Check if already registered
|
|
101
|
+
const existingAgent = this.registry.get(agentId);
|
|
102
|
+
if (existingAgent) {
|
|
103
|
+
existing.push(agent);
|
|
104
|
+
}
|
|
105
|
+
else if (autoRegister) {
|
|
106
|
+
// Register new agent
|
|
107
|
+
this.registry.register({
|
|
108
|
+
agentId,
|
|
109
|
+
agentName: agent.name,
|
|
110
|
+
agentType: agent.agentType,
|
|
111
|
+
provider: agent.provider,
|
|
112
|
+
model: agent.model,
|
|
113
|
+
category: agent.category ?? AgentCategory.INTERNAL_UTILITY,
|
|
114
|
+
riskTier: agent.riskTier ?? RiskTier.MEDIUM,
|
|
115
|
+
tags: agent.tags ?? [],
|
|
116
|
+
metadata: {
|
|
117
|
+
...agent.metadata,
|
|
118
|
+
discoveredBy: result.source,
|
|
119
|
+
discoveredAt: result.scannedAt.toISOString(),
|
|
120
|
+
framework: agent.framework,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
registered.push(agent);
|
|
124
|
+
this.auditLog?.append({
|
|
125
|
+
action: "agent_discovered",
|
|
126
|
+
actor: "discovery-service",
|
|
127
|
+
agentId,
|
|
128
|
+
description: `Auto-registered ${agent.name} (${agent.model}@${agent.provider}) from ${result.source}.`,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
skipped.push(agent);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Find orphaned agents (in registry but not discovered)
|
|
137
|
+
const orphaned = [];
|
|
138
|
+
if (this.adapters.size > 0) {
|
|
139
|
+
for (const agent of this.registry.all()) {
|
|
140
|
+
if (!discoveredIds.has(agent.agentId)) {
|
|
141
|
+
orphaned.push(agent.agentId);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const durationMs = Date.now() - startTime;
|
|
146
|
+
// Notify if new agents were found
|
|
147
|
+
if (registered.length > 0 && this.notifier) {
|
|
148
|
+
await this.notifier.notify({
|
|
149
|
+
event: "agent_discovered",
|
|
150
|
+
message: `Discovery scan found ${registered.length} new agent(s). Auto-registered.`,
|
|
151
|
+
data: {
|
|
152
|
+
newAgents: registered.map((a) => a.name),
|
|
153
|
+
adapters: discoveryResults.map((r) => r.source),
|
|
154
|
+
},
|
|
155
|
+
timestamp: new Date(),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
this.auditLog?.append({
|
|
159
|
+
action: "agent_discovered",
|
|
160
|
+
actor: "discovery-service",
|
|
161
|
+
description: `Discovery scan complete: ${registered.length} new, ${existing.length} existing, ` +
|
|
162
|
+
`${orphaned.length} orphaned, ${skipped.length} skipped, ${errors.length} errors. ` +
|
|
163
|
+
`Duration: ${durationMs}ms.`,
|
|
164
|
+
});
|
|
165
|
+
return {
|
|
166
|
+
registered,
|
|
167
|
+
existing,
|
|
168
|
+
orphaned,
|
|
169
|
+
skipped,
|
|
170
|
+
errors,
|
|
171
|
+
durationMs,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
// ============================================================
|
|
175
|
+
// Health Checks
|
|
176
|
+
// ============================================================
|
|
177
|
+
/**
|
|
178
|
+
* Check health of all registered adapters.
|
|
179
|
+
*/
|
|
180
|
+
async healthCheck() {
|
|
181
|
+
const results = {};
|
|
182
|
+
for (const adapter of this.adapters.values()) {
|
|
183
|
+
try {
|
|
184
|
+
results[adapter.id] = await adapter.healthCheck();
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
results[adapter.id] = false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return results;
|
|
191
|
+
}
|
|
192
|
+
// ============================================================
|
|
193
|
+
// Helpers
|
|
194
|
+
// ============================================================
|
|
195
|
+
/**
|
|
196
|
+
* Build a Grillo-internal agent ID from a discovered agent.
|
|
197
|
+
* Format: {framework}-{externalId} or just {externalId} if no framework.
|
|
198
|
+
*/
|
|
199
|
+
buildAgentId(agent) {
|
|
200
|
+
if (agent.framework) {
|
|
201
|
+
return `${agent.framework}-${agent.externalId}`;
|
|
202
|
+
}
|
|
203
|
+
return agent.externalId;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Format discovery results as human-readable text.
|
|
207
|
+
*/
|
|
208
|
+
formatResults(result) {
|
|
209
|
+
const lines = [
|
|
210
|
+
"## Discovery Scan Results",
|
|
211
|
+
"",
|
|
212
|
+
`**Duration:** ${result.durationMs}ms`,
|
|
213
|
+
`**New agents registered:** ${result.registered.length}`,
|
|
214
|
+
`**Already known:** ${result.existing.length}`,
|
|
215
|
+
`**Orphaned (in registry, not discovered):** ${result.orphaned.length}`,
|
|
216
|
+
`**Skipped:** ${result.skipped.length}`,
|
|
217
|
+
];
|
|
218
|
+
if (result.registered.length > 0) {
|
|
219
|
+
lines.push("", "### Newly Registered");
|
|
220
|
+
for (const a of result.registered) {
|
|
221
|
+
lines.push(`- **${a.name}** — ${a.model}@${a.provider} (${a.framework ?? "unknown"})`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (result.orphaned.length > 0) {
|
|
225
|
+
lines.push("", "### Orphaned Agents");
|
|
226
|
+
lines.push("_These agents are in Grillo's registry but were not found by any discovery adapter:_");
|
|
227
|
+
for (const id of result.orphaned) {
|
|
228
|
+
lines.push(`- \`${id}\``);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (result.errors.length > 0) {
|
|
232
|
+
lines.push("", "### Errors");
|
|
233
|
+
for (const e of result.errors) {
|
|
234
|
+
lines.push(`- ${e}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return lines.join("\n");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=discovery-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-service.js","sourceRoot":"","sources":["../../src/discovery/discovery-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAqB/D,mEAAmE;AACnE,oBAAoB;AACpB,mEAAmE;AAEnE,MAAM,OAAO,gBAAgB;IACV,QAAQ,GAAkC,IAAI,GAAG,EAAE,CAAC;IACpD,QAAQ,CAAgB;IACxB,QAAQ,CAAkB;IAC1B,QAAQ,CAAkB;IAE3C,YAAY,MAIX;QACC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC;IAC1C,CAAC;IAED,+DAA+D;IAC/D,qBAAqB;IACrB,+DAA+D;IAE/D;;OAEG;IACH,UAAU,CAAC,OAAyB;QAClC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,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KAAK,CAAC,CAAC,SAAS,IAAI,SAAS,GAAG,CAC3E,CAAC;YACJ,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,qBAAqB,CAAC,CAAC;YACtC,KAAK,CAAC,IAAI,CACR,sFAAsF,CACvF,CAAC;YACF,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACjC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;YAC7B,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAC9B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grillo Cricket — Drift Detector
|
|
3
|
+
*
|
|
4
|
+
* Temporal Drift Index (TDI) calculator. Detects when an agent's scores
|
|
5
|
+
* drift from its established baseline. Framework-agnostic: works with
|
|
6
|
+
* any dimension set (LCSH, virtue, ethics, opex).
|
|
7
|
+
*
|
|
8
|
+
* TDI = sqrt(sum((current_i - baseline_i)^2) / n)
|
|
9
|
+
*
|
|
10
|
+
* The baseline is an EMA (exponential moving average) of all historical
|
|
11
|
+
* scores, so it adapts to legitimate model improvements while flagging
|
|
12
|
+
* sudden drops.
|
|
13
|
+
*/
|
|
14
|
+
import type { DimensionScores, DriftReport, AgentRecord } from "../registry/types.js";
|
|
15
|
+
import type { GrilloConfig } from "../config/schema.js";
|
|
16
|
+
/**
|
|
17
|
+
* Calculate the Temporal Drift Index between current scores and baseline.
|
|
18
|
+
*
|
|
19
|
+
* @returns TDI value (0 = no drift, higher = more drift)
|
|
20
|
+
*/
|
|
21
|
+
export declare function calculateTDI(current: DimensionScores, baseline: DimensionScores): number;
|
|
22
|
+
/**
|
|
23
|
+
* Determine drift severity from TDI value.
|
|
24
|
+
*/
|
|
25
|
+
export declare function driftSeverity(tdi: number, config: GrilloConfig): "none" | "low" | "medium" | "high" | "critical";
|
|
26
|
+
/**
|
|
27
|
+
* Per-dimension drift breakdown.
|
|
28
|
+
*/
|
|
29
|
+
export declare function dimensionDrifts(current: DimensionScores, baseline: DimensionScores): Record<string, number>;
|
|
30
|
+
export declare class DriftDetector {
|
|
31
|
+
private readonly config;
|
|
32
|
+
constructor(config: GrilloConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Analyze drift for a single agent given their current scores.
|
|
35
|
+
*/
|
|
36
|
+
analyze(agent: AgentRecord, currentScores: DimensionScores): DriftReport;
|
|
37
|
+
/**
|
|
38
|
+
* Update the baseline using EMA (exponential moving average).
|
|
39
|
+
* Returns the updated baseline.
|
|
40
|
+
*/
|
|
41
|
+
updateBaseline(currentBaseline: DimensionScores, newScores: DimensionScores): DimensionScores;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a drift report should trigger a notification.
|
|
44
|
+
*/
|
|
45
|
+
shouldNotify(report: DriftReport): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Format a drift report as a human-readable summary.
|
|
48
|
+
*/
|
|
49
|
+
formatReport(report: DriftReport): string;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../src/drift/detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMxD;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,eAAe,GACxB,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,YAAY,GACnB,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAQjD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,eAAe,GACxB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxB;AAMD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,YAAY;IAIhC;;OAEG;IACH,OAAO,CACL,KAAK,EAAE,WAAW,EAClB,aAAa,EAAE,eAAe,GAC7B,WAAW;IAiCd;;;OAGG;IACH,cAAc,CACZ,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,eAAe,GACzB,eAAe;IAoBlB;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO;IAI1C;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM;CAoB1C"}
|