memorysync-sdk 1.8.0 → 1.9.1
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 +63 -3
- package/dist/index.d.ts +63 -3
- package/dist/index.js +94 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +60 -60
package/dist/index.mjs
CHANGED
|
@@ -532,7 +532,7 @@ var IntegrationsNamespace = class extends Namespace {
|
|
|
532
532
|
};
|
|
533
533
|
|
|
534
534
|
// src/control-plane.ts
|
|
535
|
-
var SDK_VERSION = "1.
|
|
535
|
+
var SDK_VERSION = "1.9.1";
|
|
536
536
|
function safeJson(text) {
|
|
537
537
|
try {
|
|
538
538
|
return JSON.parse(text);
|
|
@@ -1104,7 +1104,7 @@ function asSkipped(raw, defaultReason) {
|
|
|
1104
1104
|
}
|
|
1105
1105
|
return null;
|
|
1106
1106
|
}
|
|
1107
|
-
var SDK_VERSION2 = "1.
|
|
1107
|
+
var SDK_VERSION2 = "1.9.1";
|
|
1108
1108
|
function camelToSnakeKey(key) {
|
|
1109
1109
|
return key.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
1110
1110
|
}
|
|
@@ -1322,6 +1322,63 @@ var MemorySyncClient = class {
|
|
|
1322
1322
|
}))
|
|
1323
1323
|
};
|
|
1324
1324
|
}
|
|
1325
|
+
// ── Bulk import ────────────────────────────────────────────────────
|
|
1326
|
+
/**
|
|
1327
|
+
* Upload a payload and get an import job back, without waiting for it.
|
|
1328
|
+
*
|
|
1329
|
+
* `bulkAdd` accepts fifty records per call because each one runs the extraction
|
|
1330
|
+
* pipeline. For a migration out of another system, upload the whole file here
|
|
1331
|
+
* and poll {@link getImport}.
|
|
1332
|
+
*
|
|
1333
|
+
* `resume` requires `clientRef` on every record and is what makes re-running the
|
|
1334
|
+
* same file safe: records a previous run already stored come back counted as
|
|
1335
|
+
* `alreadyImported` rather than stored again.
|
|
1336
|
+
*
|
|
1337
|
+
* The payload is JSONL, or JSON when `filename` ends in `.json`. The extension
|
|
1338
|
+
* is how the server picks the reader, so it is required.
|
|
1339
|
+
*/
|
|
1340
|
+
async createImport(req) {
|
|
1341
|
+
if (!req.filename?.trim()) {
|
|
1342
|
+
throw new ValidationError("filename is required so the server can pick a reader");
|
|
1343
|
+
}
|
|
1344
|
+
const form = new FormData();
|
|
1345
|
+
form.set("resume", req.resume ? "true" : "false");
|
|
1346
|
+
form.set("continue_on_error", req.continueOnError ? "true" : "false");
|
|
1347
|
+
if (req.endUserId !== void 0) form.set("end_user_id", req.endUserId);
|
|
1348
|
+
const blob = req.file instanceof Blob ? req.file : new Blob([req.file], { type: "application/octet-stream" });
|
|
1349
|
+
form.set("file", blob, req.filename);
|
|
1350
|
+
return this.request("POST", "/imports", {
|
|
1351
|
+
form,
|
|
1352
|
+
endUserOverride: req.endUserId
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* One import job's status, progress and per-outcome counters.
|
|
1357
|
+
*
|
|
1358
|
+
* `progress_percentage` stays below 100 until the job is genuinely finished, so
|
|
1359
|
+
* reaching 100 means done.
|
|
1360
|
+
*/
|
|
1361
|
+
async getImport(jobId) {
|
|
1362
|
+
if (!jobId?.trim()) throw new ValidationError("jobId is required");
|
|
1363
|
+
return this.request("GET", `/imports/${encodeURIComponent(jobId)}`);
|
|
1364
|
+
}
|
|
1365
|
+
/** Recent import jobs, newest first. */
|
|
1366
|
+
async listImports(opts = {}) {
|
|
1367
|
+
return this.request("GET", "/imports", { query: opts });
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Ask the worker to stop between batches.
|
|
1371
|
+
*
|
|
1372
|
+
* Records already imported stay imported, and the counters report how far it
|
|
1373
|
+
* reached. Cancelling a finished job is a no-op rather than an error.
|
|
1374
|
+
*/
|
|
1375
|
+
async cancelImport(jobId) {
|
|
1376
|
+
if (!jobId?.trim()) throw new ValidationError("jobId is required");
|
|
1377
|
+
return this.request(
|
|
1378
|
+
"POST",
|
|
1379
|
+
`/imports/${encodeURIComponent(jobId)}/cancel`
|
|
1380
|
+
);
|
|
1381
|
+
}
|
|
1325
1382
|
async query(req) {
|
|
1326
1383
|
const body = { query: req.query };
|
|
1327
1384
|
if (req.k !== void 0) body.k = req.k;
|
|
@@ -1765,15 +1822,46 @@ var MemorySyncClient = class {
|
|
|
1765
1822
|
return await this.request("GET", "/memory/knowledge/stats") ?? {};
|
|
1766
1823
|
}
|
|
1767
1824
|
// ── v1 data plane ──────────────────────────────────────────────────
|
|
1768
|
-
/**
|
|
1825
|
+
/**
|
|
1826
|
+
* Store one conversational turn VERBATIM (episodic ingestion).
|
|
1827
|
+
*
|
|
1828
|
+
* The sibling of the extraction-gated fact store: nothing is rewritten,
|
|
1829
|
+
* deduped by meaning, or judged for value — the text is stored exactly as
|
|
1830
|
+
* supplied and embedded so it is retrievable. Empty text is the only
|
|
1831
|
+
* refusal. `speaker` and `occurredAt` join the server's idempotency seed,
|
|
1832
|
+
* so resending an identical payload is recognised (`already_exists: true`)
|
|
1833
|
+
* rather than stored twice. `syncEmbed: true` embeds inline so the row is
|
|
1834
|
+
* immediately queryable. `sessionId` is recorded into `metadata` under
|
|
1835
|
+
* `"session_id"`.
|
|
1836
|
+
*
|
|
1837
|
+
* A `messages` array is not accepted: this endpoint stores exactly one
|
|
1838
|
+
* turn. Earlier releases sent `messages`, which the server has not
|
|
1839
|
+
* accepted since the episodic rewrite — every such call failed with a
|
|
1840
|
+
* 422, so the mistake is now caught client-side with a real explanation.
|
|
1841
|
+
*/
|
|
1769
1842
|
async addTurn(req) {
|
|
1843
|
+
if (req.messages !== void 0) {
|
|
1844
|
+
throw new ValidationError(
|
|
1845
|
+
"addTurn() stores exactly one verbatim turn and takes text, not messages. Format the turn as a string (e.g. 'user: I always fly with the window seat.') and pass it as text, with the author in speaker."
|
|
1846
|
+
);
|
|
1847
|
+
}
|
|
1848
|
+
if (!req.text?.trim()) {
|
|
1849
|
+
throw new ValidationError("addTurn() requires non-empty text");
|
|
1850
|
+
}
|
|
1851
|
+
let metadata = req.metadata;
|
|
1852
|
+
if (req.sessionId !== void 0) {
|
|
1853
|
+
metadata = { ...req.metadata ?? {}, session_id: req.sessionId };
|
|
1854
|
+
}
|
|
1770
1855
|
const body = {
|
|
1771
1856
|
tenant_id: req.tenantId,
|
|
1772
1857
|
user_id: req.userId,
|
|
1773
|
-
|
|
1858
|
+
source: req.source ?? "chat",
|
|
1859
|
+
text: req.text
|
|
1774
1860
|
};
|
|
1775
|
-
if (req.
|
|
1776
|
-
if (req.
|
|
1861
|
+
if (req.speaker !== void 0) body.speaker = req.speaker;
|
|
1862
|
+
if (req.occurredAt !== void 0) body.occurred_at = req.occurredAt;
|
|
1863
|
+
if (metadata !== void 0) body.metadata = metadata;
|
|
1864
|
+
if (req.syncEmbed) body.sync_embed = true;
|
|
1777
1865
|
return await this.request("POST", "/v1/memory/add_turn", { body }) ?? {};
|
|
1778
1866
|
}
|
|
1779
1867
|
/**
|