@dbx-tools/appkit-mastra 0.9.153 → 0.9.157

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.
Files changed (76) hide show
  1. package/README.md +4 -3
  2. package/index.ts +32 -24
  3. package/lib/index.d.ts +32 -24
  4. package/lib/index.js +32 -23
  5. package/lib/src/agents.d.ts +5 -6
  6. package/lib/src/agents.js +12 -15
  7. package/lib/src/chart.js +33 -33
  8. package/lib/src/chat.js +10 -13
  9. package/lib/src/config.d.ts +12 -13
  10. package/lib/src/config.js +4 -4
  11. package/lib/src/evaluation.js +7 -9
  12. package/lib/src/feedback-mode.d.ts +1 -1
  13. package/lib/src/feedback-mode.js +1 -1
  14. package/lib/src/filesystems.js +6 -6
  15. package/lib/src/follow-up-suggestions.js +10 -10
  16. package/lib/src/genie-chat.js +27 -29
  17. package/lib/src/genie.d.ts +2 -2
  18. package/lib/src/genie.js +29 -29
  19. package/lib/src/identity.d.ts +3 -30
  20. package/lib/src/identity.js +2 -27
  21. package/lib/src/memory.d.ts +1 -1
  22. package/lib/src/memory.js +24 -6
  23. package/lib/src/mlflow.d.ts +4 -4
  24. package/lib/src/mlflow.js +15 -18
  25. package/lib/src/model.d.ts +3 -3
  26. package/lib/src/model.js +6 -6
  27. package/lib/src/monty-sandbox.js +8 -8
  28. package/lib/src/observability.d.ts +6 -5
  29. package/lib/src/observability.js +8 -6
  30. package/lib/src/plugin.d.ts +1 -1
  31. package/lib/src/plugin.js +49 -51
  32. package/lib/src/remote-skills.d.ts +3 -4
  33. package/lib/src/remote-skills.js +46 -46
  34. package/lib/src/rest.d.ts +2 -2
  35. package/lib/src/rest.js +3 -3
  36. package/lib/src/server.js +17 -20
  37. package/lib/src/serving.js +10 -11
  38. package/lib/src/statement.js +7 -7
  39. package/lib/src/storage-schema.js +4 -4
  40. package/lib/src/summarize.js +5 -5
  41. package/lib/src/telemetry.d.ts +0 -6
  42. package/lib/src/telemetry.js +34 -41
  43. package/lib/src/validation.js +3 -4
  44. package/lib/src/workspaces.d.ts +2 -2
  45. package/lib/src/workspaces.js +34 -36
  46. package/lib/src/writer.d.ts +2 -2
  47. package/lib/src/writer.js +3 -3
  48. package/package.json +17 -305
  49. package/src/agents.ts +27 -21
  50. package/src/chart.ts +43 -37
  51. package/src/chat.ts +10 -12
  52. package/src/config.ts +14 -15
  53. package/src/evaluation.ts +6 -8
  54. package/src/feedback-mode.ts +1 -1
  55. package/src/filesystems.ts +5 -5
  56. package/src/follow-up-suggestions.ts +9 -9
  57. package/src/genie-chat.ts +32 -31
  58. package/src/genie.ts +29 -29
  59. package/src/identity.ts +3 -38
  60. package/src/memory.ts +24 -6
  61. package/src/mlflow.ts +21 -21
  62. package/src/model.ts +7 -7
  63. package/src/monty-sandbox.ts +7 -7
  64. package/src/observability.ts +8 -6
  65. package/src/plugin.ts +78 -65
  66. package/src/remote-skills.ts +63 -55
  67. package/src/rest.ts +4 -4
  68. package/src/server.ts +32 -20
  69. package/src/serving.ts +14 -11
  70. package/src/statement.ts +10 -6
  71. package/src/storage-schema.ts +3 -3
  72. package/src/summarize.ts +4 -4
  73. package/src/telemetry.ts +49 -55
  74. package/src/validation.ts +2 -3
  75. package/src/workspaces.ts +52 -42
  76. package/src/writer.ts +3 -3
package/src/plugin.ts CHANGED
@@ -56,20 +56,41 @@ 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";
60
- import { sendGenieMessageFeedback } from "@dbx-tools/genie/feedback";
59
+ import {
60
+ pluginRegistry,
61
+ type IdentityMode,
62
+ instance,
63
+ require,
64
+ configureNativeHttpTelemetry,
65
+ excludeUnparentedOutgoingHttpTelemetry,
66
+ deferredNativeTracerProvider,
67
+ requestUserId,
68
+ useServicePrincipal,
69
+ } from "@dbx-tools/appkit";
70
+ import { sendGenieMessageFeedback } from "@dbx-tools/genie";
61
71
  import { modelCatalog } from "@dbx-tools/model";
62
- import { asyncUtils, errorUtils, log, object, stringUtils } from "@dbx-tools/shared-core";
63
72
  import {
64
- feedback,
65
- routes,
66
- wire,
73
+ combineAbortSignals,
74
+ toError,
75
+ errorContext,
76
+ logger,
77
+ toNumber,
78
+ firstNonEmpty,
79
+ } from "@dbx-tools/shared-core";
80
+ import {
67
81
  type Chart,
68
82
  type GenieChatRequest,
69
83
  type MastraClientConfig,
70
84
  type StatementData,
85
+ type FeedbackMode,
86
+ MastraFeedbackRequestSchema,
87
+ type MlflowFeedbackRequest,
88
+ type GenieFeedbackRequest,
89
+ MASTRA_ROUTES,
90
+ genieRoutePath,
91
+ GenieChatRequestSchema,
71
92
  } from "@dbx-tools/shared-mastra";
72
- import { display, type ServingEndpointSummary } from "@dbx-tools/shared-model";
93
+ import { type ServingEndpointSummary, toModelDisplayName } from "@dbx-tools/shared-model";
73
94
  import { workflowRoute } from "@mastra/ai-sdk";
74
95
  import type { Agent } from "@mastra/core/agent";
75
96
  import { Mastra } from "@mastra/core/mastra";
@@ -77,7 +98,6 @@ import { RequestContext } from "@mastra/core/request-context";
77
98
  import type { AnyWorkflow } from "@mastra/core/workflows";
78
99
  import { pipeUIMessageStreamToResponse } from "ai";
79
100
  import express from "express";
80
- import type { Pool } from "pg";
81
101
 
82
102
  import {
83
103
  buildAgents,
@@ -113,14 +133,9 @@ import {
113
133
  type GenieChatSpace,
114
134
  } from "./genie-chat.ts";
115
135
  import { collectSpaceSuggestions, resolveGenieSpaces, type GenieSpaceConfig } from "./genie.ts";
116
- import {
117
- requestUserId,
118
- resolveIdentityMode,
119
- useServicePrincipal,
120
- type MastraIdentityMode,
121
- } from "./identity.ts";
136
+ import { resolveIdentityMode } from "./identity.ts";
122
137
  import { buildMcpServer, type ResolvedMcp } from "./mcp.ts";
123
- import { createMemoryBuilder, needsLakebase } from "./memory.ts";
138
+ import { createMastraLakebasePool, createMemoryBuilder, needsLakebase } from "./memory.ts";
124
139
  import {
125
140
  flushDirectMlflowTracing,
126
141
  logFeedback,
@@ -243,7 +258,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
243
258
  return resources;
244
259
  }
245
260
 
246
- private logger = log.logger(this);
261
+ private logger = logger(this);
247
262
  private built: BuiltAgents | null = null;
248
263
  private mastra: Mastra | null = null;
249
264
  private mastraApp: express.Express | null = null;
@@ -260,13 +275,13 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
260
275
  */
261
276
  private mcp: ResolvedMcp | null = null;
262
277
  /** Resolved feedback destination published to server and browser clients. */
263
- private resolvedFeedbackMode: feedback.FeedbackMode = "none";
278
+ private resolvedFeedbackMode: FeedbackMode = "none";
264
279
  /**
265
- * Resolved {@link MastraIdentityMode}: the identity the chat path's Databricks
280
+ * Resolved AppKit identity mode: the identity the chat path's Databricks
266
281
  * calls run as. Read once at setup so an invalid `genieIdentity` fails the app
267
282
  * boot rather than the first request, and so every request agrees.
268
283
  */
269
- private identityMode: MastraIdentityMode = "user";
284
+ private identityMode: IdentityMode = "user";
270
285
  override async setup(): Promise<void> {
271
286
  // Resolve the identity mode up front so an invalid `genieIdentity` fails the
272
287
  // app boot with a clear message rather than 500-ing the first chat request.
@@ -278,10 +293,10 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
278
293
  });
279
294
  this.config.feedbackMode = this.resolvedFeedbackMode;
280
295
  if (this.config.observability !== false) {
281
- await appkitTelemetry.configureNativeHttpTelemetry({
296
+ await configureNativeHttpTelemetry({
282
297
  // A low-level request without an active semantic span becomes a noisy
283
298
  // standalone trace. Requests inside an agent/tool span remain visible.
284
- outgoingFilter: appkitTelemetry.excludeUnparentedOutgoingHttpTelemetry,
299
+ outgoingFilter: excludeUnparentedOutgoingHttpTelemetry,
285
300
  });
286
301
  await registerAppMlflowTraceInfoProcessor();
287
302
  }
@@ -321,7 +336,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
321
336
  * already in the registry by the time this fires.
322
337
  */
323
338
  private applyLakebaseAutoDefaults(): void {
324
- const hasLakebase = pluginRegistry.instance(this.context, lakebase) !== undefined;
339
+ const hasLakebase = instance(this.context, lakebase) !== undefined;
325
340
  if (!hasLakebase) return;
326
341
  if (this.config.storage === undefined) this.config.storage = true;
327
342
  if (this.config.memory === undefined) this.config.memory = true;
@@ -336,7 +351,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
336
351
  await flushDirectMlflowTracing();
337
352
  } catch (err) {
338
353
  this.logger.warn("error flushing direct MLflow traces", {
339
- error: errorUtils.toError(err),
354
+ error: toError(err),
340
355
  });
341
356
  }
342
357
  }
@@ -495,7 +510,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
495
510
  }
496
511
 
497
512
  /** Resolve the only feedback destination exposed for this plugin mode. */
498
- private feedbackMode(): feedback.FeedbackMode {
513
+ private feedbackMode(): FeedbackMode {
499
514
  return this.resolvedFeedbackMode;
500
515
  }
501
516
 
@@ -543,7 +558,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
543
558
  this.route(router, {
544
559
  name: "models",
545
560
  method: "get",
546
- path: routes.MASTRA_ROUTES.models,
561
+ path: MASTRA_ROUTES.models,
547
562
  handler: async (req, res) => {
548
563
  const result = await this.scopedSelf(req).listModelsResult();
549
564
  if (!result.ok) {
@@ -564,7 +579,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
564
579
  req: express.Request,
565
580
  res: express.Response,
566
581
  ): Promise<void> => {
567
- const requested = stringUtils.firstNonEmpty(req.params.agentId);
582
+ const requested = firstNonEmpty(req.params.agentId);
568
583
  if (requested !== null && !this.built?.agents[requested]) {
569
584
  res.status(404).json({ error: this.unknownAgentMessage(requested) });
570
585
  return;
@@ -587,19 +602,19 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
587
602
  res.json({
588
603
  agentId,
589
604
  model,
590
- displayName: model ? display.toModelDisplayName(model) : null,
605
+ displayName: model ? toModelDisplayName(model) : null,
591
606
  });
592
607
  };
593
608
  this.route(router, {
594
609
  name: "defaultModel",
595
610
  method: "get",
596
- path: routes.MASTRA_ROUTES.defaultModel,
611
+ path: MASTRA_ROUTES.defaultModel,
597
612
  handler: handleDefaultModel,
598
613
  });
599
614
  this.route(router, {
600
615
  name: "defaultModelByAgent",
601
616
  method: "get",
602
- path: `${routes.MASTRA_ROUTES.defaultModel}/:agentId`,
617
+ path: `${MASTRA_ROUTES.defaultModel}/:agentId`,
603
618
  handler: handleDefaultModel,
604
619
  });
605
620
  }
@@ -664,10 +679,10 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
664
679
  this.route(router, {
665
680
  name: "embed",
666
681
  method: "get",
667
- path: `${routes.MASTRA_ROUTES.embed}/:type/:id`,
682
+ path: `${MASTRA_ROUTES.embed}/:type/:id`,
668
683
  handler: async (req, res) => {
669
- const type = stringUtils.firstNonEmpty(req.params.type) ?? "";
670
- const id = stringUtils.firstNonEmpty(req.params.id);
684
+ const type = firstNonEmpty(req.params.type) ?? "";
685
+ const id = firstNonEmpty(req.params.id);
671
686
  const resolve = embedResolvers[type];
672
687
  if (!resolve) {
673
688
  this.logger.warn("embed:unsupported", {
@@ -748,7 +763,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
748
763
  // the upstream status. Log and degrade.
749
764
  this.logger.warn("suggestions:error", {
750
765
  status: result.status,
751
- error: errorUtils.toError(result.message),
766
+ error: toError(result.message),
752
767
  });
753
768
  res.json({ questions: [] });
754
769
  return;
@@ -758,13 +773,13 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
758
773
  this.route(router, {
759
774
  name: "suggestions",
760
775
  method: "get",
761
- path: routes.MASTRA_ROUTES.suggestions,
776
+ path: MASTRA_ROUTES.suggestions,
762
777
  handler: handleSuggestions,
763
778
  });
764
779
  this.route(router, {
765
780
  name: "suggestionsByAgent",
766
781
  method: "get",
767
- path: `${routes.MASTRA_ROUTES.suggestions}/:agentId`,
782
+ path: `${MASTRA_ROUTES.suggestions}/:agentId`,
768
783
  handler: handleSuggestions,
769
784
  });
770
785
  }
@@ -777,11 +792,11 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
777
792
  * written to Mastra Memory.
778
793
  */
779
794
  private registerGenieChatRoutes(router: IAppRouter): void {
780
- const path = (...parts: string[]) => routes.genieRoutePath(":alias", ...parts);
781
- const { chat: chatSegment, messages, suggestions, threads } = routes.MASTRA_ROUTES;
795
+ const path = (...parts: string[]) => genieRoutePath(":alias", ...parts);
796
+ const { chat: chatSegment, messages, suggestions, threads } = MASTRA_ROUTES;
782
797
  /** Resolve the route's alias, answering 404 when no such space is configured. */
783
798
  const spaceFor = (req: express.Request, res: express.Response): GenieChatSpace | undefined => {
784
- const alias = stringUtils.firstNonEmpty(req.params.alias) ?? "";
799
+ const alias = firstNonEmpty(req.params.alias) ?? "";
785
800
  const configured = resolveGenieSpaces(this.config, this.context)[alias];
786
801
  if (configured) return { alias, spaceId: configured.spaceId };
787
802
  res.status(404).json({ error: `Unknown Genie space alias "${alias}"` });
@@ -801,7 +816,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
801
816
  handler: async (req, res) => {
802
817
  const space = spaceFor(req, res);
803
818
  if (!space) return;
804
- const parsed = wire.GenieChatRequestSchema.safeParse(req.body);
819
+ const parsed = GenieChatRequestSchema.safeParse(req.body);
805
820
  if (!parsed.success) {
806
821
  res
807
822
  .status(400)
@@ -835,7 +850,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
835
850
  handler: async (req, res) => {
836
851
  const space = spaceFor(req, res);
837
852
  if (!space) return;
838
- const threadId = stringUtils.firstNonEmpty(req.params.threadId) ?? "";
853
+ const threadId = firstNonEmpty(req.params.threadId) ?? "";
839
854
  const result = await this.asUser(req).genieConversationRead((client) =>
840
855
  listGenieThreadMessages({
841
856
  client,
@@ -857,7 +872,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
857
872
  handler: async (req, res) => {
858
873
  const space = spaceFor(req, res);
859
874
  if (!space) return;
860
- const threadId = stringUtils.firstNonEmpty(req.params.threadId) ?? "";
875
+ const threadId = firstNonEmpty(req.params.threadId) ?? "";
861
876
  const result = await this.asUser(req).genieConversationWrite((client) =>
862
877
  deleteGenieThread(client, space, threadId),
863
878
  );
@@ -880,8 +895,8 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
880
895
  handler: async (req, res) => {
881
896
  const space = spaceFor(req, res);
882
897
  if (!space) return;
883
- const threadId = stringUtils.firstNonEmpty(req.params.threadId) ?? "";
884
- const messageId = stringUtils.firstNonEmpty(req.params.messageId) ?? "";
898
+ const threadId = firstNonEmpty(req.params.threadId) ?? "";
899
+ const messageId = firstNonEmpty(req.params.messageId) ?? "";
885
900
  const result = await this.asUser(req).genieConversationWrite((client) =>
886
901
  deleteGenieThreadMessage(client, space, threadId, messageId),
887
902
  );
@@ -974,14 +989,14 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
974
989
  this.route(router, {
975
990
  name: "feedback",
976
991
  method: "post",
977
- path: routes.MASTRA_ROUTES.feedback,
992
+ path: MASTRA_ROUTES.feedback,
978
993
  handler: async (req, res) => {
979
994
  const mode = this.feedbackMode();
980
995
  if (mode === "none") {
981
996
  res.status(404).json({ ok: false });
982
997
  return;
983
998
  }
984
- const parsed = feedback.MastraFeedbackRequestSchema.safeParse(req.body);
999
+ const parsed = MastraFeedbackRequestSchema.safeParse(req.body);
985
1000
  if (!parsed.success) {
986
1001
  // A Zod issue string quotes the received body back, so only the
987
1002
  // offending field names travel; the full issue list is logged.
@@ -1025,7 +1040,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
1025
1040
  this.route(router, {
1026
1041
  name: "mlflowExperiment",
1027
1042
  method: "get",
1028
- path: routes.MASTRA_ROUTES.mlflowExperiment,
1043
+ path: MASTRA_ROUTES.mlflowExperiment,
1029
1044
  handler: async (req, res) => {
1030
1045
  if (this.feedbackMode() !== "mlflow") {
1031
1046
  res.json({ url: null });
@@ -1089,7 +1104,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
1089
1104
  ): void {
1090
1105
  this.logger.warn(`${operation}:error`, {
1091
1106
  status: result.status,
1092
- error: errorUtils.toError(result.message),
1107
+ error: toError(result.message),
1093
1108
  });
1094
1109
  if (res.headersSent) return;
1095
1110
  res.status(result.status).json({ error: clientMessage });
@@ -1151,7 +1166,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
1151
1166
  if (Object.keys(spaces).length === 0) return { ok: true, data: [] };
1152
1167
  const client = getExecutionContext().client;
1153
1168
  return this.execute((executeSignal) => {
1154
- const combined = asyncUtils.combineAbortSignals(signal, executeSignal);
1169
+ const combined = combineAbortSignals(signal, executeSignal);
1155
1170
  return collectSpaceSuggestions({
1156
1171
  spaces,
1157
1172
  client,
@@ -1169,7 +1184,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
1169
1184
  * (see {@link logFeedback} in `./mlflow.js`).
1170
1185
  */
1171
1186
  private async logFeedback(
1172
- feedback: feedback.MlflowFeedbackRequest,
1187
+ feedback: MlflowFeedbackRequest,
1173
1188
  ): Promise<ExecutionResult<string | undefined>> {
1174
1189
  const ctx = getExecutionContext();
1175
1190
  const sourceId =
@@ -1189,7 +1204,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
1189
1204
  }
1190
1205
 
1191
1206
  /** Send Agent Mode rating and comment directly to the originating Genie message. */
1192
- private sendGenieFeedback(input: feedback.GenieFeedbackRequest): Promise<ExecutionResult<void>> {
1207
+ private sendGenieFeedback(input: GenieFeedbackRequest): Promise<ExecutionResult<void>> {
1193
1208
  const client = getExecutionContext().client;
1194
1209
  return this.execute(
1195
1210
  (signal) =>
@@ -1239,7 +1254,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
1239
1254
  const limit = Math.min(options.limit ?? STATEMENT_ROW_CAP, STATEMENT_ROW_CAP);
1240
1255
  return this.execute(
1241
1256
  async (executeSignal) => {
1242
- const combined = asyncUtils.combineAbortSignals(options.signal, executeSignal);
1257
+ const combined = combineAbortSignals(options.signal, executeSignal);
1243
1258
  try {
1244
1259
  const { data, visualization } = await fetchStatementEmbedData(client, statementId, {
1245
1260
  limit,
@@ -1255,7 +1270,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
1255
1270
  } catch (err) {
1256
1271
  // The Databricks SDK throws on 404; surface as `undefined`
1257
1272
  // so the route maps to a clean HTTP 404 instead of a 500.
1258
- if (errorUtils.errorContext(err).notAccessible) return undefined;
1273
+ if (errorContext(err).notAccessible) return undefined;
1259
1274
  throw err;
1260
1275
  }
1261
1276
  },
@@ -1299,7 +1314,7 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
1299
1314
  fetchChart(chartId, {
1300
1315
  userKey,
1301
1316
  ...(options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}),
1302
- signal: asyncUtils.combineAbortSignals(options.signal, executeSignal) ?? options.signal,
1317
+ signal: combineAbortSignals(options.signal, executeSignal) ?? options.signal,
1303
1318
  }),
1304
1319
  chartFetchDefaults,
1305
1320
  );
@@ -1334,16 +1349,16 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
1334
1349
  if (result.ok) return result.data;
1335
1350
  this.logger.warn("listModels:error", {
1336
1351
  status: result.status,
1337
- error: errorUtils.toError(result.message),
1352
+ error: toError(result.message),
1338
1353
  });
1339
1354
  throw new ExecutionError(MODEL_CATALOGUE_FAILED_MESSAGE);
1340
1355
  }
1341
1356
 
1342
1357
  private async buildAgentAndServer(): Promise<void> {
1343
1358
  const memoryPool = needsLakebase(this.config)
1344
- ? (lakebaseResolver.captureServicePrincipalPool(
1345
- pluginRegistry.require(this.context, lakebase, this.config).exports().pool,
1346
- ) as Pool)
1359
+ ? createMastraLakebasePool(
1360
+ require(this.context, lakebase, this.config).exports().getPgConfig(),
1361
+ )
1347
1362
  : undefined;
1348
1363
  const memoryBuilder = createMemoryBuilder(this.config, memoryPool);
1349
1364
 
@@ -1399,15 +1414,13 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
1399
1414
  // `agent.resumeStream()` errors with "could not find a suspended
1400
1415
  // run" and the approval UI hangs after the user clicks Approve.
1401
1416
  const instanceStorage = memoryBuilder?.instanceStorage();
1402
- // Wire Mastra's tracer into AppKit's global OTel pipeline via
1403
- // `@mastra/otel-bridge`. Mastra spans become native OTel spans on
1404
- // whatever tracer provider `TelemetryManager` registered during
1405
- // `createApp`, so the OTLP endpoint / headers / sampling are
1406
- // env-driven and shared with every other AppKit plugin.
1417
+ // Wire Mastra's tracer into OTel through `@mastra/otel-bridge`. Deployed
1418
+ // Apps use the provider AppKit registered during `createApp`; local direct
1419
+ // MLflow tracing uses its own global provider when no OTLP exporter exists.
1407
1420
  const observability = await buildObservability({
1408
1421
  serviceName: this.name,
1409
1422
  enabled: this.config.observability,
1410
- tracerProvider: await appkitTelemetry.deferredNativeTracerProvider(),
1423
+ tracerProvider: await deferredNativeTracerProvider(),
1411
1424
  });
1412
1425
  // Optional MCP exposure: build a Mastra MCP server from the
1413
1426
  // registered agents (and, opt-in, the ambient tools) and register
@@ -1492,7 +1505,7 @@ type EmbedResolver = (
1492
1505
  function parseTimeoutMs(raw: unknown): number | undefined {
1493
1506
  const v = Array.isArray(raw) ? raw[0] : raw;
1494
1507
  if (typeof v !== "string") return undefined;
1495
- const n = object.toNumber(v);
1508
+ const n = toNumber(v);
1496
1509
  if (n === undefined || n <= 0) return undefined;
1497
1510
  return Math.min(Math.floor(n), MAX_EMBED_POLL_TIMEOUT_MS);
1498
1511
  }
@@ -1507,7 +1520,7 @@ function parseTimeoutMs(raw: unknown): number | undefined {
1507
1520
  function parseStatementLimit(raw: unknown): number | undefined {
1508
1521
  const v = Array.isArray(raw) ? raw[0] : raw;
1509
1522
  if (typeof v !== "string") return undefined;
1510
- const n = object.toNumber(v);
1523
+ const n = toNumber(v);
1511
1524
  if (n === undefined || n < 0) return undefined;
1512
1525
  return Math.floor(n);
1513
1526
  }