unimemory 0.0.1 → 1.0.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,13 +1,108 @@
1
1
  # UniMemory
2
2
 
3
- UniMemory is a unified memory layer for AI agents.
3
+ AI memory management for your applications.
4
4
 
5
- This package is currently a placeholder while the core system is under active development.
5
+ ## Installation
6
6
 
7
- Planned:
8
- - Local-first memory core
9
- - System-level capture (macOS)
10
- - SDK for Node, browser extensions, and agents
11
- - Search and recall APIs
7
+ ```bash
8
+ npm install unimemory
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import UniMemory from 'unimemory';
15
+
16
+ const client = new UniMemory({
17
+ apiKey: process.env.UNIMEMORY_API_KEY
18
+ });
19
+
20
+ // Add a memory
21
+ await client.addMemory({
22
+ content: "User prefers dark mode",
23
+ sourceApp: "my-app"
24
+ });
25
+
26
+ // Search memories
27
+ const results = await client.search("user preferences");
28
+ console.log(results.results);
29
+ ```
30
+
31
+ ## API
32
+
33
+ ### `new UniMemory(config)`
34
+
35
+ Create a new UniMemory client.
36
+
37
+ ```typescript
38
+ const client = new UniMemory({
39
+ apiKey: 'um_live_xxx...',
40
+ baseUrl: 'https://api.unimemory.ai/api/v1' // optional
41
+ });
42
+ ```
43
+
44
+ ### `client.addMemory(options)`
45
+
46
+ Add a memory.
47
+
48
+ ```typescript
49
+ const result = await client.addMemory({
50
+ content: "Important information to remember",
51
+ sourceApp: "my-app", // optional
52
+ userId: "user123", // optional
53
+ metadata: { key: "value" } // optional
54
+ });
55
+
56
+ // Result:
57
+ // {
58
+ // wasWorthRemembering: true,
59
+ // reason: "Contains user preference",
60
+ // extractedCount: 1,
61
+ // memories: [{ id: "...", wasDeduplicated: false }]
62
+ // }
63
+ ```
64
+
65
+ ### `client.search(query, options?)`
66
+
67
+ Search memories.
68
+
69
+ ```typescript
70
+ const results = await client.search("user preferences", {
71
+ limit: 10,
72
+ userId: "user123",
73
+ minSalience: 0.5
74
+ });
75
+
76
+ // Result:
77
+ // {
78
+ // results: [{ id, content, sector, salience, score, tags }],
79
+ // total: 1,
80
+ // query: "user preferences"
81
+ // }
82
+ ```
83
+
84
+ ### `client.listMemories(options?)`
85
+
86
+ List memories.
87
+
88
+ ```typescript
89
+ const memories = await client.listMemories({
90
+ limit: 50,
91
+ offset: 0,
92
+ userId: "user123",
93
+ sector: "semantic"
94
+ });
95
+ ```
96
+
97
+ ### `client.deleteMemory(memoryId)`
98
+
99
+ Delete a memory.
100
+
101
+ ```typescript
102
+ await client.deleteMemory("memory-id-here");
103
+ ```
104
+
105
+ ## License
106
+
107
+ MIT
12
108
 
13
- Follow development at: https://github.com/unimemory
@@ -0,0 +1,86 @@
1
+ /**
2
+ * UniMemory SDK
3
+ * AI memory management for your applications
4
+ */
5
+ interface UniMemoryConfig {
6
+ apiKey: string;
7
+ baseUrl?: string;
8
+ }
9
+ interface AddMemoryOptions {
10
+ content: string;
11
+ sourceApp?: string;
12
+ userId?: string;
13
+ metadata?: Record<string, unknown>;
14
+ }
15
+ interface AddMemoryResponse {
16
+ wasWorthRemembering: boolean;
17
+ reason?: string;
18
+ extractedCount: number;
19
+ memories?: Array<{
20
+ id: string;
21
+ wasDeduplicated: boolean;
22
+ }>;
23
+ }
24
+ interface SearchOptions {
25
+ limit?: number;
26
+ userId?: string;
27
+ minSalience?: number;
28
+ debug?: boolean;
29
+ }
30
+ interface SearchResult {
31
+ id: string;
32
+ content: string;
33
+ sector?: string;
34
+ salience: number;
35
+ score: number;
36
+ tags: string[];
37
+ }
38
+ interface SearchResponse {
39
+ results: SearchResult[];
40
+ total: number;
41
+ query: string;
42
+ }
43
+ interface Memory {
44
+ id: string;
45
+ content: string;
46
+ sector?: string;
47
+ salience: number;
48
+ tags: string[];
49
+ createdAt: string;
50
+ }
51
+ interface ListMemoriesOptions {
52
+ limit?: number;
53
+ offset?: number;
54
+ userId?: string;
55
+ sector?: string;
56
+ }
57
+ interface ListMemoriesResponse {
58
+ memories: Memory[];
59
+ total: number;
60
+ }
61
+ declare class UniMemory {
62
+ private apiKey;
63
+ private baseUrl;
64
+ constructor(config: UniMemoryConfig);
65
+ private request;
66
+ /**
67
+ * Add a memory to UniMemory
68
+ */
69
+ addMemory(options: AddMemoryOptions): Promise<AddMemoryResponse>;
70
+ /**
71
+ * Search memories
72
+ */
73
+ search(query: string, options?: SearchOptions): Promise<SearchResponse>;
74
+ /**
75
+ * List memories
76
+ */
77
+ listMemories(options?: ListMemoriesOptions): Promise<ListMemoriesResponse>;
78
+ /**
79
+ * Delete a memory
80
+ */
81
+ deleteMemory(memoryId: string): Promise<{
82
+ success: boolean;
83
+ }>;
84
+ }
85
+
86
+ export { type AddMemoryOptions, type AddMemoryResponse, type ListMemoriesOptions, type ListMemoriesResponse, type Memory, type SearchOptions, type SearchResponse, type SearchResult, UniMemory, type UniMemoryConfig, UniMemory as default };
@@ -0,0 +1,86 @@
1
+ /**
2
+ * UniMemory SDK
3
+ * AI memory management for your applications
4
+ */
5
+ interface UniMemoryConfig {
6
+ apiKey: string;
7
+ baseUrl?: string;
8
+ }
9
+ interface AddMemoryOptions {
10
+ content: string;
11
+ sourceApp?: string;
12
+ userId?: string;
13
+ metadata?: Record<string, unknown>;
14
+ }
15
+ interface AddMemoryResponse {
16
+ wasWorthRemembering: boolean;
17
+ reason?: string;
18
+ extractedCount: number;
19
+ memories?: Array<{
20
+ id: string;
21
+ wasDeduplicated: boolean;
22
+ }>;
23
+ }
24
+ interface SearchOptions {
25
+ limit?: number;
26
+ userId?: string;
27
+ minSalience?: number;
28
+ debug?: boolean;
29
+ }
30
+ interface SearchResult {
31
+ id: string;
32
+ content: string;
33
+ sector?: string;
34
+ salience: number;
35
+ score: number;
36
+ tags: string[];
37
+ }
38
+ interface SearchResponse {
39
+ results: SearchResult[];
40
+ total: number;
41
+ query: string;
42
+ }
43
+ interface Memory {
44
+ id: string;
45
+ content: string;
46
+ sector?: string;
47
+ salience: number;
48
+ tags: string[];
49
+ createdAt: string;
50
+ }
51
+ interface ListMemoriesOptions {
52
+ limit?: number;
53
+ offset?: number;
54
+ userId?: string;
55
+ sector?: string;
56
+ }
57
+ interface ListMemoriesResponse {
58
+ memories: Memory[];
59
+ total: number;
60
+ }
61
+ declare class UniMemory {
62
+ private apiKey;
63
+ private baseUrl;
64
+ constructor(config: UniMemoryConfig);
65
+ private request;
66
+ /**
67
+ * Add a memory to UniMemory
68
+ */
69
+ addMemory(options: AddMemoryOptions): Promise<AddMemoryResponse>;
70
+ /**
71
+ * Search memories
72
+ */
73
+ search(query: string, options?: SearchOptions): Promise<SearchResponse>;
74
+ /**
75
+ * List memories
76
+ */
77
+ listMemories(options?: ListMemoriesOptions): Promise<ListMemoriesResponse>;
78
+ /**
79
+ * Delete a memory
80
+ */
81
+ deleteMemory(memoryId: string): Promise<{
82
+ success: boolean;
83
+ }>;
84
+ }
85
+
86
+ export { type AddMemoryOptions, type AddMemoryResponse, type ListMemoriesOptions, type ListMemoriesResponse, type Memory, type SearchOptions, type SearchResponse, type SearchResult, UniMemory, type UniMemoryConfig, UniMemory as default };
package/dist/index.js ADDED
@@ -0,0 +1,139 @@
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
+ UniMemory: () => UniMemory,
24
+ default: () => index_default
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var UniMemoryError = class extends Error {
28
+ constructor(message, status, code) {
29
+ super(message);
30
+ this.status = status;
31
+ this.code = code;
32
+ this.name = "UniMemoryError";
33
+ }
34
+ };
35
+ var UniMemory = class {
36
+ constructor(config) {
37
+ if (!config.apiKey) {
38
+ throw new UniMemoryError("API key is required");
39
+ }
40
+ this.apiKey = config.apiKey;
41
+ this.baseUrl = config.baseUrl || "https://api.unimemory.ai/api/v1";
42
+ }
43
+ async request(method, path, body) {
44
+ const url = `${this.baseUrl}${path}`;
45
+ const headers = {
46
+ "Content-Type": "application/json",
47
+ "X-API-Key": this.apiKey
48
+ };
49
+ const options = {
50
+ method,
51
+ headers
52
+ };
53
+ if (body) {
54
+ options.body = JSON.stringify(body);
55
+ }
56
+ const response = await fetch(url, options);
57
+ if (!response.ok) {
58
+ const error = await response.json().catch(() => ({}));
59
+ throw new UniMemoryError(
60
+ error.detail || `Request failed with status ${response.status}`,
61
+ response.status,
62
+ error.code
63
+ );
64
+ }
65
+ return response.json();
66
+ }
67
+ /**
68
+ * Add a memory to UniMemory
69
+ */
70
+ async addMemory(options) {
71
+ const response = await this.request("POST", "/memories/add", {
72
+ content: options.content,
73
+ source_app: options.sourceApp,
74
+ user_id: options.userId,
75
+ metadata: options.metadata
76
+ });
77
+ return {
78
+ wasWorthRemembering: response.was_worth_remembering,
79
+ reason: response.reason,
80
+ extractedCount: response.extracted_count,
81
+ memories: response.memories?.map((m) => ({
82
+ id: m.id,
83
+ wasDeduplicated: m.was_deduplicated
84
+ }))
85
+ };
86
+ }
87
+ /**
88
+ * Search memories
89
+ */
90
+ async search(query, options) {
91
+ const response = await this.request("POST", "/search", {
92
+ query,
93
+ limit: options?.limit,
94
+ user_id: options?.userId,
95
+ min_salience: options?.minSalience,
96
+ debug: options?.debug
97
+ });
98
+ return {
99
+ results: response.results,
100
+ total: response.total,
101
+ query: response.query
102
+ };
103
+ }
104
+ /**
105
+ * List memories
106
+ */
107
+ async listMemories(options) {
108
+ const params = new URLSearchParams();
109
+ if (options?.limit) params.set("limit", options.limit.toString());
110
+ if (options?.offset) params.set("offset", options.offset.toString());
111
+ if (options?.userId) params.set("user_id", options.userId);
112
+ if (options?.sector) params.set("sector", options.sector);
113
+ const queryString = params.toString();
114
+ const path = `/memories${queryString ? `?${queryString}` : ""}`;
115
+ const response = await this.request("GET", path);
116
+ return {
117
+ memories: response.memories.map((m) => ({
118
+ id: m.id,
119
+ content: m.content,
120
+ sector: m.sector,
121
+ salience: m.salience,
122
+ tags: m.tags,
123
+ createdAt: m.created_at
124
+ })),
125
+ total: response.total
126
+ };
127
+ }
128
+ /**
129
+ * Delete a memory
130
+ */
131
+ async deleteMemory(memoryId) {
132
+ return this.request("DELETE", `/memories/${memoryId}`);
133
+ }
134
+ };
135
+ var index_default = UniMemory;
136
+ // Annotate the CommonJS export names for ESM import in node:
137
+ 0 && (module.exports = {
138
+ UniMemory
139
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,114 @@
1
+ // src/index.ts
2
+ var UniMemoryError = class extends Error {
3
+ constructor(message, status, code) {
4
+ super(message);
5
+ this.status = status;
6
+ this.code = code;
7
+ this.name = "UniMemoryError";
8
+ }
9
+ };
10
+ var UniMemory = class {
11
+ constructor(config) {
12
+ if (!config.apiKey) {
13
+ throw new UniMemoryError("API key is required");
14
+ }
15
+ this.apiKey = config.apiKey;
16
+ this.baseUrl = config.baseUrl || "https://api.unimemory.ai/api/v1";
17
+ }
18
+ async request(method, path, body) {
19
+ const url = `${this.baseUrl}${path}`;
20
+ const headers = {
21
+ "Content-Type": "application/json",
22
+ "X-API-Key": this.apiKey
23
+ };
24
+ const options = {
25
+ method,
26
+ headers
27
+ };
28
+ if (body) {
29
+ options.body = JSON.stringify(body);
30
+ }
31
+ const response = await fetch(url, options);
32
+ if (!response.ok) {
33
+ const error = await response.json().catch(() => ({}));
34
+ throw new UniMemoryError(
35
+ error.detail || `Request failed with status ${response.status}`,
36
+ response.status,
37
+ error.code
38
+ );
39
+ }
40
+ return response.json();
41
+ }
42
+ /**
43
+ * Add a memory to UniMemory
44
+ */
45
+ async addMemory(options) {
46
+ const response = await this.request("POST", "/memories/add", {
47
+ content: options.content,
48
+ source_app: options.sourceApp,
49
+ user_id: options.userId,
50
+ metadata: options.metadata
51
+ });
52
+ return {
53
+ wasWorthRemembering: response.was_worth_remembering,
54
+ reason: response.reason,
55
+ extractedCount: response.extracted_count,
56
+ memories: response.memories?.map((m) => ({
57
+ id: m.id,
58
+ wasDeduplicated: m.was_deduplicated
59
+ }))
60
+ };
61
+ }
62
+ /**
63
+ * Search memories
64
+ */
65
+ async search(query, options) {
66
+ const response = await this.request("POST", "/search", {
67
+ query,
68
+ limit: options?.limit,
69
+ user_id: options?.userId,
70
+ min_salience: options?.minSalience,
71
+ debug: options?.debug
72
+ });
73
+ return {
74
+ results: response.results,
75
+ total: response.total,
76
+ query: response.query
77
+ };
78
+ }
79
+ /**
80
+ * List memories
81
+ */
82
+ async listMemories(options) {
83
+ const params = new URLSearchParams();
84
+ if (options?.limit) params.set("limit", options.limit.toString());
85
+ if (options?.offset) params.set("offset", options.offset.toString());
86
+ if (options?.userId) params.set("user_id", options.userId);
87
+ if (options?.sector) params.set("sector", options.sector);
88
+ const queryString = params.toString();
89
+ const path = `/memories${queryString ? `?${queryString}` : ""}`;
90
+ const response = await this.request("GET", path);
91
+ return {
92
+ memories: response.memories.map((m) => ({
93
+ id: m.id,
94
+ content: m.content,
95
+ sector: m.sector,
96
+ salience: m.salience,
97
+ tags: m.tags,
98
+ createdAt: m.created_at
99
+ })),
100
+ total: response.total
101
+ };
102
+ }
103
+ /**
104
+ * Delete a memory
105
+ */
106
+ async deleteMemory(memoryId) {
107
+ return this.request("DELETE", `/memories/${memoryId}`);
108
+ }
109
+ };
110
+ var index_default = UniMemory;
111
+ export {
112
+ UniMemory,
113
+ index_default as default
114
+ };
package/package.json CHANGED
@@ -1,16 +1,42 @@
1
1
  {
2
2
  "name": "unimemory",
3
- "version": "0.0.1",
4
- "description": "Unified memory layer for AI Agents.",
5
- "main": "index.js",
3
+ "version": "1.0.0",
4
+ "description": "UniMemory SDK - AI memory management for your applications",
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
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "tsup src/index.ts --format cjs,esm --dts",
17
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
18
+ "prepublishOnly": "npm run build"
19
+ },
6
20
  "keywords": [
7
21
  "memory",
8
- "context",
9
22
  "ai",
10
- "agents",
11
- "unified-memory",
12
- "recall"
23
+ "embeddings",
24
+ "search",
25
+ "vector",
26
+ "llm"
13
27
  ],
14
- "author": "Shreyas Gurav",
15
- "license": "MIT"
16
- }
28
+ "author": "UniMemory",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/shreyasgurav/UniMemory"
33
+ },
34
+ "devDependencies": {
35
+ "tsup": "^8.0.1",
36
+ "typescript": "^5.3.3"
37
+ },
38
+ "files": [
39
+ "dist"
40
+ ]
41
+ }
42
+
package/index.js DELETED
@@ -1,2 +0,0 @@
1
- // UniMemory placeholder package
2
- module.exports = {};