@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.
Files changed (51) hide show
  1. package/README.md +41 -1
  2. package/dist/index.d.ts +1229 -17
  3. package/dist/index.js +3348 -19
  4. package/package.json +17 -30
  5. package/dist/src/agents.d.ts +0 -316
  6. package/dist/src/agents.js +0 -470
  7. package/dist/src/chart.d.ts +0 -153
  8. package/dist/src/chart.js +0 -570
  9. package/dist/src/config.d.ts +0 -295
  10. package/dist/src/config.js +0 -55
  11. package/dist/src/genie.d.ts +0 -161
  12. package/dist/src/genie.js +0 -973
  13. package/dist/src/history.d.ts +0 -95
  14. package/dist/src/history.js +0 -278
  15. package/dist/src/memory.d.ts +0 -109
  16. package/dist/src/memory.js +0 -253
  17. package/dist/src/model.d.ts +0 -52
  18. package/dist/src/model.js +0 -198
  19. package/dist/src/observability.d.ts +0 -64
  20. package/dist/src/observability.js +0 -83
  21. package/dist/src/plugin.d.ts +0 -177
  22. package/dist/src/plugin.js +0 -554
  23. package/dist/src/processor.d.ts +0 -8
  24. package/dist/src/processor.js +0 -40
  25. package/dist/src/processors/strip-stale-charts.d.ts +0 -32
  26. package/dist/src/processors/strip-stale-charts.js +0 -98
  27. package/dist/src/server.d.ts +0 -51
  28. package/dist/src/server.js +0 -152
  29. package/dist/src/serving.d.ts +0 -65
  30. package/dist/src/serving.js +0 -79
  31. package/dist/src/statement.d.ts +0 -66
  32. package/dist/src/statement.js +0 -111
  33. package/dist/src/writer.d.ts +0 -23
  34. package/dist/src/writer.js +0 -37
  35. package/dist/tsconfig.build.tsbuildinfo +0 -1
  36. package/index.ts +0 -27
  37. package/src/agents.ts +0 -772
  38. package/src/chart.ts +0 -716
  39. package/src/config.ts +0 -320
  40. package/src/genie.ts +0 -1123
  41. package/src/history.ts +0 -322
  42. package/src/memory.ts +0 -293
  43. package/src/model.ts +0 -257
  44. package/src/observability.ts +0 -114
  45. package/src/plugin.ts +0 -623
  46. package/src/processor.ts +0 -46
  47. package/src/processors/strip-stale-charts.ts +0 -102
  48. package/src/server.ts +0 -195
  49. package/src/serving.ts +0 -104
  50. package/src/statement.ts +0 -120
  51. package/src/writer.ts +0 -44
@@ -1,295 +0,0 @@
1
- /**
2
- * Plugin configuration types and shared `RequestContext` keys.
3
- *
4
- * Kept in a leaf module so `plugin.ts`, `server.ts`, `model.ts`, and
5
- * `memory.ts` can import them without creating a cycle.
6
- */
7
- import type { BasePluginConfig } from "@databricks/appkit";
8
- import type { appkitUtils } from "@dbx-tools/shared";
9
- import type { AgentConfig } from "@mastra/core/agent";
10
- import type { PgVectorConfig, PostgresStoreConfig } from "@mastra/pg";
11
- import type { MastraAgentDefinition, MastraTools } from "./agents.js";
12
- import type { GenieSpacesConfig } from "./genie.js";
13
- /**
14
- * `RequestContext` key under which {@link MastraServer} stores the
15
- * resolved AppKit user. `model.ts` reads it to mint user-scoped
16
- * Databricks tokens.
17
- */
18
- export declare const MASTRA_USER_KEY = "mastra__user";
19
- /**
20
- * `RequestContext` keys for AppKit user metadata stamped by
21
- * {@link MastraServer}. Surfaced as trace metadata via
22
- * {@link TRACE_REQUEST_CONTEXT_KEYS} so traces are filterable by who
23
- * issued the request without leaking the full user object.
24
- */
25
- export declare const MASTRA_USER_NAME_KEY = "mastra__userName";
26
- export declare const MASTRA_USER_EMAIL_KEY = "mastra__userEmail";
27
- /**
28
- * `RequestContext` key for the per-HTTP-request id stamped by
29
- * {@link MastraServer}. Reads `X-Request-Id` from the incoming
30
- * headers when present (so an upstream load balancer / API gateway
31
- * can keep its trace correlation), falls back to a freshly minted
32
- * UUID. Echoed back on the response and surfaced on every span via
33
- * {@link TRACE_REQUEST_CONTEXT_KEYS} so logs and traces share a
34
- * join key.
35
- */
36
- export declare const MASTRA_REQUEST_ID_KEY = "mastra__requestId";
37
- /**
38
- * Canonical list of `RequestContext` keys we want Mastra to extract
39
- * as metadata on every observability span (agent runs, model calls,
40
- * tool invocations, workflow steps).
41
- *
42
- * Mirrors {@link https://mastra.ai/docs/observability/tracing/overview#automatic-metadata-from-requestcontext}:
43
- * passed verbatim into `Observability.configs[*].requestContextKeys`,
44
- * so any key listed here is read from `RequestContext` at trace
45
- * start and attached as scalar span metadata. Keep the set to plain
46
- * scalars - never include {@link MASTRA_USER_KEY} (it carries the
47
- * full AppKit execution context with a `WorkspaceClient` reference).
48
- *
49
- * Order is purely cosmetic; Mastra de-dupes internally.
50
- */
51
- export declare const TRACE_REQUEST_CONTEXT_KEYS: readonly string[];
52
- /** AppKit execution context plus the canonical user id. */
53
- export interface User {
54
- id: string;
55
- executionContext: appkitUtils.ExecutionContextLike;
56
- }
57
- /** PgVector config with an optional Mastra store id. */
58
- export type MastraMemoryConfig = PgVectorConfig & {
59
- id?: string;
60
- };
61
- /** Configuration accepted by the Mastra AppKit plugin. */
62
- export interface MastraPluginConfig extends BasePluginConfig {
63
- /** Mastra OpenAI-compatible provider id. Defaults to `"databricks"`. */
64
- providerId?: string;
65
- /**
66
- * PostgresStore for Mastra threads/messages. `true` reuses the
67
- * `lakebase` plugin's pool; an object opens a dedicated store.
68
- */
69
- storage?: boolean | PostgresStoreConfig;
70
- /**
71
- * PgVector store for Mastra memory recall. `true` reuses the
72
- * `lakebase` plugin's pool; an object opens a dedicated store.
73
- */
74
- memory?: boolean | MastraMemoryConfig;
75
- /**
76
- * Code-defined agents. Accepts three shapes for convenience:
77
- *
78
- * - **Record**: `{ analyst: def, helper: def }` - keys become the
79
- * registered ids and the first key is the default.
80
- * - **Single definition**: `def` - registered under
81
- * `slugify(def.name)` (or `"default"` when `name` is omitted) and
82
- * automatically marked as the default agent.
83
- * - **Array**: `[def1, def2]` - each registered under
84
- * `slugify(def.name)` (or `agent_${i}` when `name` is omitted);
85
- * the first entry is the default.
86
- *
87
- * Each entry becomes a Mastra `Agent` reachable at
88
- * `/api/<plugin>/route/chat/<id>` (the chat route also matches
89
- * `:agentId`). When `agents` is omitted entirely, the plugin
90
- * registers a single built-in `default` analyst so the bare
91
- * `mastra()` call still mounts a working chat endpoint.
92
- *
93
- * @example Single-agent shorthand
94
- * ```ts
95
- * mastra({
96
- * agents: createAgent({ instructions: "..." }),
97
- * });
98
- * ```
99
- *
100
- * @example Array
101
- * ```ts
102
- * mastra({
103
- * agents: [
104
- * createAgent({ name: "analyst", instructions: "..." }),
105
- * createAgent({ name: "helper", instructions: "..." }),
106
- * ],
107
- * });
108
- * ```
109
- *
110
- * @example Record (explicit ids)
111
- * ```ts
112
- * mastra({
113
- * agents: {
114
- * analyst: createAgent({ instructions: "..." }),
115
- * helper: createAgent({ instructions: "..." }),
116
- * },
117
- * defaultAgent: "analyst",
118
- * });
119
- * ```
120
- */
121
- agents?: Record<string, MastraAgentDefinition> | MastraAgentDefinition | MastraAgentDefinition[];
122
- /**
123
- * Ambient tools spread into every registered agent's tools record;
124
- * per-agent tools win on key collision. Use for a small shared
125
- * library; for per-agent tools set `agents[id].tools` instead.
126
- */
127
- tools?: MastraTools;
128
- /**
129
- * Agent id used when the client doesn't specify one (the bare,
130
- * un-suffixed history / suggestions routes resolve to it).
131
- * Defaults to the first key in `agents` (or `"default"` when
132
- * `agents` is omitted). Must match an id in `agents` when both are
133
- * set; a mismatch throws at setup with the available candidates.
134
- */
135
- defaultAgent?: string;
136
- /**
137
- * Plugin-level default model applied to every agent that omits its
138
- * own `model`. Mirrors AppKit's `agents({ defaultModel })`.
139
- *
140
- * - `string`: shorthand for "use the OBO auto-resolver but swap the
141
- * `modelId`" (e.g. `"databricks-claude-sonnet-4-6"`).
142
- * - Any other Mastra `DynamicArgument<MastraModelConfig>`: passed
143
- * through verbatim. Use this when you need full control over auth
144
- * or `providerId`.
145
- *
146
- * Resolution order per agent: `def.model` → `defaultModel` →
147
- * built-in `/serving-endpoints` resolver.
148
- */
149
- defaultModel?: AgentConfig["model"] | string;
150
- /**
151
- * Allow loose model names (`"claude sonnet"`) to be fuzzy-matched
152
- * against the workspace's Model Serving endpoints. Defaults to
153
- * `true`; set `false` to require exact endpoint names everywhere.
154
- */
155
- modelFuzzyMatch?: boolean;
156
- /**
157
- * Fuse.js score threshold for the fuzzy matcher (0 = exact match,
158
- * 1 = anything matches). Defaults to `0.4`. Lower values reject
159
- * loose matches; raise it if you have a sprawling endpoint
160
- * catalogue with similar-looking names.
161
- */
162
- modelFuzzyThreshold?: number;
163
- /**
164
- * TTL for the in-memory serving-endpoints list cache, in
165
- * milliseconds. Defaults to 5 minutes. The cache is per workspace
166
- * host and shared across users; concurrent callers coalesce on a
167
- * single in-flight fetch.
168
- */
169
- modelCacheTtlMs?: number;
170
- /**
171
- * Allow clients to override the active model per request via the
172
- * `X-Mastra-Model` header, `?model=` query string, or `model` body
173
- * field. Defaults to `true`. Disable when running multi-tenant
174
- * where untrusted clients shouldn't pick the backing endpoint.
175
- */
176
- modelOverride?: boolean;
177
- /**
178
- * Priority-ordered list of endpoint names tried *first* when no
179
- * agent / plugin / env / request-override model id is set, ahead of
180
- * the dynamic score-classified catalogue. The resolver picks the
181
- * first id that is actually present in the workspace's
182
- * `/serving-endpoints` listing.
183
- *
184
- * When unset, resolution is driven by the live Foundation Model API
185
- * `quality` / `speed` / `cost` scores: endpoints are classified into
186
- * chat classes (`classifyEndpoints`) and walked best-first
187
- * (ChatThinking -> ChatBalanced -> ChatFast), with the small built-in
188
- * `FALLBACK_MODEL_IDS` list as the floor when the catalogue can't be
189
- * read. Set this to
190
- * pin a regulated workspace to an approved subset, or to put custom
191
- * endpoints in front of the auto-classified catalogue.
192
- */
193
- defaultModelFallbacks?: readonly string[];
194
- /**
195
- * When `true` (default), every agent gets a built-in input
196
- * processor that strips `chartId` fields from prior assistant
197
- * tool-invocation results before they reach the model. This
198
- * prevents the model from reusing turn-scoped chartIds it sees
199
- * in memory recall (which would leave `[chart:<id>]` markers
200
- * pointing at writer events that no longer exist).
201
- *
202
- * Set to `false` to opt out - useful if a non-default agent
203
- * needs full visibility into prior chartIds (e.g. an audit
204
- * agent reasoning about chart lineage).
205
- */
206
- stripStaleCharts?: boolean;
207
- /**
208
- * Style guardrails appended to every agent's `instructions` to curb
209
- * common LLM-isms (em dashes, emojis, sycophantic openers, throwaway
210
- * closers, excessive hedging).
211
- *
212
- * - `undefined` (default): use the built-in
213
- * `DEFAULT_STYLE_INSTRUCTIONS` from `agents.ts`.
214
- * - `string`: replace the default with the supplied block.
215
- * - `false`: disable entirely (agents see only their bespoke
216
- * `instructions`).
217
- *
218
- * Appended (not prepended) so the agent's role and rules come first
219
- * and the style block leans on the model's recency bias.
220
- */
221
- styleInstructions?: string | false;
222
- /**
223
- * Genie spaces this plugin's agents can delegate to. One Mastra
224
- * tool is registered per alias (`genie` for the well-known
225
- * `default` alias, `genie_<alias>` otherwise). Each tool spins
226
- * up a per-question Genie sub-agent that runs Databricks
227
- * "agent mode" against the space, broadcasts wire events to the
228
- * UI, fetches statement rows for non-empty results, and returns
229
- * a `(string | data | chart)[]` summary the host UI renders
230
- * inline.
231
- *
232
- * Entries accept either a full {@link GenieSpaceConfig} object
233
- * or a bare `space_id` string when no extras are needed:
234
- *
235
- * ```ts
236
- * mastra({
237
- * genieSpaces: {
238
- * default: "01ef0d3c0e1b1f4a8d2c3e4f5a6b7c8d",
239
- * forecasts: { spaceId: "01ef...", hint: "weekly demand forecasts" },
240
- * },
241
- * });
242
- * ```
243
- *
244
- * Reach the spaces from an agent's `tools(plugins)` callback via
245
- * `plugins.genie?.toolkit()`; the resulting tools accept
246
- * `{ content, conversationId? }` and return a hydrated summary.
247
- *
248
- * **Fallback discovery** (highest precedence first): if this
249
- * field is omitted, the Genie agent also picks up spaces from
250
- * (1) the AppKit `genie({ spaces: { ... } })` plugin instance
251
- * when registered, and (2) the `DATABRICKS_GENIE_SPACE_ID`
252
- * env var (registered under the `default` alias). This keeps
253
- * existing AppKit deployments working without restating the
254
- * spaces config in two places.
255
- */
256
- genieSpaces?: GenieSpacesConfig;
257
- /**
258
- * TTL for the in-memory Genie space metadata cache, in
259
- * milliseconds. Defaults to 5 minutes. The Genie agent calls
260
- * `client.genie.getSpace(...)` on every cold-start to get the
261
- * title / description / warehouse id; cached responses skip the
262
- * round-trip and concurrent callers coalesce on a single
263
- * in-flight fetch. Drop to a smaller value when analysts are
264
- * actively editing space metadata and you want changes visible
265
- * within seconds; raise it to amortise the round-trip when
266
- * space metadata is effectively frozen.
267
- *
268
- * Backed by AppKit's `CacheManager`, so the cache participates
269
- * in telemetry spans (`cache.getOrExecute`) and benefits from
270
- * Lakebase persistence when the `lakebase` plugin is wired up.
271
- */
272
- genieSpaceCacheTtlMs?: number;
273
- /**
274
- * Maximum LLM steps each agent gets per turn. One step = one
275
- * round-trip to the underlying model (a tool call consumes a
276
- * step, the final-text reply consumes one too). Applies to
277
- * every agent registered through {@link MastraPluginConfig.agents}
278
- * - per-agent overrides aren't surfaced yet because the same
279
- * ceiling has been sufficient across every workload we've run.
280
- *
281
- * Defaults to {@link DEFAULT_AGENT_MAX_STEPS} (25), sized to fit
282
- * a decomposed Genie turn (grounding + several `ask_genie` calls
283
- * + `prepare_chart` per dataset + the final-text reply) with
284
- * headroom for the model to chain a couple of follow-ups before
285
- * answering. Mastra's own `agent.generate` default of 5 would
286
- * cut multi-step orchestration off after 2-3 tool calls, so
287
- * explicitly raising the ceiling here is what lets the
288
- * agent-mode loop play out.
289
- *
290
- * Lower when an unusually slow or expensive model makes long
291
- * turns unaffordable; raise for exploratory workloads that need
292
- * to drill deep into a dataset within a single turn.
293
- */
294
- agentMaxSteps?: number;
295
- }
@@ -1,55 +0,0 @@
1
- /**
2
- * Plugin configuration types and shared `RequestContext` keys.
3
- *
4
- * Kept in a leaf module so `plugin.ts`, `server.ts`, `model.ts`, and
5
- * `memory.ts` can import them without creating a cycle.
6
- */
7
- import { MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY, } from "@mastra/core/request-context";
8
- /**
9
- * `RequestContext` key under which {@link MastraServer} stores the
10
- * resolved AppKit user. `model.ts` reads it to mint user-scoped
11
- * Databricks tokens.
12
- */
13
- export const MASTRA_USER_KEY = "mastra__user";
14
- /**
15
- * `RequestContext` keys for AppKit user metadata stamped by
16
- * {@link MastraServer}. Surfaced as trace metadata via
17
- * {@link TRACE_REQUEST_CONTEXT_KEYS} so traces are filterable by who
18
- * issued the request without leaking the full user object.
19
- */
20
- export const MASTRA_USER_NAME_KEY = "mastra__userName";
21
- export const MASTRA_USER_EMAIL_KEY = "mastra__userEmail";
22
- /**
23
- * `RequestContext` key for the per-HTTP-request id stamped by
24
- * {@link MastraServer}. Reads `X-Request-Id` from the incoming
25
- * headers when present (so an upstream load balancer / API gateway
26
- * can keep its trace correlation), falls back to a freshly minted
27
- * UUID. Echoed back on the response and surfaced on every span via
28
- * {@link TRACE_REQUEST_CONTEXT_KEYS} so logs and traces share a
29
- * join key.
30
- */
31
- export const MASTRA_REQUEST_ID_KEY = "mastra__requestId";
32
- /**
33
- * Canonical list of `RequestContext` keys we want Mastra to extract
34
- * as metadata on every observability span (agent runs, model calls,
35
- * tool invocations, workflow steps).
36
- *
37
- * Mirrors {@link https://mastra.ai/docs/observability/tracing/overview#automatic-metadata-from-requestcontext}:
38
- * passed verbatim into `Observability.configs[*].requestContextKeys`,
39
- * so any key listed here is read from `RequestContext` at trace
40
- * start and attached as scalar span metadata. Keep the set to plain
41
- * scalars - never include {@link MASTRA_USER_KEY} (it carries the
42
- * full AppKit execution context with a `WorkspaceClient` reference).
43
- *
44
- * Order is purely cosmetic; Mastra de-dupes internally.
45
- */
46
- export const TRACE_REQUEST_CONTEXT_KEYS = [
47
- MASTRA_RESOURCE_ID_KEY,
48
- MASTRA_THREAD_ID_KEY,
49
- MASTRA_REQUEST_ID_KEY,
50
- MASTRA_USER_NAME_KEY,
51
- MASTRA_USER_EMAIL_KEY,
52
- // Model override key is owned by `serving.ts`; spelled inline here
53
- // so this module stays leaf-level (no cycles with `serving.ts`).
54
- "mastra__model_override",
55
- ];
@@ -1,161 +0,0 @@
1
- /**
2
- * Genie tools for Mastra.
3
- *
4
- * Surfaces each configured Genie space as a small set of flat Mastra
5
- * tools the calling agent drives directly - no inner orchestrator
6
- * agent. The central agent decomposes user questions, picks which
7
- * space to ask, streams the per-turn wire events (status, thinking,
8
- * sql, rows) through `ctx.writer`, and composes the final reply.
9
- * Rows are never fetched eagerly: the agent reads a statement's
10
- * values only when it needs to reason about them, otherwise it embeds
11
- * a `[data:<statement_id>]` marker in prose and lets the host UI
12
- * resolve the data. Charts are minted asynchronously and referenced
13
- * by `[chart:<chartId>]` markers so prose isn't blocked on chart
14
- * generation; the host UI fetches the cached spec by id once ready.
15
- * Space description and serialized-space lookups are available for
16
- * grounding when the agent needs schema context.
17
- *
18
- * Each tool's `execute` pulls the per-request
19
- * {@link WorkspaceClient} off `ctx.requestContext` (stamped by
20
- * `MastraServer` under {@link MASTRA_USER_KEY}) and the per-call
21
- * `writer` / `abortSignal` off `ctx`, so the tools are stateless
22
- * across requests and the central agent owns the loop.
23
- *
24
- * The tools talk to Genie directly via `@dbx-tools/genie`
25
- * (`genieEventChat`); statement-row fetching is delegated to
26
- * {@link fetchStatementData} from `./statement.js`, which wraps
27
- * the workspace `statementExecution.getStatement` API. AppKit's
28
- * stock `genie` plugin is honored only for its `spaces` config
29
- * so existing AppKit-style wiring keeps working without change.
30
- *
31
- * Suggested orchestration prompt for the central agent lives in
32
- * {@link GENIE_INSTRUCTIONS}; compose it into the agent's own
33
- * `instructions` when you want the canonical "how to drive the
34
- * Genie tools" guidance.
35
- */
36
- import { WorkspaceClient } from "@databricks/sdk-experimental";
37
- import { appkitUtils } from "@dbx-tools/shared";
38
- import type { MastraTools } from "./agents.js";
39
- import type { MastraPluginConfig } from "./config.js";
40
- /** Default alias used when a single unnamed Genie space is wired up. */
41
- export declare const DEFAULT_GENIE_ALIAS = "default";
42
- /** Per-space Genie agent configuration. */
43
- export interface GenieSpaceConfig {
44
- /** Genie `space_id`. Required; resolves via `client.genie.getSpace`. */
45
- spaceId: string;
46
- /**
47
- * Optional human-readable description appended to the per-space
48
- * tool descriptions so the calling LLM has hints about *what
49
- * data* this space covers (e.g. "orders, returns,
50
- * fulfillment"). When omitted, only the space's own
51
- * `description` (fetched on first use of `get_space_description`)
52
- * is shown.
53
- */
54
- hint?: string;
55
- }
56
- /** Map of alias -> space config. Accepts either explicit objects or bare space ids. */
57
- export type GenieSpacesConfig = Record<string, GenieSpaceConfig | string>;
58
- /**
59
- * Suggested orchestration prompt for the central agent that owns
60
- * the Genie tools. Compose into your agent's `instructions` to
61
- * get the canonical "decompose questions, ask Genie focused
62
- * sub-questions, place data / chart markers in prose" behavior:
63
- *
64
- * ```ts
65
- * createAgent({
66
- * instructions: `${myAgentInstructions}\n\n${GENIE_INSTRUCTIONS}`,
67
- * tools(plugins) {
68
- * return { ...plugins.genie?.toolkit() };
69
- * },
70
- * });
71
- * ```
72
- *
73
- * The prompt references the bare tool names (`ask_genie`,
74
- * `get_space_description`, `get_space_serialized`,
75
- * `get_statement`, `prepare_chart`) used for the single-space
76
- * default alias. Multi-space deployments should write their own
77
- * variant that names the suffixed per-space tools
78
- * (e.g. `ask_genie_sales`).
79
- */
80
- export declare const GENIE_INSTRUCTIONS: string;
81
- /**
82
- * Normalize the {@link GenieSpacesConfig} record. Bare-string
83
- * entries (`{ default: "01ef..." }`) get wrapped as
84
- * `{ spaceId: "01ef..." }`; object entries pass through unchanged.
85
- * `undefined` and empty-string values are dropped so callers can
86
- * pass `process.env.X` directly (matches AppKit `genie()`'s
87
- * defensive treatment of unset env vars).
88
- */
89
- export declare function normalizeGenieSpaces(spaces: GenieSpacesConfig | Record<string, string | GenieSpaceConfig | undefined> | undefined): Record<string, GenieSpaceConfig>;
90
- /**
91
- * Discover Genie space aliases from every supported source and
92
- * merge them into a single record. Precedence (highest first):
93
- *
94
- * 1. {@link MastraPluginConfig.genieSpaces} on the `mastra(...)`
95
- * call. Explicit Mastra wiring always wins so users can
96
- * override AppKit's defaults per-agent.
97
- * 2. AppKit `genie({ spaces: { ... } })` plugin instance. Lets
98
- * users keep using the existing AppKit config format
99
- * (`genie({ spaces: { sales: "...", ops: "..." } })`)
100
- * without restating the same record on the Mastra plugin.
101
- * Read off the live plugin instance via a structural cast
102
- * since `Plugin.config` is TS-protected (not runtime-private).
103
- * 3. `DATABRICKS_GENIE_SPACE_ID` env var (registered under the
104
- * well-known `default` alias). Matches the AppKit `genie()`
105
- * plugin's fallback behavior so a bare `mastra()` + `genie()`
106
- * pair just works.
107
- *
108
- * Aliases collide cleanly: a higher-precedence source's value
109
- * replaces a lower one's wholesale. Sources that contribute zero
110
- * aliases (or contribute only `undefined` / empty entries) are
111
- * silently ignored.
112
- */
113
- export declare function resolveGenieSpaces(config: MastraPluginConfig, context: appkitUtils.PluginContextLike | undefined): Record<string, GenieSpaceConfig>;
114
- /**
115
- * Build the flat Mastra tools record for every configured Genie
116
- * space. Two shared, space-agnostic tools (`get_statement`,
117
- * `prepare_chart`) are registered once regardless of how many
118
- * spaces are wired; the per-space tools (`ask_genie`,
119
- * `get_space_description`, `get_space_serialized`) are suffixed
120
- * with `_<alias>` for non-default aliases so multi-space
121
- * deployments stay disambiguated.
122
- *
123
- * Returns a record keyed by tool id, ready to spread into the
124
- * central `Agent`'s `tools` map (or surfaced via the
125
- * `plugins.genie?.toolkit()` callback). Returns an empty record
126
- * when `spaces` resolves to zero entries so the caller can spread
127
- * safely.
128
- */
129
- export declare function buildGenieTools(opts: {
130
- spaces: GenieSpacesConfig | Record<string, GenieSpaceConfig>;
131
- config: MastraPluginConfig;
132
- }): MastraTools;
133
- /**
134
- * Plugin-toolkit adapter so the `plugins.genie?.toolkit()` lookup
135
- * inside an agent's `tools(plugins)` callback returns the
136
- * flat Genie tools record instead of throwing on missing plugin.
137
- * Mirrors AppKit's `PluginToolkitProvider` shape.
138
- */
139
- export declare function buildGenieToolkitProvider(opts: {
140
- spaces: GenieSpacesConfig | Record<string, GenieSpaceConfig>;
141
- config: MastraPluginConfig;
142
- }): {
143
- toolkit(opts?: unknown): MastraTools;
144
- };
145
- /**
146
- * Collect the curated starter questions across every resolved Genie
147
- * space, deduped and capped. Each space's `sample_questions` are
148
- * fetched once (cached for {@link SUGGESTION_CACHE_TTL_MS}) via
149
- * {@link getGenieSpace} + {@link genieSampleQuestions}, then merged in
150
- * alias-iteration order so a single-space app surfaces that space's
151
- * questions and a multi-space app round-trips breadth-first up to the
152
- * cap. A per-space fetch failure degrades to "no questions for that
153
- * space" (logged, not thrown) so one unreachable space never blanks
154
- * the whole list. Returns `[]` when no spaces are configured.
155
- */
156
- export declare function collectSpaceSuggestions(opts: {
157
- spaces: Record<string, GenieSpaceConfig>;
158
- client: WorkspaceClient;
159
- signal?: AbortSignal;
160
- limit?: number;
161
- }): Promise<string[]>;