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.d.mts
CHANGED
|
@@ -1114,6 +1114,46 @@ declare class MemorySyncClient {
|
|
|
1114
1114
|
bulkAdd(items: BulkAddItem[], opts?: {
|
|
1115
1115
|
deduplicate?: boolean;
|
|
1116
1116
|
}): Promise<BulkAddResponse>;
|
|
1117
|
+
/**
|
|
1118
|
+
* Upload a payload and get an import job back, without waiting for it.
|
|
1119
|
+
*
|
|
1120
|
+
* `bulkAdd` accepts fifty records per call because each one runs the extraction
|
|
1121
|
+
* pipeline. For a migration out of another system, upload the whole file here
|
|
1122
|
+
* and poll {@link getImport}.
|
|
1123
|
+
*
|
|
1124
|
+
* `resume` requires `clientRef` on every record and is what makes re-running the
|
|
1125
|
+
* same file safe: records a previous run already stored come back counted as
|
|
1126
|
+
* `alreadyImported` rather than stored again.
|
|
1127
|
+
*
|
|
1128
|
+
* The payload is JSONL, or JSON when `filename` ends in `.json`. The extension
|
|
1129
|
+
* is how the server picks the reader, so it is required.
|
|
1130
|
+
*/
|
|
1131
|
+
createImport(req: {
|
|
1132
|
+
file: Blob | Uint8Array | string;
|
|
1133
|
+
filename: string;
|
|
1134
|
+
endUserId?: string;
|
|
1135
|
+
resume?: boolean;
|
|
1136
|
+
continueOnError?: boolean;
|
|
1137
|
+
}): Promise<Record<string, unknown>>;
|
|
1138
|
+
/**
|
|
1139
|
+
* One import job's status, progress and per-outcome counters.
|
|
1140
|
+
*
|
|
1141
|
+
* `progress_percentage` stays below 100 until the job is genuinely finished, so
|
|
1142
|
+
* reaching 100 means done.
|
|
1143
|
+
*/
|
|
1144
|
+
getImport(jobId: string): Promise<Record<string, unknown>>;
|
|
1145
|
+
/** Recent import jobs, newest first. */
|
|
1146
|
+
listImports(opts?: {
|
|
1147
|
+
status?: string;
|
|
1148
|
+
limit?: number;
|
|
1149
|
+
}): Promise<Record<string, unknown>>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Ask the worker to stop between batches.
|
|
1152
|
+
*
|
|
1153
|
+
* Records already imported stay imported, and the counters report how far it
|
|
1154
|
+
* reached. Cancelling a finished job is a no-op rather than an error.
|
|
1155
|
+
*/
|
|
1156
|
+
cancelImport(jobId: string): Promise<Record<string, unknown>>;
|
|
1117
1157
|
query(req: QueryRequest): Promise<QueryResponse>;
|
|
1118
1158
|
get(memoryId: number): Promise<MemoryRecord>;
|
|
1119
1159
|
update(memoryId: number, req: UpdateRequest): Promise<MemoryRecord>;
|
|
@@ -1277,13 +1317,33 @@ declare class MemorySyncClient {
|
|
|
1277
1317
|
}): Promise<Record<string, unknown>>;
|
|
1278
1318
|
/** Counts and coverage for the knowledge base. */
|
|
1279
1319
|
knowledgeStats(): Promise<Record<string, unknown>>;
|
|
1280
|
-
/**
|
|
1320
|
+
/**
|
|
1321
|
+
* Store one conversational turn VERBATIM (episodic ingestion).
|
|
1322
|
+
*
|
|
1323
|
+
* The sibling of the extraction-gated fact store: nothing is rewritten,
|
|
1324
|
+
* deduped by meaning, or judged for value — the text is stored exactly as
|
|
1325
|
+
* supplied and embedded so it is retrievable. Empty text is the only
|
|
1326
|
+
* refusal. `speaker` and `occurredAt` join the server's idempotency seed,
|
|
1327
|
+
* so resending an identical payload is recognised (`already_exists: true`)
|
|
1328
|
+
* rather than stored twice. `syncEmbed: true` embeds inline so the row is
|
|
1329
|
+
* immediately queryable. `sessionId` is recorded into `metadata` under
|
|
1330
|
+
* `"session_id"`.
|
|
1331
|
+
*
|
|
1332
|
+
* A `messages` array is not accepted: this endpoint stores exactly one
|
|
1333
|
+
* turn. Earlier releases sent `messages`, which the server has not
|
|
1334
|
+
* accepted since the episodic rewrite — every such call failed with a
|
|
1335
|
+
* 422, so the mistake is now caught client-side with a real explanation.
|
|
1336
|
+
*/
|
|
1281
1337
|
addTurn(req: {
|
|
1282
1338
|
tenantId: string;
|
|
1283
1339
|
userId: string;
|
|
1284
|
-
|
|
1285
|
-
|
|
1340
|
+
text: string;
|
|
1341
|
+
speaker?: string;
|
|
1342
|
+
occurredAt?: string;
|
|
1286
1343
|
metadata?: Record<string, unknown>;
|
|
1344
|
+
source?: string;
|
|
1345
|
+
syncEmbed?: boolean;
|
|
1346
|
+
sessionId?: string;
|
|
1287
1347
|
}): Promise<Record<string, unknown>>;
|
|
1288
1348
|
/**
|
|
1289
1349
|
* Build a prompt-ready context block for an LLM call.
|
package/dist/index.d.ts
CHANGED
|
@@ -1114,6 +1114,46 @@ declare class MemorySyncClient {
|
|
|
1114
1114
|
bulkAdd(items: BulkAddItem[], opts?: {
|
|
1115
1115
|
deduplicate?: boolean;
|
|
1116
1116
|
}): Promise<BulkAddResponse>;
|
|
1117
|
+
/**
|
|
1118
|
+
* Upload a payload and get an import job back, without waiting for it.
|
|
1119
|
+
*
|
|
1120
|
+
* `bulkAdd` accepts fifty records per call because each one runs the extraction
|
|
1121
|
+
* pipeline. For a migration out of another system, upload the whole file here
|
|
1122
|
+
* and poll {@link getImport}.
|
|
1123
|
+
*
|
|
1124
|
+
* `resume` requires `clientRef` on every record and is what makes re-running the
|
|
1125
|
+
* same file safe: records a previous run already stored come back counted as
|
|
1126
|
+
* `alreadyImported` rather than stored again.
|
|
1127
|
+
*
|
|
1128
|
+
* The payload is JSONL, or JSON when `filename` ends in `.json`. The extension
|
|
1129
|
+
* is how the server picks the reader, so it is required.
|
|
1130
|
+
*/
|
|
1131
|
+
createImport(req: {
|
|
1132
|
+
file: Blob | Uint8Array | string;
|
|
1133
|
+
filename: string;
|
|
1134
|
+
endUserId?: string;
|
|
1135
|
+
resume?: boolean;
|
|
1136
|
+
continueOnError?: boolean;
|
|
1137
|
+
}): Promise<Record<string, unknown>>;
|
|
1138
|
+
/**
|
|
1139
|
+
* One import job's status, progress and per-outcome counters.
|
|
1140
|
+
*
|
|
1141
|
+
* `progress_percentage` stays below 100 until the job is genuinely finished, so
|
|
1142
|
+
* reaching 100 means done.
|
|
1143
|
+
*/
|
|
1144
|
+
getImport(jobId: string): Promise<Record<string, unknown>>;
|
|
1145
|
+
/** Recent import jobs, newest first. */
|
|
1146
|
+
listImports(opts?: {
|
|
1147
|
+
status?: string;
|
|
1148
|
+
limit?: number;
|
|
1149
|
+
}): Promise<Record<string, unknown>>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Ask the worker to stop between batches.
|
|
1152
|
+
*
|
|
1153
|
+
* Records already imported stay imported, and the counters report how far it
|
|
1154
|
+
* reached. Cancelling a finished job is a no-op rather than an error.
|
|
1155
|
+
*/
|
|
1156
|
+
cancelImport(jobId: string): Promise<Record<string, unknown>>;
|
|
1117
1157
|
query(req: QueryRequest): Promise<QueryResponse>;
|
|
1118
1158
|
get(memoryId: number): Promise<MemoryRecord>;
|
|
1119
1159
|
update(memoryId: number, req: UpdateRequest): Promise<MemoryRecord>;
|
|
@@ -1277,13 +1317,33 @@ declare class MemorySyncClient {
|
|
|
1277
1317
|
}): Promise<Record<string, unknown>>;
|
|
1278
1318
|
/** Counts and coverage for the knowledge base. */
|
|
1279
1319
|
knowledgeStats(): Promise<Record<string, unknown>>;
|
|
1280
|
-
/**
|
|
1320
|
+
/**
|
|
1321
|
+
* Store one conversational turn VERBATIM (episodic ingestion).
|
|
1322
|
+
*
|
|
1323
|
+
* The sibling of the extraction-gated fact store: nothing is rewritten,
|
|
1324
|
+
* deduped by meaning, or judged for value — the text is stored exactly as
|
|
1325
|
+
* supplied and embedded so it is retrievable. Empty text is the only
|
|
1326
|
+
* refusal. `speaker` and `occurredAt` join the server's idempotency seed,
|
|
1327
|
+
* so resending an identical payload is recognised (`already_exists: true`)
|
|
1328
|
+
* rather than stored twice. `syncEmbed: true` embeds inline so the row is
|
|
1329
|
+
* immediately queryable. `sessionId` is recorded into `metadata` under
|
|
1330
|
+
* `"session_id"`.
|
|
1331
|
+
*
|
|
1332
|
+
* A `messages` array is not accepted: this endpoint stores exactly one
|
|
1333
|
+
* turn. Earlier releases sent `messages`, which the server has not
|
|
1334
|
+
* accepted since the episodic rewrite — every such call failed with a
|
|
1335
|
+
* 422, so the mistake is now caught client-side with a real explanation.
|
|
1336
|
+
*/
|
|
1281
1337
|
addTurn(req: {
|
|
1282
1338
|
tenantId: string;
|
|
1283
1339
|
userId: string;
|
|
1284
|
-
|
|
1285
|
-
|
|
1340
|
+
text: string;
|
|
1341
|
+
speaker?: string;
|
|
1342
|
+
occurredAt?: string;
|
|
1286
1343
|
metadata?: Record<string, unknown>;
|
|
1344
|
+
source?: string;
|
|
1345
|
+
syncEmbed?: boolean;
|
|
1346
|
+
sessionId?: string;
|
|
1287
1347
|
}): Promise<Record<string, unknown>>;
|
|
1288
1348
|
/**
|
|
1289
1349
|
* Build a prompt-ready context block for an LLM call.
|
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.9.1";
|
|
580
580
|
function safeJson(text) {
|
|
581
581
|
try {
|
|
582
582
|
return JSON.parse(text);
|
|
@@ -1148,7 +1148,7 @@ function asSkipped(raw, defaultReason) {
|
|
|
1148
1148
|
}
|
|
1149
1149
|
return null;
|
|
1150
1150
|
}
|
|
1151
|
-
var SDK_VERSION2 = "1.
|
|
1151
|
+
var SDK_VERSION2 = "1.9.1";
|
|
1152
1152
|
function camelToSnakeKey(key) {
|
|
1153
1153
|
return key.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
1154
1154
|
}
|
|
@@ -1366,6 +1366,63 @@ var MemorySyncClient = class {
|
|
|
1366
1366
|
}))
|
|
1367
1367
|
};
|
|
1368
1368
|
}
|
|
1369
|
+
// ── Bulk import ────────────────────────────────────────────────────
|
|
1370
|
+
/**
|
|
1371
|
+
* Upload a payload and get an import job back, without waiting for it.
|
|
1372
|
+
*
|
|
1373
|
+
* `bulkAdd` accepts fifty records per call because each one runs the extraction
|
|
1374
|
+
* pipeline. For a migration out of another system, upload the whole file here
|
|
1375
|
+
* and poll {@link getImport}.
|
|
1376
|
+
*
|
|
1377
|
+
* `resume` requires `clientRef` on every record and is what makes re-running the
|
|
1378
|
+
* same file safe: records a previous run already stored come back counted as
|
|
1379
|
+
* `alreadyImported` rather than stored again.
|
|
1380
|
+
*
|
|
1381
|
+
* The payload is JSONL, or JSON when `filename` ends in `.json`. The extension
|
|
1382
|
+
* is how the server picks the reader, so it is required.
|
|
1383
|
+
*/
|
|
1384
|
+
async createImport(req) {
|
|
1385
|
+
if (!req.filename?.trim()) {
|
|
1386
|
+
throw new ValidationError("filename is required so the server can pick a reader");
|
|
1387
|
+
}
|
|
1388
|
+
const form = new FormData();
|
|
1389
|
+
form.set("resume", req.resume ? "true" : "false");
|
|
1390
|
+
form.set("continue_on_error", req.continueOnError ? "true" : "false");
|
|
1391
|
+
if (req.endUserId !== void 0) form.set("end_user_id", req.endUserId);
|
|
1392
|
+
const blob = req.file instanceof Blob ? req.file : new Blob([req.file], { type: "application/octet-stream" });
|
|
1393
|
+
form.set("file", blob, req.filename);
|
|
1394
|
+
return this.request("POST", "/imports", {
|
|
1395
|
+
form,
|
|
1396
|
+
endUserOverride: req.endUserId
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* One import job's status, progress and per-outcome counters.
|
|
1401
|
+
*
|
|
1402
|
+
* `progress_percentage` stays below 100 until the job is genuinely finished, so
|
|
1403
|
+
* reaching 100 means done.
|
|
1404
|
+
*/
|
|
1405
|
+
async getImport(jobId) {
|
|
1406
|
+
if (!jobId?.trim()) throw new ValidationError("jobId is required");
|
|
1407
|
+
return this.request("GET", `/imports/${encodeURIComponent(jobId)}`);
|
|
1408
|
+
}
|
|
1409
|
+
/** Recent import jobs, newest first. */
|
|
1410
|
+
async listImports(opts = {}) {
|
|
1411
|
+
return this.request("GET", "/imports", { query: opts });
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Ask the worker to stop between batches.
|
|
1415
|
+
*
|
|
1416
|
+
* Records already imported stay imported, and the counters report how far it
|
|
1417
|
+
* reached. Cancelling a finished job is a no-op rather than an error.
|
|
1418
|
+
*/
|
|
1419
|
+
async cancelImport(jobId) {
|
|
1420
|
+
if (!jobId?.trim()) throw new ValidationError("jobId is required");
|
|
1421
|
+
return this.request(
|
|
1422
|
+
"POST",
|
|
1423
|
+
`/imports/${encodeURIComponent(jobId)}/cancel`
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1369
1426
|
async query(req) {
|
|
1370
1427
|
const body = { query: req.query };
|
|
1371
1428
|
if (req.k !== void 0) body.k = req.k;
|
|
@@ -1809,15 +1866,46 @@ var MemorySyncClient = class {
|
|
|
1809
1866
|
return await this.request("GET", "/memory/knowledge/stats") ?? {};
|
|
1810
1867
|
}
|
|
1811
1868
|
// ── v1 data plane ──────────────────────────────────────────────────
|
|
1812
|
-
/**
|
|
1869
|
+
/**
|
|
1870
|
+
* Store one conversational turn VERBATIM (episodic ingestion).
|
|
1871
|
+
*
|
|
1872
|
+
* The sibling of the extraction-gated fact store: nothing is rewritten,
|
|
1873
|
+
* deduped by meaning, or judged for value — the text is stored exactly as
|
|
1874
|
+
* supplied and embedded so it is retrievable. Empty text is the only
|
|
1875
|
+
* refusal. `speaker` and `occurredAt` join the server's idempotency seed,
|
|
1876
|
+
* so resending an identical payload is recognised (`already_exists: true`)
|
|
1877
|
+
* rather than stored twice. `syncEmbed: true` embeds inline so the row is
|
|
1878
|
+
* immediately queryable. `sessionId` is recorded into `metadata` under
|
|
1879
|
+
* `"session_id"`.
|
|
1880
|
+
*
|
|
1881
|
+
* A `messages` array is not accepted: this endpoint stores exactly one
|
|
1882
|
+
* turn. Earlier releases sent `messages`, which the server has not
|
|
1883
|
+
* accepted since the episodic rewrite — every such call failed with a
|
|
1884
|
+
* 422, so the mistake is now caught client-side with a real explanation.
|
|
1885
|
+
*/
|
|
1813
1886
|
async addTurn(req) {
|
|
1887
|
+
if (req.messages !== void 0) {
|
|
1888
|
+
throw new ValidationError(
|
|
1889
|
+
"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."
|
|
1890
|
+
);
|
|
1891
|
+
}
|
|
1892
|
+
if (!req.text?.trim()) {
|
|
1893
|
+
throw new ValidationError("addTurn() requires non-empty text");
|
|
1894
|
+
}
|
|
1895
|
+
let metadata = req.metadata;
|
|
1896
|
+
if (req.sessionId !== void 0) {
|
|
1897
|
+
metadata = { ...req.metadata ?? {}, session_id: req.sessionId };
|
|
1898
|
+
}
|
|
1814
1899
|
const body = {
|
|
1815
1900
|
tenant_id: req.tenantId,
|
|
1816
1901
|
user_id: req.userId,
|
|
1817
|
-
|
|
1902
|
+
source: req.source ?? "chat",
|
|
1903
|
+
text: req.text
|
|
1818
1904
|
};
|
|
1819
|
-
if (req.
|
|
1820
|
-
if (req.
|
|
1905
|
+
if (req.speaker !== void 0) body.speaker = req.speaker;
|
|
1906
|
+
if (req.occurredAt !== void 0) body.occurred_at = req.occurredAt;
|
|
1907
|
+
if (metadata !== void 0) body.metadata = metadata;
|
|
1908
|
+
if (req.syncEmbed) body.sync_embed = true;
|
|
1821
1909
|
return await this.request("POST", "/v1/memory/add_turn", { body }) ?? {};
|
|
1822
1910
|
}
|
|
1823
1911
|
/**
|