@dbx-tools/appkit-mastra 0.9.74 → 0.9.79

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.
@@ -1,70 +1,94 @@
1
1
  /**
2
- * AppKit-backed caching for Databricks workspace skill mounts.
2
+ * User-scoped workspace skill catalogues cached as one semantic record.
3
3
  *
4
4
  * @module
5
5
  */
6
- import type { CopyOptions, FileContent, FileEntry, FileStat, FileSystem, ListOptions, MakeDirectoryOptions, ReadFileOptions, RemoveOptions, WriteFileOptions } from "@dbx-tools/shared-fs";
7
- import { type MastraFileSystemAdapter } from "./filesystems.ts";
8
- /** Default remote skill metadata and content cache lifetime. */
9
- export declare const DEFAULT_WORKSPACE_SKILL_CACHE_TTL_MS: number;
10
- /** Options for one AppKit-cached workspace skill filesystem. */
11
- export interface AppKitCachedFileSystemOptions {
6
+ import type { RequestContext } from "@mastra/core/request-context";
7
+ import { z } from "zod";
8
+ declare const SkillCatalogueEntrySchema: z.ZodObject<{
9
+ name: z.ZodString;
10
+ description: z.ZodString;
11
+ instructions: z.ZodString;
12
+ sourceId: z.ZodString;
13
+ sourcePath: z.ZodString;
14
+ signature: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ declare const SkillCatalogueSchema: z.ZodObject<{
17
+ version: z.ZodLiteral<1>;
18
+ generatedAt: z.ZodString;
19
+ roots: z.ZodArray<z.ZodString>;
20
+ skills: z.ZodArray<z.ZodObject<{
21
+ name: z.ZodString;
22
+ description: z.ZodString;
23
+ instructions: z.ZodString;
24
+ sourceId: z.ZodString;
25
+ sourcePath: z.ZodString;
26
+ signature: z.ZodOptional<z.ZodString>;
27
+ }, z.core.$strip>>;
28
+ }, z.core.$strip>;
29
+ /** Parsed skill retained in a materialized workspace catalogue. */
30
+ export type SkillCatalogueEntry = z.infer<typeof SkillCatalogueEntrySchema>;
31
+ /** Versioned persisted skill catalogue. */
32
+ export type SkillCatalogue = z.infer<typeof SkillCatalogueSchema>;
33
+ /** One ordered filesystem root contributing skills to a catalogue. */
34
+ export interface SkillCatalogueSource {
35
+ /** Stable source identity including its mount precedence. */
36
+ id: string;
37
+ /** List one source-relative directory with provider metadata when available. */
38
+ list(path: string): Promise<SkillCatalogueFileEntry[]>;
39
+ /** Read one source-relative file fresh from its owning filesystem. */
40
+ read(path: string): Promise<string>;
41
+ }
42
+ /** Minimal directory metadata used to compare one catalogue refresh. */
43
+ export interface SkillCatalogueFileEntry {
44
+ metadata?: Readonly<Record<string, unknown>>;
45
+ name: string;
46
+ size?: number;
47
+ type: "directory" | "file";
48
+ }
49
+ /** Options for one user-scoped workspace skill catalogue. */
50
+ export interface WorkspaceSkillCatalogueOptions {
12
51
  host: string;
13
- source: FileSystem;
52
+ sources: readonly SkillCatalogueSource[];
14
53
  ttlMs?: number;
15
54
  userKey: string;
16
55
  }
17
- /** Stable Mastra mount plus the identity key used for source reuse. */
18
- export interface CachedWorkspaceSkillMount {
19
- cacheKey: string;
20
- filesystem: MastraFileSystemAdapter;
56
+ /** Request state used to resolve one user-scoped catalogue owner. */
57
+ export interface SkillCatalogueResolveContext {
58
+ abortSignal?: AbortSignal;
59
+ requestContext?: RequestContext;
21
60
  }
22
- /**
23
- * Cache read-only filesystem operations through AppKit while delegating
24
- * mutations to the current request's source.
25
- */
26
- export declare class AppKitCachedFileSystem implements FileSystem<"appkit-cache"> {
27
- readonly backend: "appkit-cache";
28
- readonly id: string;
29
- readonly readOnly: boolean;
30
- readonly root: string;
31
- private source;
32
- private readonly host;
33
- private readonly ttlSec;
34
- private readonly userKey;
35
- constructor(options: AppKitCachedFileSystemOptions);
36
- /** Rebind cache misses and writes to the current request's OBO filesystem. */
37
- bind(source: FileSystem): void;
38
- init(): Promise<void>;
39
- /** Keep the shared scope alive when one request releases its workspace view. */
40
- close(): Promise<void>;
41
- resolvePath(inputPath: string): string;
42
- readFile(inputPath: string): Promise<Uint8Array>;
43
- readFile(inputPath: string, options: ReadFileOptions & {
44
- encoding: string;
45
- }): Promise<string>;
46
- writeFile(inputPath: string, content: FileContent, options?: WriteFileOptions): Promise<void>;
47
- appendFile(inputPath: string, content: FileContent): Promise<void>;
48
- deleteFile(inputPath: string, options?: RemoveOptions): Promise<void>;
49
- copyFile(sourcePath: string, destinationPath: string, options?: CopyOptions): Promise<void>;
50
- moveFile(sourcePath: string, destinationPath: string, options?: CopyOptions): Promise<void>;
51
- mkdir(inputPath: string, options?: MakeDirectoryOptions): Promise<void>;
52
- rmdir(inputPath: string, options?: RemoveOptions): Promise<void>;
53
- readdir(inputPath: string, options?: ListOptions): Promise<FileEntry[]>;
54
- exists(inputPath: string): Promise<boolean>;
55
- stat(inputPath: string): Promise<FileStat>;
56
- /** Rotate this scope's cache generation so the next read reloads it. */
61
+ /** Resolve one request's complete skill catalogue. */
62
+ export type SkillCatalogueResolver = (context: SkillCatalogueResolveContext) => Promise<WorkspaceSkillCatalogue>;
63
+ /** Default lifetime for one complete workspace skill catalogue. */
64
+ export declare const DEFAULT_WORKSPACE_SKILL_CACHE_TTL_MS: number;
65
+ /** Materialized catalogue with one AppKit cache record and fresh auxiliary reads. */
66
+ export declare class WorkspaceSkillCatalogue {
67
+ private readonly options;
68
+ readonly cacheKey: string;
69
+ readonly host: string;
70
+ readonly userKey: string;
71
+ private lastValid?;
72
+ private readonly ttlMs;
73
+ private sources;
74
+ constructor(options: WorkspaceSkillCatalogueOptions);
75
+ /** Rebind refreshes and lazy reads to the current request's filesystem clients. */
76
+ bind(sources: readonly SkillCatalogueSource[]): void;
77
+ /** Return the cached catalogue, refreshing all roots once on cache miss. */
78
+ get(signal?: AbortSignal): Promise<SkillCatalogue>;
79
+ /** Expire this complete catalogue without touching unrelated cache entries. */
57
80
  invalidate(): Promise<void>;
58
- private cached;
59
- private generation;
60
- private generationKey;
61
- private mutate;
81
+ /** Read one selected skill's auxiliary file directly from its current source. */
82
+ readSkillFile(skillName: string, inputPath: string, signal?: AbortSignal): Promise<string>;
83
+ private refresh;
84
+ private rootKey;
85
+ private persistentKey;
62
86
  }
63
- /** Return one stable Mastra mount per resolved user, host, and source root. */
64
- export declare function cachedWorkspaceSkillMount(options: AppKitCachedFileSystemOptions): CachedWorkspaceSkillMount;
65
- /** Invalidate one user's cached workspace skill scope. */
87
+ /** Return one stable catalogue owner for a user, host, and ordered root set. */
88
+ export declare function workspaceSkillCatalogue(options: WorkspaceSkillCatalogueOptions): WorkspaceSkillCatalogue;
89
+ /** Invalidate matching complete catalogues and retain their stable owners. */
66
90
  export declare function clearWorkspaceSkillCache(options: {
67
91
  host: string;
68
- root?: string;
69
- userKey: string;
92
+ userKey?: string;
70
93
  }): Promise<void>;
94
+ export {};