memorysync-sdk 1.7.2 → 1.8.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/dist/index.d.mts +30 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +36 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +60 -60
package/dist/index.d.mts
CHANGED
|
@@ -807,6 +807,17 @@ interface AddRequest {
|
|
|
807
807
|
sessionId?: string;
|
|
808
808
|
metadata?: Record<string, unknown>;
|
|
809
809
|
endUserId?: string;
|
|
810
|
+
/**
|
|
811
|
+
* Your own identifier for this record, at most 128 characters.
|
|
812
|
+
*
|
|
813
|
+
* Send it and re-sending the record is recognised rather than stored a second
|
|
814
|
+
* time: the call resolves to an {@link AddSkippedResponse} with reason
|
|
815
|
+
* `already_ingested` and the ids the first write produced. That makes an
|
|
816
|
+
* interrupted write safe to retry without first checking whether it landed.
|
|
817
|
+
* Near-duplicate detection is always on but compares *meaning*, so it is a
|
|
818
|
+
* filter and not a guarantee.
|
|
819
|
+
*/
|
|
820
|
+
clientRef?: string;
|
|
810
821
|
}
|
|
811
822
|
interface MemoryRecord {
|
|
812
823
|
id: number;
|
|
@@ -832,6 +843,16 @@ interface AddSkippedResponse {
|
|
|
832
843
|
type AddResponse = MemoryRecord | AddSkippedResponse;
|
|
833
844
|
interface BulkAddItem {
|
|
834
845
|
text: string;
|
|
846
|
+
/**
|
|
847
|
+
* Your own identifier for this record, at most 128 characters.
|
|
848
|
+
*
|
|
849
|
+
* Send it and re-submitting the record is recognised rather than stored a
|
|
850
|
+
* second time: the item comes back `skipped` with reason `already_ingested`
|
|
851
|
+
* and the ids the first submission produced. This is what makes a large import
|
|
852
|
+
* safe to re-run. Near-duplicate detection is always on but compares
|
|
853
|
+
* *meaning*, so it is a filter and not a guarantee.
|
|
854
|
+
*/
|
|
855
|
+
clientRef?: string;
|
|
835
856
|
source?: string;
|
|
836
857
|
eventType?: string;
|
|
837
858
|
tags?: string[];
|
|
@@ -851,6 +872,15 @@ interface BulkAddResponse {
|
|
|
851
872
|
skipped: number;
|
|
852
873
|
rejected: number;
|
|
853
874
|
results: BulkAddItemResult[];
|
|
875
|
+
/**
|
|
876
|
+
* Items the server accepted without returning a per-item result.
|
|
877
|
+
*
|
|
878
|
+
* Normally `0`. It is the whole batch when the organization is over its plan
|
|
879
|
+
* limit: the route answers a bare success envelope and stores nothing, so
|
|
880
|
+
* there is no per-item detail to report. Counted separately from `created` on
|
|
881
|
+
* purpose — reporting these as created would be a guess, and a wrong one.
|
|
882
|
+
*/
|
|
883
|
+
unreported: number;
|
|
854
884
|
}
|
|
855
885
|
interface QueryFilters {
|
|
856
886
|
memoryType?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -807,6 +807,17 @@ interface AddRequest {
|
|
|
807
807
|
sessionId?: string;
|
|
808
808
|
metadata?: Record<string, unknown>;
|
|
809
809
|
endUserId?: string;
|
|
810
|
+
/**
|
|
811
|
+
* Your own identifier for this record, at most 128 characters.
|
|
812
|
+
*
|
|
813
|
+
* Send it and re-sending the record is recognised rather than stored a second
|
|
814
|
+
* time: the call resolves to an {@link AddSkippedResponse} with reason
|
|
815
|
+
* `already_ingested` and the ids the first write produced. That makes an
|
|
816
|
+
* interrupted write safe to retry without first checking whether it landed.
|
|
817
|
+
* Near-duplicate detection is always on but compares *meaning*, so it is a
|
|
818
|
+
* filter and not a guarantee.
|
|
819
|
+
*/
|
|
820
|
+
clientRef?: string;
|
|
810
821
|
}
|
|
811
822
|
interface MemoryRecord {
|
|
812
823
|
id: number;
|
|
@@ -832,6 +843,16 @@ interface AddSkippedResponse {
|
|
|
832
843
|
type AddResponse = MemoryRecord | AddSkippedResponse;
|
|
833
844
|
interface BulkAddItem {
|
|
834
845
|
text: string;
|
|
846
|
+
/**
|
|
847
|
+
* Your own identifier for this record, at most 128 characters.
|
|
848
|
+
*
|
|
849
|
+
* Send it and re-submitting the record is recognised rather than stored a
|
|
850
|
+
* second time: the item comes back `skipped` with reason `already_ingested`
|
|
851
|
+
* and the ids the first submission produced. This is what makes a large import
|
|
852
|
+
* safe to re-run. Near-duplicate detection is always on but compares
|
|
853
|
+
* *meaning*, so it is a filter and not a guarantee.
|
|
854
|
+
*/
|
|
855
|
+
clientRef?: string;
|
|
835
856
|
source?: string;
|
|
836
857
|
eventType?: string;
|
|
837
858
|
tags?: string[];
|
|
@@ -851,6 +872,15 @@ interface BulkAddResponse {
|
|
|
851
872
|
skipped: number;
|
|
852
873
|
rejected: number;
|
|
853
874
|
results: BulkAddItemResult[];
|
|
875
|
+
/**
|
|
876
|
+
* Items the server accepted without returning a per-item result.
|
|
877
|
+
*
|
|
878
|
+
* Normally `0`. It is the whole batch when the organization is over its plan
|
|
879
|
+
* limit: the route answers a bare success envelope and stores nothing, so
|
|
880
|
+
* there is no per-item detail to report. Counted separately from `created` on
|
|
881
|
+
* purpose — reporting these as created would be a guess, and a wrong one.
|
|
882
|
+
*/
|
|
883
|
+
unreported: number;
|
|
854
884
|
}
|
|
855
885
|
interface QueryFilters {
|
|
856
886
|
memoryType?: string;
|
package/dist/index.js
CHANGED
|
@@ -576,7 +576,7 @@ var IntegrationsNamespace = class extends Namespace {
|
|
|
576
576
|
};
|
|
577
577
|
|
|
578
578
|
// src/control-plane.ts
|
|
579
|
-
var SDK_VERSION = "1.
|
|
579
|
+
var SDK_VERSION = "1.8.0";
|
|
580
580
|
function safeJson(text) {
|
|
581
581
|
try {
|
|
582
582
|
return JSON.parse(text);
|
|
@@ -1132,7 +1132,23 @@ var ControlPlaneClient = class {
|
|
|
1132
1132
|
};
|
|
1133
1133
|
|
|
1134
1134
|
// src/index.ts
|
|
1135
|
-
|
|
1135
|
+
function asSkipped(raw, defaultReason) {
|
|
1136
|
+
if (!raw || typeof raw !== "object") return null;
|
|
1137
|
+
if (raw.status === "skipped") {
|
|
1138
|
+
return {
|
|
1139
|
+
status: "skipped",
|
|
1140
|
+
reason: raw.reason ?? defaultReason,
|
|
1141
|
+
memoryIds: raw.memory_ids ?? [],
|
|
1142
|
+
candidatesExtracted: raw.candidates_extracted ?? 0,
|
|
1143
|
+
candidatesStored: raw.candidates_stored ?? 0
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
if (raw.status === "ok" && raw.id === void 0) {
|
|
1147
|
+
return { status: "skipped", reason: "quota_exhausted", memoryIds: [], candidatesExtracted: 0, candidatesStored: 0 };
|
|
1148
|
+
}
|
|
1149
|
+
return null;
|
|
1150
|
+
}
|
|
1151
|
+
var SDK_VERSION2 = "1.8.0";
|
|
1136
1152
|
function camelToSnakeKey(key) {
|
|
1137
1153
|
return key.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
1138
1154
|
}
|
|
@@ -1299,19 +1315,13 @@ var MemorySyncClient = class {
|
|
|
1299
1315
|
if (req.sessionId !== void 0) body.session_id = req.sessionId;
|
|
1300
1316
|
if (req.metadata !== void 0) body.metadata = req.metadata;
|
|
1301
1317
|
if (req.endUserId !== void 0) body.end_user_id = req.endUserId;
|
|
1318
|
+
if (req.clientRef !== void 0) body.client_ref = req.clientRef;
|
|
1302
1319
|
const raw = await this.request("POST", "/memory/add", {
|
|
1303
1320
|
body,
|
|
1304
1321
|
endUserOverride: req.endUserId
|
|
1305
1322
|
});
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
status: "skipped",
|
|
1309
|
-
reason: raw.reason ?? "no_high_value_content",
|
|
1310
|
-
memoryIds: raw.memory_ids ?? [],
|
|
1311
|
-
candidatesExtracted: raw.candidates_extracted ?? 0,
|
|
1312
|
-
candidatesStored: raw.candidates_stored ?? 0
|
|
1313
|
-
};
|
|
1314
|
-
}
|
|
1323
|
+
const notStored = asSkipped(raw, "no_high_value_content");
|
|
1324
|
+
if (notStored) return notStored;
|
|
1315
1325
|
return snakeToCamelMemory(raw);
|
|
1316
1326
|
}
|
|
1317
1327
|
async bulkAdd(items, opts = {}) {
|
|
@@ -1326,17 +1336,29 @@ var MemorySyncClient = class {
|
|
|
1326
1336
|
if (i.metadata !== void 0) o.metadata = i.metadata;
|
|
1327
1337
|
if (i.importance !== void 0) o.importance = i.importance;
|
|
1328
1338
|
if (i.endUserId !== void 0) o.end_user_id = i.endUserId;
|
|
1339
|
+
if (i.clientRef !== void 0) o.client_ref = i.clientRef;
|
|
1329
1340
|
return o;
|
|
1330
1341
|
}),
|
|
1331
1342
|
deduplicate: opts.deduplicate ?? true
|
|
1332
1343
|
};
|
|
1333
1344
|
const raw = await this.request("POST", "/memory/bulk-add", { body });
|
|
1345
|
+
if (!Array.isArray(raw.results)) {
|
|
1346
|
+
return {
|
|
1347
|
+
total: items.length,
|
|
1348
|
+
created: 0,
|
|
1349
|
+
skipped: 0,
|
|
1350
|
+
rejected: 0,
|
|
1351
|
+
results: [],
|
|
1352
|
+
unreported: items.length
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1334
1355
|
return {
|
|
1335
1356
|
total: raw.total,
|
|
1336
1357
|
created: raw.created,
|
|
1337
1358
|
skipped: raw.skipped,
|
|
1338
1359
|
rejected: raw.rejected,
|
|
1339
|
-
|
|
1360
|
+
unreported: 0,
|
|
1361
|
+
results: raw.results.map((r) => ({
|
|
1340
1362
|
index: r.index,
|
|
1341
1363
|
status: r.status,
|
|
1342
1364
|
memoryIds: r.memory_ids ?? [],
|
|
@@ -1533,15 +1555,8 @@ var MemorySyncClient = class {
|
|
|
1533
1555
|
form,
|
|
1534
1556
|
endUserOverride: req.endUserId
|
|
1535
1557
|
});
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
status: "skipped",
|
|
1539
|
-
reason: raw.reason ?? "no_extractable_text",
|
|
1540
|
-
memoryIds: raw.memory_ids ?? [],
|
|
1541
|
-
candidatesExtracted: raw.candidates_extracted ?? 0,
|
|
1542
|
-
candidatesStored: raw.candidates_stored ?? 0
|
|
1543
|
-
};
|
|
1544
|
-
}
|
|
1558
|
+
const notStored = asSkipped(raw, "no_extractable_text");
|
|
1559
|
+
if (notStored) return notStored;
|
|
1545
1560
|
return snakeToCamelMemory(raw);
|
|
1546
1561
|
}
|
|
1547
1562
|
// ── Bulk edit ──────────────────────────────────────────────────────
|