memorysync-sdk 1.9.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.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.9.0";
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.9.0";
1107
+ var SDK_VERSION2 = "1.9.1";
1108
1108
  function camelToSnakeKey(key) {
1109
1109
  return key.replace(/([A-Z])/g, "_$1").toLowerCase();
1110
1110
  }
@@ -1822,15 +1822,46 @@ var MemorySyncClient = class {
1822
1822
  return await this.request("GET", "/memory/knowledge/stats") ?? {};
1823
1823
  }
1824
1824
  // ── v1 data plane ──────────────────────────────────────────────────
1825
- /** Add a conversation turn and extract memories from it. */
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
+ */
1826
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
+ }
1827
1855
  const body = {
1828
1856
  tenant_id: req.tenantId,
1829
1857
  user_id: req.userId,
1830
- messages: req.messages
1858
+ source: req.source ?? "chat",
1859
+ text: req.text
1831
1860
  };
1832
- if (req.sessionId !== void 0) body.session_id = req.sessionId;
1833
- if (req.metadata !== void 0) body.metadata = req.metadata;
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;
1834
1865
  return await this.request("POST", "/v1/memory/add_turn", { body }) ?? {};
1835
1866
  }
1836
1867
  /**