@mastra/libsql 1.10.0 → 1.10.1-alpha.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.js CHANGED
@@ -2991,11 +2991,13 @@ function rowToTask(row) {
2991
2991
  runId: String(row.run_id),
2992
2992
  result: parseJson(row.result),
2993
2993
  error: parseJson(row.error),
2994
+ suspendPayload: parseJson(row.suspend_payload),
2994
2995
  retryCount: Number(row.retry_count),
2995
2996
  maxRetries: Number(row.max_retries),
2996
2997
  timeoutMs: Number(row.timeout_ms),
2997
2998
  createdAt: new Date(String(row.createdAt)),
2998
2999
  startedAt: row.startedAt ? new Date(String(row.startedAt)) : void 0,
3000
+ suspendedAt: row.suspendedAt ? new Date(String(row.suspendedAt)) : void 0,
2999
3001
  completedAt: row.completedAt ? new Date(String(row.completedAt)) : void 0
3000
3002
  };
3001
3003
  }
@@ -3013,6 +3015,11 @@ var BackgroundTasksLibSQL = class extends BackgroundTasksStorage {
3013
3015
  tableName: TABLE_BACKGROUND_TASKS,
3014
3016
  schema: TABLE_SCHEMAS[TABLE_BACKGROUND_TASKS]
3015
3017
  });
3018
+ await this.#db.alterTable({
3019
+ tableName: TABLE_BACKGROUND_TASKS,
3020
+ schema: TABLE_SCHEMAS[TABLE_BACKGROUND_TASKS],
3021
+ ifNotExists: ["suspend_payload", "suspendedAt"]
3022
+ });
3016
3023
  }
3017
3024
  async dangerouslyClearAll() {
3018
3025
  await this.#db.deleteData({ tableName: TABLE_BACKGROUND_TASKS });
@@ -3032,11 +3039,13 @@ var BackgroundTasksLibSQL = class extends BackgroundTasksStorage {
3032
3039
  args: task.args,
3033
3040
  result: task.result ?? null,
3034
3041
  error: task.error ?? null,
3042
+ suspend_payload: task.suspendPayload ?? null,
3035
3043
  retry_count: task.retryCount,
3036
3044
  max_retries: task.maxRetries,
3037
3045
  timeout_ms: task.timeoutMs,
3038
3046
  createdAt: task.createdAt.toISOString(),
3039
3047
  startedAt: task.startedAt?.toISOString() ?? null,
3048
+ suspendedAt: task.suspendedAt?.toISOString() ?? null,
3040
3049
  completedAt: task.completedAt?.toISOString() ?? null
3041
3050
  }
3042
3051
  });
@@ -3056,6 +3065,10 @@ var BackgroundTasksLibSQL = class extends BackgroundTasksStorage {
3056
3065
  setClauses.push("error = jsonb(?)");
3057
3066
  params.push(serializeJson(update.error));
3058
3067
  }
3068
+ if ("suspendPayload" in update) {
3069
+ setClauses.push("suspend_payload = jsonb(?)");
3070
+ params.push(serializeJson(update.suspendPayload));
3071
+ }
3059
3072
  if ("retryCount" in update) {
3060
3073
  setClauses.push("retry_count = ?");
3061
3074
  params.push(update.retryCount);
@@ -3064,6 +3077,10 @@ var BackgroundTasksLibSQL = class extends BackgroundTasksStorage {
3064
3077
  setClauses.push("startedAt = ?");
3065
3078
  params.push(update.startedAt?.toISOString() ?? null);
3066
3079
  }
3080
+ if ("suspendedAt" in update) {
3081
+ setClauses.push("suspendedAt = ?");
3082
+ params.push(update.suspendedAt?.toISOString() ?? null);
3083
+ }
3067
3084
  if ("completedAt" in update) {
3068
3085
  setClauses.push("completedAt = ?");
3069
3086
  params.push(update.completedAt?.toISOString() ?? null);
@@ -3111,7 +3128,11 @@ var BackgroundTasksLibSQL = class extends BackgroundTasksStorage {
3111
3128
  conditions.push("tool_name = ?");
3112
3129
  params.push(filter.toolName);
3113
3130
  }
3114
- const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
3131
+ if (filter.toolCallId) {
3132
+ conditions.push("tool_call_id = ?");
3133
+ params.push(filter.toolCallId);
3134
+ }
3135
+ const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
3115
3136
  if (filter.fromDate) {
3116
3137
  conditions.push(`${dateCol} >= ?`);
3117
3138
  params.push(filter.fromDate.toISOString());
@@ -3126,7 +3147,7 @@ var BackgroundTasksLibSQL = class extends BackgroundTasksStorage {
3126
3147
  args: [...params]
3127
3148
  });
3128
3149
  const total = Number(countResult.rows[0]?.count ?? 0);
3129
- const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
3150
+ const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "suspendedAt" ? "suspendedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
3130
3151
  const direction = filter.orderDirection === "desc" ? "DESC" : "ASC";
3131
3152
  let sql = `SELECT ${buildSelectColumns(TABLE_BACKGROUND_TASKS)} FROM ${TABLE_BACKGROUND_TASKS} ${where} ORDER BY ${orderCol} ${direction}`;
3132
3153
  if (filter.perPage != null) {
@@ -3154,7 +3175,7 @@ var BackgroundTasksLibSQL = class extends BackgroundTasksStorage {
3154
3175
  conditions.push(`status IN (${statuses.map(() => "?").join(", ")})`);
3155
3176
  params.push(...statuses);
3156
3177
  }
3157
- const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
3178
+ const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
3158
3179
  if (filter.fromDate) {
3159
3180
  conditions.push(`${dateCol} >= ?`);
3160
3181
  params.push(filter.fromDate.toISOString());