@dbx-tools/appkit-mastra 0.1.12 → 0.1.14

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 (57) hide show
  1. package/README.md +303 -637
  2. package/index.ts +46 -38
  3. package/package.json +58 -43
  4. package/src/agents.ts +224 -66
  5. package/src/chart.ts +531 -429
  6. package/src/config.ts +270 -19
  7. package/src/filesystems.ts +1090 -0
  8. package/src/genie.ts +1000 -660
  9. package/src/history.ts +166 -79
  10. package/src/mcp.ts +105 -0
  11. package/src/memory.ts +119 -81
  12. package/src/mlflow.ts +149 -0
  13. package/src/model.ts +75 -408
  14. package/src/observability.ts +144 -0
  15. package/src/pagination.ts +34 -0
  16. package/src/plugin.ts +566 -59
  17. package/src/processors.ts +168 -0
  18. package/src/rest.ts +67 -0
  19. package/src/server.ts +232 -45
  20. package/src/serving-sanitize.ts +167 -0
  21. package/src/serving.ts +27 -243
  22. package/src/statement.ts +89 -0
  23. package/src/storage-schema.ts +41 -0
  24. package/src/summarize.ts +176 -0
  25. package/src/threads.ts +338 -0
  26. package/src/workspaces.ts +346 -0
  27. package/src/writer.ts +44 -0
  28. package/tsconfig.json +41 -0
  29. package/dist/index.d.ts +0 -20
  30. package/dist/index.js +0 -20
  31. package/dist/src/agents.d.ts +0 -306
  32. package/dist/src/agents.js +0 -403
  33. package/dist/src/chart.d.ts +0 -170
  34. package/dist/src/chart.js +0 -491
  35. package/dist/src/config.d.ts +0 -183
  36. package/dist/src/config.js +0 -12
  37. package/dist/src/genie.d.ts +0 -131
  38. package/dist/src/genie.js +0 -630
  39. package/dist/src/history.d.ts +0 -67
  40. package/dist/src/history.js +0 -172
  41. package/dist/src/memory.d.ts +0 -79
  42. package/dist/src/memory.js +0 -210
  43. package/dist/src/model.d.ts +0 -159
  44. package/dist/src/model.js +0 -427
  45. package/dist/src/plugin.d.ts +0 -130
  46. package/dist/src/plugin.js +0 -261
  47. package/dist/src/processors/strip-stale-charts.d.ts +0 -29
  48. package/dist/src/processors/strip-stale-charts.js +0 -96
  49. package/dist/src/server.d.ts +0 -46
  50. package/dist/src/server.js +0 -123
  51. package/dist/src/serving.d.ts +0 -156
  52. package/dist/src/serving.js +0 -231
  53. package/dist/src/tools/email.d.ts +0 -74
  54. package/dist/src/tools/email.js +0 -122
  55. package/dist/tsconfig.build.tsbuildinfo +0 -1
  56. package/src/processors/strip-stale-charts.ts +0 -105
  57. package/src/tools/email.ts +0 -147
@@ -1,131 +0,0 @@
1
- /**
2
- * Mastra tool wrappers around the AppKit `genie` plugin's exports.
3
- *
4
- * One `sendMessage` tool is registered per configured space alias so
5
- * the LLM picks the space by tool selection (the description bakes the
6
- * alias in). `getConversation` is registered once, taking `alias` as a
7
- * parameter.
8
- *
9
- * All Genie payload types are inferred from the public `genie` factory
10
- * (`genie().plugin` constructor → `exports()` return type), so any
11
- * upstream change in `@databricks/appkit` flows in automatically.
12
- *
13
- * As Genie streams its long-running events (`FETCHING_METADATA` →
14
- * `ASKING_AI` → `EXECUTING_QUERY` → `COMPLETED`, plus SQL text and
15
- * follow-ups in `message_result.attachments`), the tool forwards a
16
- * normalised {@link GenieProgress} discriminated union out through
17
- * `ctx.writer` so the client can render an incremental loading pill.
18
- * Row payloads from `query_result` are intentionally discarded - the
19
- * LLM never sees rows, and charts come from the separate
20
- * `render_data` tool when the model decides one is useful.
21
- */
22
- import { genie } from "@databricks/appkit";
23
- import { createTool } from "@mastra/core/tools";
24
- import type { MastraPluginConfig } from "./config.js";
25
- /** Live AppKit `GeniePlugin` instance. */
26
- export type GeniePluginInstance = InstanceType<ReturnType<typeof genie>["plugin"]>;
27
- /** Full `exports()` shape of the AppKit `genie` plugin. */
28
- export type GenieExports = ReturnType<GeniePluginInstance["exports"]>;
29
- /**
30
- * Stream event yielded by `genie.exports().sendMessage`. Discriminated
31
- * by `type` (`"message_start" | "status" | "message_result" |
32
- * "query_result" | "error" | "history_info"`).
33
- */
34
- export type GenieStreamEvent = ReturnType<GenieExports["sendMessage"]> extends AsyncGenerator<infer E> ? E : never;
35
- /** Conversation history returned by `genie.exports().getConversation`. */
36
- export type GenieConversation = Awaited<ReturnType<GenieExports["getConversation"]>>;
37
- /**
38
- * Normalised progress event surfaced to the UI as a Mastra
39
- * `tool-output` chunk. Loading pill events (`started`, `status`,
40
- * `sql`, `suggested`, `error`) are pure UI metadata and never reach
41
- * the LLM.
42
- *
43
- * The `chart` variant is the wire shape emitted by
44
- * {@link emitChartWithPlanning} (used by both this Genie
45
- * draining loop and the system-level `render_data` tool). All
46
- * fields except `chartId` are optional because two events per
47
- * chartId arrive on the wire: the first carries the rows
48
- * (`title` + `description?` + `data`); the second, on planner
49
- * success, carries just the resolved Echarts spec (`option`).
50
- * The host UI's `<ChartSlot>` merges them by `chartId`.
51
- */
52
- export type GenieProgress = {
53
- kind: "started";
54
- conversationId: string;
55
- messageId: string;
56
- spaceId: string;
57
- } | {
58
- kind: "status";
59
- status: string;
60
- label: string;
61
- } | {
62
- kind: "sql";
63
- sql: string;
64
- title?: string;
65
- description?: string;
66
- statementId?: string;
67
- } | {
68
- kind: "chart";
69
- chartId: string;
70
- title?: string;
71
- description?: string;
72
- data?: Array<Record<string, unknown>>;
73
- option?: Record<string, unknown>;
74
- } | {
75
- kind: "text";
76
- content: string;
77
- } | {
78
- kind: "suggested";
79
- questions: string[];
80
- } | {
81
- kind: "error";
82
- error: string;
83
- };
84
- /**
85
- * Default tool name for a wired Genie alias. The well-known `default`
86
- * alias collapses to `genie`; everything else gets a `genie_` prefix so
87
- * multiple spaces stay disambiguated when an agent has more than one
88
- * wired. Matches the `genie` / `genie_<alias>` naming used elsewhere in
89
- * dbx-tools AppKit demos.
90
- */
91
- export declare function defaultGenieToolName(alias: string): string;
92
- /**
93
- * Build one `sendMessage` tool per configured Genie alias plus a single
94
- * `getConversation` tool. Returns a record keyed by tool id, ready to
95
- * spread into an `Agent`'s `tools` map.
96
- *
97
- * `config` must be the active plugin config; Genie's
98
- * `query_result` events are routed through
99
- * {@link emitChartWithPlanning} which uses it to resolve the
100
- * chart-planner's model.
101
- */
102
- export declare function buildGenieTools(opts: {
103
- aliases: string[];
104
- exports: GenieExports;
105
- config: MastraPluginConfig;
106
- signal?: AbortSignal;
107
- }): Record<string, ReturnType<typeof createTool>>;
108
- /**
109
- * Toolkit provider built from a live AppKit `GeniePlugin` instance.
110
- * Returned by {@link buildGenieProvider} so that
111
- * `plugins.genie?.toolkit()` inside an agent's `tools(plugins)` callback
112
- * resolves to the streaming-aware {@link buildGenieTools} record instead
113
- * of the AppKit default (which does one blocking call per tool with no
114
- * mid-flight events).
115
- *
116
- * The returned `toolkit()` reads alias names off the plugin's
117
- * `getAgentTools()` registry (each entry is `${alias}.sendMessage` or
118
- * `${alias}.getConversation`), then mints one `sendMessage` tool per
119
- * alias plus a shared `getConversation`. `sendMessage` / `getConversation`
120
- * are bound back to the plugin instance so they keep their `this`
121
- * (they are class methods, not free functions).
122
- *
123
- * `_opts` is accepted but unused for now - the streaming tools are an
124
- * all-or-nothing bundle. Wire `only` / `except` / `prefix` / `rename`
125
- * later if a caller needs them.
126
- */
127
- export declare function buildGenieProvider(plugin: GeniePluginInstance, opts: {
128
- config: MastraPluginConfig;
129
- }): {
130
- toolkit(opts?: unknown): Record<string, ReturnType<typeof createTool>>;
131
- };