@dbx-tools/appkit-mastra 0.9.131 → 0.9.136
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/README.md +138 -104
- package/index.ts +3 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -2
- package/lib/src/config.d.ts +12 -17
- package/lib/src/config.js +5 -4
- package/lib/src/feedback-mode.d.ts +15 -0
- package/lib/src/feedback-mode.js +23 -0
- package/lib/src/genie-chat.d.ts +20 -13
- package/lib/src/genie-chat.js +202 -28
- package/lib/src/memory.js +4 -2
- package/lib/src/mlflow.d.ts +1 -14
- package/lib/src/mlflow.js +1 -25
- package/lib/src/model.d.ts +5 -3
- package/lib/src/model.js +7 -4
- package/lib/src/observability.js +6 -7
- package/lib/src/plugin.d.ts +16 -9
- package/lib/src/plugin.js +92 -28
- package/lib/src/server.d.ts +2 -3
- package/lib/src/server.js +5 -7
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -16
- package/src/config.ts +16 -20
- package/src/feedback-mode.ts +35 -0
- package/src/genie-chat.ts +231 -31
- package/src/memory.ts +3 -1
- package/src/mlflow.ts +1 -27
- package/src/model.ts +12 -5
- package/src/observability.ts +5 -6
- package/src/plugin.ts +104 -30
- package/src/server.ts +4 -6
package/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# @dbx-tools/appkit-mastra
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Host Mastra agents in a Databricks App with AppKit authentication, streaming
|
|
4
|
+
routes, Lakebase-backed memory, Genie tools, model selection, chart and table
|
|
5
|
+
embeds, Genie or MLflow feedback, and MCP exposure.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
Databricks authentication, Lakebase-backed memory, Genie tools, model selection,
|
|
8
|
-
chart and table embeds, MLflow feedback, and MCP exposure.
|
|
9
|
-
|
|
10
|
-
## Quick Start
|
|
7
|
+
## Quick start
|
|
11
8
|
|
|
12
9
|
Add an agent and run its command tools in the default Monty runtime:
|
|
13
10
|
|
|
@@ -25,7 +22,7 @@ await createApp({ plugins: [server(), mastra({ agents: { analyst } })] });
|
|
|
25
22
|
Add Lakebase, Genie, Analytics, or other AppKit plugins when the agent needs
|
|
26
23
|
durable threads or workspace tools.
|
|
27
24
|
|
|
28
|
-
## Choose Mastra
|
|
25
|
+
## Choose Mastra, AppKit Agents, or direct Genie
|
|
29
26
|
|
|
30
27
|
Native AppKit Agents is the shorter path for AppKit-native agent definitions,
|
|
31
28
|
streaming chat, threads, cancellation, and approvals. Choose this package when
|
|
@@ -37,13 +34,19 @@ the application already uses Mastra or needs Mastra-specific capabilities:
|
|
|
37
34
|
ToolProvider plugins stay available without rewriting them.
|
|
38
35
|
- Genie as an agent tool that emits typed progress events, result metadata, and
|
|
39
36
|
delayed chart/data markers into the same assistant turn.
|
|
40
|
-
- A paired React client in [
|
|
37
|
+
- A paired React client in [@dbx-tools/ui-mastra](../../ui/mastra) with model
|
|
41
38
|
picking, thread sidebar, approvals, feedback, exports, and inline embeds.
|
|
42
39
|
- Per-request model override and fuzzy endpoint resolution through
|
|
43
|
-
[
|
|
40
|
+
[@dbx-tools/model](../model), instead of binding every agent to a fixed
|
|
44
41
|
endpoint name.
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
Use direct Genie chat when one Genie space owns the conversation and users don't
|
|
44
|
+
need a supervising agent. Choose Mastra when one turn must combine Genie with
|
|
45
|
+
other tools, approvals, or workflows. Direct Genie keeps conversation history
|
|
46
|
+
in Genie and, when Mastra memory is configured, adds resource-scoped semantic
|
|
47
|
+
recall and saves completed turns to that memory.
|
|
48
|
+
|
|
49
|
+
## Full app example
|
|
47
50
|
|
|
48
51
|
```ts
|
|
49
52
|
import { analytics, createApp, lakebase, server } from "@databricks/appkit";
|
|
@@ -98,7 +101,7 @@ This example provides:
|
|
|
98
101
|
- Lakebase registration automatically enables durable thread storage and vector
|
|
99
102
|
memory unless you opt out.
|
|
100
103
|
|
|
101
|
-
## Agent
|
|
104
|
+
## Agent registration
|
|
102
105
|
|
|
103
106
|
`mastra({ agents })` accepts a single definition, an array, or a record.
|
|
104
107
|
Records are best when clients need stable agent ids:
|
|
@@ -135,7 +138,7 @@ Agents are also told to issue independent tool calls together in one turn and
|
|
|
135
138
|
to keep dependent or conflicting calls sequential. Models that do not support
|
|
136
139
|
parallel tool calls continue through the normal multi-step agent loop.
|
|
137
140
|
|
|
138
|
-
## Typed
|
|
141
|
+
## Typed application request context
|
|
139
142
|
|
|
140
143
|
Use Mastra's native `requestContextSchema` for UI selections that should shape a
|
|
141
144
|
turn, such as a store, workflow, route, or selected entity:
|
|
@@ -170,16 +173,35 @@ The paired UI sends this through Mastra's standard `requestContext` body field.
|
|
|
170
173
|
The agent schema validates it before model execution. AppKit-Mastra removes and
|
|
171
174
|
re-stamps trusted identity, resource, thread, auth, scope, model, and trace keys,
|
|
172
175
|
so application context cannot change conversation ownership or credentials.
|
|
176
|
+
The same native context reaches direct Genie chat, where it is supplied as
|
|
177
|
+
reference data because the Genie Agent Mode API accepts only one user message.
|
|
178
|
+
|
|
179
|
+
## Register application workflows
|
|
180
|
+
|
|
181
|
+
Pass code-defined workflows in plugin config, or let a sibling plugin register
|
|
182
|
+
one before AppKit setup completes:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
mastra({
|
|
186
|
+
workflows: { generatorDemoAssets },
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Scoped mode exposes `POST /api/mastra/route/workflows/:workflowId/stream` in AI
|
|
191
|
+
SDK v7 format while keeping Mastra's stock workflow administration routes
|
|
192
|
+
closed. The route always uses the trusted request context stamped by
|
|
193
|
+
AppKit-Mastra. Start and resume requests must provide fresh OBO context because
|
|
194
|
+
workspace clients and tokens are never persisted in workflow snapshots.
|
|
173
195
|
|
|
174
196
|
`createAgent({ requireToolApproval })` forwards Mastra's native request-level
|
|
175
197
|
approval gate. It may be an async Classifier-backed function that returns `true`
|
|
176
198
|
for calls still needing human review. A tool's own `requireApproval` remains
|
|
177
|
-
authoritative
|
|
199
|
+
authoritative. Configure that native function on the tool when policy should
|
|
178
200
|
allow some calls. Regular agents do not include Agent Controller's durable
|
|
179
201
|
allow/ask/deny permission store, so remembered decisions remain a caller-owned,
|
|
180
202
|
server-side durable policy rather than browser state.
|
|
181
203
|
|
|
182
|
-
## AppKit
|
|
204
|
+
## AppKit toolkits
|
|
183
205
|
|
|
184
206
|
The `tools(plugins)` callback receives a dynamic index of registered AppKit
|
|
185
207
|
tool-provider plugins. Each entry exposes `.toolkit(opts)` with AppKit's public
|
|
@@ -208,11 +230,11 @@ const agent = agents.createAgent({
|
|
|
208
230
|
});
|
|
209
231
|
```
|
|
210
232
|
|
|
211
|
-
Tool calls dispatch back through the owning AppKit plugin, preserving
|
|
212
|
-
and AppKit telemetry behavior. Optional
|
|
213
|
-
you spread their tools.
|
|
233
|
+
Tool calls dispatch back through the owning AppKit plugin, preserving
|
|
234
|
+
on-behalf-of-user (OBO) authentication and AppKit telemetry behavior. Optional
|
|
235
|
+
plugins should be guarded with `?.` when you spread their tools.
|
|
214
236
|
|
|
215
|
-
### Tools
|
|
237
|
+
### Tools flow in, not out
|
|
216
238
|
|
|
217
239
|
The plugin is a tool _consumer_, not an AppKit `ToolProvider`: it deliberately
|
|
218
240
|
implements neither `getAgentTools()` nor `executeAgentTool()`, so its built-in
|
|
@@ -237,7 +259,7 @@ unless `mcp: { tools: true }` names them explicitly. Approval-gated tools you
|
|
|
237
259
|
register yourself are enforced separately: boot fails if one is registered
|
|
238
260
|
without Mastra storage to persist the suspended run.
|
|
239
261
|
|
|
240
|
-
## Memory
|
|
262
|
+
## Memory and storage
|
|
241
263
|
|
|
242
264
|
The `memory` and `storage` config fields can be `false`, `true`, or a concrete
|
|
243
265
|
Mastra Postgres/PgVector config.
|
|
@@ -252,23 +274,26 @@ mastra({
|
|
|
252
274
|
|
|
253
275
|
With `lakebase()` registered, both default to enabled:
|
|
254
276
|
|
|
255
|
-
-
|
|
256
|
-
-
|
|
257
|
-
|
|
277
|
+
- Storage uses a per-agent schema for durable threads and messages.
|
|
278
|
+
- Memory uses a shared vector index with resource-scoped semantic recall across
|
|
279
|
+
the caller's threads and agents.
|
|
280
|
+
- Direct Genie turns read from and write to the default agent's native memory
|
|
281
|
+
instance while Genie retains its own visible conversation history.
|
|
282
|
+
- The existing service-principal pool is captured from `lakebase()` during
|
|
258
283
|
startup, so request-scoped OBO credentials never reach storage work and no
|
|
259
284
|
additional PostgreSQL pool is created.
|
|
260
285
|
|
|
261
286
|
Without `lakebase()`, agents are stateless unless you provide explicit storage
|
|
262
287
|
and memory configs.
|
|
263
288
|
|
|
264
|
-
### Add
|
|
289
|
+
### Add external durable memory tools
|
|
265
290
|
|
|
266
291
|
Register `@dbx-tools/appkit-memory` as a sibling plugin and request
|
|
267
292
|
`plugins.memory?.toolkit()` from the agents that need its `remember` and
|
|
268
293
|
`recall_memory` tools. The memory plugin owns Databricks and Graphiti selection.
|
|
269
294
|
Mastra continues to own only its configured PostgresStore and PgVector.
|
|
270
295
|
|
|
271
|
-
## Workspace
|
|
296
|
+
## Workspace capabilities
|
|
272
297
|
|
|
273
298
|
Every `agents.createAgent()` gets a default Mastra `Workspace` from
|
|
274
299
|
`workspaces.databricksWorkspace()`. A workspace can provide file access, skill
|
|
@@ -277,6 +302,13 @@ discovery, a command sandbox, or any combination. The default mounts
|
|
|
277
302
|
configured Assistant skill paths, and provides Monty for isolated Python
|
|
278
303
|
command execution.
|
|
279
304
|
|
|
305
|
+
Use AppKit's Files plugin when application routes and UI components need
|
|
306
|
+
governed upload, download, or volume access. Use a Mastra workspace when the
|
|
307
|
+
agent itself needs files, skills, or command execution during a turn. A
|
|
308
|
+
`FileSystem` from [@dbx-tools/databricks](../databricks) or
|
|
309
|
+
[@dbx-tools/fs](../fs) can be mounted into that workspace with
|
|
310
|
+
`filesystems(fs)`.
|
|
311
|
+
|
|
280
312
|
Pass paths directly when an agent needs a different filesystem scope:
|
|
281
313
|
|
|
282
314
|
```ts
|
|
@@ -318,7 +350,7 @@ const workspace = workspaces.databricksWorkspace({
|
|
|
318
350
|
Paths are file-only unless `skills` lists relative Mastra skill paths within
|
|
319
351
|
that included path. At workspace level, `skills` uses Mastra's native path list
|
|
320
352
|
or resolver. An empty list retains configured mounts without exposing skills.
|
|
321
|
-
`writable` controls whether the filesystem attempts mutations
|
|
353
|
+
`writable` controls whether the filesystem attempts mutations. Databricks
|
|
322
354
|
permissions still decide whether an operation succeeds. `mount` can expose the
|
|
323
355
|
path at a different Mastra path when required.
|
|
324
356
|
|
|
@@ -378,7 +410,7 @@ remote skills use their native tools without duplicating their virtual mounts
|
|
|
378
410
|
in workspace search. Set the workspace's `skills` to an empty list when the
|
|
379
411
|
workspace should expose no skills.
|
|
380
412
|
|
|
381
|
-
### Cache
|
|
413
|
+
### Cache workspace metadata
|
|
382
414
|
|
|
383
415
|
Register `filesCache()` to reuse Databricks directory metadata across page
|
|
384
416
|
refreshes and later turns:
|
|
@@ -405,7 +437,7 @@ const workspace = workspaces.databricksWorkspace({
|
|
|
405
437
|
});
|
|
406
438
|
```
|
|
407
439
|
|
|
408
|
-
### Configure
|
|
440
|
+
### Configure file approvals
|
|
409
441
|
|
|
410
442
|
Workspace tools are enabled and run without approval by default. This applies to
|
|
411
443
|
file mutations and command execution with either Monty or a supplied sandbox
|
|
@@ -434,7 +466,7 @@ are separate, so gate or disable
|
|
|
434
466
|
`WORKSPACE_TOOLS.SANDBOX.EXECUTE_COMMAND` when commands must not bypass file
|
|
435
467
|
policies. Cached metadata never grants Databricks access.
|
|
436
468
|
|
|
437
|
-
## Workspace
|
|
469
|
+
## Workspace sandbox
|
|
438
470
|
|
|
439
471
|
Auto-created workspaces use Monty by default. Supply any native Mastra
|
|
440
472
|
`WorkspaceSandbox` or request-scoped resolver to use a remote transport:
|
|
@@ -486,7 +518,7 @@ const localAgent = agents.createAgent({
|
|
|
486
518
|
An agent-level workspace overrides the plugin-level sandbox setting. Returning
|
|
487
519
|
`undefined` from a workspace resolver disables the workspace for that agent.
|
|
488
520
|
|
|
489
|
-
### Batch
|
|
521
|
+
### Batch tools with Code Mode
|
|
490
522
|
|
|
491
523
|
Mastra Code Mode is enabled by default when an agent has executable tools. It
|
|
492
524
|
adds an `execute_typescript` tool so the model can batch independent calls,
|
|
@@ -508,7 +540,7 @@ calls an exposed Lakebox-backed tool.
|
|
|
508
540
|
|
|
509
541
|
Callers may also use native Mastra `createCodeMode` directly when they want
|
|
510
542
|
multiple explicitly scoped orchestration tools, or when the TypeScript program
|
|
511
|
-
itself must
|
|
543
|
+
itself must run in a supplied Sandbox:
|
|
512
544
|
|
|
513
545
|
```ts
|
|
514
546
|
const sales = createCodeMode({
|
|
@@ -531,11 +563,11 @@ const agent = new Agent({
|
|
|
531
563
|
});
|
|
532
564
|
```
|
|
533
565
|
|
|
534
|
-
This is native Mastra `createCodeMode
|
|
566
|
+
This is native Mastra `createCodeMode`. The plugin does not wrap or re-export it.
|
|
535
567
|
Set plugin `codeMode: false` to disable the automatic Code Mode, or pass
|
|
536
568
|
`{ id, timeout }` to tune its generated tool.
|
|
537
569
|
|
|
538
|
-
## Remote
|
|
570
|
+
## Remote skills
|
|
539
571
|
|
|
540
572
|
Use `remoteSkills` to install a curated skill set when the files are not already
|
|
541
573
|
in the Databricks workspace. Sources can be a GitHub `owner/repo`, a git URL, a
|
|
@@ -615,13 +647,10 @@ mastra({
|
|
|
615
647
|
});
|
|
616
648
|
```
|
|
617
649
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
downloads them. That matters because a deployed Databricks App container has no
|
|
623
|
-
`databricks` CLI - the old CLI shell-out simply never produced skills there.
|
|
624
|
-
No Databricks auth is involved either, since the repo is public.
|
|
650
|
+
The source reads the public
|
|
651
|
+
[databricks/databricks-agent-skills](https://github.com/databricks/databricks-agent-skills)
|
|
652
|
+
repository's generated `manifest.json` and downloads the selected skill files.
|
|
653
|
+
It doesn't require the Databricks CLI or Databricks authentication.
|
|
625
654
|
|
|
626
655
|
Per-source options for `"aitools"`:
|
|
627
656
|
|
|
@@ -636,18 +665,18 @@ destination. These trees are supplied to every agent as standard agent-level
|
|
|
636
665
|
skills rather than workspace-search roots. Local filesystem mounts remain
|
|
637
666
|
available below `/.skills` when a Databricks destination is unavailable.
|
|
638
667
|
|
|
639
|
-
## Genie
|
|
668
|
+
## Genie tools
|
|
640
669
|
|
|
641
670
|
`genie.buildGenieTools()` and `plugins.genie.toolkit()` expose tools for:
|
|
642
671
|
|
|
643
|
-
-
|
|
644
|
-
-
|
|
645
|
-
-
|
|
646
|
-
-
|
|
672
|
+
- Asking a configured Genie space.
|
|
673
|
+
- Reading space descriptions and serialized space metadata.
|
|
674
|
+
- Fetching statement rows by `statement_id`.
|
|
675
|
+
- Preparing charts from Genie result sets.
|
|
647
676
|
|
|
648
677
|
The central agent drives those tools directly. Genie events stream through the
|
|
649
678
|
Mastra writer using the shared contract from
|
|
650
|
-
[
|
|
679
|
+
[@dbx-tools/shared-mastra](../../shared/mastra), so clients can show thinking,
|
|
651
680
|
SQL, row counts, summaries, chart markers, and data markers as the turn runs.
|
|
652
681
|
Independent `ask_genie` calls can run in parallel. One invocation owns the
|
|
653
682
|
thread's reusable Genie conversation while overlapping invocations use isolated
|
|
@@ -673,7 +702,7 @@ const agent = agents.createAgent({
|
|
|
673
702
|
});
|
|
674
703
|
```
|
|
675
704
|
|
|
676
|
-
### Direct Genie
|
|
705
|
+
### Direct Genie chat
|
|
677
706
|
|
|
678
707
|
The plugin also exposes a Genie-only transport for the paired Mastra UI. It
|
|
679
708
|
keeps the standard AI SDK `UIMessage` stream and the same tool, thought, table,
|
|
@@ -687,8 +716,9 @@ import { MastraChat } from "@dbx-tools/ui-mastra/react";
|
|
|
687
716
|
|
|
688
717
|
The alias must exist in `genieSpaces`. Genie owns the state in this mode:
|
|
689
718
|
conversations are thread IDs and Genie messages are projected into the
|
|
690
|
-
transcript.
|
|
691
|
-
agent
|
|
719
|
+
transcript. No supervisor agent runs. When Mastra memory is configured, direct
|
|
720
|
+
turns use the default agent's native memory instance for resource-scoped
|
|
721
|
+
semantic recall and save completed question-answer pairs back to it.
|
|
692
722
|
|
|
693
723
|
Direct Genie chat always uses AppKit's OBO user context, matching the native
|
|
694
724
|
AppKit Genie plugin. Service-principal conversations cannot safely back a
|
|
@@ -702,7 +732,7 @@ Direct turns require the
|
|
|
702
732
|
never fall back to the classic start/create/get-message polling flow, and
|
|
703
733
|
history comes only from the Agent API conversation-items endpoint. The GA
|
|
704
734
|
space conversation-list endpoint is used only to discover conversations marked
|
|
705
|
-
`GENIE_CONVERSATION_TYPE_AGENT
|
|
735
|
+
`GENIE_CONVERSATION_TYPE_AGENT`. The GA delete endpoints provide the management
|
|
706
736
|
operations that the Agent API does not expose.
|
|
707
737
|
|
|
708
738
|
Agent Mode receives Genie's visualization tool. When Genie emits a
|
|
@@ -722,7 +752,7 @@ Operational limits:
|
|
|
722
752
|
- Aborting the browser stream cancels that request instead of leaving a durable
|
|
723
753
|
Mastra run to reconnect.
|
|
724
754
|
|
|
725
|
-
## Charts
|
|
755
|
+
## Charts and data embeds
|
|
726
756
|
|
|
727
757
|
`chart.prepareChart()` mints a chart id immediately, caches an in-progress
|
|
728
758
|
record, resolves the data in the background, and stores a terminal chart or
|
|
@@ -758,10 +788,10 @@ Agents can return `[chart:<id>]` and `[data:<statement_id>]` markers in prose.
|
|
|
758
788
|
The embed route resolves them later, which avoids forcing the language model to
|
|
759
789
|
inline large tables or wait for chart planning before continuing its answer.
|
|
760
790
|
Agent Mode and polling query attachments carry statement ids when Databricks
|
|
761
|
-
returns them. Direct Genie chat
|
|
791
|
+
returns them. Direct Genie chat also uses
|
|
762
792
|
`[visualization:<statement_id>]` for AppKit UI's native Genie visualization.
|
|
763
793
|
|
|
764
|
-
### Chart
|
|
794
|
+
### Chart types and hand-written charts
|
|
765
795
|
|
|
766
796
|
The planner does not emit a raw Echarts option. It fills a small plan (chart
|
|
767
797
|
type, categories, series) that `planToEchartsOption` expands, so tooltip,
|
|
@@ -796,10 +826,10 @@ Prefer a listed type whenever one fits. `custom` trades the shared defaults for
|
|
|
796
826
|
reach, so it is the answer for an unsupported chart shape, not a way to restyle
|
|
797
827
|
a supported one.
|
|
798
828
|
|
|
799
|
-
### Brand
|
|
829
|
+
### Brand the charts
|
|
800
830
|
|
|
801
831
|
Pass a `brand` to the plugin to theme every generated chart with your brand's
|
|
802
|
-
palette and font
|
|
832
|
+
palette and font. Omit it for the default Echarts look.
|
|
803
833
|
|
|
804
834
|
```ts
|
|
805
835
|
import { brandUtils } from "@dbx-tools/shared-core";
|
|
@@ -820,24 +850,24 @@ read later in a browser whose light/dark theme the server cannot know, so the
|
|
|
820
850
|
brand's single (light) foreground would produce near-black labels on a dark chat
|
|
821
851
|
surface. The renderer resolves tick labels, axis names, grid lines, and the
|
|
822
852
|
tooltip from AppKit's live CSS tokens instead - see
|
|
823
|
-
[
|
|
824
|
-
same in either mode
|
|
853
|
+
[@dbx-tools/ui-mastra](../../ui/mastra)'s chart theming. Brand identity is the
|
|
854
|
+
same in either mode. Chrome is not.
|
|
825
855
|
|
|
826
|
-
## Model
|
|
856
|
+
## Model selection
|
|
827
857
|
|
|
828
858
|
`model.buildModel()` adapts the generic resolver from
|
|
829
|
-
[
|
|
859
|
+
[@dbx-tools/model](../model) to Mastra, then constructs a request-scoped
|
|
830
860
|
Vercel AI SDK ProviderV4 model through
|
|
831
|
-
[
|
|
861
|
+
[@dbx-tools/model-protocol](../model-protocol). It resolves the model per
|
|
832
862
|
request, so OBO identity and request-specific overrides stay isolated.
|
|
833
863
|
|
|
834
864
|
Model priority is:
|
|
835
865
|
|
|
836
|
-
1.
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
866
|
+
1. Request override (`X-Mastra-Model`, `?model=`, body `model` / `modelId`).
|
|
867
|
+
1. Per-agent `model`.
|
|
868
|
+
1. Plugin `defaultModel`.
|
|
869
|
+
1. `DATABRICKS_SERVING_ENDPOINT_NAME`.
|
|
870
|
+
1. Highest-ranked available GPT from the live workspace catalogue,
|
|
841
871
|
then the highest-ranked live chat model when no GPT is deployed.
|
|
842
872
|
|
|
843
873
|
The unconfigured default is live-only and fails clearly when the workspace has
|
|
@@ -859,7 +889,7 @@ building custom routes that should behave like the plugin's `/models` and stream
|
|
|
859
889
|
routes.
|
|
860
890
|
|
|
861
891
|
The Chat provider uses a provider-local fetch from
|
|
862
|
-
`@dbx-tools/model-protocol
|
|
892
|
+
`@dbx-tools/model-protocol`. Mastra does not patch `globalThis.fetch`. The
|
|
863
893
|
shared fetch repairs provider-specific wire requirements for both
|
|
864
894
|
`fetch(url, { body })` and `fetch(new Request(...))`. In particular,
|
|
865
895
|
Databricks-hosted GPT 5.6 Chat Completions with function tools receives
|
|
@@ -883,14 +913,14 @@ without waiting on the `/models` catalogue (so it never flashes a raw id). A
|
|
|
883
913
|
`:agentId` that is not registered returns `404` with the registered ids, the
|
|
884
914
|
same as the history and threads routes.
|
|
885
915
|
|
|
886
|
-
## Threads,
|
|
916
|
+
## Threads, history, and suggestions
|
|
887
917
|
|
|
888
918
|
When storage is enabled, the plugin provides route helpers and in-process
|
|
889
919
|
functions for conversation management:
|
|
890
920
|
|
|
891
|
-
- `history.loadHistory()` and `history.clearHistory()` read or clear one thread
|
|
921
|
+
- `history.loadHistory()` and `history.clearHistory()` read or clear one thread.
|
|
892
922
|
- `threads.listThreads()`, `threads.renameThread()`, and
|
|
893
|
-
`threads.deleteThread()` operate on the caller's scoped conversations
|
|
923
|
+
`threads.deleteThread()` operate on the caller's scoped conversations.
|
|
894
924
|
- `genie.collectSpaceSuggestions()` reads starter questions from the configured
|
|
895
925
|
Genie space.
|
|
896
926
|
|
|
@@ -898,7 +928,7 @@ The plugin resolves the active thread from `x-mastra-thread-id`, `?threadId=`,
|
|
|
898
928
|
or a per-session fallback cookie. That keeps streaming, history, and clear
|
|
899
929
|
operations aligned around the same conversation id.
|
|
900
930
|
|
|
901
|
-
## Evaluate
|
|
931
|
+
## Evaluate in process
|
|
902
932
|
|
|
903
933
|
`eval.createMastraEvalDriver()` adapts a Mastra agent's native `generate()`
|
|
904
934
|
result to AppKit 0.81's `EvalDriver` contract without reducing a chat stream:
|
|
@@ -920,10 +950,13 @@ MLflow reporting, OTel tracing, or the official AI SDK chat route.
|
|
|
920
950
|
## Feedback and observability
|
|
921
951
|
|
|
922
952
|
`observability.buildObservability()` wires Mastra tracing when OTLP export is
|
|
923
|
-
configured. `
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
953
|
+
configured. `feedbackMode` is the only feedback setting:
|
|
954
|
+
|
|
955
|
+
- `auto` prefers direct Genie feedback when Genie Agent Mode and a space are
|
|
956
|
+
available, otherwise MLflow when tracing is configured, otherwise none.
|
|
957
|
+
- `genie` or `mlflow` selects that destination and fails startup when it is not
|
|
958
|
+
available.
|
|
959
|
+
- `none` disables feedback.
|
|
927
960
|
|
|
928
961
|
`telemetry.attachChatTurnTelemetry()` writes each chat request and response to
|
|
929
962
|
the exported root span so MLflow's UC `*_trace_unified` view can display the
|
|
@@ -961,16 +994,18 @@ attribute.
|
|
|
961
994
|
```ts
|
|
962
995
|
mastra({
|
|
963
996
|
agents: analyst,
|
|
964
|
-
|
|
997
|
+
feedbackMode: "auto",
|
|
965
998
|
});
|
|
966
999
|
```
|
|
967
1000
|
|
|
968
|
-
|
|
1001
|
+
In Genie Agent Mode, the UI sends Rating and Comment to the originating Genie
|
|
1002
|
+
message and displays the original Request in the feedback dialog. In MLflow
|
|
1003
|
+
mode, `mlflow.logFeedback()` logs a human assessment against the active trace.
|
|
969
1004
|
On Apps UC traces it reads the experiment's
|
|
970
1005
|
`mlflow.experiment.databricksTraceDestinationPath` tag (or the spans-table tag)
|
|
971
1006
|
so the assessment URI matches the row the experiment UI shows. The response
|
|
972
1007
|
header name and request/response schemas live in
|
|
973
|
-
[
|
|
1008
|
+
[@dbx-tools/shared-mastra](../../shared/mastra).
|
|
974
1009
|
|
|
975
1010
|
Outside a Databricks App, an experiment id automatically enables direct MLflow
|
|
976
1011
|
tracing. The plugin initializes the MLflow Node SDK, injects
|
|
@@ -1034,18 +1069,18 @@ the global provider AppKit already owns and writes to a different store.
|
|
|
1034
1069
|
|
|
1035
1070
|
Success in the boot log looks like:
|
|
1036
1071
|
|
|
1037
|
-
```
|
|
1072
|
+
```text
|
|
1038
1073
|
[observability] Mastra observability wired through OTel bridge {
|
|
1039
|
-
otelBase: 'http://localhost:4314',
|
|
1074
|
+
otelBase: 'http://localhost:4314', mlflowAvailable: true, observability: 'mlflow'
|
|
1040
1075
|
}
|
|
1041
1076
|
```
|
|
1042
1077
|
|
|
1043
1078
|
Verify with SQL against the UC `*_trace_unified` view (the REST
|
|
1044
1079
|
`traces/search` API only covers the experiment store, not UC-backed traces).
|
|
1045
|
-
Schema names with hyphens need backticks
|
|
1080
|
+
Schema names with hyphens need backticks. `attributes` is a `VARIANT`, so use
|
|
1046
1081
|
`attributes:['key']::string` rather than `map_keys()`.
|
|
1047
1082
|
|
|
1048
|
-
## MCP
|
|
1083
|
+
## MCP exposure
|
|
1049
1084
|
|
|
1050
1085
|
`mcp.buildMcpServer()` exposes registered agents as MCP tools by default. The
|
|
1051
1086
|
AppKit plugin publishes clean aliases under its base path:
|
|
@@ -1064,7 +1099,7 @@ mastra({
|
|
|
1064
1099
|
Use `mcp: false` to disable MCP. Turn on `tools: true` only for ambient tools
|
|
1065
1100
|
that are safe outside an in-process chat turn.
|
|
1066
1101
|
|
|
1067
|
-
##
|
|
1102
|
+
## Drive a turn outside the routes
|
|
1068
1103
|
|
|
1069
1104
|
Another plugin (or a scheduled job) can run an agent turn directly, but a raw
|
|
1070
1105
|
`agent.generate(prompt)` loses everything the HTTP middleware stamps - most
|
|
@@ -1087,11 +1122,11 @@ const result = await mastra.getDefault().generate(prompt, { requestContext });
|
|
|
1087
1122
|
The AppKit user, the memory thread / resource pair, and a request id (so the
|
|
1088
1123
|
turn's spans join up in traces) are stamped exactly as the request middleware
|
|
1089
1124
|
stamps them. Call it inside an `asUser(req)` scope to inherit the caller's OBO
|
|
1090
|
-
identity
|
|
1091
|
-
[
|
|
1125
|
+
identity. Outside one it resolves to the service principal.
|
|
1126
|
+
[@dbx-tools/teams](../teams) uses this so a Teams card turn has the same tool
|
|
1092
1127
|
reach - and therefore the same answer - as a chat turn.
|
|
1093
1128
|
|
|
1094
|
-
## API
|
|
1129
|
+
## API gate
|
|
1095
1130
|
|
|
1096
1131
|
The stock `@mastra/express` app has broad management routes. The plugin's
|
|
1097
1132
|
default `apiAccess: "scoped"` allows only the chat, read-only metadata,
|
|
@@ -1104,7 +1139,7 @@ logic that need the same allowlist.
|
|
|
1104
1139
|
## Routes
|
|
1105
1140
|
|
|
1106
1141
|
Mounted under the plugin base path, which is `/api/mastra` unless you override
|
|
1107
|
-
`name`. Product-specific routes use AppKit's `route()` helper
|
|
1142
|
+
`name`. Product-specific routes use AppKit's `route()` helper. Chat and memory
|
|
1108
1143
|
use Mastra's native route surfaces behind the same scoped request-context gate.
|
|
1109
1144
|
|
|
1110
1145
|
| Method | Path | Purpose |
|
|
@@ -1122,13 +1157,13 @@ use Mastra's native route surfaces behind the same scoped request-context gate.
|
|
|
1122
1157
|
| `GET` / `PATCH` / `DELETE` | `/memory/threads[...]` | Native Mastra resource-scoped conversation history and thread management. |
|
|
1123
1158
|
| `POST` | `/memory/messages/delete` | Native message deletion used before regenerating a response. |
|
|
1124
1159
|
| `GET` | `/agents/:agentId/suspended-runs` | Native persisted approval discovery after a reload or restart. |
|
|
1125
|
-
| `POST` | `/route/feedback` |
|
|
1126
|
-
| `GET` | `/route/mlflow-experiment` | Return the experiment URL only when the active viewer has effective `CAN_MANAGE
|
|
1160
|
+
| `POST` | `/route/feedback` | Send feedback to the resolved Genie or MLflow destination. `404` when feedback mode is none. |
|
|
1161
|
+
| `GET` | `/route/mlflow-experiment` | Return the experiment URL only when the active viewer has effective `CAN_MANAGE`. Otherwise, return `{ "url": null }`. |
|
|
1127
1162
|
| `POST` / `GET` | `/mcp`, `/sse`, `/messages` | MCP transports, when `mcp` is enabled. |
|
|
1128
1163
|
|
|
1129
1164
|
The UI consumes `/chat/:agentId` with the AI SDK's `DefaultChatTransport`.
|
|
1130
1165
|
|
|
1131
|
-
## Environment
|
|
1166
|
+
## Environment variables
|
|
1132
1167
|
|
|
1133
1168
|
Every value can also be set through plugin config, which wins. These are the
|
|
1134
1169
|
fallbacks, so a deployment that already follows AppKit's Databricks env naming
|
|
@@ -1136,15 +1171,15 @@ needs no extra wiring.
|
|
|
1136
1171
|
|
|
1137
1172
|
| Variable | Effect |
|
|
1138
1173
|
| ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1139
|
-
| `DATABRICKS_SERVING_ENDPOINT_NAME` | Optional model override used when neither the agent nor `defaultModel` names one
|
|
1174
|
+
| `DATABRICKS_SERVING_ENDPOINT_NAME` | Optional model override used when neither the agent nor `defaultModel` names one. Omit for live highest-rank selection. |
|
|
1140
1175
|
| `DATABRICKS_GENIE_SPACE_ID` | Genie space registered under the `default` alias. |
|
|
1141
1176
|
| `MASTRA_GENIE_IDENTITY` | `user` (default, OBO), `service-principal`, or `auto` for the agents' Databricks calls. |
|
|
1142
1177
|
| `OTEL_EXPORTER_OTLP_ENDPOINT`, `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | Presence of either turns Mastra tracing on when `observability` is unset. On Apps, the telemetry sidecar injects these. |
|
|
1143
1178
|
| `OTEL_PROPAGATORS` | Set to `none` on Databricks Apps. The plugin disables extraction and injection before serving requests while retaining local async span parenting. |
|
|
1144
|
-
| `MLFLOW_EXPERIMENT_ID`, `MLFLOW_EXPERIMENT_NAME` |
|
|
1179
|
+
| `MLFLOW_EXPERIMENT_ID`, `MLFLOW_EXPERIMENT_NAME` | Makes MLflow available to automatic or explicit MLflow feedback mode. Assessments read the experiment's UC trace destination tag. |
|
|
1145
1180
|
| `MLFLOW_UC_TRACE_PREFIX` | Optional override for the UC table prefix. Omit to use the experiment tag. |
|
|
1146
1181
|
|
|
1147
|
-
## Configuration
|
|
1182
|
+
## Configuration reference
|
|
1148
1183
|
|
|
1149
1184
|
The main plugin options are:
|
|
1150
1185
|
|
|
@@ -1155,13 +1190,13 @@ The main plugin options are:
|
|
|
1155
1190
|
- `storage` and `memory` accept `true`, `false`, or concrete Mastra Postgres /
|
|
1156
1191
|
PgVector options. `true` resolves from `lakebase()` when present.
|
|
1157
1192
|
- `sandbox` defaults to Monty for auto-created workspaces. `false` disables
|
|
1158
|
-
command execution
|
|
1193
|
+
command execution. `true` or `"monty"` selects Monty. A native Mastra
|
|
1159
1194
|
sandbox or resolver supplies another transport.
|
|
1160
1195
|
- `codeMode` exposes all executable tools available to the current request,
|
|
1161
1196
|
including enabled native workspace tools, through native Mastra Code Mode. It
|
|
1162
1197
|
defaults on when such tools exist, selecting isolated-vm once at startup and
|
|
1163
1198
|
falling back to QuickJS only when unavailable. Both transports support
|
|
1164
|
-
concurrent external calls without SSH
|
|
1199
|
+
concurrent external calls without SSH. An SSH connection is needed only when
|
|
1165
1200
|
an exposed SSH-backed tool is called. Pass `false` to disable it.
|
|
1166
1201
|
- `workspaceSkills` enables Mastra's native on-demand skill search by default.
|
|
1167
1202
|
Pass `false` to disable it or an object with `topK`, `minScore`, and `ttlMs`
|
|
@@ -1186,9 +1221,8 @@ The main plugin options are:
|
|
|
1186
1221
|
preview-toggle responses fall back automatically.
|
|
1187
1222
|
- `defaultModel`, `modelOverride`, and `modelFuzzyMatch` control how loose model
|
|
1188
1223
|
names are resolved through Databricks Model Serving.
|
|
1189
|
-
- `
|
|
1190
|
-
|
|
1191
|
-
Explicit `true` fails startup unless an experiment id or name is configured.
|
|
1224
|
+
- `feedbackMode` is `auto`, `genie`, `mlflow`, or `none`. Explicit unavailable
|
|
1225
|
+
destinations fail startup.
|
|
1192
1226
|
- `mcp` controls whether agents are exposed as MCP tools and how that server is
|
|
1193
1227
|
named.
|
|
1194
1228
|
- `genieIdentity` selects credentials for model discovery, Genie calls, and
|
|
@@ -1203,7 +1237,7 @@ The main plugin options are:
|
|
|
1203
1237
|
deployed apps.
|
|
1204
1238
|
|
|
1205
1239
|
Clients that call these routes can import the browser-safe schemas from
|
|
1206
|
-
[
|
|
1240
|
+
[@dbx-tools/shared-mastra](../../shared/mastra).
|
|
1207
1241
|
|
|
1208
1242
|
## Modules
|
|
1209
1243
|
|
|
@@ -1232,14 +1266,14 @@ Clients that call these routes can import the browser-safe schemas from
|
|
|
1232
1266
|
- `montySandbox` - Python-only Pydantic Monty fallback using Node subprocess
|
|
1233
1267
|
workers.
|
|
1234
1268
|
- `workspaces` / `filesystems` - native Mastra workspace configuration from
|
|
1235
|
-
Databricks paths, opt-in user-scoped temp paths, and caller-supplied mounts
|
|
1269
|
+
Databricks paths, opt-in user-scoped temp paths, and caller-supplied mounts.
|
|
1236
1270
|
`filesystems(fs)` wraps any `@dbx-tools/shared-fs` `FileSystem` (including
|
|
1237
1271
|
`@dbx-tools/databricks` / `@dbx-tools/fs`) as a Mastra mount.
|
|
1238
1272
|
- `remote-skills` - startup provisioning of remote `SKILL.md` sources. The
|
|
1239
1273
|
`"aitools"` constant reads Databricks' public skill repo through a daily
|
|
1240
1274
|
`@dbx-tools/cache` snapshot and serves one shared in-memory
|
|
1241
1275
|
`/.databricks/skills` tree. Other sources go through the optional `skills` CLI
|
|
1242
|
-
or a direct fetch. Every source keeps a process-memory standard-skill copy
|
|
1276
|
+
or a direct fetch. Every source keeps a process-memory standard-skill copy.
|
|
1243
1277
|
Databricks persistence and read-only local mounts are storage options, not
|
|
1244
1278
|
runtime search roots. `refreshTtlMs` overrides the source default.
|
|
1245
1279
|
- `mcp` - MCP server construction.
|
|
@@ -1249,7 +1283,7 @@ Clients that call these routes can import the browser-safe schemas from
|
|
|
1249
1283
|
and stale chart-id input cleanup.
|
|
1250
1284
|
|
|
1251
1285
|
Browser-facing wire types are in
|
|
1252
|
-
[
|
|
1253
|
-
[
|
|
1254
|
-
are in [
|
|
1255
|
-
surface is [
|
|
1286
|
+
[@dbx-tools/shared-mastra](../../shared/mastra). Genie event contracts are in
|
|
1287
|
+
[@dbx-tools/shared-genie](../../shared/genie). Model request/result contracts
|
|
1288
|
+
are in [@dbx-tools/shared-model](../../shared/model). The matching React chat
|
|
1289
|
+
surface is [@dbx-tools/ui-mastra](../../ui/mastra).
|
package/index.ts
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export const PACKAGE_IDENTIFIER = "@dbx-tools/appkit-mastra";
|
|
6
|
-
export const PACKAGE_VERSION = "0.9.
|
|
6
|
+
export const PACKAGE_VERSION = "0.9.136";
|
|
7
7
|
export * as agents from "./src/agents.ts";
|
|
8
8
|
export * as chart from "./src/chart.ts";
|
|
9
9
|
export * as chat from "./src/chat.ts";
|
|
10
10
|
export * as config from "./src/config.ts";
|
|
11
11
|
export * as defaults from "./src/defaults.ts";
|
|
12
12
|
export * as evaluation from "./src/evaluation.ts";
|
|
13
|
+
export * as feedbackMode from "./src/feedback-mode.ts";
|
|
13
14
|
export * as filesystems from "./src/filesystems.ts";
|
|
14
15
|
export * as genie from "./src/genie.ts";
|
|
15
16
|
export * as genieChat from "./src/genie-chat.ts";
|
|
@@ -45,6 +46,7 @@ export { MASTRA_USER_KEY, MASTRA_USER_NAME_KEY, MASTRA_USER_EMAIL_KEY, MASTRA_AU
|
|
|
45
46
|
export type { User, MastraMemoryConfig, MastraWorkspaceSkillsConfig, MastraCodeModeConfig, MastraMcpConfig, MastraPluginConfig } from "./src/config.ts";
|
|
46
47
|
export { modelCatalogueDefaults, genieSuggestionDefaults, genieConversationReadDefaults, genieConversationWriteDefaults, statementDataDefaults, chartFetchDefaults, feedbackWriteDefaults } from "./src/defaults.ts";
|
|
47
48
|
export type { MastraEvalDriverOptions } from "./src/evaluation.ts";
|
|
49
|
+
export type { FeedbackAvailability } from "./src/feedback-mode.ts";
|
|
48
50
|
export { MastraFileSystemAdapter, MountedCompositeFilesystem } from "./src/filesystems.ts";
|
|
49
51
|
export type { MastraFileSystemAdapterOptions } from "./src/filesystems.ts";
|
|
50
52
|
export { DEFAULT_GENIE_ALIAS, GENIE_INSTRUCTIONS } from "./src/genie.ts";
|