@dbx-tools/appkit-mastra 0.9.152 → 0.9.154

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/package.json CHANGED
@@ -36,21 +36,21 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@databricks/appkit": "0.81.0",
39
- "@dbx-tools/appkit": "^0.9.152",
40
- "@dbx-tools/cache": "^0.9.152",
41
- "@dbx-tools/core": "^0.9.152",
42
- "@dbx-tools/databricks": "^0.9.152",
43
- "@dbx-tools/fs": "^0.9.152",
44
- "@dbx-tools/genie": "^0.9.152",
45
- "@dbx-tools/model": "^0.9.152",
46
- "@dbx-tools/model-protocol": "^0.9.152",
47
- "@dbx-tools/path": "^0.9.152",
48
- "@dbx-tools/postgres": "^0.9.152",
49
- "@dbx-tools/shared-core": "^0.9.152",
50
- "@dbx-tools/shared-fs": "^0.9.152",
51
- "@dbx-tools/shared-genie": "^0.9.152",
52
- "@dbx-tools/shared-mastra": "^0.9.152",
53
- "@dbx-tools/shared-model": "^0.9.152",
39
+ "@dbx-tools/appkit": "^0.9.154",
40
+ "@dbx-tools/cache": "^0.9.154",
41
+ "@dbx-tools/core": "^0.9.154",
42
+ "@dbx-tools/databricks": "^0.9.154",
43
+ "@dbx-tools/fs": "^0.9.154",
44
+ "@dbx-tools/genie": "^0.9.154",
45
+ "@dbx-tools/model": "^0.9.154",
46
+ "@dbx-tools/model-protocol": "^0.9.154",
47
+ "@dbx-tools/path": "^0.9.154",
48
+ "@dbx-tools/postgres": "^0.9.154",
49
+ "@dbx-tools/shared-core": "^0.9.154",
50
+ "@dbx-tools/shared-fs": "^0.9.154",
51
+ "@dbx-tools/shared-genie": "^0.9.154",
52
+ "@dbx-tools/shared-mastra": "^0.9.154",
53
+ "@dbx-tools/shared-model": "^0.9.154",
54
54
  "@mastra/ai-sdk": "1.10.5",
55
55
  "@mastra/core": "1.71.0",
56
56
  "@mastra/express": "1.5.15",
@@ -61,7 +61,7 @@
61
61
  "@mastra/otel-bridge": "1.5.11",
62
62
  "@mastra/pg": "1.27.1",
63
63
  "@modelcontextprotocol/sdk": "^1.29.0",
64
- "@opentelemetry/api": "^1.9.1",
64
+ "@opentelemetry/api": "1.9.1",
65
65
  "@opentelemetry/core": "2.11.0",
66
66
  "@opentelemetry/sdk-trace-base": "2.8.0",
67
67
  "@opentelemetry/sdk-trace-node": "2.8.0",
@@ -231,7 +231,7 @@
231
231
  "./package.json": "./package.json"
232
232
  }
233
233
  },
234
- "version": "0.9.152",
234
+ "version": "0.9.154",
235
235
  "types": "./lib/index.d.ts",
236
236
  "dbxToolsConfig": {
237
237
  "tags": [
package/src/config.ts CHANGED
@@ -241,15 +241,15 @@ export interface MastraPluginConfig extends BasePluginConfig {
241
241
  /** AI SDK provider-options namespace. Defaults to `"openai"`; no env fallback. */
242
242
  providerId?: string;
243
243
  /**
244
- * PostgresStore for Mastra threads/messages. `true` captures the
245
- * `lakebase` plugin's existing service-principal pool; an object opens a
246
- * separately configured store.
244
+ * PostgresStore for Mastra threads/messages. `true` derives a dedicated,
245
+ * lifecycle-isolated service-principal pool from the `lakebase` plugin; an
246
+ * object opens a separately configured store.
247
247
  */
248
248
  storage?: boolean | PostgresStoreConfig;
249
249
  /**
250
- * PgVector store for Mastra memory recall. `true` captures the
251
- * `lakebase` plugin's existing service-principal pool; an object opens a
252
- * separately configured store.
250
+ * PgVector store for Mastra memory recall. `true` derives a dedicated,
251
+ * lifecycle-isolated service-principal pool from the `lakebase` plugin; an
252
+ * object opens a separately configured store.
253
253
  */
254
254
  memory?: boolean | MastraMemoryConfig;
255
255
  /**
@@ -716,12 +716,12 @@ export const MASTRA_CONFIG_SCHEMA: ConfigSchema = {
716
716
  storage: {
717
717
  type: ["boolean", "object"],
718
718
  description:
719
- "PostgresStore for Mastra threads / messages. `true` captures the `lakebase` plugin's existing service-principal pool; an object opens a separately configured store. Auto-enabled when the `lakebase` plugin is registered.",
719
+ "PostgresStore for Mastra threads / messages. `true` derives a dedicated lifecycle-isolated service-principal pool from the `lakebase` plugin; an object opens a separately configured store. Auto-enabled when the `lakebase` plugin is registered.",
720
720
  },
721
721
  memory: {
722
722
  type: ["boolean", "object"],
723
723
  description:
724
- "PgVector store for Mastra semantic recall. `true` captures the `lakebase` plugin's existing service-principal pool; an object opens a separately configured store. Auto-enabled when the `lakebase` plugin is registered.",
724
+ "PgVector store for Mastra semantic recall. `true` derives a dedicated lifecycle-isolated service-principal pool from the `lakebase` plugin; an object opens a separately configured store. Auto-enabled when the `lakebase` plugin is registered.",
725
725
  },
726
726
  codeMode: {
727
727
  type: ["boolean", "string", "object"],
package/src/memory.ts CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  import { fastembed } from "@mastra/fastembed";
44
44
  import { Memory } from "@mastra/memory";
45
45
  import { PgVector, PostgresStore } from "@mastra/pg";
46
- import type { Pool } from "pg";
46
+ import { Pool, type PoolConfig } from "pg";
47
47
 
48
48
  import type { AnyMastraAgentDefinition, MastraMemoryConfigOverride } from "./agents.ts";
49
49
  import type { MastraPluginConfig } from "./config.ts";
@@ -160,6 +160,24 @@ export function createMemoryBuilder(
160
160
  return new MemoryBuilder(config, servicePrincipalPool);
161
161
  }
162
162
 
163
+ /**
164
+ * Create the plugin-owned Lakebase pool used by durable workflow storage.
165
+ *
166
+ * @internal
167
+ *
168
+ * AppKit shuts plugin hooks down concurrently, so borrowing the native
169
+ * Lakebase plugin's pool lets its shutdown race Mastra's final snapshot writes.
170
+ * A caller-provided pool is not closed by PostgresStore; idle connections do
171
+ * not keep the process alive and remain available to runs Mastra is still
172
+ * draining after its bounded shutdown window.
173
+ */
174
+ export function createMastraLakebasePool(config: PoolConfig): Pool {
175
+ return new Pool({
176
+ ...config,
177
+ allowExitOnIdle: true,
178
+ });
179
+ }
180
+
163
181
  /**
164
182
  * Builds one `Memory` per agent against a shared service-principal
165
183
  * Lakebase pool. Per-instance state keeps the shared `PgVector` alive
package/src/plugin.ts CHANGED
@@ -56,7 +56,7 @@ import {
56
56
  type PluginManifest,
57
57
  type ResourceRequirement,
58
58
  } from "@databricks/appkit";
59
- import { lakebaseResolver, pluginRegistry, telemetry as appkitTelemetry } from "@dbx-tools/appkit";
59
+ import { pluginRegistry, telemetry as appkitTelemetry } from "@dbx-tools/appkit";
60
60
  import { sendGenieMessageFeedback } from "@dbx-tools/genie/feedback";
61
61
  import { modelCatalog } from "@dbx-tools/model";
62
62
  import { asyncUtils, errorUtils, log, object, stringUtils } from "@dbx-tools/shared-core";
@@ -77,7 +77,6 @@ import { RequestContext } from "@mastra/core/request-context";
77
77
  import type { AnyWorkflow } from "@mastra/core/workflows";
78
78
  import { pipeUIMessageStreamToResponse } from "ai";
79
79
  import express from "express";
80
- import type { Pool } from "pg";
81
80
 
82
81
  import {
83
82
  buildAgents,
@@ -120,7 +119,7 @@ import {
120
119
  type MastraIdentityMode,
121
120
  } from "./identity.ts";
122
121
  import { buildMcpServer, type ResolvedMcp } from "./mcp.ts";
123
- import { createMemoryBuilder, needsLakebase } from "./memory.ts";
122
+ import { createMastraLakebasePool, createMemoryBuilder, needsLakebase } from "./memory.ts";
124
123
  import {
125
124
  flushDirectMlflowTracing,
126
125
  logFeedback,
@@ -1341,9 +1340,9 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
1341
1340
 
1342
1341
  private async buildAgentAndServer(): Promise<void> {
1343
1342
  const memoryPool = needsLakebase(this.config)
1344
- ? (lakebaseResolver.captureServicePrincipalPool(
1345
- pluginRegistry.require(this.context, lakebase, this.config).exports().pool,
1346
- ) as Pool)
1343
+ ? createMastraLakebasePool(
1344
+ pluginRegistry.require(this.context, lakebase, this.config).exports().getPgConfig(),
1345
+ )
1347
1346
  : undefined;
1348
1347
  const memoryBuilder = createMemoryBuilder(this.config, memoryPool);
1349
1348