cogmemai-sdk 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/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.js +230 -0
- package/dist/types.d.ts +161 -0
- package/dist/types.js +2 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HiFriendbot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# CogmemAi JavaScript/TypeScript SDK
|
|
2
|
+
|
|
3
|
+
Persistent memory for AI coding assistants. Give your AI tools memory that persists across sessions.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install cogmemai-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { CogmemAi } from "cogmemai-sdk";
|
|
15
|
+
|
|
16
|
+
const client = new CogmemAi({ apiKey: "cm_your_api_key_here" });
|
|
17
|
+
|
|
18
|
+
// Save a memory
|
|
19
|
+
await client.saveMemory({
|
|
20
|
+
content: "This project uses React with TypeScript",
|
|
21
|
+
memory_type: "architecture",
|
|
22
|
+
category: "frontend",
|
|
23
|
+
importance: 8,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Search memories
|
|
27
|
+
const results = await client.recallMemories({
|
|
28
|
+
query: "what framework does this project use?",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Load project context
|
|
32
|
+
const context = await client.getProjectContext({
|
|
33
|
+
projectId: "my-project",
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Extract memories from conversation
|
|
37
|
+
await client.extractMemories({
|
|
38
|
+
user_message: "Let's use PostgreSQL for the database",
|
|
39
|
+
assistant_response: "Good choice. I'll set up the schema with...",
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## All Methods
|
|
44
|
+
|
|
45
|
+
### Core Memory
|
|
46
|
+
- `saveMemory(options)` — Save a memory
|
|
47
|
+
- `recallMemories(options)` — Semantic search
|
|
48
|
+
- `extractMemories(options)` — Ai extracts facts from conversation
|
|
49
|
+
- `getProjectContext(options?)` — Load top memories with smart ranking
|
|
50
|
+
- `listMemories(options?)` — Browse with filters
|
|
51
|
+
- `updateMemory(memoryId, options)` — Edit a memory
|
|
52
|
+
- `deleteMemory(memoryId)` — Delete permanently
|
|
53
|
+
- `getUsage()` — Check usage stats and tier
|
|
54
|
+
|
|
55
|
+
### Documents & Sessions
|
|
56
|
+
- `ingestDocument(options)` — Extract memories from docs
|
|
57
|
+
- `saveSessionSummary(options)` — Capture session accomplishments
|
|
58
|
+
|
|
59
|
+
### Import / Export
|
|
60
|
+
- `exportMemories()` — Back up memories as JSON
|
|
61
|
+
- `importMemories(memories)` — Bulk import from JSON
|
|
62
|
+
- `getMemoryVersions(memoryId)` — Version history
|
|
63
|
+
|
|
64
|
+
### Team & Collaboration
|
|
65
|
+
- `getTeamMembers(projectId?)` — List team members
|
|
66
|
+
- `inviteTeamMember(email, projectId, role?)` — Invite a member
|
|
67
|
+
- `removeTeamMember(memberId)` — Remove a member
|
|
68
|
+
|
|
69
|
+
### Memory Relationships & Promotion
|
|
70
|
+
- `linkMemories(memoryId, relatedMemoryId, relationshipType)` — Link related memories
|
|
71
|
+
- `getMemoryLinks(memoryId)` — Get linked memories
|
|
72
|
+
- `getPromotionCandidates()` — Find cross-project patterns
|
|
73
|
+
- `promoteToGlobal(memoryId)` — Promote to global scope
|
|
74
|
+
|
|
75
|
+
## Error Handling
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { CogmemAi, CogmemAiError } from "cogmemai-sdk";
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
await client.saveMemory({ content: "test" });
|
|
82
|
+
} catch (err) {
|
|
83
|
+
if (err instanceof CogmemAiError) {
|
|
84
|
+
console.error(`Error ${err.statusCode}: ${err.message}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## TypeScript
|
|
90
|
+
|
|
91
|
+
Full type definitions included. All request options and response types are exported:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import type { Memory, SaveMemoryOptions, RecallResult } from "cogmemai-sdk";
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Get an API Key
|
|
98
|
+
|
|
99
|
+
1. Sign up at [hifriendbot.com/developer/](https://hifriendbot.com/developer/)
|
|
100
|
+
2. Generate an API key
|
|
101
|
+
3. Start saving memories
|
|
102
|
+
|
|
103
|
+
## Links
|
|
104
|
+
|
|
105
|
+
- [Developer Dashboard](https://hifriendbot.com/developer/)
|
|
106
|
+
- [MCP Server (npm)](https://www.npmjs.com/package/cogmemai-mcp)
|
|
107
|
+
- [Python SDK (PyPI)](https://pypi.org/project/cogmemai/)
|
|
108
|
+
- [GitHub](https://github.com/hifriendbot/cogmemai-sdk)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { CogmemAiOptions, SaveMemoryOptions, SaveMemoryResult, RecallOptions, RecallResult, ExtractOptions, ExtractResult, ContextOptions, ListOptions, UpdateMemoryOptions, IngestOptions, IngestResult, SessionSummaryOptions, ExportResult, ImportResult, MemoryVersion, UsageStats, TeamMember, MemoryLink, PromotionCandidate, Memory } from "./types.js";
|
|
2
|
+
export type { CogmemAiOptions, SaveMemoryOptions, SaveMemoryResult, RecallOptions, RecallResult, ExtractOptions, ExtractResult, ContextOptions, ListOptions, UpdateMemoryOptions, IngestOptions, IngestResult, SessionSummaryOptions, ExportResult, ImportResult, MemoryVersion, UsageStats, TeamMember, MemoryLink, PromotionCandidate, Memory, };
|
|
3
|
+
/** Error thrown by CogmemAi API calls. */
|
|
4
|
+
export declare class CogmemAiError extends Error {
|
|
5
|
+
statusCode: number | undefined;
|
|
6
|
+
constructor(message: string, statusCode?: number);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* CogmemAi SDK client.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { CogmemAi } from "cogmemai-sdk";
|
|
14
|
+
*
|
|
15
|
+
* const client = new CogmemAi({ apiKey: "cm_your_key" });
|
|
16
|
+
*
|
|
17
|
+
* await client.saveMemory({
|
|
18
|
+
* content: "This project uses React with TypeScript",
|
|
19
|
+
* memory_type: "architecture",
|
|
20
|
+
* importance: 8,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* const results = await client.recallMemories({ query: "what framework?" });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class CogmemAi {
|
|
27
|
+
private apiKey;
|
|
28
|
+
private baseUrl;
|
|
29
|
+
private timeout;
|
|
30
|
+
constructor(options: CogmemAiOptions);
|
|
31
|
+
private request;
|
|
32
|
+
private get;
|
|
33
|
+
private post;
|
|
34
|
+
private patch;
|
|
35
|
+
private del;
|
|
36
|
+
/** Save a memory. */
|
|
37
|
+
saveMemory(options: SaveMemoryOptions): Promise<SaveMemoryResult>;
|
|
38
|
+
/** Semantic search across memories. */
|
|
39
|
+
recallMemories(options: RecallOptions): Promise<RecallResult>;
|
|
40
|
+
/** Extract memories from a conversation exchange using Ai. */
|
|
41
|
+
extractMemories(options: ExtractOptions): Promise<ExtractResult>;
|
|
42
|
+
/** Load project context with smart ranking. */
|
|
43
|
+
getProjectContext(options?: ContextOptions): Promise<RecallResult>;
|
|
44
|
+
/** List memories with filters. */
|
|
45
|
+
listMemories(options?: ListOptions): Promise<{
|
|
46
|
+
memories: Memory[];
|
|
47
|
+
}>;
|
|
48
|
+
/** Update a memory. */
|
|
49
|
+
updateMemory(memoryId: number, options: UpdateMemoryOptions): Promise<{
|
|
50
|
+
updated: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
/** Delete a memory permanently. */
|
|
53
|
+
deleteMemory(memoryId: number): Promise<{
|
|
54
|
+
deleted: boolean;
|
|
55
|
+
}>;
|
|
56
|
+
/** Get usage stats and tier info. */
|
|
57
|
+
getUsage(): Promise<UsageStats>;
|
|
58
|
+
/** Extract memories from a document. */
|
|
59
|
+
ingestDocument(options: IngestOptions): Promise<IngestResult>;
|
|
60
|
+
/** Save a session summary. */
|
|
61
|
+
saveSessionSummary(options: SessionSummaryOptions): Promise<SaveMemoryResult>;
|
|
62
|
+
/** Export all memories as JSON. */
|
|
63
|
+
exportMemories(): Promise<ExportResult>;
|
|
64
|
+
/** Bulk import memories. */
|
|
65
|
+
importMemories(memories: SaveMemoryOptions[]): Promise<ImportResult>;
|
|
66
|
+
/** Get version history for a memory. */
|
|
67
|
+
getMemoryVersions(memoryId: number): Promise<{
|
|
68
|
+
versions: MemoryVersion[];
|
|
69
|
+
}>;
|
|
70
|
+
/** List team members. Requires Team or Enterprise tier. */
|
|
71
|
+
getTeamMembers(projectId?: string): Promise<{
|
|
72
|
+
members: TeamMember[];
|
|
73
|
+
}>;
|
|
74
|
+
/** Invite a team member. Requires Team or Enterprise tier. */
|
|
75
|
+
inviteTeamMember(email: string, projectId: string, role?: string): Promise<{
|
|
76
|
+
success: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
/** Remove a team member. */
|
|
79
|
+
removeTeamMember(memberId: number): Promise<{
|
|
80
|
+
success: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
/** Link two related memories. */
|
|
83
|
+
linkMemories(memoryId: number, relatedMemoryId: number, relationshipType: string): Promise<{
|
|
84
|
+
success: boolean;
|
|
85
|
+
}>;
|
|
86
|
+
/** Get linked memories. */
|
|
87
|
+
getMemoryLinks(memoryId: number): Promise<{
|
|
88
|
+
links: MemoryLink[];
|
|
89
|
+
}>;
|
|
90
|
+
/** Find cross-project patterns eligible for global promotion. */
|
|
91
|
+
getPromotionCandidates(): Promise<{
|
|
92
|
+
candidates: PromotionCandidate[];
|
|
93
|
+
}>;
|
|
94
|
+
/** Promote a project memory to global scope. */
|
|
95
|
+
promoteToGlobal(memoryId: number): Promise<{
|
|
96
|
+
success: boolean;
|
|
97
|
+
}>;
|
|
98
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CogmemAi = exports.CogmemAiError = void 0;
|
|
4
|
+
/** Error thrown by CogmemAi API calls. */
|
|
5
|
+
class CogmemAiError extends Error {
|
|
6
|
+
statusCode;
|
|
7
|
+
constructor(message, statusCode) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "CogmemAiError";
|
|
10
|
+
this.statusCode = statusCode;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.CogmemAiError = CogmemAiError;
|
|
14
|
+
const DEFAULT_BASE_URL = "https://hifriendbot.com/wp-json/hifriendbot/v1";
|
|
15
|
+
/**
|
|
16
|
+
* CogmemAi SDK client.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { CogmemAi } from "cogmemai-sdk";
|
|
21
|
+
*
|
|
22
|
+
* const client = new CogmemAi({ apiKey: "cm_your_key" });
|
|
23
|
+
*
|
|
24
|
+
* await client.saveMemory({
|
|
25
|
+
* content: "This project uses React with TypeScript",
|
|
26
|
+
* memory_type: "architecture",
|
|
27
|
+
* importance: 8,
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const results = await client.recallMemories({ query: "what framework?" });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
class CogmemAi {
|
|
34
|
+
apiKey;
|
|
35
|
+
baseUrl;
|
|
36
|
+
timeout;
|
|
37
|
+
constructor(options) {
|
|
38
|
+
if (!options.apiKey || !options.apiKey.startsWith("cm_")) {
|
|
39
|
+
throw new Error("API key must start with 'cm_'");
|
|
40
|
+
}
|
|
41
|
+
this.apiKey = options.apiKey;
|
|
42
|
+
this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
43
|
+
this.timeout = options.timeout || 30000;
|
|
44
|
+
}
|
|
45
|
+
// ── Internal helpers ───────────────────────────────
|
|
46
|
+
async request(method, path, body, params) {
|
|
47
|
+
let url = `${this.baseUrl}/cogmemai/${path}`;
|
|
48
|
+
if (params) {
|
|
49
|
+
const qs = new URLSearchParams(params).toString();
|
|
50
|
+
if (qs)
|
|
51
|
+
url += `?${qs}`;
|
|
52
|
+
}
|
|
53
|
+
const controller = new AbortController();
|
|
54
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
55
|
+
try {
|
|
56
|
+
const resp = await fetch(url, {
|
|
57
|
+
method,
|
|
58
|
+
headers: {
|
|
59
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
60
|
+
"Content-Type": "application/json",
|
|
61
|
+
},
|
|
62
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
63
|
+
signal: controller.signal,
|
|
64
|
+
});
|
|
65
|
+
let data;
|
|
66
|
+
try {
|
|
67
|
+
data = await resp.json();
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
throw new CogmemAiError(`Invalid JSON response`, resp.status);
|
|
71
|
+
}
|
|
72
|
+
if (!resp.ok) {
|
|
73
|
+
const msg = data?.error || data?.message || `HTTP ${resp.status}`;
|
|
74
|
+
throw new CogmemAiError(msg, resp.status);
|
|
75
|
+
}
|
|
76
|
+
return data;
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
clearTimeout(timer);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
get(path, params) {
|
|
83
|
+
return this.request("GET", path, undefined, params);
|
|
84
|
+
}
|
|
85
|
+
post(path, body) {
|
|
86
|
+
return this.request("POST", path, body);
|
|
87
|
+
}
|
|
88
|
+
patch(path, body) {
|
|
89
|
+
return this.request("PATCH", path, body);
|
|
90
|
+
}
|
|
91
|
+
del(path) {
|
|
92
|
+
return this.request("DELETE", path);
|
|
93
|
+
}
|
|
94
|
+
// ── Core Memory ────────────────────────────────────
|
|
95
|
+
/** Save a memory. */
|
|
96
|
+
async saveMemory(options) {
|
|
97
|
+
return this.post("store", {
|
|
98
|
+
content: options.content,
|
|
99
|
+
memory_type: options.memory_type || "context",
|
|
100
|
+
category: options.category || "general",
|
|
101
|
+
subject: options.subject || "",
|
|
102
|
+
importance: options.importance ?? 5,
|
|
103
|
+
scope: options.scope || "project",
|
|
104
|
+
project_id: options.project_id || "",
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** Semantic search across memories. */
|
|
108
|
+
async recallMemories(options) {
|
|
109
|
+
const body = {
|
|
110
|
+
query: options.query,
|
|
111
|
+
limit: options.limit || 10,
|
|
112
|
+
scope: options.scope || "all",
|
|
113
|
+
};
|
|
114
|
+
if (options.memory_type)
|
|
115
|
+
body.memory_type = options.memory_type;
|
|
116
|
+
return this.post("recall", body);
|
|
117
|
+
}
|
|
118
|
+
/** Extract memories from a conversation exchange using Ai. */
|
|
119
|
+
async extractMemories(options) {
|
|
120
|
+
const body = { user_message: options.user_message };
|
|
121
|
+
if (options.assistant_response)
|
|
122
|
+
body.assistant_response = options.assistant_response;
|
|
123
|
+
if (options.previous_context)
|
|
124
|
+
body.previous_context = options.previous_context;
|
|
125
|
+
return this.post("extract", body);
|
|
126
|
+
}
|
|
127
|
+
/** Load project context with smart ranking. */
|
|
128
|
+
async getProjectContext(options = {}) {
|
|
129
|
+
const params = {
|
|
130
|
+
include_global: String(options.include_global ?? true),
|
|
131
|
+
};
|
|
132
|
+
if (options.project_id)
|
|
133
|
+
params.project_id = options.project_id;
|
|
134
|
+
if (options.context)
|
|
135
|
+
params.context = options.context;
|
|
136
|
+
return this.get("context", params);
|
|
137
|
+
}
|
|
138
|
+
/** List memories with filters. */
|
|
139
|
+
async listMemories(options = {}) {
|
|
140
|
+
const params = {
|
|
141
|
+
limit: String(options.limit || 50),
|
|
142
|
+
offset: String(options.offset || 0),
|
|
143
|
+
scope: options.scope || "all",
|
|
144
|
+
};
|
|
145
|
+
if (options.memory_type)
|
|
146
|
+
params.memory_type = options.memory_type;
|
|
147
|
+
if (options.category)
|
|
148
|
+
params.category = options.category;
|
|
149
|
+
return this.get("memories", params);
|
|
150
|
+
}
|
|
151
|
+
/** Update a memory. */
|
|
152
|
+
async updateMemory(memoryId, options) {
|
|
153
|
+
return this.patch(`memory/${memoryId}`, options);
|
|
154
|
+
}
|
|
155
|
+
/** Delete a memory permanently. */
|
|
156
|
+
async deleteMemory(memoryId) {
|
|
157
|
+
return this.del(`memory/${memoryId}`);
|
|
158
|
+
}
|
|
159
|
+
/** Get usage stats and tier info. */
|
|
160
|
+
async getUsage() {
|
|
161
|
+
return this.get("usage");
|
|
162
|
+
}
|
|
163
|
+
// ── Documents & Sessions ───────────────────────────
|
|
164
|
+
/** Extract memories from a document. */
|
|
165
|
+
async ingestDocument(options) {
|
|
166
|
+
const body = { text: options.text };
|
|
167
|
+
if (options.document_type)
|
|
168
|
+
body.document_type = options.document_type;
|
|
169
|
+
if (options.project_id)
|
|
170
|
+
body.project_id = options.project_id;
|
|
171
|
+
return this.post("ingest", body);
|
|
172
|
+
}
|
|
173
|
+
/** Save a session summary. */
|
|
174
|
+
async saveSessionSummary(options) {
|
|
175
|
+
const body = { summary: options.summary };
|
|
176
|
+
if (options.project_id)
|
|
177
|
+
body.project_id = options.project_id;
|
|
178
|
+
return this.post("session-summary", body);
|
|
179
|
+
}
|
|
180
|
+
// ── Import / Export / Versions ─────────────────────
|
|
181
|
+
/** Export all memories as JSON. */
|
|
182
|
+
async exportMemories() {
|
|
183
|
+
return this.get("export");
|
|
184
|
+
}
|
|
185
|
+
/** Bulk import memories. */
|
|
186
|
+
async importMemories(memories) {
|
|
187
|
+
return this.post("import", { memories });
|
|
188
|
+
}
|
|
189
|
+
/** Get version history for a memory. */
|
|
190
|
+
async getMemoryVersions(memoryId) {
|
|
191
|
+
return this.get(`memory/${memoryId}/versions`);
|
|
192
|
+
}
|
|
193
|
+
// ── Team & Collaboration ──────────────────────────
|
|
194
|
+
/** List team members. Requires Team or Enterprise tier. */
|
|
195
|
+
async getTeamMembers(projectId) {
|
|
196
|
+
const params = {};
|
|
197
|
+
if (projectId)
|
|
198
|
+
params.project_id = projectId;
|
|
199
|
+
return this.get("team/members", params);
|
|
200
|
+
}
|
|
201
|
+
/** Invite a team member. Requires Team or Enterprise tier. */
|
|
202
|
+
async inviteTeamMember(email, projectId, role = "member") {
|
|
203
|
+
return this.post("team/invite", { email, project_id: projectId, role });
|
|
204
|
+
}
|
|
205
|
+
/** Remove a team member. */
|
|
206
|
+
async removeTeamMember(memberId) {
|
|
207
|
+
return this.del(`team/remove/${memberId}`);
|
|
208
|
+
}
|
|
209
|
+
// ── Memory Relationships & Promotion ──────────────
|
|
210
|
+
/** Link two related memories. */
|
|
211
|
+
async linkMemories(memoryId, relatedMemoryId, relationshipType) {
|
|
212
|
+
return this.post(`memory/${memoryId}/link`, {
|
|
213
|
+
related_memory_id: relatedMemoryId,
|
|
214
|
+
relationship_type: relationshipType,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/** Get linked memories. */
|
|
218
|
+
async getMemoryLinks(memoryId) {
|
|
219
|
+
return this.get(`memory/${memoryId}/links`);
|
|
220
|
+
}
|
|
221
|
+
/** Find cross-project patterns eligible for global promotion. */
|
|
222
|
+
async getPromotionCandidates() {
|
|
223
|
+
return this.get("promotion-candidates");
|
|
224
|
+
}
|
|
225
|
+
/** Promote a project memory to global scope. */
|
|
226
|
+
async promoteToGlobal(memoryId) {
|
|
227
|
+
return this.post(`memory/${memoryId}/promote`, {});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
exports.CogmemAi = CogmemAi;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/** Memory object returned by the API. */
|
|
2
|
+
export interface Memory {
|
|
3
|
+
id: number;
|
|
4
|
+
content: string;
|
|
5
|
+
memory_type: string;
|
|
6
|
+
category: string;
|
|
7
|
+
subject: string;
|
|
8
|
+
importance: number;
|
|
9
|
+
scope: string;
|
|
10
|
+
project_id: string;
|
|
11
|
+
custom_type: string | null;
|
|
12
|
+
is_sensitive: boolean;
|
|
13
|
+
times_referenced: number;
|
|
14
|
+
created_at: string;
|
|
15
|
+
updated_at: string;
|
|
16
|
+
}
|
|
17
|
+
/** Options for saving a memory. */
|
|
18
|
+
export interface SaveMemoryOptions {
|
|
19
|
+
content: string;
|
|
20
|
+
memory_type?: string;
|
|
21
|
+
category?: string;
|
|
22
|
+
subject?: string;
|
|
23
|
+
importance?: number;
|
|
24
|
+
scope?: string;
|
|
25
|
+
project_id?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Result from saving a memory. */
|
|
28
|
+
export interface SaveMemoryResult {
|
|
29
|
+
memory_id: number;
|
|
30
|
+
stored: boolean;
|
|
31
|
+
deduplicated?: boolean;
|
|
32
|
+
updated_existing?: number;
|
|
33
|
+
conflict_detected?: boolean;
|
|
34
|
+
archived_memory_id?: number;
|
|
35
|
+
warning?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Options for recalling memories. */
|
|
38
|
+
export interface RecallOptions {
|
|
39
|
+
query: string;
|
|
40
|
+
limit?: number;
|
|
41
|
+
memory_type?: string;
|
|
42
|
+
scope?: string;
|
|
43
|
+
}
|
|
44
|
+
/** Result from recalling memories. */
|
|
45
|
+
export interface RecallResult {
|
|
46
|
+
memories: Memory[];
|
|
47
|
+
}
|
|
48
|
+
/** Options for extracting memories from conversation. */
|
|
49
|
+
export interface ExtractOptions {
|
|
50
|
+
user_message: string;
|
|
51
|
+
assistant_response?: string;
|
|
52
|
+
previous_context?: string;
|
|
53
|
+
}
|
|
54
|
+
/** Result from extracting memories. */
|
|
55
|
+
export interface ExtractResult {
|
|
56
|
+
extracted: number;
|
|
57
|
+
memories: SaveMemoryResult[];
|
|
58
|
+
}
|
|
59
|
+
/** Options for loading project context. */
|
|
60
|
+
export interface ContextOptions {
|
|
61
|
+
project_id?: string;
|
|
62
|
+
include_global?: boolean;
|
|
63
|
+
context?: string;
|
|
64
|
+
}
|
|
65
|
+
/** Options for listing memories. */
|
|
66
|
+
export interface ListOptions {
|
|
67
|
+
memory_type?: string;
|
|
68
|
+
category?: string;
|
|
69
|
+
scope?: string;
|
|
70
|
+
limit?: number;
|
|
71
|
+
offset?: number;
|
|
72
|
+
}
|
|
73
|
+
/** Options for updating a memory. */
|
|
74
|
+
export interface UpdateMemoryOptions {
|
|
75
|
+
content?: string;
|
|
76
|
+
importance?: number;
|
|
77
|
+
scope?: string;
|
|
78
|
+
}
|
|
79
|
+
/** Options for ingesting a document. */
|
|
80
|
+
export interface IngestOptions {
|
|
81
|
+
text: string;
|
|
82
|
+
document_type?: string;
|
|
83
|
+
project_id?: string;
|
|
84
|
+
}
|
|
85
|
+
/** Result from ingesting a document. */
|
|
86
|
+
export interface IngestResult {
|
|
87
|
+
chunks_processed: number;
|
|
88
|
+
extracted: number;
|
|
89
|
+
memories: SaveMemoryResult[];
|
|
90
|
+
}
|
|
91
|
+
/** Options for saving a session summary. */
|
|
92
|
+
export interface SessionSummaryOptions {
|
|
93
|
+
summary: string;
|
|
94
|
+
project_id?: string;
|
|
95
|
+
}
|
|
96
|
+
/** Export result. */
|
|
97
|
+
export interface ExportResult {
|
|
98
|
+
version: string;
|
|
99
|
+
exported_at: string;
|
|
100
|
+
memory_count: number;
|
|
101
|
+
memories: Memory[];
|
|
102
|
+
}
|
|
103
|
+
/** Import result. */
|
|
104
|
+
export interface ImportResult {
|
|
105
|
+
imported: number;
|
|
106
|
+
skipped: number;
|
|
107
|
+
errors: number;
|
|
108
|
+
}
|
|
109
|
+
/** Memory version entry. */
|
|
110
|
+
export interface MemoryVersion {
|
|
111
|
+
id: number;
|
|
112
|
+
content: string;
|
|
113
|
+
importance: number;
|
|
114
|
+
scope: string;
|
|
115
|
+
changed_by: string;
|
|
116
|
+
created_at: string;
|
|
117
|
+
}
|
|
118
|
+
/** Usage stats. */
|
|
119
|
+
export interface UsageStats {
|
|
120
|
+
tier: string;
|
|
121
|
+
tier_name: string;
|
|
122
|
+
memories_count: number;
|
|
123
|
+
memories_limit: number;
|
|
124
|
+
extractions_count: number;
|
|
125
|
+
extractions_limit: number;
|
|
126
|
+
projects_count: number;
|
|
127
|
+
projects_limit: number;
|
|
128
|
+
}
|
|
129
|
+
/** Team member. */
|
|
130
|
+
export interface TeamMember {
|
|
131
|
+
id: number;
|
|
132
|
+
member_user_id: number;
|
|
133
|
+
project_id: string;
|
|
134
|
+
role: string;
|
|
135
|
+
invited_at: string;
|
|
136
|
+
accepted_at: string | null;
|
|
137
|
+
}
|
|
138
|
+
/** Memory link. */
|
|
139
|
+
export interface MemoryLink {
|
|
140
|
+
id: number;
|
|
141
|
+
memory_id: number;
|
|
142
|
+
related_memory_id: number;
|
|
143
|
+
relationship_type: string;
|
|
144
|
+
created_at: string;
|
|
145
|
+
}
|
|
146
|
+
/** Promotion candidate. */
|
|
147
|
+
export interface PromotionCandidate {
|
|
148
|
+
subject: string;
|
|
149
|
+
memory_type: string;
|
|
150
|
+
project_count: number;
|
|
151
|
+
memories: Memory[];
|
|
152
|
+
}
|
|
153
|
+
/** CogmemAi client options. */
|
|
154
|
+
export interface CogmemAiOptions {
|
|
155
|
+
/** API key (starts with cm_). */
|
|
156
|
+
apiKey: string;
|
|
157
|
+
/** Base URL. Defaults to hosted CogmemAi service. */
|
|
158
|
+
baseUrl?: string;
|
|
159
|
+
/** Request timeout in milliseconds. Defaults to 30000. */
|
|
160
|
+
timeout?: number;
|
|
161
|
+
}
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cogmemai-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CogmemAi — Persistent memory for AI coding assistants",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"prepublishOnly": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"ai",
|
|
16
|
+
"memory",
|
|
17
|
+
"claude",
|
|
18
|
+
"coding-assistant",
|
|
19
|
+
"mcp",
|
|
20
|
+
"developer-tools",
|
|
21
|
+
"persistent-memory"
|
|
22
|
+
],
|
|
23
|
+
"author": "HiFriendbot <developers@hifriendbot.com>",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/hifriendbot/cogmemai-sdk.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://hifriendbot.com/developer/",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.0.0"
|
|
32
|
+
}
|
|
33
|
+
}
|