@dbx-tools/appkit-mastra 0.1.58 → 0.1.68
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 +41 -1
- package/dist/index.d.ts +1229 -17
- package/dist/index.js +3348 -19
- package/package.json +17 -30
- package/dist/src/agents.d.ts +0 -316
- package/dist/src/agents.js +0 -470
- package/dist/src/chart.d.ts +0 -153
- package/dist/src/chart.js +0 -570
- package/dist/src/config.d.ts +0 -295
- package/dist/src/config.js +0 -55
- package/dist/src/genie.d.ts +0 -161
- package/dist/src/genie.js +0 -973
- package/dist/src/history.d.ts +0 -95
- package/dist/src/history.js +0 -278
- package/dist/src/memory.d.ts +0 -109
- package/dist/src/memory.js +0 -253
- package/dist/src/model.d.ts +0 -52
- package/dist/src/model.js +0 -198
- package/dist/src/observability.d.ts +0 -64
- package/dist/src/observability.js +0 -83
- package/dist/src/plugin.d.ts +0 -177
- package/dist/src/plugin.js +0 -554
- package/dist/src/processor.d.ts +0 -8
- package/dist/src/processor.js +0 -40
- package/dist/src/processors/strip-stale-charts.d.ts +0 -32
- package/dist/src/processors/strip-stale-charts.js +0 -98
- package/dist/src/server.d.ts +0 -51
- package/dist/src/server.js +0 -152
- package/dist/src/serving.d.ts +0 -65
- package/dist/src/serving.js +0 -79
- package/dist/src/statement.d.ts +0 -66
- package/dist/src/statement.js +0 -111
- package/dist/src/writer.d.ts +0 -23
- package/dist/src/writer.js +0 -37
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/index.ts +0 -27
- package/src/agents.ts +0 -772
- package/src/chart.ts +0 -716
- package/src/config.ts +0 -320
- package/src/genie.ts +0 -1123
- package/src/history.ts +0 -322
- package/src/memory.ts +0 -293
- package/src/model.ts +0 -257
- package/src/observability.ts +0 -114
- package/src/plugin.ts +0 -623
- package/src/processor.ts +0 -46
- package/src/processors/strip-stale-charts.ts +0 -102
- package/src/server.ts +0 -195
- package/src/serving.ts +0 -104
- package/src/statement.ts +0 -120
- package/src/writer.ts +0 -44
package/dist/src/plugin.d.ts
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AppKit plugin that builds one or more Mastra `Agent` instances and
|
|
3
|
-
* mounts the `@mastra/express` server. Clients drive the conversation
|
|
4
|
-
* over the standard Mastra agent stream (`@mastra/client-js`'s
|
|
5
|
-
* `getAgent(id).stream()`), so there's no bespoke chat transport to
|
|
6
|
-
* keep in sync.
|
|
7
|
-
*
|
|
8
|
-
* - Agents: registered through `config.agents` at plugin creation
|
|
9
|
-
* ({@link MastraAgentDefinition}). Each entry's `tools` field accepts
|
|
10
|
-
* either a plain record or a `(plugins) => tools` callback that gets
|
|
11
|
-
* a typed sibling-plugin index ({@link MastraPlugins}). Omit
|
|
12
|
-
* `config.agents` to get a single built-in `default` analyst.
|
|
13
|
-
* - Model: each agent call resolves a `MastraModelConfig` via
|
|
14
|
-
* {@link buildModel} from `./model.js`. Per-agent `model` overrides
|
|
15
|
-
* (`AgentConfig["model"]` or a `modelId` string) flow through
|
|
16
|
-
* {@link buildAgents}.
|
|
17
|
-
* - Memory / storage: per-agent, built by {@link createMemoryBuilder}
|
|
18
|
-
* from `./memory.js`. Both auto-default to `true` when the
|
|
19
|
-
* `lakebase` plugin is registered (unless the caller passed
|
|
20
|
-
* `false` or a custom config). Storage namespaces per agent via
|
|
21
|
-
* `schemaName: "mastra_<agentId>"`; the vector store is a single
|
|
22
|
-
* shared singleton across every agent.
|
|
23
|
-
* - Server: the Express subapp wiring lives in `./server.js`.
|
|
24
|
-
* - HTTP: AppKit mounts this plugin under `/api/mastra`. Alongside the
|
|
25
|
-
* Mastra agent routes, the plugin registers `/route/history`
|
|
26
|
-
* (load + clear thread history), `/models`, `/suggestions`, and the
|
|
27
|
-
* generic `/embed/:type/:id` resolver for inline chart / data
|
|
28
|
-
* markers.
|
|
29
|
-
*/
|
|
30
|
-
import { Plugin, type IAppRouter, type ResourceRequirement } from "@databricks/appkit";
|
|
31
|
-
import type { Agent } from "@mastra/core/agent";
|
|
32
|
-
import { Mastra } from "@mastra/core/mastra";
|
|
33
|
-
import { type ServingEndpointSummary } from "@dbx-tools/model";
|
|
34
|
-
import type { MastraPluginConfig } from "./config.js";
|
|
35
|
-
import { MastraServer } from "./server.js";
|
|
36
|
-
/**
|
|
37
|
-
* AppKit plugin (registered name: `mastra`) that hosts Mastra agents
|
|
38
|
-
* with optional Lakebase-backed memory and AI SDK chat routes under
|
|
39
|
-
* the plugin mount (typically `/api/mastra`).
|
|
40
|
-
*/
|
|
41
|
-
export declare class MastraPlugin extends Plugin<MastraPluginConfig> {
|
|
42
|
-
static manifest: {
|
|
43
|
-
name: "mastra";
|
|
44
|
-
displayName: string;
|
|
45
|
-
description: string;
|
|
46
|
-
stability: "beta";
|
|
47
|
-
resources: {
|
|
48
|
-
required: never[];
|
|
49
|
-
optional: Omit<ResourceRequirement, "required">[];
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Tighten resource requirements based on which features are enabled.
|
|
54
|
-
* AppKit calls this at registration time (config-aware) so disabled
|
|
55
|
-
* features don't surface their resource asks to the host app.
|
|
56
|
-
*/
|
|
57
|
-
static getResourceRequirements(config: MastraPluginConfig): ResourceRequirement[];
|
|
58
|
-
private log;
|
|
59
|
-
private built;
|
|
60
|
-
private mastra;
|
|
61
|
-
private mastraApp;
|
|
62
|
-
private mastraServer;
|
|
63
|
-
/**
|
|
64
|
-
* Dedicated service-principal Lakebase pool backing Mastra memory /
|
|
65
|
-
* storage. Built once in {@link buildAgentAndServer} (outside any
|
|
66
|
-
* `asUser` scope, so it never inherits a request's OBO identity) and
|
|
67
|
-
* drained in {@link abortActiveOperations}. `null` until setup runs
|
|
68
|
-
* or when Lakebase isn't needed.
|
|
69
|
-
*/
|
|
70
|
-
private servicePrincipalPool;
|
|
71
|
-
setup(): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* When the `lakebase` plugin is registered, auto-enable `storage`
|
|
74
|
-
* and `memory` unless the caller opted out explicitly (`false` or a
|
|
75
|
-
* custom config object). Run after `setup:complete` so the lookup
|
|
76
|
-
* is reliable: any plugin that registers itself synchronously is
|
|
77
|
-
* already in the registry by the time this fires.
|
|
78
|
-
*/
|
|
79
|
-
private applyLakebaseAutoDefaults;
|
|
80
|
-
/**
|
|
81
|
-
* Drain the memory service-principal pool on shutdown. AppKit calls
|
|
82
|
-
* this during teardown; the lakebase plugin closes its own SP / OBO
|
|
83
|
-
* pools the same way. Fire-and-forget so shutdown isn't blocked on a
|
|
84
|
-
* slow drain, and clear the handle so a re-`setup()` rebuilds it.
|
|
85
|
-
*/
|
|
86
|
-
abortActiveOperations(): void;
|
|
87
|
-
exports(): {
|
|
88
|
-
/**
|
|
89
|
-
* Ids of every registered agent in registration order. Matches
|
|
90
|
-
* AppKit `agents.list()` so callers can iterate the registry the
|
|
91
|
-
* same way under both plugins.
|
|
92
|
-
*/
|
|
93
|
-
list: () => string[];
|
|
94
|
-
/**
|
|
95
|
-
* Look up a registered agent by id. Returns `null` (not
|
|
96
|
-
* undefined) when unknown so call sites can early-return without
|
|
97
|
-
* a separate `in` check.
|
|
98
|
-
*/
|
|
99
|
-
get: (id: string) => Agent | null;
|
|
100
|
-
/**
|
|
101
|
-
* The agent the client converses with when it doesn't name one.
|
|
102
|
-
* Resolves to `config.defaultAgent`, the first registered id, or
|
|
103
|
-
* the built-in `default` fallback.
|
|
104
|
-
*/
|
|
105
|
-
getDefault: () => Agent | null;
|
|
106
|
-
/** Underlying Mastra instance for advanced use (custom routes etc.). */
|
|
107
|
-
getMastra: () => Mastra<Record<string, Agent<any, import("@mastra/core/agent").ToolsInput, undefined, unknown, import("@mastra/core/agent").AgentEditorConfig | undefined>>, Record<string, import("@mastra/core/workflows").AnyWorkflow>, Record<string, import("@mastra/core/vector").MastraVector<any>>, Record<string, import("@mastra/core/tts").MastraTTS>, import("@mastra/core/logger").IMastraLogger, Record<string, import("@mastra/core/mcp").MCPServerBase<any>>, Record<string, import("@mastra/core/evals").MastraScorer<any, any, any, any>>, Record<string, import("@mastra/core/tools").ToolAction<any, any, any, any, any, any, unknown>>, Record<string, import("@mastra/core/processors").Processor<any, unknown>>, Record<string, import("@mastra/core/memory").MastraMemory>, Record<string, import("@mastra/core/channels").ChannelProvider>> | null;
|
|
108
|
-
/** Express subapp Mastra is mounted on; mostly for tests. */
|
|
109
|
-
getMastraServer: () => MastraServer | null;
|
|
110
|
-
/**
|
|
111
|
-
* Fetch the workspace's Model Serving endpoints (cached). Same
|
|
112
|
-
* payload the `GET /models` route returns; surfaced here so
|
|
113
|
-
* other plugins / scripts can introspect the catalogue without
|
|
114
|
-
* an HTTP round-trip. AppKit wraps this with `asUser(req)` for
|
|
115
|
-
* OBO scoping automatically.
|
|
116
|
-
*/
|
|
117
|
-
listModels: () => Promise<ServingEndpointSummary[]>;
|
|
118
|
-
/**
|
|
119
|
-
* Force-evict cached endpoint listings via AppKit's
|
|
120
|
-
* `CacheManager`. Useful in tests or right after an admin
|
|
121
|
-
* deploys a new endpoint and doesn't want to wait for the TTL.
|
|
122
|
-
* Returns the underlying `CacheManager.delete`/`clear` promise.
|
|
123
|
-
*/
|
|
124
|
-
clearModelsCache: (host?: string) => Promise<void>;
|
|
125
|
-
};
|
|
126
|
-
clientConfig(): Record<string, unknown>;
|
|
127
|
-
injectRoutes(router: IAppRouter): void;
|
|
128
|
-
/**
|
|
129
|
-
* Invoke the Mastra express sub-app. Exists as a method (instead of reading
|
|
130
|
-
* `this.mastraApp` through the `asUser(req)` proxy at the call site) so the
|
|
131
|
-
* proxy binds this plain method - whose `.bind` is `Function.prototype.bind`
|
|
132
|
-
* - rather than the express app, whose `.bind` is the HTTP BIND route
|
|
133
|
-
* registrar (see the note in `injectRoutes`). Runs inside the user scope so
|
|
134
|
-
* `getExecutionContext()` returns the OBO client for the agent/model
|
|
135
|
-
* resolvers.
|
|
136
|
-
*/
|
|
137
|
-
private dispatchMastra;
|
|
138
|
-
/**
|
|
139
|
-
* Implementation backing the `/suggestions` route. Runs inside the
|
|
140
|
-
* AppKit user-context proxy so `getExecutionContext()` returns the
|
|
141
|
-
* OBO-scoped client. Resolves the plugin's Genie spaces and merges
|
|
142
|
-
* their curated `sample_questions` (see {@link collectSpaceSuggestions}).
|
|
143
|
-
* Returns `[]` when no Genie space is configured so the client
|
|
144
|
-
* shows a bare empty state instead of built-in example prompts.
|
|
145
|
-
*/
|
|
146
|
-
private fetchSuggestions;
|
|
147
|
-
/**
|
|
148
|
-
* Implementation backing the `data` embed resolver
|
|
149
|
-
* (`GET /embed/data/:id`). Runs inside the AppKit user-context proxy so
|
|
150
|
-
* `getExecutionContext()` returns the OBO-scoped workspace
|
|
151
|
-
* client, then reuses the same `fetchStatementData` pipeline
|
|
152
|
-
* the `get_statement` tool runs so the LLM and the UI see the
|
|
153
|
-
* exact same shape for the same statement.
|
|
154
|
-
*
|
|
155
|
-
* Returns `undefined` for upstream 404s so the route can map
|
|
156
|
-
* them to a clean HTTP 404; any other failure bubbles up.
|
|
157
|
-
*/
|
|
158
|
-
private fetchStatement;
|
|
159
|
-
/**
|
|
160
|
-
* Return `this.asUser(req)` when the request carries an OBO token,
|
|
161
|
-
* otherwise return `this` directly. Prevents the noisy AppKit warn
|
|
162
|
-
* (`asUser() called without user token in development mode. Skipping
|
|
163
|
-
* user impersonation.`) on every request in local dev where the
|
|
164
|
-
* browser never sends `x-forwarded-access-token`. Behavior is
|
|
165
|
-
* unchanged in production: a missing token always means a real OBO
|
|
166
|
-
* proxy call (and AppKit will throw upstream if that's wrong).
|
|
167
|
-
*/
|
|
168
|
-
private userScopedSelf;
|
|
169
|
-
/**
|
|
170
|
-
* Implementation backing both the `/models` route and the
|
|
171
|
-
* `listModels` export. Runs inside the AppKit user-context proxy so
|
|
172
|
-
* `getExecutionContext()` returns the OBO-scoped client.
|
|
173
|
-
*/
|
|
174
|
-
private listModels;
|
|
175
|
-
private buildAgentAndServer;
|
|
176
|
-
}
|
|
177
|
-
export declare const mastra: import("@databricks/appkit").ToPlugin<typeof MastraPlugin, MastraPluginConfig, "mastra">;
|