@mastra/libsql 0.0.0-knowledge-w1-20261007232522 → 0.0.0-knowledge-w1-20261008204450

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.
@@ -33,6 +33,49 @@ declare function parseListKnowledgeScopeNodesInput(input?: ListKnowledgeScopeNod
33
33
  };
34
34
  /** Builds a page from up to `limit + 1` name/id-ordered scope nodes. */
35
35
  declare function pageKnowledgeScopeNodes(rows: KnowledgeScopeNodeSummary[], limit: number, input: ListKnowledgeScopeNodesInput): ListKnowledgeScopeNodesOutput;
36
+ /** A node placed inside a structural scope. Child scopes are members too, with `scope: null`. */
37
+ interface KnowledgeScopeMember {
38
+ id: string;
39
+ type: 'node';
40
+ name: string;
41
+ kind: string;
42
+ content?: string;
43
+ description?: string;
44
+ scope: string[] | null;
45
+ version: number;
46
+ mergedInto?: string;
47
+ createdAt: Date;
48
+ updatedAt: Date;
49
+ }
50
+ interface ListKnowledgeScopeMembersInput {
51
+ scopeNodeId: string;
52
+ /** `nextCursor` from the previous page for the same scope. */
53
+ cursor?: string;
54
+ /** Members to return, 1–500 (default 500). */
55
+ limit?: number;
56
+ }
57
+ interface ListKnowledgeScopeMembersOutput {
58
+ /** Most recently updated members first (ties by name, then ID), at most `limit`. */
59
+ members: KnowledgeScopeMember[];
60
+ /** True when the scope has more members than were returned. */
61
+ hasMore: boolean;
62
+ /** Pass as `cursor` to read the next page; `null` on the last page. */
63
+ nextCursor: string | null;
64
+ }
65
+ declare const MAX_KNOWLEDGE_SCOPE_MEMBERS_LIMIT = 500;
66
+ /** Clamps a requested member limit to 1–{@link MAX_KNOWLEDGE_SCOPE_MEMBERS_LIMIT}. */
67
+ declare function knowledgeScopeMembersLimit(limit: number | undefined): number;
68
+ /** Validates the page size and cursor of a `listScopeMembers` query; throws on a cursor from another scope. */
69
+ declare function parseListKnowledgeScopeMembersInput(input: ListKnowledgeScopeMembersInput): {
70
+ limit: number;
71
+ after: {
72
+ updatedAt: Date;
73
+ name: string;
74
+ id: string;
75
+ } | null;
76
+ };
77
+ /** Builds a page from up to `limit + 1` members in `listScopeMembers` order. */
78
+ declare function pageKnowledgeScopeMembers(rows: KnowledgeScopeMember[], limit: number, input: ListKnowledgeScopeMembersInput): ListKnowledgeScopeMembersOutput;
36
79
  /** A reconciled structural scope node with its containing scope nodes. */
37
80
  interface KnowledgeScopeNodeSummary {
38
81
  /** UUID of the `isScope` node. */
@@ -189,10 +232,6 @@ declare const KNOWLEDGE_V2_RECORDS_SCHEMA: {
189
232
  readonly type: 'timestamp';
190
233
  readonly nullable: true;
191
234
  };
192
- readonly maxScope: {
193
- readonly type: 'text';
194
- readonly nullable: true;
195
- };
196
235
  };
197
236
  declare const KNOWLEDGE_V2_MENTIONS_SCHEMA: {
198
237
  readonly recordId: {
@@ -550,5 +589,5 @@ interface KnowledgeV2Core {
550
589
  declare function assertKnowledgeV2CoreSupport(features: ReadonlySet<string>): void;
551
590
  declare function createKnowledgeV2CoreLoader(features: ReadonlySet<string>, loadStorageModule: () => Promise<unknown>): () => Promise<KnowledgeV2Core>;
552
591
  //#endregion
553
- export { KNOWLEDGE_ACCESS_STATE_SCHEMA, KNOWLEDGE_IMPORT_RUNS_SCHEMA, KNOWLEDGE_IMPORT_STATE_SCHEMA, KNOWLEDGE_NODE_ADDRESSES_SCHEMA, KNOWLEDGE_NODE_SCOPES_SCHEMA, KNOWLEDGE_PROPOSALS_SCHEMA, KNOWLEDGE_RECORD_SCOPES_SCHEMA, KNOWLEDGE_SCOPE_ADDRESSES_SCHEMA, KNOWLEDGE_SCOPE_GRANTS_SCHEMA, KNOWLEDGE_STORAGE_CONTRACT_VERSION, KNOWLEDGE_STORAGE_SCHEMA_VERSION, KNOWLEDGE_TABLE_NAMES, KNOWLEDGE_V2_ACTIVITY_SCHEMA, KNOWLEDGE_V2_CORE_FEATURE, KNOWLEDGE_V2_MENTIONS_SCHEMA, KNOWLEDGE_V2_NODES_SCHEMA, KNOWLEDGE_V2_RECORDS_SCHEMA, KnowledgeSchemaInspection, KnowledgeSchemaSnapshot, KnowledgeScopeNodeSummary, ListKnowledgeScopeNodesInput, ListKnowledgeScopeNodesOutput, MAX_KNOWLEDGE_SCOPE_NODES, PUBLISHED_KNOWLEDGE_V1_INDEX_NAMES, PUBLISHED_KNOWLEDGE_V1_TABLE_NAMES, RETIRED_KNOWLEDGE_TABLE_NAMES, TABLE_KNOWLEDGE_ACCESS_STATE, TABLE_KNOWLEDGE_IMPORT_RUNS, TABLE_KNOWLEDGE_IMPORT_STATE, TABLE_KNOWLEDGE_NODE_ADDRESSES, TABLE_KNOWLEDGE_NODE_SCOPES, TABLE_KNOWLEDGE_PROPOSALS, TABLE_KNOWLEDGE_RECORD_SCOPES, TABLE_KNOWLEDGE_SCOPE_ADDRESSES, TABLE_KNOWLEDGE_SCOPE_GRANTS, assertKnowledgeV2CoreSupport, createKnowledgeScopeNodeCursor, createKnowledgeV2CoreLoader, pageKnowledgeScopeNodes, parseListKnowledgeScopeNodesInput };
592
+ export { KNOWLEDGE_ACCESS_STATE_SCHEMA, KNOWLEDGE_IMPORT_RUNS_SCHEMA, KNOWLEDGE_IMPORT_STATE_SCHEMA, KNOWLEDGE_NODE_ADDRESSES_SCHEMA, KNOWLEDGE_NODE_SCOPES_SCHEMA, KNOWLEDGE_PROPOSALS_SCHEMA, KNOWLEDGE_RECORD_SCOPES_SCHEMA, KNOWLEDGE_SCOPE_ADDRESSES_SCHEMA, KNOWLEDGE_SCOPE_GRANTS_SCHEMA, KNOWLEDGE_STORAGE_CONTRACT_VERSION, KNOWLEDGE_STORAGE_SCHEMA_VERSION, KNOWLEDGE_TABLE_NAMES, KNOWLEDGE_V2_ACTIVITY_SCHEMA, KNOWLEDGE_V2_CORE_FEATURE, KNOWLEDGE_V2_MENTIONS_SCHEMA, KNOWLEDGE_V2_NODES_SCHEMA, KNOWLEDGE_V2_RECORDS_SCHEMA, KnowledgeSchemaInspection, KnowledgeSchemaSnapshot, KnowledgeScopeMember, KnowledgeScopeNodeSummary, ListKnowledgeScopeMembersInput, ListKnowledgeScopeMembersOutput, ListKnowledgeScopeNodesInput, ListKnowledgeScopeNodesOutput, MAX_KNOWLEDGE_SCOPE_MEMBERS_LIMIT, MAX_KNOWLEDGE_SCOPE_NODES, PUBLISHED_KNOWLEDGE_V1_INDEX_NAMES, PUBLISHED_KNOWLEDGE_V1_TABLE_NAMES, RETIRED_KNOWLEDGE_TABLE_NAMES, TABLE_KNOWLEDGE_ACCESS_STATE, TABLE_KNOWLEDGE_IMPORT_RUNS, TABLE_KNOWLEDGE_IMPORT_STATE, TABLE_KNOWLEDGE_NODE_ADDRESSES, TABLE_KNOWLEDGE_NODE_SCOPES, TABLE_KNOWLEDGE_PROPOSALS, TABLE_KNOWLEDGE_RECORD_SCOPES, TABLE_KNOWLEDGE_SCOPE_ADDRESSES, TABLE_KNOWLEDGE_SCOPE_GRANTS, assertKnowledgeV2CoreSupport, createKnowledgeScopeNodeCursor, createKnowledgeV2CoreLoader, knowledgeScopeMembersLimit, pageKnowledgeScopeMembers, pageKnowledgeScopeNodes, parseListKnowledgeScopeMembersInput, parseListKnowledgeScopeNodesInput };
554
593
  //# sourceMappingURL=index.d.ts.map
@@ -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: "0.0.0-knowledge-w1-20261007232522"
6
+ version: "0.0.0-knowledge-w1-20261008204450"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.0-knowledge-w1-20261007232522",
2
+ "version": "0.0.0-knowledge-w1-20261008204450",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -125,7 +125,7 @@ import { agent } from './agent'
125
125
 
126
126
  const approvalClassifier = new Classifier({
127
127
  id: 'tool-approval-classifier',
128
- model: typeSafeAi.evaluationModel('jev-latest'),
128
+ model: typeSafeAi.decisionModel('jev-latest'),
129
129
  questions: {
130
130
  requiresApproval: {
131
131
  type: 'boolean',
@@ -137,7 +137,7 @@ const approvalClassifier = new Classifier({
137
137
 
138
138
  const stream = await agent.stream('Clean up old records', {
139
139
  requireToolApproval: async ({ toolName, args }) => {
140
- const result = await approvalClassifier.evaluate({
140
+ const result = await approvalClassifier.decide({
141
141
  state: {
142
142
  toolName,
143
143
  argumentNames: Object.keys(args),
@@ -149,7 +149,7 @@ const stream = await agent.stream('Clean up old records', {
149
149
  })
150
150
  ```
151
151
 
152
- The example sends argument names rather than values because the classifier forwards its state to the configured evaluation model. If the decision requires argument values, redact sensitive data first or use an evaluation model and provider that meet the protected tool's data-handling requirements.
152
+ The example sends argument names rather than values because the classifier forwards its state to the configured decision model. If the decision requires argument values, redact sensitive data first or use a decision model and provider that meet the protected tool's data-handling requirements.
153
153
 
154
154
  Returning `true` pauses the tool call for human approval. It doesn't approve or decline the call automatically. Choose a threshold that matches the risk of the tools available to the agent. If this `requireToolApproval` function throws, it defaults to requiring approval.
155
155
 
@@ -260,6 +260,8 @@ const weatherTool = createTool({
260
260
 
261
261
  > **Note:** `suspend()` doesn't throw, return immediately after calling it (e.g. `return await suspend({ ... })`). Code after `await suspend(...)` still runs before the tool pauses.
262
262
 
263
+ Use `suspend()` instead of a tool without `execute` when the tool needs a structured answer from the user and also runs inside a subagent: subagents can't run client tools, but suspension propagates through the supervisor. To resume from AI SDK `useChat()`, see [resuming a suspended tool from `useChat()`](https://mastra.ai/integrations/agentic-ui/ai-sdk-ui).
264
+
263
265
  ## Tool approval with `generate()`
264
266
 
265
267
  Tool approval also works with `generate()` for non-streaming use cases. When a tool requires approval, `generate()` returns immediately with `finishReason: 'suspended'`, a `suspendPayload` containing the tool call details (`toolCallId`, `toolName`, `args`), and a `runId`:
@@ -99,7 +99,7 @@ import { Agent } from '@mastra/core/agent'
99
99
  import { Memory } from '@mastra/memory'
100
100
  import { LibSQLStore } from '@mastra/libsql'
101
101
  import { PineconeVector } from '@mastra/pinecone'
102
- import { OpenAIEmbedder } from '@mastra/openai'
102
+ import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
103
103
  import { openai } from '@ai-sdk/openai'
104
104
 
105
105
  const agent = new Agent({
@@ -115,10 +115,7 @@ const agent = new Agent({
115
115
  id: 'memory-vector',
116
116
  apiKey: process.env.PINECONE_API_KEY!,
117
117
  }),
118
- embedder: new OpenAIEmbedder({
119
- model: 'text-embedding-3-small',
120
- apiKey: process.env.OPENAI_API_KEY!,
121
- }),
118
+ embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
122
119
  semanticRecall: { enabled: true }, // SemanticRecall processor automatically added
123
120
  }),
124
121
  })
@@ -411,11 +411,11 @@ PostgreSQL supports both IVFFlat and HNSW indexes. By default, Mastra creates an
411
411
 
412
412
  ```typescript
413
413
  import { Memory } from '@mastra/memory'
414
- import { PgStore, PgVector } from '@mastra/pg'
414
+ import { PostgresStore, PgVector } from '@mastra/pg'
415
415
 
416
416
  const agent = new Agent({
417
417
  memory: new Memory({
418
- storage: new PgStore({
418
+ storage: new PostgresStore({
419
419
  id: 'agent-storage',
420
420
  connectionString: process.env.DATABASE_URL,
421
421
  }),
@@ -101,14 +101,14 @@ export const agent = new Agent({
101
101
  import { Memory } from '@mastra/memory'
102
102
  import { Agent } from '@mastra/core/agent'
103
103
  import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
104
- import { PgStore, PgVector } from '@mastra/pg'
104
+ import { PostgresStore, PgVector } from '@mastra/pg'
105
105
 
106
106
  export const agent = new Agent({
107
107
  name: 'pg-agent',
108
108
  instructions: 'You are an agent with optimized PostgreSQL memory.',
109
109
  model: 'openai/gpt-5.6-sol',
110
110
  memory: new Memory({
111
- storage: new PgStore({
111
+ storage: new PostgresStore({
112
112
  id: 'pg-agent-storage',
113
113
  connectionString: process.env.DATABASE_URL,
114
114
  }),
@@ -50,23 +50,25 @@ console.log(results)
50
50
 
51
51
  The `topK` parameter specifies the maximum number of most similar results to return from the vector search.
52
52
 
53
- Results include both the text content and a similarity score:
53
+ Each result includes an `id`, a similarity `score`, and the stored `metadata`. When you store chunk text in metadata, it's available as `metadata.text`:
54
54
 
55
55
  ```ts
56
56
  [
57
57
  {
58
- text: 'Climate change poses significant challenges...',
58
+ id: 'chunk-1',
59
59
  score: 0.89,
60
- metadata: { source: 'article1.txt' },
60
+ metadata: { text: 'Climate change poses significant challenges...', source: 'article1.txt' },
61
61
  },
62
62
  {
63
- text: 'Rising temperatures affect crop yields...',
63
+ id: 'chunk-2',
64
64
  score: 0.82,
65
- metadata: { source: 'article1.txt' },
65
+ metadata: { text: 'Rising temperatures affect crop yields...', source: 'article1.txt' },
66
66
  },
67
67
  ]
68
68
  ```
69
69
 
70
+ Results can also include `vector` when you set `includeVector: true`, and `document` when the store returns the original document (Chroma only).
71
+
70
72
  ## Advanced retrieval options
71
73
 
72
74
  ### Metadata Filtering
package/dist/index.cjs CHANGED
@@ -6072,7 +6072,8 @@ function createKnowledgeScopeNodeCursor(scope, input) {
6072
6072
  }
6073
6073
  /** Validates the page size and cursor of a `listScopeNodes` query; throws on a cursor from a different query. */
6074
6074
  function parseListKnowledgeScopeNodesInput(input = {}) {
6075
- const limit = Math.min(Math.max(Math.trunc(input.limit ?? 1e3), 1), MAX_KNOWLEDGE_SCOPE_NODES);
6075
+ const requested = Number.isFinite(input.limit) ? Math.trunc(input.limit) : MAX_KNOWLEDGE_SCOPE_NODES;
6076
+ const limit = Math.min(Math.max(requested, 1), MAX_KNOWLEDGE_SCOPE_NODES);
6076
6077
  if (!input.cursor) return {
6077
6078
  limit,
6078
6079
  after: null
@@ -6102,6 +6103,54 @@ function pageKnowledgeScopeNodes(rows, limit, input) {
6102
6103
  nextCursor: rows.length > limit && last ? createKnowledgeScopeNodeCursor(last, input) : null
6103
6104
  };
6104
6105
  }
6106
+ /** Clamps a requested member limit to 1–{@link MAX_KNOWLEDGE_SCOPE_MEMBERS_LIMIT}. */
6107
+ function knowledgeScopeMembersLimit(limit) {
6108
+ if (limit === void 0 || !Number.isFinite(limit)) return 500;
6109
+ return Math.min(Math.max(Math.trunc(limit), 1), 500);
6110
+ }
6111
+ /** Validates the page size and cursor of a `listScopeMembers` query; throws on a cursor from another scope. */
6112
+ function parseListKnowledgeScopeMembersInput(input) {
6113
+ const limit = knowledgeScopeMembersLimit(input.limit);
6114
+ if (!input.cursor) return {
6115
+ limit,
6116
+ after: null
6117
+ };
6118
+ let value;
6119
+ try {
6120
+ value = JSON.parse(decodeURIComponent(input.cursor));
6121
+ } catch {
6122
+ throw new Error("Invalid Knowledge scope member cursor.");
6123
+ }
6124
+ const parsed = value && typeof value === "object" ? value : {};
6125
+ const updatedAt = typeof parsed.updatedAt === "string" ? new Date(parsed.updatedAt) : /* @__PURE__ */ new Date(NaN);
6126
+ if (parsed.version !== 1 || parsed.type !== "scope-member" || parsed.scopeNodeId !== input.scopeNodeId || typeof parsed.name !== "string" || typeof parsed.id !== "string" || Number.isNaN(updatedAt.getTime())) throw new Error("Knowledge scope member cursor does not match this query.");
6127
+ return {
6128
+ limit,
6129
+ after: {
6130
+ updatedAt,
6131
+ name: parsed.name,
6132
+ id: parsed.id
6133
+ }
6134
+ };
6135
+ }
6136
+ /** Builds a page from up to `limit + 1` members in `listScopeMembers` order. */
6137
+ function pageKnowledgeScopeMembers(rows, limit, input) {
6138
+ const members = rows.slice(0, limit);
6139
+ const last = members.at(-1);
6140
+ const hasMore = rows.length > limit;
6141
+ return {
6142
+ members,
6143
+ hasMore,
6144
+ nextCursor: hasMore && last ? encodeURIComponent(JSON.stringify({
6145
+ version: 1,
6146
+ type: "scope-member",
6147
+ scopeNodeId: input.scopeNodeId,
6148
+ updatedAt: last.updatedAt.toISOString(),
6149
+ name: last.name,
6150
+ id: last.id
6151
+ })) : null
6152
+ };
6153
+ }
6105
6154
  const TABLE_KNOWLEDGE_NODES$1 = "mastra_knowledge_nodes";
6106
6155
  const TABLE_KNOWLEDGE_RECORDS$1 = "mastra_knowledge_records";
6107
6156
  const TABLE_KNOWLEDGE_MENTIONS$1 = "mastra_knowledge_mentions";
@@ -6281,10 +6330,6 @@ const KNOWLEDGE_V2_RECORDS_SCHEMA = {
6281
6330
  when: {
6282
6331
  type: "timestamp",
6283
6332
  nullable: true
6284
- },
6285
- maxScope: {
6286
- type: "text",
6287
- nullable: true
6288
6333
  }
6289
6334
  };
6290
6335
  const KNOWLEDGE_V2_MENTIONS_SCHEMA = {
@@ -6657,7 +6702,21 @@ function withReconcileLock(key, operation) {
6657
6702
  });
6658
6703
  return result;
6659
6704
  }
6660
- const visibleSql = (scopeColumn = "scope") => `NOT EXISTS (SELECT 1 FROM json_each(${scopeColumn}) stored WHERE NOT EXISTS (SELECT 1 FROM json_each(?) available WHERE available.value = stored.value)) AND ? IS NOT NULL`;
6705
+ /**
6706
+ * Scope keys visible to a caller holding `scope`: a row is visible when its scope is a subset of the
6707
+ * caller's (companion entries such as `resource:x:uncurated` make this more than a prefix match).
6708
+ * Matching rows by `scopeKey` keeps visibility filters on an index; a caller scope has only a few
6709
+ * entries, so the list stays small.
6710
+ */
6711
+ function visibleScopeKeys(scope) {
6712
+ const canonical = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(scope);
6713
+ const keys = /* @__PURE__ */ new Set();
6714
+ for (let mask = 1; mask < 1 << canonical.length; mask++) try {
6715
+ keys.add((0, _mastra_core_storage.knowledgeScopeKey)(canonical.filter((_, index) => mask & 1 << index)));
6716
+ } catch {}
6717
+ return [...keys];
6718
+ }
6719
+ const visibleSql = (keys, scopeKeyColumn = "scopeKey") => `${scopeKeyColumn} IN (${keys.map(() => "?").join(",")})`;
6661
6720
  function parseJson$3(value) {
6662
6721
  if (typeof value === "string") return JSON.parse(value);
6663
6722
  if (value instanceof Uint8Array) return JSON.parse(new TextDecoder().decode(value));
@@ -6704,7 +6763,6 @@ function parseKnowledge(row) {
6704
6763
  sourceThreadId: String(row.sourceThreadId),
6705
6764
  capturedAt: toDate(row.capturedAt),
6706
6765
  when: optionalDate(row.when),
6707
- maxScope: row.maxScope == null ? void 0 : String(row.maxScope),
6708
6766
  metadata: (row.metadataJson ?? row.metadata) == null ? void 0 : parseJson$3(row.metadataJson ?? row.metadata),
6709
6767
  deletedAt: optionalDate(row.deletedAt),
6710
6768
  deletedBy: row.deletedBy == null ? void 0 : String(row.deletedBy)
@@ -6745,7 +6803,7 @@ const knowledgeV2TableSchemas = /* @__PURE__ */ new Map([
6745
6803
  [TABLE_KNOWLEDGE_PROPOSALS, KNOWLEDGE_PROPOSALS_SCHEMA]
6746
6804
  ]);
6747
6805
  function canonicalizeLibSQLUrl(url) {
6748
- if (url.includes(":memory:")) return void 0;
6806
+ if (url.includes(":memory:")) return /[?&]cache=shared(?:&|$)/.test(url) ? "file::memory:?cache=shared" : void 0;
6749
6807
  if (url.startsWith("file:")) {
6750
6808
  const [path$1] = url.slice(5).split("?");
6751
6809
  if (url.startsWith("file://")) {
@@ -6765,10 +6823,11 @@ function canonicalizeLibSQLUrl(url) {
6765
6823
  }
6766
6824
  }
6767
6825
  const unidentifiedClientIsolationKey = {};
6768
- function getLibSQLKnowledgeIsolationKey(config, _client) {
6826
+ function getLibSQLKnowledgeIsolationKey(config, client) {
6769
6827
  if (config.storageIsolationKey !== void 0) return config.storageIsolationKey;
6770
- const urlKey = config.url ? canonicalizeLibSQLUrl(config.url) : void 0;
6771
- return urlKey ? `libsql:${urlKey}` : unidentifiedClientIsolationKey;
6828
+ if (!config.url) return unidentifiedClientIsolationKey;
6829
+ const urlKey = canonicalizeLibSQLUrl(config.url);
6830
+ return urlKey ? `libsql:${urlKey}` : client ?? config.client ?? config;
6772
6831
  }
6773
6832
  var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
6774
6833
  #client;
@@ -6927,10 +6986,13 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
6927
6986
  for (const statement of [
6928
6987
  `CREATE UNIQUE INDEX IF NOT EXISTS idx_knowledge_nodes_identity ON "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" (type, scopeKey, canonicalName)`,
6929
6988
  `CREATE INDEX IF NOT EXISTS idx_knowledge_nodes_scope ON "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" (scopeKey, type)`,
6989
+ `CREATE INDEX IF NOT EXISTS idx_knowledge_nodes_name ON "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" (type, canonicalName)`,
6930
6990
  `CREATE INDEX IF NOT EXISTS idx_knowledge_records_node_latest ON "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" (node, id DESC)`,
6931
6991
  `CREATE INDEX IF NOT EXISTS idx_knowledge_records_thread_latest ON "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" (sourceThreadId, id DESC)`,
6932
6992
  `CREATE INDEX IF NOT EXISTS idx_knowledge_mentions_record ON "${_mastra_core_storage.TABLE_KNOWLEDGE_MENTIONS}" (recordId, sourceType, sourceId)`,
6933
6993
  `CREATE INDEX IF NOT EXISTS idx_knowledge_activity_latest ON "${_mastra_core_storage.TABLE_KNOWLEDGE_ACTIVITY}" (id DESC)`,
6994
+ `CREATE INDEX IF NOT EXISTS idx_knowledge_records_scope ON "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" (scopeKey, id)`,
6995
+ `CREATE INDEX IF NOT EXISTS idx_knowledge_activity_scope ON "${_mastra_core_storage.TABLE_KNOWLEDGE_ACTIVITY}" (scopeKey, id DESC)`,
6934
6996
  `CREATE UNIQUE INDEX IF NOT EXISTS idx_knowledge_outbox_idempotency ON "${_mastra_core_storage.TABLE_KNOWLEDGE_SEMANTIC_OUTBOX}" (idempotencyKey)`,
6935
6997
  `CREATE INDEX IF NOT EXISTS idx_knowledge_outbox_claim ON "${_mastra_core_storage.TABLE_KNOWLEDGE_SEMANTIC_OUTBOX}" (status, availableAt, createdAt)`,
6936
6998
  `CREATE INDEX IF NOT EXISTS idx_knowledge_node_scopes_scope ON "${TABLE_KNOWLEDGE_NODE_SCOPES}" (scopeNodeId, nodeId)`,
@@ -7051,7 +7113,11 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7051
7113
  throw new Error(`Knowledge parent scope does not exist: ${parentAddress}`);
7052
7114
  }
7053
7115
  if ((await tx.execute({
7054
- sql: `SELECT n.id FROM "mastra_knowledge_node_scopes" ns JOIN "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" n ON n.id=ns.nodeId WHERE ns.scopeNodeId=? AND n.canonicalName=? AND n.deletedAt IS NULL AND n.id<>? LIMIT 1`,
7116
+ sql: `SELECT 1 FROM "mastra_knowledge_node_scopes" WHERE nodeId=? AND scopeNodeId=?`,
7117
+ args: [scopeNodeId, parentId]
7118
+ })).rows.length) continue;
7119
+ if ((await tx.execute({
7120
+ sql: `SELECT n.id FROM "mastra_knowledge_node_scopes" ns JOIN "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" n ON n.id=ns.nodeId WHERE ns.scopeNodeId=? AND n.isScope AND n.canonicalName=? AND n.deletedAt IS NULL AND n.id<>? LIMIT 1`,
7055
7121
  args: [
7056
7122
  parentId,
7057
7123
  canonicalName(scope.name),
@@ -7158,11 +7224,19 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7158
7224
  })), limit, input);
7159
7225
  }
7160
7226
  async listScopeMembers(input) {
7161
- const limit = Math.min(Math.max(input.limit ?? 500, 1), 500);
7162
- return (await this.#client.execute({
7163
- sql: `SELECT *, json(scope) AS scopeJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" n WHERE EXISTS (SELECT 1 FROM "${TABLE_KNOWLEDGE_NODE_SCOPES}" ns WHERE ns.nodeId=n.id AND ns.scopeNodeId=?) AND n.deletedAt IS NULL AND n.mergedInto IS NULL ORDER BY n.updatedAt DESC, n.name ASC, n.id ASC LIMIT ?`,
7164
- args: [input.scopeNodeId, limit]
7165
- })).rows.map(parseNode);
7227
+ const { limit, after } = parseListKnowledgeScopeMembersInput(input);
7228
+ const args = [input.scopeNodeId];
7229
+ let keyset = "";
7230
+ if (after) {
7231
+ const updatedAt = after.updatedAt.toISOString();
7232
+ keyset = ` AND (n.updatedAt < ? OR (n.updatedAt = ? AND (n.name > ? OR (n.name = ? AND n.id > ?))))`;
7233
+ args.push(updatedAt, updatedAt, after.name, after.name, after.id);
7234
+ }
7235
+ args.push(limit + 1);
7236
+ return pageKnowledgeScopeMembers((await this.#client.execute({
7237
+ sql: `SELECT *, json(scope) AS scopeJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" n WHERE EXISTS (SELECT 1 FROM "${TABLE_KNOWLEDGE_NODE_SCOPES}" ns WHERE ns.nodeId=n.id AND ns.scopeNodeId=?) AND n.deletedAt IS NULL AND n.mergedInto IS NULL${keyset} ORDER BY n.updatedAt DESC, n.name ASC, n.id ASC LIMIT ?`,
7238
+ args
7239
+ })).rows.map(parseNode), limit, input);
7166
7240
  }
7167
7241
  async createNode(input) {
7168
7242
  await assertKnowledgeDescriptionWithinBoundCompat(input.description);
@@ -7172,6 +7246,7 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7172
7246
  if (existing) {
7173
7247
  const terminal = await this.#resolveTerminalNode(tx, existing.id);
7174
7248
  if (!(0, _mastra_core_storage.isKnowledgeScopeVisible)(terminal.scope, scope)) throw new Error(`Merged knowledge node is not visible from scope: ${input.name}`);
7249
+ await this.#placeNodeInScopes(tx, terminal.id, input.scopeAddresses, /* @__PURE__ */ new Date());
7175
7250
  return terminal;
7176
7251
  }
7177
7252
  const now = /* @__PURE__ */ new Date();
@@ -7222,14 +7297,13 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7222
7297
  return this.#resolveNode(this.#client, input.name, (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope));
7223
7298
  }
7224
7299
  async listNodes(input) {
7225
- const scope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope);
7226
- const key = JSON.stringify(scope);
7300
+ const keys = visibleScopeKeys((0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope));
7227
7301
  const clauses = [
7228
7302
  `type = 'node'`,
7229
7303
  "mergedInto IS NULL",
7230
- visibleSql()
7304
+ visibleSql(keys)
7231
7305
  ];
7232
- const args = [key, key];
7306
+ const args = [...keys];
7233
7307
  if (input.namePrefix) {
7234
7308
  clauses.push("canonicalName LIKE ? ESCAPE '='");
7235
7309
  args.push(`${escapeLikePattern(canonicalName(input.namePrefix))}%`);
@@ -7384,7 +7458,6 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7384
7458
  const scope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope);
7385
7459
  const resolutionScope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.resolutionScope);
7386
7460
  const defaultScope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.defaultScope);
7387
- (0, _mastra_core_storage.assertKnowledgeScopeWithinCeiling)(scope, input.maxScope);
7388
7461
  return this.#transaction(async (tx) => {
7389
7462
  const node = nodeReferenceId(input.node);
7390
7463
  const parent = await this.#resolveTerminalNode(tx, node);
@@ -7397,11 +7470,10 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7397
7470
  sourceThreadId: input.sourceThreadId,
7398
7471
  capturedAt: /* @__PURE__ */ new Date(),
7399
7472
  when: input.when ? new Date(input.when) : void 0,
7400
- maxScope: input.maxScope,
7401
7473
  metadata: input.metadata
7402
7474
  };
7403
7475
  await tx.execute({
7404
- sql: `INSERT INTO "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" (id,node,text,scope,scopeKey,sourceThreadId,capturedAt,"when",maxScope,metadata,version,updatedAt,deletedAt,deletedBy) VALUES (?,?,?,jsonb(?),?,?,?,?,?,jsonb(?),?,?,NULL,NULL)`,
7476
+ sql: `INSERT INTO "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" (id,node,text,scope,scopeKey,sourceThreadId,capturedAt,"when",metadata,version,updatedAt,deletedAt,deletedBy) VALUES (?,?,?,jsonb(?),?,?,?,?,jsonb(?),?,?,NULL,NULL)`,
7405
7477
  args: [
7406
7478
  record.id,
7407
7479
  record.node,
@@ -7411,7 +7483,6 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7411
7483
  record.sourceThreadId,
7412
7484
  record.capturedAt.toISOString(),
7413
7485
  record.when?.toISOString() ?? null,
7414
- record.maxScope ?? null,
7415
7486
  record.metadata ? JSON.stringify(record.metadata) : null,
7416
7487
  1,
7417
7488
  record.capturedAt.toISOString()
@@ -7441,18 +7512,13 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7441
7512
  return this.#queryKnowledge(input, "related");
7442
7513
  }
7443
7514
  async knowledgeBySource(input) {
7444
- const scope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope);
7445
- const key = JSON.stringify(scope);
7446
- const args = [
7447
- input.sourceThreadId,
7448
- key,
7449
- key
7450
- ];
7515
+ const keys = visibleScopeKeys((0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope));
7516
+ const args = [input.sourceThreadId, ...keys];
7451
7517
  if (input.after) args.push(input.after);
7452
7518
  const limit = input.limit ?? 100;
7453
7519
  args.push(limit + 1);
7454
7520
  const records = (await this.#client.execute({
7455
- sql: `SELECT *,json(scope) AS scopeJson,json(metadata) AS metadataJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" WHERE sourceThreadId=? AND ${visibleSql()}${input.includeDeleted ? "" : " AND deletedAt IS NULL"}${input.after ? " AND id > ?" : ""} ORDER BY id ASC LIMIT ?`,
7521
+ sql: `SELECT *,json(scope) AS scopeJson,json(metadata) AS metadataJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" WHERE sourceThreadId=? AND ${visibleSql(keys)}${input.includeDeleted ? "" : " AND deletedAt IS NULL"}${input.after ? " AND id > ?" : ""} ORDER BY id ASC LIMIT ?`,
7456
7522
  args
7457
7523
  })).rows.map(parseKnowledge);
7458
7524
  return {
@@ -7507,7 +7573,6 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7507
7573
  return this.#transaction(async (tx) => {
7508
7574
  const record = await this.#getKnowledge(tx, input.id, true);
7509
7575
  if (!record) throw new _mastra_core_storage.KnowledgeNotFoundError("record", input.id);
7510
- (0, _mastra_core_storage.assertKnowledgeScopeWithinCeiling)(scope, record.maxScope);
7511
7576
  const updatedAt = /* @__PURE__ */ new Date();
7512
7577
  await tx.execute({
7513
7578
  sql: `UPDATE "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" SET scope=jsonb(?),scopeKey=?,version=version+1,updatedAt=? WHERE id=?`,
@@ -7528,37 +7593,16 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7528
7593
  };
7529
7594
  });
7530
7595
  }
7531
- async raiseKnowledgeCeiling(input) {
7532
- return this.#transaction(async (tx) => {
7533
- const record = await this.#getKnowledge(tx, input.id, true);
7534
- if (!record) throw new _mastra_core_storage.KnowledgeNotFoundError("record", input.id);
7535
- (0, _mastra_core_storage.assertKnowledgeScopeWithinCeiling)(record.scope, input.maxScope);
7536
- (0, _mastra_core_storage.assertKnowledgeCeilingRaised)(record.maxScope, input.maxScope);
7537
- await tx.execute({
7538
- sql: `UPDATE "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" SET maxScope=?,version=version+1,updatedAt=? WHERE id=?`,
7539
- args: [
7540
- input.maxScope ?? null,
7541
- (/* @__PURE__ */ new Date()).toISOString(),
7542
- input.id
7543
- ]
7544
- });
7545
- return {
7546
- ...record,
7547
- maxScope: input.maxScope
7548
- };
7549
- });
7550
- }
7551
7596
  async search(input) {
7552
7597
  const scope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope);
7553
- const key = JSON.stringify(scope);
7598
+ const keys = visibleScopeKeys(scope);
7554
7599
  const normalizedQuery = input.query.trim().toLocaleLowerCase();
7555
7600
  if (!normalizedQuery) return [];
7556
7601
  const query = `%${escapeLikePattern(normalizedQuery)}%`;
7557
7602
  const results = (await this.#client.execute({
7558
- sql: `SELECT *,json(scope) AS scopeJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" WHERE mergedInto IS NULL AND ${visibleSql()} AND (canonicalName LIKE ? ESCAPE '=' OR lower(COALESCE(kind,'')) LIKE ? ESCAPE '=' OR lower(COALESCE(content,'')) LIKE ? ESCAPE '=' OR lower(COALESCE(description,'')) LIKE ? ESCAPE '=') ORDER BY updatedAt DESC LIMIT ?`,
7603
+ sql: `SELECT *,json(scope) AS scopeJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" WHERE mergedInto IS NULL AND ${visibleSql(keys)} AND (canonicalName LIKE ? ESCAPE '=' OR lower(COALESCE(kind,'')) LIKE ? ESCAPE '=' OR lower(COALESCE(content,'')) LIKE ? ESCAPE '=' OR lower(COALESCE(description,'')) LIKE ? ESCAPE '=') ORDER BY updatedAt DESC LIMIT ?`,
7559
7604
  args: [
7560
- key,
7561
- key,
7605
+ ...keys,
7562
7606
  query,
7563
7607
  query,
7564
7608
  query,
@@ -7579,10 +7623,9 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7579
7623
  }));
7580
7624
  if (results.length < (input.limit ?? 20)) {
7581
7625
  const knowledge = await this.#client.execute({
7582
- sql: `SELECT k.*,json(k.scope) AS scopeJson,json(k.metadata) AS metadataJson,n.name,json(n.scope) AS parentScopeJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" k JOIN "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" n ON n.id=k.node AND n.type='node' AND n.mergedInto IS NULL WHERE k.deletedAt IS NULL AND ${visibleSql("k.scope")} AND lower(k.text) LIKE ? ESCAPE '=' ORDER BY k.id DESC LIMIT ?`,
7626
+ sql: `SELECT k.*,json(k.scope) AS scopeJson,json(k.metadata) AS metadataJson,n.name,json(n.scope) AS parentScopeJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" k CROSS JOIN "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" n ON n.id=k.node AND n.type='node' AND n.mergedInto IS NULL WHERE k.deletedAt IS NULL AND ${visibleSql(keys, "k.scopeKey")} AND lower(k.text) LIKE ? ESCAPE '=' ORDER BY k.id DESC LIMIT ?`,
7583
7627
  args: [
7584
- key,
7585
- key,
7628
+ ...keys,
7586
7629
  query,
7587
7630
  (input.limit ?? 20) - results.length
7588
7631
  ]
@@ -7616,13 +7659,11 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7616
7659
  throw new Error(KNOWLEDGE_CURATION_CURSOR_REMOVED_MESSAGE);
7617
7660
  }
7618
7661
  async listActivity(input) {
7619
- const scope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope);
7620
- const key = JSON.stringify(scope);
7662
+ const keys = visibleScopeKeys((0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope));
7621
7663
  return (await this.#client.execute({
7622
- sql: `SELECT *,json(scope) AS scopeJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_ACTIVITY}" WHERE ${visibleSql()}${input.after ? " AND id < ?" : ""} ORDER BY id DESC LIMIT ?`,
7664
+ sql: `SELECT *,json(scope) AS scopeJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_ACTIVITY}" WHERE ${visibleSql(keys)}${input.after ? " AND id < ?" : ""} ORDER BY id DESC LIMIT ?`,
7623
7665
  args: [
7624
- key,
7625
- key,
7666
+ ...keys,
7626
7667
  ...input.after ? [input.after] : [],
7627
7668
  input.limit ?? 100
7628
7669
  ]
@@ -7644,9 +7685,9 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7644
7685
  args.push(input.status);
7645
7686
  }
7646
7687
  if (input.scope) {
7647
- const key = JSON.stringify((0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope));
7648
- clauses.push(visibleSql());
7649
- args.push(key, key);
7688
+ const keys = visibleScopeKeys(input.scope);
7689
+ clauses.push(visibleSql(keys));
7690
+ args.push(...keys);
7650
7691
  }
7651
7692
  args.push(input.limit ?? 100);
7652
7693
  return (await this.#client.execute({
@@ -7665,9 +7706,9 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7665
7706
  ];
7666
7707
  const args = [now.toISOString(), stale.toISOString()];
7667
7708
  if (input.scope) {
7668
- const key = JSON.stringify((0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope));
7669
- clauses.push(visibleSql());
7670
- args.push(key, key);
7709
+ const keys = visibleScopeKeys(input.scope);
7710
+ clauses.push(visibleSql(keys));
7711
+ args.push(...keys);
7671
7712
  }
7672
7713
  args.push(input.limit ?? 100);
7673
7714
  const ids = (await tx.execute({
@@ -7744,9 +7785,10 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7744
7785
  return result.rows[0] ? parseNode(result.rows[0]) : null;
7745
7786
  }
7746
7787
  async #resolveNode(executor, name, scope) {
7788
+ const keys = visibleScopeKeys(scope);
7747
7789
  const candidates = (await executor.execute({
7748
- sql: `SELECT *,json(scope) AS scopeJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" WHERE type='node' AND canonicalName=?`,
7749
- args: [canonicalName(name)]
7790
+ sql: `SELECT *,json(scope) AS scopeJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_NODES}" WHERE type='node' AND canonicalName=? AND (scopeKey IN (${keys.map(() => "?").join(",")}) OR mergedInto IS NOT NULL)`,
7791
+ args: [canonicalName(name), ...keys]
7750
7792
  })).rows.map(parseNode).sort((left, right) => right.scope.length - left.scope.length);
7751
7793
  for (const candidate of candidates) {
7752
7794
  const terminal = await this.#resolveTerminalNode(executor, candidate.id);
@@ -7775,19 +7817,18 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
7775
7817
  const scope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope);
7776
7818
  const node = await this.#resolveTerminalNode(this.#client, nodeReferenceId(input.node));
7777
7819
  if (!node) return { records: [] };
7778
- const key = JSON.stringify(scope);
7820
+ const keys = visibleScopeKeys(scope);
7779
7821
  const includesMentions = relationship !== "about";
7780
7822
  const relationSql = relationship === "about" ? "k.node=?" : relationship === "mentioning" ? "m.recordId=?" : "(k.node=? OR m.recordId=?)";
7781
7823
  const args = [
7782
7824
  node.id,
7783
7825
  ...relationship === "related" ? [node.id] : [],
7784
- key,
7785
- key
7826
+ ...keys
7786
7827
  ];
7787
7828
  if (input.after) args.push(input.after);
7788
7829
  args.push((input.limit ?? 100) + 1);
7789
7830
  const result = await this.#client.execute({
7790
- sql: `SELECT DISTINCT k.*,json(k.scope) AS scopeJson,json(k.metadata) AS metadataJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" k${includesMentions ? ` LEFT JOIN "${_mastra_core_storage.TABLE_KNOWLEDGE_MENTIONS}" m ON m.sourceType='record' AND m.sourceId=k.id` : ""} WHERE ${relationSql} AND ${visibleSql("k.scope")}${input.includeDeleted ? "" : " AND k.deletedAt IS NULL"}${input.after ? " AND k.id < ?" : ""} ORDER BY k.id DESC LIMIT ?`,
7831
+ sql: `SELECT DISTINCT k.*,json(k.scope) AS scopeJson,json(k.metadata) AS metadataJson FROM "${_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS}" k${includesMentions ? ` LEFT JOIN "${_mastra_core_storage.TABLE_KNOWLEDGE_MENTIONS}" m ON m.sourceType='record' AND m.sourceId=k.id` : ""} WHERE ${relationSql} AND ${visibleSql(keys, "k.scopeKey")}${input.includeDeleted ? "" : " AND k.deletedAt IS NULL"}${input.after ? " AND k.id < ?" : ""} ORDER BY k.id DESC LIMIT ?`,
7791
7832
  args
7792
7833
  });
7793
7834
  const limit = input.limit ?? 100;
@@ -14478,7 +14519,7 @@ var WorkflowsLibSQL = class WorkflowsLibSQL extends _mastra_core_storage.Workflo
14478
14519
  this.logger.warn("LibSQL Workflows: Failed to set PRAGMA settings.", err);
14479
14520
  }
14480
14521
  }
14481
- async updateWorkflowResults({ workflowName, runId, stepId, result, requestContext }) {
14522
+ async updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state }) {
14482
14523
  return this.executeWithRetry(() => withClientWriteLock(this.#client, async () => {
14483
14524
  const tx = await this.#client.transaction("write");
14484
14525
  try {
@@ -14509,7 +14550,8 @@ var WorkflowsLibSQL = class WorkflowsLibSQL extends _mastra_core_storage.Workflo
14509
14550
  snapshot,
14510
14551
  stepId,
14511
14552
  result,
14512
- requestContext
14553
+ requestContext,
14554
+ state
14513
14555
  });
14514
14556
  const now = (/* @__PURE__ */ new Date()).toISOString();
14515
14557
  await tx.execute({
@@ -15702,7 +15744,7 @@ var LibSQLStore = class extends _mastra_core_storage.MastraCompositeStore {
15702
15744
  const memory = new MemoryLibSQL(domainConfig);
15703
15745
  const knowledge = new KnowledgeLibSQL({
15704
15746
  ...domainConfig,
15705
- storageIsolationKey: getLibSQLKnowledgeIsolationKey(config, this.client)
15747
+ storageIsolationKey: config.storageIsolationKey ?? getLibSQLKnowledgeIsolationKey(config, this.client)
15706
15748
  });
15707
15749
  const observability = new ObservabilityLibSQL(domainConfig);
15708
15750
  const agents = new AgentsLibSQL(domainConfig);