@tanmaysangam018/crossagent 0.0.0-stage → 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/README.md CHANGED
@@ -1,3 +1,156 @@
1
- # Temporary Holding Version
1
+ # crossagent
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Persistent memory + multi-model routing for AI apps.
4
+
5
+ Store what your users tell any AI. Search it semantically. Build apps that remember.
6
+
7
+ ```bash
8
+ npm install crossagent
9
+ ```
10
+
11
+ ---
12
+
13
+ ## Quick start
14
+
15
+ ```ts
16
+ import { Crossagent } from 'crossagent'
17
+
18
+ const ca = new Crossagent()
19
+
20
+ // Store a memory after any AI conversation
21
+ await ca.memory.add({
22
+ userId: 'user_123',
23
+ message: 'I prefer TypeScript over Python for backend work.',
24
+ response: "Got it, I'll keep that in mind.",
25
+ })
26
+
27
+ // Semantic search over everything the user has ever said
28
+ const memories = await ca.memory.search('user_123', 'programming preferences')
29
+ // → [{ content: 'User prefers TypeScript over Python for backend.', score: 0.91 }]
30
+
31
+ // Ask a natural language question over stored memories
32
+ const answer = await ca.memory.ask('user_123', 'What languages does this user like?')
33
+ // → "Based on your memories, you prefer TypeScript for backend work."
34
+ ```
35
+
36
+ ---
37
+
38
+ ## API
39
+
40
+ ### `new Crossagent(options?)`
41
+
42
+ | Option | Type | Default | Description |
43
+ |--------|------|---------|-------------|
44
+ | `apiKey` | `string` | — | Your Crossagent API key (optional on free tier) |
45
+ | `baseUrl` | `string` | `https://backend-wine-phi-85.vercel.app` | Self-host override |
46
+
47
+ ---
48
+
49
+ ### `ca.memory.add(opts)`
50
+
51
+ Stores a conversation turn as one or more atomic memories. Facts are extracted automatically via LLM and embedded with pgvector.
52
+
53
+ ```ts
54
+ await ca.memory.add({
55
+ userId: 'user_123',
56
+ message: 'I live in New York and work in fintech.',
57
+ response: 'Noted!',
58
+ sourceAgent: 'my-app', // optional — where the message came from
59
+ targetAgent: 'claude', // optional — which AI responded
60
+ })
61
+ ```
62
+
63
+ ---
64
+
65
+ ### `ca.memory.search(userId, query, limit?)`
66
+
67
+ Semantic search over a user's memories. Returns matches sorted by relevance.
68
+
69
+ ```ts
70
+ const results = await ca.memory.search('user_123', 'where does the user live', 5)
71
+ // → [{ id, content, mem_type, score }, ...]
72
+ ```
73
+
74
+ ---
75
+
76
+ ### `ca.memory.ask(userId, question)`
77
+
78
+ Natural language Q&A over stored memories. Uses an LLM to synthesize an answer from the user's memory.
79
+
80
+ ```ts
81
+ const answer = await ca.memory.ask('user_123', 'What industry does this user work in?')
82
+ // → "Based on your memories, you work in fintech in New York."
83
+ ```
84
+
85
+ ---
86
+
87
+ ### `ca.memory.list(userId)`
88
+
89
+ Returns all memories for a user, ordered by recency.
90
+
91
+ ```ts
92
+ const all = await ca.memory.list('user_123')
93
+ ```
94
+
95
+ ---
96
+
97
+ ### `ca.memory.profile(userId)`
98
+
99
+ Returns a pre-built profile: permanent facts and recent activity context.
100
+
101
+ ```ts
102
+ const { static_facts, dynamic_ctx } = await ca.memory.profile('user_123')
103
+ // static_facts: ['User works in fintech', 'User prefers TypeScript']
104
+ // dynamic_ctx: ['User is building a payments API']
105
+ ```
106
+
107
+ ---
108
+
109
+ ### `ca.memory.delete(userId, memoryId)`
110
+
111
+ Soft-deletes a memory (marks it superseded).
112
+
113
+ ```ts
114
+ await ca.memory.delete('user_123', 'mem_id_here')
115
+ ```
116
+
117
+ ---
118
+
119
+ ## MCP server
120
+
121
+ Connect any MCP-compatible AI agent directly to Crossagent memory:
122
+
123
+ ```
124
+ https://backend-wine-phi-85.vercel.app/mcp
125
+ ```
126
+
127
+ Tools exposed: `remember`, `recall`, `get_profile`, `list_memories`
128
+
129
+ ---
130
+
131
+ ## Memory types
132
+
133
+ | Type | What it means | Expires |
134
+ |------|---------------|---------|
135
+ | `fact` | Permanent info — name, location, job, stack | Never |
136
+ | `preference` | What the user likes or wants | Never |
137
+ | `episode` | Current activity — "working on X" | 21 days |
138
+
139
+ ---
140
+
141
+ ## Self-hosting
142
+
143
+ The backend is open source. Deploy your own in one command:
144
+
145
+ ```bash
146
+ git clone https://github.com/TanmaySangam18/crossagent-backend
147
+ vercel deploy
148
+ ```
149
+
150
+ Requires: `GEMINI_API_KEY`, `SUPABASE_URL`, `SUPABASE_SERVICE_KEY`
151
+
152
+ ---
153
+
154
+ ## License
155
+
156
+ MIT
@@ -0,0 +1,45 @@
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 };
@@ -0,0 +1,45 @@
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.js ADDED
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Crossagent: () => Crossagent,
24
+ CrossagentMemory: () => CrossagentMemory,
25
+ default: () => index_default
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+ var DEFAULT_BASE = "https://backend-wine-phi-85.vercel.app";
29
+ var CrossagentMemory = class {
30
+ constructor(base, headers) {
31
+ this.base = base;
32
+ this.headers = headers;
33
+ }
34
+ async add(opts) {
35
+ await fetch(`${this.base}/memory/store`, {
36
+ method: "POST",
37
+ headers: { "Content-Type": "application/json", ...this.headers },
38
+ body: JSON.stringify({
39
+ userId: opts.userId,
40
+ message: opts.message,
41
+ response: opts.response,
42
+ sourceAgent: opts.sourceAgent ?? "sdk",
43
+ targetAgent: opts.targetAgent ?? "sdk"
44
+ })
45
+ });
46
+ }
47
+ async search(userId, query, limit = 5) {
48
+ const url = `${this.base}/memory/search?userId=${encodeURIComponent(userId)}&q=${encodeURIComponent(query)}&limit=${limit}`;
49
+ const res = await fetch(url, { headers: this.headers });
50
+ const data = await res.json();
51
+ return data.memories ?? [];
52
+ }
53
+ async list(userId) {
54
+ const res = await fetch(`${this.base}/memory/list?userId=${encodeURIComponent(userId)}`, { headers: this.headers });
55
+ const data = await res.json();
56
+ return data.memories ?? [];
57
+ }
58
+ async ask(userId, question) {
59
+ const res = await fetch(`${this.base}/memory/ask`, {
60
+ method: "POST",
61
+ headers: { "Content-Type": "application/json", ...this.headers },
62
+ body: JSON.stringify({ userId, question })
63
+ });
64
+ const data = await res.json();
65
+ return data.response ?? "";
66
+ }
67
+ async profile(userId) {
68
+ const res = await fetch(`${this.base}/memory/profile?userId=${encodeURIComponent(userId)}`, { headers: this.headers });
69
+ const data = await res.json();
70
+ return data.profile ?? { static_facts: [], dynamic_ctx: [] };
71
+ }
72
+ async delete(userId, memoryId) {
73
+ await fetch(`${this.base}/memory/delete/${memoryId}?userId=${encodeURIComponent(userId)}`, {
74
+ method: "DELETE",
75
+ headers: this.headers
76
+ });
77
+ }
78
+ };
79
+ var Crossagent = class {
80
+ constructor(opts = {}) {
81
+ const base = (opts.baseUrl ?? DEFAULT_BASE).replace(/\/$/, "");
82
+ const headers = {};
83
+ if (opts.apiKey) headers["x-api-key"] = opts.apiKey;
84
+ this.memory = new CrossagentMemory(base, headers);
85
+ this.mcpUrl = `${base}/mcp`;
86
+ }
87
+ };
88
+ var index_default = Crossagent;
89
+ // Annotate the CommonJS export names for ESM import in node:
90
+ 0 && (module.exports = {
91
+ Crossagent,
92
+ CrossagentMemory
93
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,67 @@
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
+ };
package/package.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "@tanmaysangam018/crossagent",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Memory + multi-model API for AI apps. Persistent user memory with semantic search, cross-AI routing, and MCP support.",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist", "README.md"],
16
+ "scripts": {
17
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
18
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
19
+ "prepublishOnly": "npm run build"
20
+ },
21
+ "keywords": ["ai", "memory", "llm", "crossagent", "multi-model", "mcp", "chatgpt", "claude", "gemini"],
22
+ "author": "Tanmay Sangam",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/TanmaySangam18/crossagent-backend"
27
+ },
28
+ "devDependencies": {
29
+ "tsup": "^8.0.0",
30
+ "typescript": "^5.0.0"
31
+ }
32
+ }