@mastra/libsql 1.23.4-alpha.0 → 1.24.0-alpha.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.
@@ -3,7 +3,7 @@ name: mastra-libsql
3
3
  description: Documentation for @mastra/libsql. Use when working with @mastra/libsql APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/libsql"
6
- version: "1.23.4-alpha.0"
6
+ version: "1.24.0-alpha.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.23.4-alpha.0",
2
+ "version": "1.24.0-alpha.2",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -120,12 +120,14 @@ The function can be asynchronous. For decisions that depend on the tool name and
120
120
 
121
121
  ```typescript
122
122
  import { Classifier } from '@mastra/core/classifier'
123
- import { model } from '../models/evaluation-model'
123
+ import { createTypeSafeAi } from '@ai-sdk/typesafe-ai'
124
124
  import { agent } from './agent'
125
125
 
126
126
  const approvalClassifier = new Classifier({
127
127
  id: 'tool-approval-classifier',
128
- model,
128
+ model: createTypeSafeAi({ apiKey: process.env.TYPESAFE_AI_API_KEY }).evaluationModel(
129
+ 'jev-latest',
130
+ ),
129
131
  questions: {
130
132
  requiresApproval: {
131
133
  type: 'boolean',
package/dist/index.cjs CHANGED
@@ -424,9 +424,14 @@ function handleLogicalOperator(key, value, parentPath) {
424
424
  }
425
425
  const values = [];
426
426
  const joinOperator = key === "$or" || key === "$nor" ? "OR" : "AND";
427
- const joined = (Array.isArray(value) ? value.map((f) => {
428
- return (!!f ? Object.entries(f) : []).map(([k, v]) => buildCondition$1(k, v, key));
429
- }) : [buildCondition$1(key, value, parentPath)]).flat().map((c) => {
427
+ const joined = (Array.isArray(value) ? value.flatMap((f) => {
428
+ const branch = (!!f ? Object.entries(f) : []).map(([k, v]) => buildCondition$1(k, v, key));
429
+ if (branch.length <= 1) return branch;
430
+ return [{
431
+ sql: `(${branch.map((c) => c.sql).join(" AND ")})`,
432
+ values: branch.flatMap((c) => c.values)
433
+ }];
434
+ }) : [buildCondition$1(key, value, parentPath)]).map((c) => {
430
435
  values.push(...c.values);
431
436
  return c.sql;
432
437
  }).join(` ${joinOperator} `);
@@ -2954,7 +2959,9 @@ function rowToTask(row) {
2954
2959
  createdAt: new Date(String(row.createdAt)),
2955
2960
  startedAt: row.startedAt ? new Date(String(row.startedAt)) : void 0,
2956
2961
  suspendedAt: row.suspendedAt ? new Date(String(row.suspendedAt)) : void 0,
2957
- completedAt: row.completedAt ? new Date(String(row.completedAt)) : void 0
2962
+ completedAt: row.completedAt ? new Date(String(row.completedAt)) : void 0,
2963
+ ownerId: row.ownerId != null ? String(row.ownerId) : void 0,
2964
+ leaseExpiresAt: row.leaseExpiresAt ? new Date(String(row.leaseExpiresAt)) : void 0
2958
2965
  };
2959
2966
  }
2960
2967
  var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_storage.BackgroundTasksStorage {
@@ -2988,7 +2995,12 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
2988
2995
  await this.#db.alterTable({
2989
2996
  tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
2990
2997
  schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS],
2991
- ifNotExists: ["suspend_payload", "suspendedAt"]
2998
+ ifNotExists: [
2999
+ "suspend_payload",
3000
+ "suspendedAt",
3001
+ "ownerId",
3002
+ "leaseExpiresAt"
3003
+ ]
2992
3004
  });
2993
3005
  }
2994
3006
  async dangerouslyClearAll() {
@@ -3031,7 +3043,9 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
3031
3043
  createdAt: task.createdAt.toISOString(),
3032
3044
  startedAt: task.startedAt?.toISOString() ?? null,
3033
3045
  suspendedAt: task.suspendedAt?.toISOString() ?? null,
3034
- completedAt: task.completedAt?.toISOString() ?? null
3046
+ completedAt: task.completedAt?.toISOString() ?? null,
3047
+ ownerId: task.ownerId ?? null,
3048
+ leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
3035
3049
  }
3036
3050
  });
3037
3051
  }
@@ -3070,6 +3084,14 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
3070
3084
  setClauses.push("completedAt = ?");
3071
3085
  params.push(update.completedAt?.toISOString() ?? null);
3072
3086
  }
3087
+ if ("ownerId" in update) {
3088
+ setClauses.push("ownerId = ?");
3089
+ params.push(update.ownerId ?? null);
3090
+ }
3091
+ if ("leaseExpiresAt" in update) {
3092
+ setClauses.push("leaseExpiresAt = ?");
3093
+ params.push(update.leaseExpiresAt?.toISOString() ?? null);
3094
+ }
3073
3095
  if (setClauses.length === 0) return false;
3074
3096
  params.push(taskId);
3075
3097
  let where = "id = ?";
@@ -3077,6 +3099,16 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
3077
3099
  where += " AND status = ?";
3078
3100
  params.push(options.expectedStatus);
3079
3101
  }
3102
+ if (options?.expectedOwnerId !== void 0) if (options.expectedOwnerId === null) where += " AND ownerId IS NULL";
3103
+ else {
3104
+ where += " AND ownerId = ?";
3105
+ params.push(options.expectedOwnerId);
3106
+ }
3107
+ if (options?.expectedLeaseExpiresAt !== void 0) if (options.expectedLeaseExpiresAt === null) where += " AND leaseExpiresAt IS NULL";
3108
+ else {
3109
+ where += " AND leaseExpiresAt = ?";
3110
+ params.push(options.expectedLeaseExpiresAt.toISOString());
3111
+ }
3080
3112
  return (await this.#client.execute({
3081
3113
  sql: `UPDATE ${_mastra_core_storage.TABLE_BACKGROUND_TASKS} SET ${setClauses.join(", ")} WHERE ${where}`,
3082
3114
  args: params