conare 0.1.5 → 0.1.6
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/dist/index.js +12 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1049,7 +1049,7 @@ function indexCodebase(rootPath) {
|
|
|
1049
1049
|
|
|
1050
1050
|
// src/api.ts
|
|
1051
1051
|
var API_URL = "https://mcp.conare.ai";
|
|
1052
|
-
function createUploadBatches(memories, maxItems =
|
|
1052
|
+
function createUploadBatches(memories, maxItems = 50, maxChars = 1500000) {
|
|
1053
1053
|
const batches = [];
|
|
1054
1054
|
let current = [];
|
|
1055
1055
|
let currentChars = 0;
|
|
@@ -1100,7 +1100,7 @@ async function getRemoteMemoryCount(apiKey) {
|
|
|
1100
1100
|
return null;
|
|
1101
1101
|
}
|
|
1102
1102
|
}
|
|
1103
|
-
async function uploadItems(apiKey, items) {
|
|
1103
|
+
async function uploadItems(apiKey, items, asyncEmbed = false) {
|
|
1104
1104
|
let retries = 4;
|
|
1105
1105
|
while (retries > 0) {
|
|
1106
1106
|
try {
|
|
@@ -1110,7 +1110,7 @@ async function uploadItems(apiKey, items) {
|
|
|
1110
1110
|
"Content-Type": "application/json",
|
|
1111
1111
|
Authorization: `Bearer ${apiKey}`
|
|
1112
1112
|
},
|
|
1113
|
-
body: JSON.stringify(items)
|
|
1113
|
+
body: JSON.stringify(asyncEmbed ? { items, async: true } : items)
|
|
1114
1114
|
});
|
|
1115
1115
|
if (res.status === 429) {
|
|
1116
1116
|
retries--;
|
|
@@ -1144,8 +1144,9 @@ async function uploadBulk(apiKey, memories, onProgress) {
|
|
|
1144
1144
|
let failed = 0;
|
|
1145
1145
|
const total = memories.length;
|
|
1146
1146
|
const results = [];
|
|
1147
|
-
|
|
1148
|
-
|
|
1147
|
+
const batches = createUploadBatches(memories);
|
|
1148
|
+
for (const batch of batches) {
|
|
1149
|
+
let batchResults = await uploadItems(apiKey, batch.items, true);
|
|
1149
1150
|
if (batch.items.length > 1 && batchResults.some((result) => !result.success)) {
|
|
1150
1151
|
const retriedResults = [];
|
|
1151
1152
|
for (let i = 0;i < batch.items.length; i++) {
|
|
@@ -1154,7 +1155,7 @@ async function uploadBulk(apiKey, memories, onProgress) {
|
|
|
1154
1155
|
retriedResults.push(result);
|
|
1155
1156
|
continue;
|
|
1156
1157
|
}
|
|
1157
|
-
const [singleResult] = await uploadItems(apiKey, [batch.items[i]]);
|
|
1158
|
+
const [singleResult] = await uploadItems(apiKey, [batch.items[i]], true);
|
|
1158
1159
|
retriedResults.push(singleResult);
|
|
1159
1160
|
}
|
|
1160
1161
|
batchResults = retriedResults;
|
|
@@ -2234,6 +2235,11 @@ Nothing new to index.`);
|
|
|
2234
2235
|
allMemories.push(...memories);
|
|
2235
2236
|
console.log(renderDiscoverySummary(memories.length, filtered, deduped));
|
|
2236
2237
|
}
|
|
2238
|
+
allMemories.sort((a, b3) => {
|
|
2239
|
+
const da = a.metadata?.date || "0000";
|
|
2240
|
+
const db = b3.metadata?.date || "0000";
|
|
2241
|
+
return db.localeCompare(da);
|
|
2242
|
+
});
|
|
2237
2243
|
console.log();
|
|
2238
2244
|
if (allMemories.length === 0) {
|
|
2239
2245
|
console.log("Nothing new to upload.");
|