n8n-nodes-recallio
Version:
RecallioAI Memory node for n8n
81 lines • 2.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RecallioError = exports.RecallioClient = void 0;
class RecallioError extends Error {
constructor(message, status, details) {
super(message);
this.name = 'RecallioError';
this.status = status;
this.details = details;
}
}
exports.RecallioError = RecallioError;
class RecallioClient {
constructor(options, httpRequest) {
this.apiKey = options.apiKey;
this.baseUrl = options.baseUrl || 'https://app.recallio.ai';
this.httpRequest = httpRequest;
}
async makeRequest(method, path, params, data) {
var _a;
const url = new URL(path, this.baseUrl);
if (params) {
Object.keys(params).forEach(key => {
if (params[key] !== undefined && params[key] !== null) {
url.searchParams.append(key, params[key].toString());
}
});
}
const options = {
url: url.toString(),
method: method.toUpperCase(),
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
},
json: true,
body: data
};
try {
const response = await this.httpRequest(options);
return response;
}
catch (error) {
const status = error.statusCode || error.status;
const message = ((_a = error.error) === null || _a === void 0 ? void 0 : _a.error) || error.message || 'Request failed';
throw new RecallioError(message, status, error.error);
}
}
async writeMemory(body) {
await this.makeRequest('POST', '/api/Memory/write', undefined, body);
}
async recallMemory(body, options = {}) {
const params = {
summarized: options.summarized,
reRank: options.reRank,
type: options.type,
similarityThreshold: options.similarityThreshold,
limit: options.limit
};
return this.makeRequest('POST', '/api/Memory/recall', params, body);
}
async deleteMemory(body) {
await this.makeRequest('DELETE', '/api/Memory/delete', undefined, body);
}
async recallSummary(body) {
return this.makeRequest('POST', '/api/Memory/recall-summary', undefined, body);
}
async exportMemory(params) {
const query = {
Type: params.type,
Format: params.format,
UserId: params.userId,
ProjectId: params.projectId,
StartDate: params.startDate,
EndDate: params.endDate
};
return this.makeRequest('GET', '/api/Memory/export', query);
}
}
exports.RecallioClient = RecallioClient;
//# sourceMappingURL=RecallioClient.js.map