@mastra/libsql 1.27.0-alpha.2 → 1.27.0-alpha.3

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.27.0-alpha.2"
6
+ version: "1.27.0-alpha.3"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.27.0-alpha.2",
2
+ "version": "1.27.0-alpha.3",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -144,7 +144,8 @@ const stream = await agent.stream('Clean up old records', {
144
144
  },
145
145
  })
146
146
 
147
- return result.answers.requiresApproval.probability >= 0.7
147
+ // A refused question has no probability, so it falls back to requiring approval.
148
+ return (result.answers.requiresApproval.probability ?? 1) >= 0.7
148
149
  },
149
150
  })
150
151
  ```
@@ -147,6 +147,12 @@ Re-drives every orphaned `running` durable-agent run across all registered durab
147
147
 
148
148
  Requires persistent storage. With an in-memory store, there's nothing to recover after a process restart.
149
149
 
150
+ Agents and their runs are attempted serially. Each built-in `recoverActiveRuns()` attempt waits up to 30 seconds in total for `recover()` setup and settlement of the whole recovered workflow, then traversal can continue to later runs and agents. This isn't an overall recovery deadline: discovery and overridden custom recovery methods aren't bounded by this budget.
151
+
152
+ A timed-out attempt continues in the background. Its outcome is `status: 'skipped'` with `reason: 'recovery-timeout'` and no `retryAt`. It contributes only to `skipped`, not `recovered`, `succeeded`, or `failed`, and Mastra doesn't automatically retry it. Late settlement doesn't change the returned counts.
153
+
154
+ When shutdown begins, recovery stops dispatching new agents and runs. The recovery traversal and original attempts, including timed-out setup or execution, participate in the same shared shutdown drain as active executions. A recovery wait timeout doesn't cancel the attempt or give it a separate shutdown drain window.
155
+
150
156
  A run that another execution still drives isn't taken over. It's counted in `skipped` and checked again once that execution's claim could have lapsed, so a run whose process crashed is recovered without another call. `shutdown()` cancels pending re-checks. See [run ownership](https://mastra.ai/docs/harness/durable-agents).
151
157
 
152
158
  ```typescript
@@ -164,4 +170,4 @@ Returns:
164
170
 
165
171
  **failed** (`number`): Runs whose restart threw an error.
166
172
 
167
- **skipped** (`number`): Runs that another execution still drives. Each is checked again later.
173
+ **skipped** (`number`): Runs skipped because they are already active, recovery is already in progress, or the recovery wait timed out. Only ownership skips eligible for re-checks are checked again; recovery timeouts are not automatically retried.
package/dist/index.cjs CHANGED
@@ -14377,7 +14377,7 @@ var SkillsLibSQL = class extends _mastra_core_storage.SkillsStorage {
14377
14377
  }
14378
14378
  async list(args) {
14379
14379
  try {
14380
- const { page = 0, perPage: perPageInput, orderBy, authorId, visibility, status, entityIds, pinFavoritedFor, favoritedOnly } = args || {};
14380
+ const { page = 0, perPage: perPageInput, orderBy, authorId, visibility, status, entityIds, pinFavoritedFor, favoritedOnly, metadata } = args || {};
14381
14381
  const { field, direction } = this.parseOrderBy(orderBy);
14382
14382
  if (entityIds && entityIds.length === 0) return {
14383
14383
  skills: [],
@@ -14405,6 +14405,28 @@ var SkillsLibSQL = class extends _mastra_core_storage.SkillsStorage {
14405
14405
  conditions.push(`s_e.id IN (${placeholders})`);
14406
14406
  queryParams.push(...entityIds);
14407
14407
  }
14408
+ if (metadata && Object.keys(metadata).length > 0) {
14409
+ const latestVersionId = `(SELECT lv.id FROM "${_mastra_core_storage.TABLE_SKILL_VERSIONS}" lv WHERE lv."skillId" = s_e.id ORDER BY lv."versionNumber" DESC LIMIT 1)`;
14410
+ const resolvedVersionId = status === "draft" ? latestVersionId : `COALESCE(s_e."activeVersionId", ${latestVersionId})`;
14411
+ const metadataConditions = [];
14412
+ for (const [key, value] of Object.entries(metadata)) {
14413
+ if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(key)) throw new _mastra_core_error.MastraError({
14414
+ id: (0, _mastra_core_storage.createStorageErrorId)("LIBSQL", "LIST_SKILLS", "INVALID_METADATA_KEY"),
14415
+ domain: _mastra_core_error.ErrorDomain.STORAGE,
14416
+ category: _mastra_core_error.ErrorCategory.USER,
14417
+ text: `Invalid metadata key: ${key}. Keys must be alphanumeric with underscores.`,
14418
+ details: { key }
14419
+ });
14420
+ if (typeof value === "string") {
14421
+ metadataConditions.push(`json_extract(mv.metadata, '$.${key}') = ?`);
14422
+ queryParams.push(value);
14423
+ } else {
14424
+ metadataConditions.push(`json_extract(mv.metadata, '$.${key}') = json_extract(?, '$')`);
14425
+ queryParams.push(JSON.stringify(value));
14426
+ }
14427
+ }
14428
+ conditions.push(`EXISTS (SELECT 1 FROM "${_mastra_core_storage.TABLE_SKILL_VERSIONS}" mv WHERE mv."skillId" = s_e.id AND mv.id = ${resolvedVersionId} AND ${metadataConditions.join(" AND ")})`);
14429
+ }
14408
14430
  const joinUserId = pinFavoritedFor;
14409
14431
  const useJoin = Boolean(joinUserId);
14410
14432
  let joinClause = "";