@dbx-tools/appkit-mastra 0.1.5 → 0.1.10

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 (53) hide show
  1. package/README.md +394 -0
  2. package/index.ts +46 -37
  3. package/package.json +58 -47
  4. package/src/agents.ts +233 -62
  5. package/src/chart.ts +555 -285
  6. package/src/config.ts +282 -18
  7. package/src/filesystems.ts +1090 -0
  8. package/src/genie.ts +1004 -601
  9. package/src/history.ts +178 -79
  10. package/src/mcp.ts +105 -0
  11. package/src/memory.ts +129 -74
  12. package/src/mlflow.ts +149 -0
  13. package/src/model.ts +80 -408
  14. package/src/observability.ts +144 -0
  15. package/src/pagination.ts +34 -0
  16. package/src/plugin.ts +573 -59
  17. package/src/processors.ts +168 -0
  18. package/src/rest.ts +67 -0
  19. package/src/server.ts +243 -45
  20. package/src/serving-sanitize.ts +167 -0
  21. package/src/serving.ts +27 -224
  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 -19
  30. package/dist/index.js +0 -19
  31. package/dist/src/agents.d.ts +0 -306
  32. package/dist/src/agents.js +0 -393
  33. package/dist/src/chart.d.ts +0 -104
  34. package/dist/src/chart.js +0 -375
  35. package/dist/src/config.d.ts +0 -170
  36. package/dist/src/config.js +0 -12
  37. package/dist/src/genie.d.ts +0 -116
  38. package/dist/src/genie.js +0 -594
  39. package/dist/src/history.d.ts +0 -67
  40. package/dist/src/history.js +0 -158
  41. package/dist/src/memory.d.ts +0 -79
  42. package/dist/src/memory.js +0 -197
  43. package/dist/src/model.d.ts +0 -159
  44. package/dist/src/model.js +0 -423
  45. package/dist/src/plugin.d.ts +0 -130
  46. package/dist/src/plugin.js +0 -255
  47. package/dist/src/render-chart-route.d.ts +0 -33
  48. package/dist/src/render-chart-route.js +0 -120
  49. package/dist/src/server.d.ts +0 -46
  50. package/dist/src/server.js +0 -113
  51. package/dist/src/serving.d.ts +0 -156
  52. package/dist/src/serving.js +0 -214
  53. package/src/render-chart-route.ts +0 -141
@@ -1,116 +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
- /** Live AppKit `GeniePlugin` instance. */
25
- export type GeniePluginInstance = InstanceType<ReturnType<typeof genie>["plugin"]>;
26
- /** Full `exports()` shape of the AppKit `genie` plugin. */
27
- export type GenieExports = ReturnType<GeniePluginInstance["exports"]>;
28
- /**
29
- * Stream event yielded by `genie.exports().sendMessage`. Discriminated
30
- * by `type` (`"message_start" | "status" | "message_result" |
31
- * "query_result" | "error" | "history_info"`).
32
- */
33
- export type GenieStreamEvent = ReturnType<GenieExports["sendMessage"]> extends AsyncGenerator<infer E> ? E : never;
34
- /** Conversation history returned by `genie.exports().getConversation`. */
35
- export type GenieConversation = Awaited<ReturnType<GenieExports["getConversation"]>>;
36
- /**
37
- * Normalised progress event surfaced to the UI as a Mastra
38
- * `tool-output` chunk. Loading pill events (`started`, `status`,
39
- * `sql`, `suggested`, `error`) are pure UI metadata and never reach
40
- * the LLM. The `chart` variant carries the rows from a Genie SQL
41
- * statement so the host UI's `<ChartSlot>` can render them inline
42
- * via the same path as the `render_data` tool; the LLM still only
43
- * sees the matching {@link datasetSchema} metadata in
44
- * `genieAnswer`'s sibling `datasets[]` field.
45
- */
46
- export type GenieProgress = {
47
- kind: "started";
48
- conversationId: string;
49
- messageId: string;
50
- spaceId: string;
51
- } | {
52
- kind: "status";
53
- status: string;
54
- label: string;
55
- } | {
56
- kind: "sql";
57
- sql: string;
58
- title?: string;
59
- description?: string;
60
- statementId?: string;
61
- } | {
62
- kind: "chart";
63
- chartId: string;
64
- title: string;
65
- description?: string;
66
- data: Array<Record<string, unknown>>;
67
- } | {
68
- kind: "text";
69
- content: string;
70
- } | {
71
- kind: "suggested";
72
- questions: string[];
73
- } | {
74
- kind: "error";
75
- error: string;
76
- };
77
- /**
78
- * Default tool name for a wired Genie alias. The well-known `default`
79
- * alias collapses to `genie`; everything else gets a `genie_` prefix so
80
- * multiple spaces stay disambiguated when an agent has more than one
81
- * wired. Matches the `genie` / `genie_<alias>` naming used elsewhere in
82
- * dbx-tools AppKit demos.
83
- */
84
- export declare function defaultGenieToolName(alias: string): string;
85
- /**
86
- * Build one `sendMessage` tool per configured Genie alias plus a single
87
- * `getConversation` tool. Returns a record keyed by tool id, ready to
88
- * spread into an `Agent`'s `tools` map.
89
- */
90
- export declare function buildGenieTools(opts: {
91
- aliases: string[];
92
- exports: GenieExports;
93
- signal?: AbortSignal;
94
- }): Record<string, ReturnType<typeof createTool>>;
95
- /**
96
- * Toolkit provider built from a live AppKit `GeniePlugin` instance.
97
- * Returned by {@link buildGenieProvider} so that
98
- * `plugins.genie?.toolkit()` inside an agent's `tools(plugins)` callback
99
- * resolves to the streaming-aware {@link buildGenieTools} record instead
100
- * of the AppKit default (which does one blocking call per tool with no
101
- * mid-flight events).
102
- *
103
- * The returned `toolkit()` reads alias names off the plugin's
104
- * `getAgentTools()` registry (each entry is `${alias}.sendMessage` or
105
- * `${alias}.getConversation`), then mints one `sendMessage` tool per
106
- * alias plus a shared `getConversation`. `sendMessage` / `getConversation`
107
- * are bound back to the plugin instance so they keep their `this`
108
- * (they are class methods, not free functions).
109
- *
110
- * `_opts` is accepted but unused for now - the streaming tools are an
111
- * all-or-nothing bundle. Wire `only` / `except` / `prefix` / `rename`
112
- * later if a caller needs them.
113
- */
114
- export declare function buildGenieProvider(plugin: GeniePluginInstance): {
115
- toolkit(opts?: unknown): Record<string, ReturnType<typeof createTool>>;
116
- };