@dbx-tools/appkit-mastra 0.9.118 → 0.9.120

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.
@@ -1 +1 @@
1
- {"root":["../src/agents.ts","../src/chart.ts","../src/chat.ts","../src/config.ts","../src/defaults.ts","../src/evaluation.ts","../src/filesystems.ts","../src/genie.ts","../src/identity.ts","../src/mcp.ts","../src/memory.ts","../src/mlflow.ts","../src/model.ts","../src/monty-sandbox.ts","../src/observability.ts","../src/openapi-tool.ts","../src/plugin.ts","../src/processors.ts","../src/remote-skills.ts","../src/rest.ts","../src/sandbox.ts","../src/server.ts","../src/serving.ts","../src/skill-paths.ts","../src/statement.ts","../src/storage-schema.ts","../src/style.ts","../src/summarize.ts","../src/telemetry.ts","../src/trace-attributes.ts","../src/validation.ts","../src/workspaces.ts","../src/writer.ts","../index.ts"],"version":"5.9.3"}
1
+ {"root":["../src/agents.ts","../src/chart.ts","../src/chat.ts","../src/config.ts","../src/defaults.ts","../src/evaluation.ts","../src/filesystems.ts","../src/genie.ts","../src/identity.ts","../src/mcp.ts","../src/memory.ts","../src/mlflow.ts","../src/model.ts","../src/monty-sandbox.ts","../src/observability.ts","../src/openapi-tool.ts","../src/plugin.ts","../src/processors.ts","../src/remote-skills.ts","../src/rest.ts","../src/server.ts","../src/serving.ts","../src/skill-paths.ts","../src/statement.ts","../src/storage-schema.ts","../src/style.ts","../src/summarize.ts","../src/telemetry.ts","../src/trace-attributes.ts","../src/validation.ts","../src/workspaces.ts","../src/writer.ts","../index.ts"],"version":"5.9.3"}
package/package.json CHANGED
@@ -34,20 +34,21 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@databricks/appkit": "0.81.0",
37
- "@dbx-tools/appkit": "^0.9.118",
38
- "@dbx-tools/core": "^0.9.118",
39
- "@dbx-tools/databricks": "^0.9.118",
40
- "@dbx-tools/fs": "^0.9.118",
41
- "@dbx-tools/genie": "^0.9.118",
42
- "@dbx-tools/model": "^0.9.118",
43
- "@dbx-tools/model-protocol": "^0.9.118",
44
- "@dbx-tools/path": "^0.9.118",
45
- "@dbx-tools/postgres": "^0.9.118",
46
- "@dbx-tools/shared-core": "^0.9.118",
47
- "@dbx-tools/shared-fs": "^0.9.118",
48
- "@dbx-tools/shared-genie": "^0.9.118",
49
- "@dbx-tools/shared-mastra": "^0.9.118",
50
- "@dbx-tools/shared-model": "^0.9.118",
37
+ "@dbx-tools/appkit": "^0.9.120",
38
+ "@dbx-tools/cache": "^0.9.120",
39
+ "@dbx-tools/core": "^0.9.120",
40
+ "@dbx-tools/databricks": "^0.9.120",
41
+ "@dbx-tools/fs": "^0.9.120",
42
+ "@dbx-tools/genie": "^0.9.120",
43
+ "@dbx-tools/model": "^0.9.120",
44
+ "@dbx-tools/model-protocol": "^0.9.120",
45
+ "@dbx-tools/path": "^0.9.120",
46
+ "@dbx-tools/postgres": "^0.9.120",
47
+ "@dbx-tools/shared-core": "^0.9.120",
48
+ "@dbx-tools/shared-fs": "^0.9.120",
49
+ "@dbx-tools/shared-genie": "^0.9.120",
50
+ "@dbx-tools/shared-mastra": "^0.9.120",
51
+ "@dbx-tools/shared-model": "^0.9.120",
51
52
  "@mastra/ai-sdk": "1.10.5",
52
53
  "@mastra/core": "1.71.0",
53
54
  "@mastra/express": "1.5.15",
@@ -68,7 +69,6 @@
68
69
  "ai": "^7.0.0",
69
70
  "express": "^5.1.0",
70
71
  "fuse.js": "^7.4.2",
71
- "lru-cache": "11.5.3",
72
72
  "pg": "^8.22.0",
73
73
  "yaml": "^2.9.0",
74
74
  "zod": "4.3.6"
@@ -164,10 +164,6 @@
164
164
  "types": "./lib/src/rest.d.ts",
165
165
  "default": "./lib/src/rest.js"
166
166
  },
167
- "./sandbox": {
168
- "types": "./lib/src/sandbox.d.ts",
169
- "default": "./lib/src/sandbox.js"
170
- },
171
167
  "./server": {
172
168
  "types": "./lib/src/server.d.ts",
173
169
  "default": "./lib/src/server.js"
@@ -223,7 +219,7 @@
223
219
  "./package.json": "./package.json"
224
220
  }
225
221
  },
226
- "version": "0.9.118",
222
+ "version": "0.9.120",
227
223
  "types": "./lib/index.d.ts",
228
224
  "dbxToolsConfig": {
229
225
  "tags": [
@@ -316,10 +312,6 @@
316
312
  "types": "./lib/src/rest.d.ts",
317
313
  "default": "./lib/src/rest.js"
318
314
  },
319
- "./sandbox": {
320
- "types": "./lib/src/sandbox.d.ts",
321
- "default": "./lib/src/sandbox.js"
322
- },
323
315
  "./server": {
324
316
  "types": "./lib/src/server.d.ts",
325
317
  "default": "./lib/src/server.js"
package/src/agents.ts CHANGED
@@ -616,7 +616,7 @@ function codeModeTransport(): Promise<CodeModeTransport> {
616
616
  return transport;
617
617
  } catch (caught) {
618
618
  codeModeLogger.warn("isolated-vm unavailable; using QuickJS", {
619
- error: errorUtils.errorMessage(caught),
619
+ error: errorUtils.toError(caught),
620
620
  });
621
621
  return new QuickJsCodeModeTransport();
622
622
  }
@@ -767,7 +767,7 @@ export async function buildAgents(opts: {
767
767
  fallbackToTmp: config.workspaceFallbackToTmp,
768
768
  ...(config.workspaceTools !== undefined ? { tools: config.workspaceTools } : {}),
769
769
  pluginContext: context,
770
- sandbox: config.sandbox === true ? "databricks" : config.sandbox,
770
+ sandbox: config.sandbox,
771
771
  });
772
772
  markDefaultWorkspace(workspace);
773
773
  } else if (workspace) {
@@ -854,8 +854,7 @@ function toolErrorLoggingProcessor(logger: log.Logger): OutputProcessor {
854
854
  logger.error("tool execution failed", {
855
855
  toolName: part.payload.toolName,
856
856
  toolCallId: part.payload.toolCallId,
857
- error: error.message,
858
- stack: error.stack,
857
+ error,
859
858
  });
860
859
  }
861
860
  return part;
package/src/chart.ts CHANGED
@@ -516,7 +516,7 @@ async function writeChart(entry: Chart, userKey: string): Promise<void> {
516
516
  } catch (err) {
517
517
  logger.warn("write-error", {
518
518
  chartId: entry.chartId,
519
- error: errorUtils.errorMessage(err),
519
+ error: errorUtils.toError(err),
520
520
  });
521
521
  }
522
522
  }
@@ -534,7 +534,7 @@ async function readChart(chartId: string, userKey: string): Promise<Chart | unde
534
534
  } catch (err) {
535
535
  logger.warn("read-error", {
536
536
  chartId,
537
- error: errorUtils.errorMessage(err),
537
+ error: errorUtils.toError(err),
538
538
  });
539
539
  return undefined;
540
540
  }
@@ -629,7 +629,7 @@ async function runPrepareChart(chartId: string, opts: PrepareChartOptions): Prom
629
629
  elapsedMs: Date.now() - startedAt,
630
630
  });
631
631
  } catch (err) {
632
- logger.warn("error", { chartId, error: errorUtils.errorMessage(err) });
632
+ logger.warn("error", { chartId, error: errorUtils.toError(err) });
633
633
  // The entry's `error` is rendered in the chat, so only an AppKitError's
634
634
  // own message travels; anything else could carry upstream provider detail.
635
635
  const errText = err instanceof AppKitError ? err.message : CHART_FAILED_MESSAGE;
package/src/chat.ts CHANGED
@@ -133,7 +133,7 @@ export function agentChatRoutes() {
133
133
  function serializeChatStreamError(error: unknown): string {
134
134
  if (isStaleMastraResumeError(error)) {
135
135
  logger.warn("ignored stale mastra resume", {
136
- error: errorUtils.errorMessage(error),
136
+ error: errorUtils.toError(error),
137
137
  });
138
138
  return STALE_MASTRA_RESUME_STREAM_TEXT;
139
139
  }
package/src/config.ts CHANGED
@@ -20,14 +20,17 @@ import type { BrandContext } from "@dbx-tools/shared-core";
20
20
  import type { AgentConfig } from "@mastra/core/agent";
21
21
  import type { RequestContext } from "@mastra/core/request-context";
22
22
  import { MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY } from "@mastra/core/request-context";
23
- import type { WorkspaceToolsConfig } from "@mastra/core/workspace";
23
+ import type {
24
+ WorkspaceSandbox,
25
+ WorkspaceSandboxResolver,
26
+ WorkspaceToolsConfig,
27
+ } from "@mastra/core/workspace";
24
28
  import type { PgVectorConfig, PostgresStoreConfig } from "@mastra/pg";
25
29
 
26
30
  import type { AnyMastraAgentDefinition, MastraTools } from "./agents.ts";
27
31
  import type { GenieSpacesConfig } from "./genie.ts";
28
32
  import { IDENTITY_MODES, type MastraIdentityMode } from "./identity.ts";
29
- import type { RemoteSkillsOption } from "./remote-skills.ts";
30
- import type { DatabricksWorkspaceSandboxOptions } from "./sandbox.ts";
33
+ import type { LocalSkillMount, RemoteSkillsOption } from "./remote-skills.ts";
31
34
 
32
35
  /**
33
36
  * `RequestContext` key under which {@link MastraServer} stores the
@@ -216,30 +219,34 @@ export interface MastraPluginConfig extends BasePluginConfig {
216
219
  /** AI SDK provider-options namespace. Defaults to `"openai"`; no env fallback. */
217
220
  providerId?: string;
218
221
  /**
219
- * PostgresStore for Mastra threads/messages. `true` reuses the
220
- * `lakebase` plugin's pool; an object opens a dedicated store.
222
+ * PostgresStore for Mastra threads/messages. `true` captures the
223
+ * `lakebase` plugin's existing service-principal pool; an object opens a
224
+ * separately configured store.
221
225
  */
222
226
  storage?: boolean | PostgresStoreConfig;
223
227
  /**
224
- * PgVector store for Mastra memory recall. `true` reuses the
225
- * `lakebase` plugin's pool; an object opens a dedicated store.
228
+ * PgVector store for Mastra memory recall. `true` captures the
229
+ * `lakebase` plugin's existing service-principal pool; an object opens a
230
+ * separately configured store.
226
231
  */
227
232
  memory?: boolean | MastraMemoryConfig;
228
233
  /**
229
- * Expose executable tools from each agent definition through native Mastra
230
- * Code Mode. Defaults on whenever the agent has executable tools. The plugin
231
- * selects Mastra's isolated-vm transport once during startup and falls back
232
- * to Mastra QuickJS when the native transport is unavailable. Set `false` to
234
+ * Expose executable tools available to the current request through native
235
+ * Mastra Code Mode. Defaults on whenever the request has executable tools.
236
+ * The plugin selects Mastra's isolated-vm transport once during startup and
237
+ * falls back to Mastra QuickJS when the native transport is unavailable.
238
+ * These transports do not execute through the workspace command sandbox;
239
+ * SSH is used only when an exposed SSH-backed tool is called. Set `false` to
233
240
  * opt out.
234
241
  */
235
242
  codeMode?: boolean | MastraCodeModeConfig;
236
243
  /**
237
244
  * Sandbox for auto-created agent workspaces. Defaults to Monty. `false`
238
- * disables command execution; `true`, `"databricks"`, or an object
239
- * selects/configures Databricks Sandbox. An agent with an explicit custom
240
- * `workspace` keeps that workspace and its sandbox.
245
+ * disables command execution; `true` or `"monty"` selects Monty; an explicit
246
+ * Mastra sandbox or resolver supplies a remote transport. An agent with an
247
+ * explicit custom `workspace` keeps that workspace and its sandbox.
241
248
  */
242
- sandbox?: boolean | "databricks" | "monty" | DatabricksWorkspaceSandboxOptions;
249
+ sandbox?: boolean | "monty" | WorkspaceSandbox | WorkspaceSandboxResolver;
243
250
  /** Add user-scoped `/tmp` only when no configured workspace path mounts writable. */
244
251
  workspaceFallbackToTmp?: boolean;
245
252
  /** Native Mastra workspace tool availability, approval, and hook configuration. */
@@ -634,10 +641,10 @@ export interface MastraPluginConfig extends BasePluginConfig {
634
641
  * without it, a URL source is fetched directly. A source that resolves
635
642
  * through neither fails startup unless `failOnError: false`.
636
643
  *
637
- * Provisioned skills are written to the Databricks user's Assistant skills
638
- * folder (`/Workspace/Users/<email>/.assistant/skills`, the personal skill
639
- * target) so they persist and are picked up by the built-in Assistant-skills
640
- * mount. With no writable workspace, they go to a local temp dir instead.
644
+ * AI Tools is cached daily with `@dbx-tools/cache` and served to every
645
+ * auto-created workspace from the shared `/.databricks/skills` memory mount.
646
+ * Other sources are written to the Databricks user's Assistant skills folder
647
+ * when writable, with a read-only local-memory fallback.
641
648
  *
642
649
  * @example
643
650
  * ```ts
@@ -651,6 +658,8 @@ export interface MastraPluginConfig extends BasePluginConfig {
651
658
  * ```
652
659
  */
653
660
  remoteSkills?: RemoteSkillsOption;
661
+ /** Read-only local skill trees mounted into every default agent workspace. */
662
+ localSkillMounts?: LocalSkillMount[];
654
663
  }
655
664
 
656
665
  /**
@@ -677,27 +686,27 @@ export const MASTRA_CONFIG_SCHEMA: ConfigSchema = {
677
686
  remoteSkills: {
678
687
  type: ["string", "array", "object"],
679
688
  description:
680
- 'Remote Agent-Skill sources provisioned at startup: "aitools" for Databricks\' own skill set (read from the public databricks/databricks-agent-skills repo, no CLI needed), a GitHub owner/repo, a git/GitLab URL, or a direct SKILL.md/archive URL. Non-aitools sources prefer the optional `skills` npm CLI, else a direct fetch; fails startup on error unless failOnError:false. Written to the Databricks user Assistant skills folder, or read-only local backing storage exposed at stable virtual workspace mounts.',
689
+ 'Remote Agent-Skill sources provisioned at startup: "aitools" for Databricks\' own skill set (daily @dbx-tools/cache snapshot served from the shared in-memory /.databricks/skills mount), a GitHub owner/repo, a git/GitLab URL, or a direct SKILL.md/archive URL. Non-aitools sources prefer the optional `skills` npm CLI, else a direct fetch; fails startup on error unless failOnError:false. Other sources write to the Databricks user Assistant skills folder or a read-only local-memory fallback.',
681
690
  },
682
691
  storage: {
683
692
  type: ["boolean", "object"],
684
693
  description:
685
- "PostgresStore for Mastra threads / messages. `true` reuses the `lakebase` plugin's pool, an object opens a dedicated store. Auto-enabled when the `lakebase` plugin is registered.",
694
+ "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.",
686
695
  },
687
696
  memory: {
688
697
  type: ["boolean", "object"],
689
698
  description:
690
- "PgVector store for Mastra semantic recall. `true` reuses the `lakebase` plugin's pool, an object opens a dedicated store. Auto-enabled when the `lakebase` plugin is registered.",
699
+ "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.",
691
700
  },
692
701
  codeMode: {
693
702
  type: ["boolean", "object"],
694
703
  description:
695
- "Expose all executable tools available to the current request, including native workspace tools, through dynamically generated Mastra Code Mode for sandboxed TypeScript batching, aggregation, and arithmetic. The plugin selects Mastra isolated-vm once during startup and falls back to Mastra QuickJS when native initialization is unavailable. False disables it.",
704
+ "Expose all executable tools available to the current request through native Mastra Code Mode for TypeScript batching, aggregation, and arithmetic. The plugin uses Mastra isolated-vm with the existing QuickJS fallback; neither transport runs through the workspace command sandbox, so SSH is used only when an SSH-backed tool is called. False disables it.",
696
705
  },
697
706
  sandbox: {
698
707
  type: ["boolean", "string", "object"],
699
708
  description:
700
- 'Command sandbox for auto-created agent workspaces. Defaults to Monty. False disables command execution; true, "databricks", or an object selects/configures Databricks Sandbox.',
709
+ 'Command sandbox for auto-created agent workspaces. Defaults to Monty. False disables command execution; true or "monty" selects Monty; an explicit sandbox or resolver supplies another transport.',
701
710
  },
702
711
  workspaceFallbackToTmp: {
703
712
  type: "boolean",
package/src/defaults.ts CHANGED
@@ -53,9 +53,9 @@ const STATEMENT_CACHE_TTL_SEC = 5 * 60;
53
53
  export const modelCatalogueDefaults: ExecuteSettings = {
54
54
  default: {
55
55
  // Cache disabled here because `listServingEndpoints` already memoizes the
56
- // catalogue through the same `CacheManager`, keyed by workspace host with
57
- // `config.modelCacheTtlMs`. That entry is shared across identities; a
58
- // second interceptor cache would duplicate it once per user.
56
+ // catalogue in the shared model cache, keyed by workspace host and trusted
57
+ // credential identity with `config.modelCacheTtlMs`. A second interceptor
58
+ // cache would duplicate it once per user.
59
59
  cache: { enabled: false },
60
60
  // Retry enabled: listing endpoints is an idempotent GET, and the listing
61
61
  // is on the chat UI's load path, so a transient 5xx should not blank the
package/src/genie.ts CHANGED
@@ -45,6 +45,7 @@ import {
45
45
  } from "@databricks/appkit";
46
46
  import type { WorkspaceClient } from "@databricks/appkit";
47
47
  import { pluginRegistry } from "@dbx-tools/appkit";
48
+ import { createCache } from "@dbx-tools/cache/cache";
48
49
  import { chat, space as genieSpace } from "@dbx-tools/genie";
49
50
  import { errorUtils, log, stringUtils } from "@dbx-tools/shared-core";
50
51
  import { genieModel, type GenieMessage } from "@dbx-tools/shared-genie";
@@ -52,7 +53,6 @@ import type { StartedEvent } from "@dbx-tools/shared-mastra";
52
53
  import type { RequestContext } from "@mastra/core/request-context";
53
54
  import { MASTRA_THREAD_ID_KEY } from "@mastra/core/request-context";
54
55
  import { createTool, type ToolExecutionContext } from "@mastra/core/tools";
55
- import { LRUCache } from "lru-cache";
56
56
  import { z } from "zod";
57
57
 
58
58
  import type { MastraTools } from "./agents.ts";
@@ -248,7 +248,7 @@ async function readCachedConversationId(cacheKey: string | undefined): Promise<s
248
248
  return v ?? undefined;
249
249
  } catch (err) {
250
250
  logger.warn("conversation-cache:read-error", {
251
- error: errorUtils.errorMessage(err),
251
+ error: errorUtils.toError(err),
252
252
  });
253
253
  return undefined;
254
254
  }
@@ -272,7 +272,7 @@ async function saveCachedConversationId(
272
272
  });
273
273
  } catch (err) {
274
274
  logger.warn("conversation-cache:write-error", {
275
- error: errorUtils.errorMessage(err),
275
+ error: errorUtils.toError(err),
276
276
  });
277
277
  }
278
278
  }
@@ -284,7 +284,7 @@ async function evictCachedConversationId(cacheKey: string | undefined): Promise<
284
284
  await CacheManager.getInstanceSync().delete(cacheKey);
285
285
  } catch (err) {
286
286
  logger.warn("conversation-cache:delete-error", {
287
- error: errorUtils.errorMessage(err),
287
+ error: errorUtils.toError(err),
288
288
  });
289
289
  }
290
290
  }
@@ -515,7 +515,7 @@ function buildAskGenieTool(opts: {
515
515
  logger.warn("conversation-cache:stale, resetting", {
516
516
  spaceId,
517
517
  conversationId: rejectedConversationId,
518
- error: errorUtils.errorMessage(err),
518
+ error: errorUtils.toError(err),
519
519
  });
520
520
  if (ownsReusableConversation) {
521
521
  await evictCachedConversationId(cacheKey);
@@ -1091,19 +1091,19 @@ const SUGGESTION_LIMIT = 6;
1091
1091
  const SUGGESTION_CACHE_TTL_MS = 10 * 60_000;
1092
1092
 
1093
1093
  /** Bounded process-local cache of parsed sample questions by Genie space id. */
1094
- const _suggestionCache = new LRUCache<string, string[]>({
1095
- max: 128,
1094
+ const _suggestionCache = createCache({
1095
+ maxEntries: 128,
1096
1096
  ttl: SUGGESTION_CACHE_TTL_MS,
1097
1097
  });
1098
1098
 
1099
1099
  /** Read a space's cached questions, or `undefined` on miss / expiry. */
1100
- function readSuggestionCache(spaceId: string): string[] | undefined {
1101
- return _suggestionCache.get(spaceId);
1100
+ function readSuggestionCache(spaceId: string): Promise<string[] | undefined> {
1101
+ return _suggestionCache.get<string[]>(spaceId);
1102
1102
  }
1103
1103
 
1104
1104
  /** Cache a space's parsed questions for {@link SUGGESTION_CACHE_TTL_MS}. */
1105
- function writeSuggestionCache(spaceId: string, questions: string[]): void {
1106
- _suggestionCache.set(spaceId, questions);
1105
+ async function writeSuggestionCache(spaceId: string, questions: string[]): Promise<void> {
1106
+ await _suggestionCache.set(spaceId, questions);
1107
1107
  }
1108
1108
 
1109
1109
  /**
@@ -1115,7 +1115,9 @@ function writeSuggestionCache(spaceId: string, questions: string[]): void {
1115
1115
  * questions and a multi-space app round-trips breadth-first up to the
1116
1116
  * cap. A per-space fetch failure degrades to "no questions for that
1117
1117
  * space" (logged, not thrown) so one unreachable space never blanks
1118
- * the whole list. Returns `[]` when no spaces are configured.
1118
+ * the whole list. When `signal` aborts (the HTTP caller disconnected),
1119
+ * collection stops silently and returns what was merged so far.
1120
+ * Returns `[]` when no spaces are configured.
1119
1121
  */
1120
1122
  export async function collectSpaceSuggestions(opts: {
1121
1123
  spaces: Record<string, GenieSpaceConfig>;
@@ -1128,7 +1130,7 @@ export async function collectSpaceSuggestions(opts: {
1128
1130
  const seen = new Set<string>();
1129
1131
 
1130
1132
  for (const { spaceId } of Object.values(opts.spaces)) {
1131
- let questions = readSuggestionCache(spaceId);
1133
+ let questions = await readSuggestionCache(spaceId);
1132
1134
  if (!questions) {
1133
1135
  try {
1134
1136
  const space = await genieSpace.getGenieSpace(spaceId, {
@@ -1136,11 +1138,12 @@ export async function collectSpaceSuggestions(opts: {
1136
1138
  ...(opts.signal ? { context: opts.signal } : {}),
1137
1139
  });
1138
1140
  questions = genieSpace.genieSampleQuestions(space);
1139
- writeSuggestionCache(spaceId, questions);
1141
+ await writeSuggestionCache(spaceId, questions);
1140
1142
  } catch (err) {
1143
+ if (opts.signal?.aborted) return merged;
1141
1144
  logger.warn("suggestions:fetch-error", {
1142
1145
  spaceId,
1143
- error: errorUtils.errorMessage(err),
1146
+ error: errorUtils.toError(err),
1144
1147
  });
1145
1148
  questions = [];
1146
1149
  }
package/src/memory.ts CHANGED
@@ -32,9 +32,7 @@
32
32
  * @module
33
33
  */
34
34
 
35
- import { getUsernameWithApiLookup } from "@databricks/appkit";
36
35
  import { migration as appkitMigration } from "@dbx-tools/appkit";
37
- import { postgresConnectionOptions } from "@dbx-tools/postgres";
38
36
  import { hash, log } from "@dbx-tools/shared-core";
39
37
  import type { AgentMemoryOption } from "@mastra/core/agent";
40
38
  import {
@@ -45,7 +43,7 @@ import {
45
43
  import { fastembed } from "@mastra/fastembed";
46
44
  import { Memory } from "@mastra/memory";
47
45
  import { PgVector, PostgresStore } from "@mastra/pg";
48
- import { Pool, type PoolConfig } from "pg";
46
+ import type { Pool } from "pg";
49
47
 
50
48
  import type { AnyMastraAgentDefinition, MastraMemoryConfigOverride } from "./agents.ts";
51
49
  import type { MastraPluginConfig } from "./config.ts";
@@ -132,34 +130,6 @@ export function withSoftStorageInit(store: PostgresStore): PostgresStore {
132
130
  return store;
133
131
  }
134
132
 
135
- /**
136
- * Build a dedicated **service-principal** Lakebase pool for Mastra
137
- * memory from the lakebase plugin's resolved SP pg config.
138
- *
139
- * The plugin's `exports().pool` is a `RoutingPool` that switches to
140
- * the per-user (OBO) pool whenever a query runs inside an `asUser`
141
- * scope - exactly the context the mastra plugin establishes around
142
- * every chat turn. Memory (threads / messages + semantic recall) must
143
- * instead always act as the app service principal: it owns the
144
- * auto-created `mastra_*` schemas (a per-user role usually can't
145
- * `CREATE SCHEMA`) and is shared across users, so it cannot inherit a
146
- * request's OBO identity.
147
- *
148
- * `pgConfig` must be the plugin's `exports().getPgConfig()` evaluated
149
- * **outside** any `asUser` scope (i.e. during setup), so it carries
150
- * the SP connection target, OAuth token-refresh `password` callback,
151
- * and any `lakebase({ pool })` tuning overrides - all of which this
152
- * pool inherits. See the call site in `plugin.ts`.
153
- */
154
- export async function createServicePrincipalPool(pgConfig: PoolConfig): Promise<Pool> {
155
- // `getPgConfig()` resolves the SP username synchronously from
156
- // `PGUSER` / `DATABRICKS_CLIENT_ID`; fall back to the async API
157
- // lookup (e.g. local dev authenticating via PAT) so the pool always
158
- // has an identity to connect with.
159
- const user = pgConfig.user ?? (await getUsernameWithApiLookup());
160
- return new Pool(postgresConnectionOptions({ ...pgConfig, user }));
161
- }
162
-
163
133
  /** Effective per-knob setting after the plugin/agent cascade. */
164
134
  type StorageSetting = AnyMastraAgentDefinition["storage"];
165
135
  type MemorySetting = AnyMastraAgentDefinition["memory"];
@@ -179,7 +149,7 @@ export function needsLakebase(config: MastraPluginConfig): boolean {
179
149
 
180
150
  /**
181
151
  * Construct a per-agent {@link Memory} factory bound to the supplied
182
- * service-principal pool (see {@link createServicePrincipalPool}).
152
+ * service-principal pool.
183
153
  * Caches the shared `PgVector` singleton (built on first need) so each
184
154
  * agent build is O(1) after the first.
185
155
  */
package/src/mlflow.ts CHANGED
@@ -366,7 +366,7 @@ export async function initializeAppMlflowTraceInfo(client?: WorkspaceClient): Pr
366
366
  return true;
367
367
  } catch (err) {
368
368
  logger.warn("Databricks Apps MLflow trace-info promotion disabled", {
369
- error: errorUtils.errorMessage(err),
369
+ error: errorUtils.toError(err),
370
370
  });
371
371
  return false;
372
372
  }
@@ -424,7 +424,7 @@ export function persistAppMlflowTraceInfo(params: AppMlflowTraceInfo): void {
424
424
  .catch((err) => {
425
425
  logger.warn("Databricks Apps MLflow trace-info promotion failed", {
426
426
  traceId: params.traceId,
427
- error: errorUtils.errorMessage(err),
427
+ error: errorUtils.toError(err),
428
428
  });
429
429
  })
430
430
  .finally(() => pendingAppMlflowTraceInfo.delete(pending));
@@ -466,7 +466,7 @@ async function detectedDirectMlflowTraceLocation(
466
466
  } catch (err) {
467
467
  logger.warn("direct MLflow UC trace-location detection failed", {
468
468
  experimentId,
469
- error: errorUtils.errorMessage(err),
469
+ error: errorUtils.toError(err),
470
470
  });
471
471
  return undefined;
472
472
  }
@@ -530,7 +530,7 @@ export async function initializeDirectMlflowTracing(): Promise<boolean> {
530
530
  return true;
531
531
  } catch (err) {
532
532
  logger.warn("direct MLflow tracing disabled", {
533
- error: errorUtils.errorMessage(err),
533
+ error: errorUtils.toError(err),
534
534
  });
535
535
  return false;
536
536
  }
@@ -693,18 +693,10 @@ async function resolveExperimentId(client: WorkspaceClient): Promise<string | un
693
693
  }
694
694
 
695
695
  /** Parameters for {@link logFeedback}. */
696
- export interface LogFeedbackParams {
697
- /** MLflow trace id the assessment attaches to (`tr-<hex>`). */
698
- traceId: string;
699
- /** Assessment name; defaults per whether a value or a comment is sent. */
700
- name?: string;
701
- /** Thumbs / rating / label value. Omit for a comment-only submission. */
702
- value?: boolean | number | string;
703
- /** Freeform comment: the rationale alongside a value, or the value itself when none. */
704
- comment?: string;
696
+ export type LogFeedbackParams = feedback.MastraFeedbackRequest & {
705
697
  /** Identity the feedback is attributed to (user email / id). */
706
698
  sourceId?: string;
707
- }
699
+ };
708
700
 
709
701
  /**
710
702
  * Log a HUMAN feedback assessment to a trace. Returns the created
@@ -751,7 +743,7 @@ export async function logFeedback(
751
743
  logger.warn("feedback request failed", {
752
744
  traceId: params.traceId,
753
745
  assessmentTraceId,
754
- error: errorUtils.errorMessage(err),
746
+ error: errorUtils.toError(err),
755
747
  });
756
748
  return undefined;
757
749
  }
@@ -68,7 +68,7 @@ const montyContext = functionUtils.memoize(async (): Promise<MontyContext> => {
68
68
  } catch (error) {
69
69
  errors.push(errorUtils.toError(error));
70
70
  logger.debug(`${target.name} unavailable`, {
71
- error: errorUtils.errorMessage(error),
71
+ error: errorUtils.toError(error),
72
72
  });
73
73
  }
74
74
  }