@deepagents/text2sql 0.10.1 → 0.10.2

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 CHANGED
@@ -1610,7 +1610,11 @@ var SqliteHistory = class extends History {
1610
1610
  async addMessage(message) {
1611
1611
  const createdAt = message.createdAt ? message.createdAt.toISOString() : (/* @__PURE__ */ new Date()).toISOString();
1612
1612
  this.#db.prepare(
1613
- `INSERT INTO messages (id, "chatId", role, "createdAt", content) VALUES (?, ?, ?, ?, ?)`
1613
+ `INSERT INTO messages (id, "chatId", role, "createdAt", content) VALUES (?, ?, ?, ?, ?)
1614
+ ON CONFLICT(id) DO UPDATE SET
1615
+ "chatId" = excluded."chatId",
1616
+ role = excluded.role,
1617
+ content = excluded.content`
1614
1618
  ).run(
1615
1619
  message.id,
1616
1620
  message.chatId,
@@ -1735,7 +1739,6 @@ import {
1735
1739
  ToolCallRepairError,
1736
1740
  generateId
1737
1741
  } from "ai";
1738
- import { v7 as v72 } from "uuid";
1739
1742
  import {
1740
1743
  generate as generate5,
1741
1744
  stream,
@@ -3039,15 +3042,15 @@ var Text2Sql = class {
3039
3042
  "Saving user message to history:",
3040
3043
  JSON.stringify(userMessage)
3041
3044
  );
3042
- await this.#config.history.addMessage({
3043
- id: v72(),
3045
+ await this.#config.history.upsertMessage({
3046
+ id: userMessage.id,
3044
3047
  chatId: params.chatId,
3045
3048
  role: userMessage.role,
3046
3049
  content: userMessage
3047
3050
  });
3048
3051
  }
3049
- await this.#config.history.addMessage({
3050
- id: v72(),
3052
+ await this.#config.history.upsertMessage({
3053
+ id: responseMessage.id,
3051
3054
  chatId: params.chatId,
3052
3055
  role: responseMessage.role,
3053
3056
  content: responseMessage
@@ -3095,15 +3098,15 @@ async function withChat(history, params, messages, streamFn) {
3095
3098
  "Saving user message to history:",
3096
3099
  JSON.stringify(userMessage)
3097
3100
  );
3098
- await history.addMessage({
3099
- id: v72(),
3101
+ await history.upsertMessage({
3102
+ id: userMessage.id,
3100
3103
  chatId: params.chatId,
3101
3104
  role: userMessage.role,
3102
3105
  content: userMessage
3103
3106
  });
3104
3107
  }
3105
- await history.addMessage({
3106
- id: v72(),
3108
+ await history.upsertMessage({
3109
+ id: responseMessage.id,
3107
3110
  chatId: params.chatId,
3108
3111
  role: responseMessage.role,
3109
3112
  content: responseMessage