@tanmaysangam018/crossagent 0.2.0 → 0.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/dist/index.d.ts CHANGED
@@ -33,6 +33,39 @@ export interface Profile {
33
33
  static_facts: string[];
34
34
  dynamic_ctx: string[];
35
35
  }
36
+ export interface PatternCluster {
37
+ category: string;
38
+ label: string;
39
+ count: number;
40
+ recentCount: number;
41
+ velocity: number;
42
+ topMemories: string[];
43
+ dominantAI: string;
44
+ aiBreakdown: Record<string, number>;
45
+ }
46
+ export interface PatternReport {
47
+ dominant: PatternCluster | null;
48
+ clusters: PatternCluster[];
49
+ prediction: string;
50
+ anomaly: string | null;
51
+ insight: string;
52
+ totalMemories: number;
53
+ aiDiversity: number;
54
+ generatedAt: string;
55
+ }
56
+ export interface IntegrityReport {
57
+ agentId: string | null;
58
+ score: number;
59
+ verdict: 'pristine' | 'stable' | 'drifting' | 'compromised';
60
+ driftOnset: string | null;
61
+ sessionsAffected: number;
62
+ baselineAvgRisk: number;
63
+ recentAvgRisk: number;
64
+ anomalyCount: number;
65
+ sensitiveRate: number;
66
+ topFlags: string[];
67
+ generatedAt: string;
68
+ }
36
69
  export declare class CrossagentMemory {
37
70
  private base;
38
71
  private headers;
@@ -43,6 +76,7 @@ export declare class CrossagentMemory {
43
76
  response: string;
44
77
  sourceAgent?: string;
45
78
  targetAgent?: string;
79
+ agentId?: string;
46
80
  }): Promise<void>;
47
81
  search(userId: string, query: string, limit?: number): Promise<MemoryMatch[]>;
48
82
  list(userId: string): Promise<Memory[]>;
@@ -51,9 +85,21 @@ export declare class CrossagentMemory {
51
85
  delete(userId: string, memoryId: string): Promise<void>;
52
86
  scan(text: string): Promise<ScanResult>;
53
87
  }
88
+ export declare class CrossagentSecurity {
89
+ private base;
90
+ private headers;
91
+ constructor(base: string, headers: Record<string, string>);
92
+ integrity(agentId?: string): Promise<IntegrityReport>;
93
+ anomalies(): Promise<unknown[]>;
94
+ audit(limit?: number): Promise<unknown[]>;
95
+ }
54
96
  export declare class Crossagent {
55
97
  readonly memory: CrossagentMemory;
98
+ readonly security: CrossagentSecurity;
56
99
  readonly mcpUrl: string;
100
+ private base;
101
+ private headers;
57
102
  constructor(opts?: CrossagentOptions);
103
+ patterns(): Promise<PatternReport>;
58
104
  }
59
105
  export default Crossagent;
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ export class CrossagentMemory {
14
14
  response: opts.response,
15
15
  sourceAgent: opts.sourceAgent ?? 'sdk',
16
16
  targetAgent: opts.targetAgent ?? 'sdk',
17
+ agentId: opts.agentId,
17
18
  }),
18
19
  });
19
20
  }
@@ -51,7 +52,7 @@ export class CrossagentMemory {
51
52
  async scan(text) {
52
53
  const res = await fetch(`${this.base}/memory/scan`, {
53
54
  method: 'POST',
54
- headers: { 'Content-Type': 'application/json', ...this.headers },
55
+ headers: { 'Content-Type': 'application/json' },
55
56
  body: JSON.stringify({ text }),
56
57
  });
57
58
  if (!res.ok)
@@ -59,14 +60,51 @@ export class CrossagentMemory {
59
60
  return res.json();
60
61
  }
61
62
  }
63
+ export class CrossagentSecurity {
64
+ constructor(base, headers) {
65
+ this.base = base;
66
+ this.headers = headers;
67
+ }
68
+ async integrity(agentId) {
69
+ const url = agentId
70
+ ? `${this.base}/security/integrity?agent_id=${encodeURIComponent(agentId)}`
71
+ : `${this.base}/security/integrity`;
72
+ const res = await fetch(url, { headers: this.headers });
73
+ if (!res.ok)
74
+ throw new Error(`integrity check failed: ${res.status}`);
75
+ return res.json();
76
+ }
77
+ async anomalies() {
78
+ const res = await fetch(`${this.base}/security/anomalies`, { headers: this.headers });
79
+ if (!res.ok)
80
+ throw new Error(`anomalies failed: ${res.status}`);
81
+ const data = await res.json();
82
+ return data.anomalies ?? [];
83
+ }
84
+ async audit(limit = 50) {
85
+ const res = await fetch(`${this.base}/security/audit?limit=${limit}`, { headers: this.headers });
86
+ if (!res.ok)
87
+ throw new Error(`audit failed: ${res.status}`);
88
+ const data = await res.json();
89
+ return data.events ?? [];
90
+ }
91
+ }
62
92
  export class Crossagent {
63
93
  constructor(opts = {}) {
64
- const base = (opts.baseUrl ?? DEFAULT_BASE).replace(/\/$/, '');
65
- const headers = {};
94
+ this.base = (opts.baseUrl ?? DEFAULT_BASE).replace(/\/$/, '');
95
+ this.headers = {};
96
+ // Fix: backend expects Authorization: Bearer <eng_key>, not x-api-key
66
97
  if (opts.apiKey)
67
- headers['x-api-key'] = opts.apiKey;
68
- this.memory = new CrossagentMemory(base, headers);
69
- this.mcpUrl = `${base}/mcp`;
98
+ this.headers['Authorization'] = `Bearer ${opts.apiKey}`;
99
+ this.memory = new CrossagentMemory(this.base, this.headers);
100
+ this.security = new CrossagentSecurity(this.base, this.headers);
101
+ this.mcpUrl = `${this.base}/mcp`;
102
+ }
103
+ async patterns() {
104
+ const res = await fetch(`${this.base}/patterns`, { headers: this.headers });
105
+ if (!res.ok)
106
+ throw new Error(`patterns failed: ${res.status}`);
107
+ return res.json();
70
108
  }
71
109
  }
72
110
  export default Crossagent;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanmaysangam018/crossagent",
3
- "version": "0.2.0",
4
- "description": "Persistent memory + cognitive security layer for AI apps. Semantic memory, pattern intelligence, and prompt injection scanning.",
3
+ "version": "0.3.0",
4
+ "description": "Behavioral firewall for autonomous AI agents. Memory, pattern intelligence, prompt injection scanner + context poisoning detection, and agent integrity scoring.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",