@dbx-tools/appkit-mastra 0.3.44 → 0.4.0

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 (56) hide show
  1. package/lib/index.d.ts +71 -0
  2. package/lib/index.js +56 -0
  3. package/lib/src/agents.d.ts +347 -0
  4. package/lib/src/agents.js +554 -0
  5. package/lib/src/chart.d.ts +192 -0
  6. package/lib/src/chart.js +638 -0
  7. package/lib/src/config.d.ts +479 -0
  8. package/lib/src/config.js +190 -0
  9. package/lib/src/defaults.d.ts +68 -0
  10. package/lib/src/defaults.js +107 -0
  11. package/lib/src/filesystems.d.ts +208 -0
  12. package/lib/src/filesystems.js +958 -0
  13. package/lib/src/genie.d.ts +166 -0
  14. package/lib/src/genie.js +969 -0
  15. package/lib/src/history.d.ts +97 -0
  16. package/lib/src/history.js +264 -0
  17. package/lib/src/mcp.d.ts +66 -0
  18. package/lib/src/mcp.js +65 -0
  19. package/lib/src/memory.d.ts +111 -0
  20. package/lib/src/memory.js +275 -0
  21. package/lib/src/mlflow.d.ts +63 -0
  22. package/lib/src/mlflow.js +117 -0
  23. package/lib/src/model.d.ts +62 -0
  24. package/lib/src/model.js +168 -0
  25. package/lib/src/observability.d.ts +81 -0
  26. package/lib/src/observability.js +98 -0
  27. package/lib/src/pagination.d.ts +23 -0
  28. package/lib/src/pagination.js +31 -0
  29. package/lib/src/plugin.d.ts +352 -0
  30. package/lib/src/plugin.js +1015 -0
  31. package/lib/src/processors.d.ts +62 -0
  32. package/lib/src/processors.js +162 -0
  33. package/lib/src/rest.d.ts +36 -0
  34. package/lib/src/rest.js +46 -0
  35. package/lib/src/server.d.ts +155 -0
  36. package/lib/src/server.js +336 -0
  37. package/lib/src/serving-sanitize.d.ts +104 -0
  38. package/lib/src/serving-sanitize.js +228 -0
  39. package/lib/src/serving.d.ts +61 -0
  40. package/lib/src/serving.js +78 -0
  41. package/lib/src/statement.d.ts +51 -0
  42. package/lib/src/statement.js +83 -0
  43. package/lib/src/storage-schema.d.ts +14 -0
  44. package/lib/src/storage-schema.js +34 -0
  45. package/lib/src/summarize.d.ts +70 -0
  46. package/lib/src/summarize.js +142 -0
  47. package/lib/src/threads.d.ts +109 -0
  48. package/lib/src/threads.js +301 -0
  49. package/lib/src/validation.d.ts +19 -0
  50. package/lib/src/validation.js +17 -0
  51. package/lib/src/workspaces.d.ts +68 -0
  52. package/lib/src/workspaces.js +246 -0
  53. package/lib/src/writer.d.ts +25 -0
  54. package/lib/src/writer.js +40 -0
  55. package/lib/tsconfig.tsbuildinfo +1 -0
  56. package/package.json +17 -13
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Mastra {@link WorkspaceFilesystem} implementations for Databricks Apps.
3
+ *
4
+ * {@link DatabricksWorkspaceFilesystem} maps a Mastra workspace namespace onto
5
+ * an absolute Databricks path (Unity Catalog volume, workspace object tree, or
6
+ * DBFS). {@link emptyFilesystem} is a read-only no-op mount used when no
7
+ * dynamic mounts resolve for a request.
8
+ *
9
+ * Path helpers ({@link normalizeDatabricksBasePath}, {@link isDbfsPath}, …)
10
+ * are exported for tests and callers that need to reason about Databricks
11
+ * paths without constructing a filesystem.
12
+ *
13
+ * @module
14
+ */
15
+ import { WorkspaceClient } from "@databricks/sdk-experimental";
16
+ import { MastraFilesystem } from "@mastra/core/workspace";
17
+ import type { CopyOptions, FileContent, FileEntry, FileStat, FilesystemInfo, ListOptions, MastraFilesystemOptions, ProviderStatus, ReadOptions, RemoveOptions, WriteOptions } from "@mastra/core/workspace";
18
+ /** How {@link DatabricksWorkspaceFilesystem.init} handles a missing {@link basePath}. */
19
+ export type DatabricksMkdirsMode = boolean | "try";
20
+ /** Options for {@link DatabricksWorkspaceFilesystem}. */
21
+ export interface DatabricksWorkspaceFilesystemOptions extends MastraFilesystemOptions {
22
+ /** Unique identifier for this filesystem instance. */
23
+ id?: string;
24
+ /** Auth-scoped Databricks workspace client. */
25
+ client?: WorkspaceClient;
26
+ /**
27
+ * Absolute Databricks path that roots the workspace namespace, e.g.
28
+ * `/Volumes/catalog/schema/volume` or `/dbfs/FileStore/shared`.
29
+ */
30
+ basePath: string;
31
+ /**
32
+ * When the {@link basePath} is missing at {@link init}, create it with the
33
+ * matching Databricks `mkdirs` API. `"try"` (default) logs at debug and
34
+ * falls back to an empty read-only namespace on failure; `true` fails init;
35
+ * `false` skips creation and uses the empty namespace.
36
+ *
37
+ * A successful mkdir also satisfies the write-access probe when
38
+ * {@link readOnly} is omitted.
39
+ */
40
+ mkdirs?: DatabricksMkdirsMode;
41
+ /** Block writes while still allowing reads. When omitted, {@link init} probes write access. */
42
+ readOnly?: boolean;
43
+ }
44
+ /** Normalize a Databricks base path (POSIX, no trailing slash). */
45
+ export declare function normalizeDatabricksBasePath(basePath: string): string;
46
+ /** True when `absolutePath` is served by DBFS rather than the UC Files API. */
47
+ export declare function isDbfsPath(absolutePath: string): boolean;
48
+ /** True when `absolutePath` is a Databricks workspace object path. */
49
+ export declare function isWorkspaceFilesPath(absolutePath: string): boolean;
50
+ /**
51
+ * Resolve a workspace-relative path to an absolute Databricks path under
52
+ * `basePath`.
53
+ */
54
+ export declare function resolveDatabricksAbsolutePath(basePath: string, inputPath: string): string;
55
+ /** Map an absolute Databricks path back to the workspace namespace. */
56
+ export declare function toDatabricksWorkspacePath(basePath: string, absolutePath: string): string;
57
+ /**
58
+ * Mastra filesystem provider that reads and writes through a Databricks
59
+ * {@link WorkspaceClient}.
60
+ *
61
+ * Workspace paths are absolute within the namespace (`/notes.md` maps to
62
+ * `<basePath>/notes.md`). Unity Catalog volumes use the Files API;
63
+ * `/dbfs/...` paths use DBFS.
64
+ */
65
+ export declare class DatabricksWorkspaceFilesystem extends MastraFilesystem {
66
+ readonly id: string;
67
+ readonly name = "DatabricksWorkspaceFilesystem";
68
+ readonly provider = "databricks";
69
+ readonly basePath: string;
70
+ status: ProviderStatus;
71
+ private readonly client;
72
+ private readonly mkdirs;
73
+ private _readOnly;
74
+ private _basePathMissing;
75
+ get readOnly(): boolean | undefined;
76
+ /**
77
+ * @param options.client - Defaults to the AppKit execution-context client.
78
+ * @param options.mkdirs - Default `"try"`; see {@link DatabricksMkdirsMode}.
79
+ * @param options.readOnly - When omitted, {@link init} probes write access.
80
+ */
81
+ constructor(options: DatabricksWorkspaceFilesystemOptions);
82
+ /** Resolve and sandbox a workspace-relative path under {@link basePath}. */
83
+ private resolvePath;
84
+ /** Map a Databricks absolute path back to the workspace namespace. */
85
+ private workspacePath;
86
+ /** Throw when the filesystem is read-only. */
87
+ private assertWritable;
88
+ /** Map SDK / HTTP errors to Mastra workspace filesystem errors. */
89
+ private rethrow;
90
+ /**
91
+ * Probe whether {@link basePath} exists and cache the result on
92
+ * {@link _basePathMissing}.
93
+ */
94
+ private resolveBasePathStatus;
95
+ /** Delegate to {@link emptyFilesystem} when the base path is missing. */
96
+ private emptyFallback;
97
+ init(): Promise<void>;
98
+ /**
99
+ * Write and delete a ephemeral probe file to detect read-only access when
100
+ * {@link DatabricksWorkspaceFilesystemOptions.readOnly} was not set.
101
+ *
102
+ * @returns `true` when the probe write (and cleanup) succeeded.
103
+ */
104
+ private probeReadOnly;
105
+ destroy(): Promise<void>;
106
+ /** Probe that `absolutePath` exists (file or directory metadata). */
107
+ private assertAbsoluteReadable;
108
+ /** Read the full contents of `absolutePath` from the matching backend. */
109
+ private readAbsolute;
110
+ /** Write `buffer` to `absolutePath` on the matching backend. */
111
+ private writeAbsolute;
112
+ /** Upload a buffer to a Unity Catalog Files API path. */
113
+ private uploadUcFile;
114
+ /** Delete a single file at `absolutePath` (non-recursive). */
115
+ private deleteAbsoluteFile;
116
+ /**
117
+ * Delete a file or directory at `absolutePath`.
118
+ *
119
+ * DBFS and workspace APIs accept `recursive`; UC volumes recurse manually.
120
+ */
121
+ private deleteAbsolutePath;
122
+ /** Create `absolutePath` and any missing parents on the matching backend. */
123
+ private mkdirAbsolute;
124
+ private readDbfsFile;
125
+ private readWorkspaceFile;
126
+ private writeDbfsFile;
127
+ private writeWorkspaceFile;
128
+ getInfo(): FilesystemInfo<{
129
+ basePath: string;
130
+ }>;
131
+ getInstructions(): string;
132
+ /** Map a workspace-relative path to the backing Databricks absolute path. */
133
+ resolveAbsolutePath(inputPath: string): string | undefined;
134
+ /** Read file contents from the workspace namespace. */
135
+ readFile(inputPath: string, options?: ReadOptions): Promise<string | Buffer>;
136
+ /** Write file contents into the workspace namespace. */
137
+ writeFile(inputPath: string, content: FileContent, options?: WriteOptions): Promise<void>;
138
+ /** Append to an existing file, creating it when missing. */
139
+ appendFile(inputPath: string, content: FileContent): Promise<void>;
140
+ /** Delete a file in the workspace namespace. */
141
+ deleteFile(inputPath: string, options?: RemoveOptions): Promise<void>;
142
+ /** Copy a file within the workspace namespace. */
143
+ copyFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
144
+ /** Move or rename a file within the workspace namespace. */
145
+ moveFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
146
+ /** Create a directory in the workspace namespace. */
147
+ mkdir(inputPath: string, options?: {
148
+ recursive?: boolean;
149
+ }): Promise<void>;
150
+ /** Remove a directory from the workspace namespace. */
151
+ rmdir(inputPath: string, options?: RemoveOptions): Promise<void>;
152
+ /**
153
+ * Recursively delete a Unity Catalog directory tree.
154
+ *
155
+ * DBFS and workspace trees use native recursive delete via
156
+ * {@link deleteAbsolutePath} instead.
157
+ */
158
+ private deleteUcDirectoryRecursive;
159
+ /** List entries in a workspace directory. */
160
+ readdir(inputPath: string, options?: ListOptions): Promise<FileEntry[]>;
161
+ private readDirectoryRecursive;
162
+ private listAbsoluteDirectory;
163
+ /** Apply Mastra list filters (`extension`, etc.) to directory entries. */
164
+ private filterEntries;
165
+ /** Return whether `inputPath` exists in the workspace namespace. */
166
+ exists(inputPath: string): Promise<boolean>;
167
+ /** Return file or directory metadata for `inputPath`. */
168
+ stat(inputPath: string): Promise<FileStat>;
169
+ /**
170
+ * Stat a Unity Catalog path by probing file metadata first, then
171
+ * directory metadata.
172
+ */
173
+ private statUcAbsolute;
174
+ }
175
+ /**
176
+ * Read-only in-memory {@link WorkspaceFilesystem} with a single empty root.
177
+ * Use {@link emptyFilesystem} rather than constructing directly.
178
+ */
179
+ declare class EmptyFilesystem extends MastraFilesystem {
180
+ readonly id = "empty-fs";
181
+ readonly name = "EmptyFilesystem";
182
+ readonly provider = "empty";
183
+ readonly readOnly = true;
184
+ status: ProviderStatus;
185
+ constructor();
186
+ init(): Promise<void>;
187
+ destroy(): Promise<void>;
188
+ getInfo(): FilesystemInfo;
189
+ getInstructions(): string;
190
+ private rootStat;
191
+ private assertWritable;
192
+ readFile(inputPath: string, _options?: ReadOptions): Promise<string | Buffer>;
193
+ writeFile(_inputPath: string, _content: FileContent, _options?: WriteOptions): Promise<void>;
194
+ appendFile(_inputPath: string, _content: FileContent): Promise<void>;
195
+ deleteFile(inputPath: string, options?: RemoveOptions): Promise<void>;
196
+ copyFile(src: string, _dest: string, _options?: CopyOptions): Promise<void>;
197
+ moveFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
198
+ mkdir(_inputPath: string, _options?: {
199
+ recursive?: boolean;
200
+ }): Promise<void>;
201
+ rmdir(inputPath: string, options?: RemoveOptions): Promise<void>;
202
+ readdir(inputPath: string, _options?: ListOptions): Promise<FileEntry[]>;
203
+ exists(inputPath: string): Promise<boolean>;
204
+ stat(inputPath: string): Promise<FileStat>;
205
+ }
206
+ /** Memoized singleton empty read-only filesystem for no-op mounts. */
207
+ export declare const emptyFilesystem: () => EmptyFilesystem;
208
+ export {};