@memclaw/plugin 0.9.0 → 0.9.2
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 +23 -9
- package/dist/index.d.ts +100 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin-impl.d.ts +40 -0
- package/dist/plugin-impl.d.ts.map +1 -0
- package/dist/plugin-impl.js +445 -0
- package/dist/plugin-impl.js.map +1 -0
- package/dist/src/binaries.d.ts +29 -0
- package/dist/src/binaries.d.ts.map +1 -0
- package/dist/src/binaries.js +292 -0
- package/dist/src/binaries.js.map +1 -0
- package/dist/src/client.d.ts +88 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +131 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/config.d.ts +50 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +257 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/migrate.d.ts +26 -0
- package/dist/src/migrate.d.ts.map +1 -0
- package/dist/src/migrate.js +287 -0
- package/dist/src/migrate.js.map +1 -0
- package/openclaw.plugin.json +70 -70
- package/package.json +2 -2
- package/skill/references/setup.md +2 -41
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Binary management for MemClaw
|
|
4
|
+
*
|
|
5
|
+
* Binaries are bundled in platform-specific npm packages:
|
|
6
|
+
* - @memclaw/bin-darwin-arm64 (macOS Apple Silicon)
|
|
7
|
+
* - @memclaw/bin-win-x64 (Windows x64)
|
|
8
|
+
*
|
|
9
|
+
* The correct package is installed automatically via optionalDependencies.
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.getPlatform = getPlatform;
|
|
46
|
+
exports.isPlatformSupported = isPlatformSupported;
|
|
47
|
+
exports.getUnsupportedPlatformMessage = getUnsupportedPlatformMessage;
|
|
48
|
+
exports.getBinaryPath = getBinaryPath;
|
|
49
|
+
exports.isBinaryAvailable = isBinaryAvailable;
|
|
50
|
+
exports.isPlatformPackageInstalled = isPlatformPackageInstalled;
|
|
51
|
+
exports.getInstallInstructions = getInstallInstructions;
|
|
52
|
+
exports.checkServiceStatus = checkServiceStatus;
|
|
53
|
+
exports.startQdrant = startQdrant;
|
|
54
|
+
exports.startCortexMemService = startCortexMemService;
|
|
55
|
+
exports.stopAllServices = stopAllServices;
|
|
56
|
+
exports.ensureAllServices = ensureAllServices;
|
|
57
|
+
exports.getCliPath = getCliPath;
|
|
58
|
+
const fs = __importStar(require("fs"));
|
|
59
|
+
const path = __importStar(require("path"));
|
|
60
|
+
const child_process_1 = require("child_process");
|
|
61
|
+
const config_js_1 = require("./config.js");
|
|
62
|
+
// Platform detection
|
|
63
|
+
function getPlatform() {
|
|
64
|
+
const platform = process.platform;
|
|
65
|
+
const arch = process.arch;
|
|
66
|
+
if (platform === "darwin" && arch === "arm64") {
|
|
67
|
+
return "darwin-arm64";
|
|
68
|
+
}
|
|
69
|
+
else if (platform === "win32" && arch === "x64") {
|
|
70
|
+
return "win-x64";
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
// Check if current platform is supported
|
|
75
|
+
function isPlatformSupported() {
|
|
76
|
+
return getPlatform() !== null;
|
|
77
|
+
}
|
|
78
|
+
// Get unsupported platform message
|
|
79
|
+
function getUnsupportedPlatformMessage() {
|
|
80
|
+
const platform = process.platform;
|
|
81
|
+
const arch = process.arch;
|
|
82
|
+
return `
|
|
83
|
+
MemClaw is only supported on:
|
|
84
|
+
- macOS Apple Silicon (darwin-arm64)
|
|
85
|
+
- Windows x64 (win-x64)
|
|
86
|
+
|
|
87
|
+
Current platform: ${platform}-${arch} is not supported.
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
// Get binary name with platform extension
|
|
91
|
+
function getBinaryFileName(binary) {
|
|
92
|
+
return process.platform === "win32" ? `${binary}.exe` : binary;
|
|
93
|
+
}
|
|
94
|
+
// Get the path to the platform-specific npm package
|
|
95
|
+
function getPlatformPackagePath() {
|
|
96
|
+
const platform = getPlatform();
|
|
97
|
+
if (!platform) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const packageName = `@memclaw/bin-${platform}`;
|
|
101
|
+
try {
|
|
102
|
+
// Try to resolve the package path
|
|
103
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
104
|
+
return path.dirname(packageJsonPath);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Get binary path from npm package
|
|
111
|
+
function getBinaryPath(binary) {
|
|
112
|
+
const packagePath = getPlatformPackagePath();
|
|
113
|
+
if (!packagePath) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
const binaryFileName = getBinaryFileName(binary);
|
|
117
|
+
const binaryPath = path.join(packagePath, "bin", binaryFileName);
|
|
118
|
+
if (fs.existsSync(binaryPath)) {
|
|
119
|
+
return binaryPath;
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
// Check if binary is available
|
|
124
|
+
function isBinaryAvailable(binary) {
|
|
125
|
+
return getBinaryPath(binary) !== null;
|
|
126
|
+
}
|
|
127
|
+
// Check if platform package is installed
|
|
128
|
+
function isPlatformPackageInstalled() {
|
|
129
|
+
return getPlatformPackagePath() !== null;
|
|
130
|
+
}
|
|
131
|
+
// Get installation instructions for missing platform package
|
|
132
|
+
function getInstallInstructions() {
|
|
133
|
+
const platform = getPlatform();
|
|
134
|
+
if (!platform) {
|
|
135
|
+
return getUnsupportedPlatformMessage();
|
|
136
|
+
}
|
|
137
|
+
const packageName = `@memclaw/bin-${platform}`;
|
|
138
|
+
return `
|
|
139
|
+
Platform binaries not found for ${platform}.
|
|
140
|
+
|
|
141
|
+
Try running: npm install ${packageName}
|
|
142
|
+
|
|
143
|
+
Or reinstall memclaw: npm install memclaw
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
async function checkServiceStatus() {
|
|
147
|
+
const qdrant = await isPortOpen(6333);
|
|
148
|
+
const cortexMemService = await isPortOpen(8085);
|
|
149
|
+
return { qdrant, cortexMemService };
|
|
150
|
+
}
|
|
151
|
+
async function isPortOpen(port) {
|
|
152
|
+
try {
|
|
153
|
+
const response = await fetch(`http://127.0.0.1:${port}/health`, {
|
|
154
|
+
method: "GET",
|
|
155
|
+
signal: AbortSignal.timeout(2000),
|
|
156
|
+
});
|
|
157
|
+
return response.ok;
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
// Try alternate endpoints for Qdrant
|
|
161
|
+
try {
|
|
162
|
+
if (port === 6333 || port === 6334) {
|
|
163
|
+
const response = await fetch(`http://127.0.0.1:${port}`, {
|
|
164
|
+
method: "GET",
|
|
165
|
+
signal: AbortSignal.timeout(2000),
|
|
166
|
+
});
|
|
167
|
+
return response.ok;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch { }
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Running processes
|
|
175
|
+
const runningProcesses = new Map();
|
|
176
|
+
async function startQdrant(log) {
|
|
177
|
+
const status = await checkServiceStatus();
|
|
178
|
+
if (status.qdrant) {
|
|
179
|
+
log?.("Qdrant is already running");
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const binaryPath = getBinaryPath("qdrant");
|
|
183
|
+
if (!binaryPath) {
|
|
184
|
+
throw new Error(`Qdrant binary not found. ${getInstallInstructions()}`);
|
|
185
|
+
}
|
|
186
|
+
const dataDir = (0, config_js_1.getDataDir)();
|
|
187
|
+
const storagePath = path.join(dataDir, "qdrant-storage");
|
|
188
|
+
if (!fs.existsSync(storagePath)) {
|
|
189
|
+
fs.mkdirSync(storagePath, { recursive: true });
|
|
190
|
+
}
|
|
191
|
+
log?.(`Starting Qdrant with storage at ${storagePath}...`);
|
|
192
|
+
const proc = (0, child_process_1.spawn)(binaryPath, [
|
|
193
|
+
"--storage-path",
|
|
194
|
+
storagePath,
|
|
195
|
+
"--http-port",
|
|
196
|
+
"6333",
|
|
197
|
+
"--grpc-port",
|
|
198
|
+
"6334",
|
|
199
|
+
], {
|
|
200
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
201
|
+
detached: true,
|
|
202
|
+
});
|
|
203
|
+
proc.on("error", (err) => {
|
|
204
|
+
log?.(`Qdrant error: ${err.message}`);
|
|
205
|
+
});
|
|
206
|
+
proc.unref();
|
|
207
|
+
runningProcesses.set("qdrant", proc);
|
|
208
|
+
// Wait for Qdrant to start
|
|
209
|
+
let retries = 30;
|
|
210
|
+
while (retries > 0) {
|
|
211
|
+
const status = await checkServiceStatus();
|
|
212
|
+
if (status.qdrant) {
|
|
213
|
+
log?.("Qdrant started successfully");
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
217
|
+
retries--;
|
|
218
|
+
}
|
|
219
|
+
throw new Error("Qdrant failed to start within 15 seconds");
|
|
220
|
+
}
|
|
221
|
+
async function startCortexMemService(log) {
|
|
222
|
+
const status = await checkServiceStatus();
|
|
223
|
+
if (status.cortexMemService) {
|
|
224
|
+
log?.("cortex-mem-service is already running");
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const binaryPath = getBinaryPath("cortex-mem-service");
|
|
228
|
+
if (!binaryPath) {
|
|
229
|
+
throw new Error(`cortex-mem-service binary not found. ${getInstallInstructions()}`);
|
|
230
|
+
}
|
|
231
|
+
const configPath = (0, config_js_1.getConfigPath)();
|
|
232
|
+
const dataDir = (0, config_js_1.getDataDir)();
|
|
233
|
+
log?.(`Starting cortex-mem-service with config ${configPath}...`);
|
|
234
|
+
const proc = (0, child_process_1.spawn)(binaryPath, ["--config", configPath, "--data-dir", dataDir], {
|
|
235
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
236
|
+
detached: true,
|
|
237
|
+
});
|
|
238
|
+
proc.on("error", (err) => {
|
|
239
|
+
log?.(`cortex-mem-service error: ${err.message}`);
|
|
240
|
+
});
|
|
241
|
+
proc.unref();
|
|
242
|
+
runningProcesses.set("cortex-mem-service", proc);
|
|
243
|
+
// Wait for service to start
|
|
244
|
+
let retries = 30;
|
|
245
|
+
while (retries > 0) {
|
|
246
|
+
const status = await checkServiceStatus();
|
|
247
|
+
if (status.cortexMemService) {
|
|
248
|
+
log?.("cortex-mem-service started successfully");
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
252
|
+
retries--;
|
|
253
|
+
}
|
|
254
|
+
throw new Error("cortex-mem-service failed to start within 15 seconds");
|
|
255
|
+
}
|
|
256
|
+
function stopAllServices() {
|
|
257
|
+
for (const [name, proc] of runningProcesses) {
|
|
258
|
+
try {
|
|
259
|
+
proc.kill();
|
|
260
|
+
console.log(`Stopped ${name}`);
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
console.error(`Failed to stop ${name}:`, err);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
runningProcesses.clear();
|
|
267
|
+
}
|
|
268
|
+
async function ensureAllServices(log) {
|
|
269
|
+
// Check if platform is supported
|
|
270
|
+
if (!isPlatformSupported()) {
|
|
271
|
+
log?.(getUnsupportedPlatformMessage());
|
|
272
|
+
return { qdrant: false, cortexMemService: false };
|
|
273
|
+
}
|
|
274
|
+
// Check if platform package is installed
|
|
275
|
+
if (!isPlatformPackageInstalled()) {
|
|
276
|
+
log?.(`Warning: Platform binaries not installed. ${getInstallInstructions()}`);
|
|
277
|
+
return { qdrant: false, cortexMemService: false };
|
|
278
|
+
}
|
|
279
|
+
const status = await checkServiceStatus();
|
|
280
|
+
if (!status.qdrant) {
|
|
281
|
+
await startQdrant(log);
|
|
282
|
+
}
|
|
283
|
+
if (!status.cortexMemService) {
|
|
284
|
+
await startCortexMemService(log);
|
|
285
|
+
}
|
|
286
|
+
return checkServiceStatus();
|
|
287
|
+
}
|
|
288
|
+
// Get CLI binary path for external commands (like migration)
|
|
289
|
+
function getCliPath() {
|
|
290
|
+
return getBinaryPath("cortex-mem-cli");
|
|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IACpD,CAAC;IAED,yCAAyC;IACzC,IAAI,CAAC,0BAA0B,EAAE,EAAE,CAAC;QAClC,GAAG,EAAE,CAAC,6CAA6C,sBAAsB,EAAE,EAAE,CAAC,CAAC;QAC/E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC;IACpD,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,kBAAkB,EAAE,CAAC;IAE1C,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC7B,MAAM,qBAAqB,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,kBAAkB,EAAE,CAAC;AAC9B,CAAC;AAED,6DAA6D;AAC7D,SAAgB,UAAU;IACxB,OAAO,aAAa,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cortex Memory API Client
|
|
3
|
+
*
|
|
4
|
+
* HTTP client for cortex-mem-service REST API
|
|
5
|
+
*/
|
|
6
|
+
export interface SearchRequest {
|
|
7
|
+
query: string;
|
|
8
|
+
thread?: string;
|
|
9
|
+
limit?: number;
|
|
10
|
+
min_score?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SearchResult {
|
|
13
|
+
uri: string;
|
|
14
|
+
score: number;
|
|
15
|
+
snippet: string;
|
|
16
|
+
content?: string;
|
|
17
|
+
source: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SessionResponse {
|
|
20
|
+
thread_id: string;
|
|
21
|
+
status: string;
|
|
22
|
+
message_count: number;
|
|
23
|
+
created_at: string;
|
|
24
|
+
updated_at: string;
|
|
25
|
+
}
|
|
26
|
+
export interface CreateSessionRequest {
|
|
27
|
+
thread_id?: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
user_id?: string;
|
|
30
|
+
agent_id?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AddMessageRequest {
|
|
33
|
+
role: "user" | "assistant" | "system";
|
|
34
|
+
content: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Cortex Memory API Client
|
|
38
|
+
*/
|
|
39
|
+
export declare class CortexMemClient {
|
|
40
|
+
private baseUrl;
|
|
41
|
+
constructor(baseUrl?: string);
|
|
42
|
+
/**
|
|
43
|
+
* Layered semantic search (L0 -> L1 -> L2 tiered retrieval)
|
|
44
|
+
*/
|
|
45
|
+
search(request: SearchRequest): Promise<SearchResult[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Quick search returning only L0 abstracts
|
|
48
|
+
*/
|
|
49
|
+
find(query: string, scope?: string, limit?: number): Promise<SearchResult[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Layered recall - uses L0/L1/L2 tiered search internally
|
|
52
|
+
*
|
|
53
|
+
* The search engine performs tiered retrieval (L0→L1→L2) internally,
|
|
54
|
+
* but returns unified results with snippet and content.
|
|
55
|
+
*
|
|
56
|
+
* @param query - Search query
|
|
57
|
+
* @param scope - Optional session/thread scope
|
|
58
|
+
* @param limit - Maximum results
|
|
59
|
+
*/
|
|
60
|
+
recall(query: string, scope?: string, limit?: number): Promise<SearchResult[]>;
|
|
61
|
+
/**
|
|
62
|
+
* List all sessions
|
|
63
|
+
*/
|
|
64
|
+
listSessions(): Promise<SessionResponse[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Create a new session
|
|
67
|
+
*/
|
|
68
|
+
createSession(request?: CreateSessionRequest): Promise<SessionResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Add a message to a session
|
|
71
|
+
*/
|
|
72
|
+
addMessage(threadId: string, message: AddMessageRequest): Promise<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Close a session
|
|
75
|
+
*/
|
|
76
|
+
closeSession(threadId: string): Promise<SessionResponse>;
|
|
77
|
+
/**
|
|
78
|
+
* Switch tenant
|
|
79
|
+
*/
|
|
80
|
+
switchTenant(tenantId: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Health check
|
|
83
|
+
*/
|
|
84
|
+
healthCheck(): Promise<boolean>;
|
|
85
|
+
private get;
|
|
86
|
+
private post;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAGD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,GAAE,MAAgC;IAIrD;;OAEG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAK7D;;OAEG;IACG,IAAI,CACR,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,KAAK,GAAE,MAAU,GAChB,OAAO,CAAC,YAAY,EAAE,CAAC;IAS1B;;;;;;;;;OASG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,KAAK,GAAE,MAAW,GACjB,OAAO,CAAC,YAAY,EAAE,CAAC;IAS1B;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAKhD;;OAEG;IACG,aAAa,CACjB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,eAAe,CAAC;IAQ3B;;OAEG;IACG,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,MAAM,CAAC;IAQlB;;OAEG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAQ9D;;OAEG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;YAUvB,GAAG;YAYH,IAAI;CAoBnB"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cortex Memory API Client
|
|
4
|
+
*
|
|
5
|
+
* HTTP client for cortex-mem-service REST API
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CortexMemClient = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Cortex Memory API Client
|
|
11
|
+
*/
|
|
12
|
+
class CortexMemClient {
|
|
13
|
+
baseUrl;
|
|
14
|
+
constructor(baseUrl = "http://localhost:8085") {
|
|
15
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Layered semantic search (L0 -> L1 -> L2 tiered retrieval)
|
|
19
|
+
*/
|
|
20
|
+
async search(request) {
|
|
21
|
+
const response = await this.post("/api/v2/search", request);
|
|
22
|
+
return response;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Quick search returning only L0 abstracts
|
|
26
|
+
*/
|
|
27
|
+
async find(query, scope, limit = 5) {
|
|
28
|
+
return this.search({
|
|
29
|
+
query,
|
|
30
|
+
thread: scope,
|
|
31
|
+
limit,
|
|
32
|
+
min_score: 0.5,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Layered recall - uses L0/L1/L2 tiered search internally
|
|
37
|
+
*
|
|
38
|
+
* The search engine performs tiered retrieval (L0→L1→L2) internally,
|
|
39
|
+
* but returns unified results with snippet and content.
|
|
40
|
+
*
|
|
41
|
+
* @param query - Search query
|
|
42
|
+
* @param scope - Optional session/thread scope
|
|
43
|
+
* @param limit - Maximum results
|
|
44
|
+
*/
|
|
45
|
+
async recall(query, scope, limit = 10) {
|
|
46
|
+
return this.search({
|
|
47
|
+
query,
|
|
48
|
+
thread: scope,
|
|
49
|
+
limit,
|
|
50
|
+
min_score: 0.5,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* List all sessions
|
|
55
|
+
*/
|
|
56
|
+
async listSessions() {
|
|
57
|
+
const response = await this.get("/api/v2/sessions");
|
|
58
|
+
return response;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a new session
|
|
62
|
+
*/
|
|
63
|
+
async createSession(request = {}) {
|
|
64
|
+
const response = await this.post("/api/v2/sessions", request);
|
|
65
|
+
return response;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Add a message to a session
|
|
69
|
+
*/
|
|
70
|
+
async addMessage(threadId, message) {
|
|
71
|
+
const response = await this.post(`/api/v2/sessions/${threadId}/messages`, message);
|
|
72
|
+
return response;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Close a session
|
|
76
|
+
*/
|
|
77
|
+
async closeSession(threadId) {
|
|
78
|
+
const response = await this.post(`/api/v2/sessions/${threadId}/close`, {});
|
|
79
|
+
return response;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Switch tenant
|
|
83
|
+
*/
|
|
84
|
+
async switchTenant(tenantId) {
|
|
85
|
+
await this.post("/api/v2/tenants/switch", { tenant_id: tenantId });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Health check
|
|
89
|
+
*/
|
|
90
|
+
async healthCheck() {
|
|
91
|
+
try {
|
|
92
|
+
const response = await fetch(`${this.baseUrl}/health`);
|
|
93
|
+
return response.ok;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Private helpers
|
|
100
|
+
async get(path) {
|
|
101
|
+
const response = await fetch(`${this.baseUrl}${path}`);
|
|
102
|
+
if (!response.ok) {
|
|
103
|
+
throw new Error(`API error: ${response.status} ${response.statusText}`);
|
|
104
|
+
}
|
|
105
|
+
const data = (await response.json());
|
|
106
|
+
if (!data.success) {
|
|
107
|
+
throw new Error(data.error || "API request failed");
|
|
108
|
+
}
|
|
109
|
+
return data.data;
|
|
110
|
+
}
|
|
111
|
+
async post(path, body) {
|
|
112
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: {
|
|
115
|
+
"Content-Type": "application/json",
|
|
116
|
+
},
|
|
117
|
+
body: JSON.stringify(body),
|
|
118
|
+
});
|
|
119
|
+
if (!response.ok) {
|
|
120
|
+
const errorText = await response.text();
|
|
121
|
+
throw new Error(`API error: ${response.status} ${response.statusText} - ${errorText}`);
|
|
122
|
+
}
|
|
123
|
+
const data = (await response.json());
|
|
124
|
+
if (!data.success) {
|
|
125
|
+
throw new Error(data.error || "API request failed");
|
|
126
|
+
}
|
|
127
|
+
return data.data;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.CortexMemClient = CortexMemClient;
|
|
131
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA+CH;;GAEG;AACH,MAAa,eAAe;IAClB,OAAO,CAAS;IAExB,YAAY,UAAkB,uBAAuB;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,OAAsB;QACjC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAiB,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAC5E,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CACR,KAAa,EACb,KAAc,EACd,QAAgB,CAAC;QAEjB,OAAO,IAAI,CAAC,MAAM,CAAC;YACjB,KAAK;YACL,MAAM,EAAE,KAAK;YACb,KAAK;YACL,SAAS,EAAE,GAAG;SACf,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAM,CACV,KAAa,EACb,KAAc,EACd,QAAgB,EAAE;QAElB,OAAO,IAAI,CAAC,MAAM,CAAC;YACjB,KAAK;YACL,MAAM,EAAE,KAAK;YACb,KAAK;YACL,SAAS,EAAE,GAAG;SACf,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY;QAChB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAoB,kBAAkB,CAAC,CAAC;QACvE,OAAO,QAAQ,CAAC;IACl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and auto-opening config files for user editing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getConfigDir(): string;
|
|
8
|
+
export declare function getDataDir(): string;
|
|
9
|
+
export declare function getConfigPath(): string;
|
|
10
|
+
export interface MemClawConfig {
|
|
11
|
+
qdrant: {
|
|
12
|
+
url: string;
|
|
13
|
+
collection_name: string;
|
|
14
|
+
timeout_secs: number;
|
|
15
|
+
};
|
|
16
|
+
llm: {
|
|
17
|
+
api_base_url: string;
|
|
18
|
+
api_key: string;
|
|
19
|
+
model_efficient: string;
|
|
20
|
+
temperature: number;
|
|
21
|
+
max_tokens: number;
|
|
22
|
+
};
|
|
23
|
+
embedding: {
|
|
24
|
+
api_base_url: string;
|
|
25
|
+
api_key: string;
|
|
26
|
+
model_name: string;
|
|
27
|
+
batch_size: number;
|
|
28
|
+
timeout_secs: number;
|
|
29
|
+
};
|
|
30
|
+
server: {
|
|
31
|
+
host: string;
|
|
32
|
+
port: number;
|
|
33
|
+
};
|
|
34
|
+
cortex: {
|
|
35
|
+
data_dir: string;
|
|
36
|
+
enable_intent_analysis: boolean;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export declare function generateConfigTemplate(): string;
|
|
40
|
+
export declare function ensureConfigExists(): {
|
|
41
|
+
created: boolean;
|
|
42
|
+
path: string;
|
|
43
|
+
};
|
|
44
|
+
export declare function openConfigFile(configPath: string): Promise<void>;
|
|
45
|
+
export declare function parseConfig(configPath: string): MemClawConfig;
|
|
46
|
+
export declare function validateConfig(config: MemClawConfig): {
|
|
47
|
+
valid: boolean;
|
|
48
|
+
errors: string[];
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,wBAAgB,YAAY,IAAI,MAAM,CAarC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAoBnC;AAED,wB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