@dbx-tools/appkit-mastra 0.1.78 → 0.1.79
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 +23 -54
- package/dist/index.d.ts +50 -326
- package/dist/index.js +191 -617
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -143,46 +143,6 @@ defining a same-named tool in `config.tools` (or a per-agent `tools`), and
|
|
|
143
143
|
reuse it programmatically via the exported `summarizeText(config, text,
|
|
144
144
|
opts)` / `buildSummarizeTool(config)`.
|
|
145
145
|
|
|
146
|
-
### Managed Memory (Databricks Agent Memory, Beta)
|
|
147
|
-
|
|
148
|
-
`managedMemory` swaps the Postgres `PgVector` semantic-recall layer for
|
|
149
|
-
[Databricks Managed Agent Memory](https://docs.databricks.com/aws/en/generative-ai/agent-framework/managed-memory)
|
|
150
|
-
- a Unity Catalog memory-store. When active, every agent gets two
|
|
151
|
-
ambient tools (`save_memory`, `search_memory`) plus an auto-recall input
|
|
152
|
-
processor that searches the user's entries with the latest message and
|
|
153
|
-
injects the top matches before each turn. Entries are scoped per-user
|
|
154
|
-
via OBO (the model never sets the scope). The thread / message
|
|
155
|
-
transcript still uses `PostgresStore` only when `lakebase()` is
|
|
156
|
-
registered - managed memory does not pull in Lakebase.
|
|
157
|
-
|
|
158
|
-
```ts
|
|
159
|
-
mastra({
|
|
160
|
-
// Prefer-if-available: enabled automatically when MEMORY_STORE is set
|
|
161
|
-
// and the workspace exposes the memory-stores API; otherwise PgVector.
|
|
162
|
-
managedMemory: true, // or { store, topK, autoCreate, recall, tools }
|
|
163
|
-
});
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
The store is a three-level Unity Catalog name (`catalog.schema.name`),
|
|
167
|
-
resolved from `managedMemory.store` or the `MEMORY_STORE` env var.
|
|
168
|
-
Enable semantics:
|
|
169
|
-
|
|
170
|
-
- **omitted** (default, prefer-if-available): on only when `MEMORY_STORE`
|
|
171
|
-
is set and the API is reachable; otherwise the `PgVector` path.
|
|
172
|
-
- **`false`**: never use managed memory.
|
|
173
|
-
- **`true`**: enable; store must come from `MEMORY_STORE`.
|
|
174
|
-
- **object**: enable with explicit `store` (or `MEMORY_STORE`) plus
|
|
175
|
-
`topK`, `autoCreate`, `recall`, `tools`, `entryPath` overrides.
|
|
176
|
-
|
|
177
|
-
Required Unity Catalog privileges for the app service principal:
|
|
178
|
-
`CREATE MEMORY STORE` on the schema (only when `autoCreate` is on, the
|
|
179
|
-
default), plus `READ MEMORY STORE` / `WRITE MEMORY STORE` on the store.
|
|
180
|
-
The capability probe and optional store auto-create run once at setup as
|
|
181
|
-
the service principal. Managed Memory is Beta and REST-only; on any
|
|
182
|
-
probe, create, or search failure the plugin logs and falls back to the
|
|
183
|
-
`PgVector` path so chat stays available. The connector lives in
|
|
184
|
-
[`connectors/managed-memory/`](src/connectors/managed-memory).
|
|
185
|
-
|
|
186
146
|
## The `tools(plugins)` callback
|
|
187
147
|
|
|
188
148
|
Each agent supplies either a static `tools: { ... }` record or a
|
|
@@ -336,19 +296,25 @@ available in-process from a sibling plugin via
|
|
|
336
296
|
|
|
337
297
|
## MCP server
|
|
338
298
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
external MCP clients - Claude Desktop, Cursor, the Mastra
|
|
342
|
-
another agent - can call them over the standard MCP
|
|
343
|
-
server is registered on the Mastra instance via
|
|
344
|
-
`@mastra/express` serves the stock MCP routes under the
|
|
345
|
-
bespoke route is added.
|
|
299
|
+
The plugin's agents are exposed as a Mastra
|
|
300
|
+
[`MCPServer`](https://mastra.ai/docs/tools-mcp/mcp-overview) **by
|
|
301
|
+
default** so external MCP clients - Claude Desktop, Cursor, the Mastra
|
|
302
|
+
playground, or another agent - can call them over the standard MCP
|
|
303
|
+
transports. The server is registered on the Mastra instance via
|
|
304
|
+
`mcpServers`, so `@mastra/express` serves the stock MCP routes under the
|
|
305
|
+
plugin mount; no bespoke route is added. It's on out of the box because
|
|
306
|
+
wrapping the already-registered agents is free - only the ambient tools
|
|
307
|
+
(which assume an in-process chat turn) stay off unless opted in.
|
|
346
308
|
|
|
347
309
|
```ts
|
|
348
310
|
import { mastra } from "@dbx-tools/appkit-mastra";
|
|
349
311
|
|
|
350
|
-
//
|
|
351
|
-
|
|
312
|
+
// MCP is on by default: every registered agent is an `ask_<agentId>`
|
|
313
|
+
// MCP tool with no extra config.
|
|
314
|
+
mastra({});
|
|
315
|
+
|
|
316
|
+
// Turn it off entirely.
|
|
317
|
+
mastra({ mcp: false });
|
|
352
318
|
|
|
353
319
|
// Or tune the server id / metadata and expose extra tools.
|
|
354
320
|
mastra({
|
|
@@ -361,12 +327,15 @@ mastra({
|
|
|
361
327
|
});
|
|
362
328
|
```
|
|
363
329
|
|
|
364
|
-
With `mcp` enabled the transports mount under the plugin
|
|
365
|
-
(`/api/<plugin>`):
|
|
330
|
+
With `mcp` enabled the transports mount at clean paths under the plugin
|
|
331
|
+
base path (`/api/<plugin>`):
|
|
332
|
+
|
|
333
|
+
- Streamable HTTP: `POST /api/<plugin>/mcp`
|
|
334
|
+
- SSE (legacy): `GET /api/<plugin>/sse` + `POST /api/<plugin>/messages`
|
|
366
335
|
|
|
367
|
-
|
|
368
|
-
-
|
|
369
|
-
|
|
336
|
+
(`@mastra/express` mounts these under `/mcp/<serverId>/<transport>`
|
|
337
|
+
internally - the plugin rewrites the clean alias to that route, so a
|
|
338
|
+
client never sees the doubled `/mcp/<serverId>/mcp` segment.)
|
|
370
339
|
|
|
371
340
|
`serverId` defaults to the plugin name. Requests run under the same
|
|
372
341
|
AppKit OBO scope as the chat routes, so an agent invoked over MCP
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { appkitUtils, logUtils } from "@dbx-tools/shared";
|
|
|
4
4
|
import * as _mastra_core_agent0 from "@mastra/core/agent";
|
|
5
5
|
import { Agent, AgentConfig, ToolsInput } from "@mastra/core/agent";
|
|
6
6
|
import * as _mastra_core_tools0 from "@mastra/core/tools";
|
|
7
|
-
import { Tool, createTool
|
|
7
|
+
import { Tool, createTool } from "@mastra/core/tools";
|
|
8
8
|
import * as _databricks_appkit0 from "@databricks/appkit";
|
|
9
9
|
import { BasePluginConfig, IAppRouter, Plugin, ResourceRequirement } from "@databricks/appkit";
|
|
10
10
|
import { z } from "zod";
|
|
@@ -29,99 +29,6 @@ import * as _mastra_core_channels0 from "@mastra/core/channels";
|
|
|
29
29
|
export * from "@dbx-tools/appkit-mastra-shared";
|
|
30
30
|
export * from "@dbx-tools/model";
|
|
31
31
|
|
|
32
|
-
//#region packages/appkit-mastra/src/connectors/managed-memory/types.d.ts
|
|
33
|
-
/**
|
|
34
|
-
* Type contract for the Databricks Managed Agent Memory connector.
|
|
35
|
-
*
|
|
36
|
-
* Managed Memory is a Beta Unity Catalog feature (REST-only, no TS
|
|
37
|
-
* SDK yet) that stores long-term agent memories as scoped entries in a
|
|
38
|
-
* UC `memory-store`. In `@dbx-tools/appkit-mastra` it plays the role
|
|
39
|
-
* the Postgres `PgVector` semantic-recall layer otherwise fills: an
|
|
40
|
-
* auto-recall input processor reads the user's top entries before each
|
|
41
|
-
* turn, and `save_memory` / `search_memory` tools let the agent persist
|
|
42
|
-
* and look up durable facts. Every read / write is scoped to the OBO
|
|
43
|
-
* user id resolved in trusted server code - the model never sets scope.
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
* Caller-facing configuration for the managed-memory backend, set via
|
|
47
|
-
* {@link MastraPluginConfig.managedMemory}. Every field is optional;
|
|
48
|
-
* the object form only needs to override what differs from the
|
|
49
|
-
* connector defaults.
|
|
50
|
-
*/
|
|
51
|
-
interface ManagedMemoryConfig {
|
|
52
|
-
/**
|
|
53
|
-
* Three-level Unity Catalog name of the memory store
|
|
54
|
-
* (`catalog.schema.name`). Falls back to the `MEMORY_STORE` env var
|
|
55
|
-
* when omitted. Required (here or in env) whenever managed memory is
|
|
56
|
-
* explicitly enabled; in prefer-if-available mode its absence simply
|
|
57
|
-
* leaves managed memory off.
|
|
58
|
-
*/
|
|
59
|
-
store?: string;
|
|
60
|
-
/** Description stamped on the store when {@link autoCreate} creates it. */
|
|
61
|
-
description?: string;
|
|
62
|
-
/**
|
|
63
|
-
* Number of entries the recall processor injects and `search_memory`
|
|
64
|
-
* returns by default. Defaults to {@link DEFAULT_TOPK}.
|
|
65
|
-
*/
|
|
66
|
-
topK?: number;
|
|
67
|
-
/**
|
|
68
|
-
* Create the store at setup when it doesn't exist (requires
|
|
69
|
-
* `CREATE MEMORY STORE` on the schema). Defaults to `true`; set
|
|
70
|
-
* `false` to require the store be provisioned out of band.
|
|
71
|
-
*/
|
|
72
|
-
autoCreate?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Attach the auto-recall input processor that injects the user's
|
|
75
|
-
* top entries before each turn. Defaults to `true`.
|
|
76
|
-
*/
|
|
77
|
-
recall?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Expose the `save_memory` / `search_memory` ambient tools to every
|
|
80
|
-
* agent. Defaults to `true`.
|
|
81
|
-
*/
|
|
82
|
-
tools?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Entry path new `save_memory` writes land under. Defaults to
|
|
85
|
-
* {@link DEFAULT_ENTRY_PATH}. Managed Memory keys entries by path
|
|
86
|
-
* within a scope, so a stable path accumulates notes for a user.
|
|
87
|
-
*/
|
|
88
|
-
entryPath?: string;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* A single memory entry as returned by the search endpoint. Fields
|
|
92
|
-
* mirror the UC memory-store wire shape but are all optional except
|
|
93
|
-
* `contents` because the Beta API surface may still drift.
|
|
94
|
-
*/
|
|
95
|
-
interface MemoryEntry {
|
|
96
|
-
/** Entry path within the scope (e.g. `/memories/notes.md`). */
|
|
97
|
-
path?: string;
|
|
98
|
-
/** Entry body - the recalled text. */
|
|
99
|
-
contents: string;
|
|
100
|
-
/** Optional one-line summary of the entry. */
|
|
101
|
-
description?: string;
|
|
102
|
-
/** Relevance score from the search ranker, when present. */
|
|
103
|
-
score?: number;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Resolved managed-memory runtime handed to the tools and recall
|
|
107
|
-
* processor when managed memory is the active long-term backend.
|
|
108
|
-
* Built once at setup after the capability probe succeeds; carries the
|
|
109
|
-
* store target and recall sizing, not the workspace client (that is
|
|
110
|
-
* resolved per-request from the OBO execution context).
|
|
111
|
-
*/
|
|
112
|
-
interface ManagedMemoryRuntime {
|
|
113
|
-
/** Three-level UC name of the resolved store. */
|
|
114
|
-
storeName: string;
|
|
115
|
-
/** Entries to recall / return per call. */
|
|
116
|
-
topK: number;
|
|
117
|
-
/** Default path for `save_memory` writes. */
|
|
118
|
-
entryPath: string;
|
|
119
|
-
/** Whether to expose the `save_memory` / `search_memory` tools. */
|
|
120
|
-
tools: boolean;
|
|
121
|
-
/** Whether to attach the auto-recall input processor. */
|
|
122
|
-
recall: boolean;
|
|
123
|
-
}
|
|
124
|
-
//#endregion
|
|
125
32
|
//#region packages/appkit-mastra/src/genie.d.ts
|
|
126
33
|
/** Default alias used when a single unnamed Genie space is wired up. */
|
|
127
34
|
declare const DEFAULT_GENIE_ALIAS = "default";
|
|
@@ -345,40 +252,8 @@ interface MastraPluginConfig extends BasePluginConfig {
|
|
|
345
252
|
/**
|
|
346
253
|
* PgVector store for Mastra memory recall. `true` reuses the
|
|
347
254
|
* `lakebase` plugin's pool; an object opens a dedicated store.
|
|
348
|
-
*
|
|
349
|
-
* When {@link managedMemory} is active it takes over the long-term /
|
|
350
|
-
* semantic-recall role and `PgVector` is not built, regardless of
|
|
351
|
-
* this setting; thread / message transcript (`storage`) is
|
|
352
|
-
* unaffected.
|
|
353
255
|
*/
|
|
354
256
|
memory?: boolean | MastraMemoryConfig;
|
|
355
|
-
/**
|
|
356
|
-
* Databricks Managed Agent Memory (Beta) as the long-term /
|
|
357
|
-
* semantic-recall backend, replacing the Postgres `PgVector` role.
|
|
358
|
-
* When active, every agent gets `save_memory` / `search_memory` tools
|
|
359
|
-
* and an auto-recall input processor that injects the user's top
|
|
360
|
-
* entries before each turn; entries are scoped per-user via OBO. The
|
|
361
|
-
* thread / message transcript still uses `PostgresStore` only when
|
|
362
|
-
* the `lakebase` plugin is registered - managed memory does not pull
|
|
363
|
-
* in Lakebase.
|
|
364
|
-
*
|
|
365
|
-
* - `undefined` (default, prefer-if-available): enabled only when the
|
|
366
|
-
* `MEMORY_STORE` env var names a store and the workspace exposes the
|
|
367
|
-
* memory-stores API; otherwise the `PgVector` path is used.
|
|
368
|
-
* - `false`: never use managed memory.
|
|
369
|
-
* - `true`: enable; the store must be named via the `MEMORY_STORE`
|
|
370
|
-
* env var (a missing store is a setup error).
|
|
371
|
-
* - {@link ManagedMemoryConfig}: enable with explicit `store`
|
|
372
|
-
* (or `MEMORY_STORE`), recall size, auto-create, and tool / recall
|
|
373
|
-
* toggles.
|
|
374
|
-
*
|
|
375
|
-
* The store is a three-level Unity Catalog name (`catalog.schema.name`).
|
|
376
|
-
* The app service principal needs `CREATE MEMORY STORE` on the schema
|
|
377
|
-
* when auto-create is on, plus `READ/WRITE MEMORY STORE`. On any probe
|
|
378
|
-
* or create failure the plugin logs and falls back to the `PgVector`
|
|
379
|
-
* path so chat stays available.
|
|
380
|
-
*/
|
|
381
|
-
managedMemory?: boolean | ManagedMemoryConfig;
|
|
382
257
|
/**
|
|
383
258
|
* Code-defined agents. Accepts three shapes for convenience:
|
|
384
259
|
*
|
|
@@ -621,11 +496,15 @@ interface MastraPluginConfig extends BasePluginConfig {
|
|
|
621
496
|
* Expose the plugin's agents (and optionally tools) as a Mastra MCP
|
|
622
497
|
* server so external MCP clients - Claude Desktop, Cursor, the Mastra
|
|
623
498
|
* playground, or another agent - can call them over the standard MCP
|
|
624
|
-
* transports.
|
|
499
|
+
* transports. Enabled by default (agents only): wrapping the
|
|
500
|
+
* already-registered agents costs nothing extra, so the endpoint is on
|
|
501
|
+
* out of the box; only the ambient tools (which assume an in-process
|
|
502
|
+
* chat turn) stay off unless explicitly opted in.
|
|
625
503
|
*
|
|
626
|
-
* - `undefined` / `
|
|
627
|
-
*
|
|
628
|
-
*
|
|
504
|
+
* - `undefined` (default) / `true`: expose every registered agent as
|
|
505
|
+
* an `ask_<agentId>` MCP tool under a server whose id is the plugin
|
|
506
|
+
* name.
|
|
507
|
+
* - `false`: no MCP endpoints.
|
|
629
508
|
* - {@link MastraMcpConfig}: fine-grained control over the server id,
|
|
630
509
|
* advertised metadata, and which agents / tools are exposed.
|
|
631
510
|
*
|
|
@@ -667,17 +546,6 @@ interface MastraPluginConfig extends BasePluginConfig {
|
|
|
667
546
|
}
|
|
668
547
|
//#endregion
|
|
669
548
|
//#region packages/appkit-mastra/src/memory.d.ts
|
|
670
|
-
/** Options controlling how {@link MemoryBuilder} resolves each agent's memory. */
|
|
671
|
-
interface MemoryBuilderOptions {
|
|
672
|
-
/**
|
|
673
|
-
* Skip building / attaching `PgVector` (and its `semanticRecall`)
|
|
674
|
-
* for every agent. Set when Databricks Managed Memory is the active
|
|
675
|
-
* long-term backend - it fills the semantic-recall role instead, via
|
|
676
|
-
* the recall input processor and memory tools. Thread / message
|
|
677
|
-
* storage (`PostgresStore`) is unaffected.
|
|
678
|
-
*/
|
|
679
|
-
suppressVector?: boolean;
|
|
680
|
-
}
|
|
681
549
|
/**
|
|
682
550
|
* Builds one `Memory` per agent against a shared service-principal
|
|
683
551
|
* Lakebase pool. Per-instance state keeps the shared `PgVector` alive
|
|
@@ -686,15 +554,8 @@ interface MemoryBuilderOptions {
|
|
|
686
554
|
declare class MemoryBuilder {
|
|
687
555
|
private readonly config;
|
|
688
556
|
private readonly servicePrincipalPool;
|
|
689
|
-
private readonly options;
|
|
690
557
|
private sharedVector;
|
|
691
|
-
constructor(config: MastraPluginConfig, servicePrincipalPool: Pool
|
|
692
|
-
/**
|
|
693
|
-
* Build a `Memory` for `agentId` after the plugin/agent cascade.
|
|
694
|
-
* Returns `undefined` when the agent has neither storage nor a
|
|
695
|
-
* vector store enabled - Mastra accepts a missing `memory` field
|
|
696
|
-
* and treats the agent as stateless.
|
|
697
|
-
*/
|
|
558
|
+
constructor(config: MastraPluginConfig, servicePrincipalPool: Pool);
|
|
698
559
|
/**
|
|
699
560
|
* Build the Mastra-instance-level storage used for workflow
|
|
700
561
|
* snapshots. Returns `undefined` when plugin-level `storage` is
|
|
@@ -707,6 +568,12 @@ declare class MemoryBuilder {
|
|
|
707
568
|
* `Mastra` instance that owns the workflow execution.
|
|
708
569
|
*/
|
|
709
570
|
instanceStorage(): PostgresStore | undefined;
|
|
571
|
+
/**
|
|
572
|
+
* Build a `Memory` for `agentId` after the plugin/agent cascade.
|
|
573
|
+
* Returns `undefined` when the agent has neither storage nor a
|
|
574
|
+
* vector store enabled - Mastra accepts a missing `memory` field
|
|
575
|
+
* and treats the agent as stateless.
|
|
576
|
+
*/
|
|
710
577
|
forAgent(agentId: string, def: MastraAgentDefinition): Memory | undefined;
|
|
711
578
|
private buildStorage;
|
|
712
579
|
/**
|
|
@@ -1020,14 +887,6 @@ declare function buildAgents(opts: {
|
|
|
1020
887
|
config: MastraPluginConfig;
|
|
1021
888
|
context: appkitUtils.PluginContextLike | undefined;
|
|
1022
889
|
memoryBuilder?: MemoryBuilder;
|
|
1023
|
-
/**
|
|
1024
|
-
* Active Databricks Managed Memory runtime, present only when managed
|
|
1025
|
-
* memory was resolved and probed successfully at setup. When set,
|
|
1026
|
-
* every agent gets the `save_memory` / `search_memory` tools and the
|
|
1027
|
-
* auto-recall input processor; the `PgVector` path is suppressed
|
|
1028
|
-
* upstream in `memory.ts`.
|
|
1029
|
-
*/
|
|
1030
|
-
managedMemory?: ManagedMemoryRuntime;
|
|
1031
890
|
log: logUtils.Logger;
|
|
1032
891
|
}): Promise<BuiltAgents>;
|
|
1033
892
|
//#endregion
|
|
@@ -1156,153 +1015,23 @@ declare function buildRenderDataTool(config: MastraPluginConfig): _mastra_core_t
|
|
|
1156
1015
|
chartId: string;
|
|
1157
1016
|
}, unknown, unknown, _mastra_core_tools0.ToolExecutionContext<unknown, unknown, unknown>, "render_data", unknown>;
|
|
1158
1017
|
//#endregion
|
|
1159
|
-
//#region packages/appkit-mastra/src/connectors/managed-memory/client.d.ts
|
|
1160
|
-
/** Workspace client carried on an AppKit execution context. */
|
|
1161
|
-
type WorkspaceClient$1 = appkitUtils.WorkspaceClientLike;
|
|
1162
|
-
/** Parsed three-level Unity Catalog name. */
|
|
1163
|
-
interface StoreName {
|
|
1164
|
-
catalog: string;
|
|
1165
|
-
schema: string;
|
|
1166
|
-
name: string;
|
|
1167
|
-
}
|
|
1168
|
-
/**
|
|
1169
|
-
* Error thrown for a non-2xx memory-store response. Carries the HTTP
|
|
1170
|
-
* status so callers can distinguish "feature unavailable / store
|
|
1171
|
-
* missing" (probe falls back) from genuine failures.
|
|
1172
|
-
*/
|
|
1173
|
-
declare class ManagedMemoryError extends Error {
|
|
1174
|
-
readonly status: number;
|
|
1175
|
-
readonly statusText: string;
|
|
1176
|
-
constructor(status: number, statusText: string, body: string);
|
|
1177
|
-
}
|
|
1178
|
-
/**
|
|
1179
|
-
* Split a three-level `catalog.schema.name` into its parts. Throws when
|
|
1180
|
-
* the input isn't exactly three dot-separated, non-empty segments so a
|
|
1181
|
-
* misconfigured `MEMORY_STORE` fails loudly at setup rather than
|
|
1182
|
-
* silently hitting a malformed URL.
|
|
1183
|
-
*/
|
|
1184
|
-
declare function parseStoreName(fullName: string): StoreName;
|
|
1185
|
-
/**
|
|
1186
|
-
* Fetch a store by full name. Returns the raw store payload when it
|
|
1187
|
-
* exists, or `null` on 404 so callers can treat "missing" as a normal
|
|
1188
|
-
* condition (the capability probe and `ensureStore` both rely on this).
|
|
1189
|
-
* Any other non-2xx status throws.
|
|
1190
|
-
*/
|
|
1191
|
-
declare function getStore(client: WorkspaceClient$1, fullName: string, signal?: AbortSignal): Promise<unknown | null>;
|
|
1192
|
-
/**
|
|
1193
|
-
* Probe for the store and create it when missing. Returns `true` when
|
|
1194
|
-
* the store exists (found or created). The create body splits the
|
|
1195
|
-
* three-level name into the catalog / schema / name fields the API
|
|
1196
|
-
* expects. A `getStore` 404 followed by a successful create is the
|
|
1197
|
-
* common first-run path.
|
|
1198
|
-
*/
|
|
1199
|
-
declare function ensureStore(client: WorkspaceClient$1, fullName: string, description: string, signal?: AbortSignal): Promise<boolean>;
|
|
1200
|
-
/**
|
|
1201
|
-
* Write (upsert) an entry into the store under `scope`. Scope is the
|
|
1202
|
-
* OBO user id resolved in trusted code; it travels as a query parameter
|
|
1203
|
-
* so the API isolates one user's memories from another's.
|
|
1204
|
-
*/
|
|
1205
|
-
declare function writeEntry(client: WorkspaceClient$1, fullName: string, scope: string, entry: {
|
|
1206
|
-
path: string;
|
|
1207
|
-
contents: string;
|
|
1208
|
-
description?: string;
|
|
1209
|
-
}, signal?: AbortSignal): Promise<void>;
|
|
1210
|
-
/**
|
|
1211
|
-
* Semantic search over a user's entries within `scope`. Returns up to
|
|
1212
|
-
* `topK` entries, parsed defensively so a renamed / missing Beta field
|
|
1213
|
-
* degrades to an empty list rather than crashing the turn.
|
|
1214
|
-
*/
|
|
1215
|
-
declare function search(client: WorkspaceClient$1, fullName: string, scope: string, query: string, topK: number, signal?: AbortSignal): Promise<MemoryEntry[]>;
|
|
1216
|
-
//#endregion
|
|
1217
|
-
//#region packages/appkit-mastra/src/connectors/managed-memory/context.d.ts
|
|
1218
|
-
/** Resolved per-request memory context: the client to call and the scope. */
|
|
1219
|
-
interface MemoryRequestContext {
|
|
1220
|
-
client: appkitUtils.WorkspaceClientLike;
|
|
1221
|
-
scope: string;
|
|
1222
|
-
}
|
|
1223
|
-
/**
|
|
1224
|
-
* Resolve the OBO-scoped workspace client and the memory scope for the
|
|
1225
|
-
* current turn. Mirrors `model.ts`: prefer the AppKit user stamped on
|
|
1226
|
-
* the request context, fall back to the ambient execution context (the
|
|
1227
|
-
* active OBO scope or the service principal). Scope is the Mastra
|
|
1228
|
-
* resource id (the per-user thread owner) when present, else the user
|
|
1229
|
-
* id. Returns `null` when neither yields a usable scope.
|
|
1230
|
-
*/
|
|
1231
|
-
declare function resolveMemoryContext(requestContext: RequestContext | undefined): MemoryRequestContext | null;
|
|
1232
|
-
//#endregion
|
|
1233
|
-
//#region packages/appkit-mastra/src/connectors/managed-memory/defaults.d.ts
|
|
1234
|
-
/**
|
|
1235
|
-
* Default values and environment variable names for the managed-memory
|
|
1236
|
-
* connector. Kept in a leaf module so the client, tools, recall
|
|
1237
|
-
* processor, and plugin setup can share them without a cycle.
|
|
1238
|
-
*/
|
|
1239
|
-
/**
|
|
1240
|
-
* Environment variable holding the three-level Unity Catalog store name
|
|
1241
|
-
* (`catalog.schema.name`). Read when {@link ManagedMemoryConfig.store}
|
|
1242
|
-
* is omitted; also the sole enable signal in prefer-if-available mode
|
|
1243
|
-
* (managed memory stays off when it is unset).
|
|
1244
|
-
*/
|
|
1245
|
-
declare const MEMORY_STORE_ENV = "MEMORY_STORE";
|
|
1246
|
-
/**
|
|
1247
|
-
* Default number of entries the recall processor injects and
|
|
1248
|
-
* `search_memory` returns. Matches the prior `PgVector`
|
|
1249
|
-
* `semanticRecall.topK` so behavior is unchanged after the swap.
|
|
1250
|
-
*/
|
|
1251
|
-
declare const DEFAULT_TOPK = 3;
|
|
1252
|
-
/**
|
|
1253
|
-
* Default path `save_memory` writes land under. Managed Memory keys
|
|
1254
|
-
* entries by path within a scope, so a single stable path accumulates a
|
|
1255
|
-
* user's notes rather than scattering them.
|
|
1256
|
-
*/
|
|
1257
|
-
declare const DEFAULT_ENTRY_PATH = "/memories/notes.md";
|
|
1258
|
-
/** Description stamped on the store when the connector auto-creates it. */
|
|
1259
|
-
declare const DEFAULT_STORE_DESCRIPTION = "Long-term agent memory managed by @dbx-tools/appkit-mastra.";
|
|
1260
|
-
//#endregion
|
|
1261
|
-
//#region packages/appkit-mastra/src/connectors/managed-memory/resolve.d.ts
|
|
1262
|
-
/**
|
|
1263
|
-
* Fully-resolved managed-memory target: everything `plugin.ts` needs to
|
|
1264
|
-
* probe the API, optionally create the store, and (on success) build
|
|
1265
|
-
* the runtime / tools / recall processor.
|
|
1266
|
-
*/
|
|
1267
|
-
interface ManagedMemoryTarget {
|
|
1268
|
-
storeName: string;
|
|
1269
|
-
description: string;
|
|
1270
|
-
topK: number;
|
|
1271
|
-
entryPath: string;
|
|
1272
|
-
autoCreate: boolean;
|
|
1273
|
-
recall: boolean;
|
|
1274
|
-
tools: boolean;
|
|
1275
|
-
}
|
|
1276
|
-
/**
|
|
1277
|
-
* Resolve the managed-memory target from config + env, or `null` when
|
|
1278
|
-
* managed memory is disabled. Throws when explicitly enabled but no
|
|
1279
|
-
* store name can be resolved (config or `MEMORY_STORE`), so a
|
|
1280
|
-
* misconfiguration surfaces at setup rather than silently falling back.
|
|
1281
|
-
*/
|
|
1282
|
-
declare function resolveManagedMemoryTarget(config: MastraPluginConfig): ManagedMemoryTarget | null;
|
|
1283
|
-
//#endregion
|
|
1284
|
-
//#region packages/appkit-mastra/src/connectors/managed-memory/tools.d.ts
|
|
1285
|
-
/** Mastra tool record shape (kept local to avoid an `agents.ts` cycle). */
|
|
1286
|
-
type MastraTools$1 = Record<string, ReturnType<typeof createTool$1>>;
|
|
1287
|
-
/**
|
|
1288
|
-
* Build the `save_memory` / `search_memory` tool pair bound to a
|
|
1289
|
-
* resolved managed-memory runtime. The runtime supplies the store name,
|
|
1290
|
-
* recall size, and default entry path; the per-request client and scope
|
|
1291
|
-
* are resolved inside each `execute`.
|
|
1292
|
-
*/
|
|
1293
|
-
declare function buildManagedMemoryTools(runtime: ManagedMemoryRuntime): MastraTools$1;
|
|
1294
|
-
/** Render an entry to a single recall line (summary prefix when present). */
|
|
1295
|
-
declare function renderEntry(entry: MemoryEntry): string;
|
|
1296
|
-
//#endregion
|
|
1297
1018
|
//#region packages/appkit-mastra/src/mcp.d.ts
|
|
1298
1019
|
/**
|
|
1299
1020
|
* A built MCP server plus the request paths it answers on, relative to
|
|
1300
|
-
* the plugin's base path (`/api/<plugin>`).
|
|
1301
|
-
*
|
|
1302
|
-
*
|
|
1021
|
+
* the plugin's base path (`/api/<plugin>`).
|
|
1022
|
+
*
|
|
1023
|
+
* The paths are the **clean public aliases** (`/mcp`, `/sse`,
|
|
1024
|
+
* `/messages`) the plugin exposes. `@mastra/express` actually mounts the
|
|
1025
|
+
* transports under `/mcp/<serverId>/<transport>` off the `Mastra`
|
|
1026
|
+
* instance's `mcpServers`; the plugin rewrites the alias to that route
|
|
1027
|
+
* before dispatch (see {@link ResolvedMcp.serverId}), so a client never
|
|
1028
|
+
* sees the doubled `/mcp/<serverId>/mcp` segment.
|
|
1303
1029
|
*/
|
|
1304
1030
|
interface ResolvedMcp {
|
|
1305
|
-
/**
|
|
1031
|
+
/**
|
|
1032
|
+
* Registry id, used in the underlying `@mastra/express` route
|
|
1033
|
+
* (`/mcp/<serverId>/...`) the plugin rewrites the clean alias to.
|
|
1034
|
+
*/
|
|
1306
1035
|
serverId: string;
|
|
1307
1036
|
/** The Mastra MCP server to hand to `new Mastra({ mcpServers })`. */
|
|
1308
1037
|
server: MCPServer;
|
|
@@ -1314,14 +1043,20 @@ interface ResolvedMcp {
|
|
|
1314
1043
|
messagePath: string;
|
|
1315
1044
|
}
|
|
1316
1045
|
/**
|
|
1317
|
-
* Build the plugin's MCP server, or `null` when `config.mcp` is
|
|
1318
|
-
*
|
|
1046
|
+
* Build the plugin's MCP server, or `null` only when `config.mcp` is
|
|
1047
|
+
* explicitly `false`.
|
|
1319
1048
|
*
|
|
1320
|
-
*
|
|
1321
|
-
*
|
|
1322
|
-
* (
|
|
1323
|
-
*
|
|
1324
|
-
*
|
|
1049
|
+
* Agent exposure is on by default because it's cheap: the already-
|
|
1050
|
+
* registered agents are wrapped as `ask_<agentId>` tools and handed to
|
|
1051
|
+
* `@mastra/express` (already mounted for the chat routes) - no extra
|
|
1052
|
+
* process, dependency, or network cost, and requests run under the same
|
|
1053
|
+
* OBO scope. So `undefined` (the default) and `true` both expose every
|
|
1054
|
+
* registered agent under a server id equal to the plugin name; only
|
|
1055
|
+
* `false` turns MCP off. The object form ({@link MastraMcpConfig}) tunes
|
|
1056
|
+
* the id / advertised metadata and can additionally expose the plugin's
|
|
1057
|
+
* ambient tools or a set of extra MCP-only tools. Ambient tools stay off
|
|
1058
|
+
* unless explicitly enabled - they assume an in-process chat turn, so
|
|
1059
|
+
* they aren't cheap / safe to expose to a standalone MCP client.
|
|
1325
1060
|
*/
|
|
1326
1061
|
declare function buildMcpServer(opts: {
|
|
1327
1062
|
config: MastraPluginConfig;
|
|
@@ -1528,6 +1263,14 @@ declare class MastraPlugin extends Plugin<MastraPluginConfig> {
|
|
|
1528
1263
|
* resolvers.
|
|
1529
1264
|
*/
|
|
1530
1265
|
private dispatchMastra;
|
|
1266
|
+
/**
|
|
1267
|
+
* Map a clean, mount-relative MCP alias path to the underlying
|
|
1268
|
+
* `@mastra/express` route. Returns `null` when MCP is off or the path
|
|
1269
|
+
* isn't an alias. Collapses the stock `/mcp/<serverId>/<transport>`
|
|
1270
|
+
* layout (serverId defaults to the plugin name) down to `/mcp`,
|
|
1271
|
+
* `/sse`, and `/messages`.
|
|
1272
|
+
*/
|
|
1273
|
+
private mcpRouteAlias;
|
|
1531
1274
|
/**
|
|
1532
1275
|
* Implementation backing the `/suggestions` route. Runs inside the
|
|
1533
1276
|
* AppKit user-context proxy so `getExecutionContext()` returns the
|
|
@@ -1574,25 +1317,6 @@ declare class MastraPlugin extends Plugin<MastraPluginConfig> {
|
|
|
1574
1317
|
* `getExecutionContext()` returns the OBO-scoped client.
|
|
1575
1318
|
*/
|
|
1576
1319
|
private listModels;
|
|
1577
|
-
/**
|
|
1578
|
-
* Resolve and probe the Databricks Managed Memory backend at setup.
|
|
1579
|
-
*
|
|
1580
|
-
* Returns the runtime (store + recall sizing + tool / recall toggles)
|
|
1581
|
-
* when managed memory is enabled and the workspace memory-stores API
|
|
1582
|
-
* is reachable, else `undefined` so the caller uses the PgVector path.
|
|
1583
|
-
*
|
|
1584
|
-
* The probe runs as the service principal (setup is outside any
|
|
1585
|
-
* `asUser` scope, so `getExecutionContext()` yields the SP client):
|
|
1586
|
-
* the SP owns the store and is the identity that can `CREATE MEMORY
|
|
1587
|
-
* STORE`. When `autoCreate` is on the store is created if missing.
|
|
1588
|
-
*
|
|
1589
|
-
* A misconfiguration where managed memory is explicitly enabled but no
|
|
1590
|
-
* store name is resolvable throws ({@link resolveManagedMemoryTarget})
|
|
1591
|
-
* - that is a wiring bug, not a runtime condition. Every other failure
|
|
1592
|
-
* (feature unavailable, permission denied, network) is caught, logged,
|
|
1593
|
-
* and degraded to a PgVector fallback so chat stays available.
|
|
1594
|
-
*/
|
|
1595
|
-
private resolveManagedMemory;
|
|
1596
1320
|
private buildAgentAndServer;
|
|
1597
1321
|
}
|
|
1598
1322
|
declare const mastra: _databricks_appkit0.ToPlugin<typeof MastraPlugin, MastraPluginConfig, "mastra">;
|
|
@@ -1662,4 +1386,4 @@ declare function buildSummarizeTool(config: MastraPluginConfig): _mastra_core_to
|
|
|
1662
1386
|
maxWords?: number | undefined;
|
|
1663
1387
|
}, unknown, unknown, unknown, _mastra_core_tools0.ToolExecutionContext<unknown, unknown, unknown>, "summarize", unknown>;
|
|
1664
1388
|
//#endregion
|
|
1665
|
-
export { AppKitToolOptions, BuiltAgents, ChartPlannerRequest, DEFAULT_AGENT_MAX_STEPS,
|
|
1389
|
+
export { AppKitToolOptions, BuiltAgents, ChartPlannerRequest, DEFAULT_AGENT_MAX_STEPS, DEFAULT_GENIE_ALIAS, DEFAULT_STYLE_INSTRUCTIONS, FALLBACK_AGENT_ID, FetchChartOptions, GENIE_INSTRUCTIONS, GenieSpaceConfig, GenieSpacesConfig, MASTRA_MODEL_OVERRIDE_KEY, MASTRA_REQUEST_ID_KEY, MASTRA_USER_EMAIL_KEY, MASTRA_USER_KEY, MASTRA_USER_NAME_KEY, MastraAgentDefinition, MastraMcpConfig, MastraMemoryConfig, MastraMemoryConfigOverride, MastraPlugin, MastraPluginConfig, MastraPluginToolkitProvider, MastraPlugins, MastraStorageConfigOverride, MastraTools, MastraToolsFn, type ModelOverrideRequest, PrepareChartOptions, ResolvedMcp, type SummarizeOptions, TRACE_REQUEST_CONTEXT_KEYS, ToolkitOptions, User, buildAgents, buildGenieToolkitProvider, buildGenieTools, buildMcpServer, buildRenderDataTool, buildSummarizeTool, chartPlannerRequestSchema, collectSpaceSuggestions, createAgent, createTool, extractModelOverride, fetchChart, mastra, normalizeGenieSpaces, prepareChart, resolveGenieSpaces, summarizeText, tool };
|