@tanmaysangam018/crossagent 0.1.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/README.md +28 -4
- package/dist/index.d.ts +68 -8
- package/dist/index.js +110 -93
- package/package.json +22 -10
- package/dist/index.d.mts +0 -45
- package/dist/index.mjs +0 -67
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# crossagent
|
|
1
|
+
# @tanmaysangam018/crossagent (Engram SDK)
|
|
2
2
|
|
|
3
|
-
Persistent memory +
|
|
3
|
+
Persistent memory + cognitive security layer for AI applications.
|
|
4
4
|
|
|
5
|
-
Store what your users tell any AI. Search it semantically.
|
|
5
|
+
Store what your users tell any AI. Search it semantically. Scan every AI response for prompt injection before you act on it.
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install crossagent
|
|
8
|
+
npm install @tanmaysangam018/crossagent
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
---
|
|
@@ -35,6 +35,30 @@ const answer = await ca.memory.ask('user_123', 'What languages does this user li
|
|
|
35
35
|
|
|
36
36
|
---
|
|
37
37
|
|
|
38
|
+
## Cognitive security: scan before you trust
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import Crossagent from '@tanmaysangam018/crossagent'
|
|
42
|
+
|
|
43
|
+
const engram = new Crossagent({ apiKey: 'your-key' })
|
|
44
|
+
|
|
45
|
+
// Scan any AI response for injection attacks before acting on it
|
|
46
|
+
const scan = await engram.memory.scan(aiResponse)
|
|
47
|
+
|
|
48
|
+
if (scan.verdict !== 'clean') {
|
|
49
|
+
console.warn('Injection detected:', scan.flags)
|
|
50
|
+
// → { type: 'instruction_override', severity: 'critical', match: 'Ignore all previous instructions', position: 0 }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// score: 0–100 | verdict: clean / suspicious / likely_injection / definite_injection
|
|
54
|
+
// Detects: instruction_override, role_hijacking, context_extraction, data_exfiltration,
|
|
55
|
+
// encoded_payload, urgency_manipulation, chain_injection, indirect_injection
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Try it live (no account needed): **crossagentsi.vercel.app/demo**
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
38
62
|
## API
|
|
39
63
|
|
|
40
64
|
### `new Crossagent(options?)`
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
interface CrossagentOptions {
|
|
1
|
+
export interface CrossagentOptions {
|
|
2
2
|
apiKey?: string;
|
|
3
3
|
baseUrl?: string;
|
|
4
4
|
}
|
|
5
|
-
interface Memory {
|
|
5
|
+
export interface Memory {
|
|
6
6
|
id: string;
|
|
7
7
|
content: string;
|
|
8
8
|
mem_type: 'fact' | 'preference' | 'episode';
|
|
@@ -12,14 +12,61 @@ interface Memory {
|
|
|
12
12
|
created_at: string;
|
|
13
13
|
expires_at: string | null;
|
|
14
14
|
}
|
|
15
|
-
interface MemoryMatch extends Pick<Memory, 'id' | 'content' | 'mem_type' | 'src_agent' | 'tgt_agent'> {
|
|
15
|
+
export interface MemoryMatch extends Pick<Memory, 'id' | 'content' | 'mem_type' | 'src_agent' | 'tgt_agent'> {
|
|
16
16
|
score: number;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
export interface ScanFlag {
|
|
19
|
+
type: string;
|
|
20
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
21
|
+
match: string;
|
|
22
|
+
position: number;
|
|
23
|
+
description: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ScanResult {
|
|
26
|
+
score: number;
|
|
27
|
+
verdict: 'clean' | 'suspicious' | 'likely_injection' | 'definite_injection';
|
|
28
|
+
flags: ScanFlag[];
|
|
29
|
+
summary: string;
|
|
30
|
+
scanned_at: string;
|
|
31
|
+
}
|
|
32
|
+
export interface Profile {
|
|
19
33
|
static_facts: string[];
|
|
20
34
|
dynamic_ctx: string[];
|
|
21
35
|
}
|
|
22
|
-
|
|
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
|
+
}
|
|
69
|
+
export declare class CrossagentMemory {
|
|
23
70
|
private base;
|
|
24
71
|
private headers;
|
|
25
72
|
constructor(base: string, headers: Record<string, string>);
|
|
@@ -29,17 +76,30 @@ declare class CrossagentMemory {
|
|
|
29
76
|
response: string;
|
|
30
77
|
sourceAgent?: string;
|
|
31
78
|
targetAgent?: string;
|
|
79
|
+
agentId?: string;
|
|
32
80
|
}): Promise<void>;
|
|
33
81
|
search(userId: string, query: string, limit?: number): Promise<MemoryMatch[]>;
|
|
34
82
|
list(userId: string): Promise<Memory[]>;
|
|
35
83
|
ask(userId: string, question: string): Promise<string>;
|
|
36
84
|
profile(userId: string): Promise<Profile>;
|
|
37
85
|
delete(userId: string, memoryId: string): Promise<void>;
|
|
86
|
+
scan(text: string): Promise<ScanResult>;
|
|
38
87
|
}
|
|
39
|
-
declare class
|
|
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
|
+
}
|
|
96
|
+
export declare class Crossagent {
|
|
40
97
|
readonly memory: CrossagentMemory;
|
|
98
|
+
readonly security: CrossagentSecurity;
|
|
41
99
|
readonly mcpUrl: string;
|
|
100
|
+
private base;
|
|
101
|
+
private headers;
|
|
42
102
|
constructor(opts?: CrossagentOptions);
|
|
103
|
+
patterns(): Promise<PatternReport>;
|
|
43
104
|
}
|
|
44
|
-
|
|
45
|
-
export { Crossagent, CrossagentMemory, type CrossagentOptions, type Memory, type MemoryMatch, type Profile, Crossagent as default };
|
|
105
|
+
export default Crossagent;
|
package/dist/index.js
CHANGED
|
@@ -1,93 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
})
|
|
1
|
+
const DEFAULT_BASE = 'https://backend-wine-phi-85.vercel.app';
|
|
2
|
+
export class CrossagentMemory {
|
|
3
|
+
constructor(base, headers) {
|
|
4
|
+
this.base = base;
|
|
5
|
+
this.headers = headers;
|
|
6
|
+
}
|
|
7
|
+
async add(opts) {
|
|
8
|
+
await fetch(`${this.base}/memory/store`, {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
headers: { 'Content-Type': 'application/json', ...this.headers },
|
|
11
|
+
body: JSON.stringify({
|
|
12
|
+
userId: opts.userId,
|
|
13
|
+
message: opts.message,
|
|
14
|
+
response: opts.response,
|
|
15
|
+
sourceAgent: opts.sourceAgent ?? 'sdk',
|
|
16
|
+
targetAgent: opts.targetAgent ?? 'sdk',
|
|
17
|
+
agentId: opts.agentId,
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async search(userId, query, limit = 5) {
|
|
22
|
+
const url = `${this.base}/memory/search?userId=${encodeURIComponent(userId)}&q=${encodeURIComponent(query)}&limit=${limit}`;
|
|
23
|
+
const res = await fetch(url, { headers: this.headers });
|
|
24
|
+
const data = await res.json();
|
|
25
|
+
return data.memories ?? [];
|
|
26
|
+
}
|
|
27
|
+
async list(userId) {
|
|
28
|
+
const res = await fetch(`${this.base}/memory/list?userId=${encodeURIComponent(userId)}`, { headers: this.headers });
|
|
29
|
+
const data = await res.json();
|
|
30
|
+
return data.memories ?? [];
|
|
31
|
+
}
|
|
32
|
+
async ask(userId, question) {
|
|
33
|
+
const res = await fetch(`${this.base}/memory/ask`, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: { 'Content-Type': 'application/json', ...this.headers },
|
|
36
|
+
body: JSON.stringify({ userId, question }),
|
|
37
|
+
});
|
|
38
|
+
const data = await res.json();
|
|
39
|
+
return data.response ?? '';
|
|
40
|
+
}
|
|
41
|
+
async profile(userId) {
|
|
42
|
+
const res = await fetch(`${this.base}/memory/profile?userId=${encodeURIComponent(userId)}`, { headers: this.headers });
|
|
43
|
+
const data = await res.json();
|
|
44
|
+
return data.profile ?? { static_facts: [], dynamic_ctx: [] };
|
|
45
|
+
}
|
|
46
|
+
async delete(userId, memoryId) {
|
|
47
|
+
await fetch(`${this.base}/memory/delete/${memoryId}?userId=${encodeURIComponent(userId)}`, {
|
|
48
|
+
method: 'DELETE',
|
|
49
|
+
headers: this.headers,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async scan(text) {
|
|
53
|
+
const res = await fetch(`${this.base}/memory/scan`, {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
headers: { 'Content-Type': 'application/json' },
|
|
56
|
+
body: JSON.stringify({ text }),
|
|
57
|
+
});
|
|
58
|
+
if (!res.ok)
|
|
59
|
+
throw new Error(`scan failed: ${res.status}`);
|
|
60
|
+
return res.json();
|
|
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
|
+
}
|
|
92
|
+
export class Crossagent {
|
|
93
|
+
constructor(opts = {}) {
|
|
94
|
+
this.base = (opts.baseUrl ?? DEFAULT_BASE).replace(/\/$/, '');
|
|
95
|
+
this.headers = {};
|
|
96
|
+
// Fix: backend expects Authorization: Bearer <eng_key>, not x-api-key
|
|
97
|
+
if (opts.apiKey)
|
|
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();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export default Crossagent;
|
package/package.json
CHANGED
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanmaysangam018/crossagent",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
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
|
-
"module": "./dist/index.
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
11
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.
|
|
12
|
-
"require": "./dist/index.js"
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"files": [
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
16
19
|
"scripts": {
|
|
17
|
-
"build": "
|
|
18
|
-
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
20
|
+
"build": "tsc --skipLibCheck --outDir dist --declaration",
|
|
19
21
|
"prepublishOnly": "npm run build"
|
|
20
22
|
},
|
|
21
|
-
"keywords": [
|
|
23
|
+
"keywords": [
|
|
24
|
+
"ai",
|
|
25
|
+
"memory",
|
|
26
|
+
"llm",
|
|
27
|
+
"crossagent",
|
|
28
|
+
"multi-model",
|
|
29
|
+
"mcp",
|
|
30
|
+
"chatgpt",
|
|
31
|
+
"claude",
|
|
32
|
+
"gemini"
|
|
33
|
+
],
|
|
22
34
|
"author": "Tanmay Sangam",
|
|
23
35
|
"license": "MIT",
|
|
24
36
|
"repository": {
|
|
@@ -26,7 +38,7 @@
|
|
|
26
38
|
"url": "https://github.com/TanmaySangam18/crossagent-backend"
|
|
27
39
|
},
|
|
28
40
|
"devDependencies": {
|
|
29
|
-
"tsup": "^
|
|
41
|
+
"tsup": "^9.0.0",
|
|
30
42
|
"typescript": "^5.0.0"
|
|
31
43
|
}
|
|
32
44
|
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
interface CrossagentOptions {
|
|
2
|
-
apiKey?: string;
|
|
3
|
-
baseUrl?: string;
|
|
4
|
-
}
|
|
5
|
-
interface Memory {
|
|
6
|
-
id: string;
|
|
7
|
-
content: string;
|
|
8
|
-
mem_type: 'fact' | 'preference' | 'episode';
|
|
9
|
-
src_agent: string;
|
|
10
|
-
tgt_agent: string;
|
|
11
|
-
strength: number;
|
|
12
|
-
created_at: string;
|
|
13
|
-
expires_at: string | null;
|
|
14
|
-
}
|
|
15
|
-
interface MemoryMatch extends Pick<Memory, 'id' | 'content' | 'mem_type' | 'src_agent' | 'tgt_agent'> {
|
|
16
|
-
score: number;
|
|
17
|
-
}
|
|
18
|
-
interface Profile {
|
|
19
|
-
static_facts: string[];
|
|
20
|
-
dynamic_ctx: string[];
|
|
21
|
-
}
|
|
22
|
-
declare class CrossagentMemory {
|
|
23
|
-
private base;
|
|
24
|
-
private headers;
|
|
25
|
-
constructor(base: string, headers: Record<string, string>);
|
|
26
|
-
add(opts: {
|
|
27
|
-
userId: string;
|
|
28
|
-
message: string;
|
|
29
|
-
response: string;
|
|
30
|
-
sourceAgent?: string;
|
|
31
|
-
targetAgent?: string;
|
|
32
|
-
}): Promise<void>;
|
|
33
|
-
search(userId: string, query: string, limit?: number): Promise<MemoryMatch[]>;
|
|
34
|
-
list(userId: string): Promise<Memory[]>;
|
|
35
|
-
ask(userId: string, question: string): Promise<string>;
|
|
36
|
-
profile(userId: string): Promise<Profile>;
|
|
37
|
-
delete(userId: string, memoryId: string): Promise<void>;
|
|
38
|
-
}
|
|
39
|
-
declare class Crossagent {
|
|
40
|
-
readonly memory: CrossagentMemory;
|
|
41
|
-
readonly mcpUrl: string;
|
|
42
|
-
constructor(opts?: CrossagentOptions);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { Crossagent, CrossagentMemory, type CrossagentOptions, type Memory, type MemoryMatch, type Profile, Crossagent as default };
|
package/dist/index.mjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
var DEFAULT_BASE = "https://backend-wine-phi-85.vercel.app";
|
|
3
|
-
var CrossagentMemory = class {
|
|
4
|
-
constructor(base, headers) {
|
|
5
|
-
this.base = base;
|
|
6
|
-
this.headers = headers;
|
|
7
|
-
}
|
|
8
|
-
async add(opts) {
|
|
9
|
-
await fetch(`${this.base}/memory/store`, {
|
|
10
|
-
method: "POST",
|
|
11
|
-
headers: { "Content-Type": "application/json", ...this.headers },
|
|
12
|
-
body: JSON.stringify({
|
|
13
|
-
userId: opts.userId,
|
|
14
|
-
message: opts.message,
|
|
15
|
-
response: opts.response,
|
|
16
|
-
sourceAgent: opts.sourceAgent ?? "sdk",
|
|
17
|
-
targetAgent: opts.targetAgent ?? "sdk"
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
async search(userId, query, limit = 5) {
|
|
22
|
-
const url = `${this.base}/memory/search?userId=${encodeURIComponent(userId)}&q=${encodeURIComponent(query)}&limit=${limit}`;
|
|
23
|
-
const res = await fetch(url, { headers: this.headers });
|
|
24
|
-
const data = await res.json();
|
|
25
|
-
return data.memories ?? [];
|
|
26
|
-
}
|
|
27
|
-
async list(userId) {
|
|
28
|
-
const res = await fetch(`${this.base}/memory/list?userId=${encodeURIComponent(userId)}`, { headers: this.headers });
|
|
29
|
-
const data = await res.json();
|
|
30
|
-
return data.memories ?? [];
|
|
31
|
-
}
|
|
32
|
-
async ask(userId, question) {
|
|
33
|
-
const res = await fetch(`${this.base}/memory/ask`, {
|
|
34
|
-
method: "POST",
|
|
35
|
-
headers: { "Content-Type": "application/json", ...this.headers },
|
|
36
|
-
body: JSON.stringify({ userId, question })
|
|
37
|
-
});
|
|
38
|
-
const data = await res.json();
|
|
39
|
-
return data.response ?? "";
|
|
40
|
-
}
|
|
41
|
-
async profile(userId) {
|
|
42
|
-
const res = await fetch(`${this.base}/memory/profile?userId=${encodeURIComponent(userId)}`, { headers: this.headers });
|
|
43
|
-
const data = await res.json();
|
|
44
|
-
return data.profile ?? { static_facts: [], dynamic_ctx: [] };
|
|
45
|
-
}
|
|
46
|
-
async delete(userId, memoryId) {
|
|
47
|
-
await fetch(`${this.base}/memory/delete/${memoryId}?userId=${encodeURIComponent(userId)}`, {
|
|
48
|
-
method: "DELETE",
|
|
49
|
-
headers: this.headers
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var Crossagent = class {
|
|
54
|
-
constructor(opts = {}) {
|
|
55
|
-
const base = (opts.baseUrl ?? DEFAULT_BASE).replace(/\/$/, "");
|
|
56
|
-
const headers = {};
|
|
57
|
-
if (opts.apiKey) headers["x-api-key"] = opts.apiKey;
|
|
58
|
-
this.memory = new CrossagentMemory(base, headers);
|
|
59
|
-
this.mcpUrl = `${base}/mcp`;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
var index_default = Crossagent;
|
|
63
|
-
export {
|
|
64
|
-
Crossagent,
|
|
65
|
-
CrossagentMemory,
|
|
66
|
-
index_default as default
|
|
67
|
-
};
|